class-transformer
Advanced tools
Comparing version 0.1.10 to 0.2.0
@@ -13,3 +13,3 @@ define("class-transformer/ClassTransformOptions", ["require", "exports"], function (require, exports) { | ||
var TypeMetadata = /** @class */ (function () { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction) { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction, options) { | ||
this.target = target; | ||
@@ -19,2 +19,3 @@ this.propertyName = propertyName; | ||
this.typeFunction = typeFunction; | ||
this.options = options; | ||
} | ||
@@ -301,3 +302,3 @@ return TypeMetadata; | ||
// ------------------------------------------------------------------------- | ||
this.transformedTypesMap = new Map(); | ||
this.recursionStack = new Set(); | ||
} | ||
@@ -310,8 +311,28 @@ // ------------------------------------------------------------------------- | ||
if (level === void 0) { level = 0; } | ||
if (value instanceof Array || value instanceof Set) { | ||
if (Array.isArray(value) || value instanceof Set) { | ||
var newValue_1 = arrayType && this.transformationType === TransformationType.PLAIN_TO_CLASS ? new arrayType() : []; | ||
value.forEach(function (subValue, index) { | ||
var subSource = source ? source[index] : undefined; | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue, level)) { | ||
var value_1 = _this.transform(subSource, subValue, targetType, undefined, subValue instanceof Map, level + 1); | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue)) { | ||
var realTargetType = void 0; | ||
if (typeof targetType !== "function" && targetType && targetType.options && targetType.options.discriminator && targetType.options.discriminator.property && targetType.options.discriminator.subTypes) { | ||
if (_this.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
realTargetType = targetType.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[targetType.options.discriminator.property]; }); | ||
var options = { newObject: newValue_1, object: subValue, property: undefined }; | ||
var newType = targetType.typeFunction(options); | ||
realTargetType === undefined ? realTargetType = newType : realTargetType = realTargetType.value; | ||
if (!targetType.options.keepDiscriminatorProperty) | ||
delete subValue[targetType.options.discriminator.property]; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
realTargetType = subValue.constructor; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[targetType.options.discriminator.property] = targetType.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
realTargetType = targetType; | ||
} | ||
var value_1 = _this.transform(subSource, subValue, realTargetType, undefined, subValue instanceof Map, level + 1); | ||
if (newValue_1 instanceof Set) { | ||
@@ -336,8 +357,14 @@ newValue_1.add(value_1); | ||
else if (targetType === String && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return String(value); | ||
} | ||
else if (targetType === Number && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Number(value); | ||
} | ||
else if (targetType === Boolean && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Boolean(value); | ||
@@ -361,3 +388,3 @@ } | ||
// add transformed type to prevent circular references | ||
this.transformedTypesMap.set(value, { level: level, object: value }); | ||
this.recursionStack.add(value); | ||
} | ||
@@ -389,4 +416,5 @@ var keys = this.getKeys(targetType, value); | ||
var exposeMetadata = storage_1.defaultMetadataStorage.findExposeMetadata(targetType, key); | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) { | ||
newValueKey = exposeMetadata.options.name; | ||
} | ||
} | ||
@@ -411,7 +439,29 @@ } | ||
else if (targetType) { | ||
var metadata = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata) { | ||
var metadata_1 = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata_1) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
type = metadata.typeFunction(options); | ||
isSubValueMap = isSubValueMap || metadata.reflectedType === Map; | ||
var newType = metadata_1.typeFunction(options); | ||
if (metadata_1.options && metadata_1.options.discriminator && metadata_1.options.discriminator.property && metadata_1.options.discriminator.subTypes) { | ||
if (!(value[valueKey] instanceof Array)) { | ||
if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
type = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[metadata_1.options.discriminator.property]; }); | ||
type === undefined ? type = newType : type = type.value; | ||
if (!metadata_1.options.keepDiscriminatorProperty) | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
type = subValue.constructor; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[metadata_1.options.discriminator.property] = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
type = metadata_1; | ||
} | ||
} | ||
else { | ||
type = newType; | ||
} | ||
isSubValueMap = isSubValueMap || metadata_1.reflectedType === Map; | ||
} | ||
@@ -425,3 +475,3 @@ else if (this_1.options.targetMaps) { // try to find a type in target maps | ||
// if value is an array try to get its custom array type | ||
var arrayType_1 = value[valueKey] instanceof Array ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
var arrayType_1 = Array.isArray(value[valueKey]) ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
// const subValueKey = TransformationType === TransformationType.PLAIN_TO_CLASS && newKeyName ? newKeyName : key; | ||
@@ -440,6 +490,19 @@ var subSource = source ? source[valueKey] : undefined; | ||
} | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue, level)) { | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue)) { | ||
var transformKey = this_1.transformationType === TransformationType.PLAIN_TO_CLASS ? newValueKey : key; | ||
var finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
var finalValue = void 0; | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
// Get original value | ||
finalValue = value[transformKey]; | ||
// Apply custom transformation | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
// If nothing change, it means no custom transformation was applied, so use the subValue. | ||
finalValue = (value[transformKey] === finalValue) ? subValue : finalValue; | ||
// Apply the default transformation | ||
finalValue = this_1.transform(subSource, finalValue, type, arrayType_1, isSubValueMap, level + 1); | ||
} | ||
else { | ||
finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
} | ||
if (newValue instanceof Map) { | ||
@@ -469,2 +532,5 @@ newValue.set(newValueKey, finalValue); | ||
} | ||
if (this.options.enableCircularCheck) { | ||
this.recursionStack.delete(value); | ||
} | ||
return newValue; | ||
@@ -506,5 +572,4 @@ } | ||
// preventing circular references | ||
TransformOperationExecutor.prototype.isCircular = function (object, level) { | ||
var transformed = this.transformedTypesMap.get(object); | ||
return transformed !== undefined && transformed.level < level; | ||
TransformOperationExecutor.prototype.isCircular = function (object) { | ||
return this.recursionStack.has(object); | ||
}; | ||
@@ -673,7 +738,8 @@ TransformOperationExecutor.prototype.getReflectedType = function (target, propertyName) { | ||
* Specifies a type of the property. | ||
* The given TypeFunction can return a constructor. A discriminator can be given in the options. | ||
*/ | ||
function Type(typeFunction) { | ||
function Type(typeFunction, options) { | ||
return function (target, key) { | ||
var type = Reflect.getMetadata("design:type", target, key); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction, options); | ||
storage_2.defaultMetadataStorage.addTypeMetadata(metadata); | ||
@@ -745,2 +811,21 @@ }; | ||
exports.TransformClassToClass = TransformClassToClass; | ||
/** | ||
* Return the class instance only with the exposed properties. | ||
*/ | ||
function TransformPlainToClass(classType, params) { | ||
return function (target, propertyKey, descriptor) { | ||
var classTransformer = new ClassTransformer_1.ClassTransformer(); | ||
var originalMethod = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var result = originalMethod.apply(this, args); | ||
var isPromise = !!result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function"; | ||
return isPromise ? result.then(function (data) { return classTransformer.plainToClass(classType, data, params); }) : classTransformer.plainToClass(classType, result, params); | ||
}; | ||
}; | ||
} | ||
exports.TransformPlainToClass = TransformPlainToClass; | ||
}); | ||
@@ -747,0 +832,0 @@ define("class-transformer/index", ["require", "exports", "class-transformer/ClassTransformer", "class-transformer/ClassTransformer", "class-transformer/decorators"], function (require, exports, ClassTransformer_2, ClassTransformer_3, decorators_1) { |
@@ -1,1 +0,1 @@ | ||
define("class-transformer/ClassTransformOptions",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}),define("class-transformer/metadata/ExposeExcludeOptions",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}),define("class-transformer/metadata/TypeMetadata",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r,a){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=a}return t}();e.TypeMetadata=r}),define("class-transformer/metadata/ExposeMetadata",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}();e.ExposeMetadata=r}),define("class-transformer/metadata/ExcludeMetadata",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}();e.ExcludeMetadata=r}),define("class-transformer/metadata/TransformMetadata",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r,a){this.target=t,this.propertyName=e,this.transformFn=r,this.options=a}return t}();e.TransformMetadata=r}),define("class-transformer/metadata/MetadataStorage",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,a){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?a===r.TransformationType.CLASS_TO_CLASS||a===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||a===r.TransformationType.CLASS_TO_PLAIN))})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),a=this._exposeMetadatas.get(t),o=a&&a.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,a=t.get(e);a&&(r=Array.from(a.values()).filter(function(t){return void 0!==t.propertyName}));for(var o=[],n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=Array.from(p.values()).filter(function(t){return void 0!==t.propertyName});o.push.apply(o,f)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var a=t.get(e);if(a){var o=a.get(r);if(o)return o}for(var n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=p.get(r);if(f)return f}}},t.prototype.findMetadatas=function(t,e,r){var a,o=t.get(e);o&&(a=o.get(r));for(var n=[],s=0,i=this.getAncestors(e);s<i.length;s++){var p=i[s],f=t.get(p);f&&f.has(r)&&n.push.apply(n,f.get(r))}return n.reverse().concat((a||[]).reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}();e.MetadataStorage=a}),define("class-transformer/storage",["require","exports","class-transformer/metadata/MetadataStorage"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultMetadataStorage=new r.MetadataStorage}),define("class-transformer/TransformOperationExecutor",["require","exports","class-transformer/storage"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(a=e.TransformationType||(e.TransformationType={}));var o=function(){function t(t,e){this.transformationType=t,this.options=e,this.transformedTypesMap=new Map}return t.prototype.transform=function(t,e,o,n,s,i){var p=this;if(void 0===i&&(i=0),e instanceof Array||e instanceof Set){var f=n&&this.transformationType===a.PLAIN_TO_CLASS?new n:[];return e.forEach(function(e,r){var n=t?t[r]:void 0;if(p.options.enableCircularCheck&&p.isCircular(e,i))p.transformationType===a.CLASS_TO_CLASS&&(f instanceof Set?f.add(e):f.push(e));else{var s=p.transform(n,e,o,void 0,e instanceof Map,i+1);f instanceof Set?f.add(s):f.push(s)}}),f}if(o!==String||s){if(o!==Number||s){if(o!==Boolean||s){if((o===Date||e instanceof Date)&&!s)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if("object"==typeof e&&null!==e){o||e.constructor===Object||(o=e.constructor),!o&&t&&(o=t.constructor),this.options.enableCircularCheck&&this.transformedTypesMap.set(e,{level:i,object:e});var u=this.getKeys(o,e),c=t||{};t||this.transformationType!==a.PLAIN_TO_CLASS&&this.transformationType!==a.CLASS_TO_CLASS||(c=s?new Map:o?new o:{});for(var d=this,l=0,y=u;l<y.length;l++){var m=y[l];!function(n){var p=n,f=n,u=n;if(!d.options.ignoreDecorators&&o)if(d.transformationType===a.PLAIN_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadataByCustomName(o,n);l&&(u=l.propertyName,f=l.propertyName)}else if(d.transformationType===a.CLASS_TO_PLAIN||d.transformationType===a.CLASS_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadata(o,n);l&&l.options&&l.options.name&&(f=l.options.name)}var y=void 0;y=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var m=void 0,T=y instanceof Map;if(o&&s)m=o;else if(o){var M=r.defaultMetadataStorage.findTypeMetadata(o,u);if(M){var h={newObject:c,object:e,property:u};m=M.typeFunction(h),T=T||M.reflectedType===Map}else d.options.targetMaps&&d.options.targetMaps.filter(function(t){return t.target===o&&!!t.properties[u]}).forEach(function(t){return m=t.properties[u]})}var v=e[p]instanceof Array?d.getReflectedType(o,u):void 0,_=t?t[p]:void 0;if(c.constructor.prototype){var S=Object.getOwnPropertyDescriptor(c.constructor.prototype,f);if((d.transformationType===a.PLAIN_TO_CLASS||d.transformationType===a.CLASS_TO_CLASS)&&(c[f]instanceof Function||S&&!S.set))return"continue"}if(d.options.enableCircularCheck&&d.isCircular(y,i)){if(d.transformationType===a.CLASS_TO_CLASS){var g=y;g=d.applyCustomTransformations(g,o,n,e,d.transformationType),c instanceof Map?c.set(f,g):c[f]=g}}else{var C=d.transformationType===a.PLAIN_TO_CLASS?f:n,g=d.transform(_,y,m,v,T,i+1);g=d.applyCustomTransformations(g,o,C,e,d.transformationType),c instanceof Map?c.set(f,g):c[f]=g}}(m)}return c}return e}return Boolean(e)}return Number(e)}return String(e)},t.prototype.applyCustomTransformations=function(t,e,a,o,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,a,this.transformationType);return void 0!==this.options.version&&(i=i.filter(function(t){return!t.options||s.checkVersion(t.options.since,t.options.until)})),i=this.options.groups&&this.options.groups.length?i.filter(function(t){return!t.options||s.checkGroups(t.options.groups)}):i.filter(function(t){return!t.options||!t.options.groups||!t.options.groups.length}),i.forEach(function(e){t=e.transformFn(t,o,n)}),t},t.prototype.isCircular=function(t,e){var r=this.transformedTypesMap.get(t);return void 0!==r&&r.level<e},t.prototype.getReflectedType=function(t,e){if(t){var a=r.defaultMetadataStorage.findTypeMetadata(t,e);return a?a.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,n=r.defaultMetadataStorage.getStrategy(t);"none"===n&&(n=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===n&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=r.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===a.PLAIN_TO_CLASS&&(i=i.map(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return a&&a.options&&a.options.name?a.options.name:e})),s=s.concat(i);var p=r.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);p.length>0&&(s=s.filter(function(t){return-1===p.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkGroups(a.options.groups)}):s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(a&&a.options&&a.options.groups&&a.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return o.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s=s.filter(function(t,e,r){return r.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return-1!==t.indexOf(e)})},t}();e.TransformOperationExecutor=o}),define("class-transformer/ClassTransformer",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){}return t.prototype.classToPlain=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t.prototype.deserializeArray=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t}();e.ClassTransformer=a}),define("class-transformer/decorators",["require","exports","class-transformer/ClassTransformer","class-transformer/storage","class-transformer/metadata/TypeMetadata","class-transformer/metadata/ExposeMetadata","class-transformer/metadata/ExcludeMetadata","class-transformer/metadata/TransformMetadata"],function(t,e,r,a,o,n,s,i){"use strict";function p(t,e){return function(r,o){var n=new i.TransformMetadata(r.constructor,o,t,e);a.defaultMetadataStorage.addTransformMetadata(n)}}function f(t){return function(e,r){var n=Reflect.getMetadata("design:type",e,r),s=new o.TypeMetadata(e.constructor,r,n,t);a.defaultMetadataStorage.addTypeMetadata(s)}}function u(t){return function(e,r){var o=new n.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});a.defaultMetadataStorage.addExposeMetadata(o)}}function c(t){return function(e,r){var o=new s.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});a.defaultMetadataStorage.addExcludeMetadata(o)}}function d(t){return function(e,a,o){var n=new r.ClassTransformer,s=o.value;o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=s.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?n.classToPlain(a,t):a.then(function(e){return n.classToPlain(e,t)})}}}function l(t){return function(e,a,o){var n=new r.ClassTransformer,s=o.value;o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=s.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?n.classToClass(a,t):a.then(function(e){return n.classToClass(e,t)})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.Transform=p,e.Type=f,e.Expose=u,e.Exclude=c,e.TransformClassToPlain=d,e.TransformClassToClass=l}),define("class-transformer/index",["require","exports","class-transformer/ClassTransformer","class-transformer/ClassTransformer","class-transformer/decorators"],function(t,e,r,a,o){"use strict";function n(t,e){return y.classToPlain(t,e)}function s(t,e,r){return y.classToPlainFromExist(t,e,r)}function i(t,e,r){return y.plainToClass(t,e,r)}function p(t,e,r){return y.plainToClassFromExist(t,e,r)}function f(t,e){return y.classToClass(t,e)}function u(t,e,r){return y.classToClassFromExist(t,e,r)}function c(t,e){return y.serialize(t,e)}function d(t,e,r){return y.deserialize(t,e,r)}function l(t,e,r){return y.deserializeArray(t,e,r)}Object.defineProperty(e,"__esModule",{value:!0}),e.ClassTransformer=a.ClassTransformer,function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(o);var y=new r.ClassTransformer;e.classToPlain=n,e.classToPlainFromExist=s,e.plainToClass=i,e.plainToClassFromExist=p,e.classToClass=f,e.classToClassFromExist=u,e.serialize=c,e.deserialize=d,e.deserializeArray=l;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(e.TransformationType||(e.TransformationType={}))}),define("class-transformer",["require","exports","class-transformer/index"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(r)}); | ||
define("class-transformer/ClassTransformOptions",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}),define("class-transformer/metadata/ExposeExcludeOptions",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})}),define("class-transformer/metadata/TypeMetadata",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r,a,o){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=a,this.options=o}return t}();e.TypeMetadata=r}),define("class-transformer/metadata/ExposeMetadata",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}();e.ExposeMetadata=r}),define("class-transformer/metadata/ExcludeMetadata",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}();e.ExcludeMetadata=r}),define("class-transformer/metadata/TransformMetadata",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r,a){this.target=t,this.propertyName=e,this.transformFn=r,this.options=a}return t}();e.TransformMetadata=r}),define("class-transformer/metadata/MetadataStorage",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,a){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?a===r.TransformationType.CLASS_TO_CLASS||a===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||a===r.TransformationType.CLASS_TO_PLAIN))})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),a=this._exposeMetadatas.get(t),o=a&&a.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,a=t.get(e);a&&(r=Array.from(a.values()).filter(function(t){return void 0!==t.propertyName}));for(var o=[],n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=Array.from(p.values()).filter(function(t){return void 0!==t.propertyName});o.push.apply(o,f)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var a=t.get(e);if(a){var o=a.get(r);if(o)return o}for(var n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=p.get(r);if(f)return f}}},t.prototype.findMetadatas=function(t,e,r){var a,o=t.get(e);o&&(a=o.get(r));for(var n=[],s=0,i=this.getAncestors(e);s<i.length;s++){var p=i[s],f=t.get(p);f&&f.has(r)&&n.push.apply(n,f.get(r))}return n.reverse().concat((a||[]).reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}();e.MetadataStorage=a}),define("class-transformer/storage",["require","exports","class-transformer/metadata/MetadataStorage"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.defaultMetadataStorage=new r.MetadataStorage}),define("class-transformer/TransformOperationExecutor",["require","exports","class-transformer/storage"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(a=e.TransformationType||(e.TransformationType={}));var o=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,o,n,s,i){var p=this;if(void 0===i&&(i=0),Array.isArray(e)||e instanceof Set){var f=n&&this.transformationType===a.PLAIN_TO_CLASS?new n:[];return e.forEach(function(e,r){var n=t?t[r]:void 0;if(p.options.enableCircularCheck&&p.isCircular(e))p.transformationType===a.CLASS_TO_CLASS&&(f instanceof Set?f.add(e):f.push(e));else{var s=void 0;if("function"!=typeof o&&o&&o.options&&o.options.discriminator&&o.options.discriminator.property&&o.options.discriminator.subTypes){if(p.transformationType===a.PLAIN_TO_CLASS){s=o.options.discriminator.subTypes.find(function(t){return t.name===e[o.options.discriminator.property]});var u={newObject:f,object:e,property:void 0},c=o.typeFunction(u);s=void 0===s?c:s.value,o.options.keepDiscriminatorProperty||delete e[o.options.discriminator.property]}p.transformationType===a.CLASS_TO_CLASS&&(s=e.constructor),p.transformationType===a.CLASS_TO_PLAIN&&(e[o.options.discriminator.property]=o.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else s=o;var d=p.transform(n,e,s,void 0,e instanceof Map,i+1);f instanceof Set?f.add(d):f.push(d)}}),f}if(o!==String||s){if(o!==Number||s){if(o!==Boolean||s){if((o===Date||e instanceof Date)&&!s)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if("object"==typeof e&&null!==e){o||e.constructor===Object||(o=e.constructor),!o&&t&&(o=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var u=this.getKeys(o,e),c=t||{};t||this.transformationType!==a.PLAIN_TO_CLASS&&this.transformationType!==a.CLASS_TO_CLASS||(c=s?new Map:o?new o:{});for(var d=this,l=0,y=u;l<y.length;l++){var m=y[l];!function(n){var p=n,f=n,u=n;if(!d.options.ignoreDecorators&&o)if(d.transformationType===a.PLAIN_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadataByCustomName(o,n);l&&(u=l.propertyName,f=l.propertyName)}else if(d.transformationType===a.CLASS_TO_PLAIN||d.transformationType===a.CLASS_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadata(o,n);l&&l.options&&l.options.name&&(f=l.options.name)}var y=void 0;y=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var m=void 0,T=y instanceof Map;if(o&&s)m=o;else if(o){var S=r.defaultMetadataStorage.findTypeMetadata(o,u);if(S){var v={newObject:c,object:e,property:u},_=S.typeFunction(v);S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[p]instanceof Array?m=S:(d.transformationType===a.PLAIN_TO_CLASS&&(m=S.options.discriminator.subTypes.find(function(t){return t.name===y[S.options.discriminator.property]}),m=void 0===m?_:m.value,S.options.keepDiscriminatorProperty||delete y[S.options.discriminator.property]),d.transformationType===a.CLASS_TO_CLASS&&(m=y.constructor),d.transformationType===a.CLASS_TO_PLAIN&&(y[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===y.constructor}).name)):m=_,T=T||S.reflectedType===Map}else d.options.targetMaps&&d.options.targetMaps.filter(function(t){return t.target===o&&!!t.properties[u]}).forEach(function(t){return m=t.properties[u]})}var h=Array.isArray(e[p])?d.getReflectedType(o,u):void 0,M=t?t[p]:void 0;if(c.constructor.prototype){var g=Object.getOwnPropertyDescriptor(c.constructor.prototype,f);if((d.transformationType===a.PLAIN_TO_CLASS||d.transformationType===a.CLASS_TO_CLASS)&&(c[f]instanceof Function||g&&!g.set))return"continue"}if(d.options.enableCircularCheck&&d.isCircular(y)){if(d.transformationType===a.CLASS_TO_CLASS){var C=y;C=d.applyCustomTransformations(C,o,n,e,d.transformationType),c instanceof Map?c.set(f,C):c[f]=C}}else{var A=d.transformationType===a.PLAIN_TO_CLASS?f:n,C=void 0;d.transformationType===a.CLASS_TO_PLAIN?(C=e[A],C=d.applyCustomTransformations(C,o,A,e,d.transformationType),C=e[A]===C?y:C,C=d.transform(M,C,m,h,T,i+1)):(C=d.transform(M,y,m,h,T,i+1),C=d.applyCustomTransformations(C,o,A,e,d.transformationType)),c instanceof Map?c.set(f,C):c[f]=C}}(m)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),c}return e}return null===e||void 0===e?e:Boolean(e)}return null===e||void 0===e?e:Number(e)}return null===e||void 0===e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,a,o,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,a,this.transformationType);return void 0!==this.options.version&&(i=i.filter(function(t){return!t.options||s.checkVersion(t.options.since,t.options.until)})),i=this.options.groups&&this.options.groups.length?i.filter(function(t){return!t.options||s.checkGroups(t.options.groups)}):i.filter(function(t){return!t.options||!t.options.groups||!t.options.groups.length}),i.forEach(function(e){t=e.transformFn(t,o,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var a=r.defaultMetadataStorage.findTypeMetadata(t,e);return a?a.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,n=r.defaultMetadataStorage.getStrategy(t);"none"===n&&(n=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===n&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=r.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===a.PLAIN_TO_CLASS&&(i=i.map(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return a&&a.options&&a.options.name?a.options.name:e})),s=s.concat(i);var p=r.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);p.length>0&&(s=s.filter(function(t){return-1===p.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkGroups(a.options.groups)}):s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(a&&a.options&&a.options.groups&&a.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return o.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s=s.filter(function(t,e,r){return r.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return-1!==t.indexOf(e)})},t}();e.TransformOperationExecutor=o}),define("class-transformer/ClassTransformer",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){}return t.prototype.classToPlain=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t.prototype.deserializeArray=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t}();e.ClassTransformer=a}),define("class-transformer/decorators",["require","exports","class-transformer/ClassTransformer","class-transformer/storage","class-transformer/metadata/TypeMetadata","class-transformer/metadata/ExposeMetadata","class-transformer/metadata/ExcludeMetadata","class-transformer/metadata/TransformMetadata"],function(t,e,r,a,o,n,s,i){"use strict";function p(t,e){return function(r,o){var n=new i.TransformMetadata(r.constructor,o,t,e);a.defaultMetadataStorage.addTransformMetadata(n)}}function f(t,e){return function(r,n){var s=Reflect.getMetadata("design:type",r,n),i=new o.TypeMetadata(r.constructor,n,s,t,e);a.defaultMetadataStorage.addTypeMetadata(i)}}function u(t){return function(e,r){var o=new n.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});a.defaultMetadataStorage.addExposeMetadata(o)}}function c(t){return function(e,r){var o=new s.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});a.defaultMetadataStorage.addExcludeMetadata(o)}}function d(t){return function(e,a,o){var n=new r.ClassTransformer,s=o.value;o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=s.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?n.classToPlain(a,t):a.then(function(e){return n.classToPlain(e,t)})}}}function l(t){return function(e,a,o){var n=new r.ClassTransformer,s=o.value;o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=s.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?n.classToClass(a,t):a.then(function(e){return n.classToClass(e,t)})}}}function y(t,e){return function(a,o,n){var s=new r.ClassTransformer,i=n.value;n.value=function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];var o=i.apply(this,r);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?s.plainToClass(t,o,e):o.then(function(r){return s.plainToClass(t,r,e)})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.Transform=p,e.Type=f,e.Expose=u,e.Exclude=c,e.TransformClassToPlain=d,e.TransformClassToClass=l,e.TransformPlainToClass=y}),define("class-transformer/index",["require","exports","class-transformer/ClassTransformer","class-transformer/ClassTransformer","class-transformer/decorators"],function(t,e,r,a,o){"use strict";function n(t,e){return y.classToPlain(t,e)}function s(t,e,r){return y.classToPlainFromExist(t,e,r)}function i(t,e,r){return y.plainToClass(t,e,r)}function p(t,e,r){return y.plainToClassFromExist(t,e,r)}function f(t,e){return y.classToClass(t,e)}function u(t,e,r){return y.classToClassFromExist(t,e,r)}function c(t,e){return y.serialize(t,e)}function d(t,e,r){return y.deserialize(t,e,r)}function l(t,e,r){return y.deserializeArray(t,e,r)}Object.defineProperty(e,"__esModule",{value:!0}),e.ClassTransformer=a.ClassTransformer,function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(o);var y=new r.ClassTransformer;e.classToPlain=n,e.classToPlainFromExist=s,e.plainToClass=i,e.plainToClassFromExist=p,e.classToClass=f,e.classToClassFromExist=u,e.serialize=c,e.deserialize=d,e.deserializeArray=l;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(e.TransformationType||(e.TransformationType={}))}),define("class-transformer",["require","exports","class-transformer/index"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(r)}); |
@@ -10,3 +10,3 @@ define("class-transformer/ClassTransformOptions", ["require", "exports"], function (require, exports) { | ||
var TypeMetadata = /** @class */ (function () { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction) { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction, options) { | ||
this.target = target; | ||
@@ -16,2 +16,3 @@ this.propertyName = propertyName; | ||
this.typeFunction = typeFunction; | ||
this.options = options; | ||
} | ||
@@ -292,3 +293,3 @@ return TypeMetadata; | ||
// ------------------------------------------------------------------------- | ||
this.transformedTypesMap = new Map(); | ||
this.recursionStack = new Set(); | ||
} | ||
@@ -301,8 +302,28 @@ // ------------------------------------------------------------------------- | ||
if (level === void 0) { level = 0; } | ||
if (value instanceof Array || value instanceof Set) { | ||
if (Array.isArray(value) || value instanceof Set) { | ||
var newValue_1 = arrayType && this.transformationType === TransformationType.PLAIN_TO_CLASS ? new arrayType() : []; | ||
value.forEach(function (subValue, index) { | ||
var subSource = source ? source[index] : undefined; | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue, level)) { | ||
var value_1 = _this.transform(subSource, subValue, targetType, undefined, subValue instanceof Map, level + 1); | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue)) { | ||
var realTargetType = void 0; | ||
if (typeof targetType !== "function" && targetType && targetType.options && targetType.options.discriminator && targetType.options.discriminator.property && targetType.options.discriminator.subTypes) { | ||
if (_this.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
realTargetType = targetType.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[targetType.options.discriminator.property]; }); | ||
var options = { newObject: newValue_1, object: subValue, property: undefined }; | ||
var newType = targetType.typeFunction(options); | ||
realTargetType === undefined ? realTargetType = newType : realTargetType = realTargetType.value; | ||
if (!targetType.options.keepDiscriminatorProperty) | ||
delete subValue[targetType.options.discriminator.property]; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
realTargetType = subValue.constructor; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[targetType.options.discriminator.property] = targetType.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
realTargetType = targetType; | ||
} | ||
var value_1 = _this.transform(subSource, subValue, realTargetType, undefined, subValue instanceof Map, level + 1); | ||
if (newValue_1 instanceof Set) { | ||
@@ -327,8 +348,14 @@ newValue_1.add(value_1); | ||
else if (targetType === String && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return String(value); | ||
} | ||
else if (targetType === Number && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Number(value); | ||
} | ||
else if (targetType === Boolean && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Boolean(value); | ||
@@ -352,3 +379,3 @@ } | ||
// add transformed type to prevent circular references | ||
this.transformedTypesMap.set(value, { level: level, object: value }); | ||
this.recursionStack.add(value); | ||
} | ||
@@ -380,4 +407,5 @@ var keys = this.getKeys(targetType, value); | ||
var exposeMetadata = storage_1.defaultMetadataStorage.findExposeMetadata(targetType, key); | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) { | ||
newValueKey = exposeMetadata.options.name; | ||
} | ||
} | ||
@@ -402,7 +430,29 @@ } | ||
else if (targetType) { | ||
var metadata = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata) { | ||
var metadata_1 = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata_1) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
type = metadata.typeFunction(options); | ||
isSubValueMap = isSubValueMap || metadata.reflectedType === Map; | ||
var newType = metadata_1.typeFunction(options); | ||
if (metadata_1.options && metadata_1.options.discriminator && metadata_1.options.discriminator.property && metadata_1.options.discriminator.subTypes) { | ||
if (!(value[valueKey] instanceof Array)) { | ||
if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
type = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[metadata_1.options.discriminator.property]; }); | ||
type === undefined ? type = newType : type = type.value; | ||
if (!metadata_1.options.keepDiscriminatorProperty) | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
type = subValue.constructor; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[metadata_1.options.discriminator.property] = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
type = metadata_1; | ||
} | ||
} | ||
else { | ||
type = newType; | ||
} | ||
isSubValueMap = isSubValueMap || metadata_1.reflectedType === Map; | ||
} | ||
@@ -416,3 +466,3 @@ else if (this_1.options.targetMaps) { // try to find a type in target maps | ||
// if value is an array try to get its custom array type | ||
var arrayType_1 = value[valueKey] instanceof Array ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
var arrayType_1 = Array.isArray(value[valueKey]) ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
// const subValueKey = TransformationType === TransformationType.PLAIN_TO_CLASS && newKeyName ? newKeyName : key; | ||
@@ -431,6 +481,19 @@ var subSource = source ? source[valueKey] : undefined; | ||
} | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue, level)) { | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue)) { | ||
var transformKey = this_1.transformationType === TransformationType.PLAIN_TO_CLASS ? newValueKey : key; | ||
var finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
var finalValue = void 0; | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
// Get original value | ||
finalValue = value[transformKey]; | ||
// Apply custom transformation | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
// If nothing change, it means no custom transformation was applied, so use the subValue. | ||
finalValue = (value[transformKey] === finalValue) ? subValue : finalValue; | ||
// Apply the default transformation | ||
finalValue = this_1.transform(subSource, finalValue, type, arrayType_1, isSubValueMap, level + 1); | ||
} | ||
else { | ||
finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
} | ||
if (newValue instanceof Map) { | ||
@@ -460,2 +523,5 @@ newValue.set(newValueKey, finalValue); | ||
} | ||
if (this.options.enableCircularCheck) { | ||
this.recursionStack.delete(value); | ||
} | ||
return newValue; | ||
@@ -497,5 +563,4 @@ } | ||
// preventing circular references | ||
TransformOperationExecutor.prototype.isCircular = function (object, level) { | ||
var transformed = this.transformedTypesMap.get(object); | ||
return transformed !== undefined && transformed.level < level; | ||
TransformOperationExecutor.prototype.isCircular = function (object) { | ||
return this.recursionStack.has(object); | ||
}; | ||
@@ -662,7 +727,8 @@ TransformOperationExecutor.prototype.getReflectedType = function (target, propertyName) { | ||
* Specifies a type of the property. | ||
* The given TypeFunction can return a constructor. A discriminator can be given in the options. | ||
*/ | ||
function Type(typeFunction) { | ||
function Type(typeFunction, options) { | ||
return function (target, key) { | ||
var type = Reflect.getMetadata("design:type", target, key); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction, options); | ||
storage_2.defaultMetadataStorage.addTypeMetadata(metadata); | ||
@@ -734,2 +800,21 @@ }; | ||
exports.TransformClassToClass = TransformClassToClass; | ||
/** | ||
* Return the class instance only with the exposed properties. | ||
*/ | ||
function TransformPlainToClass(classType, params) { | ||
return function (target, propertyKey, descriptor) { | ||
var classTransformer = new ClassTransformer_1.ClassTransformer(); | ||
var originalMethod = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var result = originalMethod.apply(this, args); | ||
var isPromise = !!result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function"; | ||
return isPromise ? result.then(function (data) { return classTransformer.plainToClass(classType, data, params); }) : classTransformer.plainToClass(classType, result, params); | ||
}; | ||
}; | ||
} | ||
exports.TransformPlainToClass = TransformPlainToClass; | ||
}); | ||
@@ -736,0 +821,0 @@ define("class-transformer/index", ["require", "exports", "class-transformer/ClassTransformer", "class-transformer/ClassTransformer", "class-transformer/decorators"], function (require, exports, ClassTransformer_2, ClassTransformer_3, decorators_1) { |
@@ -1,1 +0,1 @@ | ||
define("class-transformer/ClassTransformOptions",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0})}),define("class-transformer/metadata/ExposeExcludeOptions",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0})}),define("class-transformer/metadata/TypeMetadata",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e,a,r){this.target=t,this.propertyName=e,this.reflectedType=a,this.typeFunction=r}return t}();e.TypeMetadata=a}),define("class-transformer/metadata/ExposeMetadata",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e,a){this.target=t,this.propertyName=e,this.options=a}return t}();e.ExposeMetadata=a}),define("class-transformer/metadata/ExcludeMetadata",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e,a){this.target=t,this.propertyName=e,this.options=a}return t}();e.ExcludeMetadata=a}),define("class-transformer/metadata/TransformMetadata",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e,a,r){this.target=t,this.propertyName=e,this.transformFn=a,this.options=r}return t}();e.TransformMetadata=a}),define("class-transformer/metadata/MetadataStorage",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,a){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===a.TransformationType.CLASS_TO_CLASS||r===a.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===a.TransformationType.CLASS_TO_PLAIN))})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),a=e&&e.get(void 0),r=this._exposeMetadatas.get(t),o=r&&r.get(void 0);return a&&o||!a&&!o?"none":a?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===a.TransformationType.CLASS_TO_CLASS||e===a.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===a.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===a.TransformationType.CLASS_TO_CLASS||e===a.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===a.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var a,r=t.get(e);r&&(a=Array.from(r.values()).filter(function(t){return void 0!==t.propertyName}));for(var o=[],n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=Array.from(p.values()).filter(function(t){return void 0!==t.propertyName});o.push.apply(o,f)}}return o.concat(a||[])},t.prototype.findMetadata=function(t,e,a){var r=t.get(e);if(r){var o=r.get(a);if(o)return o}for(var n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=p.get(a);if(f)return f}}},t.prototype.findMetadatas=function(t,e,a){var r,o=t.get(e);o&&(r=o.get(a));for(var n=[],s=0,i=this.getAncestors(e);s<i.length;s++){var p=i[s],f=t.get(p);f&&f.has(a)&&n.push.apply(n,f.get(a))}return n.reverse().concat((r||[]).reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],a=Object.getPrototypeOf(t.prototype.constructor);void 0!==a.prototype;a=Object.getPrototypeOf(a.prototype.constructor))e.push(a);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}();e.MetadataStorage=r}),define("class-transformer/storage",["require","exports","class-transformer/metadata/MetadataStorage"],function(t,e,a){Object.defineProperty(e,"__esModule",{value:!0}),e.defaultMetadataStorage=new a.MetadataStorage}),define("class-transformer/TransformOperationExecutor",["require","exports","class-transformer/storage"],function(t,e,a){Object.defineProperty(e,"__esModule",{value:!0});var r;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(r=e.TransformationType||(e.TransformationType={}));var o=function(){function t(t,e){this.transformationType=t,this.options=e,this.transformedTypesMap=new Map}return t.prototype.transform=function(t,e,o,n,s,i){var p=this;if(void 0===i&&(i=0),e instanceof Array||e instanceof Set){var f=n&&this.transformationType===r.PLAIN_TO_CLASS?new n:[];return e.forEach(function(e,a){var n=t?t[a]:void 0;if(p.options.enableCircularCheck&&p.isCircular(e,i))p.transformationType===r.CLASS_TO_CLASS&&(f instanceof Set?f.add(e):f.push(e));else{var s=p.transform(n,e,o,void 0,e instanceof Map,i+1);f instanceof Set?f.add(s):f.push(s)}}),f}if(o!==String||s){if(o!==Number||s){if(o!==Boolean||s){if((o===Date||e instanceof Date)&&!s)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if("object"==typeof e&&null!==e){o||e.constructor===Object||(o=e.constructor),!o&&t&&(o=t.constructor),this.options.enableCircularCheck&&this.transformedTypesMap.set(e,{level:i,object:e});var u=this.getKeys(o,e),c=t||{};t||this.transformationType!==r.PLAIN_TO_CLASS&&this.transformationType!==r.CLASS_TO_CLASS||(c=s?new Map:o?new o:{});for(var d=this,l=0,y=u;l<y.length;l++){var m=y[l];!function(n){var p=n,f=n,u=n;if(!d.options.ignoreDecorators&&o)if(d.transformationType===r.PLAIN_TO_CLASS){var l=a.defaultMetadataStorage.findExposeMetadataByCustomName(o,n);l&&(u=l.propertyName,f=l.propertyName)}else if(d.transformationType===r.CLASS_TO_PLAIN||d.transformationType===r.CLASS_TO_CLASS){var l=a.defaultMetadataStorage.findExposeMetadata(o,n);l&&l.options&&l.options.name&&(f=l.options.name)}var y=void 0;y=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var m=void 0,T=y instanceof Map;if(o&&s)m=o;else if(o){var M=a.defaultMetadataStorage.findTypeMetadata(o,u);if(M){var h={newObject:c,object:e,property:u};m=M.typeFunction(h),T=T||M.reflectedType===Map}else d.options.targetMaps&&d.options.targetMaps.filter(function(t){return t.target===o&&!!t.properties[u]}).forEach(function(t){return m=t.properties[u]})}var v=e[p]instanceof Array?d.getReflectedType(o,u):void 0,_=t?t[p]:void 0;if(c.constructor.prototype){var S=Object.getOwnPropertyDescriptor(c.constructor.prototype,f);if((d.transformationType===r.PLAIN_TO_CLASS||d.transformationType===r.CLASS_TO_CLASS)&&(c[f]instanceof Function||S&&!S.set))return"continue"}if(d.options.enableCircularCheck&&d.isCircular(y,i)){if(d.transformationType===r.CLASS_TO_CLASS){var g=y;g=d.applyCustomTransformations(g,o,n,e,d.transformationType),c instanceof Map?c.set(f,g):c[f]=g}}else{var C=d.transformationType===r.PLAIN_TO_CLASS?f:n,g=d.transform(_,y,m,v,T,i+1);g=d.applyCustomTransformations(g,o,C,e,d.transformationType),c instanceof Map?c.set(f,g):c[f]=g}}(m)}return c}return e}return Boolean(e)}return Number(e)}return String(e)},t.prototype.applyCustomTransformations=function(t,e,r,o,n){var s=this,i=a.defaultMetadataStorage.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(i=i.filter(function(t){return!t.options||s.checkVersion(t.options.since,t.options.until)})),i=this.options.groups&&this.options.groups.length?i.filter(function(t){return!t.options||s.checkGroups(t.options.groups)}):i.filter(function(t){return!t.options||!t.options.groups||!t.options.groups.length}),i.forEach(function(e){t=e.transformFn(t,o,n)}),t},t.prototype.isCircular=function(t,e){var a=this.transformedTypesMap.get(t);return void 0!==a&&a.level<e},t.prototype.getReflectedType=function(t,e){if(t){var r=a.defaultMetadataStorage.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,n=a.defaultMetadataStorage.getStrategy(t);"none"===n&&(n=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===n&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=a.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===r.PLAIN_TO_CLASS&&(i=i.map(function(e){var r=a.defaultMetadataStorage.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e})),s=s.concat(i);var p=a.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);p.length>0&&(s=s.filter(function(t){return-1===p.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var r=a.defaultMetadataStorage.findExposeMetadata(t,e);return!r||!r.options||o.checkVersion(r.options.since,r.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var r=a.defaultMetadataStorage.findExposeMetadata(t,e);return!r||!r.options||o.checkGroups(r.options.groups)}):s.filter(function(e){var r=a.defaultMetadataStorage.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return o.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s=s.filter(function(t,e,a){return a.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var a=!0;return a&&t&&(a=this.options.version>=t),a&&e&&(a=this.options.version<e),a},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return-1!==t.indexOf(e)})},t}();e.TransformOperationExecutor=o}),define("class-transformer/ClassTransformer",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,a){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){}return t.prototype.classToPlain=function(t,e){return new a.TransformOperationExecutor(a.TransformationType.CLASS_TO_PLAIN,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new a.TransformOperationExecutor(a.TransformationType.CLASS_TO_PLAIN,r||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,r){return new a.TransformOperationExecutor(a.TransformationType.PLAIN_TO_CLASS,r||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new a.TransformOperationExecutor(a.TransformationType.PLAIN_TO_CLASS,r||{}).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new a.TransformOperationExecutor(a.TransformationType.CLASS_TO_CLASS,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new a.TransformOperationExecutor(a.TransformationType.CLASS_TO_CLASS,r||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,a){var r=JSON.parse(e);return this.plainToClass(t,r,a)},t.prototype.deserializeArray=function(t,e,a){var r=JSON.parse(e);return this.plainToClass(t,r,a)},t}();e.ClassTransformer=r}),define("class-transformer/decorators",["require","exports","class-transformer/ClassTransformer","class-transformer/storage","class-transformer/metadata/TypeMetadata","class-transformer/metadata/ExposeMetadata","class-transformer/metadata/ExcludeMetadata","class-transformer/metadata/TransformMetadata"],function(t,e,a,r,o,n,s,i){function p(t,e){return function(a,o){var n=new i.TransformMetadata(a.constructor,o,t,e);r.defaultMetadataStorage.addTransformMetadata(n)}}function f(t){return function(e,a){var n=Reflect.getMetadata("design:type",e,a),s=new o.TypeMetadata(e.constructor,a,n,t);r.defaultMetadataStorage.addTypeMetadata(s)}}function u(t){return function(e,a){var o=new n.ExposeMetadata(e instanceof Function?e:e.constructor,a,t||{});r.defaultMetadataStorage.addExposeMetadata(o)}}function c(t){return function(e,a){var o=new s.ExcludeMetadata(e instanceof Function?e:e.constructor,a,t||{});r.defaultMetadataStorage.addExcludeMetadata(o)}}function d(t){return function(e,r,o){var n=new a.ClassTransformer,s=o.value;o.value=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];var r=s.apply(this,e);return!r||"object"!=typeof r&&"function"!=typeof r||"function"!=typeof r.then?n.classToPlain(r,t):r.then(function(e){return n.classToPlain(e,t)})}}}function l(t){return function(e,r,o){var n=new a.ClassTransformer,s=o.value;o.value=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];var r=s.apply(this,e);return!r||"object"!=typeof r&&"function"!=typeof r||"function"!=typeof r.then?n.classToClass(r,t):r.then(function(e){return n.classToClass(e,t)})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.Transform=p,e.Type=f,e.Expose=u,e.Exclude=c,e.TransformClassToPlain=d,e.TransformClassToClass=l}),define("class-transformer/index",["require","exports","class-transformer/ClassTransformer","class-transformer/ClassTransformer","class-transformer/decorators"],function(t,e,a,r,o){function n(t,e){return y.classToPlain(t,e)}function s(t,e,a){return y.classToPlainFromExist(t,e,a)}function i(t,e,a){return y.plainToClass(t,e,a)}function p(t,e,a){return y.plainToClassFromExist(t,e,a)}function f(t,e){return y.classToClass(t,e)}function u(t,e,a){return y.classToClassFromExist(t,e,a)}function c(t,e){return y.serialize(t,e)}function d(t,e,a){return y.deserialize(t,e,a)}function l(t,e,a){return y.deserializeArray(t,e,a)}Object.defineProperty(e,"__esModule",{value:!0}),e.ClassTransformer=r.ClassTransformer,function(t){for(var a in t)e.hasOwnProperty(a)||(e[a]=t[a])}(o);var y=new a.ClassTransformer;e.classToPlain=n,e.classToPlainFromExist=s,e.plainToClass=i,e.plainToClassFromExist=p,e.classToClass=f,e.classToClassFromExist=u,e.serialize=c,e.deserialize=d,e.deserializeArray=l;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(e.TransformationType||(e.TransformationType={}))}),define("class-transformer",["require","exports","class-transformer/index"],function(t,e,a){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var a in t)e.hasOwnProperty(a)||(e[a]=t[a])}(a)}); | ||
define("class-transformer/ClassTransformOptions",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0})}),define("class-transformer/metadata/ExposeExcludeOptions",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0})}),define("class-transformer/metadata/TypeMetadata",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r,a,o){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=a,this.options=o}return t}();e.TypeMetadata=r}),define("class-transformer/metadata/ExposeMetadata",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}();e.ExposeMetadata=r}),define("class-transformer/metadata/ExcludeMetadata",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}();e.ExcludeMetadata=r}),define("class-transformer/metadata/TransformMetadata",["require","exports"],function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e,r,a){this.target=t,this.propertyName=e,this.transformFn=r,this.options=a}return t}();e.TransformMetadata=r}),define("class-transformer/metadata/MetadataStorage",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,a){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?a===r.TransformationType.CLASS_TO_CLASS||a===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||a===r.TransformationType.CLASS_TO_PLAIN))})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),a=this._exposeMetadatas.get(t),o=a&&a.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,a=t.get(e);a&&(r=Array.from(a.values()).filter(function(t){return void 0!==t.propertyName}));for(var o=[],n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=Array.from(p.values()).filter(function(t){return void 0!==t.propertyName});o.push.apply(o,f)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var a=t.get(e);if(a){var o=a.get(r);if(o)return o}for(var n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=p.get(r);if(f)return f}}},t.prototype.findMetadatas=function(t,e,r){var a,o=t.get(e);o&&(a=o.get(r));for(var n=[],s=0,i=this.getAncestors(e);s<i.length;s++){var p=i[s],f=t.get(p);f&&f.has(r)&&n.push.apply(n,f.get(r))}return n.reverse().concat((a||[]).reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}();e.MetadataStorage=a}),define("class-transformer/storage",["require","exports","class-transformer/metadata/MetadataStorage"],function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.defaultMetadataStorage=new r.MetadataStorage}),define("class-transformer/TransformOperationExecutor",["require","exports","class-transformer/storage"],function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});var a;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(a=e.TransformationType||(e.TransformationType={}));var o=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,o,n,s,i){var p=this;if(void 0===i&&(i=0),Array.isArray(e)||e instanceof Set){var f=n&&this.transformationType===a.PLAIN_TO_CLASS?new n:[];return e.forEach(function(e,r){var n=t?t[r]:void 0;if(p.options.enableCircularCheck&&p.isCircular(e))p.transformationType===a.CLASS_TO_CLASS&&(f instanceof Set?f.add(e):f.push(e));else{var s=void 0;if("function"!=typeof o&&o&&o.options&&o.options.discriminator&&o.options.discriminator.property&&o.options.discriminator.subTypes){if(p.transformationType===a.PLAIN_TO_CLASS){s=o.options.discriminator.subTypes.find(function(t){return t.name===e[o.options.discriminator.property]});var u={newObject:f,object:e,property:void 0},c=o.typeFunction(u);s=void 0===s?c:s.value,o.options.keepDiscriminatorProperty||delete e[o.options.discriminator.property]}p.transformationType===a.CLASS_TO_CLASS&&(s=e.constructor),p.transformationType===a.CLASS_TO_PLAIN&&(e[o.options.discriminator.property]=o.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else s=o;var d=p.transform(n,e,s,void 0,e instanceof Map,i+1);f instanceof Set?f.add(d):f.push(d)}}),f}if(o!==String||s){if(o!==Number||s){if(o!==Boolean||s){if((o===Date||e instanceof Date)&&!s)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if("object"==typeof e&&null!==e){o||e.constructor===Object||(o=e.constructor),!o&&t&&(o=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var u=this.getKeys(o,e),c=t||{};t||this.transformationType!==a.PLAIN_TO_CLASS&&this.transformationType!==a.CLASS_TO_CLASS||(c=s?new Map:o?new o:{});for(var d=this,l=0,y=u;l<y.length;l++){var m=y[l];!function(n){var p=n,f=n,u=n;if(!d.options.ignoreDecorators&&o)if(d.transformationType===a.PLAIN_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadataByCustomName(o,n);l&&(u=l.propertyName,f=l.propertyName)}else if(d.transformationType===a.CLASS_TO_PLAIN||d.transformationType===a.CLASS_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadata(o,n);l&&l.options&&l.options.name&&(f=l.options.name)}var y=void 0;y=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var m=void 0,T=y instanceof Map;if(o&&s)m=o;else if(o){var S=r.defaultMetadataStorage.findTypeMetadata(o,u);if(S){var v={newObject:c,object:e,property:u},_=S.typeFunction(v);S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[p]instanceof Array?m=S:(d.transformationType===a.PLAIN_TO_CLASS&&(m=S.options.discriminator.subTypes.find(function(t){return t.name===y[S.options.discriminator.property]}),m=void 0===m?_:m.value,S.options.keepDiscriminatorProperty||delete y[S.options.discriminator.property]),d.transformationType===a.CLASS_TO_CLASS&&(m=y.constructor),d.transformationType===a.CLASS_TO_PLAIN&&(y[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===y.constructor}).name)):m=_,T=T||S.reflectedType===Map}else d.options.targetMaps&&d.options.targetMaps.filter(function(t){return t.target===o&&!!t.properties[u]}).forEach(function(t){return m=t.properties[u]})}var h=Array.isArray(e[p])?d.getReflectedType(o,u):void 0,M=t?t[p]:void 0;if(c.constructor.prototype){var g=Object.getOwnPropertyDescriptor(c.constructor.prototype,f);if((d.transformationType===a.PLAIN_TO_CLASS||d.transformationType===a.CLASS_TO_CLASS)&&(c[f]instanceof Function||g&&!g.set))return"continue"}if(d.options.enableCircularCheck&&d.isCircular(y)){if(d.transformationType===a.CLASS_TO_CLASS){var C=y;C=d.applyCustomTransformations(C,o,n,e,d.transformationType),c instanceof Map?c.set(f,C):c[f]=C}}else{var A=d.transformationType===a.PLAIN_TO_CLASS?f:n,C=void 0;d.transformationType===a.CLASS_TO_PLAIN?(C=e[A],C=d.applyCustomTransformations(C,o,A,e,d.transformationType),C=e[A]===C?y:C,C=d.transform(M,C,m,h,T,i+1)):(C=d.transform(M,y,m,h,T,i+1),C=d.applyCustomTransformations(C,o,A,e,d.transformationType)),c instanceof Map?c.set(f,C):c[f]=C}}(m)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),c}return e}return null===e||void 0===e?e:Boolean(e)}return null===e||void 0===e?e:Number(e)}return null===e||void 0===e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,a,o,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,a,this.transformationType);return void 0!==this.options.version&&(i=i.filter(function(t){return!t.options||s.checkVersion(t.options.since,t.options.until)})),i=this.options.groups&&this.options.groups.length?i.filter(function(t){return!t.options||s.checkGroups(t.options.groups)}):i.filter(function(t){return!t.options||!t.options.groups||!t.options.groups.length}),i.forEach(function(e){t=e.transformFn(t,o,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var a=r.defaultMetadataStorage.findTypeMetadata(t,e);return a?a.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,n=r.defaultMetadataStorage.getStrategy(t);"none"===n&&(n=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===n&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=r.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===a.PLAIN_TO_CLASS&&(i=i.map(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return a&&a.options&&a.options.name?a.options.name:e})),s=s.concat(i);var p=r.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);p.length>0&&(s=s.filter(function(t){return-1===p.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkGroups(a.options.groups)}):s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(a&&a.options&&a.options.groups&&a.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return o.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s=s.filter(function(t,e,r){return r.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return-1!==t.indexOf(e)})},t}();e.TransformOperationExecutor=o}),define("class-transformer/ClassTransformer",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){}return t.prototype.classToPlain=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t.prototype.deserializeArray=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t}();e.ClassTransformer=a}),define("class-transformer/decorators",["require","exports","class-transformer/ClassTransformer","class-transformer/storage","class-transformer/metadata/TypeMetadata","class-transformer/metadata/ExposeMetadata","class-transformer/metadata/ExcludeMetadata","class-transformer/metadata/TransformMetadata"],function(t,e,r,a,o,n,s,i){function p(t,e){return function(r,o){var n=new i.TransformMetadata(r.constructor,o,t,e);a.defaultMetadataStorage.addTransformMetadata(n)}}function f(t,e){return function(r,n){var s=Reflect.getMetadata("design:type",r,n),i=new o.TypeMetadata(r.constructor,n,s,t,e);a.defaultMetadataStorage.addTypeMetadata(i)}}function u(t){return function(e,r){var o=new n.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});a.defaultMetadataStorage.addExposeMetadata(o)}}function c(t){return function(e,r){var o=new s.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});a.defaultMetadataStorage.addExcludeMetadata(o)}}function d(t){return function(e,a,o){var n=new r.ClassTransformer,s=o.value;o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=s.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?n.classToPlain(a,t):a.then(function(e){return n.classToPlain(e,t)})}}}function l(t){return function(e,a,o){var n=new r.ClassTransformer,s=o.value;o.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=s.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?n.classToClass(a,t):a.then(function(e){return n.classToClass(e,t)})}}}function y(t,e){return function(a,o,n){var s=new r.ClassTransformer,i=n.value;n.value=function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];var o=i.apply(this,r);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?s.plainToClass(t,o,e):o.then(function(r){return s.plainToClass(t,r,e)})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.Transform=p,e.Type=f,e.Expose=u,e.Exclude=c,e.TransformClassToPlain=d,e.TransformClassToClass=l,e.TransformPlainToClass=y}),define("class-transformer/index",["require","exports","class-transformer/ClassTransformer","class-transformer/ClassTransformer","class-transformer/decorators"],function(t,e,r,a,o){function n(t,e){return y.classToPlain(t,e)}function s(t,e,r){return y.classToPlainFromExist(t,e,r)}function i(t,e,r){return y.plainToClass(t,e,r)}function p(t,e,r){return y.plainToClassFromExist(t,e,r)}function f(t,e){return y.classToClass(t,e)}function u(t,e,r){return y.classToClassFromExist(t,e,r)}function c(t,e){return y.serialize(t,e)}function d(t,e,r){return y.deserialize(t,e,r)}function l(t,e,r){return y.deserializeArray(t,e,r)}Object.defineProperty(e,"__esModule",{value:!0}),e.ClassTransformer=a.ClassTransformer,function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(o);var y=new r.ClassTransformer;e.classToPlain=n,e.classToPlainFromExist=s,e.plainToClass=i,e.plainToClassFromExist=p,e.classToClass=f,e.classToClassFromExist=u,e.serialize=c,e.deserialize=d,e.deserializeArray=l;!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(e.TransformationType||(e.TransformationType={}))}),define("class-transformer",["require","exports","class-transformer/index"],function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(r)}); |
@@ -24,3 +24,3 @@ System.register("class-transformer/ClassTransformOptions", [], function (exports_1, context_1) { | ||
TypeMetadata = /** @class */ (function () { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction) { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction, options) { | ||
this.target = target; | ||
@@ -30,2 +30,3 @@ this.propertyName = propertyName; | ||
this.typeFunction = typeFunction; | ||
this.options = options; | ||
} | ||
@@ -354,3 +355,3 @@ return TypeMetadata; | ||
// ------------------------------------------------------------------------- | ||
this.transformedTypesMap = new Map(); | ||
this.recursionStack = new Set(); | ||
} | ||
@@ -363,8 +364,28 @@ // ------------------------------------------------------------------------- | ||
if (level === void 0) { level = 0; } | ||
if (value instanceof Array || value instanceof Set) { | ||
if (Array.isArray(value) || value instanceof Set) { | ||
var newValue_1 = arrayType && this.transformationType === TransformationType.PLAIN_TO_CLASS ? new arrayType() : []; | ||
value.forEach(function (subValue, index) { | ||
var subSource = source ? source[index] : undefined; | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue, level)) { | ||
var value_1 = _this.transform(subSource, subValue, targetType, undefined, subValue instanceof Map, level + 1); | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue)) { | ||
var realTargetType = void 0; | ||
if (typeof targetType !== "function" && targetType && targetType.options && targetType.options.discriminator && targetType.options.discriminator.property && targetType.options.discriminator.subTypes) { | ||
if (_this.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
realTargetType = targetType.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[targetType.options.discriminator.property]; }); | ||
var options = { newObject: newValue_1, object: subValue, property: undefined }; | ||
var newType = targetType.typeFunction(options); | ||
realTargetType === undefined ? realTargetType = newType : realTargetType = realTargetType.value; | ||
if (!targetType.options.keepDiscriminatorProperty) | ||
delete subValue[targetType.options.discriminator.property]; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
realTargetType = subValue.constructor; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[targetType.options.discriminator.property] = targetType.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
realTargetType = targetType; | ||
} | ||
var value_1 = _this.transform(subSource, subValue, realTargetType, undefined, subValue instanceof Map, level + 1); | ||
if (newValue_1 instanceof Set) { | ||
@@ -389,8 +410,14 @@ newValue_1.add(value_1); | ||
else if (targetType === String && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return String(value); | ||
} | ||
else if (targetType === Number && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Number(value); | ||
} | ||
else if (targetType === Boolean && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Boolean(value); | ||
@@ -414,3 +441,3 @@ } | ||
// add transformed type to prevent circular references | ||
this.transformedTypesMap.set(value, { level: level, object: value }); | ||
this.recursionStack.add(value); | ||
} | ||
@@ -442,4 +469,5 @@ var keys = this.getKeys(targetType, value); | ||
var exposeMetadata = storage_1.defaultMetadataStorage.findExposeMetadata(targetType, key); | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) { | ||
newValueKey = exposeMetadata.options.name; | ||
} | ||
} | ||
@@ -464,7 +492,29 @@ } | ||
else if (targetType) { | ||
var metadata = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata) { | ||
var metadata_1 = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata_1) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
type = metadata.typeFunction(options); | ||
isSubValueMap = isSubValueMap || metadata.reflectedType === Map; | ||
var newType = metadata_1.typeFunction(options); | ||
if (metadata_1.options && metadata_1.options.discriminator && metadata_1.options.discriminator.property && metadata_1.options.discriminator.subTypes) { | ||
if (!(value[valueKey] instanceof Array)) { | ||
if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
type = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[metadata_1.options.discriminator.property]; }); | ||
type === undefined ? type = newType : type = type.value; | ||
if (!metadata_1.options.keepDiscriminatorProperty) | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
type = subValue.constructor; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[metadata_1.options.discriminator.property] = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
type = metadata_1; | ||
} | ||
} | ||
else { | ||
type = newType; | ||
} | ||
isSubValueMap = isSubValueMap || metadata_1.reflectedType === Map; | ||
} | ||
@@ -478,3 +528,3 @@ else if (this_1.options.targetMaps) { // try to find a type in target maps | ||
// if value is an array try to get its custom array type | ||
var arrayType_1 = value[valueKey] instanceof Array ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
var arrayType_1 = Array.isArray(value[valueKey]) ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
// const subValueKey = TransformationType === TransformationType.PLAIN_TO_CLASS && newKeyName ? newKeyName : key; | ||
@@ -493,6 +543,19 @@ var subSource = source ? source[valueKey] : undefined; | ||
} | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue, level)) { | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue)) { | ||
var transformKey = this_1.transformationType === TransformationType.PLAIN_TO_CLASS ? newValueKey : key; | ||
var finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
var finalValue = void 0; | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
// Get original value | ||
finalValue = value[transformKey]; | ||
// Apply custom transformation | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
// If nothing change, it means no custom transformation was applied, so use the subValue. | ||
finalValue = (value[transformKey] === finalValue) ? subValue : finalValue; | ||
// Apply the default transformation | ||
finalValue = this_1.transform(subSource, finalValue, type, arrayType_1, isSubValueMap, level + 1); | ||
} | ||
else { | ||
finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
} | ||
if (newValue instanceof Map) { | ||
@@ -522,2 +585,5 @@ newValue.set(newValueKey, finalValue); | ||
} | ||
if (this.options.enableCircularCheck) { | ||
this.recursionStack.delete(value); | ||
} | ||
return newValue; | ||
@@ -559,5 +625,4 @@ } | ||
// preventing circular references | ||
TransformOperationExecutor.prototype.isCircular = function (object, level) { | ||
var transformed = this.transformedTypesMap.get(object); | ||
return transformed !== undefined && transformed.level < level; | ||
TransformOperationExecutor.prototype.isCircular = function (object) { | ||
return this.recursionStack.has(object); | ||
}; | ||
@@ -737,7 +802,8 @@ TransformOperationExecutor.prototype.getReflectedType = function (target, propertyName) { | ||
* Specifies a type of the property. | ||
* The given TypeFunction can return a constructor. A discriminator can be given in the options. | ||
*/ | ||
function Type(typeFunction) { | ||
function Type(typeFunction, options) { | ||
return function (target, key) { | ||
var type = Reflect.getMetadata("design:type", target, key); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction, options); | ||
storage_2.defaultMetadataStorage.addTypeMetadata(metadata); | ||
@@ -809,2 +875,21 @@ }; | ||
exports_11("TransformClassToClass", TransformClassToClass); | ||
/** | ||
* Return the class instance only with the exposed properties. | ||
*/ | ||
function TransformPlainToClass(classType, params) { | ||
return function (target, propertyKey, descriptor) { | ||
var classTransformer = new ClassTransformer_1.ClassTransformer(); | ||
var originalMethod = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var result = originalMethod.apply(this, args); | ||
var isPromise = !!result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function"; | ||
return isPromise ? result.then(function (data) { return classTransformer.plainToClass(classType, data, params); }) : classTransformer.plainToClass(classType, result, params); | ||
}; | ||
}; | ||
} | ||
exports_11("TransformPlainToClass", TransformPlainToClass); | ||
return { | ||
@@ -811,0 +896,0 @@ setters: [ |
@@ -1,1 +0,1 @@ | ||
System.register("class-transformer/ClassTransformOptions",[],function(t,e){e&&e.id;return{setters:[],execute:function(){}}}),System.register("class-transformer/metadata/ExposeExcludeOptions",[],function(t,e){e&&e.id;return{setters:[],execute:function(){}}}),System.register("class-transformer/metadata/TypeMetadata",[],function(t,e){var a;e&&e.id;return{setters:[],execute:function(){a=function(){function t(t,e,a,r){this.target=t,this.propertyName=e,this.reflectedType=a,this.typeFunction=r}return t}(),t("TypeMetadata",a)}}}),System.register("class-transformer/metadata/ExposeMetadata",[],function(t,e){var a;e&&e.id;return{setters:[],execute:function(){a=function(){function t(t,e,a){this.target=t,this.propertyName=e,this.options=a}return t}(),t("ExposeMetadata",a)}}}),System.register("class-transformer/metadata/ExcludeMetadata",[],function(t,e){var a;e&&e.id;return{setters:[],execute:function(){a=function(){function t(t,e,a){this.target=t,this.propertyName=e,this.options=a}return t}(),t("ExcludeMetadata",a)}}}),System.register("class-transformer/metadata/TransformMetadata",[],function(t,e){var a;e&&e.id;return{setters:[],execute:function(){a=function(){function t(t,e,a,r){this.target=t,this.propertyName=e,this.transformFn=a,this.options=r}return t}(),t("TransformMetadata",a)}}}),System.register("class-transformer/metadata/MetadataStorage",["class-transformer/TransformOperationExecutor"],function(t,e){var a,r;e&&e.id;return{setters:[function(t){a=t}],execute:function(){r=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,r){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?r===a.TransformationType.CLASS_TO_CLASS||r===a.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||r===a.TransformationType.CLASS_TO_PLAIN))})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),a=e&&e.get(void 0),r=this._exposeMetadatas.get(t),n=r&&r.get(void 0);return a&&n||!a&&!n?"none":a?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===a.TransformationType.CLASS_TO_CLASS||e===a.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===a.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===a.TransformationType.CLASS_TO_CLASS||e===a.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===a.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var a,r=t.get(e);r&&(a=Array.from(r.values()).filter(function(t){return void 0!==t.propertyName}));for(var n=[],o=0,s=this.getAncestors(e);o<s.length;o++){var i=s[o],f=t.get(i);if(f){var p=Array.from(f.values()).filter(function(t){return void 0!==t.propertyName});n.push.apply(n,p)}}return n.concat(a||[])},t.prototype.findMetadata=function(t,e,a){var r=t.get(e);if(r){var n=r.get(a);if(n)return n}for(var o=0,s=this.getAncestors(e);o<s.length;o++){var i=s[o],f=t.get(i);if(f){var p=f.get(a);if(p)return p}}},t.prototype.findMetadatas=function(t,e,a){var r,n=t.get(e);n&&(r=n.get(a));for(var o=[],s=0,i=this.getAncestors(e);s<i.length;s++){var f=i[s],p=t.get(f);p&&p.has(a)&&o.push.apply(o,p.get(a))}return o.reverse().concat((r||[]).reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],a=Object.getPrototypeOf(t.prototype.constructor);void 0!==a.prototype;a=Object.getPrototypeOf(a.prototype.constructor))e.push(a);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),t("MetadataStorage",r)}}}),System.register("class-transformer/storage",["class-transformer/metadata/MetadataStorage"],function(t,e){var a,r;e&&e.id;return{setters:[function(t){a=t}],execute:function(){t("defaultMetadataStorage",r=new a.MetadataStorage)}}}),System.register("class-transformer/TransformOperationExecutor",["class-transformer/storage"],function(t,e){var a,r,n;e&&e.id;return{setters:[function(t){a=t}],execute:function(){!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(r||(r={})),t("TransformationType",r),n=function(){function t(t,e){this.transformationType=t,this.options=e,this.transformedTypesMap=new Map}return t.prototype.transform=function(t,e,n,o,s,i){var f=this;if(void 0===i&&(i=0),e instanceof Array||e instanceof Set){var p=o&&this.transformationType===r.PLAIN_TO_CLASS?new o:[];return e.forEach(function(e,a){var o=t?t[a]:void 0;if(f.options.enableCircularCheck&&f.isCircular(e,i))f.transformationType===r.CLASS_TO_CLASS&&(p instanceof Set?p.add(e):p.push(e));else{var s=f.transform(o,e,n,void 0,e instanceof Map,i+1);p instanceof Set?p.add(s):p.push(s)}}),p}if(n!==String||s){if(n!==Number||s){if(n!==Boolean||s){if((n===Date||e instanceof Date)&&!s)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if("object"==typeof e&&null!==e){n||e.constructor===Object||(n=e.constructor),!n&&t&&(n=t.constructor),this.options.enableCircularCheck&&this.transformedTypesMap.set(e,{level:i,object:e});var u=this.getKeys(n,e),c=t||{};t||this.transformationType!==r.PLAIN_TO_CLASS&&this.transformationType!==r.CLASS_TO_CLASS||(c=s?new Map:n?new n:{});for(var d=this,l=0,m=u;l<m.length;l++){var y=m[l];!function(o){var f=o,p=o,u=o;if(!d.options.ignoreDecorators&&n)if(d.transformationType===r.PLAIN_TO_CLASS){var l=a.defaultMetadataStorage.findExposeMetadataByCustomName(n,o);l&&(u=l.propertyName,p=l.propertyName)}else if(d.transformationType===r.CLASS_TO_PLAIN||d.transformationType===r.CLASS_TO_CLASS){var l=a.defaultMetadataStorage.findExposeMetadata(n,o);l&&l.options&&l.options.name&&(p=l.options.name)}var m=void 0;m=e instanceof Map?e.get(f):e[f]instanceof Function?e[f]():e[f];var y=void 0,T=m instanceof Map;if(n&&s)y=n;else if(n){var S=a.defaultMetadataStorage.findTypeMetadata(n,u);if(S){var g={newObject:c,object:e,property:u};y=S.typeFunction(g),T=T||S.reflectedType===Map}else d.options.targetMaps&&d.options.targetMaps.filter(function(t){return t.target===n&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]})}var h=e[f]instanceof Array?d.getReflectedType(n,u):void 0,M=t?t[f]:void 0;if(c.constructor.prototype){var v=Object.getOwnPropertyDescriptor(c.constructor.prototype,p);if((d.transformationType===r.PLAIN_TO_CLASS||d.transformationType===r.CLASS_TO_CLASS)&&(c[p]instanceof Function||v&&!v.set))return"continue"}if(d.options.enableCircularCheck&&d.isCircular(m,i)){if(d.transformationType===r.CLASS_TO_CLASS){var _=m;_=d.applyCustomTransformations(_,n,o,e,d.transformationType),c instanceof Map?c.set(p,_):c[p]=_}}else{var C=d.transformationType===r.PLAIN_TO_CLASS?p:o,_=d.transform(M,m,y,h,T,i+1);_=d.applyCustomTransformations(_,n,C,e,d.transformationType),c instanceof Map?c.set(p,_):c[p]=_}}(y)}return c}return e}return Boolean(e)}return Number(e)}return String(e)},t.prototype.applyCustomTransformations=function(t,e,r,n,o){var s=this,i=a.defaultMetadataStorage.findTransformMetadatas(e,r,this.transformationType);return void 0!==this.options.version&&(i=i.filter(function(t){return!t.options||s.checkVersion(t.options.since,t.options.until)})),i=this.options.groups&&this.options.groups.length?i.filter(function(t){return!t.options||s.checkGroups(t.options.groups)}):i.filter(function(t){return!t.options||!t.options.groups||!t.options.groups.length}),i.forEach(function(e){t=e.transformFn(t,n,o)}),t},t.prototype.isCircular=function(t,e){var a=this.transformedTypesMap.get(t);return void 0!==a&&a.level<e},t.prototype.getReflectedType=function(t,e){if(t){var r=a.defaultMetadataStorage.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var n=this,o=a.defaultMetadataStorage.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===o&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=a.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===r.PLAIN_TO_CLASS&&(i=i.map(function(e){var r=a.defaultMetadataStorage.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e})),s=s.concat(i);var f=a.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);f.length>0&&(s=s.filter(function(t){return-1===f.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var r=a.defaultMetadataStorage.findExposeMetadata(t,e);return!r||!r.options||n.checkVersion(r.options.since,r.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var r=a.defaultMetadataStorage.findExposeMetadata(t,e);return!r||!r.options||n.checkGroups(r.options.groups)}):s.filter(function(e){var r=a.defaultMetadataStorage.findExposeMetadata(t,e);return!(r&&r.options&&r.options.groups&&r.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return n.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s=s.filter(function(t,e,a){return a.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var a=!0;return a&&t&&(a=this.options.version>=t),a&&e&&(a=this.options.version<e),a},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return-1!==t.indexOf(e)})},t}(),t("TransformOperationExecutor",n)}}}),System.register("class-transformer/ClassTransformer",["class-transformer/TransformOperationExecutor"],function(t,e){var a,r;e&&e.id;return{setters:[function(t){a=t}],execute:function(){r=function(){function t(){}return t.prototype.classToPlain=function(t,e){return new a.TransformOperationExecutor(a.TransformationType.CLASS_TO_PLAIN,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,r){return new a.TransformOperationExecutor(a.TransformationType.CLASS_TO_PLAIN,r||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,r){return new a.TransformOperationExecutor(a.TransformationType.PLAIN_TO_CLASS,r||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,r){return new a.TransformOperationExecutor(a.TransformationType.PLAIN_TO_CLASS,r||{}).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new a.TransformOperationExecutor(a.TransformationType.CLASS_TO_CLASS,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,r){return new a.TransformOperationExecutor(a.TransformationType.CLASS_TO_CLASS,r||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,a){var r=JSON.parse(e);return this.plainToClass(t,r,a)},t.prototype.deserializeArray=function(t,e,a){var r=JSON.parse(e);return this.plainToClass(t,r,a)},t}(),t("ClassTransformer",r)}}}),System.register("class-transformer/decorators",["class-transformer/ClassTransformer","class-transformer/storage","class-transformer/metadata/TypeMetadata","class-transformer/metadata/ExposeMetadata","class-transformer/metadata/ExcludeMetadata","class-transformer/metadata/TransformMetadata"],function(t,e){function a(t,e){return function(a,r){var n=new l.TransformMetadata(a.constructor,r,t,e);p.defaultMetadataStorage.addTransformMetadata(n)}}function r(t){return function(e,a){var r=Reflect.getMetadata("design:type",e,a),n=new u.TypeMetadata(e.constructor,a,r,t);p.defaultMetadataStorage.addTypeMetadata(n)}}function n(t){return function(e,a){var r=new c.ExposeMetadata(e instanceof Function?e:e.constructor,a,t||{});p.defaultMetadataStorage.addExposeMetadata(r)}}function o(t){return function(e,a){var r=new d.ExcludeMetadata(e instanceof Function?e:e.constructor,a,t||{});p.defaultMetadataStorage.addExcludeMetadata(r)}}function s(t){return function(e,a,r){var n=new f.ClassTransformer,o=r.value;r.value=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];var r=o.apply(this,e);return!r||"object"!=typeof r&&"function"!=typeof r||"function"!=typeof r.then?n.classToPlain(r,t):r.then(function(e){return n.classToPlain(e,t)})}}}function i(t){return function(e,a,r){var n=new f.ClassTransformer,o=r.value;r.value=function(){for(var e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];var r=o.apply(this,e);return!r||"object"!=typeof r&&"function"!=typeof r||"function"!=typeof r.then?n.classToClass(r,t):r.then(function(e){return n.classToClass(e,t)})}}}var f,p,u,c,d,l;e&&e.id;return t("Transform",a),t("Type",r),t("Expose",n),t("Exclude",o),t("TransformClassToPlain",s),t("TransformClassToClass",i),{setters:[function(t){f=t},function(t){p=t},function(t){u=t},function(t){c=t},function(t){d=t},function(t){l=t}],execute:function(){}}}),System.register("class-transformer/index",["class-transformer/ClassTransformer","class-transformer/decorators"],function(t,e){function a(t,e){return l.classToPlain(t,e)}function r(t,e,a){return l.classToPlainFromExist(t,e,a)}function n(t,e,a){return l.plainToClass(t,e,a)}function o(t,e,a){return l.plainToClassFromExist(t,e,a)}function s(t,e){return l.classToClass(t,e)}function i(t,e,a){return l.classToClassFromExist(t,e,a)}function f(t,e){return l.serialize(t,e)}function p(t,e,a){return l.deserialize(t,e,a)}function u(t,e,a){return l.deserializeArray(t,e,a)}function c(e){var a={};for(var r in e)"default"===r||y.hasOwnProperty(r)||(a[r]=e[r]);t(a)}var d,l,m;e&&e.id;t("classToPlain",a),t("classToPlainFromExist",r),t("plainToClass",n),t("plainToClassFromExist",o),t("classToClass",s),t("classToClassFromExist",i),t("serialize",f),t("deserialize",p),t("deserializeArray",u);var y={classToPlain:!0,classToPlainFromExist:!0,plainToClass:!0,plainToClassFromExist:!0,classToClass:!0,classToClassFromExist:!0,serialize:!0,deserialize:!0,deserializeArray:!0,TransformationType:!0,ClassTransformer:!0};return{setters:[function(e){d=e,t({ClassTransformer:e.ClassTransformer})},function(t){c(t)}],execute:function(){l=new d.ClassTransformer,function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(m||(m={})),t("TransformationType",m)}}}),System.register("class-transformer",["class-transformer/index"],function(t,e){function a(e){var a={};for(var r in e)"default"!==r&&(a[r]=e[r]);t(a)}e&&e.id;return{setters:[function(t){a(t)}],execute:function(){}}}); | ||
System.register("class-transformer/ClassTransformOptions",[],function(t,e){e&&e.id;return{setters:[],execute:function(){}}}),System.register("class-transformer/metadata/ExposeExcludeOptions",[],function(t,e){e&&e.id;return{setters:[],execute:function(){}}}),System.register("class-transformer/metadata/TypeMetadata",[],function(t,e){var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r,a,o){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=a,this.options=o}return t}(),t("TypeMetadata",r)}}}),System.register("class-transformer/metadata/ExposeMetadata",[],function(t,e){var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}(),t("ExposeMetadata",r)}}}),System.register("class-transformer/metadata/ExcludeMetadata",[],function(t,e){var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}(),t("ExcludeMetadata",r)}}}),System.register("class-transformer/metadata/TransformMetadata",[],function(t,e){var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r,a){this.target=t,this.propertyName=e,this.transformFn=r,this.options=a}return t}(),t("TransformMetadata",r)}}}),System.register("class-transformer/metadata/MetadataStorage",["class-transformer/TransformOperationExecutor"],function(t,e){var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){a=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,a){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?a===r.TransformationType.CLASS_TO_CLASS||a===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||a===r.TransformationType.CLASS_TO_PLAIN))})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),a=this._exposeMetadatas.get(t),o=a&&a.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,a=t.get(e);a&&(r=Array.from(a.values()).filter(function(t){return void 0!==t.propertyName}));for(var o=[],n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=Array.from(p.values()).filter(function(t){return void 0!==t.propertyName});o.push.apply(o,f)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var a=t.get(e);if(a){var o=a.get(r);if(o)return o}for(var n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var f=p.get(r);if(f)return f}}},t.prototype.findMetadatas=function(t,e,r){var a,o=t.get(e);o&&(a=o.get(r));for(var n=[],s=0,i=this.getAncestors(e);s<i.length;s++){var p=i[s],f=t.get(p);f&&f.has(r)&&n.push.apply(n,f.get(r))}return n.reverse().concat((a||[]).reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),t("MetadataStorage",a)}}}),System.register("class-transformer/storage",["class-transformer/metadata/MetadataStorage"],function(t,e){var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){t("defaultMetadataStorage",a=new r.MetadataStorage)}}}),System.register("class-transformer/TransformOperationExecutor",["class-transformer/storage"],function(t,e){var r,a,o;e&&e.id;return{setters:[function(t){r=t}],execute:function(){!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(a||(a={})),t("TransformationType",a),o=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,o,n,s,i){var p=this;if(void 0===i&&(i=0),Array.isArray(e)||e instanceof Set){var f=n&&this.transformationType===a.PLAIN_TO_CLASS?new n:[];return e.forEach(function(e,r){var n=t?t[r]:void 0;if(p.options.enableCircularCheck&&p.isCircular(e))p.transformationType===a.CLASS_TO_CLASS&&(f instanceof Set?f.add(e):f.push(e));else{var s=void 0;if("function"!=typeof o&&o&&o.options&&o.options.discriminator&&o.options.discriminator.property&&o.options.discriminator.subTypes){if(p.transformationType===a.PLAIN_TO_CLASS){s=o.options.discriminator.subTypes.find(function(t){return t.name===e[o.options.discriminator.property]});var u={newObject:f,object:e,property:void 0},c=o.typeFunction(u);s=void 0===s?c:s.value,o.options.keepDiscriminatorProperty||delete e[o.options.discriminator.property]}p.transformationType===a.CLASS_TO_CLASS&&(s=e.constructor),p.transformationType===a.CLASS_TO_PLAIN&&(e[o.options.discriminator.property]=o.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else s=o;var d=p.transform(n,e,s,void 0,e instanceof Map,i+1);f instanceof Set?f.add(d):f.push(d)}}),f}if(o!==String||s){if(o!==Number||s){if(o!==Boolean||s){if((o===Date||e instanceof Date)&&!s)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if("object"==typeof e&&null!==e){o||e.constructor===Object||(o=e.constructor),!o&&t&&(o=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var u=this.getKeys(o,e),c=t||{};t||this.transformationType!==a.PLAIN_TO_CLASS&&this.transformationType!==a.CLASS_TO_CLASS||(c=s?new Map:o?new o:{});for(var d=this,l=0,m=u;l<m.length;l++){var y=m[l];!function(n){var p=n,f=n,u=n;if(!d.options.ignoreDecorators&&o)if(d.transformationType===a.PLAIN_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadataByCustomName(o,n);l&&(u=l.propertyName,f=l.propertyName)}else if(d.transformationType===a.CLASS_TO_PLAIN||d.transformationType===a.CLASS_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadata(o,n);l&&l.options&&l.options.name&&(f=l.options.name)}var m=void 0;m=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var y=void 0,T=m instanceof Map;if(o&&s)y=o;else if(o){var S=r.defaultMetadataStorage.findTypeMetadata(o,u);if(S){var h={newObject:c,object:e,property:u},v=S.typeFunction(h);S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[p]instanceof Array?y=S:(d.transformationType===a.PLAIN_TO_CLASS&&(y=S.options.discriminator.subTypes.find(function(t){return t.name===m[S.options.discriminator.property]}),y=void 0===y?v:y.value,S.options.keepDiscriminatorProperty||delete m[S.options.discriminator.property]),d.transformationType===a.CLASS_TO_CLASS&&(y=m.constructor),d.transformationType===a.CLASS_TO_PLAIN&&(m[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===m.constructor}).name)):y=v,T=T||S.reflectedType===Map}else d.options.targetMaps&&d.options.targetMaps.filter(function(t){return t.target===o&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]})}var g=Array.isArray(e[p])?d.getReflectedType(o,u):void 0,M=t?t[p]:void 0;if(c.constructor.prototype){var _=Object.getOwnPropertyDescriptor(c.constructor.prototype,f);if((d.transformationType===a.PLAIN_TO_CLASS||d.transformationType===a.CLASS_TO_CLASS)&&(c[f]instanceof Function||_&&!_.set))return"continue"}if(d.options.enableCircularCheck&&d.isCircular(m)){if(d.transformationType===a.CLASS_TO_CLASS){var C=m;C=d.applyCustomTransformations(C,o,n,e,d.transformationType),c instanceof Map?c.set(f,C):c[f]=C}}else{var A=d.transformationType===a.PLAIN_TO_CLASS?f:n,C=void 0;d.transformationType===a.CLASS_TO_PLAIN?(C=e[A],C=d.applyCustomTransformations(C,o,A,e,d.transformationType),C=e[A]===C?m:C,C=d.transform(M,C,y,g,T,i+1)):(C=d.transform(M,m,y,g,T,i+1),C=d.applyCustomTransformations(C,o,A,e,d.transformationType)),c instanceof Map?c.set(f,C):c[f]=C}}(y)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),c}return e}return null===e||void 0===e?e:Boolean(e)}return null===e||void 0===e?e:Number(e)}return null===e||void 0===e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,a,o,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,a,this.transformationType);return void 0!==this.options.version&&(i=i.filter(function(t){return!t.options||s.checkVersion(t.options.since,t.options.until)})),i=this.options.groups&&this.options.groups.length?i.filter(function(t){return!t.options||s.checkGroups(t.options.groups)}):i.filter(function(t){return!t.options||!t.options.groups||!t.options.groups.length}),i.forEach(function(e){t=e.transformFn(t,o,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var a=r.defaultMetadataStorage.findTypeMetadata(t,e);return a?a.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,n=r.defaultMetadataStorage.getStrategy(t);"none"===n&&(n=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===n&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=r.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===a.PLAIN_TO_CLASS&&(i=i.map(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return a&&a.options&&a.options.name?a.options.name:e})),s=s.concat(i);var p=r.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);p.length>0&&(s=s.filter(function(t){return-1===p.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkGroups(a.options.groups)}):s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(a&&a.options&&a.options.groups&&a.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return o.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s=s.filter(function(t,e,r){return r.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return-1!==t.indexOf(e)})},t}(),t("TransformOperationExecutor",o)}}}),System.register("class-transformer/ClassTransformer",["class-transformer/TransformOperationExecutor"],function(t,e){var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){a=function(){function t(){}return t.prototype.classToPlain=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t.prototype.deserializeArray=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t}(),t("ClassTransformer",a)}}}),System.register("class-transformer/decorators",["class-transformer/ClassTransformer","class-transformer/storage","class-transformer/metadata/TypeMetadata","class-transformer/metadata/ExposeMetadata","class-transformer/metadata/ExcludeMetadata","class-transformer/metadata/TransformMetadata"],function(t,e){function r(t,e){return function(r,a){var o=new m.TransformMetadata(r.constructor,a,t,e);u.defaultMetadataStorage.addTransformMetadata(o)}}function a(t,e){return function(r,a){var o=Reflect.getMetadata("design:type",r,a),n=new c.TypeMetadata(r.constructor,a,o,t,e);u.defaultMetadataStorage.addTypeMetadata(n)}}function o(t){return function(e,r){var a=new d.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});u.defaultMetadataStorage.addExposeMetadata(a)}}function n(t){return function(e,r){var a=new l.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});u.defaultMetadataStorage.addExcludeMetadata(a)}}function s(t){return function(e,r,a){var o=new f.ClassTransformer,n=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=n.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?o.classToPlain(a,t):a.then(function(e){return o.classToPlain(e,t)})}}}function i(t){return function(e,r,a){var o=new f.ClassTransformer,n=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=n.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?o.classToClass(a,t):a.then(function(e){return o.classToClass(e,t)})}}}function p(t,e){return function(r,a,o){var n=new f.ClassTransformer,s=o.value;o.value=function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];var o=s.apply(this,r);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.plainToClass(t,o,e):o.then(function(r){return n.plainToClass(t,r,e)})}}}var f,u,c,d,l,m;e&&e.id;return t("Transform",r),t("Type",a),t("Expose",o),t("Exclude",n),t("TransformClassToPlain",s),t("TransformClassToClass",i),t("TransformPlainToClass",p),{setters:[function(t){f=t},function(t){u=t},function(t){c=t},function(t){d=t},function(t){l=t},function(t){m=t}],execute:function(){}}}),System.register("class-transformer/index",["class-transformer/ClassTransformer","class-transformer/decorators"],function(t,e){function r(t,e){return l.classToPlain(t,e)}function a(t,e,r){return l.classToPlainFromExist(t,e,r)}function o(t,e,r){return l.plainToClass(t,e,r)}function n(t,e,r){return l.plainToClassFromExist(t,e,r)}function s(t,e){return l.classToClass(t,e)}function i(t,e,r){return l.classToClassFromExist(t,e,r)}function p(t,e){return l.serialize(t,e)}function f(t,e,r){return l.deserialize(t,e,r)}function u(t,e,r){return l.deserializeArray(t,e,r)}function c(e){var r={};for(var a in e)"default"===a||y.hasOwnProperty(a)||(r[a]=e[a]);t(r)}var d,l,m;e&&e.id;t("classToPlain",r),t("classToPlainFromExist",a),t("plainToClass",o),t("plainToClassFromExist",n),t("classToClass",s),t("classToClassFromExist",i),t("serialize",p),t("deserialize",f),t("deserializeArray",u);var y={classToPlain:!0,classToPlainFromExist:!0,plainToClass:!0,plainToClassFromExist:!0,classToClass:!0,classToClassFromExist:!0,serialize:!0,deserialize:!0,deserializeArray:!0,TransformationType:!0,ClassTransformer:!0};return{setters:[function(e){d=e,t({ClassTransformer:e.ClassTransformer})},function(t){c(t)}],execute:function(){l=new d.ClassTransformer,function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(m||(m={})),t("TransformationType",m)}}}),System.register("class-transformer",["class-transformer/index"],function(t,e){function r(e){var r={};for(var a in e)"default"!==a&&(r[a]=e[a]);t(r)}e&&e.id;return{setters:[function(t){r(t)}],execute:function(){}}}); |
@@ -27,3 +27,3 @@ System.register("class-transformer/ClassTransformOptions", [], function (exports_1, context_1) { | ||
TypeMetadata = /** @class */ (function () { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction) { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction, options) { | ||
this.target = target; | ||
@@ -33,2 +33,3 @@ this.propertyName = propertyName; | ||
this.typeFunction = typeFunction; | ||
this.options = options; | ||
} | ||
@@ -363,3 +364,3 @@ return TypeMetadata; | ||
// ------------------------------------------------------------------------- | ||
this.transformedTypesMap = new Map(); | ||
this.recursionStack = new Set(); | ||
} | ||
@@ -372,8 +373,28 @@ // ------------------------------------------------------------------------- | ||
if (level === void 0) { level = 0; } | ||
if (value instanceof Array || value instanceof Set) { | ||
if (Array.isArray(value) || value instanceof Set) { | ||
var newValue_1 = arrayType && this.transformationType === TransformationType.PLAIN_TO_CLASS ? new arrayType() : []; | ||
value.forEach(function (subValue, index) { | ||
var subSource = source ? source[index] : undefined; | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue, level)) { | ||
var value_1 = _this.transform(subSource, subValue, targetType, undefined, subValue instanceof Map, level + 1); | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue)) { | ||
var realTargetType = void 0; | ||
if (typeof targetType !== "function" && targetType && targetType.options && targetType.options.discriminator && targetType.options.discriminator.property && targetType.options.discriminator.subTypes) { | ||
if (_this.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
realTargetType = targetType.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[targetType.options.discriminator.property]; }); | ||
var options = { newObject: newValue_1, object: subValue, property: undefined }; | ||
var newType = targetType.typeFunction(options); | ||
realTargetType === undefined ? realTargetType = newType : realTargetType = realTargetType.value; | ||
if (!targetType.options.keepDiscriminatorProperty) | ||
delete subValue[targetType.options.discriminator.property]; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
realTargetType = subValue.constructor; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[targetType.options.discriminator.property] = targetType.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
realTargetType = targetType; | ||
} | ||
var value_1 = _this.transform(subSource, subValue, realTargetType, undefined, subValue instanceof Map, level + 1); | ||
if (newValue_1 instanceof Set) { | ||
@@ -398,8 +419,14 @@ newValue_1.add(value_1); | ||
else if (targetType === String && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return String(value); | ||
} | ||
else if (targetType === Number && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Number(value); | ||
} | ||
else if (targetType === Boolean && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Boolean(value); | ||
@@ -423,3 +450,3 @@ } | ||
// add transformed type to prevent circular references | ||
this.transformedTypesMap.set(value, { level: level, object: value }); | ||
this.recursionStack.add(value); | ||
} | ||
@@ -451,4 +478,5 @@ var keys = this.getKeys(targetType, value); | ||
var exposeMetadata = storage_1.defaultMetadataStorage.findExposeMetadata(targetType, key); | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) { | ||
newValueKey = exposeMetadata.options.name; | ||
} | ||
} | ||
@@ -473,7 +501,29 @@ } | ||
else if (targetType) { | ||
var metadata = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata) { | ||
var metadata_1 = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata_1) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
type = metadata.typeFunction(options); | ||
isSubValueMap = isSubValueMap || metadata.reflectedType === Map; | ||
var newType = metadata_1.typeFunction(options); | ||
if (metadata_1.options && metadata_1.options.discriminator && metadata_1.options.discriminator.property && metadata_1.options.discriminator.subTypes) { | ||
if (!(value[valueKey] instanceof Array)) { | ||
if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
type = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[metadata_1.options.discriminator.property]; }); | ||
type === undefined ? type = newType : type = type.value; | ||
if (!metadata_1.options.keepDiscriminatorProperty) | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
type = subValue.constructor; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[metadata_1.options.discriminator.property] = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
type = metadata_1; | ||
} | ||
} | ||
else { | ||
type = newType; | ||
} | ||
isSubValueMap = isSubValueMap || metadata_1.reflectedType === Map; | ||
} | ||
@@ -487,3 +537,3 @@ else if (this_1.options.targetMaps) { // try to find a type in target maps | ||
// if value is an array try to get its custom array type | ||
var arrayType_1 = value[valueKey] instanceof Array ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
var arrayType_1 = Array.isArray(value[valueKey]) ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
// const subValueKey = TransformationType === TransformationType.PLAIN_TO_CLASS && newKeyName ? newKeyName : key; | ||
@@ -502,6 +552,19 @@ var subSource = source ? source[valueKey] : undefined; | ||
} | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue, level)) { | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue)) { | ||
var transformKey = this_1.transformationType === TransformationType.PLAIN_TO_CLASS ? newValueKey : key; | ||
var finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
var finalValue = void 0; | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
// Get original value | ||
finalValue = value[transformKey]; | ||
// Apply custom transformation | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
// If nothing change, it means no custom transformation was applied, so use the subValue. | ||
finalValue = (value[transformKey] === finalValue) ? subValue : finalValue; | ||
// Apply the default transformation | ||
finalValue = this_1.transform(subSource, finalValue, type, arrayType_1, isSubValueMap, level + 1); | ||
} | ||
else { | ||
finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
} | ||
if (newValue instanceof Map) { | ||
@@ -531,2 +594,5 @@ newValue.set(newValueKey, finalValue); | ||
} | ||
if (this.options.enableCircularCheck) { | ||
this.recursionStack.delete(value); | ||
} | ||
return newValue; | ||
@@ -568,5 +634,4 @@ } | ||
// preventing circular references | ||
TransformOperationExecutor.prototype.isCircular = function (object, level) { | ||
var transformed = this.transformedTypesMap.get(object); | ||
return transformed !== undefined && transformed.level < level; | ||
TransformOperationExecutor.prototype.isCircular = function (object) { | ||
return this.recursionStack.has(object); | ||
}; | ||
@@ -748,7 +813,8 @@ TransformOperationExecutor.prototype.getReflectedType = function (target, propertyName) { | ||
* Specifies a type of the property. | ||
* The given TypeFunction can return a constructor. A discriminator can be given in the options. | ||
*/ | ||
function Type(typeFunction) { | ||
function Type(typeFunction, options) { | ||
return function (target, key) { | ||
var type = Reflect.getMetadata("design:type", target, key); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction, options); | ||
storage_2.defaultMetadataStorage.addTypeMetadata(metadata); | ||
@@ -820,2 +886,21 @@ }; | ||
exports_11("TransformClassToClass", TransformClassToClass); | ||
/** | ||
* Return the class instance only with the exposed properties. | ||
*/ | ||
function TransformPlainToClass(classType, params) { | ||
return function (target, propertyKey, descriptor) { | ||
var classTransformer = new ClassTransformer_1.ClassTransformer(); | ||
var originalMethod = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var result = originalMethod.apply(this, args); | ||
var isPromise = !!result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function"; | ||
return isPromise ? result.then(function (data) { return classTransformer.plainToClass(classType, data, params); }) : classTransformer.plainToClass(classType, result, params); | ||
}; | ||
}; | ||
} | ||
exports_11("TransformPlainToClass", TransformPlainToClass); | ||
return { | ||
@@ -822,0 +907,0 @@ setters: [ |
@@ -1,1 +0,1 @@ | ||
System.register("class-transformer/ClassTransformOptions",[],function(t,e){"use strict";e&&e.id;return{setters:[],execute:function(){}}}),System.register("class-transformer/metadata/ExposeExcludeOptions",[],function(t,e){"use strict";e&&e.id;return{setters:[],execute:function(){}}}),System.register("class-transformer/metadata/TypeMetadata",[],function(t,e){"use strict";var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r,a){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=a}return t}(),t("TypeMetadata",r)}}}),System.register("class-transformer/metadata/ExposeMetadata",[],function(t,e){"use strict";var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}(),t("ExposeMetadata",r)}}}),System.register("class-transformer/metadata/ExcludeMetadata",[],function(t,e){"use strict";var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}(),t("ExcludeMetadata",r)}}}),System.register("class-transformer/metadata/TransformMetadata",[],function(t,e){"use strict";var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r,a){this.target=t,this.propertyName=e,this.transformFn=r,this.options=a}return t}(),t("TransformMetadata",r)}}}),System.register("class-transformer/metadata/MetadataStorage",["class-transformer/TransformOperationExecutor"],function(t,e){"use strict";var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){a=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,a){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?a===r.TransformationType.CLASS_TO_CLASS||a===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||a===r.TransformationType.CLASS_TO_PLAIN))})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),a=this._exposeMetadatas.get(t),n=a&&a.get(void 0);return r&&n||!r&&!n?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,a=t.get(e);a&&(r=Array.from(a.values()).filter(function(t){return void 0!==t.propertyName}));for(var n=[],o=0,s=this.getAncestors(e);o<s.length;o++){var i=s[o],f=t.get(i);if(f){var u=Array.from(f.values()).filter(function(t){return void 0!==t.propertyName});n.push.apply(n,u)}}return n.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var a=t.get(e);if(a){var n=a.get(r);if(n)return n}for(var o=0,s=this.getAncestors(e);o<s.length;o++){var i=s[o],f=t.get(i);if(f){var u=f.get(r);if(u)return u}}},t.prototype.findMetadatas=function(t,e,r){var a,n=t.get(e);n&&(a=n.get(r));for(var o=[],s=0,i=this.getAncestors(e);s<i.length;s++){var f=i[s],u=t.get(f);u&&u.has(r)&&o.push.apply(o,u.get(r))}return o.reverse().concat((a||[]).reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),t("MetadataStorage",a)}}}),System.register("class-transformer/storage",["class-transformer/metadata/MetadataStorage"],function(t,e){"use strict";var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){t("defaultMetadataStorage",a=new r.MetadataStorage)}}}),System.register("class-transformer/TransformOperationExecutor",["class-transformer/storage"],function(t,e){"use strict";var r,a,n;e&&e.id;return{setters:[function(t){r=t}],execute:function(){!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(a||(a={})),t("TransformationType",a),n=function(){function t(t,e){this.transformationType=t,this.options=e,this.transformedTypesMap=new Map}return t.prototype.transform=function(t,e,n,o,s,i){var f=this;if(void 0===i&&(i=0),e instanceof Array||e instanceof Set){var u=o&&this.transformationType===a.PLAIN_TO_CLASS?new o:[];return e.forEach(function(e,r){var o=t?t[r]:void 0;if(f.options.enableCircularCheck&&f.isCircular(e,i))f.transformationType===a.CLASS_TO_CLASS&&(u instanceof Set?u.add(e):u.push(e));else{var s=f.transform(o,e,n,void 0,e instanceof Map,i+1);u instanceof Set?u.add(s):u.push(s)}}),u}if(n!==String||s){if(n!==Number||s){if(n!==Boolean||s){if((n===Date||e instanceof Date)&&!s)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if("object"==typeof e&&null!==e){n||e.constructor===Object||(n=e.constructor),!n&&t&&(n=t.constructor),this.options.enableCircularCheck&&this.transformedTypesMap.set(e,{level:i,object:e});var p=this.getKeys(n,e),c=t||{};t||this.transformationType!==a.PLAIN_TO_CLASS&&this.transformationType!==a.CLASS_TO_CLASS||(c=s?new Map:n?new n:{});for(var d=this,l=0,m=p;l<m.length;l++){var y=m[l];!function(o){var f=o,u=o,p=o;if(!d.options.ignoreDecorators&&n)if(d.transformationType===a.PLAIN_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadataByCustomName(n,o);l&&(p=l.propertyName,u=l.propertyName)}else if(d.transformationType===a.CLASS_TO_PLAIN||d.transformationType===a.CLASS_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadata(n,o);l&&l.options&&l.options.name&&(u=l.options.name)}var m=void 0;m=e instanceof Map?e.get(f):e[f]instanceof Function?e[f]():e[f];var y=void 0,T=m instanceof Map;if(n&&s)y=n;else if(n){var S=r.defaultMetadataStorage.findTypeMetadata(n,p);if(S){var g={newObject:c,object:e,property:p};y=S.typeFunction(g),T=T||S.reflectedType===Map}else d.options.targetMaps&&d.options.targetMaps.filter(function(t){return t.target===n&&!!t.properties[p]}).forEach(function(t){return y=t.properties[p]})}var h=e[f]instanceof Array?d.getReflectedType(n,p):void 0,M=t?t[f]:void 0;if(c.constructor.prototype){var v=Object.getOwnPropertyDescriptor(c.constructor.prototype,u);if((d.transformationType===a.PLAIN_TO_CLASS||d.transformationType===a.CLASS_TO_CLASS)&&(c[u]instanceof Function||v&&!v.set))return"continue"}if(d.options.enableCircularCheck&&d.isCircular(m,i)){if(d.transformationType===a.CLASS_TO_CLASS){var _=m;_=d.applyCustomTransformations(_,n,o,e,d.transformationType),c instanceof Map?c.set(u,_):c[u]=_}}else{var C=d.transformationType===a.PLAIN_TO_CLASS?u:o,_=d.transform(M,m,y,h,T,i+1);_=d.applyCustomTransformations(_,n,C,e,d.transformationType),c instanceof Map?c.set(u,_):c[u]=_}}(y)}return c}return e}return Boolean(e)}return Number(e)}return String(e)},t.prototype.applyCustomTransformations=function(t,e,a,n,o){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,a,this.transformationType);return void 0!==this.options.version&&(i=i.filter(function(t){return!t.options||s.checkVersion(t.options.since,t.options.until)})),i=this.options.groups&&this.options.groups.length?i.filter(function(t){return!t.options||s.checkGroups(t.options.groups)}):i.filter(function(t){return!t.options||!t.options.groups||!t.options.groups.length}),i.forEach(function(e){t=e.transformFn(t,n,o)}),t},t.prototype.isCircular=function(t,e){var r=this.transformedTypesMap.get(t);return void 0!==r&&r.level<e},t.prototype.getReflectedType=function(t,e){if(t){var a=r.defaultMetadataStorage.findTypeMetadata(t,e);return a?a.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var n=this,o=r.defaultMetadataStorage.getStrategy(t);"none"===o&&(o=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===o&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=r.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===a.PLAIN_TO_CLASS&&(i=i.map(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return a&&a.options&&a.options.name?a.options.name:e})),s=s.concat(i);var f=r.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);f.length>0&&(s=s.filter(function(t){return-1===f.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||n.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||n.checkGroups(a.options.groups)}):s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(a&&a.options&&a.options.groups&&a.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return n.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s=s.filter(function(t,e,r){return r.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return-1!==t.indexOf(e)})},t}(),t("TransformOperationExecutor",n)}}}),System.register("class-transformer/ClassTransformer",["class-transformer/TransformOperationExecutor"],function(t,e){"use strict";var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){a=function(){function t(){}return t.prototype.classToPlain=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t.prototype.deserializeArray=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t}(),t("ClassTransformer",a)}}}),System.register("class-transformer/decorators",["class-transformer/ClassTransformer","class-transformer/storage","class-transformer/metadata/TypeMetadata","class-transformer/metadata/ExposeMetadata","class-transformer/metadata/ExcludeMetadata","class-transformer/metadata/TransformMetadata"],function(t,e){"use strict";function r(t,e){return function(r,a){var n=new l.TransformMetadata(r.constructor,a,t,e);u.defaultMetadataStorage.addTransformMetadata(n)}}function a(t){return function(e,r){var a=Reflect.getMetadata("design:type",e,r),n=new p.TypeMetadata(e.constructor,r,a,t);u.defaultMetadataStorage.addTypeMetadata(n)}}function n(t){return function(e,r){var a=new c.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});u.defaultMetadataStorage.addExposeMetadata(a)}}function o(t){return function(e,r){var a=new d.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});u.defaultMetadataStorage.addExcludeMetadata(a)}}function s(t){return function(e,r,a){var n=new f.ClassTransformer,o=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=o.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?n.classToPlain(a,t):a.then(function(e){return n.classToPlain(e,t)})}}}function i(t){return function(e,r,a){var n=new f.ClassTransformer,o=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=o.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?n.classToClass(a,t):a.then(function(e){return n.classToClass(e,t)})}}}var f,u,p,c,d,l;e&&e.id;return t("Transform",r),t("Type",a),t("Expose",n),t("Exclude",o),t("TransformClassToPlain",s),t("TransformClassToClass",i),{setters:[function(t){f=t},function(t){u=t},function(t){p=t},function(t){c=t},function(t){d=t},function(t){l=t}],execute:function(){}}}),System.register("class-transformer/index",["class-transformer/ClassTransformer","class-transformer/decorators"],function(t,e){"use strict";function r(t,e){return l.classToPlain(t,e)}function a(t,e,r){return l.classToPlainFromExist(t,e,r)}function n(t,e,r){return l.plainToClass(t,e,r)}function o(t,e,r){return l.plainToClassFromExist(t,e,r)}function s(t,e){return l.classToClass(t,e)}function i(t,e,r){return l.classToClassFromExist(t,e,r)}function f(t,e){return l.serialize(t,e)}function u(t,e,r){return l.deserialize(t,e,r)}function p(t,e,r){return l.deserializeArray(t,e,r)}function c(e){var r={};for(var a in e)"default"===a||y.hasOwnProperty(a)||(r[a]=e[a]);t(r)}var d,l,m;e&&e.id;t("classToPlain",r),t("classToPlainFromExist",a),t("plainToClass",n),t("plainToClassFromExist",o),t("classToClass",s),t("classToClassFromExist",i),t("serialize",f),t("deserialize",u),t("deserializeArray",p);var y={classToPlain:!0,classToPlainFromExist:!0,plainToClass:!0,plainToClassFromExist:!0,classToClass:!0,classToClassFromExist:!0,serialize:!0,deserialize:!0,deserializeArray:!0,TransformationType:!0,ClassTransformer:!0};return{setters:[function(e){d=e,t({ClassTransformer:e.ClassTransformer})},function(t){c(t)}],execute:function(){l=new d.ClassTransformer,function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(m||(m={})),t("TransformationType",m)}}}),System.register("class-transformer",["class-transformer/index"],function(t,e){"use strict";function r(e){var r={};for(var a in e)"default"!==a&&(r[a]=e[a]);t(r)}e&&e.id;return{setters:[function(t){r(t)}],execute:function(){}}}); | ||
System.register("class-transformer/ClassTransformOptions",[],function(t,e){"use strict";e&&e.id;return{setters:[],execute:function(){}}}),System.register("class-transformer/metadata/ExposeExcludeOptions",[],function(t,e){"use strict";e&&e.id;return{setters:[],execute:function(){}}}),System.register("class-transformer/metadata/TypeMetadata",[],function(t,e){"use strict";var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r,a,o){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=a,this.options=o}return t}(),t("TypeMetadata",r)}}}),System.register("class-transformer/metadata/ExposeMetadata",[],function(t,e){"use strict";var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}(),t("ExposeMetadata",r)}}}),System.register("class-transformer/metadata/ExcludeMetadata",[],function(t,e){"use strict";var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r){this.target=t,this.propertyName=e,this.options=r}return t}(),t("ExcludeMetadata",r)}}}),System.register("class-transformer/metadata/TransformMetadata",[],function(t,e){"use strict";var r;e&&e.id;return{setters:[],execute:function(){r=function(){function t(t,e,r,a){this.target=t,this.propertyName=e,this.transformFn=r,this.options=a}return t}(),t("TransformMetadata",r)}}}),System.register("class-transformer/metadata/MetadataStorage",["class-transformer/TransformOperationExecutor"],function(t,e){"use strict";var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){a=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(t){this._typeMetadatas.has(t.target)||this._typeMetadatas.set(t.target,new Map),this._typeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addTransformMetadata=function(t){this._transformMetadatas.has(t.target)||this._transformMetadatas.set(t.target,new Map),this._transformMetadatas.get(t.target).has(t.propertyName)||this._transformMetadatas.get(t.target).set(t.propertyName,[]),this._transformMetadatas.get(t.target).get(t.propertyName).push(t)},t.prototype.addExposeMetadata=function(t){this._exposeMetadatas.has(t.target)||this._exposeMetadatas.set(t.target,new Map),this._exposeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.addExcludeMetadata=function(t){this._excludeMetadatas.has(t.target)||this._excludeMetadatas.set(t.target,new Map),this._excludeMetadatas.get(t.target).set(t.propertyName,t)},t.prototype.findTransformMetadatas=function(t,e,a){return this.findMetadatas(this._transformMetadatas,t,e).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?a===r.TransformationType.CLASS_TO_CLASS||a===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||a===r.TransformationType.CLASS_TO_PLAIN))})},t.prototype.findExcludeMetadata=function(t,e){return this.findMetadata(this._excludeMetadatas,t,e)},t.prototype.findExposeMetadata=function(t,e){return this.findMetadata(this._exposeMetadatas,t,e)},t.prototype.findExposeMetadataByCustomName=function(t,e){return this.getExposedMetadatas(t).find(function(t){return t.options&&t.options.name===e})},t.prototype.findTypeMetadata=function(t,e){return this.findMetadata(this._typeMetadatas,t,e)},t.prototype.getStrategy=function(t){var e=this._excludeMetadatas.get(t),r=e&&e.get(void 0),a=this._exposeMetadatas.get(t),o=a&&a.get(void 0);return r&&o||!r&&!o?"none":r?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(t){return this.getMetadata(this._exposeMetadatas,t)},t.prototype.getExcludedMetadatas=function(t){return this.getMetadata(this._excludeMetadatas,t)},t.prototype.getExposedProperties=function(t,e){return this.getExposedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.getExcludedProperties=function(t,e){return this.getExcludedMetadatas(t).filter(function(t){return!t.options||(!0===t.options.toClassOnly&&!0===t.options.toPlainOnly||(!0===t.options.toClassOnly?e===r.TransformationType.CLASS_TO_CLASS||e===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||e===r.TransformationType.CLASS_TO_PLAIN))}).map(function(t){return t.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(t,e){var r,a=t.get(e);a&&(r=Array.from(a.values()).filter(function(t){return void 0!==t.propertyName}));for(var o=[],n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var u=Array.from(p.values()).filter(function(t){return void 0!==t.propertyName});o.push.apply(o,u)}}return o.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var a=t.get(e);if(a){var o=a.get(r);if(o)return o}for(var n=0,s=this.getAncestors(e);n<s.length;n++){var i=s[n],p=t.get(i);if(p){var u=p.get(r);if(u)return u}}},t.prototype.findMetadatas=function(t,e,r){var a,o=t.get(e);o&&(a=o.get(r));for(var n=[],s=0,i=this.getAncestors(e);s<i.length;s++){var p=i[s],u=t.get(p);u&&u.has(r)&&n.push.apply(n,u.get(r))}return n.reverse().concat((a||[]).reverse())},t.prototype.getAncestors=function(t){if(!t)return[];if(!this._ancestorsMap.has(t)){for(var e=[],r=Object.getPrototypeOf(t.prototype.constructor);void 0!==r.prototype;r=Object.getPrototypeOf(r.prototype.constructor))e.push(r);this._ancestorsMap.set(t,e)}return this._ancestorsMap.get(t)},t}(),t("MetadataStorage",a)}}}),System.register("class-transformer/storage",["class-transformer/metadata/MetadataStorage"],function(t,e){"use strict";var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){t("defaultMetadataStorage",a=new r.MetadataStorage)}}}),System.register("class-transformer/TransformOperationExecutor",["class-transformer/storage"],function(t,e){"use strict";var r,a,o;e&&e.id;return{setters:[function(t){r=t}],execute:function(){!function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(a||(a={})),t("TransformationType",a),o=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,o,n,s,i){var p=this;if(void 0===i&&(i=0),Array.isArray(e)||e instanceof Set){var u=n&&this.transformationType===a.PLAIN_TO_CLASS?new n:[];return e.forEach(function(e,r){var n=t?t[r]:void 0;if(p.options.enableCircularCheck&&p.isCircular(e))p.transformationType===a.CLASS_TO_CLASS&&(u instanceof Set?u.add(e):u.push(e));else{var s=void 0;if("function"!=typeof o&&o&&o.options&&o.options.discriminator&&o.options.discriminator.property&&o.options.discriminator.subTypes){if(p.transformationType===a.PLAIN_TO_CLASS){s=o.options.discriminator.subTypes.find(function(t){return t.name===e[o.options.discriminator.property]});var f={newObject:u,object:e,property:void 0},c=o.typeFunction(f);s=void 0===s?c:s.value,o.options.keepDiscriminatorProperty||delete e[o.options.discriminator.property]}p.transformationType===a.CLASS_TO_CLASS&&(s=e.constructor),p.transformationType===a.CLASS_TO_PLAIN&&(e[o.options.discriminator.property]=o.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else s=o;var d=p.transform(n,e,s,void 0,e instanceof Map,i+1);u instanceof Set?u.add(d):u.push(d)}}),u}if(o!==String||s){if(o!==Number||s){if(o!==Boolean||s){if((o===Date||e instanceof Date)&&!s)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if("object"==typeof e&&null!==e){o||e.constructor===Object||(o=e.constructor),!o&&t&&(o=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var f=this.getKeys(o,e),c=t||{};t||this.transformationType!==a.PLAIN_TO_CLASS&&this.transformationType!==a.CLASS_TO_CLASS||(c=s?new Map:o?new o:{});for(var d=this,l=0,m=f;l<m.length;l++){var y=m[l];!function(n){var p=n,u=n,f=n;if(!d.options.ignoreDecorators&&o)if(d.transformationType===a.PLAIN_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadataByCustomName(o,n);l&&(f=l.propertyName,u=l.propertyName)}else if(d.transformationType===a.CLASS_TO_PLAIN||d.transformationType===a.CLASS_TO_CLASS){var l=r.defaultMetadataStorage.findExposeMetadata(o,n);l&&l.options&&l.options.name&&(u=l.options.name)}var m=void 0;m=e instanceof Map?e.get(p):e[p]instanceof Function?e[p]():e[p];var y=void 0,T=m instanceof Map;if(o&&s)y=o;else if(o){var S=r.defaultMetadataStorage.findTypeMetadata(o,f);if(S){var h={newObject:c,object:e,property:f},v=S.typeFunction(h);S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[p]instanceof Array?y=S:(d.transformationType===a.PLAIN_TO_CLASS&&(y=S.options.discriminator.subTypes.find(function(t){return t.name===m[S.options.discriminator.property]}),y=void 0===y?v:y.value,S.options.keepDiscriminatorProperty||delete m[S.options.discriminator.property]),d.transformationType===a.CLASS_TO_CLASS&&(y=m.constructor),d.transformationType===a.CLASS_TO_PLAIN&&(m[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===m.constructor}).name)):y=v,T=T||S.reflectedType===Map}else d.options.targetMaps&&d.options.targetMaps.filter(function(t){return t.target===o&&!!t.properties[f]}).forEach(function(t){return y=t.properties[f]})}var g=Array.isArray(e[p])?d.getReflectedType(o,f):void 0,M=t?t[p]:void 0;if(c.constructor.prototype){var _=Object.getOwnPropertyDescriptor(c.constructor.prototype,u);if((d.transformationType===a.PLAIN_TO_CLASS||d.transformationType===a.CLASS_TO_CLASS)&&(c[u]instanceof Function||_&&!_.set))return"continue"}if(d.options.enableCircularCheck&&d.isCircular(m)){if(d.transformationType===a.CLASS_TO_CLASS){var C=m;C=d.applyCustomTransformations(C,o,n,e,d.transformationType),c instanceof Map?c.set(u,C):c[u]=C}}else{var A=d.transformationType===a.PLAIN_TO_CLASS?u:n,C=void 0;d.transformationType===a.CLASS_TO_PLAIN?(C=e[A],C=d.applyCustomTransformations(C,o,A,e,d.transformationType),C=e[A]===C?m:C,C=d.transform(M,C,y,g,T,i+1)):(C=d.transform(M,m,y,g,T,i+1),C=d.applyCustomTransformations(C,o,A,e,d.transformationType)),c instanceof Map?c.set(u,C):c[u]=C}}(y)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),c}return e}return null===e||void 0===e?e:Boolean(e)}return null===e||void 0===e?e:Number(e)}return null===e||void 0===e?e:String(e)},t.prototype.applyCustomTransformations=function(t,e,a,o,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,a,this.transformationType);return void 0!==this.options.version&&(i=i.filter(function(t){return!t.options||s.checkVersion(t.options.since,t.options.until)})),i=this.options.groups&&this.options.groups.length?i.filter(function(t){return!t.options||s.checkGroups(t.options.groups)}):i.filter(function(t){return!t.options||!t.options.groups||!t.options.groups.length}),i.forEach(function(e){t=e.transformFn(t,o,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var a=r.defaultMetadataStorage.findTypeMetadata(t,e);return a?a.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,n=r.defaultMetadataStorage.getStrategy(t);"none"===n&&(n=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===n&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=r.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===a.PLAIN_TO_CLASS&&(i=i.map(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return a&&a.options&&a.options.name?a.options.name:e})),s=s.concat(i);var p=r.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);p.length>0&&(s=s.filter(function(t){return-1===p.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||o.checkGroups(a.options.groups)}):s.filter(function(e){var a=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(a&&a.options&&a.options.groups&&a.options.groups.length)})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(s=s.filter(function(t){return o.options.excludePrefixes.every(function(e){return t.substr(0,e.length)!==e})})),s=s.filter(function(t,e,r){return r.indexOf(t)===e})},t.prototype.checkVersion=function(t,e){var r=!0;return r&&t&&(r=this.options.version>=t),r&&e&&(r=this.options.version<e),r},t.prototype.checkGroups=function(t){return!t||this.options.groups.some(function(e){return-1!==t.indexOf(e)})},t}(),t("TransformOperationExecutor",o)}}}),System.register("class-transformer/ClassTransformer",["class-transformer/TransformOperationExecutor"],function(t,e){"use strict";var r,a;e&&e.id;return{setters:[function(t){r=t}],execute:function(){a=function(){function t(){}return t.prototype.classToPlain=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToPlainFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,a||{}).transform(t,e,void 0,void 0,void 0,void 0)},t.prototype.classToClass=function(t,e){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,e||{}).transform(void 0,t,void 0,void 0,void 0,void 0)},t.prototype.classToClassFromExist=function(t,e,a){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,a||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.serialize=function(t,e){return JSON.stringify(this.classToPlain(t,e))},t.prototype.deserialize=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t.prototype.deserializeArray=function(t,e,r){var a=JSON.parse(e);return this.plainToClass(t,a,r)},t}(),t("ClassTransformer",a)}}}),System.register("class-transformer/decorators",["class-transformer/ClassTransformer","class-transformer/storage","class-transformer/metadata/TypeMetadata","class-transformer/metadata/ExposeMetadata","class-transformer/metadata/ExcludeMetadata","class-transformer/metadata/TransformMetadata"],function(t,e){"use strict";function r(t,e){return function(r,a){var o=new m.TransformMetadata(r.constructor,a,t,e);f.defaultMetadataStorage.addTransformMetadata(o)}}function a(t,e){return function(r,a){var o=Reflect.getMetadata("design:type",r,a),n=new c.TypeMetadata(r.constructor,a,o,t,e);f.defaultMetadataStorage.addTypeMetadata(n)}}function o(t){return function(e,r){var a=new d.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});f.defaultMetadataStorage.addExposeMetadata(a)}}function n(t){return function(e,r){var a=new l.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});f.defaultMetadataStorage.addExcludeMetadata(a)}}function s(t){return function(e,r,a){var o=new u.ClassTransformer,n=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=n.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?o.classToPlain(a,t):a.then(function(e){return o.classToPlain(e,t)})}}}function i(t){return function(e,r,a){var o=new u.ClassTransformer,n=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var a=n.apply(this,e);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?o.classToClass(a,t):a.then(function(e){return o.classToClass(e,t)})}}}function p(t,e){return function(r,a,o){var n=new u.ClassTransformer,s=o.value;o.value=function(){for(var r=[],a=0;a<arguments.length;a++)r[a]=arguments[a];var o=s.apply(this,r);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.plainToClass(t,o,e):o.then(function(r){return n.plainToClass(t,r,e)})}}}var u,f,c,d,l,m;e&&e.id;return t("Transform",r),t("Type",a),t("Expose",o),t("Exclude",n),t("TransformClassToPlain",s),t("TransformClassToClass",i),t("TransformPlainToClass",p),{setters:[function(t){u=t},function(t){f=t},function(t){c=t},function(t){d=t},function(t){l=t},function(t){m=t}],execute:function(){}}}),System.register("class-transformer/index",["class-transformer/ClassTransformer","class-transformer/decorators"],function(t,e){"use strict";function r(t,e){return l.classToPlain(t,e)}function a(t,e,r){return l.classToPlainFromExist(t,e,r)}function o(t,e,r){return l.plainToClass(t,e,r)}function n(t,e,r){return l.plainToClassFromExist(t,e,r)}function s(t,e){return l.classToClass(t,e)}function i(t,e,r){return l.classToClassFromExist(t,e,r)}function p(t,e){return l.serialize(t,e)}function u(t,e,r){return l.deserialize(t,e,r)}function f(t,e,r){return l.deserializeArray(t,e,r)}function c(e){var r={};for(var a in e)"default"===a||y.hasOwnProperty(a)||(r[a]=e[a]);t(r)}var d,l,m;e&&e.id;t("classToPlain",r),t("classToPlainFromExist",a),t("plainToClass",o),t("plainToClassFromExist",n),t("classToClass",s),t("classToClassFromExist",i),t("serialize",p),t("deserialize",u),t("deserializeArray",f);var y={classToPlain:!0,classToPlainFromExist:!0,plainToClass:!0,plainToClassFromExist:!0,classToClass:!0,classToClassFromExist:!0,serialize:!0,deserialize:!0,deserializeArray:!0,TransformationType:!0,ClassTransformer:!0};return{setters:[function(e){d=e,t({ClassTransformer:e.ClassTransformer})},function(t){c(t)}],execute:function(){l=new d.ClassTransformer,function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"}(m||(m={})),t("TransformationType",m)}}}),System.register("class-transformer",["class-transformer/index"],function(t,e){"use strict";function r(e){var r={};for(var a in e)"default"!==a&&(r[a]=e[a]);t(r)}e&&e.id;return{setters:[function(t){r(t)}],execute:function(){}}}); |
@@ -1,2 +0,2 @@ | ||
import { ExposeOptions, ExcludeOptions, TypeOptions, TransformOptions } from "./metadata/ExposeExcludeOptions"; | ||
import { ExposeOptions, ExcludeOptions, TypeHelpOptions, TransformOptions, TypeOptions } from "./metadata/ExposeExcludeOptions"; | ||
import { ClassTransformOptions } from "./ClassTransformOptions"; | ||
@@ -10,4 +10,5 @@ import { TransformationType } from "./TransformOperationExecutor"; | ||
* Specifies a type of the property. | ||
* The given TypeFunction can return a constructor. A discriminator can be given in the options. | ||
*/ | ||
export declare function Type(typeFunction?: (type?: TypeOptions) => Function): (target: any, key: string) => void; | ||
export declare function Type(typeFunction: (type?: TypeHelpOptions) => Function, options?: TypeOptions): (target: any, key: string) => void; | ||
/** | ||
@@ -33,1 +34,5 @@ * Marks property as included in the process of transformation. By default it includes the property for both | ||
export declare function TransformClassToClass(params?: ClassTransformOptions): Function; | ||
/** | ||
* Return the class instance only with the exposed properties. | ||
*/ | ||
export declare function TransformPlainToClass(classType: any, params?: ClassTransformOptions): Function; |
@@ -21,7 +21,8 @@ "use strict"; | ||
* Specifies a type of the property. | ||
* The given TypeFunction can return a constructor. A discriminator can be given in the options. | ||
*/ | ||
function Type(typeFunction) { | ||
function Type(typeFunction, options) { | ||
return function (target, key) { | ||
var type = Reflect.getMetadata("design:type", target, key); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction); | ||
var metadata = new TypeMetadata_1.TypeMetadata(target.constructor, key, type, typeFunction, options); | ||
storage_1.defaultMetadataStorage.addTypeMetadata(metadata); | ||
@@ -93,3 +94,22 @@ }; | ||
exports.TransformClassToClass = TransformClassToClass; | ||
/** | ||
* Return the class instance only with the exposed properties. | ||
*/ | ||
function TransformPlainToClass(classType, params) { | ||
return function (target, propertyKey, descriptor) { | ||
var classTransformer = new ClassTransformer_1.ClassTransformer(); | ||
var originalMethod = descriptor.value; | ||
descriptor.value = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var result = originalMethod.apply(this, args); | ||
var isPromise = !!result && (typeof result === "object" || typeof result === "function") && typeof result.then === "function"; | ||
return isPromise ? result.then(function (data) { return classTransformer.plainToClass(classType, data, params); }) : classTransformer.plainToClass(classType, result, params); | ||
}; | ||
}; | ||
} | ||
exports.TransformPlainToClass = TransformPlainToClass; | ||
//# sourceMappingURL=decorators.js.map |
@@ -9,2 +9,9 @@ export interface TransformOptions { | ||
export interface TypeOptions { | ||
discriminator?: Discriminator; | ||
/** | ||
* Is false by default. | ||
*/ | ||
keepDiscriminatorProperty?: boolean; | ||
} | ||
export interface TypeHelpOptions { | ||
newObject: any; | ||
@@ -26,1 +33,9 @@ object: Object; | ||
} | ||
export interface Discriminator { | ||
property: string; | ||
subTypes: JsonSubType[]; | ||
} | ||
export interface JsonSubType { | ||
value: new (...args: any[]) => any; | ||
name: string; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { TypeOptions } from "./ExposeExcludeOptions"; | ||
import { TypeHelpOptions, TypeOptions } from "./ExposeExcludeOptions"; | ||
export declare class TypeMetadata { | ||
@@ -6,4 +6,5 @@ target: Function; | ||
reflectedType: any; | ||
typeFunction: (options?: TypeOptions) => Function; | ||
constructor(target: Function, propertyName: string, reflectedType: any, typeFunction: (options?: TypeOptions) => Function); | ||
typeFunction: (options?: TypeHelpOptions) => Function; | ||
options: TypeOptions; | ||
constructor(target: Function, propertyName: string, reflectedType: any, typeFunction: (options?: TypeHelpOptions) => Function, options: TypeOptions); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var TypeMetadata = /** @class */ (function () { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction) { | ||
function TypeMetadata(target, propertyName, reflectedType, typeFunction, options) { | ||
this.target = target; | ||
@@ -9,2 +9,3 @@ this.propertyName = propertyName; | ||
this.typeFunction = typeFunction; | ||
this.options = options; | ||
} | ||
@@ -11,0 +12,0 @@ return TypeMetadata; |
{ | ||
"name": "class-transformer", | ||
"version": "0.1.10", | ||
"version": "0.2.0", | ||
"description": "Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
102
README.md
@@ -105,3 +105,3 @@ # class-transformer | ||
fetch("users.json").then((users: Object[]) => { | ||
const realUsers = plainToClass(users); | ||
const realUsers = plainToClass(User, users); | ||
// now each user in realUsers is instance of User class | ||
@@ -271,2 +271,74 @@ }); | ||
### Providing more than one type option | ||
In case the nested object can be of different types, you can provide an additional options object, | ||
that specifies a discriminator. The discriminator option must define a `property` that holds the sub | ||
type name for the object and the possible `subTypes`, the nested object can converted to. A sub type | ||
has a `value`, that holds the constructor of the Type and the `name`, that can match with the `property` | ||
of the discriminator. | ||
Lets say we have an album that has a top photo. But this photo can be of certain different types. | ||
And we are trying to convert album plain object to class object. The plain object input has to define | ||
the additional property `__type`. This property is removed during transformation by default: | ||
**JSON input**: | ||
```json | ||
{ | ||
"id": 1, | ||
"name": "foo", | ||
"topPhoto": { | ||
"id": 9, | ||
"filename": "cool_wale.jpg", | ||
"depth": 1245, | ||
"__type": "underwater" | ||
} | ||
} | ||
``` | ||
```javascript | ||
import {Type, plainToClass} from "class-transformer"; | ||
export abstract class Photo { | ||
id: number; | ||
filename: string; | ||
} | ||
export class Landscape extends Photo { | ||
panorama: boolean; | ||
} | ||
export class Portrait extends Photo { | ||
person: Person; | ||
} | ||
export class UnderWater extends Photo { | ||
depth: number; | ||
} | ||
export class Album { | ||
id: number; | ||
name: string; | ||
@Type(() => Photo, { | ||
discriminator: { | ||
property: "__type", | ||
subTypes: [ | ||
{ value: Landscape, name: "landscape" }, | ||
{ value: Portrait, name: "portrait" }, | ||
{ value: UnderWater, name: "underwater" } | ||
] | ||
} | ||
}) | ||
topPhoto: Landscape | Portrait | UnderWater; | ||
} | ||
let album = plainToClass(Album, albumJson); | ||
// now album is Album object with a UnderWater object without `__type` property. | ||
``` | ||
Hint: The same applies for arrays with different sub types. Moreover you can specify `keepDiscriminatorProperty: true` | ||
in the options to keep the discriminator property also inside your resulting class. | ||
## Exposing getters and method return values | ||
@@ -535,3 +607,3 @@ | ||
```javascript | ||
import {ArrayType} from "class-transformer"; | ||
import {Type} from "class-transformer"; | ||
@@ -552,3 +624,3 @@ export class Photo { | ||
```javascript | ||
import {ArrayType} from "class-transformer"; | ||
import {Type} from "class-transformer"; | ||
@@ -572,2 +644,25 @@ export class AlbumCollection extends Array<Album> { | ||
ES6 collections `Set` and `Map` also require the `@Type` decorator: | ||
```javascript | ||
export class Skill { | ||
name: string; | ||
} | ||
export class Weapon { | ||
name: string; | ||
range: number; | ||
} | ||
export class Player { | ||
name: string; | ||
@Type(() => Skill) | ||
skills: Set<Skill>; | ||
@Type(() => Weapon) | ||
weapons: Map<string, Weapon>; | ||
} | ||
``` | ||
## Additional data transformation | ||
@@ -619,2 +714,3 @@ | ||
| `@TransformClassToClass` | `@TransformClassToClass({ groups: ["user"] })` | Transform the method return with classToClass and expose the properties on the class. | ||
| `@TransformPlainToClass` | `@TransformPlainToClass(User, { groups: ["user"] })` | Transform the method return with plainToClass and expose the properties on the class. | ||
@@ -621,0 +717,0 @@ The above decorators accept one optional argument: |
import { ClassTransformOptions } from "./ClassTransformOptions"; | ||
import { TypeMetadata } from "./metadata/TypeMetadata"; | ||
export declare enum TransformationType { | ||
@@ -10,5 +11,5 @@ PLAIN_TO_CLASS = 0, | ||
private options; | ||
private transformedTypesMap; | ||
private recursionStack; | ||
constructor(transformationType: TransformationType, options: ClassTransformOptions); | ||
transform(source: Object | Object[] | any, value: Object | Object[] | any, targetType: Function, arrayType: Function, isMap: boolean, level?: number): any; | ||
transform(source: Object | Object[] | any, value: Object | Object[] | any, targetType: Function | TypeMetadata, arrayType: Function, isMap: boolean, level?: number): any; | ||
private applyCustomTransformations; | ||
@@ -15,0 +16,0 @@ private isCircular; |
@@ -20,3 +20,3 @@ "use strict"; | ||
// ------------------------------------------------------------------------- | ||
this.transformedTypesMap = new Map(); | ||
this.recursionStack = new Set(); | ||
} | ||
@@ -29,8 +29,28 @@ // ------------------------------------------------------------------------- | ||
if (level === void 0) { level = 0; } | ||
if (value instanceof Array || value instanceof Set) { | ||
if (Array.isArray(value) || value instanceof Set) { | ||
var newValue_1 = arrayType && this.transformationType === TransformationType.PLAIN_TO_CLASS ? new arrayType() : []; | ||
value.forEach(function (subValue, index) { | ||
var subSource = source ? source[index] : undefined; | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue, level)) { | ||
var value_1 = _this.transform(subSource, subValue, targetType, undefined, subValue instanceof Map, level + 1); | ||
if (!_this.options.enableCircularCheck || !_this.isCircular(subValue)) { | ||
var realTargetType = void 0; | ||
if (typeof targetType !== "function" && targetType && targetType.options && targetType.options.discriminator && targetType.options.discriminator.property && targetType.options.discriminator.subTypes) { | ||
if (_this.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
realTargetType = targetType.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[targetType.options.discriminator.property]; }); | ||
var options = { newObject: newValue_1, object: subValue, property: undefined }; | ||
var newType = targetType.typeFunction(options); | ||
realTargetType === undefined ? realTargetType = newType : realTargetType = realTargetType.value; | ||
if (!targetType.options.keepDiscriminatorProperty) | ||
delete subValue[targetType.options.discriminator.property]; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
realTargetType = subValue.constructor; | ||
} | ||
if (_this.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[targetType.options.discriminator.property] = targetType.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
realTargetType = targetType; | ||
} | ||
var value_1 = _this.transform(subSource, subValue, realTargetType, undefined, subValue instanceof Map, level + 1); | ||
if (newValue_1 instanceof Set) { | ||
@@ -55,8 +75,14 @@ newValue_1.add(value_1); | ||
else if (targetType === String && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return String(value); | ||
} | ||
else if (targetType === Number && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Number(value); | ||
} | ||
else if (targetType === Boolean && !isMap) { | ||
if (value === null || value === undefined) | ||
return value; | ||
return Boolean(value); | ||
@@ -80,3 +106,3 @@ } | ||
// add transformed type to prevent circular references | ||
this.transformedTypesMap.set(value, { level: level, object: value }); | ||
this.recursionStack.add(value); | ||
} | ||
@@ -108,4 +134,5 @@ var keys = this.getKeys(targetType, value); | ||
var exposeMetadata = storage_1.defaultMetadataStorage.findExposeMetadata(targetType, key); | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) | ||
if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) { | ||
newValueKey = exposeMetadata.options.name; | ||
} | ||
} | ||
@@ -130,7 +157,29 @@ } | ||
else if (targetType) { | ||
var metadata = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata) { | ||
var metadata_1 = storage_1.defaultMetadataStorage.findTypeMetadata(targetType, propertyName); | ||
if (metadata_1) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
type = metadata.typeFunction(options); | ||
isSubValueMap = isSubValueMap || metadata.reflectedType === Map; | ||
var newType = metadata_1.typeFunction(options); | ||
if (metadata_1.options && metadata_1.options.discriminator && metadata_1.options.discriminator.property && metadata_1.options.discriminator.subTypes) { | ||
if (!(value[valueKey] instanceof Array)) { | ||
if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
type = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.name === subValue[metadata_1.options.discriminator.property]; }); | ||
type === undefined ? type = newType : type = type.value; | ||
if (!metadata_1.options.keepDiscriminatorProperty) | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
type = subValue.constructor; | ||
} | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
subValue[metadata_1.options.discriminator.property] = metadata_1.options.discriminator.subTypes.find(function (subType) { return subType.value === subValue.constructor; }).name; | ||
} | ||
} | ||
else { | ||
type = metadata_1; | ||
} | ||
} | ||
else { | ||
type = newType; | ||
} | ||
isSubValueMap = isSubValueMap || metadata_1.reflectedType === Map; | ||
} | ||
@@ -144,3 +193,3 @@ else if (this_1.options.targetMaps) { // try to find a type in target maps | ||
// if value is an array try to get its custom array type | ||
var arrayType_1 = value[valueKey] instanceof Array ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
var arrayType_1 = Array.isArray(value[valueKey]) ? this_1.getReflectedType(targetType, propertyName) : undefined; | ||
// const subValueKey = TransformationType === TransformationType.PLAIN_TO_CLASS && newKeyName ? newKeyName : key; | ||
@@ -159,6 +208,19 @@ var subSource = source ? source[valueKey] : undefined; | ||
} | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue, level)) { | ||
if (!this_1.options.enableCircularCheck || !this_1.isCircular(subValue)) { | ||
var transformKey = this_1.transformationType === TransformationType.PLAIN_TO_CLASS ? newValueKey : key; | ||
var finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
var finalValue = void 0; | ||
if (this_1.transformationType === TransformationType.CLASS_TO_PLAIN) { | ||
// Get original value | ||
finalValue = value[transformKey]; | ||
// Apply custom transformation | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
// If nothing change, it means no custom transformation was applied, so use the subValue. | ||
finalValue = (value[transformKey] === finalValue) ? subValue : finalValue; | ||
// Apply the default transformation | ||
finalValue = this_1.transform(subSource, finalValue, type, arrayType_1, isSubValueMap, level + 1); | ||
} | ||
else { | ||
finalValue = this_1.transform(subSource, subValue, type, arrayType_1, isSubValueMap, level + 1); | ||
finalValue = this_1.applyCustomTransformations(finalValue, targetType, transformKey, value, this_1.transformationType); | ||
} | ||
if (newValue instanceof Map) { | ||
@@ -188,2 +250,5 @@ newValue.set(newValueKey, finalValue); | ||
} | ||
if (this.options.enableCircularCheck) { | ||
this.recursionStack.delete(value); | ||
} | ||
return newValue; | ||
@@ -225,5 +290,4 @@ } | ||
// preventing circular references | ||
TransformOperationExecutor.prototype.isCircular = function (object, level) { | ||
var transformed = this.transformedTypesMap.get(object); | ||
return transformed !== undefined && transformed.level < level; | ||
TransformOperationExecutor.prototype.isCircular = function (object) { | ||
return this.recursionStack.has(object); | ||
}; | ||
@@ -230,0 +294,0 @@ TransformOperationExecutor.prototype.getReflectedType = function (target, propertyName) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
453718
5024
798