class-transformer
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -440,10 +440,17 @@ define("class-transformer/ClassTransformOptions", ["require", "exports"], function (require, exports) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
var newType = metadata_1.typeFunction(options); | ||
var newType = metadata_1.typeFunction ? metadata_1.typeFunction(options) : metadata_1.reflectedType; | ||
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 = metadata_1.options.discriminator.subTypes.find(function (subType) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
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 (!metadata_1.options.keepDiscriminatorProperty) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
} | ||
} | ||
@@ -471,2 +478,10 @@ if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
} | ||
else if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
// if we have no registererd type via the @Type() decorator then we check if we have any | ||
// type declarations in reflect-metadata (type declaration is emited only if some decorator is added to the property.) | ||
var reflectedType = Reflect.getMetadata("design:type", targetType.prototype, propertyName); | ||
if (reflectedType) { | ||
type = reflectedType; | ||
} | ||
} | ||
} | ||
@@ -485,3 +500,3 @@ // if value is an array try to get its custom array type | ||
if ((this_1.transformationType === TransformationType.PLAIN_TO_CLASS || this_1.transformationType === TransformationType.CLASS_TO_CLASS) | ||
&& ((descriptor && !descriptor.set) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
&& ((descriptor && !descriptor.writable) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
return "continue"; | ||
@@ -488,0 +503,0 @@ } |
@@ -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,o,a){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=o,this.options=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,o){this.target=t,this.propertyName=e,this.transformFn=r,this.options=o}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 o=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,o){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?o===r.TransformationType.CLASS_TO_CLASS||o===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||o===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),o=this._exposeMetadatas.get(t),a=o&&o.get(void 0);return r&&a||!r&&!a?"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,o=t.get(e);o&&(r=Array.from(o.values()).filter(function(t){return void 0!==t.propertyName}));for(var a=[],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});a.push.apply(a,f)}}return a.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var o=t.get(e);if(o){var a=o.get(r);if(a)return a}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 o,a=t.get(e);a&&(o=a.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((o||[]).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=o}),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";function o(t){var e=new t;return e instanceof Set||"push"in e?e:[]}function a(){try{return Buffer,!0}catch(t){}return!1}Object.defineProperty(e,"__esModule",{value:!0});var n;!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"}(n=e.TransformationType||(e.TransformationType={}));var s=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,s,i,p,f){var u=this;if(void 0===f&&(f=0),Array.isArray(e)||e instanceof Set){var c=i&&this.transformationType===n.PLAIN_TO_CLASS?o(i):[];return e.forEach(function(e,r){var o=t?t[r]:void 0;if(u.options.enableCircularCheck&&u.isCircular(e))u.transformationType===n.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var a=void 0;if("function"!=typeof s&&s&&s.options&&s.options.discriminator&&s.options.discriminator.property&&s.options.discriminator.subTypes){if(u.transformationType===n.PLAIN_TO_CLASS){a=s.options.discriminator.subTypes.find(function(t){return t.name===e[s.options.discriminator.property]});var i={newObject:c,object:e,property:void 0},p=s.typeFunction(i);a=void 0===a?p:a.value,s.options.keepDiscriminatorProperty||delete e[s.options.discriminator.property]}u.transformationType===n.CLASS_TO_CLASS&&(a=e.constructor),u.transformationType===n.CLASS_TO_PLAIN&&(e[s.options.discriminator.property]=s.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else a=s;var d=u.transform(o,e,a,void 0,e instanceof Map,f+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(s!==String||p){if(s!==Number||p){if(s!==Boolean||p){if((s===Date||e instanceof Date)&&!p)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if(a()&&(s===Buffer||e instanceof Buffer)&&!p)return null===e||void 0===e?e:Buffer.from(e);if("object"==typeof e&&null!==e){s||e.constructor===Object||(s=e.constructor),!s&&t&&(s=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var d=this.getKeys(s,e),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=p?new Map:s?new s:{});for(var y=this,m=0,T=d;m<T.length;m++){var S=T[m];!function(o){var a=o,i=o,u=o;if(!y.options.ignoreDecorators&&s)if(y.transformationType===n.PLAIN_TO_CLASS){var c=r.defaultMetadataStorage.findExposeMetadataByCustomName(s,o);c&&(u=c.propertyName,i=c.propertyName)}else if(y.transformationType===n.CLASS_TO_PLAIN||y.transformationType===n.CLASS_TO_CLASS){var c=r.defaultMetadataStorage.findExposeMetadata(s,o);c&&c.options&&c.options.name&&(i=c.options.name)}var d=void 0;d=e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var m=void 0,T=d instanceof Map;if(s&&p)m=s;else if(s){var S=r.defaultMetadataStorage.findTypeMetadata(s,u);if(S){var v={newObject:l,object:e,property:u},h=S.typeFunction(v);S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[a]instanceof Array?m=S:(y.transformationType===n.PLAIN_TO_CLASS&&(m=S.options.discriminator.subTypes.find(function(t){return t.name===d[S.options.discriminator.property]}),m=void 0===m?h:m.value,S.options.keepDiscriminatorProperty||delete d[S.options.discriminator.property]),y.transformationType===n.CLASS_TO_CLASS&&(m=d.constructor),y.transformationType===n.CLASS_TO_PLAIN&&(d[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):m=h,T=T||S.reflectedType===Map}else y.options.targetMaps&&y.options.targetMaps.filter(function(t){return t.target===s&&!!t.properties[u]}).forEach(function(t){return m=t.properties[u]})}var _=Array.isArray(e[a])?y.getReflectedType(s,u):void 0,M=t?t[a]:void 0;if(l.constructor.prototype){var g=Object.getOwnPropertyDescriptor(l.constructor.prototype,i);if((y.transformationType===n.PLAIN_TO_CLASS||y.transformationType===n.CLASS_TO_CLASS)&&(g&&!g.set||l[i]instanceof Function))return"continue"}if(y.options.enableCircularCheck&&y.isCircular(d)){if(y.transformationType===n.CLASS_TO_CLASS){var C=d;C=y.applyCustomTransformations(C,s,o,e,y.transformationType),l instanceof Map?l.set(i,C):l[i]=C}}else{var A=y.transformationType===n.PLAIN_TO_CLASS?i:o,C=void 0;y.transformationType===n.CLASS_TO_PLAIN?(C=e[A],C=y.applyCustomTransformations(C,s,A,e,y.transformationType),C=e[A]===C?d:C,C=y.transform(M,C,m,_,T,f+1)):(C=y.transform(M,d,m,_,T,f+1),C=y.applyCustomTransformations(C,s,A,e,y.transformationType)),l instanceof Map?l.set(i,C):l[i]=C}}(S)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}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,o,a,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,o,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,a,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var o=r.defaultMetadataStorage.findTypeMetadata(t,e);return o?o.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,a=r.defaultMetadataStorage.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===a&&(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===n.PLAIN_TO_CLASS&&(i=i.map(function(e){var o=r.defaultMetadataStorage.findExposeMetadata(t,e);return o&&o.options&&o.options.name?o.options.name:e})),s=this.options.excludeExtraneousValues?i: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 o=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(o&&o.options&&o.options.groups&&o.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=s,e.testForBuffer=a}),define("class-transformer/ClassTransformer",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=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,o){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,o||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,o){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,o||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,o){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,o||{}).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,o){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,o||{}).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 o=JSON.parse(e);return this.plainToClass(t,o,r)},t.prototype.deserializeArray=function(t,e,r){var o=JSON.parse(e);return this.plainToClass(t,o,r)},t}();e.ClassTransformer=o}),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,o,a,n,s,i){"use strict";function p(t,e){return function(r,a){var n=new i.TransformMetadata(r.constructor,a,t,e);o.defaultMetadataStorage.addTransformMetadata(n)}}function f(t,e){return function(r,n){var s=Reflect.getMetadata("design:type",r,n),i=new a.TypeMetadata(r.constructor,n,s,t,e);o.defaultMetadataStorage.addTypeMetadata(i)}}function u(t){return function(e,r){var a=new n.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});o.defaultMetadataStorage.addExposeMetadata(a)}}function c(t){return function(e,r){var a=new s.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});o.defaultMetadataStorage.addExcludeMetadata(a)}}function d(t){return function(e,o,a){var n=new r.ClassTransformer,s=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var o=s.apply(this,e);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.classToPlain(o,t):o.then(function(e){return n.classToPlain(e,t)})}}}function l(t){return function(e,o,a){var n=new r.ClassTransformer,s=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var o=s.apply(this,e);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.classToClass(o,t):o.then(function(e){return n.classToClass(e,t)})}}}function y(t,e){return function(o,a,n){var s=new r.ClassTransformer,i=n.value;n.value=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var a=i.apply(this,r);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?s.plainToClass(t,a,e):a.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,o,a){"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=o.ClassTransformer,function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(a);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,o,a){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=o,this.options=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,o){this.target=t,this.propertyName=e,this.transformFn=r,this.options=o}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 o=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,o){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?o===r.TransformationType.CLASS_TO_CLASS||o===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||o===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),o=this._exposeMetadatas.get(t),a=o&&o.get(void 0);return r&&a||!r&&!a?"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,o=t.get(e);o&&(r=Array.from(o.values()).filter(function(t){return void 0!==t.propertyName}));for(var a=[],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});a.push.apply(a,f)}}return a.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var o=t.get(e);if(o){var a=o.get(r);if(a)return a}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 o,a=t.get(e);a&&(o=a.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((o||[]).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=o}),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";function o(t){var e=new t;return e instanceof Set||"push"in e?e:[]}function a(){try{return Buffer,!0}catch(t){}return!1}Object.defineProperty(e,"__esModule",{value:!0});var n;!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"}(n=e.TransformationType||(e.TransformationType={}));var s=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,s,i,p,f){var u=this;if(void 0===f&&(f=0),Array.isArray(e)||e instanceof Set){var c=i&&this.transformationType===n.PLAIN_TO_CLASS?o(i):[];return e.forEach(function(e,r){var o=t?t[r]:void 0;if(u.options.enableCircularCheck&&u.isCircular(e))u.transformationType===n.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var a=void 0;if("function"!=typeof s&&s&&s.options&&s.options.discriminator&&s.options.discriminator.property&&s.options.discriminator.subTypes){if(u.transformationType===n.PLAIN_TO_CLASS){a=s.options.discriminator.subTypes.find(function(t){return t.name===e[s.options.discriminator.property]});var i={newObject:c,object:e,property:void 0},p=s.typeFunction(i);a=void 0===a?p:a.value,s.options.keepDiscriminatorProperty||delete e[s.options.discriminator.property]}u.transformationType===n.CLASS_TO_CLASS&&(a=e.constructor),u.transformationType===n.CLASS_TO_PLAIN&&(e[s.options.discriminator.property]=s.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else a=s;var d=u.transform(o,e,a,void 0,e instanceof Map,f+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(s!==String||p){if(s!==Number||p){if(s!==Boolean||p){if((s===Date||e instanceof Date)&&!p)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if(a()&&(s===Buffer||e instanceof Buffer)&&!p)return null===e||void 0===e?e:Buffer.from(e);if("object"==typeof e&&null!==e){s||e.constructor===Object||(s=e.constructor),!s&&t&&(s=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var d=this.getKeys(s,e),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=p?new Map:s?new s:{});for(var y=this,m=0,T=d;m<T.length;m++){var S=T[m];!function(o){var a=o,i=o,u=o;if(!y.options.ignoreDecorators&&s)if(y.transformationType===n.PLAIN_TO_CLASS){var c=r.defaultMetadataStorage.findExposeMetadataByCustomName(s,o);c&&(u=c.propertyName,i=c.propertyName)}else if(y.transformationType===n.CLASS_TO_PLAIN||y.transformationType===n.CLASS_TO_CLASS){var c=r.defaultMetadataStorage.findExposeMetadata(s,o);c&&c.options&&c.options.name&&(i=c.options.name)}var d=void 0;d=e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var m=void 0,T=d instanceof Map;if(s&&p)m=s;else if(s){var S=r.defaultMetadataStorage.findTypeMetadata(s,u);if(S){var v={newObject:l,object:e,property:u},_=S.typeFunction?S.typeFunction(v):S.reflectedType;S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[a]instanceof Array?m=S:(y.transformationType===n.PLAIN_TO_CLASS&&(m=S.options.discriminator.subTypes.find(function(t){if(d&&S.options.discriminator.property in d)return t.name===d[S.options.discriminator.property]}),m=void 0===m?_:m.value,S.options.keepDiscriminatorProperty||d&&S.options.discriminator.property in d&&delete d[S.options.discriminator.property]),y.transformationType===n.CLASS_TO_CLASS&&(m=d.constructor),y.transformationType===n.CLASS_TO_PLAIN&&(d[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):m=_,T=T||S.reflectedType===Map}else if(y.options.targetMaps)y.options.targetMaps.filter(function(t){return t.target===s&&!!t.properties[u]}).forEach(function(t){return m=t.properties[u]});else if(y.transformationType===n.PLAIN_TO_CLASS){var h=Reflect.getMetadata("design:type",s.prototype,u);h&&(m=h)}}var M=Array.isArray(e[a])?y.getReflectedType(s,u):void 0,g=t?t[a]:void 0;if(l.constructor.prototype){var C=Object.getOwnPropertyDescriptor(l.constructor.prototype,i);if((y.transformationType===n.PLAIN_TO_CLASS||y.transformationType===n.CLASS_TO_CLASS)&&(C&&!C.writable||l[i]instanceof Function))return"continue"}if(y.options.enableCircularCheck&&y.isCircular(d)){if(y.transformationType===n.CLASS_TO_CLASS){var A=d;A=y.applyCustomTransformations(A,s,o,e,y.transformationType),l instanceof Map?l.set(i,A):l[i]=A}}else{var O=y.transformationType===n.PLAIN_TO_CLASS?i:o,A=void 0;y.transformationType===n.CLASS_TO_PLAIN?(A=e[O],A=y.applyCustomTransformations(A,s,O,e,y.transformationType),A=e[O]===A?d:A,A=y.transform(g,A,m,M,T,f+1)):(A=y.transform(g,d,m,M,T,f+1),A=y.applyCustomTransformations(A,s,O,e,y.transformationType)),l instanceof Map?l.set(i,A):l[i]=A}}(S)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}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,o,a,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,o,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,a,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var o=r.defaultMetadataStorage.findTypeMetadata(t,e);return o?o.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,a=r.defaultMetadataStorage.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===a&&(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===n.PLAIN_TO_CLASS&&(i=i.map(function(e){var o=r.defaultMetadataStorage.findExposeMetadata(t,e);return o&&o.options&&o.options.name?o.options.name:e})),s=this.options.excludeExtraneousValues?i: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 o=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(o&&o.options&&o.options.groups&&o.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=s,e.testForBuffer=a}),define("class-transformer/ClassTransformer",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=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,o){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,o||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,o){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,o||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,o){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,o||{}).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,o){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,o||{}).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 o=JSON.parse(e);return this.plainToClass(t,o,r)},t.prototype.deserializeArray=function(t,e,r){var o=JSON.parse(e);return this.plainToClass(t,o,r)},t}();e.ClassTransformer=o}),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,o,a,n,s,i){"use strict";function p(t,e){return function(r,a){var n=new i.TransformMetadata(r.constructor,a,t,e);o.defaultMetadataStorage.addTransformMetadata(n)}}function f(t,e){return function(r,n){var s=Reflect.getMetadata("design:type",r,n),i=new a.TypeMetadata(r.constructor,n,s,t,e);o.defaultMetadataStorage.addTypeMetadata(i)}}function u(t){return function(e,r){var a=new n.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});o.defaultMetadataStorage.addExposeMetadata(a)}}function c(t){return function(e,r){var a=new s.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});o.defaultMetadataStorage.addExcludeMetadata(a)}}function d(t){return function(e,o,a){var n=new r.ClassTransformer,s=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var o=s.apply(this,e);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.classToPlain(o,t):o.then(function(e){return n.classToPlain(e,t)})}}}function l(t){return function(e,o,a){var n=new r.ClassTransformer,s=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var o=s.apply(this,e);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.classToClass(o,t):o.then(function(e){return n.classToClass(e,t)})}}}function y(t,e){return function(o,a,n){var s=new r.ClassTransformer,i=n.value;n.value=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var a=i.apply(this,r);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?s.plainToClass(t,a,e):a.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,o,a){"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=o.ClassTransformer,function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(a);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)}); |
@@ -431,10 +431,17 @@ define("class-transformer/ClassTransformOptions", ["require", "exports"], function (require, exports) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
var newType = metadata_1.typeFunction(options); | ||
var newType = metadata_1.typeFunction ? metadata_1.typeFunction(options) : metadata_1.reflectedType; | ||
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 = metadata_1.options.discriminator.subTypes.find(function (subType) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
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 (!metadata_1.options.keepDiscriminatorProperty) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
} | ||
} | ||
@@ -462,2 +469,10 @@ if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
} | ||
else if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
// if we have no registererd type via the @Type() decorator then we check if we have any | ||
// type declarations in reflect-metadata (type declaration is emited only if some decorator is added to the property.) | ||
var reflectedType = Reflect.getMetadata("design:type", targetType.prototype, propertyName); | ||
if (reflectedType) { | ||
type = reflectedType; | ||
} | ||
} | ||
} | ||
@@ -476,3 +491,3 @@ // if value is an array try to get its custom array type | ||
if ((this_1.transformationType === TransformationType.PLAIN_TO_CLASS || this_1.transformationType === TransformationType.CLASS_TO_CLASS) | ||
&& ((descriptor && !descriptor.set) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
&& ((descriptor && !descriptor.writable) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
return "continue"; | ||
@@ -479,0 +494,0 @@ } |
@@ -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 r=function(){function t(t,e,r,o,a){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=o,this.options=a}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,o){this.target=t,this.propertyName=e,this.transformFn=r,this.options=o}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 o=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,o){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?o===r.TransformationType.CLASS_TO_CLASS||o===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||o===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),o=this._exposeMetadatas.get(t),a=o&&o.get(void 0);return r&&a||!r&&!a?"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,o=t.get(e);o&&(r=Array.from(o.values()).filter(function(t){return void 0!==t.propertyName}));for(var a=[],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});a.push.apply(a,f)}}return a.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var o=t.get(e);if(o){var a=o.get(r);if(a)return a}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 o,a=t.get(e);a&&(o=a.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((o||[]).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=o}),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){function o(t){var e=new t;return e instanceof Set||"push"in e?e:[]}function a(){try{return Buffer,!0}catch(t){}return!1}Object.defineProperty(e,"__esModule",{value:!0});var n;!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"}(n=e.TransformationType||(e.TransformationType={}));var s=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,s,i,p,f){var u=this;if(void 0===f&&(f=0),Array.isArray(e)||e instanceof Set){var c=i&&this.transformationType===n.PLAIN_TO_CLASS?o(i):[];return e.forEach(function(e,r){var o=t?t[r]:void 0;if(u.options.enableCircularCheck&&u.isCircular(e))u.transformationType===n.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var a=void 0;if("function"!=typeof s&&s&&s.options&&s.options.discriminator&&s.options.discriminator.property&&s.options.discriminator.subTypes){if(u.transformationType===n.PLAIN_TO_CLASS){a=s.options.discriminator.subTypes.find(function(t){return t.name===e[s.options.discriminator.property]});var i={newObject:c,object:e,property:void 0},p=s.typeFunction(i);a=void 0===a?p:a.value,s.options.keepDiscriminatorProperty||delete e[s.options.discriminator.property]}u.transformationType===n.CLASS_TO_CLASS&&(a=e.constructor),u.transformationType===n.CLASS_TO_PLAIN&&(e[s.options.discriminator.property]=s.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else a=s;var d=u.transform(o,e,a,void 0,e instanceof Map,f+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(s!==String||p){if(s!==Number||p){if(s!==Boolean||p){if((s===Date||e instanceof Date)&&!p)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if(a()&&(s===Buffer||e instanceof Buffer)&&!p)return null===e||void 0===e?e:Buffer.from(e);if("object"==typeof e&&null!==e){s||e.constructor===Object||(s=e.constructor),!s&&t&&(s=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var d=this.getKeys(s,e),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=p?new Map:s?new s:{});for(var y=this,m=0,T=d;m<T.length;m++){var S=T[m];!function(o){var a=o,i=o,u=o;if(!y.options.ignoreDecorators&&s)if(y.transformationType===n.PLAIN_TO_CLASS){var c=r.defaultMetadataStorage.findExposeMetadataByCustomName(s,o);c&&(u=c.propertyName,i=c.propertyName)}else if(y.transformationType===n.CLASS_TO_PLAIN||y.transformationType===n.CLASS_TO_CLASS){var c=r.defaultMetadataStorage.findExposeMetadata(s,o);c&&c.options&&c.options.name&&(i=c.options.name)}var d=void 0;d=e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var m=void 0,T=d instanceof Map;if(s&&p)m=s;else if(s){var S=r.defaultMetadataStorage.findTypeMetadata(s,u);if(S){var v={newObject:l,object:e,property:u},h=S.typeFunction(v);S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[a]instanceof Array?m=S:(y.transformationType===n.PLAIN_TO_CLASS&&(m=S.options.discriminator.subTypes.find(function(t){return t.name===d[S.options.discriminator.property]}),m=void 0===m?h:m.value,S.options.keepDiscriminatorProperty||delete d[S.options.discriminator.property]),y.transformationType===n.CLASS_TO_CLASS&&(m=d.constructor),y.transformationType===n.CLASS_TO_PLAIN&&(d[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):m=h,T=T||S.reflectedType===Map}else y.options.targetMaps&&y.options.targetMaps.filter(function(t){return t.target===s&&!!t.properties[u]}).forEach(function(t){return m=t.properties[u]})}var _=Array.isArray(e[a])?y.getReflectedType(s,u):void 0,M=t?t[a]:void 0;if(l.constructor.prototype){var g=Object.getOwnPropertyDescriptor(l.constructor.prototype,i);if((y.transformationType===n.PLAIN_TO_CLASS||y.transformationType===n.CLASS_TO_CLASS)&&(g&&!g.set||l[i]instanceof Function))return"continue"}if(y.options.enableCircularCheck&&y.isCircular(d)){if(y.transformationType===n.CLASS_TO_CLASS){var C=d;C=y.applyCustomTransformations(C,s,o,e,y.transformationType),l instanceof Map?l.set(i,C):l[i]=C}}else{var A=y.transformationType===n.PLAIN_TO_CLASS?i:o,C=void 0;y.transformationType===n.CLASS_TO_PLAIN?(C=e[A],C=y.applyCustomTransformations(C,s,A,e,y.transformationType),C=e[A]===C?d:C,C=y.transform(M,C,m,_,T,f+1)):(C=y.transform(M,d,m,_,T,f+1),C=y.applyCustomTransformations(C,s,A,e,y.transformationType)),l instanceof Map?l.set(i,C):l[i]=C}}(S)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}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,o,a,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,o,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,a,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var o=r.defaultMetadataStorage.findTypeMetadata(t,e);return o?o.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,a=r.defaultMetadataStorage.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===a&&(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===n.PLAIN_TO_CLASS&&(i=i.map(function(e){var o=r.defaultMetadataStorage.findExposeMetadata(t,e);return o&&o.options&&o.options.name?o.options.name:e})),s=this.options.excludeExtraneousValues?i: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 o=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(o&&o.options&&o.options.groups&&o.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=s,e.testForBuffer=a}),define("class-transformer/ClassTransformer",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});var o=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,o){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,o||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,o){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,o||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,o){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,o||{}).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,o){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,o||{}).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 o=JSON.parse(e);return this.plainToClass(t,o,r)},t.prototype.deserializeArray=function(t,e,r){var o=JSON.parse(e);return this.plainToClass(t,o,r)},t}();e.ClassTransformer=o}),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,o,a,n,s,i){function p(t,e){return function(r,a){var n=new i.TransformMetadata(r.constructor,a,t,e);o.defaultMetadataStorage.addTransformMetadata(n)}}function f(t,e){return function(r,n){var s=Reflect.getMetadata("design:type",r,n),i=new a.TypeMetadata(r.constructor,n,s,t,e);o.defaultMetadataStorage.addTypeMetadata(i)}}function u(t){return function(e,r){var a=new n.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});o.defaultMetadataStorage.addExposeMetadata(a)}}function c(t){return function(e,r){var a=new s.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});o.defaultMetadataStorage.addExcludeMetadata(a)}}function d(t){return function(e,o,a){var n=new r.ClassTransformer,s=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var o=s.apply(this,e);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.classToPlain(o,t):o.then(function(e){return n.classToPlain(e,t)})}}}function l(t){return function(e,o,a){var n=new r.ClassTransformer,s=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var o=s.apply(this,e);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.classToClass(o,t):o.then(function(e){return n.classToClass(e,t)})}}}function y(t,e){return function(o,a,n){var s=new r.ClassTransformer,i=n.value;n.value=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var a=i.apply(this,r);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?s.plainToClass(t,a,e):a.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,o,a){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=o.ClassTransformer,function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(a);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)}); | ||
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,o,a){this.target=t,this.propertyName=e,this.reflectedType=r,this.typeFunction=o,this.options=a}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,o){this.target=t,this.propertyName=e,this.transformFn=r,this.options=o}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 o=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,o){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?o===r.TransformationType.CLASS_TO_CLASS||o===r.TransformationType.PLAIN_TO_CLASS:!0!==t.options.toPlainOnly||o===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),o=this._exposeMetadatas.get(t),a=o&&o.get(void 0);return r&&a||!r&&!a?"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,o=t.get(e);o&&(r=Array.from(o.values()).filter(function(t){return void 0!==t.propertyName}));for(var a=[],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});a.push.apply(a,f)}}return a.concat(r||[])},t.prototype.findMetadata=function(t,e,r){var o=t.get(e);if(o){var a=o.get(r);if(a)return a}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 o,a=t.get(e);a&&(o=a.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((o||[]).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=o}),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){function o(t){var e=new t;return e instanceof Set||"push"in e?e:[]}function a(){try{return Buffer,!0}catch(t){}return!1}Object.defineProperty(e,"__esModule",{value:!0});var n;!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"}(n=e.TransformationType||(e.TransformationType={}));var s=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,s,i,p,f){var u=this;if(void 0===f&&(f=0),Array.isArray(e)||e instanceof Set){var c=i&&this.transformationType===n.PLAIN_TO_CLASS?o(i):[];return e.forEach(function(e,r){var o=t?t[r]:void 0;if(u.options.enableCircularCheck&&u.isCircular(e))u.transformationType===n.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var a=void 0;if("function"!=typeof s&&s&&s.options&&s.options.discriminator&&s.options.discriminator.property&&s.options.discriminator.subTypes){if(u.transformationType===n.PLAIN_TO_CLASS){a=s.options.discriminator.subTypes.find(function(t){return t.name===e[s.options.discriminator.property]});var i={newObject:c,object:e,property:void 0},p=s.typeFunction(i);a=void 0===a?p:a.value,s.options.keepDiscriminatorProperty||delete e[s.options.discriminator.property]}u.transformationType===n.CLASS_TO_CLASS&&(a=e.constructor),u.transformationType===n.CLASS_TO_PLAIN&&(e[s.options.discriminator.property]=s.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else a=s;var d=u.transform(o,e,a,void 0,e instanceof Map,f+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(s!==String||p){if(s!==Number||p){if(s!==Boolean||p){if((s===Date||e instanceof Date)&&!p)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if(a()&&(s===Buffer||e instanceof Buffer)&&!p)return null===e||void 0===e?e:Buffer.from(e);if("object"==typeof e&&null!==e){s||e.constructor===Object||(s=e.constructor),!s&&t&&(s=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var d=this.getKeys(s,e),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=p?new Map:s?new s:{});for(var y=this,m=0,T=d;m<T.length;m++){var S=T[m];!function(o){var a=o,i=o,u=o;if(!y.options.ignoreDecorators&&s)if(y.transformationType===n.PLAIN_TO_CLASS){var c=r.defaultMetadataStorage.findExposeMetadataByCustomName(s,o);c&&(u=c.propertyName,i=c.propertyName)}else if(y.transformationType===n.CLASS_TO_PLAIN||y.transformationType===n.CLASS_TO_CLASS){var c=r.defaultMetadataStorage.findExposeMetadata(s,o);c&&c.options&&c.options.name&&(i=c.options.name)}var d=void 0;d=e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var m=void 0,T=d instanceof Map;if(s&&p)m=s;else if(s){var S=r.defaultMetadataStorage.findTypeMetadata(s,u);if(S){var v={newObject:l,object:e,property:u},_=S.typeFunction?S.typeFunction(v):S.reflectedType;S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[a]instanceof Array?m=S:(y.transformationType===n.PLAIN_TO_CLASS&&(m=S.options.discriminator.subTypes.find(function(t){if(d&&S.options.discriminator.property in d)return t.name===d[S.options.discriminator.property]}),m=void 0===m?_:m.value,S.options.keepDiscriminatorProperty||d&&S.options.discriminator.property in d&&delete d[S.options.discriminator.property]),y.transformationType===n.CLASS_TO_CLASS&&(m=d.constructor),y.transformationType===n.CLASS_TO_PLAIN&&(d[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):m=_,T=T||S.reflectedType===Map}else if(y.options.targetMaps)y.options.targetMaps.filter(function(t){return t.target===s&&!!t.properties[u]}).forEach(function(t){return m=t.properties[u]});else if(y.transformationType===n.PLAIN_TO_CLASS){var h=Reflect.getMetadata("design:type",s.prototype,u);h&&(m=h)}}var M=Array.isArray(e[a])?y.getReflectedType(s,u):void 0,g=t?t[a]:void 0;if(l.constructor.prototype){var C=Object.getOwnPropertyDescriptor(l.constructor.prototype,i);if((y.transformationType===n.PLAIN_TO_CLASS||y.transformationType===n.CLASS_TO_CLASS)&&(C&&!C.writable||l[i]instanceof Function))return"continue"}if(y.options.enableCircularCheck&&y.isCircular(d)){if(y.transformationType===n.CLASS_TO_CLASS){var A=d;A=y.applyCustomTransformations(A,s,o,e,y.transformationType),l instanceof Map?l.set(i,A):l[i]=A}}else{var O=y.transformationType===n.PLAIN_TO_CLASS?i:o,A=void 0;y.transformationType===n.CLASS_TO_PLAIN?(A=e[O],A=y.applyCustomTransformations(A,s,O,e,y.transformationType),A=e[O]===A?d:A,A=y.transform(g,A,m,M,T,f+1)):(A=y.transform(g,d,m,M,T,f+1),A=y.applyCustomTransformations(A,s,O,e,y.transformationType)),l instanceof Map?l.set(i,A):l[i]=A}}(S)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}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,o,a,n){var s=this,i=r.defaultMetadataStorage.findTransformMetadatas(e,o,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,a,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var o=r.defaultMetadataStorage.findTypeMetadata(t,e);return o?o.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var o=this,a=r.defaultMetadataStorage.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===a&&(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===n.PLAIN_TO_CLASS&&(i=i.map(function(e){var o=r.defaultMetadataStorage.findExposeMetadata(t,e);return o&&o.options&&o.options.name?o.options.name:e})),s=this.options.excludeExtraneousValues?i: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 o=r.defaultMetadataStorage.findExposeMetadata(t,e);return!(o&&o.options&&o.options.groups&&o.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=s,e.testForBuffer=a}),define("class-transformer/ClassTransformer",["require","exports","class-transformer/TransformOperationExecutor"],function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});var o=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,o){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_PLAIN,o||{}).transform(e,t,void 0,void 0,void 0,void 0)},t.prototype.plainToClass=function(t,e,o){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,o||{}).transform(void 0,e,t,void 0,void 0,void 0)},t.prototype.plainToClassFromExist=function(t,e,o){return new r.TransformOperationExecutor(r.TransformationType.PLAIN_TO_CLASS,o||{}).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,o){return new r.TransformOperationExecutor(r.TransformationType.CLASS_TO_CLASS,o||{}).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 o=JSON.parse(e);return this.plainToClass(t,o,r)},t.prototype.deserializeArray=function(t,e,r){var o=JSON.parse(e);return this.plainToClass(t,o,r)},t}();e.ClassTransformer=o}),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,o,a,n,s,i){function p(t,e){return function(r,a){var n=new i.TransformMetadata(r.constructor,a,t,e);o.defaultMetadataStorage.addTransformMetadata(n)}}function f(t,e){return function(r,n){var s=Reflect.getMetadata("design:type",r,n),i=new a.TypeMetadata(r.constructor,n,s,t,e);o.defaultMetadataStorage.addTypeMetadata(i)}}function u(t){return function(e,r){var a=new n.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});o.defaultMetadataStorage.addExposeMetadata(a)}}function c(t){return function(e,r){var a=new s.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});o.defaultMetadataStorage.addExcludeMetadata(a)}}function d(t){return function(e,o,a){var n=new r.ClassTransformer,s=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var o=s.apply(this,e);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.classToPlain(o,t):o.then(function(e){return n.classToPlain(e,t)})}}}function l(t){return function(e,o,a){var n=new r.ClassTransformer,s=a.value;a.value=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var o=s.apply(this,e);return!o||"object"!=typeof o&&"function"!=typeof o||"function"!=typeof o.then?n.classToClass(o,t):o.then(function(e){return n.classToClass(e,t)})}}}function y(t,e){return function(o,a,n){var s=new r.ClassTransformer,i=n.value;n.value=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var a=i.apply(this,r);return!a||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?s.plainToClass(t,a,e):a.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,o,a){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=o.ClassTransformer,function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(a);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)}); |
@@ -509,10 +509,17 @@ System.register("class-transformer/ClassTransformOptions", [], function (exports_1, context_1) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
var newType = metadata_1.typeFunction(options); | ||
var newType = metadata_1.typeFunction ? metadata_1.typeFunction(options) : metadata_1.reflectedType; | ||
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 = metadata_1.options.discriminator.subTypes.find(function (subType) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
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 (!metadata_1.options.keepDiscriminatorProperty) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
} | ||
} | ||
@@ -540,2 +547,10 @@ if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
} | ||
else if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
// if we have no registererd type via the @Type() decorator then we check if we have any | ||
// type declarations in reflect-metadata (type declaration is emited only if some decorator is added to the property.) | ||
var reflectedType = Reflect.getMetadata("design:type", targetType.prototype, propertyName); | ||
if (reflectedType) { | ||
type = reflectedType; | ||
} | ||
} | ||
} | ||
@@ -554,3 +569,3 @@ // if value is an array try to get its custom array type | ||
if ((this_1.transformationType === TransformationType.PLAIN_TO_CLASS || this_1.transformationType === TransformationType.CLASS_TO_CLASS) | ||
&& ((descriptor && !descriptor.set) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
&& ((descriptor && !descriptor.writable) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
return "continue"; | ||
@@ -557,0 +572,0 @@ } |
@@ -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 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],f=t.get(i);if(f){var p=Array.from(f.values()).filter(function(t){return void 0!==t.propertyName});o.push.apply(o,p)}}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],f=t.get(i);if(f){var p=f.get(r);if(p)return p}}},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 f=i[s],p=t.get(f);p&&p.has(r)&&n.push.apply(n,p.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){function r(t){var e=new t;return e instanceof Set||"push"in e?e:[]}function a(){try{return Buffer,!0}catch(t){}return!1}var o,n,s;e&&e.id;return t("testForBuffer",a),{setters:[function(t){o=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"}(n||(n={})),t("TransformationType",n),s=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,s,i,f,p){var u=this;if(void 0===p&&(p=0),Array.isArray(e)||e instanceof Set){var c=i&&this.transformationType===n.PLAIN_TO_CLASS?r(i):[];return e.forEach(function(e,r){var a=t?t[r]:void 0;if(u.options.enableCircularCheck&&u.isCircular(e))u.transformationType===n.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var o=void 0;if("function"!=typeof s&&s&&s.options&&s.options.discriminator&&s.options.discriminator.property&&s.options.discriminator.subTypes){if(u.transformationType===n.PLAIN_TO_CLASS){o=s.options.discriminator.subTypes.find(function(t){return t.name===e[s.options.discriminator.property]});var i={newObject:c,object:e,property:void 0},f=s.typeFunction(i);o=void 0===o?f:o.value,s.options.keepDiscriminatorProperty||delete e[s.options.discriminator.property]}u.transformationType===n.CLASS_TO_CLASS&&(o=e.constructor),u.transformationType===n.CLASS_TO_PLAIN&&(e[s.options.discriminator.property]=s.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else o=s;var d=u.transform(a,e,o,void 0,e instanceof Map,p+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(s!==String||f){if(s!==Number||f){if(s!==Boolean||f){if((s===Date||e instanceof Date)&&!f)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if(a()&&(s===Buffer||e instanceof Buffer)&&!f)return null===e||void 0===e?e:Buffer.from(e);if("object"==typeof e&&null!==e){s||e.constructor===Object||(s=e.constructor),!s&&t&&(s=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var d=this.getKeys(s,e),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=f?new Map:s?new s:{});for(var m=this,y=0,T=d;y<T.length;y++){var S=T[y];!function(r){var a=r,i=r,u=r;if(!m.options.ignoreDecorators&&s)if(m.transformationType===n.PLAIN_TO_CLASS){var c=o.defaultMetadataStorage.findExposeMetadataByCustomName(s,r);c&&(u=c.propertyName,i=c.propertyName)}else if(m.transformationType===n.CLASS_TO_PLAIN||m.transformationType===n.CLASS_TO_CLASS){var c=o.defaultMetadataStorage.findExposeMetadata(s,r);c&&c.options&&c.options.name&&(i=c.options.name)}var d=void 0;d=e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var y=void 0,T=d instanceof Map;if(s&&f)y=s;else if(s){var S=o.defaultMetadataStorage.findTypeMetadata(s,u);if(S){var h={newObject:l,object:e,property:u},v=S.typeFunction(h);S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[a]instanceof Array?y=S:(m.transformationType===n.PLAIN_TO_CLASS&&(y=S.options.discriminator.subTypes.find(function(t){return t.name===d[S.options.discriminator.property]}),y=void 0===y?v:y.value,S.options.keepDiscriminatorProperty||delete d[S.options.discriminator.property]),m.transformationType===n.CLASS_TO_CLASS&&(y=d.constructor),m.transformationType===n.CLASS_TO_PLAIN&&(d[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):y=v,T=T||S.reflectedType===Map}else m.options.targetMaps&&m.options.targetMaps.filter(function(t){return t.target===s&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]})}var g=Array.isArray(e[a])?m.getReflectedType(s,u):void 0,M=t?t[a]:void 0;if(l.constructor.prototype){var _=Object.getOwnPropertyDescriptor(l.constructor.prototype,i);if((m.transformationType===n.PLAIN_TO_CLASS||m.transformationType===n.CLASS_TO_CLASS)&&(_&&!_.set||l[i]instanceof Function))return"continue"}if(m.options.enableCircularCheck&&m.isCircular(d)){if(m.transformationType===n.CLASS_TO_CLASS){var C=d;C=m.applyCustomTransformations(C,s,r,e,m.transformationType),l instanceof Map?l.set(i,C):l[i]=C}}else{var A=m.transformationType===n.PLAIN_TO_CLASS?i:r,C=void 0;m.transformationType===n.CLASS_TO_PLAIN?(C=e[A],C=m.applyCustomTransformations(C,s,A,e,m.transformationType),C=e[A]===C?d:C,C=m.transform(M,C,y,g,T,p+1)):(C=m.transform(M,d,y,g,T,p+1),C=m.applyCustomTransformations(C,s,A,e,m.transformationType)),l instanceof Map?l.set(i,C):l[i]=C}}(S)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}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,r,a,n){var s=this,i=o.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,a,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=o.defaultMetadataStorage.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var r=this,a=o.defaultMetadataStorage.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===a&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=o.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===n.PLAIN_TO_CLASS&&(i=i.map(function(e){var r=o.defaultMetadataStorage.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e})),s=this.options.excludeExtraneousValues?i:s.concat(i);var f=o.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=o.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||r.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=o.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||r.checkGroups(a.options.groups)}):s.filter(function(e){var r=o.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 r.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",s)}}}),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 p.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 p.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 f(t,e){return function(r,a,o){var n=new p.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 p,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",f),{setters:[function(t){p=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 f(t,e){return l.serialize(t,e)}function p(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",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 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){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){function r(t){var e=new t;return e instanceof Set||"push"in e?e:[]}function a(){try{return Buffer,!0}catch(t){}return!1}var o,n,s;e&&e.id;return t("testForBuffer",a),{setters:[function(t){o=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"}(n||(n={})),t("TransformationType",n),s=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,s,i,p,f){var u=this;if(void 0===f&&(f=0),Array.isArray(e)||e instanceof Set){var c=i&&this.transformationType===n.PLAIN_TO_CLASS?r(i):[];return e.forEach(function(e,r){var a=t?t[r]:void 0;if(u.options.enableCircularCheck&&u.isCircular(e))u.transformationType===n.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var o=void 0;if("function"!=typeof s&&s&&s.options&&s.options.discriminator&&s.options.discriminator.property&&s.options.discriminator.subTypes){if(u.transformationType===n.PLAIN_TO_CLASS){o=s.options.discriminator.subTypes.find(function(t){return t.name===e[s.options.discriminator.property]});var i={newObject:c,object:e,property:void 0},p=s.typeFunction(i);o=void 0===o?p:o.value,s.options.keepDiscriminatorProperty||delete e[s.options.discriminator.property]}u.transformationType===n.CLASS_TO_CLASS&&(o=e.constructor),u.transformationType===n.CLASS_TO_PLAIN&&(e[s.options.discriminator.property]=s.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else o=s;var d=u.transform(a,e,o,void 0,e instanceof Map,f+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(s!==String||p){if(s!==Number||p){if(s!==Boolean||p){if((s===Date||e instanceof Date)&&!p)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if(a()&&(s===Buffer||e instanceof Buffer)&&!p)return null===e||void 0===e?e:Buffer.from(e);if("object"==typeof e&&null!==e){s||e.constructor===Object||(s=e.constructor),!s&&t&&(s=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var d=this.getKeys(s,e),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=p?new Map:s?new s:{});for(var m=this,y=0,T=d;y<T.length;y++){var S=T[y];!function(r){var a=r,i=r,u=r;if(!m.options.ignoreDecorators&&s)if(m.transformationType===n.PLAIN_TO_CLASS){var c=o.defaultMetadataStorage.findExposeMetadataByCustomName(s,r);c&&(u=c.propertyName,i=c.propertyName)}else if(m.transformationType===n.CLASS_TO_PLAIN||m.transformationType===n.CLASS_TO_CLASS){var c=o.defaultMetadataStorage.findExposeMetadata(s,r);c&&c.options&&c.options.name&&(i=c.options.name)}var d=void 0;d=e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var y=void 0,T=d instanceof Map;if(s&&p)y=s;else if(s){var S=o.defaultMetadataStorage.findTypeMetadata(s,u);if(S){var h={newObject:l,object:e,property:u},v=S.typeFunction?S.typeFunction(h):S.reflectedType;S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[a]instanceof Array?y=S:(m.transformationType===n.PLAIN_TO_CLASS&&(y=S.options.discriminator.subTypes.find(function(t){if(d&&S.options.discriminator.property in d)return t.name===d[S.options.discriminator.property]}),y=void 0===y?v:y.value,S.options.keepDiscriminatorProperty||d&&S.options.discriminator.property in d&&delete d[S.options.discriminator.property]),m.transformationType===n.CLASS_TO_CLASS&&(y=d.constructor),m.transformationType===n.CLASS_TO_PLAIN&&(d[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):y=v,T=T||S.reflectedType===Map}else if(m.options.targetMaps)m.options.targetMaps.filter(function(t){return t.target===s&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]});else if(m.transformationType===n.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",s.prototype,u);g&&(y=g)}}var M=Array.isArray(e[a])?m.getReflectedType(s,u):void 0,_=t?t[a]:void 0;if(l.constructor.prototype){var C=Object.getOwnPropertyDescriptor(l.constructor.prototype,i);if((m.transformationType===n.PLAIN_TO_CLASS||m.transformationType===n.CLASS_TO_CLASS)&&(C&&!C.writable||l[i]instanceof Function))return"continue"}if(m.options.enableCircularCheck&&m.isCircular(d)){if(m.transformationType===n.CLASS_TO_CLASS){var A=d;A=m.applyCustomTransformations(A,s,r,e,m.transformationType),l instanceof Map?l.set(i,A):l[i]=A}}else{var x=m.transformationType===n.PLAIN_TO_CLASS?i:r,A=void 0;m.transformationType===n.CLASS_TO_PLAIN?(A=e[x],A=m.applyCustomTransformations(A,s,x,e,m.transformationType),A=e[x]===A?d:A,A=m.transform(_,A,y,M,T,f+1)):(A=m.transform(_,d,y,M,T,f+1),A=m.applyCustomTransformations(A,s,x,e,m.transformationType)),l instanceof Map?l.set(i,A):l[i]=A}}(S)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}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,r,a,n){var s=this,i=o.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,a,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=o.defaultMetadataStorage.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var r=this,a=o.defaultMetadataStorage.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===a&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=o.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===n.PLAIN_TO_CLASS&&(i=i.map(function(e){var r=o.defaultMetadataStorage.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e})),s=this.options.excludeExtraneousValues?i:s.concat(i);var p=o.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=o.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||r.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=o.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||r.checkGroups(a.options.groups)}):s.filter(function(e){var r=o.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 r.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",s)}}}),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(){}}}); |
@@ -518,10 +518,17 @@ System.register("class-transformer/ClassTransformOptions", [], function (exports_1, context_1) { | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
var newType = metadata_1.typeFunction(options); | ||
var newType = metadata_1.typeFunction ? metadata_1.typeFunction(options) : metadata_1.reflectedType; | ||
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 = metadata_1.options.discriminator.subTypes.find(function (subType) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
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 (!metadata_1.options.keepDiscriminatorProperty) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
} | ||
} | ||
@@ -549,2 +556,10 @@ if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
} | ||
else if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
// if we have no registererd type via the @Type() decorator then we check if we have any | ||
// type declarations in reflect-metadata (type declaration is emited only if some decorator is added to the property.) | ||
var reflectedType = Reflect.getMetadata("design:type", targetType.prototype, propertyName); | ||
if (reflectedType) { | ||
type = reflectedType; | ||
} | ||
} | ||
} | ||
@@ -563,3 +578,3 @@ // if value is an array try to get its custom array type | ||
if ((this_1.transformationType === TransformationType.PLAIN_TO_CLASS || this_1.transformationType === TransformationType.CLASS_TO_CLASS) | ||
&& ((descriptor && !descriptor.set) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
&& ((descriptor && !descriptor.writable) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
return "continue"; | ||
@@ -566,0 +581,0 @@ } |
@@ -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,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],u=t.get(i);if(u){var f=Array.from(u.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],u=t.get(i);if(u){var f=u.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 u=i[s],f=t.get(u);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){"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";function r(t){var e=new t;return e instanceof Set||"push"in e?e:[]}function a(){try{return Buffer,!0}catch(t){}return!1}var o,n,s;e&&e.id;return t("testForBuffer",a),{setters:[function(t){o=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"}(n||(n={})),t("TransformationType",n),s=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,s,i,u,f){var p=this;if(void 0===f&&(f=0),Array.isArray(e)||e instanceof Set){var c=i&&this.transformationType===n.PLAIN_TO_CLASS?r(i):[];return e.forEach(function(e,r){var a=t?t[r]:void 0;if(p.options.enableCircularCheck&&p.isCircular(e))p.transformationType===n.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var o=void 0;if("function"!=typeof s&&s&&s.options&&s.options.discriminator&&s.options.discriminator.property&&s.options.discriminator.subTypes){if(p.transformationType===n.PLAIN_TO_CLASS){o=s.options.discriminator.subTypes.find(function(t){return t.name===e[s.options.discriminator.property]});var i={newObject:c,object:e,property:void 0},u=s.typeFunction(i);o=void 0===o?u:o.value,s.options.keepDiscriminatorProperty||delete e[s.options.discriminator.property]}p.transformationType===n.CLASS_TO_CLASS&&(o=e.constructor),p.transformationType===n.CLASS_TO_PLAIN&&(e[s.options.discriminator.property]=s.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else o=s;var d=p.transform(a,e,o,void 0,e instanceof Map,f+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(s!==String||u){if(s!==Number||u){if(s!==Boolean||u){if((s===Date||e instanceof Date)&&!u)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if(a()&&(s===Buffer||e instanceof Buffer)&&!u)return null===e||void 0===e?e:Buffer.from(e);if("object"==typeof e&&null!==e){s||e.constructor===Object||(s=e.constructor),!s&&t&&(s=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var d=this.getKeys(s,e),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=u?new Map:s?new s:{});for(var m=this,y=0,T=d;y<T.length;y++){var S=T[y];!function(r){var a=r,i=r,p=r;if(!m.options.ignoreDecorators&&s)if(m.transformationType===n.PLAIN_TO_CLASS){var c=o.defaultMetadataStorage.findExposeMetadataByCustomName(s,r);c&&(p=c.propertyName,i=c.propertyName)}else if(m.transformationType===n.CLASS_TO_PLAIN||m.transformationType===n.CLASS_TO_CLASS){var c=o.defaultMetadataStorage.findExposeMetadata(s,r);c&&c.options&&c.options.name&&(i=c.options.name)}var d=void 0;d=e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var y=void 0,T=d instanceof Map;if(s&&u)y=s;else if(s){var S=o.defaultMetadataStorage.findTypeMetadata(s,p);if(S){var h={newObject:l,object:e,property:p},v=S.typeFunction(h);S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[a]instanceof Array?y=S:(m.transformationType===n.PLAIN_TO_CLASS&&(y=S.options.discriminator.subTypes.find(function(t){return t.name===d[S.options.discriminator.property]}),y=void 0===y?v:y.value,S.options.keepDiscriminatorProperty||delete d[S.options.discriminator.property]),m.transformationType===n.CLASS_TO_CLASS&&(y=d.constructor),m.transformationType===n.CLASS_TO_PLAIN&&(d[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):y=v,T=T||S.reflectedType===Map}else m.options.targetMaps&&m.options.targetMaps.filter(function(t){return t.target===s&&!!t.properties[p]}).forEach(function(t){return y=t.properties[p]})}var g=Array.isArray(e[a])?m.getReflectedType(s,p):void 0,M=t?t[a]:void 0;if(l.constructor.prototype){var _=Object.getOwnPropertyDescriptor(l.constructor.prototype,i);if((m.transformationType===n.PLAIN_TO_CLASS||m.transformationType===n.CLASS_TO_CLASS)&&(_&&!_.set||l[i]instanceof Function))return"continue"}if(m.options.enableCircularCheck&&m.isCircular(d)){if(m.transformationType===n.CLASS_TO_CLASS){var C=d;C=m.applyCustomTransformations(C,s,r,e,m.transformationType),l instanceof Map?l.set(i,C):l[i]=C}}else{var A=m.transformationType===n.PLAIN_TO_CLASS?i:r,C=void 0;m.transformationType===n.CLASS_TO_PLAIN?(C=e[A],C=m.applyCustomTransformations(C,s,A,e,m.transformationType),C=e[A]===C?d:C,C=m.transform(M,C,y,g,T,f+1)):(C=m.transform(M,d,y,g,T,f+1),C=m.applyCustomTransformations(C,s,A,e,m.transformationType)),l instanceof Map?l.set(i,C):l[i]=C}}(S)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}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,r,a,n){var s=this,i=o.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,a,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=o.defaultMetadataStorage.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var r=this,a=o.defaultMetadataStorage.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===a&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=o.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===n.PLAIN_TO_CLASS&&(i=i.map(function(e){var r=o.defaultMetadataStorage.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e})),s=this.options.excludeExtraneousValues?i:s.concat(i);var u=o.defaultMetadataStorage.getExcludedProperties(t,this.transformationType);u.length>0&&(s=s.filter(function(t){return-1===u.indexOf(t)})),void 0!==this.options.version&&(s=s.filter(function(e){var a=o.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||r.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=o.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||r.checkGroups(a.options.groups)}):s.filter(function(e){var r=o.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 r.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",s)}}}),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);p.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);p.defaultMetadataStorage.addTypeMetadata(n)}}function o(t){return function(e,r){var a=new d.ExposeMetadata(e instanceof Function?e:e.constructor,r,t||{});p.defaultMetadataStorage.addExposeMetadata(a)}}function n(t){return function(e,r){var a=new l.ExcludeMetadata(e instanceof Function?e:e.constructor,r,t||{});p.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 u(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,p,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",u),{setters:[function(t){f=t},function(t){p=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 u(t,e){return l.serialize(t,e)}function f(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",o),t("plainToClassFromExist",n),t("classToClass",s),t("classToClassFromExist",i),t("serialize",u),t("deserialize",f),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 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){"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";function r(t){var e=new t;return e instanceof Set||"push"in e?e:[]}function a(){try{return Buffer,!0}catch(t){}return!1}var o,n,s;e&&e.id;return t("testForBuffer",a),{setters:[function(t){o=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"}(n||(n={})),t("TransformationType",n),s=function(){function t(t,e){this.transformationType=t,this.options=e,this.recursionStack=new Set}return t.prototype.transform=function(t,e,s,i,p,f){var u=this;if(void 0===f&&(f=0),Array.isArray(e)||e instanceof Set){var c=i&&this.transformationType===n.PLAIN_TO_CLASS?r(i):[];return e.forEach(function(e,r){var a=t?t[r]:void 0;if(u.options.enableCircularCheck&&u.isCircular(e))u.transformationType===n.CLASS_TO_CLASS&&(c instanceof Set?c.add(e):c.push(e));else{var o=void 0;if("function"!=typeof s&&s&&s.options&&s.options.discriminator&&s.options.discriminator.property&&s.options.discriminator.subTypes){if(u.transformationType===n.PLAIN_TO_CLASS){o=s.options.discriminator.subTypes.find(function(t){return t.name===e[s.options.discriminator.property]});var i={newObject:c,object:e,property:void 0},p=s.typeFunction(i);o=void 0===o?p:o.value,s.options.keepDiscriminatorProperty||delete e[s.options.discriminator.property]}u.transformationType===n.CLASS_TO_CLASS&&(o=e.constructor),u.transformationType===n.CLASS_TO_PLAIN&&(e[s.options.discriminator.property]=s.options.discriminator.subTypes.find(function(t){return t.value===e.constructor}).name)}else o=s;var d=u.transform(a,e,o,void 0,e instanceof Map,f+1);c instanceof Set?c.add(d):c.push(d)}}),c}if(s!==String||p){if(s!==Number||p){if(s!==Boolean||p){if((s===Date||e instanceof Date)&&!p)return e instanceof Date?new Date(e.valueOf()):null===e||void 0===e?e:new Date(e);if(a()&&(s===Buffer||e instanceof Buffer)&&!p)return null===e||void 0===e?e:Buffer.from(e);if("object"==typeof e&&null!==e){s||e.constructor===Object||(s=e.constructor),!s&&t&&(s=t.constructor),this.options.enableCircularCheck&&this.recursionStack.add(e);var d=this.getKeys(s,e),l=t||{};t||this.transformationType!==n.PLAIN_TO_CLASS&&this.transformationType!==n.CLASS_TO_CLASS||(l=p?new Map:s?new s:{});for(var m=this,y=0,T=d;y<T.length;y++){var S=T[y];!function(r){var a=r,i=r,u=r;if(!m.options.ignoreDecorators&&s)if(m.transformationType===n.PLAIN_TO_CLASS){var c=o.defaultMetadataStorage.findExposeMetadataByCustomName(s,r);c&&(u=c.propertyName,i=c.propertyName)}else if(m.transformationType===n.CLASS_TO_PLAIN||m.transformationType===n.CLASS_TO_CLASS){var c=o.defaultMetadataStorage.findExposeMetadata(s,r);c&&c.options&&c.options.name&&(i=c.options.name)}var d=void 0;d=e instanceof Map?e.get(a):e[a]instanceof Function?e[a]():e[a];var y=void 0,T=d instanceof Map;if(s&&p)y=s;else if(s){var S=o.defaultMetadataStorage.findTypeMetadata(s,u);if(S){var h={newObject:l,object:e,property:u},v=S.typeFunction?S.typeFunction(h):S.reflectedType;S.options&&S.options.discriminator&&S.options.discriminator.property&&S.options.discriminator.subTypes?e[a]instanceof Array?y=S:(m.transformationType===n.PLAIN_TO_CLASS&&(y=S.options.discriminator.subTypes.find(function(t){if(d&&S.options.discriminator.property in d)return t.name===d[S.options.discriminator.property]}),y=void 0===y?v:y.value,S.options.keepDiscriminatorProperty||d&&S.options.discriminator.property in d&&delete d[S.options.discriminator.property]),m.transformationType===n.CLASS_TO_CLASS&&(y=d.constructor),m.transformationType===n.CLASS_TO_PLAIN&&(d[S.options.discriminator.property]=S.options.discriminator.subTypes.find(function(t){return t.value===d.constructor}).name)):y=v,T=T||S.reflectedType===Map}else if(m.options.targetMaps)m.options.targetMaps.filter(function(t){return t.target===s&&!!t.properties[u]}).forEach(function(t){return y=t.properties[u]});else if(m.transformationType===n.PLAIN_TO_CLASS){var g=Reflect.getMetadata("design:type",s.prototype,u);g&&(y=g)}}var M=Array.isArray(e[a])?m.getReflectedType(s,u):void 0,_=t?t[a]:void 0;if(l.constructor.prototype){var C=Object.getOwnPropertyDescriptor(l.constructor.prototype,i);if((m.transformationType===n.PLAIN_TO_CLASS||m.transformationType===n.CLASS_TO_CLASS)&&(C&&!C.writable||l[i]instanceof Function))return"continue"}if(m.options.enableCircularCheck&&m.isCircular(d)){if(m.transformationType===n.CLASS_TO_CLASS){var A=d;A=m.applyCustomTransformations(A,s,r,e,m.transformationType),l instanceof Map?l.set(i,A):l[i]=A}}else{var x=m.transformationType===n.PLAIN_TO_CLASS?i:r,A=void 0;m.transformationType===n.CLASS_TO_PLAIN?(A=e[x],A=m.applyCustomTransformations(A,s,x,e,m.transformationType),A=e[x]===A?d:A,A=m.transform(_,A,y,M,T,f+1)):(A=m.transform(_,d,y,M,T,f+1),A=m.applyCustomTransformations(A,s,x,e,m.transformationType)),l instanceof Map?l.set(i,A):l[i]=A}}(S)}return this.options.enableCircularCheck&&this.recursionStack.delete(e),l}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,r,a,n){var s=this,i=o.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,a,n)}),t},t.prototype.isCircular=function(t){return this.recursionStack.has(t)},t.prototype.getReflectedType=function(t,e){if(t){var r=o.defaultMetadataStorage.findTypeMetadata(t,e);return r?r.reflectedType:void 0}},t.prototype.getKeys=function(t,e){var r=this,a=o.defaultMetadataStorage.getStrategy(t);"none"===a&&(a=this.options.strategy||"exposeAll");var s=[];if("exposeAll"===a&&(s=e instanceof Map?Array.from(e.keys()):Object.keys(e)),!this.options.ignoreDecorators&&t){var i=o.defaultMetadataStorage.getExposedProperties(t,this.transformationType);this.transformationType===n.PLAIN_TO_CLASS&&(i=i.map(function(e){var r=o.defaultMetadataStorage.findExposeMetadata(t,e);return r&&r.options&&r.options.name?r.options.name:e})),s=this.options.excludeExtraneousValues?i:s.concat(i);var p=o.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=o.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||r.checkVersion(a.options.since,a.options.until)})),s=this.options.groups&&this.options.groups.length?s.filter(function(e){var a=o.defaultMetadataStorage.findExposeMetadata(t,e);return!a||!a.options||r.checkGroups(a.options.groups)}):s.filter(function(e){var r=o.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 r.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",s)}}}),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);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){"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 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){"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(){}}}); |
@@ -12,3 +12,3 @@ import { ExposeOptions, ExcludeOptions, TypeHelpOptions, TransformOptions, TypeOptions } from "./metadata/ExposeExcludeOptions"; | ||
*/ | ||
export declare function Type(typeFunction: (type?: TypeHelpOptions) => Function, options?: TypeOptions): (target: any, key: string) => void; | ||
export declare function Type(typeFunction?: (type?: TypeHelpOptions) => Function, options?: TypeOptions): (target: any, key: string) => void; | ||
/** | ||
@@ -15,0 +15,0 @@ * Marks property as included in the process of transformation. By default it includes the property for both |
{ | ||
"name": "class-transformer", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -160,10 +160,17 @@ "use strict"; | ||
var options = { newObject: newValue, object: value, property: propertyName }; | ||
var newType = metadata_1.typeFunction(options); | ||
var newType = metadata_1.typeFunction ? metadata_1.typeFunction(options) : metadata_1.reflectedType; | ||
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 = metadata_1.options.discriminator.subTypes.find(function (subType) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
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 (!metadata_1.options.keepDiscriminatorProperty) { | ||
if (subValue && metadata_1.options.discriminator.property in subValue) { | ||
delete subValue[metadata_1.options.discriminator.property]; | ||
} | ||
} | ||
} | ||
@@ -191,2 +198,10 @@ if (this_1.transformationType === TransformationType.CLASS_TO_CLASS) { | ||
} | ||
else if (this_1.transformationType === TransformationType.PLAIN_TO_CLASS) { | ||
// if we have no registererd type via the @Type() decorator then we check if we have any | ||
// type declarations in reflect-metadata (type declaration is emited only if some decorator is added to the property.) | ||
var reflectedType = Reflect.getMetadata("design:type", targetType.prototype, propertyName); | ||
if (reflectedType) { | ||
type = reflectedType; | ||
} | ||
} | ||
} | ||
@@ -205,3 +220,3 @@ // if value is an array try to get its custom array type | ||
if ((this_1.transformationType === TransformationType.PLAIN_TO_CLASS || this_1.transformationType === TransformationType.CLASS_TO_CLASS) | ||
&& ((descriptor && !descriptor.set) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
&& ((descriptor && !descriptor.writable) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS | ||
return "continue"; | ||
@@ -208,0 +223,0 @@ } |
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
472962
5234