diff --git a/bower.json b/bower.json index c9c76f8..7327381 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "automapper-ts", - "version": "1.8.2", + "version": "1.8.3", "description": "A convention-based object-object mapper in JavaScript, written in TypeScript. Ported from the original C# AutoMapper library at https://github.com/AutoMapper/AutoMapper.", "keywords": [ "automapper", diff --git a/dist/automapper-classes.d.ts b/dist/automapper-classes.d.ts index 1edd1b2..976768f 100644 --- a/dist/automapper-classes.d.ts +++ b/dist/automapper-classes.d.ts @@ -1,7 +1,7 @@ // [bundle remove start] /// // [bundle remove end] -// Type definitions for AutoMapper.js 1.8.2 +// Type definitions for AutoMapper.js 1.8.3 // Project: https://github.com/loedeman/AutoMapper // Definitions by: Bert Loedeman // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/dist/automapper-declaration.d.ts b/dist/automapper-declaration.d.ts index 42c164b..3253014 100644 --- a/dist/automapper-declaration.d.ts +++ b/dist/automapper-declaration.d.ts @@ -2,7 +2,7 @@ /// -// Type definitions for AutoMapper.js 1.8.2 +// Type definitions for AutoMapper.js 1.8.3 // Project: https://github.com/loedeman/AutoMapper // Definitions by: Bert Loedeman // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/dist/automapper-interfaces.d.ts b/dist/automapper-interfaces.d.ts index 2abc840..2a94c36 100644 --- a/dist/automapper-interfaces.d.ts +++ b/dist/automapper-interfaces.d.ts @@ -1,5 +1,5 @@ // [bundle remove start] -// Type definitions for AutoMapper.js 1.8.2 +// Type definitions for AutoMapper.js 1.8.3 // Project: https://github.com/loedeman/AutoMapper // Definitions by: Bert Loedeman // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/dist/automapper.d.ts b/dist/automapper.d.ts index 2e0a9c5..cc3dd39 100644 --- a/dist/automapper.d.ts +++ b/dist/automapper.d.ts @@ -1,4 +1,4 @@ -// Type definitions for AutoMapper.js 1.8.2 +// Type definitions for AutoMapper.js 1.8.3 // Project: https://github.com/loedeman/AutoMapper // Definitions by: Bert Loedeman // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/dist/automapper.js b/dist/automapper.js index e7cb7ad..487fda5 100644 --- a/dist/automapper.js +++ b/dist/automapper.js @@ -1,11 +1,11 @@ /*! - * TypeScript / Javascript AutoMapper Library v1.8.2 + * TypeScript / Javascript AutoMapper Library v1.8.3 * https://github.com/loedeman/AutoMapper * * Copyright 2015-2017 Interest IT / Bert Loedeman and other contributors * Released under the MIT license * - * Date: 2017-05-29T16:00:00.000Z + * Date: 2017-09-01T16:00:00.000Z */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { diff --git a/dist/automapper.min.js b/dist/automapper.min.js index 09acfcb..8a861e5 100644 --- a/dist/automapper.min.js +++ b/dist/automapper.min.js @@ -1,11 +1,11 @@ /*! - * TypeScript / Javascript AutoMapper Library v1.8.2 + * TypeScript / Javascript AutoMapper Library v1.8.3 * https://github.com/loedeman/AutoMapper * * Copyright 2015-2017 Interest IT / Bert Loedeman and other contributors * Released under the MIT license * - * Date: 2017-05-29T16:00:00.000Z + * Date: 2017-09-01T16:00:00.000Z */ var AutoMapperJs;!function(t){"use strict";var e=function(){function e(){}return e.getClassName=function(t){if(t&&t.name)return t.name;if(t&&t.constructor){var e=t.toString();if(e){var r=e.match(/function\s*(\w+)/);if(r&&2===r.length)return r[1]}if(t.constructor.name)return t.constructor.name;if(t.constructor.toString()){var n=t.constructor.toString(),o=void 0;if((o="["===n.charAt(0)?n.match(/\[\w+\s*(\w+)\]/):n.match(/function\s*(\w+)/))&&2===o.length)return o[1]}}throw new Error("Unable to extract class name from type '"+t+"'")},e.getFunctionParameters=function(t){var e=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,r=/([^\s,]+)/g,n=t.replace(e,""),o=n.slice(n.indexOf("(")+1,n.indexOf(")")).match(r);return null===o&&(o=new Array),o},e.handleCurrying=function(t,e,r){function n(e,o,i){for(var a=o.slice(0),p=i,s=0;s=1?i[0]:"",p=n?t:e.getMapFromString(o,t,a),s={destination:t,source:p,transformation:e.getDestinationTransformation(r,!0,n,2===i.length),sourceMapping:n,condition:null,ignore:e.getIgnoreFromString(o,t),async:2===i.length};return!s.async&&e.getFunctionCallIndex(o,"condition",a)>=0&&(s.condition=e.getConditionFromFunction(r,p)),s},e.getDestinationTransformation=function(e,r,n,o){if(!r)return{transformationType:t.DestinationTransformationType.Constant,constant:e};return n?o?{transformationType:t.DestinationTransformationType.AsyncSourceMemberOptions,asyncSourceMemberConfigurationOptionsFunc:e}:{transformationType:t.DestinationTransformationType.SourceMemberOptions,sourceMemberConfigurationOptionsFunc:e}:o?{transformationType:t.DestinationTransformationType.AsyncMemberOptions,asyncMemberConfigurationOptionsFunc:e}:{transformationType:t.DestinationTransformationType.MemberOptions,memberConfigurationOptionsFunc:e}},e.getIgnoreFromString=function(t,r){var n=e.getFunctionCallIndex(t,"ignore",r);if(n<0)return!1;var o=t.indexOf("(",n)+1,i=t.indexOf(")",o);if(o<0||i<0)return!1;var a=t.substring(o,i).replace(/\r/g,"").replace(/\n/g,"").trim();return null===a||""===a},e.getMapFromString=function(t,r,n){var o=e.getFunctionCallIndex(t,"mapFrom",n);if(o<0)return r;var i=t.indexOf("(",o)+1,a=t.indexOf(")",i);if(i<0||a<0)return r;var p=t.substring(i,a).replace(/'/g,"").replace(/"/g,"").trim();return null===p||""===p?r:p},e.getFunctionCallIndex=function(t,e,r){var n=t.indexOf(r+"."+e);return n<0&&(n=t.indexOf("."+e)),n},e.getConditionFromFunction=function(t,e){var r={};r[e]={};var n,o={ignore:function(){},condition:function(t){n=t},mapFrom:function(t){},sourceObject:r,sourcePropertyName:e,intermediatePropertyValue:{}};try{t(o)}catch(t){}return n},e}();t.AutoMapperHelper=e}(AutoMapperJs||(AutoMapperJs={}));var AutoMapperJs;!function(t){"use strict";var e=function(){function e(){}return e.assertConfigurationIsValid=function(t,r){for(var n in t)t.hasOwnProperty(n)&&e.assertMappingConfiguration(t[n],r)},e.assertMappingConfiguration=function(r,n){var o=r.sourceKey+"=>"+r.destinationKey,i=r.sourceTypeClass,a=r.destinationTypeClass,p=i?t.AutoMapperHelper.getClassName(i):void 0,s=a?t.AutoMapperHelper.getClassName(a):void 0;if(!i||!a){if(!1===n)return;throw new Error("Mapping '"+o+"' cannot be validated, since mapping.sourceType or mapping.destinationType are unspecified.")}for(var u=function(t){if(t)throw new Error("Mapping '"+o+"' is invalid: "+t+" (source: '"+p+"', destination: '"+s+"').")},c=new Array,f=new i,l=new a,y=0,m=r.properties;y=0||(u(e.validateProperty(g,l)),c.push(g)));for(var d in l)l.hasOwnProperty(d)&&(c.indexOf(d)>=0||u("Destination member '"+d+"' does not exist on source type"))},e.validatePropertyMapping=function(t,r,n,o){var i=e.getDestinationProperty(t.destinationPropertyName,t);return i.sourceMapping?e.validateSourcePropertyMapping(t,i,r,n,o):e.validateDestinationPropertyMapping(t,i,r,n,o)},e.validateSourcePropertyMapping=function(t,e,r,n,o){if(!n.hasOwnProperty(r))return"Source member '"+r+"' is configured, but does not exist on source type";{if(!e.ignore)return o.hasOwnProperty(r)?void 0:"Source member '"+r+"' is configured to be mapped, but does not exist on destination type";if(o.hasOwnProperty(r))return"Source member '"+r+"' is ignored, but does exist on destination type"}},e.validateDestinationPropertyMapping=function(t,e,r,n,o){if(!o.hasOwnProperty(e.name))return"Destination member '"+e.destinationPropertyName+"' is configured, but does not exist on destination type";{if(!e.ignore)return n.hasOwnProperty(r)?void 0:"Destination member '"+r+"' is configured to be mapped, but does not exist on source type";if(n.hasOwnProperty(r))return"Destination member '"+r+"' is ignored, but does exist on source type"}},e.validateProperty=function(t,e){if(!e.hasOwnProperty(t))return"Source member '"+t+"' is configured to be mapped, but does not exist on destination type"},e.getDestinationProperty=function(t,e){if(e.destination)return e.destination;if(e.children)for(var r=0,n=e.children;r0)for(var p=0,s=a;p0)for(var o=0,i=t.forAllMemberMappings;o0)for(var o=0,i=t.forAllMemberMappings;o=0;n--)""===r[n]&&r.splice(n,1);return t.destinationMemberNamingConvention.transformPropertyName(r)}catch(t){return e}},e.prototype.getPropertyMappings=function(t,e){for(var r=[],n=0,o=t;n0)for(var i=r?r[e.name]:null,a=0,p=e.children;a"+t.sourceKey+e+"=>"+t.destinationKey,n=this._mappings[r];if(n){n.forAllMemberMappings.length>0&&(s=t.forAllMemberMappings).push.apply(s,n.forAllMemberMappings),n.typeConverterFunction&&(t.typeConverterFunction=n.typeConverterFunction,t.mapItemFunction=n.mapItemFunction),n.destinationTypeClass&&(t.destinationTypeClass=n.destinationTypeClass);for(var o=0,i=n.properties;o0){var o=this.getDestinationProperty(n.destinationPropertyName,n);return this.handleMapFromProperties(t,n)?!!this.mergeDestinationProperty(t.destination,o)&&(n.destination=o,n.children=[],!0):this.mergeDestinationProperty(t.destination,o)}return!!this.mergeDestinationProperty(t.destination,n.destination)&&(this.handleMapFromProperties(t,n),!0)}if(n.children.length>0){for(var i=0,a=t.children;i"+r[n]);return automapper.createMap.apply(automapper,r)},t}();t.Profile=e}(AutoMapperJs||(AutoMapperJs={}));var AutoMapperJs;!function(t){"use strict";var e=function(){function t(){}return t.prototype.convert=function(t){throw new Error("The TypeConverter.convert method is abstract. Use a TypeConverter extension class instead.")},t}();t.TypeConverter=e}(AutoMapperJs||(AutoMapperJs={}));var AutoMapperJs;!function(t){"use strict";var e=function(){function t(){this.splittingExpression=/(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/,this.separatorCharacter=""}return t.prototype.transformPropertyName=function(t){for(var e="",r=0,n=t.length;r\r\n/// \r\n/// \r\n/// \r\n/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n // interface shorthands\r\n type IDMCO = IMemberConfigurationOptions;\r\n type ISMCO = ISourceMemberConfigurationOptions;\r\n\r\n /**\r\n * AsyncAutoMapper implementation, for asynchronous mapping support when using AutoMapper.\r\n */\r\n export class AsyncAutoMapper extends AutoMapperBase {\r\n private static asyncInstance = new AsyncAutoMapper();\r\n\r\n constructor() {\r\n super();\r\n AsyncAutoMapper.asyncInstance = this;\r\n }\r\n\r\n public createMap(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any)): any {\r\n throw new Error('Method AsyncAutoMapper.createMap is not implemented.');\r\n }\r\n\r\n public createMapForMember(mapping: IMapping, property: ISourceProperty): void {\r\n mapping.async = true;\r\n mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any, cb: IMapCallback) => this.mapItem(m, srcObj, dstObj, cb);\r\n // property.async = true;\r\n // property.conversionValuesAndFunctions.push(func);\r\n }\r\n\r\n public createMapConvertUsing(mapping: IMapping, converterFunction: (ctx: IResolutionContext, cb: IMapCallback) => void): void {\r\n mapping.async = true;\r\n mapping.typeConverterFunction = converterFunction;\r\n mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any, cb: IMapCallback) => this.mapItemUsingTypeConverter(m, srcObj, dstObj, cb);\r\n }\r\n\r\n public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any)): (dstKey: string | (new () => any), srcObj: any, cb: IMapCallback) => void;\r\n public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any), dstKey: string | (new () => any)): (srcObj: any, cb: IMapCallback) => void;\r\n public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any), dstKey?: string | (new () => any), sourceObject?: any): (cb: IMapCallback) => void;\r\n public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any), dstKey?: string | (new () => any), sourceObject?: any, cb?: IMapCallback): void;\r\n public map(mappings: { [key: string]: IMapping },\r\n sourceKey: string | (new () => any),\r\n destinationKey?: string | (new () => any),\r\n sourceObject?: any,\r\n callback?: IMapCallback): any /* actually, void (impossible with overloads) */ {\r\n\r\n switch (arguments.length) {\r\n case 5:\r\n this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), sourceObject, callback);\r\n return;\r\n // provide performance optimized (preloading) currying support.\r\n case 4:\r\n return (cb: IMapCallback) => this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), sourceObject, cb);\r\n case 3:\r\n return (srcObj: any, cb: IMapCallback) => this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), srcObj, cb);\r\n case 2:\r\n return (dstKey: string | (new () => any), srcObj: any, cb: IMapCallback) => this.map(mappings, sourceKey, dstKey, srcObj, cb);\r\n default:\r\n throw new Error('The AsyncAutoMapper.map function expects between 2 and 5 parameters, you provided ' + arguments.length + '.');\r\n }\r\n }\r\n\r\n public mapWithMapping(mapping: IMapping, sourceObject: any, callback: IMapCallback): void {\r\n if (super.isArray(sourceObject)) {\r\n this.mapArray(mapping, sourceObject, callback);\r\n return;\r\n }\r\n\r\n return (mapping.mapItemFunction)(mapping, sourceObject, super.createDestinationObject(mapping.destinationTypeClass), callback);\r\n }\r\n\r\n /**\r\n * Execute a mapping from the source array to a new destination array with explicit mapping configuration and supplied mapping options (using createMap).\r\n * @param mapping The mapping configuration for the current mapping keys/types.\r\n * @param sourceArray The source array to map.\r\n * @returns {Array} Destination array.\r\n */\r\n private mapArray(mapping: IMapping, sourceArray: Array, callback: IMapCallback): void {\r\n var callbacksToGo = 0;\r\n\r\n var destinationArray = super.handleArray(mapping, sourceArray, (sourceObject: any, destinationObject: any) => {\r\n callbacksToGo++;\r\n (mapping.mapItemFunction)(mapping, sourceObject, destinationObject, (result: any): void => {\r\n callbacksToGo--;\r\n });\r\n });\r\n\r\n var waitForCallbackToSend = (): void => {\r\n if (callbacksToGo === 0) {\r\n callback(destinationArray);\r\n } else {\r\n setTimeout((): void => {\r\n waitForCallbackToSend();\r\n }, 10 * callbacksToGo);\r\n }\r\n };\r\n\r\n waitForCallbackToSend();\r\n }\r\n\r\n private mapItemUsingTypeConverter(mapping: IMapping, sourceObject: any, destinationObject: any, callback: IMapCallback): void {\r\n var resolutionContext: IResolutionContext = {\r\n sourceValue: sourceObject,\r\n destinationValue: destinationObject\r\n };\r\n (<(ctx: IResolutionContext, cb: IMapCallback) => any>mapping.typeConverterFunction)(resolutionContext, callback);\r\n }\r\n\r\n /**\r\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\r\n * @param mapping The mapping configuration for the current mapping keys/types.\r\n * @param sourceObject The source object to map.\r\n * @param destinationObject The destination object to map to.\r\n * @param callback The callback to call after async mapping has been executed.\r\n */\r\n private mapItem(mapping: IMapping, sourceObject: any, destinationObject: any, callback: IMapCallback): void {\r\n var callbacksToGo = 0;\r\n\r\n super.handleItem(mapping, sourceObject, destinationObject, (sourceProperty: string) => {\r\n callbacksToGo++;\r\n this.mapProperty(mapping, sourceObject, sourceProperty, destinationObject, (result: any): void => {\r\n callbacksToGo--;\r\n });\r\n });\r\n\r\n var waitForCallbackToSend = (): void => {\r\n if (callbacksToGo === 0) {\r\n callback(destinationObject);\r\n } else {\r\n setTimeout((): void => {\r\n waitForCallbackToSend();\r\n }, 10 * callbacksToGo);\r\n }\r\n };\r\n\r\n waitForCallbackToSend();\r\n }\r\n\r\n /**\r\n * Execute a mapping from the source object property to the destination object property with explicit mapping configuration and supplied mapping options.\r\n * @param mapping The mapping configuration for the current mapping keys/types.\r\n * @param sourceObject The source object to map.\r\n * @param sourcePropertyName The source property to map.\r\n * @param destinationObject The destination object to map to.\r\n * @param callback The callback to call after async property mapping has been executed.\r\n */\r\n private mapProperty(mapping: IMapping, sourceObject: any, sourceProperty: string, destinationObject: any, callback: IMemberCallback): void {\r\n super.handleProperty(mapping, sourceObject, sourceProperty, destinationObject,\r\n (destinationProperty: IDestinationProperty, options: IDMCO) => {\r\n this.transform(mapping, sourceObject, destinationProperty, destinationObject, options, (destinationPropertyValue: any, success: boolean) => {\r\n callback(destinationPropertyValue);\r\n });\r\n }, (destinationPropertyValue: any) => {\r\n callback(destinationPropertyValue);\r\n });\r\n }\r\n\r\n private transform(\r\n mapping: IMapping,\r\n sourceObject: any,\r\n destinationProperty: IDestinationProperty,\r\n destinationObject: any,\r\n options: IDMCO,\r\n callback: IAsyncTransformCallback\r\n ): void {\r\n var childDestinationProperty = destinationProperty.child;\r\n if (childDestinationProperty) {\r\n var childDestinationObject = destinationObject[destinationProperty.name];\r\n if (!childDestinationObject) {\r\n // no child source object? create.\r\n childDestinationObject = {};\r\n }\r\n\r\n // transform child by recursively calling the transform function.\r\n this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options, (callbackValue: any, success: boolean): void => {\r\n if (success) {\r\n // only set child destination object when transformation has been successful.\r\n destinationObject[destinationProperty.name] = childDestinationObject;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, success);\r\n });\r\n return;\r\n }\r\n\r\n if (!super.shouldProcessDestination(destinationProperty, sourceObject)) {\r\n callback(undefined /* opts.intermediatePropertyValue */, false);\r\n return;\r\n }\r\n\r\n // actually transform destination property.\r\n this.processTransformations(destinationProperty, destinationProperty.transformations, options, (callbackValue: any, success: boolean) => {\r\n if (success) {\r\n super.setPropertyValue(mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\r\n }\r\n callback(options.intermediatePropertyValue, success);\r\n });\r\n }\r\n\r\n private processTransformations(\r\n property: IDestinationProperty, transformations: IDestinationTransformation[], options: IDMCO, callback: IAsyncTransformCallback\r\n ): void {\r\n if (transformations.length === 0) {\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n }\r\n\r\n let transformation = transformations[0];\r\n this.processTransformation(property, transformation, options, (callbackValue: any, success: boolean) => {\r\n if (!success) {\r\n callback(options.intermediatePropertyValue, false);\r\n return;\r\n }\r\n\r\n this.processTransformations(property, transformations.slice(1), options, callback);\r\n });\r\n }\r\n\r\n private processTransformation(\r\n property: IDestinationProperty, transformation: IDestinationTransformation, options: IDMCO, callback: IAsyncTransformCallback\r\n ): void {\r\n switch (transformation.transformationType) {\r\n case DestinationTransformationType.Constant:\r\n options.intermediatePropertyValue = transformation.constant;\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n case DestinationTransformationType.MemberOptions: {\r\n let result = transformation.memberConfigurationOptionsFunc(options);\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n } else if (!options.sourceObject) {\r\n callback(options.intermediatePropertyValue, false);\r\n return;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n }\r\n case DestinationTransformationType.SourceMemberOptions: {\r\n let result = transformation.sourceMemberConfigurationOptionsFunc(options);\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n } else if (!options.sourceObject) {\r\n callback(options.intermediatePropertyValue, false);\r\n return;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n }\r\n case DestinationTransformationType.AsyncMemberOptions:\r\n transformation.asyncMemberConfigurationOptionsFunc(options, (result: any) => {\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n });\r\n return;\r\n case DestinationTransformationType.AsyncSourceMemberOptions:\r\n transformation.asyncSourceMemberConfigurationOptionsFunc(options, (result: any) => {\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n });\r\n return;\r\n default:\r\n // TODO: this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation}`);\r\n callback(options.intermediatePropertyValue, false);\r\n return;\r\n }\r\n }\r\n }\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["AsyncAutoMapper.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,sCAAsC;AACtC,yCAAyC;AACzC,4CAA4C;AAC5C,+CAA+C;;;;;;;;;;;AAE/C,IAAO,YAAY,CAqRlB;AArRD,WAAO,YAAY;IACf,YAAY,CAAC;IAMb;;OAEG;IACH;QAAqC,mCAAc;QAG/C;YAAA,YACI,iBAAO,SAEV;YADG,eAAe,CAAC,aAAa,GAAG,KAAI,CAAC;;QACzC,CAAC;QAEM,mCAAS,GAAhB,UAAiB,eAAyC,EAAE,oBAA8C;YACtG,MAAM,IAAI,KAAK,CAAC,sDAAsD,CA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O,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;oBACnD,MAAM,CAAC;YACf,CAAC;QACL,CAAC;QACL,sBAAC;IAAD,CA1QA,AA0QC,CA1QoC,aAAA,cAAc;IAChC,6BAAa,GAAG,IAAI,eAAe,EAAE,CAAC;IAD5C,4BAAe,kBA0Q3B,CAAA;AACL,CAAC,EArRM,YAAY,KAAZ,YAAY,QAqRlB","file":"AsyncAutoMapper.js","sourcesContent":["/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n // interface shorthands\r\n type IDMCO = IMemberConfigurationOptions;\r\n type ISMCO = ISourceMemberConfigurationOptions;\r\n\r\n /**\r\n * AsyncAutoMapper implementation, for asynchronous mapping support when using AutoMapper.\r\n */\r\n export class AsyncAutoMapper extends AutoMapperBase {\r\n private static asyncInstance = new AsyncAutoMapper();\r\n\r\n constructor() {\r\n super();\r\n AsyncAutoMapper.asyncInstance = this;\r\n }\r\n\r\n public createMap(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any)): any {\r\n throw new Error('Method AsyncAutoMapper.createMap is not implemented.');\r\n }\r\n\r\n public createMapForMember(mapping: IMapping, property: ISourceProperty): void {\r\n mapping.async = true;\r\n mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any, cb: IMapCallback): void => this.mapItem(m, srcObj, dstObj, cb);\r\n // property.async = true;\r\n // property.conversionValuesAndFunctions.push(func);\r\n }\r\n\r\n public createMapConvertUsing(mapping: IMapping, converterFunction: (ctx: IResolutionContext, cb: IMapCallback) => void): void {\r\n mapping.async = true;\r\n mapping.typeConverterFunction = converterFunction;\r\n mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any, cb: IMapCallback): void => this.mapItemUsingTypeConverter(m, srcObj, dstObj, cb);\r\n }\r\n\r\n public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any)): (dstKey: string | (new () => any), srcObj: any, cb: IMapCallback) => void;\r\n public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any), dstKey: string | (new () => any)): (srcObj: any, cb: IMapCallback) => void;\r\n public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any), dstKey?: string | (new () => any), sourceObject?: any): (cb: IMapCallback) => void;\r\n public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any), dstKey?: string | (new () => any), sourceObject?: any, cb?: IMapCallback): void;\r\n public map(mappings: { [key: string]: IMapping },\r\n sourceKey: string | (new () => any),\r\n destinationKey?: string | (new () => any),\r\n sourceObject?: any,\r\n callback?: IMapCallback): any /* actually, void (impossible with overloads) */ {\r\n\r\n switch (arguments.length) {\r\n case 5:\r\n this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), sourceObject, callback);\r\n return;\r\n // provide performance optimized (preloading) currying support.\r\n case 4:\r\n return (cb: IMapCallback): void => this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), sourceObject, cb);\r\n case 3:\r\n return (srcObj: any, cb: IMapCallback): void => this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), srcObj, cb);\r\n case 2:\r\n return (dstKey: string | (new () => any), srcObj: any, cb: IMapCallback): void => this.map(mappings, sourceKey, dstKey, srcObj, cb);\r\n default:\r\n throw new Error('The AsyncAutoMapper.map function expects between 2 and 5 parameters, you provided ' + arguments.length + '.');\r\n }\r\n }\r\n\r\n public mapWithMapping(mapping: IMapping, sourceObject: any, callback: IMapCallback): void {\r\n if (super.isArray(sourceObject)) {\r\n this.mapArray(mapping, sourceObject, callback);\r\n return;\r\n }\r\n\r\n return (mapping.mapItemFunction)(mapping, sourceObject, super.createDestinationObject(mapping.destinationTypeClass), callback);\r\n }\r\n\r\n /**\r\n * Execute a mapping from the source array to a new destination array with explicit mapping configuration and supplied mapping options (using createMap).\r\n * @param mapping The mapping configuration for the current mapping keys/types.\r\n * @param sourceArray The source array to map.\r\n * @returns {Array} Destination array.\r\n */\r\n private mapArray(mapping: IMapping, sourceArray: Array, callback: IMapCallback): void {\r\n var callbacksToGo = 0;\r\n\r\n var destinationArray = super.handleArray(mapping, sourceArray, (sourceObject: any, destinationObject: any) => {\r\n callbacksToGo++;\r\n (mapping.mapItemFunction)(mapping, sourceObject, destinationObject, (result: any): void => {\r\n callbacksToGo--;\r\n });\r\n });\r\n\r\n var waitForCallbackToSend = (): void => {\r\n if (callbacksToGo === 0) {\r\n callback(destinationArray);\r\n } else {\r\n setTimeout((): void => {\r\n waitForCallbackToSend();\r\n }, 10 * callbacksToGo);\r\n }\r\n };\r\n\r\n waitForCallbackToSend();\r\n }\r\n\r\n private mapItemUsingTypeConverter(mapping: IMapping, sourceObject: any, destinationObject: any, callback: IMapCallback): void {\r\n var resolutionContext: IResolutionContext = {\r\n sourceValue: sourceObject,\r\n destinationValue: destinationObject\r\n };\r\n (<(ctx: IResolutionContext, cb: IMapCallback) => any>mapping.typeConverterFunction)(resolutionContext, callback);\r\n }\r\n\r\n /**\r\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\r\n * @param mapping The mapping configuration for the current mapping keys/types.\r\n * @param sourceObject The source object to map.\r\n * @param destinationObject The destination object to map to.\r\n * @param callback The callback to call after async mapping has been executed.\r\n */\r\n private mapItem(mapping: IMapping, sourceObject: any, destinationObject: any, callback: IMapCallback): void {\r\n var callbacksToGo = 0;\r\n\r\n super.handleItem(mapping, sourceObject, destinationObject, (sourceProperty: string) => {\r\n callbacksToGo++;\r\n this.mapProperty(mapping, sourceObject, sourceProperty, destinationObject, (result: any): void => {\r\n callbacksToGo--;\r\n });\r\n });\r\n\r\n var waitForCallbackToSend = (): void => {\r\n if (callbacksToGo === 0) {\r\n callback(destinationObject);\r\n } else {\r\n setTimeout((): void => {\r\n waitForCallbackToSend();\r\n }, 10 * callbacksToGo);\r\n }\r\n };\r\n\r\n waitForCallbackToSend();\r\n }\r\n\r\n /**\r\n * Execute a mapping from the source object property to the destination object property with explicit mapping configuration and supplied mapping options.\r\n * @param mapping The mapping configuration for the current mapping keys/types.\r\n * @param sourceObject The source object to map.\r\n * @param sourcePropertyName The source property to map.\r\n * @param destinationObject The destination object to map to.\r\n * @param callback The callback to call after async property mapping has been executed.\r\n */\r\n private mapProperty(mapping: IMapping, sourceObject: any, sourceProperty: string, destinationObject: any, callback: IMemberCallback): void {\r\n super.handleProperty(mapping, sourceObject, sourceProperty, destinationObject,\r\n (destinationProperty: IDestinationProperty, options: IDMCO) => {\r\n this.transform(mapping, sourceObject, destinationProperty, destinationObject, options, (destinationPropertyValue: any, success: boolean) => {\r\n callback(destinationPropertyValue);\r\n });\r\n }, (destinationPropertyValue: any) => {\r\n callback(destinationPropertyValue);\r\n });\r\n }\r\n\r\n private transform(\r\n mapping: IMapping,\r\n sourceObject: any,\r\n destinationProperty: IDestinationProperty,\r\n destinationObject: any,\r\n options: IDMCO,\r\n callback: IAsyncTransformCallback\r\n ): void {\r\n var childDestinationProperty = destinationProperty.child;\r\n if (childDestinationProperty) {\r\n var childDestinationObject = destinationObject[destinationProperty.name];\r\n if (!childDestinationObject) {\r\n // no child source object? create.\r\n childDestinationObject = {};\r\n }\r\n\r\n // transform child by recursively calling the transform function.\r\n this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options, (callbackValue: any, success: boolean): void => {\r\n if (success) {\r\n // only set child destination object when transformation has been successful.\r\n destinationObject[destinationProperty.name] = childDestinationObject;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, success);\r\n });\r\n return;\r\n }\r\n\r\n if (!super.shouldProcessDestination(destinationProperty, sourceObject)) {\r\n callback(undefined /* opts.intermediatePropertyValue */, false);\r\n return;\r\n }\r\n\r\n // actually transform destination property.\r\n this.processTransformations(destinationProperty, destinationProperty.transformations, options, (callbackValue: any, success: boolean) => {\r\n if (success) {\r\n super.setPropertyValue(mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\r\n }\r\n callback(options.intermediatePropertyValue, success);\r\n });\r\n }\r\n\r\n private processTransformations(\r\n property: IDestinationProperty, transformations: IDestinationTransformation[], options: IDMCO, callback: IAsyncTransformCallback\r\n ): void {\r\n if (transformations.length === 0) {\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n }\r\n\r\n let transformation = transformations[0];\r\n this.processTransformation(property, transformation, options, (callbackValue: any, success: boolean) => {\r\n if (!success) {\r\n callback(options.intermediatePropertyValue, false);\r\n return;\r\n }\r\n\r\n this.processTransformations(property, transformations.slice(1), options, callback);\r\n });\r\n }\r\n\r\n private processTransformation(\r\n property: IDestinationProperty, transformation: IDestinationTransformation, options: IDMCO, callback: IAsyncTransformCallback\r\n ): void {\r\n switch (transformation.transformationType) {\r\n case DestinationTransformationType.Constant:\r\n options.intermediatePropertyValue = transformation.constant;\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n case DestinationTransformationType.MemberOptions: {\r\n let result = transformation.memberConfigurationOptionsFunc(options);\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n } else if (!options.sourceObject) {\r\n callback(options.intermediatePropertyValue, false);\r\n return;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n }\r\n case DestinationTransformationType.SourceMemberOptions: {\r\n let result = transformation.sourceMemberConfigurationOptionsFunc(options);\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n } else if (!options.sourceObject) {\r\n callback(options.intermediatePropertyValue, false);\r\n return;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n }\r\n case DestinationTransformationType.AsyncMemberOptions:\r\n transformation.asyncMemberConfigurationOptionsFunc(options, (result: any) => {\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n });\r\n return;\r\n case DestinationTransformationType.AsyncSourceMemberOptions:\r\n transformation.asyncSourceMemberConfigurationOptionsFunc(options, (result: any) => {\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n }\r\n\r\n callback(options.intermediatePropertyValue, true);\r\n return;\r\n });\r\n return;\r\n default:\r\n // TODO: this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation}`);\r\n callback(options.intermediatePropertyValue, false);\r\n return;\r\n }\r\n }\r\n }\r\n}\r\n"]} \ No newline at end of file diff --git a/src/js/AutoMapper.js.map b/src/js/AutoMapper.js.map index 8a671fa..bd8884d 100644 --- a/src/js/AutoMapper.js.map +++ b/src/js/AutoMapper.js.map @@ -1 +1 @@ -{"version":3,"sources":["AutoMapper.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,kDAAkD;AAClD,0CAA0C;AAC1C,2CAA2C;AAC3C,yCAAyC;AACzC,4CAA4C;AAC5C,+CAA+C;;;;;;;;;;;AAE/C,IAAO,YAAY,CAsrBlB;AAtrBD,WAAO,YAAY;IACf,YAAY,CAAC;IAgBb;QAAgC,8BAAc;QAY1C;;;WAGG;QACH;YAAA,YACI,iBAAO,SAYV;YAVG,EAAE,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;gBACvB,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;YAChC,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,UAAU,CAAC,SAAS,GAAG,KAAI,CAAC;gBAE5B,KAAI,CAAC,SAAS,GAAG,EAAE,CAAC;gBACpB,KAAI,CAAC,SAAS,GAAG,EAAE,CAAC;gBAEpB,KAAI,CAAC,YAAY,GAAG,IAAI,aAAA,eAAe,EAAE,CAAC;YAC9C,CAAC;;QACL,CAAC;QArBa,sBAAW,GAAzB;YACI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;QAChC,CAAC;QAqBD;;;WAGG;QACI,+BAAU,GAAjB,UAAkB,cAAgD;YAC9D,IAAI,IAAI,GAAG,IAAI,CAAC;YAEhB,IAAI,aAAa,GAAwB;gBACrC,UAAU,EAAE,UAAC,OAAiB;oBAC1B,OAAO,CAAC,SAAS,EAAE,CAAC;oBACpB,IAAI,CAAC,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;IAAD,CApqBA,AAoqBC,CApqB+B,aAAA,cAAc;IAC3B,oBAAS,GAAG,IAAI,UAAU,EAAE,CAAC;IADnC,uBAAU,aAoqBtB,CAAA;AACL,CAAC,EAtrBM,YAAY,KAAZ,YAAY,QAsrBlB;AAED,0HAA0H;AAC1H,IAAI,UAAU,GAA4B,CAAC,UAAC,GAAQ;IAChD,GAAG,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;IACvD,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;AAC1B,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC","file":"AutoMapper.js","sourcesContent":["/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n // interface shorthands\r\n type IFluentFunc = ICreateMapFluentFunctions;\r\n type IDMCO = IMemberConfigurationOptions;\r\n type ISMCO = ISourceMemberConfigurationOptions;\r\n type IMC = IMemberCallback;\r\n type IRC = IResolutionContext;\r\n type TC = TypeConverter;\r\n\r\n // method overload shorthands\r\n type stringOrClass = string | (new () => any);\r\n type forMemberValueOrFunction = any | ((opts: IDMCO) => any) | ((opts: IDMCO, cb: IMC) => void);\r\n type forSourceMemberFunction = ((opts: ISMCO) => any) | ((opts: ISMCO, cb: IMC) => void);\r\n type convertUsingClassOrInstanceOrFunction = ((ctx: IRC) => any) | ((ctx: IRC, callback: IMapCallback) => void) | TC | (new () => TC);\r\n\r\n export class AutoMapper extends AutoMapperBase {\r\n private static _instance = new AutoMapper();\r\n\r\n private _profiles: { [name: string]: IProfile };\r\n private _mappings: { [key: string]: IMapping };\r\n\r\n private _asyncMapper: AsyncAutoMapper;\r\n\r\n public static getInstance(): AutoMapper {\r\n return AutoMapper._instance;\r\n }\r\n\r\n /**\r\n * This class is intended to be a Singleton. Preferrably use getInstance()\r\n * function instead of using the constructor directly from code.\r\n */\r\n constructor() {\r\n super();\r\n\r\n if (AutoMapper._instance) {\r\n return AutoMapper._instance;\r\n } else {\r\n AutoMapper._instance = this;\r\n\r\n this._profiles = {};\r\n this._mappings = {};\r\n\r\n this._asyncMapper = new AsyncAutoMapper();\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the mapper with the supplied configuration.\r\n * @param {(config: IConfiguration) => void} configFunction Configuration function to call.\r\n */\r\n public initialize(configFunction: (config: IConfiguration) => void): void {\r\n var that = this;\r\n\r\n var configuration: IConfiguration = {\r\n addProfile: (profile: IProfile): void => {\r\n profile.configure();\r\n that._profiles[profile.profileName] = profile;\r\n },\r\n createMap: function (sourceKey: string, destinationKey: string): IFluentFunc {\r\n // pass through using arguments to keep createMap's currying support fully functional.\r\n return that.createMap.apply(that, arguments);\r\n }\r\n };\r\n\r\n configFunction(configuration);\r\n }\r\n\r\n /**\r\n * Create a mapping profile.\r\n * @param {string} sourceKey The map source key.\r\n * @param {string} destinationKey The map destination key.\r\n * @returns {Core.ICreateMapFluentFunctions}\r\n */\r\n public createMap(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any)): IFluentFunc {\r\n // provide currying support.\r\n if (arguments.length < 2) {\r\n return AutoMapperHelper.handleCurrying(this.createMap, arguments, this);\r\n }\r\n\r\n var mapping = this.createMappingObjectForGivenKeys(sourceKeyOrType, destinationKeyOrType);\r\n\r\n return this.createMapGetFluentApiFunctions(mapping);\r\n }\r\n\r\n /**\r\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\r\n * @param sourceKey Source key, for instance the source type name.\r\n * @param destinationKey Destination key, for instance the destination type name.\r\n * @param sourceObject The source object to map.\r\n * @returns {any} Destination object.\r\n */\r\n public map(sourceKeyOrType: stringOrClass, destinationKeyOrType: stringOrClass, sourceObject: any): any {\r\n if (arguments.length === 3) {\r\n return this.mapInternal(super.getMapping(this._mappings, sourceKeyOrType, destinationKeyOrType), sourceObject);\r\n }\r\n\r\n // provide performance optimized (preloading) currying support.\r\n if (arguments.length === 2) {\r\n return (srcObj: any) => this.mapInternal(super.getMapping(this._mappings, sourceKeyOrType, destinationKeyOrType), srcObj);\r\n }\r\n\r\n if (arguments.length === 1) {\r\n return (dstKey: string | (new () => any), srcObj: any) => this.map(sourceKeyOrType, dstKey, srcObj);\r\n }\r\n\r\n return (srcKey: string | (new () => any), dstKey: string | (new () => any), srcObj: any) => this.map(srcKey, dstKey, srcObj);\r\n }\r\n\r\n /**\r\n * Execute an asynchronous mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\r\n * @param sourceKey Source key, for instance the source type name.\r\n * @param destinationKey Destination key, for instance the destination type name.\r\n * @param sourceObject The source object to map.\r\n * @param {IMapCallback} callback The callback to call when asynchronous mapping is complete.\r\n */\r\n public mapAsync(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any), sourceObject: any, callback: IMapCallback): any {\r\n switch (arguments.length) {\r\n case 4:\r\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject, callback);\r\n case 3:\r\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject);\r\n case 2:\r\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType);\r\n case 1:\r\n return this._asyncMapper.map(this._mappings, sourceKeyOrType);\r\n default:\r\n throw new Error('The mapAsync function expects between 1 and 4 parameters, you provided ' + arguments.length + '.');\r\n }\r\n }\r\n\r\n /**\r\n * Validates mapping configuration by dry-running. Since JS does not fully support typing, it only checks if properties match on both\r\n * sides. The function needs IMapping.sourceTypeClass and IMapping.destinationTypeClass to function.\r\n * @param {boolean} strictMode Whether or not to fail when properties sourceTypeClass or destinationTypeClass are unavailable.\r\n */\r\n public assertConfigurationIsValid(strictMode: boolean = true): void {\r\n AutoMapperValidator.assertConfigurationIsValid(this._mappings, strictMode);\r\n }\r\n\r\n private createMapForAllMembers(mapping: IMapping, fluentFunc: IFluentFunc, func: (dstObj: any, dstProp: string, val: any) => void): IFluentFunc {\r\n mapping.forAllMemberMappings.push(func);\r\n return fluentFunc;\r\n }\r\n\r\n private createMapIgnoreAllNonExisting(mapping: IMapping, fluentFunc: IFluentFunc): IFluentFunc {\r\n mapping.ignoreAllNonExisting = true;\r\n return fluentFunc;\r\n }\r\n\r\n private createMapConvertToType(mapping: IMapping, fluentFunc: IFluentFunc, typeClass: new () => any): IFluentFunc {\r\n if (mapping.destinationTypeClass) {\r\n throw new Error('Destination type class can only be set once.');\r\n }\r\n\r\n mapping.destinationTypeClass = typeClass;\r\n return fluentFunc;\r\n }\r\n\r\n private createMapConvertUsing(mapping: IMapping, tcClassOrFunc: convertUsingClassOrInstanceOrFunction): void {\r\n var configureSynchronousConverterFunction = (converterFunc: any) => {\r\n if (!converterFunc || AutoMapperHelper.getFunctionParameters(converterFunc.toString()).length !== 1) {\r\n throw new Error('The function provided does not provide exactly one (resolutionContext) parameter.');\r\n }\r\n\r\n mapping.typeConverterFunction = <(resolutionContext: IResolutionContext) => any>converterFunc;\r\n mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any): any => this.mapItemUsingTypeConverter(m, srcObj, dstObj);\r\n };\r\n\r\n try {\r\n // check if sync: TypeConverter instance\r\n if (tcClassOrFunc instanceof TypeConverter) {\r\n configureSynchronousConverterFunction(tcClassOrFunc.convert);\r\n return;\r\n }\r\n\r\n var functionParameters = AutoMapperHelper.getFunctionParameters(tcClassOrFunc.toString());\r\n switch (functionParameters.length) {\r\n case 0:\r\n // check if sync: TypeConverter class definition\r\n var typeConverter: TypeConverter;\r\n try {\r\n typeConverter = (new ( TypeConverter>tcClassOrFunc)());\r\n } catch (e) {\r\n // Obviously, typeConverterClassOrFunction is not a TypeConverter class definition\r\n }\r\n if (typeConverter instanceof TypeConverter) {\r\n configureSynchronousConverterFunction(typeConverter.convert);\r\n return;\r\n }\r\n break;\r\n case 1:\r\n // sync: function with resolutionContext parameter\r\n configureSynchronousConverterFunction(<(resolutionContext: IResolutionContext) => any>tcClassOrFunc);\r\n return;\r\n case 2:\r\n // check if async: function with resolutionContext and callback parameters\r\n this._asyncMapper.createMapConvertUsing(mapping, <(ctx: IResolutionContext, cb: IMapCallback) => void>tcClassOrFunc);\r\n return;\r\n }\r\n\r\n // okay, just try feeding the function to the configure function anyway...\r\n configureSynchronousConverterFunction(tcClassOrFunc);\r\n } catch (e) {\r\n throw new Error(`The value provided for typeConverterClassOrFunction is invalid. ${e}`);\r\n }\r\n }\r\n\r\n private createMapWithProfile(mapping: IMapping, profileName: string): void {\r\n // check if given profile exists\r\n var profile = this._profiles[profileName];\r\n if (typeof profile === 'undefined' || profile.profileName !== profileName) {\r\n throw new Error(`Could not find profile with profile name '${profileName}'.`);\r\n }\r\n\r\n mapping.profile = profile;\r\n // merge mappings\r\n this.createMapWithProfileMergeMappings(mapping, profileName);\r\n }\r\n\r\n private createMapWithProfileMergeMappings(mapping: IMapping, profileName: string): void {\r\n var profileMappingKey = `${profileName}=>${mapping.sourceKey}${profileName}=>${mapping.destinationKey}`;\r\n var profileMapping: IMapping = this._mappings[profileMappingKey];\r\n if (!profileMapping) {\r\n return;\r\n }\r\n\r\n // append forAllMemberMappings calls to the original array.\r\n if (profileMapping.forAllMemberMappings.length > 0) {\r\n mapping.forAllMemberMappings.push(...profileMapping.forAllMemberMappings);\r\n }\r\n\r\n // overwrite original type converter function\r\n if (profileMapping.typeConverterFunction) {\r\n mapping.typeConverterFunction = profileMapping.typeConverterFunction;\r\n mapping.mapItemFunction = profileMapping.mapItemFunction;\r\n }\r\n\r\n // overwrite original type converter function\r\n if (profileMapping.destinationTypeClass) {\r\n mapping.destinationTypeClass = profileMapping.destinationTypeClass;\r\n }\r\n\r\n // walk through all the profile's property mappings\r\n for (let property of profileMapping.properties) {\r\n // TODO Awkward way of locating sourceMapping ;) ...\r\n let sourceMapping = this.getDestinationProperty(property.destinationPropertyName, property).sourceMapping;\r\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\r\n mapping.properties.push(property);\r\n }\r\n }\r\n }\r\n\r\n private mapInternal(mapping: IMapping, sourceObject: any): any {\r\n if (mapping.async) {\r\n throw new Error('Impossible to use asynchronous mapping using automapper.map(); use automapper.mapAsync() instead.');\r\n }\r\n\r\n if (super.isArray(sourceObject)) {\r\n return this.mapArray(mapping, sourceObject);\r\n }\r\n\r\n return (mapping.mapItemFunction)(mapping, sourceObject, super.createDestinationObject(mapping.destinationTypeClass));\r\n }\r\n\r\n private mapArray(mapping: IMapping, sourceArray: Array): Array {\r\n var destinationArray = super.handleArray(mapping, sourceArray, (sourceObject: any, destinationObject: any) => {\r\n (mapping.mapItemFunction)(mapping, sourceObject, destinationObject);\r\n });\r\n return destinationArray;\r\n }\r\n\r\n private mapItem(mapping: IMapping, sourceObject: any, destinationObject: any): void {\r\n destinationObject = super.handleItem(mapping, sourceObject, destinationObject, (propertyName: string) => {\r\n this.mapProperty(mapping, sourceObject, destinationObject, propertyName);\r\n });\r\n return destinationObject;\r\n }\r\n\r\n private mapItemUsingTypeConverter(mapping: IMapping, sourceObject: any, destinationObject: any, arrayIndex?: number): void {\r\n var resolutionContext: IResolutionContext = {\r\n sourceValue: sourceObject,\r\n destinationValue: destinationObject\r\n };\r\n return (<(ctx: IResolutionContext) => any>mapping.typeConverterFunction)(resolutionContext);\r\n }\r\n\r\n private mapProperty(mapping: IMapping, sourceObject: any, destinationObject: any, sourceProperty: string): void {\r\n super.handleProperty(mapping, sourceObject, sourceProperty, destinationObject, (destinationProperty: IDestinationProperty, options: IDMCO) =>\r\n this.transform(mapping, sourceObject, destinationProperty, destinationObject, options)\r\n );\r\n }\r\n\r\n private transform(mapping: IMapping, sourceObject: any, destinationProperty: IDestinationProperty, destinationObject: any, options: IDMCO): boolean {\r\n var childDestinationProperty = destinationProperty.child;\r\n if (childDestinationProperty) {\r\n var childDestinationObject = destinationObject[destinationProperty.name];\r\n if (!childDestinationObject) {\r\n // no child source object? create.\r\n childDestinationObject = {};\r\n }\r\n\r\n // transform child by recursively calling the transform function.\r\n let transformed = this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options /*, callback*/);\r\n if (transformed) {\r\n // only set child destination object when transformation has been successful.\r\n destinationObject[destinationProperty.name] = childDestinationObject;\r\n }\r\n\r\n return transformed;\r\n }\r\n\r\n if (!super.shouldProcessDestination(destinationProperty, sourceObject)) {\r\n return false;\r\n }\r\n\r\n // actually transform destination property.\r\n for (let transformation of destinationProperty.transformations) {\r\n if (!this.processTransformation(destinationProperty, transformation, options)) {\r\n return false;\r\n }\r\n }\r\n\r\n super.setPropertyValue(mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\r\n return true;\r\n }\r\n\r\n private processTransformation(property: IDestinationProperty, transformation: IDestinationTransformation, options: IDMCO): boolean {\r\n switch (transformation.transformationType) {\r\n case DestinationTransformationType.Constant:\r\n options.intermediatePropertyValue = transformation.constant;\r\n return true;\r\n case DestinationTransformationType.MemberOptions: {\r\n let result = transformation.memberConfigurationOptionsFunc(options);\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n } else if (!options.sourceObject) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n case DestinationTransformationType.SourceMemberOptions: {\r\n let result = transformation.sourceMemberConfigurationOptionsFunc(options);\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n } else if (!options.sourceObject) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n default:\r\n // this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation.transformationType}`);\r\n return false;\r\n }\r\n }\r\n\r\n private createMappingObjectForGivenKeys(srcKeyOrType: string | (new () => any), dstKeyOrType: string | (new () => any)): IMapping {\r\n var mapping: IMapping = {\r\n sourceKey: super.getKey(srcKeyOrType),\r\n destinationKey: super.getKey(dstKeyOrType),\r\n forAllMemberMappings: new Array<(destinationObject: any, destinationPropertyName: string, value: any) => void>(),\r\n properties: [],\r\n typeConverterFunction: undefined,\r\n mapItemFunction: (m: IMapping, srcObj: any, dstObj: any): any => this.mapItem(m, srcObj, dstObj),\r\n sourceTypeClass: (typeof srcKeyOrType === 'string' ? undefined : srcKeyOrType),\r\n destinationTypeClass: (typeof dstKeyOrType === 'string' ? undefined : dstKeyOrType),\r\n profile: undefined,\r\n async: false\r\n };\r\n this._mappings[mapping.sourceKey + mapping.destinationKey] = mapping;\r\n return mapping;\r\n }\r\n\r\n private createMapGetFluentApiFunctions(mapping: IMapping): IFluentFunc {\r\n // create a fluent interface / method chaining (e.g. automapper.createMap().forMember().forMember() ...)\r\n var fluentFunc: IFluentFunc = {\r\n forMember: (prop: string, valFunc: forMemberValueOrFunction): IFluentFunc =>\r\n this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: valFunc, sourceMapping: false, fluentFunctions: fluentFunc }),\r\n forSourceMember: (prop: string, cfgFunc: ((opts: ISMCO) => any) | ((opts: ISMCO, cb: IMC) => void)): IFluentFunc =>\r\n this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: cfgFunc, sourceMapping: true, fluentFunctions: fluentFunc }),\r\n forAllMembers: (func: (dstObj: any, dstProp: string, value: any) => void): IFluentFunc =>\r\n this.createMapForAllMembers(mapping, fluentFunc, func),\r\n ignoreAllNonExisting: (): IFluentFunc => this.createMapIgnoreAllNonExisting(mapping, fluentFunc),\r\n convertToType: (type: new () => any): IFluentFunc => this.createMapConvertToType(mapping, fluentFunc, type),\r\n convertUsing: (tcClassOrFunc: convertUsingClassOrInstanceOrFunction): void =>\r\n this.createMapConvertUsing(mapping, tcClassOrFunc),\r\n withProfile: (profile: string): void => this.createMapWithProfile(mapping, profile)\r\n };\r\n\r\n return fluentFunc;\r\n }\r\n\r\n private createMapForMember(parameters: ICreateMapForMemberParameters): IFluentFunc {\r\n var { mapping, propertyName, transformation, sourceMapping, fluentFunctions } = parameters;\r\n\r\n // extract source/destination property names\r\n var metadata = AutoMapperHelper.getMappingMetadataFromTransformationFunction(propertyName, transformation, sourceMapping);\r\n this.validateForMemberParameters(metadata);\r\n\r\n var { source, destination } = metadata;\r\n\r\n // create property (regardless of current existance)\r\n var property = this.createSourceProperty(metadata, null);\r\n\r\n // merge with existing property or add property\r\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\r\n mapping.properties.push(property);\r\n }\r\n\r\n if (metadata.async) {\r\n this._asyncMapper.createMapForMember(mapping, this.findProperty(property.name, mapping.properties));\r\n }\r\n\r\n return fluentFunctions;\r\n }\r\n\r\n private validateForMemberParameters(metadata: IMemberMappingMetaData): void {\r\n if (!metadata.sourceMapping) {\r\n return;\r\n }\r\n\r\n // validate forSourceMember parameters\r\n if (metadata.transformation.transformationType === DestinationTransformationType.Constant) {\r\n throw new Error('Configuration of forSourceMember has to be a function with one (sync) or two (async) options parameters.');\r\n }\r\n }\r\n\r\n private createSourceProperty(metadata: IMemberMappingMetaData, parent: ISourceProperty): ISourceProperty {\r\n var level = !parent ? 0 : parent.level + 1;\r\n var sourceNameParts = metadata.source.split('.');\r\n\r\n var source = {\r\n name: sourceNameParts[level],\r\n sourcePropertyName: metadata.source,\r\n destinationPropertyName: metadata.destination,\r\n parent: parent,\r\n level: level,\r\n children: [],\r\n destination: null\r\n };\r\n\r\n if ((level + 1) < sourceNameParts.length) {\r\n // recursively add child source properties ...\r\n var child = this.createSourceProperty(metadata, source);\r\n if (child) { // TODO should not be necessary, test thoroughly!\r\n source.children.push(child);\r\n }\r\n source.destination = null;\r\n } else {\r\n // ... or (!) add destination\r\n source.destination = this.createDestinationProperty(metadata, null);\r\n }\r\n return source;\r\n }\r\n\r\n private createDestinationProperty(metadata: IMemberMappingMetaData, parent: IDestinationProperty): IDestinationProperty {\r\n var level = !parent ? 0 : parent.level + 1;\r\n var destinationNameParts = metadata.destination.split('.');\r\n\r\n var destination = {\r\n name: destinationNameParts[level],\r\n sourcePropertyName: metadata.source,\r\n destinationPropertyName: metadata.destination,\r\n parent: parent,\r\n level: level,\r\n child: null,\r\n transformations: [],\r\n conditionFunction: null,\r\n ignore: false,\r\n sourceMapping: false\r\n };\r\n\r\n if ((level + 1) < destinationNameParts.length) {\r\n // recursively add child destination properties\r\n destination.child = this.createDestinationProperty(metadata, destination);\r\n } else {\r\n // add/merge properties\r\n destination.sourceMapping = metadata.sourceMapping;\r\n destination.conditionFunction = metadata.condition;\r\n destination.ignore = metadata.ignore;\r\n destination.transformations.push(metadata.transformation);\r\n }\r\n\r\n return destination;\r\n }\r\n\r\n private mergeSourceProperty(property: ISourceProperty, existingProperties: ISourceProperty[], sourceMapping: boolean): boolean {\r\n // find source property\r\n var existing = sourceMapping\r\n ? this.findProperty(property.name, existingProperties)\r\n : this.matchSourcePropertyByDestination(property, existingProperties);\r\n\r\n if (!existing) {\r\n return false;\r\n }\r\n\r\n if (property.destination) { // new source is not (further) nested.\r\n if (existing.children.length > 0) {\r\n let existingDestination = this.getDestinationProperty(existing.destinationPropertyName, existing);\r\n\r\n // existing is (further) nested => rebase and/or merge\r\n if (this.handleMapFromProperties(property, existing)) {\r\n // merge and rebase existing destination to current source level\r\n if (!this.mergeDestinationProperty(property.destination, existingDestination)) {\r\n return false;\r\n }\r\n\r\n existing.destination = existingDestination;\r\n existing.children = [];\r\n return true;\r\n }\r\n\r\n // merge property.destination with existing mapFrom() destination (don't care about nesting depth here)\r\n return this.mergeDestinationProperty(property.destination, existingDestination);\r\n }\r\n\r\n // both are at same level => simple merge.\r\n if (!this.mergeDestinationProperty(property.destination, existing.destination)) {\r\n return false;\r\n }\r\n\r\n this.handleMapFromProperties(property, existing);\r\n return true;\r\n }\r\n\r\n // new source is (further) nested (has children).\r\n if (existing.children.length > 0) {\r\n // both have further nesting, delegate merging child(ren) by recursively calling this function.\r\n for (let child of property.children) {\r\n if (!this.mergeSourceProperty(child, existing.children, sourceMapping)) {\r\n return false;\r\n }\r\n }\r\n\r\n if (property.destinationPropertyName !== property.sourcePropertyName) {\r\n // this is a mapFrom() registration. It is handled using the nested source properties,\r\n // we only are responsible for syncing the name properties.\r\n existing.name = property.name;\r\n existing.sourcePropertyName = property.sourcePropertyName;\r\n }\r\n return true;\r\n }\r\n\r\n // existing is not (further) nested. this is always a mapFrom() situation.\r\n // if (property.sourcePropertyName !== existing.sourcePropertyName) {\r\n let newDestination = this.getDestinationProperty(existing.destinationPropertyName, property);\r\n\r\n if (property.destinationPropertyName !== property.sourcePropertyName) {\r\n // this is a mapFrom() registration. In that case:\r\n // 1) merge destinations, 2) add source child and 3) move destination to (youngest) child\r\n // NOTE special mergeDestinationProperty call => we use the new destination as 'target',\r\n // because that will save us trouble overwriting ;)...\r\n if (!this.mergeDestinationProperty(existing.destination, newDestination, true)) {\r\n return false;\r\n }\r\n\r\n existing.children = property.children;\r\n existing.name = property.name;\r\n existing.sourcePropertyName = property.sourcePropertyName;\r\n existing.destination = null;\r\n // TODO Should never be necessary (test): existing.destinationPropertyName = property.destinationPropertyName;\r\n return true;\r\n }\r\n\r\n // ... nope, it is a destination which has previously been registered using mapFrom. just merge\r\n return this.mergeDestinationProperty(newDestination, existing.destination);\r\n // }\r\n }\r\n\r\n /**\r\n * handle property naming when the current property to merge is a mapFrom property\r\n */\r\n private handleMapFromProperties(property: TProperty, existingProperty: TProperty): boolean {\r\n if (property.destinationPropertyName === property.sourcePropertyName ||\r\n property.sourcePropertyName === existingProperty.sourcePropertyName) {\r\n return false;\r\n }\r\n\r\n // only overwrite name when a mapFrom situation applies\r\n existingProperty.name = property.name;\r\n existingProperty.sourcePropertyName = property.sourcePropertyName;\r\n // TODO Should never be necessary (test) => existingProperty.destinationPropertyName = property.destinationPropertyName;\r\n\r\n return true;\r\n }\r\n\r\n private getDestinationProperty(destinationPropertyName: string, existingSource: ISourceProperty): IDestinationProperty {\r\n if (existingSource.destination) {\r\n return existingSource.destination;\r\n }\r\n\r\n for (let child of existingSource.children) {\r\n var destination = this.getDestinationProperty(destinationPropertyName, child);\r\n if (destination) {\r\n return destination;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private mergeDestinationProperty(destination: IDestinationProperty, existingDestination: IDestinationProperty, swapTransformations: boolean = false): boolean {\r\n if (destination.child) { // destination is (further) nested\r\n if (existingDestination.child) {\r\n // both have further nesting, delegate merging children by recursively calling this function.\r\n if (!this.mergeDestinationProperty(destination.child, existingDestination.child, swapTransformations)) {\r\n return false;\r\n }\r\n\r\n this.handleMapFromProperties(destination, existingDestination);\r\n return true;\r\n }\r\n\r\n // the current destination is not (further) nested. a destination property registration has one of both:\r\n // a) children or b) transformations. returning false will cause creating a duplicate source property entry instead.\r\n return false;\r\n }\r\n\r\n if (existingDestination.sourceMapping !== destination.sourceMapping &&\r\n existingDestination.sourcePropertyName !== destination.sourcePropertyName) {\r\n // unable to perform mapFrom() on a property which is being registered using forSourceMember.\r\n return false; // TODO: Unpredictable? Idea: throw new Error('Unable to perform mapFrom() on a property which is being registered using forSourceMember.');\r\n }\r\n\r\n // merge destination properties\r\n if (destination.sourceMapping) {\r\n // only set source mapping when not yet set to true, once source mapped is source mapped forever.\r\n // TODO Verify edge cases!\r\n existingDestination.sourceMapping = destination.sourceMapping;\r\n }\r\n\r\n if (destination.ignore) {\r\n // only set ignore when not yet set, once ignored is ignored forever.\r\n existingDestination.ignore = destination.ignore;\r\n }\r\n\r\n if (destination.conditionFunction) {\r\n // overwrite condition function by the latest one specified.\r\n existingDestination.conditionFunction = destination.conditionFunction;\r\n }\r\n\r\n let transformations: IDestinationTransformation[] = [];\r\n if (swapTransformations) {\r\n for (let transformation of destination.transformations) {\r\n transformations.push(transformation);\r\n }\r\n for (let transformation of existingDestination.transformations) {\r\n transformations.push(transformation);\r\n }\r\n } else {\r\n for (let transformation of existingDestination.transformations) {\r\n transformations.push(transformation);\r\n }\r\n for (let transformation of destination.transformations) {\r\n transformations.push(transformation);\r\n }\r\n }\r\n existingDestination.transformations = transformations;\r\n\r\n this.handleMapFromProperties(destination, existingDestination);\r\n return true;\r\n }\r\n\r\n private matchSourcePropertyByDestination(source: ISourceProperty, properties: ISourceProperty[]): ISourceProperty {\r\n if (!properties) {\r\n return null;\r\n }\r\n\r\n for (let property of properties) {\r\n if (property.destinationPropertyName === source.destinationPropertyName) {\r\n return property;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private findProperty(name: string, properties: TProperty[]): TProperty {\r\n if (!properties) {\r\n return null;\r\n }\r\n\r\n for (var property of properties) {\r\n if (property.name === name) {\r\n return property;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n }\r\n}\r\n\r\n// Add AutoMapper to the application's global scope. Of course, you could still use Core.AutoMapper.getInstance() as well.\r\nvar automapper: AutoMapperJs.AutoMapper = ((app: any) => {\r\n app.automapper = AutoMapperJs.AutoMapper.getInstance();\r\n return app.automapper;\r\n})(this);\r\n"]} \ No newline at end of file +{"version":3,"sources":["AutoMapper.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,kDAAkD;AAClD,0CAA0C;AAC1C,2CAA2C;AAC3C,yCAAyC;AACzC,4CAA4C;AAC5C,+CAA+C;;;;;;;;;;;AAE/C,IAAO,YAAY,CAsrBlB;AAtrBD,WAAO,YAAY;IACf,YAAY,CAAC;IAgBb;QAAgC,8BAAc;QAY1C;;;WAGG;QACH;YAAA,YACI,iBAAO,SAYV;YAVG,EAAE,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;gBACvB,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;YAChC,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,UAAU,CAAC,SAAS,GAAG,KAAI,CAAC;gBAE5B,KAAI,CAAC,SAAS,GAAG,EAAE,CAAC;gBACpB,KAAI,CAAC,SAAS,GAAG,EAAE,CAAC;gBAEpB,KAAI,CAAC,YAAY,GAAG,IAAI,aAAA,eAAe,EAAE,CAAC;YAC9C,CAAC;;QACL,CAAC;QArBa,sBAAW,GAAzB;YACI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;QAChC,CAAC;QAqBD;;;WAGG;QACI,+BAAU,GAAjB,UAAkB,cAAgD;YAC9D,IAAI,IAAI,GAAG,IAAI,CAAC;YAEhB,IAAI,aAAa,GAA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M,CAAC,QAAQ,CAAC;gBACpB,CAAC;aACJ;YAED,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QAEL,iBAAC;IAAD,CApqBA,AAoqBC,CApqB+B,aAAA,cAAc;IAC3B,oBAAS,GAAG,IAAI,UAAU,EAAE,CAAC;IADnC,uBAAU,aAoqBtB,CAAA;AACL,CAAC,EAtrBM,YAAY,KAAZ,YAAY,QAsrBlB;AAED,0HAA0H;AAC1H,IAAI,UAAU,GAA4B,CAAC,UAAC,GAAQ;IAChD,GAAG,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;IACvD,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC;AAC1B,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC","file":"AutoMapper.js","sourcesContent":["/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n // interface shorthands\r\n type IFluentFunc = ICreateMapFluentFunctions;\r\n type IDMCO = IMemberConfigurationOptions;\r\n type ISMCO = ISourceMemberConfigurationOptions;\r\n type IMC = IMemberCallback;\r\n type IRC = IResolutionContext;\r\n type TC = TypeConverter;\r\n\r\n // method overload shorthands\r\n type stringOrClass = string | (new () => any);\r\n type forMemberValueOrFunction = any | ((opts: IDMCO) => any) | ((opts: IDMCO, cb: IMC) => void);\r\n type forSourceMemberFunction = ((opts: ISMCO) => any) | ((opts: ISMCO, cb: IMC) => void);\r\n type convertUsingClassOrInstanceOrFunction = ((ctx: IRC) => any) | ((ctx: IRC, callback: IMapCallback) => void) | TC | (new () => TC);\r\n\r\n export class AutoMapper extends AutoMapperBase {\r\n private static _instance = new AutoMapper();\r\n\r\n private _profiles: { [name: string]: IProfile };\r\n private _mappings: { [key: string]: IMapping };\r\n\r\n private _asyncMapper: AsyncAutoMapper;\r\n\r\n public static getInstance(): AutoMapper {\r\n return AutoMapper._instance;\r\n }\r\n\r\n /**\r\n * This class is intended to be a Singleton. Preferrably use getInstance()\r\n * function instead of using the constructor directly from code.\r\n */\r\n constructor() {\r\n super();\r\n\r\n if (AutoMapper._instance) {\r\n return AutoMapper._instance;\r\n } else {\r\n AutoMapper._instance = this;\r\n\r\n this._profiles = {};\r\n this._mappings = {};\r\n\r\n this._asyncMapper = new AsyncAutoMapper();\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the mapper with the supplied configuration.\r\n * @param {(config: IConfiguration) => void} configFunction Configuration function to call.\r\n */\r\n public initialize(configFunction: (config: IConfiguration) => void): void {\r\n var that = this;\r\n\r\n var configuration: IConfiguration = {\r\n addProfile: (profile: IProfile): void => {\r\n profile.configure();\r\n that._profiles[profile.profileName] = profile;\r\n },\r\n createMap: function (sourceKey: string, destinationKey: string): IFluentFunc {\r\n // pass through using arguments to keep createMap's currying support fully functional.\r\n return that.createMap.apply(that, arguments);\r\n }\r\n };\r\n\r\n configFunction(configuration);\r\n }\r\n\r\n /**\r\n * Create a mapping profile.\r\n * @param {string} sourceKey The map source key.\r\n * @param {string} destinationKey The map destination key.\r\n * @returns {Core.ICreateMapFluentFunctions}\r\n */\r\n public createMap(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any)): IFluentFunc {\r\n // provide currying support.\r\n if (arguments.length < 2) {\r\n return AutoMapperHelper.handleCurrying(this.createMap, arguments, this);\r\n }\r\n\r\n var mapping = this.createMappingObjectForGivenKeys(sourceKeyOrType, destinationKeyOrType);\r\n\r\n return this.createMapGetFluentApiFunctions(mapping);\r\n }\r\n\r\n /**\r\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\r\n * @param sourceKey Source key, for instance the source type name.\r\n * @param destinationKey Destination key, for instance the destination type name.\r\n * @param sourceObject The source object to map.\r\n * @returns {any} Destination object.\r\n */\r\n public map(sourceKeyOrType: stringOrClass, destinationKeyOrType: stringOrClass, sourceObject: any): any {\r\n if (arguments.length === 3) {\r\n return this.mapInternal(super.getMapping(this._mappings, sourceKeyOrType, destinationKeyOrType), sourceObject);\r\n }\r\n\r\n // provide performance optimized (preloading) currying support.\r\n if (arguments.length === 2) {\r\n return (srcObj: any): any => this.mapInternal(super.getMapping(this._mappings, sourceKeyOrType, destinationKeyOrType), srcObj);\r\n }\r\n\r\n if (arguments.length === 1) {\r\n return (dstKey: string | (new () => any), srcObj: any): any => this.map(sourceKeyOrType, dstKey, srcObj);\r\n }\r\n\r\n return (srcKey: string | (new () => any), dstKey: string | (new () => any), srcObj: any): any => this.map(srcKey, dstKey, srcObj);\r\n }\r\n\r\n /**\r\n * Execute an asynchronous mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\r\n * @param sourceKey Source key, for instance the source type name.\r\n * @param destinationKey Destination key, for instance the destination type name.\r\n * @param sourceObject The source object to map.\r\n * @param {IMapCallback} callback The callback to call when asynchronous mapping is complete.\r\n */\r\n public mapAsync(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any), sourceObject: any, callback: IMapCallback): any {\r\n switch (arguments.length) {\r\n case 4:\r\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject, callback);\r\n case 3:\r\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject);\r\n case 2:\r\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType);\r\n case 1:\r\n return this._asyncMapper.map(this._mappings, sourceKeyOrType);\r\n default:\r\n throw new Error('The mapAsync function expects between 1 and 4 parameters, you provided ' + arguments.length + '.');\r\n }\r\n }\r\n\r\n /**\r\n * Validates mapping configuration by dry-running. Since JS does not fully support typing, it only checks if properties match on both\r\n * sides. The function needs IMapping.sourceTypeClass and IMapping.destinationTypeClass to function.\r\n * @param {boolean} strictMode Whether or not to fail when properties sourceTypeClass or destinationTypeClass are unavailable.\r\n */\r\n public assertConfigurationIsValid(strictMode: boolean = true): void {\r\n AutoMapperValidator.assertConfigurationIsValid(this._mappings, strictMode);\r\n }\r\n\r\n private createMapForAllMembers(mapping: IMapping, fluentFunc: IFluentFunc, func: (dstObj: any, dstProp: string, val: any) => void): IFluentFunc {\r\n mapping.forAllMemberMappings.push(func);\r\n return fluentFunc;\r\n }\r\n\r\n private createMapIgnoreAllNonExisting(mapping: IMapping, fluentFunc: IFluentFunc): IFluentFunc {\r\n mapping.ignoreAllNonExisting = true;\r\n return fluentFunc;\r\n }\r\n\r\n private createMapConvertToType(mapping: IMapping, fluentFunc: IFluentFunc, typeClass: new () => any): IFluentFunc {\r\n if (mapping.destinationTypeClass) {\r\n throw new Error('Destination type class can only be set once.');\r\n }\r\n\r\n mapping.destinationTypeClass = typeClass;\r\n return fluentFunc;\r\n }\r\n\r\n private createMapConvertUsing(mapping: IMapping, tcClassOrFunc: convertUsingClassOrInstanceOrFunction): void {\r\n var configureSynchronousConverterFunction = (converterFunc: any): void => {\r\n if (!converterFunc || AutoMapperHelper.getFunctionParameters(converterFunc.toString()).length !== 1) {\r\n throw new Error('The function provided does not provide exactly one (resolutionContext) parameter.');\r\n }\r\n\r\n mapping.typeConverterFunction = <(resolutionContext: IResolutionContext) => any>converterFunc;\r\n mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any): any => this.mapItemUsingTypeConverter(m, srcObj, dstObj);\r\n };\r\n\r\n try {\r\n // check if sync: TypeConverter instance\r\n if (tcClassOrFunc instanceof TypeConverter) {\r\n configureSynchronousConverterFunction(tcClassOrFunc.convert);\r\n return;\r\n }\r\n\r\n var functionParameters = AutoMapperHelper.getFunctionParameters(tcClassOrFunc.toString());\r\n switch (functionParameters.length) {\r\n case 0:\r\n // check if sync: TypeConverter class definition\r\n var typeConverter: TypeConverter;\r\n try {\r\n typeConverter = (new ( TypeConverter>tcClassOrFunc)());\r\n } catch (e) {\r\n // Obviously, typeConverterClassOrFunction is not a TypeConverter class definition\r\n }\r\n if (typeConverter instanceof TypeConverter) {\r\n configureSynchronousConverterFunction(typeConverter.convert);\r\n return;\r\n }\r\n break;\r\n case 1:\r\n // sync: function with resolutionContext parameter\r\n configureSynchronousConverterFunction(<(resolutionContext: IResolutionContext) => any>tcClassOrFunc);\r\n return;\r\n case 2:\r\n // check if async: function with resolutionContext and callback parameters\r\n this._asyncMapper.createMapConvertUsing(mapping, <(ctx: IResolutionContext, cb: IMapCallback) => void>tcClassOrFunc);\r\n return;\r\n }\r\n\r\n // okay, just try feeding the function to the configure function anyway...\r\n configureSynchronousConverterFunction(tcClassOrFunc);\r\n } catch (e) {\r\n throw new Error(`The value provided for typeConverterClassOrFunction is invalid. ${e}`);\r\n }\r\n }\r\n\r\n private createMapWithProfile(mapping: IMapping, profileName: string): void {\r\n // check if given profile exists\r\n var profile = this._profiles[profileName];\r\n if (typeof profile === 'undefined' || profile.profileName !== profileName) {\r\n throw new Error(`Could not find profile with profile name '${profileName}'.`);\r\n }\r\n\r\n mapping.profile = profile;\r\n // merge mappings\r\n this.createMapWithProfileMergeMappings(mapping, profileName);\r\n }\r\n\r\n private createMapWithProfileMergeMappings(mapping: IMapping, profileName: string): void {\r\n var profileMappingKey = `${profileName}=>${mapping.sourceKey}${profileName}=>${mapping.destinationKey}`;\r\n var profileMapping: IMapping = this._mappings[profileMappingKey];\r\n if (!profileMapping) {\r\n return;\r\n }\r\n\r\n // append forAllMemberMappings calls to the original array.\r\n if (profileMapping.forAllMemberMappings.length > 0) {\r\n mapping.forAllMemberMappings.push(...profileMapping.forAllMemberMappings);\r\n }\r\n\r\n // overwrite original type converter function\r\n if (profileMapping.typeConverterFunction) {\r\n mapping.typeConverterFunction = profileMapping.typeConverterFunction;\r\n mapping.mapItemFunction = profileMapping.mapItemFunction;\r\n }\r\n\r\n // overwrite original type converter function\r\n if (profileMapping.destinationTypeClass) {\r\n mapping.destinationTypeClass = profileMapping.destinationTypeClass;\r\n }\r\n\r\n // walk through all the profile's property mappings\r\n for (let property of profileMapping.properties) {\r\n // TODO Awkward way of locating sourceMapping ;) ...\r\n let sourceMapping = this.getDestinationProperty(property.destinationPropertyName, property).sourceMapping;\r\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\r\n mapping.properties.push(property);\r\n }\r\n }\r\n }\r\n\r\n private mapInternal(mapping: IMapping, sourceObject: any): any {\r\n if (mapping.async) {\r\n throw new Error('Impossible to use asynchronous mapping using automapper.map(); use automapper.mapAsync() instead.');\r\n }\r\n\r\n if (super.isArray(sourceObject)) {\r\n return this.mapArray(mapping, sourceObject);\r\n }\r\n\r\n return (mapping.mapItemFunction)(mapping, sourceObject, super.createDestinationObject(mapping.destinationTypeClass));\r\n }\r\n\r\n private mapArray(mapping: IMapping, sourceArray: Array): Array {\r\n var destinationArray = super.handleArray(mapping, sourceArray, (sourceObject: any, destinationObject: any) => {\r\n (mapping.mapItemFunction)(mapping, sourceObject, destinationObject);\r\n });\r\n return destinationArray;\r\n }\r\n\r\n private mapItem(mapping: IMapping, sourceObject: any, destinationObject: any): void {\r\n destinationObject = super.handleItem(mapping, sourceObject, destinationObject, (propertyName: string) => {\r\n this.mapProperty(mapping, sourceObject, destinationObject, propertyName);\r\n });\r\n return destinationObject;\r\n }\r\n\r\n private mapItemUsingTypeConverter(mapping: IMapping, sourceObject: any, destinationObject: any, arrayIndex?: number): void {\r\n var resolutionContext: IResolutionContext = {\r\n sourceValue: sourceObject,\r\n destinationValue: destinationObject\r\n };\r\n return (<(ctx: IResolutionContext) => any>mapping.typeConverterFunction)(resolutionContext);\r\n }\r\n\r\n private mapProperty(mapping: IMapping, sourceObject: any, destinationObject: any, sourceProperty: string): void {\r\n super.handleProperty(mapping, sourceObject, sourceProperty, destinationObject, (destinationProperty: IDestinationProperty, options: IDMCO) =>\r\n this.transform(mapping, sourceObject, destinationProperty, destinationObject, options)\r\n );\r\n }\r\n\r\n private transform(mapping: IMapping, sourceObject: any, destinationProperty: IDestinationProperty, destinationObject: any, options: IDMCO): boolean {\r\n var childDestinationProperty = destinationProperty.child;\r\n if (childDestinationProperty) {\r\n var childDestinationObject = destinationObject[destinationProperty.name];\r\n if (!childDestinationObject) {\r\n // no child source object? create.\r\n childDestinationObject = {};\r\n }\r\n\r\n // transform child by recursively calling the transform function.\r\n let transformed = this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options /*, callback*/);\r\n if (transformed) {\r\n // only set child destination object when transformation has been successful.\r\n destinationObject[destinationProperty.name] = childDestinationObject;\r\n }\r\n\r\n return transformed;\r\n }\r\n\r\n if (!super.shouldProcessDestination(destinationProperty, sourceObject)) {\r\n return false;\r\n }\r\n\r\n // actually transform destination property.\r\n for (let transformation of destinationProperty.transformations) {\r\n if (!this.processTransformation(destinationProperty, transformation, options)) {\r\n return false;\r\n }\r\n }\r\n\r\n super.setPropertyValue(mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\r\n return true;\r\n }\r\n\r\n private processTransformation(property: IDestinationProperty, transformation: IDestinationTransformation, options: IDMCO): boolean {\r\n switch (transformation.transformationType) {\r\n case DestinationTransformationType.Constant:\r\n options.intermediatePropertyValue = transformation.constant;\r\n return true;\r\n case DestinationTransformationType.MemberOptions: {\r\n let result = transformation.memberConfigurationOptionsFunc(options);\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n } else if (!options.sourceObject) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n case DestinationTransformationType.SourceMemberOptions: {\r\n let result = transformation.sourceMemberConfigurationOptionsFunc(options);\r\n if (typeof result !== 'undefined') {\r\n options.intermediatePropertyValue = result;\r\n } else if (!options.sourceObject) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n default:\r\n // this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation.transformationType}`);\r\n return false;\r\n }\r\n }\r\n\r\n private createMappingObjectForGivenKeys(srcKeyOrType: string | (new () => any), dstKeyOrType: string | (new () => any)): IMapping {\r\n var mapping: IMapping = {\r\n sourceKey: super.getKey(srcKeyOrType),\r\n destinationKey: super.getKey(dstKeyOrType),\r\n forAllMemberMappings: new Array<(destinationObject: any, destinationPropertyName: string, value: any) => void>(),\r\n properties: [],\r\n typeConverterFunction: undefined,\r\n mapItemFunction: (m: IMapping, srcObj: any, dstObj: any): any => this.mapItem(m, srcObj, dstObj),\r\n sourceTypeClass: (typeof srcKeyOrType === 'string' ? undefined : srcKeyOrType),\r\n destinationTypeClass: (typeof dstKeyOrType === 'string' ? undefined : dstKeyOrType),\r\n profile: undefined,\r\n async: false\r\n };\r\n this._mappings[mapping.sourceKey + mapping.destinationKey] = mapping;\r\n return mapping;\r\n }\r\n\r\n private createMapGetFluentApiFunctions(mapping: IMapping): IFluentFunc {\r\n // create a fluent interface / method chaining (e.g. automapper.createMap().forMember().forMember() ...)\r\n var fluentFunc: IFluentFunc = {\r\n forMember: (prop: string, valFunc: forMemberValueOrFunction): IFluentFunc =>\r\n this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: valFunc, sourceMapping: false, fluentFunctions: fluentFunc }),\r\n forSourceMember: (prop: string, cfgFunc: ((opts: ISMCO) => any) | ((opts: ISMCO, cb: IMC) => void)): IFluentFunc =>\r\n this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: cfgFunc, sourceMapping: true, fluentFunctions: fluentFunc }),\r\n forAllMembers: (func: (dstObj: any, dstProp: string, value: any) => void): IFluentFunc =>\r\n this.createMapForAllMembers(mapping, fluentFunc, func),\r\n ignoreAllNonExisting: (): IFluentFunc => this.createMapIgnoreAllNonExisting(mapping, fluentFunc),\r\n convertToType: (type: new () => any): IFluentFunc => this.createMapConvertToType(mapping, fluentFunc, type),\r\n convertUsing: (tcClassOrFunc: convertUsingClassOrInstanceOrFunction): void =>\r\n this.createMapConvertUsing(mapping, tcClassOrFunc),\r\n withProfile: (profile: string): void => this.createMapWithProfile(mapping, profile)\r\n };\r\n\r\n return fluentFunc;\r\n }\r\n\r\n private createMapForMember(parameters: ICreateMapForMemberParameters): IFluentFunc {\r\n var { mapping, propertyName, transformation, sourceMapping, fluentFunctions } = parameters;\r\n\r\n // extract source/destination property names\r\n var metadata = AutoMapperHelper.getMappingMetadataFromTransformationFunction(propertyName, transformation, sourceMapping);\r\n this.validateForMemberParameters(metadata);\r\n\r\n var { source, destination } = metadata;\r\n\r\n // create property (regardless of current existance)\r\n var property = this.createSourceProperty(metadata, null);\r\n\r\n // merge with existing property or add property\r\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\r\n mapping.properties.push(property);\r\n }\r\n\r\n if (metadata.async) {\r\n this._asyncMapper.createMapForMember(mapping, this.findProperty(property.name, mapping.properties));\r\n }\r\n\r\n return fluentFunctions;\r\n }\r\n\r\n private validateForMemberParameters(metadata: IMemberMappingMetaData): void {\r\n if (!metadata.sourceMapping) {\r\n return;\r\n }\r\n\r\n // validate forSourceMember parameters\r\n if (metadata.transformation.transformationType === DestinationTransformationType.Constant) {\r\n throw new Error('Configuration of forSourceMember has to be a function with one (sync) or two (async) options parameters.');\r\n }\r\n }\r\n\r\n private createSourceProperty(metadata: IMemberMappingMetaData, parent: ISourceProperty): ISourceProperty {\r\n var level = !parent ? 0 : parent.level + 1;\r\n var sourceNameParts = metadata.source.split('.');\r\n\r\n var source = {\r\n name: sourceNameParts[level],\r\n sourcePropertyName: metadata.source,\r\n destinationPropertyName: metadata.destination,\r\n parent: parent,\r\n level: level,\r\n children: [],\r\n destination: null\r\n };\r\n\r\n if ((level + 1) < sourceNameParts.length) {\r\n // recursively add child source properties ...\r\n var child = this.createSourceProperty(metadata, source);\r\n if (child) { // TODO should not be necessary, test thoroughly!\r\n source.children.push(child);\r\n }\r\n source.destination = null;\r\n } else {\r\n // ... or (!) add destination\r\n source.destination = this.createDestinationProperty(metadata, null);\r\n }\r\n return source;\r\n }\r\n\r\n private createDestinationProperty(metadata: IMemberMappingMetaData, parent: IDestinationProperty): IDestinationProperty {\r\n var level = !parent ? 0 : parent.level + 1;\r\n var destinationNameParts = metadata.destination.split('.');\r\n\r\n var destination = {\r\n name: destinationNameParts[level],\r\n sourcePropertyName: metadata.source,\r\n destinationPropertyName: metadata.destination,\r\n parent: parent,\r\n level: level,\r\n child: null,\r\n transformations: [],\r\n conditionFunction: null,\r\n ignore: false,\r\n sourceMapping: false\r\n };\r\n\r\n if ((level + 1) < destinationNameParts.length) {\r\n // recursively add child destination properties\r\n destination.child = this.createDestinationProperty(metadata, destination);\r\n } else {\r\n // add/merge properties\r\n destination.sourceMapping = metadata.sourceMapping;\r\n destination.conditionFunction = metadata.condition;\r\n destination.ignore = metadata.ignore;\r\n destination.transformations.push(metadata.transformation);\r\n }\r\n\r\n return destination;\r\n }\r\n\r\n private mergeSourceProperty(property: ISourceProperty, existingProperties: ISourceProperty[], sourceMapping: boolean): boolean {\r\n // find source property\r\n var existing = sourceMapping\r\n ? this.findProperty(property.name, existingProperties)\r\n : this.matchSourcePropertyByDestination(property, existingProperties);\r\n\r\n if (!existing) {\r\n return false;\r\n }\r\n\r\n if (property.destination) { // new source is not (further) nested.\r\n if (existing.children.length > 0) {\r\n let existingDestination = this.getDestinationProperty(existing.destinationPropertyName, existing);\r\n\r\n // existing is (further) nested => rebase and/or merge\r\n if (this.handleMapFromProperties(property, existing)) {\r\n // merge and rebase existing destination to current source level\r\n if (!this.mergeDestinationProperty(property.destination, existingDestination)) {\r\n return false;\r\n }\r\n\r\n existing.destination = existingDestination;\r\n existing.children = [];\r\n return true;\r\n }\r\n\r\n // merge property.destination with existing mapFrom() destination (don't care about nesting depth here)\r\n return this.mergeDestinationProperty(property.destination, existingDestination);\r\n }\r\n\r\n // both are at same level => simple merge.\r\n if (!this.mergeDestinationProperty(property.destination, existing.destination)) {\r\n return false;\r\n }\r\n\r\n this.handleMapFromProperties(property, existing);\r\n return true;\r\n }\r\n\r\n // new source is (further) nested (has children).\r\n if (existing.children.length > 0) {\r\n // both have further nesting, delegate merging child(ren) by recursively calling this function.\r\n for (let child of property.children) {\r\n if (!this.mergeSourceProperty(child, existing.children, sourceMapping)) {\r\n return false;\r\n }\r\n }\r\n\r\n if (property.destinationPropertyName !== property.sourcePropertyName) {\r\n // this is a mapFrom() registration. It is handled using the nested source properties,\r\n // we only are responsible for syncing the name properties.\r\n existing.name = property.name;\r\n existing.sourcePropertyName = property.sourcePropertyName;\r\n }\r\n return true;\r\n }\r\n\r\n // existing is not (further) nested. this is always a mapFrom() situation.\r\n // if (property.sourcePropertyName !== existing.sourcePropertyName) {\r\n let newDestination = this.getDestinationProperty(existing.destinationPropertyName, property);\r\n\r\n if (property.destinationPropertyName !== property.sourcePropertyName) {\r\n // this is a mapFrom() registration. In that case:\r\n // 1) merge destinations, 2) add source child and 3) move destination to (youngest) child\r\n // NOTE special mergeDestinationProperty call => we use the new destination as 'target',\r\n // because that will save us trouble overwriting ;)...\r\n if (!this.mergeDestinationProperty(existing.destination, newDestination, true)) {\r\n return false;\r\n }\r\n\r\n existing.children = property.children;\r\n existing.name = property.name;\r\n existing.sourcePropertyName = property.sourcePropertyName;\r\n existing.destination = null;\r\n // TODO Should never be necessary (test): existing.destinationPropertyName = property.destinationPropertyName;\r\n return true;\r\n }\r\n\r\n // ... nope, it is a destination which has previously been registered using mapFrom. just merge\r\n return this.mergeDestinationProperty(newDestination, existing.destination);\r\n // }\r\n }\r\n\r\n /**\r\n * handle property naming when the current property to merge is a mapFrom property\r\n */\r\n private handleMapFromProperties(property: TProperty, existingProperty: TProperty): boolean {\r\n if (property.destinationPropertyName === property.sourcePropertyName ||\r\n property.sourcePropertyName === existingProperty.sourcePropertyName) {\r\n return false;\r\n }\r\n\r\n // only overwrite name when a mapFrom situation applies\r\n existingProperty.name = property.name;\r\n existingProperty.sourcePropertyName = property.sourcePropertyName;\r\n // TODO Should never be necessary (test) => existingProperty.destinationPropertyName = property.destinationPropertyName;\r\n\r\n return true;\r\n }\r\n\r\n private getDestinationProperty(destinationPropertyName: string, existingSource: ISourceProperty): IDestinationProperty {\r\n if (existingSource.destination) {\r\n return existingSource.destination;\r\n }\r\n\r\n for (let child of existingSource.children) {\r\n var destination = this.getDestinationProperty(destinationPropertyName, child);\r\n if (destination) {\r\n return destination;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private mergeDestinationProperty(destination: IDestinationProperty, existingDestination: IDestinationProperty, swapTransformations: boolean = false): boolean {\r\n if (destination.child) { // destination is (further) nested\r\n if (existingDestination.child) {\r\n // both have further nesting, delegate merging children by recursively calling this function.\r\n if (!this.mergeDestinationProperty(destination.child, existingDestination.child, swapTransformations)) {\r\n return false;\r\n }\r\n\r\n this.handleMapFromProperties(destination, existingDestination);\r\n return true;\r\n }\r\n\r\n // the current destination is not (further) nested. a destination property registration has one of both:\r\n // a) children or b) transformations. returning false will cause creating a duplicate source property entry instead.\r\n return false;\r\n }\r\n\r\n if (existingDestination.sourceMapping !== destination.sourceMapping &&\r\n existingDestination.sourcePropertyName !== destination.sourcePropertyName) {\r\n // unable to perform mapFrom() on a property which is being registered using forSourceMember.\r\n return false; // TODO: Unpredictable? Idea: throw new Error('Unable to perform mapFrom() on a property which is being registered using forSourceMember.');\r\n }\r\n\r\n // merge destination properties\r\n if (destination.sourceMapping) {\r\n // only set source mapping when not yet set to true, once source mapped is source mapped forever.\r\n // TODO Verify edge cases!\r\n existingDestination.sourceMapping = destination.sourceMapping;\r\n }\r\n\r\n if (destination.ignore) {\r\n // only set ignore when not yet set, once ignored is ignored forever.\r\n existingDestination.ignore = destination.ignore;\r\n }\r\n\r\n if (destination.conditionFunction) {\r\n // overwrite condition function by the latest one specified.\r\n existingDestination.conditionFunction = destination.conditionFunction;\r\n }\r\n\r\n let transformations: IDestinationTransformation[] = [];\r\n if (swapTransformations) {\r\n for (let transformation of destination.transformations) {\r\n transformations.push(transformation);\r\n }\r\n for (let transformation of existingDestination.transformations) {\r\n transformations.push(transformation);\r\n }\r\n } else {\r\n for (let transformation of existingDestination.transformations) {\r\n transformations.push(transformation);\r\n }\r\n for (let transformation of destination.transformations) {\r\n transformations.push(transformation);\r\n }\r\n }\r\n existingDestination.transformations = transformations;\r\n\r\n this.handleMapFromProperties(destination, existingDestination);\r\n return true;\r\n }\r\n\r\n private matchSourcePropertyByDestination(source: ISourceProperty, properties: ISourceProperty[]): ISourceProperty {\r\n if (!properties) {\r\n return null;\r\n }\r\n\r\n for (let property of properties) {\r\n if (property.destinationPropertyName === source.destinationPropertyName) {\r\n return property;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n private findProperty(name: string, properties: TProperty[]): TProperty {\r\n if (!properties) {\r\n return null;\r\n }\r\n\r\n for (var property of properties) {\r\n if (property.name === name) {\r\n return property;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n }\r\n}\r\n\r\n// Add AutoMapper to the application's global scope. Of course, you could still use Core.AutoMapper.getInstance() as well.\r\nvar automapper: AutoMapperJs.AutoMapper = ((app: any): AutoMapperJs.AutoMapper => {\r\n app.automapper = AutoMapperJs.AutoMapper.getInstance();\r\n return app.automapper;\r\n})(this);\r\n"]} \ No newline at end of file diff --git a/src/js/AutoMapperHelper.js.map b/src/js/AutoMapperHelper.js.map index 2fcd38c..451f931 100644 --- a/src/js/AutoMapperHelper.js.map +++ b/src/js/AutoMapperHelper.js.map @@ -1 +1 @@ -{"version":3,"sources":["AutoMapperHelper.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,IAAO,YAAY,CA8PlB;AA9PD,WAAO,YAAY;IACf,YAAY,CAAC;IAEb;;OAEG;IACH;QAAA;QAuPA,CAAC;QAtPiB,6BAAY,GAA1B,UAA2B,SAAwB;YAC/C,EAAE,CAAC,CAAC,SAAS,IAAU,SAAU,CAAC,IAAI,CAAC,CAAC,CAAC;gBACrC,MAAM,CAAO,SAAU,CAAC,IAAI,CAAC;YACjC,CAAC;YACD,qDAAqD;YACrD,EAAE,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;gBACrC,IAAI,SAAS,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;gBACrC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;oBACZ,6DAA6D;oBAC7D,IAAI,UAAU,GAAG,SAAS,CAAC,KAAK,CAA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CAAC,CAAC;gBAC1B,mBAAmB,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,GAAG,iBAAiB,CAAC,CAAC;YAC1E,CAAC;YAED,MAAM,CAAC,mBAAmB,CAAC;QAC/B,CAAC;QAEc,yCAAwB,GAAvC,UAAwC,IAAc,EAAE,cAAsB;YAC1E,oHAAoH;YACpH,wHAAwH;YACxH,uHAAuH;YACvH,iBAAiB;YACjB,IAAI,YAAY,GAAQ,EAAE,CAAC;YAC3B,YAAY,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;YAElC,IAAI,SAAyC,CAAC;YAE9C,wHAAwH;YACxH,IAAM,iBAAiB,GAAgC;gBACnD,MAAM,EAAE;oBACJ,aAAa;gBACjB,CAAC;gBACD,SAAS,EAAE,UAAC,SAA2C;oBACnD,SAAS,GAAG,SAAS,CAAC;gBAC1B,CAAC;gBACD,OAAO,EAAE,UAAC,kBAA0B;oBAChC,aAAa;gBACjB,CAAC;gBACD,YAAY,EAAE,YAAY;gBAC1B,kBAAkB,EAAE,cAAc;gBAClC,yBAAyB,EAAE,EAAE;aAChC,CAAC;YAEF,IAAI,CAAC;gBACD,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC5B,CAAC;YAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACX,4BAA4B;YAChC,CAAC;YAED,MAAM,CAAC,SAAS,CAAC;QACrB,CAAC;QACL,uBAAC;IAAD,CAvPA,AAuPC,IAAA;IAvPY,6BAAgB,mBAuP5B,CAAA;AACL,CAAC,EA9PM,YAAY,KAAZ,YAAY,QA8PlB","file":"AutoMapperHelper.js","sourcesContent":["/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n /**\r\n * AutoMapper helper functions\r\n */\r\n export class AutoMapperHelper {\r\n public static getClassName(classType: new () => any): string {\r\n if (classType && (classType).name) {\r\n return (classType).name;\r\n }\r\n // source: http://stackoverflow.com/a/13914278/702357\r\n if (classType && classType.constructor) {\r\n let className = classType.toString();\r\n if (className) {\r\n // classType.toString() is \"function classType (...) { ... }\"\r\n let matchParts = className.match(/function\\s*(\\w+)/);\r\n if (matchParts && matchParts.length === 2) {\r\n return matchParts[1];\r\n }\r\n }\r\n\r\n // for browsers which have name property in the constructor\r\n // of the object, such as chrome\r\n if ((classType.constructor).name) {\r\n return (classType.constructor).name;\r\n }\r\n\r\n if (classType.constructor.toString()) {\r\n let str = classType.constructor.toString();\r\n\r\n let regExpMatchArray: RegExpMatchArray;\r\n if (str.charAt(0) === '[') {\r\n // executed if the return of object.constructor.toString() is \"[object objectClass]\"\r\n regExpMatchArray = str.match(/\\[\\w+\\s*(\\w+)\\]/);\r\n } else {\r\n // executed if the return of object.constructor.toString() is \"function objectClass () {}\"\r\n // (IE and Firefox)\r\n regExpMatchArray = str.match(/function\\s*(\\w+)/);\r\n }\r\n\r\n if (regExpMatchArray && regExpMatchArray.length === 2) {\r\n return regExpMatchArray[1];\r\n }\r\n }\r\n }\r\n\r\n throw new Error(`Unable to extract class name from type '${classType}'`);\r\n }\r\n\r\n public static getFunctionParameters(functionStr: string): Array {\r\n const stripComments = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg;\r\n const argumentNames = /([^\\s,]+)/g;\r\n\r\n var functionString = functionStr.replace(stripComments, '');\r\n var functionParameterNames = functionString.slice(functionString.indexOf('(') + 1, functionString.indexOf(')')).match(argumentNames);\r\n if (functionParameterNames === null) {\r\n functionParameterNames = new Array();\r\n }\r\n return functionParameterNames;\r\n }\r\n\r\n public static handleCurrying(func: Function, args: IArguments, closure: any): any {\r\n const argumentsStillToCome = func.length - args.length;\r\n\r\n // saved accumulator array\r\n // NOTE BL this does not deep copy array objects, only the array itself; should side effects occur, please report (or refactor).\r\n var argumentsCopy = Array.prototype.slice.apply(args);\r\n\r\n function accumulator(moreArgs: IArguments, alreadyProvidedArgs: Array, stillToCome: number): Function {\r\n var previousAlreadyProvidedArgs = alreadyProvidedArgs.slice(0); // to reset\r\n var previousStillToCome = stillToCome; // to reset\r\n\r\n for (let i = 0; i < moreArgs.length; i++ , stillToCome--) {\r\n alreadyProvidedArgs[alreadyProvidedArgs.length] = moreArgs[i];\r\n }\r\n\r\n if (stillToCome - moreArgs.length <= 0) {\r\n var functionCallResult = func.apply(closure, alreadyProvidedArgs);\r\n\r\n // reset vars, so curried function can be applied to new params.\r\n alreadyProvidedArgs = previousAlreadyProvidedArgs;\r\n stillToCome = previousStillToCome;\r\n\r\n return functionCallResult;\r\n } else {\r\n return function (): Function {\r\n // arguments are params, so closure bussiness is avoided.\r\n return accumulator(arguments, alreadyProvidedArgs.slice(0), stillToCome);\r\n };\r\n }\r\n }\r\n\r\n return accumulator(([]), argumentsCopy, argumentsStillToCome);\r\n }\r\n\r\n public static getMappingMetadataFromTransformationFunction(destination: string, func: any, sourceMapping: boolean): IMemberMappingMetaData {\r\n if (typeof func !== 'function') {\r\n return {\r\n destination: destination,\r\n source: destination,\r\n transformation: AutoMapperHelper.getDestinationTransformation(func, false, sourceMapping, false),\r\n sourceMapping: sourceMapping,\r\n condition: null,\r\n ignore: false,\r\n async: false\r\n };\r\n }\r\n var functionStr = func.toString();\r\n var parameterNames = AutoMapperHelper.getFunctionParameters(functionStr);\r\n\r\n var optsParamName = parameterNames.length >= 1 ? parameterNames[0] : '';\r\n\r\n var source = sourceMapping\r\n ? destination\r\n : AutoMapperHelper.getMapFromString(functionStr, destination, optsParamName);\r\n\r\n var metadata: IMemberMappingMetaData = {\r\n destination: destination,\r\n source: source,\r\n transformation: AutoMapperHelper.getDestinationTransformation(func, true, sourceMapping, parameterNames.length === 2),\r\n sourceMapping: sourceMapping,\r\n condition: null,\r\n ignore: AutoMapperHelper.getIgnoreFromString(functionStr, destination),\r\n async: parameterNames.length === 2\r\n };\r\n\r\n // calling the member options function when used asynchronous would be too 'dangerous'.\r\n if (!metadata.async && AutoMapperHelper.getFunctionCallIndex(functionStr, 'condition', optsParamName) >= 0) {\r\n metadata.condition = AutoMapperHelper.getConditionFromFunction(func, source);\r\n }\r\n\r\n return metadata;\r\n }\r\n\r\n private static getDestinationTransformation(func: any, isFunction: boolean, sourceMapping: boolean, async: boolean): IDestinationTransformation {\r\n if (!isFunction) {\r\n return {\r\n transformationType: DestinationTransformationType.Constant,\r\n constant: func\r\n };\r\n }\r\n\r\n var transformation: IDestinationTransformation;\r\n if (sourceMapping) {\r\n if (async) {\r\n transformation = {\r\n transformationType: DestinationTransformationType.AsyncSourceMemberOptions,\r\n asyncSourceMemberConfigurationOptionsFunc: func\r\n };\r\n } else {\r\n transformation = {\r\n transformationType: DestinationTransformationType.SourceMemberOptions,\r\n sourceMemberConfigurationOptionsFunc: func\r\n };\r\n }\r\n } else {\r\n if (async) {\r\n transformation = {\r\n transformationType: DestinationTransformationType.AsyncMemberOptions,\r\n asyncMemberConfigurationOptionsFunc: func\r\n };\r\n } else {\r\n transformation = {\r\n transformationType: DestinationTransformationType.MemberOptions,\r\n memberConfigurationOptionsFunc: func\r\n };\r\n }\r\n }\r\n return transformation;\r\n }\r\n\r\n private static getIgnoreFromString(functionString: string, optionsParameterName: string): boolean {\r\n var indexOfIgnore = AutoMapperHelper.getFunctionCallIndex(functionString, 'ignore', optionsParameterName);\r\n if (indexOfIgnore < 0) {\r\n return false;\r\n }\r\n\r\n var indexOfMapFromStart = functionString.indexOf('(', indexOfIgnore) + 1;\r\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\r\n\r\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\r\n return false;\r\n }\r\n\r\n var ignoreString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/\\r/g, '').replace(/\\n/g, '').trim();\r\n return ignoreString === null || ignoreString === ''\r\n ? true // .ignore()\r\n : false; // .ignore( -> unexpected content)\r\n }\r\n\r\n private static getMapFromString(functionString: string, defaultValue: string, optionsParameterName: string): string {\r\n var indexOfMapFrom = AutoMapperHelper.getFunctionCallIndex(functionString, 'mapFrom', optionsParameterName);\r\n if (indexOfMapFrom < 0) {\r\n return defaultValue;\r\n }\r\n\r\n var indexOfMapFromStart = functionString.indexOf('(', indexOfMapFrom) + 1;\r\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\r\n\r\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\r\n return defaultValue;\r\n }\r\n\r\n var mapFromString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/'/g, '').replace(/\"/g, '').trim();\r\n return mapFromString === null || mapFromString === ''\r\n ? defaultValue\r\n : mapFromString;\r\n }\r\n\r\n private static getFunctionCallIndex(functionString: string, functionToLookFor: string, optionsParameterName: string): number {\r\n var indexOfFunctionCall = functionString.indexOf(optionsParameterName + '.' + functionToLookFor);\r\n if (indexOfFunctionCall < 0) {\r\n indexOfFunctionCall = functionString.indexOf('.' + functionToLookFor);\r\n }\r\n\r\n return indexOfFunctionCall;\r\n }\r\n\r\n private static getConditionFromFunction(func: Function, sourceProperty: string): ((sourceObject: any) => boolean) {\r\n // Since we are calling the valueOrFunction function to determine whether to ignore or map from another property, we\r\n // want to prevent the call to be error prone when the end user uses the '(opts)=> opts.sourceObject.sourcePropertyName'\r\n // syntax. We don't actually have a source object when creating a mapping; therefore, we 'stub' a source object for the\r\n // function call.\r\n var sourceObject: any = {};\r\n sourceObject[sourceProperty] = {};\r\n\r\n var condition: (sourceObject: any) => boolean;\r\n\r\n // calling the function will result in calling our stubbed ignore() and mapFrom() functions if used inside the function.\r\n const configFuncOptions: IMemberConfigurationOptions = {\r\n ignore: (): void => {\r\n // do nothing\r\n },\r\n condition: (predicate: ((sourceObject: any) => boolean)): void => {\r\n condition = predicate;\r\n },\r\n mapFrom: (sourcePropertyName: string): void => {\r\n // do nothing\r\n },\r\n sourceObject: sourceObject,\r\n sourcePropertyName: sourceProperty,\r\n intermediatePropertyValue: {}\r\n };\r\n\r\n try {\r\n func(configFuncOptions);\r\n } catch (exc) {\r\n // do not handle by default.\r\n }\r\n\r\n return condition;\r\n }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kBAAkB,EAAE,cAAc;gBAClC,yBAAyB,EAAE,EAAE;aAChC,CAAC;YAEF,IAAI,CAAC;gBACD,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC5B,CAAC;YAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACX,4BAA4B;YAChC,CAAC;YAED,MAAM,CAAC,SAAS,CAAC;QACrB,CAAC;QACL,uBAAC;IAAD,CAxPA,AAwPC,IAAA;IAxPY,6BAAgB,mBAwP5B,CAAA;AACL,CAAC,EA/PM,YAAY,KAAZ,YAAY,QA+PlB","file":"AutoMapperHelper.js","sourcesContent":["/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n /**\r\n * AutoMapper helper functions\r\n */\r\n export class AutoMapperHelper {\r\n public static getClassName(classType: new () => any): string {\r\n if (classType && (classType).name) {\r\n return (classType).name;\r\n }\r\n // source: http://stackoverflow.com/a/13914278/702357\r\n if (classType && classType.constructor) {\r\n let className = classType.toString();\r\n if (className) {\r\n // classType.toString() is \"function classType (...) { ... }\"\r\n let matchParts = className.match(/function\\s*(\\w+)/);\r\n if (matchParts && matchParts.length === 2) {\r\n return matchParts[1];\r\n }\r\n }\r\n\r\n // for browsers which have name property in the constructor\r\n // of the object, such as chrome\r\n if ((classType.constructor).name) {\r\n return (classType.constructor).name;\r\n }\r\n\r\n if (classType.constructor.toString()) {\r\n let str = classType.constructor.toString();\r\n\r\n let regExpMatchArray: RegExpMatchArray;\r\n if (str.charAt(0) === '[') {\r\n // executed if the return of object.constructor.toString() is \"[object objectClass]\"\r\n regExpMatchArray = str.match(/\\[\\w+\\s*(\\w+)\\]/);\r\n } else {\r\n // executed if the return of object.constructor.toString() is \"function objectClass () {}\"\r\n // (IE and Firefox)\r\n regExpMatchArray = str.match(/function\\s*(\\w+)/);\r\n }\r\n\r\n if (regExpMatchArray && regExpMatchArray.length === 2) {\r\n return regExpMatchArray[1];\r\n }\r\n }\r\n }\r\n\r\n throw new Error(`Unable to extract class name from type '${classType}'`);\r\n }\r\n\r\n public static getFunctionParameters(functionStr: string): Array {\r\n const stripComments = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg;\r\n const argumentNames = /([^\\s,]+)/g;\r\n\r\n var functionString = functionStr.replace(stripComments, '');\r\n\r\n var functionParameterNames = functionString.slice(functionString.indexOf('(') + 1, functionString.indexOf(')')).match(argumentNames);\r\n if (functionParameterNames === null) {\r\n functionParameterNames = new Array();\r\n }\r\n return functionParameterNames;\r\n }\r\n\r\n public static handleCurrying(func: Function, args: IArguments, closure: any): any {\r\n const argumentsStillToCome = func.length - args.length;\r\n\r\n // saved accumulator array\r\n // NOTE BL this does not deep copy array objects, only the array itself; should side effects occur, please report (or refactor).\r\n var argumentsCopy = Array.prototype.slice.apply(args);\r\n\r\n function accumulator(moreArgs: IArguments, alreadyProvidedArgs: Array, stillToCome: number): Function {\r\n var previousAlreadyProvidedArgs = alreadyProvidedArgs.slice(0); // to reset\r\n var previousStillToCome = stillToCome; // to reset\r\n\r\n for (let i = 0; i < moreArgs.length; i++ , stillToCome--) {\r\n alreadyProvidedArgs[alreadyProvidedArgs.length] = moreArgs[i];\r\n }\r\n\r\n if (stillToCome - moreArgs.length <= 0) {\r\n var functionCallResult = func.apply(closure, alreadyProvidedArgs);\r\n\r\n // reset vars, so curried function can be applied to new params.\r\n alreadyProvidedArgs = previousAlreadyProvidedArgs;\r\n stillToCome = previousStillToCome;\r\n\r\n return functionCallResult;\r\n } else {\r\n return function (): Function {\r\n // arguments are params, so closure bussiness is avoided.\r\n return accumulator(arguments, alreadyProvidedArgs.slice(0), stillToCome);\r\n };\r\n }\r\n }\r\n\r\n return accumulator(([]), argumentsCopy, argumentsStillToCome);\r\n }\r\n\r\n public static getMappingMetadataFromTransformationFunction(destination: string, func: any, sourceMapping: boolean): IMemberMappingMetaData {\r\n if (typeof func !== 'function') {\r\n return {\r\n destination: destination,\r\n source: destination,\r\n transformation: AutoMapperHelper.getDestinationTransformation(func, false, sourceMapping, false),\r\n sourceMapping: sourceMapping,\r\n condition: null,\r\n ignore: false,\r\n async: false\r\n };\r\n }\r\n var functionStr = func.toString();\r\n var parameterNames = AutoMapperHelper.getFunctionParameters(functionStr);\r\n\r\n var optsParamName = parameterNames.length >= 1 ? parameterNames[0] : '';\r\n\r\n var source = sourceMapping\r\n ? destination\r\n : AutoMapperHelper.getMapFromString(functionStr, destination, optsParamName);\r\n\r\n var metadata: IMemberMappingMetaData = {\r\n destination: destination,\r\n source: source,\r\n transformation: AutoMapperHelper.getDestinationTransformation(func, true, sourceMapping, parameterNames.length === 2),\r\n sourceMapping: sourceMapping,\r\n condition: null,\r\n ignore: AutoMapperHelper.getIgnoreFromString(functionStr, destination),\r\n async: parameterNames.length === 2\r\n };\r\n\r\n // calling the member options function when used asynchronous would be too 'dangerous'.\r\n if (!metadata.async && AutoMapperHelper.getFunctionCallIndex(functionStr, 'condition', optsParamName) >= 0) {\r\n metadata.condition = AutoMapperHelper.getConditionFromFunction(func, source);\r\n }\r\n\r\n return metadata;\r\n }\r\n\r\n private static getDestinationTransformation(func: any, isFunction: boolean, sourceMapping: boolean, async: boolean): IDestinationTransformation {\r\n if (!isFunction) {\r\n return {\r\n transformationType: DestinationTransformationType.Constant,\r\n constant: func\r\n };\r\n }\r\n\r\n var transformation: IDestinationTransformation;\r\n if (sourceMapping) {\r\n if (async) {\r\n transformation = {\r\n transformationType: DestinationTransformationType.AsyncSourceMemberOptions,\r\n asyncSourceMemberConfigurationOptionsFunc: func\r\n };\r\n } else {\r\n transformation = {\r\n transformationType: DestinationTransformationType.SourceMemberOptions,\r\n sourceMemberConfigurationOptionsFunc: func\r\n };\r\n }\r\n } else {\r\n if (async) {\r\n transformation = {\r\n transformationType: DestinationTransformationType.AsyncMemberOptions,\r\n asyncMemberConfigurationOptionsFunc: func\r\n };\r\n } else {\r\n transformation = {\r\n transformationType: DestinationTransformationType.MemberOptions,\r\n memberConfigurationOptionsFunc: func\r\n };\r\n }\r\n }\r\n return transformation;\r\n }\r\n\r\n private static getIgnoreFromString(functionString: string, optionsParameterName: string): boolean {\r\n var indexOfIgnore = AutoMapperHelper.getFunctionCallIndex(functionString, 'ignore', optionsParameterName);\r\n if (indexOfIgnore < 0) {\r\n return false;\r\n }\r\n\r\n var indexOfMapFromStart = functionString.indexOf('(', indexOfIgnore) + 1;\r\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\r\n\r\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\r\n return false;\r\n }\r\n\r\n var ignoreString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/\\r/g, '').replace(/\\n/g, '').trim();\r\n return ignoreString === null || ignoreString === ''\r\n ? true // .ignore()\r\n : false; // .ignore( -> unexpected content)\r\n }\r\n\r\n private static getMapFromString(functionString: string, defaultValue: string, optionsParameterName: string): string {\r\n var indexOfMapFrom = AutoMapperHelper.getFunctionCallIndex(functionString, 'mapFrom', optionsParameterName);\r\n if (indexOfMapFrom < 0) {\r\n return defaultValue;\r\n }\r\n\r\n var indexOfMapFromStart = functionString.indexOf('(', indexOfMapFrom) + 1;\r\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\r\n\r\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\r\n return defaultValue;\r\n }\r\n\r\n var mapFromString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/'/g, '').replace(/\"/g, '').trim();\r\n return mapFromString === null || mapFromString === ''\r\n ? defaultValue\r\n : mapFromString;\r\n }\r\n\r\n private static getFunctionCallIndex(functionString: string, functionToLookFor: string, optionsParameterName: string): number {\r\n var indexOfFunctionCall = functionString.indexOf(optionsParameterName + '.' + functionToLookFor);\r\n if (indexOfFunctionCall < 0) {\r\n indexOfFunctionCall = functionString.indexOf('.' + functionToLookFor);\r\n }\r\n\r\n return indexOfFunctionCall;\r\n }\r\n\r\n private static getConditionFromFunction(func: Function, sourceProperty: string): ((sourceObject: any) => boolean) {\r\n // Since we are calling the valueOrFunction function to determine whether to ignore or map from another property, we\r\n // want to prevent the call to be error prone when the end user uses the '(opts)=> opts.sourceObject.sourcePropertyName'\r\n // syntax. We don't actually have a source object when creating a mapping; therefore, we 'stub' a source object for the\r\n // function call.\r\n var sourceObject: any = {};\r\n sourceObject[sourceProperty] = {};\r\n\r\n var condition: (sourceObject: any) => boolean;\r\n\r\n // calling the function will result in calling our stubbed ignore() and mapFrom() functions if used inside the function.\r\n const configFuncOptions: IMemberConfigurationOptions = {\r\n ignore: (): void => {\r\n // do nothing\r\n },\r\n condition: (predicate: ((sourceObject: any) => boolean)): void => {\r\n condition = predicate;\r\n },\r\n mapFrom: (sourcePropertyName: string): void => {\r\n // do nothing\r\n },\r\n sourceObject: sourceObject,\r\n sourcePropertyName: sourceProperty,\r\n intermediatePropertyValue: {}\r\n };\r\n\r\n try {\r\n func(configFuncOptions);\r\n } catch (exc) {\r\n // do not handle by default.\r\n }\r\n\r\n return condition;\r\n }\r\n }\r\n}"]} \ No newline at end of file diff --git a/src/js/AutoMapperValidator.js.map b/src/js/AutoMapperValidator.js.map index b893f35..da81299 100644 --- a/src/js/AutoMapperValidator.js.map +++ b/src/js/AutoMapperValidator.js.map @@ -1 +1 @@ -{"version":3,"sources":["AutoMapperValidator.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,4CAA4C;AAC5C,IAAO,YAAY,CA4LlB;AA5LD,WAAO,YAAY;IACf,YAAY,CAAC;IAEb;;OAEG;IACH;QAAA;QAqLA,CAAC;QApLG;;;;;;;;WAQG;QACW,8CAA0B,GAAxC,UAAyC,QAAa,EAAE,UAAmB;YACvE,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC;gBACvB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAChC,QAAQ,CAAC;gBACb,CAAC;gBAED,mBAAmB,CAAC,0BAA0B,CAA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AAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;oBAC9E,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;wBACd,MAAM,CAAC,WAAW,CAAC;oBACvB,CAAC;iBACJ;YACL,CAAC;YAED,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QAEL,0BAAC;IAAD,CArLA,AAqLC,IAAA;IArLY,gCAAmB,sBAqL/B,CAAA;AACL,CAAC,EA5LM,YAAY,KAAZ,YAAY,QA4LlB","file":"AutoMapperValidator.js","sourcesContent":["/// \r\n/// \r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n /**\r\n * AutoMapper configuration validator.\r\n */\r\n export class AutoMapperValidator {\r\n /**\r\n * Validates mapping configuration by dry-running. Since JS does not\r\n * fully support typing, it only checks if properties match on both\r\n * sides. The function needs IMapping.sourceTypeClass and\r\n * IMapping.destinationTypeClass to function.\r\n * @param {boolean} strictMode Whether or not to fail when properties\r\n * sourceTypeClass or destinationTypeClass\r\n * are unavailable.\r\n */\r\n public static assertConfigurationIsValid(mappings: any, strictMode: boolean): void {\r\n for (var key in mappings) {\r\n if (!mappings.hasOwnProperty(key)) {\r\n continue;\r\n }\r\n\r\n AutoMapperValidator.assertMappingConfiguration(mappings[key], strictMode);\r\n }\r\n }\r\n\r\n private static assertMappingConfiguration(mapping: IMapping, strictMode: boolean): void {\r\n var mappingKey = `${mapping.sourceKey}=>${mapping.destinationKey}`;\r\n\r\n var sourceType = mapping.sourceTypeClass;\r\n var destinationType = mapping.destinationTypeClass;\r\n\r\n var sourceClassName = sourceType ? AutoMapperHelper.getClassName(sourceType) : undefined;\r\n var destinationClassName = destinationType ? AutoMapperHelper.getClassName(destinationType) : undefined;\r\n\r\n if (!sourceType || !destinationType) {\r\n if (strictMode === false) {\r\n return;\r\n }\r\n\r\n throw new Error(`Mapping '${mappingKey}' cannot be validated, since mapping.sourceType or mapping.destinationType are unspecified.`);\r\n }\r\n\r\n var tryHandle = (errorMessage: string) => {\r\n if (errorMessage) {\r\n throw new Error(`Mapping '${mappingKey}' is invalid: ${errorMessage} (source: '${sourceClassName}', destination: '${destinationClassName}').`);\r\n }\r\n };\r\n\r\n var validatedMembers = new Array();\r\n\r\n var srcObj = new sourceType();\r\n var dstObj = new destinationType();\r\n\r\n // walk member mappings\r\n for (let property of mapping.properties) {\r\n\r\n\r\n tryHandle(AutoMapperValidator.validatePropertyMapping(property, property.name, srcObj, dstObj));\r\n validatedMembers.push(property.name);\r\n }\r\n\r\n // walk source members\r\n for (let srcMember in srcObj) {\r\n if (!srcObj.hasOwnProperty(srcMember)) {\r\n continue;\r\n }\r\n\r\n if (validatedMembers.indexOf(srcMember) >= 0) {\r\n // already validated\r\n continue;\r\n }\r\n\r\n tryHandle(AutoMapperValidator.validateProperty(srcMember, dstObj));\r\n validatedMembers.push(srcMember);\r\n }\r\n\r\n // walk destination members\r\n for (let dstMember in dstObj) {\r\n if (!dstObj.hasOwnProperty(dstMember)) {\r\n continue;\r\n }\r\n\r\n if (validatedMembers.indexOf(dstMember) >= 0) {\r\n // already validated\r\n continue;\r\n }\r\n\r\n tryHandle(`Destination member '${dstMember}' does not exist on source type`);\r\n }\r\n // /* tslint:disable */\r\n // console.error(key);\r\n // /* tslint:enable */\r\n }\r\n\r\n private static validatePropertyMapping(propertyMapping: ISourceProperty, member: any, srcObj: any, dstObj: any): string {\r\n // awkward way of locating sourceMapping ;) ...\r\n let destinationProperty = AutoMapperValidator.getDestinationProperty(propertyMapping.destinationPropertyName, propertyMapping);\r\n\r\n return destinationProperty.sourceMapping\r\n ? AutoMapperValidator.validateSourcePropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj)\r\n : AutoMapperValidator.validateDestinationPropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj);\r\n }\r\n\r\n private static validateSourcePropertyMapping(\r\n ropertyMapping: ISourceProperty,\r\n destinationProperty: IDestinationProperty,\r\n member: any,\r\n srcObj: any,\r\n dstObj: any): string {\r\n // a member for which configuration is provided, should exist.\r\n if (!srcObj.hasOwnProperty(member)) {\r\n return `Source member '${member}' is configured, but does not exist on source type`;\r\n }\r\n\r\n // an ignored source member should not exist on the destination type.\r\n if (destinationProperty.ignore) {\r\n if (dstObj.hasOwnProperty(member)) {\r\n return `Source member '${member}' is ignored, but does exist on destination type`;\r\n }\r\n return undefined;\r\n }\r\n\r\n // a mapped source member should exist on the destination type.\r\n if (!dstObj.hasOwnProperty(member)) {\r\n return `Source member '${member}' is configured to be mapped, but does not exist on destination type`;\r\n }\r\n\r\n //var dstMember = propertyMapping.destinationProperty;\r\n\r\n return undefined;\r\n }\r\n\r\n private static validateDestinationPropertyMapping(\r\n propertyMapping: ISourceProperty,\r\n destinationProperty: IDestinationProperty,\r\n member: any,\r\n srcObj: any,\r\n dstObj: any): string {\r\n // a member for which configuration is provided, should exist.\r\n if (!dstObj.hasOwnProperty(destinationProperty.name)) {\r\n return `Destination member '${destinationProperty.destinationPropertyName}' is configured, but does not exist on destination type`;\r\n }\r\n\r\n // an ignored destination member should not exist on the source type.\r\n if (destinationProperty.ignore) {\r\n if (srcObj.hasOwnProperty(member)) {\r\n return `Destination member '${member}' is ignored, but does exist on source type`;\r\n }\r\n return undefined;\r\n }\r\n\r\n // a mapped destination member should exist on the source type.\r\n if (!srcObj.hasOwnProperty(member)) {\r\n return `Destination member '${member}' is configured to be mapped, but does not exist on source type`;\r\n }\r\n\r\n //var dstMember = propertyMapping.destinationProperty;\r\n\r\n return undefined;\r\n }\r\n\r\n private static validateProperty(srcMember: any, dstObj: any): string {\r\n if (!dstObj.hasOwnProperty(srcMember)) {\r\n return `Source member '${srcMember}' is configured to be mapped, but does not exist on destination type`;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n private static getDestinationProperty(destinationPropertyName: string, existingSource: ISourceProperty): IDestinationProperty {\r\n if (existingSource.destination) {\r\n return existingSource.destination;\r\n }\r\n\r\n if (existingSource.children) {\r\n for (let child of existingSource.children) {\r\n var destination = this.getDestinationProperty(destinationPropertyName, child);\r\n if (destination) {\r\n return destination;\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n }\r\n}"]} \ No newline at end of file +{"version":3,"sources":["AutoMapperValidator.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,4CAA4C;AAC5C,IAAO,YAAY,CA4LlB;AA5LD,WAAO,YAAY;IACf,YAAY,CAAC;IAEb;;OAEG;IACH;QAAA;QAqLA,CAAC;QApLG;;;;;;;;WAQG;QACW,8CAA0B,GAAxC,UAAyC,QAAa,EAAE,UAAmB;YACvE,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC;gBACvB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAChC,QAAQ,CAAC;gBACb,CAAC;gBAED,mBAAmB,CAAC,0BAA0B,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;YAC9E,CAAC;QACL,CAAC;QAEc,8CAA0B,GAAzC,UAA0C,OAAiB,EAAE,UAAmB;YAC5E,IAAI,UAAU,GAAM,OAAO,CAAC,SAAS,UAAK,OAAO,CAAC,cAAgB,CAAC;YAEnE,IAAI,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;YACzC,IAAI,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAEnD,IAAI,eAAe,GAAG,UAAU,GAAG,aAAA,gBAAgB,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;YACzF,IAAI,oBAAoB,GAAG,eAAe,GAAG,aAAA,gBAAgB,CAAC,YAAY,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC;YAExG,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;gBAClC,EAAE,CAAC,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC;oBACvB,MAAM,CAAC;gBACX,CAAC;gBAED,MAAM,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CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACpC,MAAM,CAAC,oBAAkB,SAAS,yEAAsE,CAAC;YAC7G,CAAC;YAED,MAAM,CAAC,SAAS,CAAC;QACrB,CAAC;QAEc,0CAAsB,GAArC,UAAsC,uBAA+B,EAAE,cAA+B;YAClG,EAAE,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC7B,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC;YACtC,CAAC;YAED,EAAE,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC1B,GAAG,CAAC,CAAc,UAAuB,EAAvB,KAAA,cAAc,CAAC,QAAQ,EAAvB,cAAuB,EAAvB,IAAuB;oBAApC,IAAI,KAAK,SAAA;oBACV,IAAI,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;oBAC9E,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;wBACd,MAAM,CAAC,WAAW,CAAC;oBACvB,CAAC;iBACJ;YACL,CAAC;YAED,MAAM,CAAC,IAAI,CAAC;QAChB,CAAC;QAEL,0BAAC;IAAD,CArLA,AAqLC,IAAA;IArLY,gCAAmB,sBAqL/B,CAAA;AACL,CAAC,EA5LM,YAAY,KAAZ,YAAY,QA4LlB","file":"AutoMapperValidator.js","sourcesContent":["/// \r\n/// \r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n /**\r\n * AutoMapper configuration validator.\r\n */\r\n export class AutoMapperValidator {\r\n /**\r\n * Validates mapping configuration by dry-running. Since JS does not\r\n * fully support typing, it only checks if properties match on both\r\n * sides. The function needs IMapping.sourceTypeClass and\r\n * IMapping.destinationTypeClass to function.\r\n * @param {boolean} strictMode Whether or not to fail when properties\r\n * sourceTypeClass or destinationTypeClass\r\n * are unavailable.\r\n */\r\n public static assertConfigurationIsValid(mappings: any, strictMode: boolean): void {\r\n for (var key in mappings) {\r\n if (!mappings.hasOwnProperty(key)) {\r\n continue;\r\n }\r\n\r\n AutoMapperValidator.assertMappingConfiguration(mappings[key], strictMode);\r\n }\r\n }\r\n\r\n private static assertMappingConfiguration(mapping: IMapping, strictMode: boolean): void {\r\n var mappingKey = `${mapping.sourceKey}=>${mapping.destinationKey}`;\r\n\r\n var sourceType = mapping.sourceTypeClass;\r\n var destinationType = mapping.destinationTypeClass;\r\n\r\n var sourceClassName = sourceType ? AutoMapperHelper.getClassName(sourceType) : undefined;\r\n var destinationClassName = destinationType ? AutoMapperHelper.getClassName(destinationType) : undefined;\r\n\r\n if (!sourceType || !destinationType) {\r\n if (strictMode === false) {\r\n return;\r\n }\r\n\r\n throw new Error(`Mapping '${mappingKey}' cannot be validated, since mapping.sourceType or mapping.destinationType are unspecified.`);\r\n }\r\n\r\n var tryHandle = (errorMessage: string): void => {\r\n if (errorMessage) {\r\n throw new Error(`Mapping '${mappingKey}' is invalid: ${errorMessage} (source: '${sourceClassName}', destination: '${destinationClassName}').`);\r\n }\r\n };\r\n\r\n var validatedMembers = new Array();\r\n\r\n var srcObj = new sourceType();\r\n var dstObj = new destinationType();\r\n\r\n // walk member mappings\r\n for (let property of mapping.properties) {\r\n\r\n\r\n tryHandle(AutoMapperValidator.validatePropertyMapping(property, property.name, srcObj, dstObj));\r\n validatedMembers.push(property.name);\r\n }\r\n\r\n // walk source members\r\n for (let srcMember in srcObj) {\r\n if (!srcObj.hasOwnProperty(srcMember)) {\r\n continue;\r\n }\r\n\r\n if (validatedMembers.indexOf(srcMember) >= 0) {\r\n // already validated\r\n continue;\r\n }\r\n\r\n tryHandle(AutoMapperValidator.validateProperty(srcMember, dstObj));\r\n validatedMembers.push(srcMember);\r\n }\r\n\r\n // walk destination members\r\n for (let dstMember in dstObj) {\r\n if (!dstObj.hasOwnProperty(dstMember)) {\r\n continue;\r\n }\r\n\r\n if (validatedMembers.indexOf(dstMember) >= 0) {\r\n // already validated\r\n continue;\r\n }\r\n\r\n tryHandle(`Destination member '${dstMember}' does not exist on source type`);\r\n }\r\n // /* tslint:disable */\r\n // console.error(key);\r\n // /* tslint:enable */\r\n }\r\n\r\n private static validatePropertyMapping(propertyMapping: ISourceProperty, member: any, srcObj: any, dstObj: any): string {\r\n // awkward way of locating sourceMapping ;) ...\r\n let destinationProperty = AutoMapperValidator.getDestinationProperty(propertyMapping.destinationPropertyName, propertyMapping);\r\n\r\n return destinationProperty.sourceMapping\r\n ? AutoMapperValidator.validateSourcePropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj)\r\n : AutoMapperValidator.validateDestinationPropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj);\r\n }\r\n\r\n private static validateSourcePropertyMapping(\r\n ropertyMapping: ISourceProperty,\r\n destinationProperty: IDestinationProperty,\r\n member: any,\r\n srcObj: any,\r\n dstObj: any): string {\r\n // a member for which configuration is provided, should exist.\r\n if (!srcObj.hasOwnProperty(member)) {\r\n return `Source member '${member}' is configured, but does not exist on source type`;\r\n }\r\n\r\n // an ignored source member should not exist on the destination type.\r\n if (destinationProperty.ignore) {\r\n if (dstObj.hasOwnProperty(member)) {\r\n return `Source member '${member}' is ignored, but does exist on destination type`;\r\n }\r\n return undefined;\r\n }\r\n\r\n // a mapped source member should exist on the destination type.\r\n if (!dstObj.hasOwnProperty(member)) {\r\n return `Source member '${member}' is configured to be mapped, but does not exist on destination type`;\r\n }\r\n\r\n //var dstMember = propertyMapping.destinationProperty;\r\n\r\n return undefined;\r\n }\r\n\r\n private static validateDestinationPropertyMapping(\r\n propertyMapping: ISourceProperty,\r\n destinationProperty: IDestinationProperty,\r\n member: any,\r\n srcObj: any,\r\n dstObj: any): string {\r\n // a member for which configuration is provided, should exist.\r\n if (!dstObj.hasOwnProperty(destinationProperty.name)) {\r\n return `Destination member '${destinationProperty.destinationPropertyName}' is configured, but does not exist on destination type`;\r\n }\r\n\r\n // an ignored destination member should not exist on the source type.\r\n if (destinationProperty.ignore) {\r\n if (srcObj.hasOwnProperty(member)) {\r\n return `Destination member '${member}' is ignored, but does exist on source type`;\r\n }\r\n return undefined;\r\n }\r\n\r\n // a mapped destination member should exist on the source type.\r\n if (!srcObj.hasOwnProperty(member)) {\r\n return `Destination member '${member}' is configured to be mapped, but does not exist on source type`;\r\n }\r\n\r\n //var dstMember = propertyMapping.destinationProperty;\r\n\r\n return undefined;\r\n }\r\n\r\n private static validateProperty(srcMember: any, dstObj: any): string {\r\n if (!dstObj.hasOwnProperty(srcMember)) {\r\n return `Source member '${srcMember}' is configured to be mapped, but does not exist on destination type`;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n private static getDestinationProperty(destinationPropertyName: string, existingSource: ISourceProperty): IDestinationProperty {\r\n if (existingSource.destination) {\r\n return existingSource.destination;\r\n }\r\n\r\n if (existingSource.children) {\r\n for (let child of existingSource.children) {\r\n var destination = this.getDestinationProperty(destinationPropertyName, child);\r\n if (destination) {\r\n return destination;\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n }\r\n}"]} \ No newline at end of file diff --git a/src/js/naming-conventions/CamelCaseNamingConvention.js.map b/src/js/naming-conventions/CamelCaseNamingConvention.js.map index 020711b..8eba4d2 100644 --- a/src/js/naming-conventions/CamelCaseNamingConvention.js.map +++ b/src/js/naming-conventions/CamelCaseNamingConvention.js.map @@ -1 +1 @@ -{"version":3,"sources":["naming-conventions/CamelCaseNamingConvention.ts"],"names":[],"mappings":"AAAA,iEAAiE;AAEjE,IAAO,YAAY,CAwBlB;AAxBD,WAAO,YAAY;IACf,YAAY,CAAC;IAEhB;QAAA;YACc,wBAAmB,GAAG,kDAAkD,CAAC;YACzE,uBAAkB,GAAG,EAAE,CAAC;QAkBtC,CAAC;QAhBO,yDAAqB,GAA5B,UAA6B,uBAAiC;YACpD,gCAAgC;YAChC,IAAI,MAAM,GAAW,EAAE,CAAC;YAExB,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,uBAAuB,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC9F,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;oBACH,MAAM,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;wBACxD,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACjE,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACI,MAAM,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;wBACtD,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACnD,CAAC;YACL,CAAC;YAED,MAAM,CAAC,MAAM,CAAC;QAClB,CAAC;QACR,gCAAC;IAAD,CApBA,AAoBC,IAAA;IApBY,sCAAyB,4BAoBrC,CAAA;AACF,CAAC,EAxBM,YAAY,KAAZ,YAAY,QAwBlB","file":"CamelCaseNamingConvention.js","sourcesContent":["/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n\texport class CamelCaseNamingConvention implements INamingConvention {\r\n public splittingExpression = /(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\r\n public separatorCharacter = '';\r\n\r\n\t\tpublic transformPropertyName(sourcePropertyNameParts: string[]): string {\r\n // Transform the splitted parts.\r\n var result: string = '';\r\n\r\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\r\n \t\t\t\tif (index === 0) {\r\n result += sourcePropertyNameParts[index].charAt(0).toLowerCase() +\r\n sourcePropertyNameParts[index].substr(1);\r\n\t\t\t\t} else {\r\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\r\n sourcePropertyNameParts[index].substr(1);\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\t}\r\n}"]} \ No newline at end of file +{"version":3,"sources":["naming-conventions/CamelCaseNamingConvention.ts"],"names":[],"mappings":"AAAA,iEAAiE;AAEjE,IAAO,YAAY,CAwBlB;AAxBD,WAAO,YAAY;IACf,YAAY,CAAC;IAEhB;QAAA;YACc,wBAAmB,GAAG,kDAAkD,CAAC;YACzE,uBAAkB,GAAG,EAAE,CAAC;QAkBtC,CAAC;QAhBO,yDAAqB,GAA5B,UAA6B,uBAAiC;YACpD,gCAAgC;YAChC,IAAI,MAAM,GAAG,EAAE,CAAC;YAEhB,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,uBAAuB,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC9F,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC;oBACH,MAAM,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;wBACxD,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACjE,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACI,MAAM,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;wBACtD,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACnD,CAAC;YACL,CAAC;YAED,MAAM,CAAC,MAAM,CAAC;QAClB,CAAC;QACR,gCAAC;IAAD,CApBA,AAoBC,IAAA;IApBY,sCAAyB,4BAoBrC,CAAA;AACF,CAAC,EAxBM,YAAY,KAAZ,YAAY,QAwBlB","file":"CamelCaseNamingConvention.js","sourcesContent":["/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n\texport class CamelCaseNamingConvention implements INamingConvention {\r\n public splittingExpression = /(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\r\n public separatorCharacter = '';\r\n\r\n\t\tpublic transformPropertyName(sourcePropertyNameParts: string[]): string {\r\n // Transform the splitted parts.\r\n var result = '';\r\n\r\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\r\n \t\t\t\tif (index === 0) {\r\n result += sourcePropertyNameParts[index].charAt(0).toLowerCase() +\r\n sourcePropertyNameParts[index].substr(1);\r\n\t\t\t\t} else {\r\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\r\n sourcePropertyNameParts[index].substr(1);\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\t}\r\n}"]} \ No newline at end of file diff --git a/src/js/naming-conventions/PascalCaseNamingConvention.js.map b/src/js/naming-conventions/PascalCaseNamingConvention.js.map index 4125f80..dd5c90f 100644 --- a/src/js/naming-conventions/PascalCaseNamingConvention.js.map +++ b/src/js/naming-conventions/PascalCaseNamingConvention.js.map @@ -1 +1 @@ -{"version":3,"sources":["naming-conventions/PascalCaseNamingConvention.ts"],"names":[],"mappings":"AAAA,iEAAiE;AAEjE,IAAO,YAAY,CAuBlB;AAvBD,WAAO,YAAY;IACf,YAAY,CAAC;IAEhB;QAAA;YACc,wBAAmB,GAAG,kDAAkD,CAAC;YACzE,uBAAkB,GAAG,EAAE,CAAC;QAiBtC,CAAC;QAfO,0DAAqB,GAA5B,UAA6B,uBAAiC;YACpD,gCAAgC;YAChC,IAAI,MAAM,GAAW,EAAE,CAAC;YAExB,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,uBAAuB,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBACnF,MAAM,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;oBACtD,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAE/D,6BAA6B;gBAC7B,8BAA8B;gBAC9B,GAAG;YACK,CAAC;YAED,MAAM,CAAC,MAAM,CAAC;QAClB,CAAC;QACR,iCAAC;IAAD,CAnBA,AAmBC,IAAA;IAnBY,uCAA0B,6BAmBtC,CAAA;AACF,CAAC,EAvBM,YAAY,KAAZ,YAAY,QAuBlB","file":"PascalCaseNamingConvention.js","sourcesContent":["/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n\texport class PascalCaseNamingConvention implements INamingConvention {\r\n public splittingExpression = /(^[A-Z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\r\n public separatorCharacter = '';\r\n\r\n\t\tpublic transformPropertyName(sourcePropertyNameParts: string[]): string {\r\n // Transform the splitted parts.\r\n var result: string = '';\r\n\r\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\r\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\r\n sourcePropertyNameParts[index].substr(1);\r\n\r\n\t\t\t\t//if (index < (length - 1)) {\r\n\t\t\t\t// this.separatorCharacter;\r\n\t\t\t\t//}\r\n }\r\n\r\n return result;\r\n }\r\n\t}\r\n}"]} \ No newline at end of file +{"version":3,"sources":["naming-conventions/PascalCaseNamingConvention.ts"],"names":[],"mappings":"AAAA,iEAAiE;AAEjE,IAAO,YAAY,CAuBlB;AAvBD,WAAO,YAAY;IACf,YAAY,CAAC;IAEhB;QAAA;YACc,wBAAmB,GAAG,kDAAkD,CAAC;YACzE,uBAAkB,GAAG,EAAE,CAAC;QAiBtC,CAAC;QAfO,0DAAqB,GAA5B,UAA6B,uBAAiC;YACpD,gCAAgC;YAChC,IAAI,MAAM,GAAG,EAAE,CAAC;YAEhB,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,uBAAuB,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBACnF,MAAM,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;oBACtD,uBAAuB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAE/D,6BAA6B;gBAC7B,8BAA8B;gBAC9B,GAAG;YACK,CAAC;YAED,MAAM,CAAC,MAAM,CAAC;QAClB,CAAC;QACR,iCAAC;IAAD,CAnBA,AAmBC,IAAA;IAnBY,uCAA0B,6BAmBtC,CAAA;AACF,CAAC,EAvBM,YAAY,KAAZ,YAAY,QAuBlB","file":"PascalCaseNamingConvention.js","sourcesContent":["/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n\texport class PascalCaseNamingConvention implements INamingConvention {\r\n public splittingExpression = /(^[A-Z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\r\n public separatorCharacter = '';\r\n\r\n\t\tpublic transformPropertyName(sourcePropertyNameParts: string[]): string {\r\n // Transform the splitted parts.\r\n var result = '';\r\n\r\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\r\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\r\n sourcePropertyNameParts[index].substr(1);\r\n\r\n\t\t\t\t//if (index < (length - 1)) {\r\n\t\t\t\t// this.separatorCharacter;\r\n\t\t\t\t//}\r\n }\r\n\r\n return result;\r\n }\r\n\t}\r\n}"]} \ No newline at end of file diff --git a/src/ts/AsyncAutoMapper.ts b/src/ts/AsyncAutoMapper.ts index fb3e456..6cc4d82 100644 --- a/src/ts/AsyncAutoMapper.ts +++ b/src/ts/AsyncAutoMapper.ts @@ -28,7 +28,7 @@ module AutoMapperJs { public createMapForMember(mapping: IMapping, property: ISourceProperty): void { mapping.async = true; - mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any, cb: IMapCallback) => this.mapItem(m, srcObj, dstObj, cb); + mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any, cb: IMapCallback): void => this.mapItem(m, srcObj, dstObj, cb); // property.async = true; // property.conversionValuesAndFunctions.push(func); } @@ -36,7 +36,7 @@ module AutoMapperJs { public createMapConvertUsing(mapping: IMapping, converterFunction: (ctx: IResolutionContext, cb: IMapCallback) => void): void { mapping.async = true; mapping.typeConverterFunction = converterFunction; - mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any, cb: IMapCallback) => this.mapItemUsingTypeConverter(m, srcObj, dstObj, cb); + mapping.mapItemFunction = (m: IMapping, srcObj: any, dstObj: any, cb: IMapCallback): void => this.mapItemUsingTypeConverter(m, srcObj, dstObj, cb); } public map(m: { [key: string]: IMapping }, srcKey: string | (new () => any)): (dstKey: string | (new () => any), srcObj: any, cb: IMapCallback) => void; @@ -55,11 +55,11 @@ module AutoMapperJs { return; // provide performance optimized (preloading) currying support. case 4: - return (cb: IMapCallback) => this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), sourceObject, cb); + return (cb: IMapCallback): void => this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), sourceObject, cb); case 3: - return (srcObj: any, cb: IMapCallback) => this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), srcObj, cb); + return (srcObj: any, cb: IMapCallback): void => this.mapWithMapping(super.getMapping(mappings, sourceKey, destinationKey), srcObj, cb); case 2: - return (dstKey: string | (new () => any), srcObj: any, cb: IMapCallback) => this.map(mappings, sourceKey, dstKey, srcObj, cb); + return (dstKey: string | (new () => any), srcObj: any, cb: IMapCallback): void => this.map(mappings, sourceKey, dstKey, srcObj, cb); default: throw new Error('The AsyncAutoMapper.map function expects between 2 and 5 parameters, you provided ' + arguments.length + '.'); } diff --git a/src/ts/AutoMapper.ts b/src/ts/AutoMapper.ts index 3a9e46b..f50ab36 100644 --- a/src/ts/AutoMapper.ts +++ b/src/ts/AutoMapper.ts @@ -106,14 +106,14 @@ module AutoMapperJs { // provide performance optimized (preloading) currying support. if (arguments.length === 2) { - return (srcObj: any) => this.mapInternal(super.getMapping(this._mappings, sourceKeyOrType, destinationKeyOrType), srcObj); + return (srcObj: any): any => this.mapInternal(super.getMapping(this._mappings, sourceKeyOrType, destinationKeyOrType), srcObj); } if (arguments.length === 1) { - return (dstKey: string | (new () => any), srcObj: any) => this.map(sourceKeyOrType, dstKey, srcObj); + return (dstKey: string | (new () => any), srcObj: any): any => this.map(sourceKeyOrType, dstKey, srcObj); } - return (srcKey: string | (new () => any), dstKey: string | (new () => any), srcObj: any) => this.map(srcKey, dstKey, srcObj); + return (srcKey: string | (new () => any), dstKey: string | (new () => any), srcObj: any): any => this.map(srcKey, dstKey, srcObj); } /** @@ -167,7 +167,7 @@ module AutoMapperJs { } private createMapConvertUsing(mapping: IMapping, tcClassOrFunc: convertUsingClassOrInstanceOrFunction): void { - var configureSynchronousConverterFunction = (converterFunc: any) => { + var configureSynchronousConverterFunction = (converterFunc: any): void => { if (!converterFunc || AutoMapperHelper.getFunctionParameters(converterFunc.toString()).length !== 1) { throw new Error('The function provided does not provide exactly one (resolutionContext) parameter.'); } @@ -703,7 +703,7 @@ module AutoMapperJs { } // Add AutoMapper to the application's global scope. Of course, you could still use Core.AutoMapper.getInstance() as well. -var automapper: AutoMapperJs.AutoMapper = ((app: any) => { +var automapper: AutoMapperJs.AutoMapper = ((app: any): AutoMapperJs.AutoMapper => { app.automapper = AutoMapperJs.AutoMapper.getInstance(); return app.automapper; })(this); diff --git a/src/ts/AutoMapperHelper.ts b/src/ts/AutoMapperHelper.ts index 9711e28..d3c0d29 100644 --- a/src/ts/AutoMapperHelper.ts +++ b/src/ts/AutoMapperHelper.ts @@ -55,6 +55,7 @@ module AutoMapperJs { const argumentNames = /([^\s,]+)/g; var functionString = functionStr.replace(stripComments, ''); + var functionParameterNames = functionString.slice(functionString.indexOf('(') + 1, functionString.indexOf(')')).match(argumentNames); if (functionParameterNames === null) { functionParameterNames = new Array(); diff --git a/src/ts/AutoMapperValidator.ts b/src/ts/AutoMapperValidator.ts index 841af64..41c2194 100644 --- a/src/ts/AutoMapperValidator.ts +++ b/src/ts/AutoMapperValidator.ts @@ -43,7 +43,7 @@ module AutoMapperJs { throw new Error(`Mapping '${mappingKey}' cannot be validated, since mapping.sourceType or mapping.destinationType are unspecified.`); } - var tryHandle = (errorMessage: string) => { + var tryHandle = (errorMessage: string): void => { if (errorMessage) { throw new Error(`Mapping '${mappingKey}' is invalid: ${errorMessage} (source: '${sourceClassName}', destination: '${destinationClassName}').`); } diff --git a/src/ts/naming-conventions/CamelCaseNamingConvention.ts b/src/ts/naming-conventions/CamelCaseNamingConvention.ts index a0ef135..061e288 100644 --- a/src/ts/naming-conventions/CamelCaseNamingConvention.ts +++ b/src/ts/naming-conventions/CamelCaseNamingConvention.ts @@ -9,7 +9,7 @@ module AutoMapperJs { public transformPropertyName(sourcePropertyNameParts: string[]): string { // Transform the splitted parts. - var result: string = ''; + var result = ''; for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) { if (index === 0) { diff --git a/src/ts/naming-conventions/PascalCaseNamingConvention.ts b/src/ts/naming-conventions/PascalCaseNamingConvention.ts index 324c407..b2ced66 100644 --- a/src/ts/naming-conventions/PascalCaseNamingConvention.ts +++ b/src/ts/naming-conventions/PascalCaseNamingConvention.ts @@ -9,7 +9,7 @@ module AutoMapperJs { public transformPropertyName(sourcePropertyNameParts: string[]): string { // Transform the splitted parts. - var result: string = ''; + var result = ''; for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) { result += sourcePropertyNameParts[index].charAt(0).toUpperCase() + diff --git a/test/tests/js/automapper-assertconfig-specs.js b/test/tests/js/automapper-assertconfig-specs.js index affd88b..ebe718d 100644 --- a/test/tests/js/automapper-assertconfig-specs.js +++ b/test/tests/js/automapper-assertconfig-specs.js @@ -31,6 +31,15 @@ var AutoMapperJs; // act and assert automapper.assertConfigurationIsValid(); }); + // // TODO Should work! + // it('should set strictMode to \'true\' when no value is provided and validate (with valid mappings)', () => { + // // arrange + // automapper + // .createMap(AssertConfigPropertiesProp, AssertConfigPropertiesProp2) + // .forMember('prop2', (opts: AutoMapperJs.IMemberConfigurationOptions) => opts.mapFrom('prop')); + // // act and assert + // automapper.assertConfigurationIsValid(); + // }); // it('should set strictMode to \'true\' when no value is provided and validate (with valid nested mappings)', () => { // // arrange // automapper.createMap(AssertConfigPropertiesNestedProp, AssertConfigPropertiesProp) diff --git a/test/tests/js/automapper-createmap-formember-specs.js b/test/tests/js/automapper-createmap-formember-specs.js index 267133d..b81b19b 100644 --- a/test/tests/js/automapper-createmap-formember-specs.js +++ b/test/tests/js/automapper-createmap-formember-specs.js @@ -25,7 +25,10 @@ var AutoMapperJs; // assert var properties = TestHelper.assertAndGetProperty(fromKey, toKey); expect(properties.length).toBe(1); - var destination = TestHelper.createDestinationProperty('prop', 'prop', 'prop', null, [{ transformationType: 2, memberConfigurationOptionsFunc: ignoreFunc }], true, false); + var destination = TestHelper.createDestinationProperty('prop', 'prop', 'prop', null, [{ + transformationType: 2, + memberConfigurationOptionsFunc: ignoreFunc + }], true, false); var source = TestHelper.createSourceProperty('prop', 'prop', 'prop', null, destination); expect(properties[0]).toEqualData(source); }); @@ -75,9 +78,15 @@ var AutoMapperJs; // assert var properties = TestHelper.assertAndGetProperty(fromKey, toKey); expect(properties.length).toBe(2); - var destination1 = TestHelper.createDestinationProperty('prop1', 'prop2', 'prop1', null, [{ transformationType: 2, memberConfigurationOptionsFunc: mapFromFunc }], false, false); + var destination1 = TestHelper.createDestinationProperty('prop1', 'prop2', 'prop1', null, [{ + transformationType: 2, + memberConfigurationOptionsFunc: mapFromFunc + }], false, false); var source1 = TestHelper.createSourceProperty('prop2', 'prop2', 'prop1', null, destination1); - var destination2 = TestHelper.createDestinationProperty('prop2', 'prop2', 'prop2', null, [{ transformationType: 2, memberConfigurationOptionsFunc: ignoreFunc }], true, false); + var destination2 = TestHelper.createDestinationProperty('prop2', 'prop2', 'prop2', null, [{ + transformationType: 2, + memberConfigurationOptionsFunc: ignoreFunc + }], true, false); var source2 = TestHelper.createSourceProperty('prop2', 'prop2', 'prop2', null, destination2); expect(properties[0]).toEqualData(source1); expect(properties[1]).toEqualData(source2); diff --git a/test/tests/js/automapper-createmap-specs.js b/test/tests/js/automapper-createmap-specs.js index abf6028..834d7c2 100644 --- a/test/tests/js/automapper-createmap-specs.js +++ b/test/tests/js/automapper-createmap-specs.js @@ -204,6 +204,25 @@ var AutoMapperJs; // assert expect(objB).toEqualData({ prop1: objA.prop1, prop: objA.prop2 }); }); + it('should be able to use forMember to do custom mapping using lambda function', function () { + //arrange + var objA = { prop1: 'From A', prop2: 'From A too' }; + var fromKey = '{7AC4134B-ECC1-464B-B144-5B9D8F5B578E}'; + var toKey = '{2BDE907C-1CE6-4CC5-A601-9A94CC665737}'; + var mapFromNullable = function (opts, field) { + if (opts.sourceObject[field]) { + return opts.sourceObject[field]; + } + return ''; + }; + automapper + .createMap(fromKey, toKey) + .forMember('prop', function (opts) { return mapFromNullable(opts, 'prop2'); }); + // act + var objB = automapper.map(fromKey, toKey, objA); + // assert + expect(objB).toEqualData({ prop1: objA.prop1, prop: objA.prop2 }); + }); it('should use forAllMembers function for each mapped destination property when specified', function () { // arrange var objA = { prop1: 'From A', prop2: 'From A too' }; diff --git a/test/tests/js/automapper-helper-specs.js b/test/tests/js/automapper-helper-specs.js new file mode 100644 index 0000000..39f8ab4 --- /dev/null +++ b/test/tests/js/automapper-helper-specs.js @@ -0,0 +1,24 @@ +/// +/// +/// +/// +/// +var globalScope = this; +var AutoMapperJs; +(function (AutoMapperJs) { + 'use strict'; + describe('AutoMapperHelper', function () { + var postfix = ' [f0e5ef36-e1ed-47c4-a86f-48f8b52e6897]'; + beforeEach(function () { + utils.registerTools(globalScope); + utils.registerCustomMatchers(globalScope); + }); + it('should be able to use forMember to ignore a property', function () { + // arrange + var functionString = ''; + // act + var parameters = AutoMapperJs.AutoMapperHelper.getFunctionParameters(functionString); + // assert + }); + }); +})(AutoMapperJs || (AutoMapperJs = {})); diff --git a/test/tests/ts/automapper-assertconfig-specs.ts b/test/tests/ts/automapper-assertconfig-specs.ts index 7dcd71e..22a8d85 100644 --- a/test/tests/ts/automapper-assertconfig-specs.ts +++ b/test/tests/ts/automapper-assertconfig-specs.ts @@ -40,6 +40,17 @@ module AutoMapperJs { automapper.assertConfigurationIsValid(); }); + // // TODO Should work! + // it('should set strictMode to \'true\' when no value is provided and validate (with valid mappings)', () => { + // // arrange + // automapper + // .createMap(AssertConfigPropertiesProp, AssertConfigPropertiesProp2) + // .forMember('prop2', (opts: AutoMapperJs.IMemberConfigurationOptions) => opts.mapFrom('prop')); + + // // act and assert + // automapper.assertConfigurationIsValid(); + // }); + // it('should set strictMode to \'true\' when no value is provided and validate (with valid nested mappings)', () => { // // arrange // automapper.createMap(AssertConfigPropertiesNestedProp, AssertConfigPropertiesProp) diff --git a/test/tests/ts/automapper-createmap-formember-specs.ts b/test/tests/ts/automapper-createmap-formember-specs.ts index 564522f..5f5e20f 100644 --- a/test/tests/ts/automapper-createmap-formember-specs.ts +++ b/test/tests/ts/automapper-createmap-formember-specs.ts @@ -34,7 +34,10 @@ module AutoMapperJs { var properties = TestHelper.assertAndGetProperty(fromKey, toKey); expect(properties.length).toBe(1); - var destination = TestHelper.createDestinationProperty('prop', 'prop', 'prop', null, [{ transformationType: 2, memberConfigurationOptionsFunc: ignoreFunc }], true, false); + var destination = TestHelper.createDestinationProperty('prop', 'prop', 'prop', null, [{ + transformationType: 2, + memberConfigurationOptionsFunc: ignoreFunc + }], true, false); var source = TestHelper.createSourceProperty('prop', 'prop', 'prop', null, destination); expect(properties[0]).toEqualData(source); @@ -102,10 +105,16 @@ module AutoMapperJs { var properties = TestHelper.assertAndGetProperty(fromKey, toKey); expect(properties.length).toBe(2); - var destination1 = TestHelper.createDestinationProperty('prop1', 'prop2', 'prop1', null, [{ transformationType: 2, memberConfigurationOptionsFunc: mapFromFunc }], false, false); + var destination1 = TestHelper.createDestinationProperty('prop1', 'prop2', 'prop1', null, [{ + transformationType: 2, + memberConfigurationOptionsFunc: mapFromFunc + }], false, false); var source1 = TestHelper.createSourceProperty('prop2', 'prop2', 'prop1', null, destination1); - var destination2 = TestHelper.createDestinationProperty('prop2', 'prop2', 'prop2', null, [{ transformationType: 2, memberConfigurationOptionsFunc: ignoreFunc }], true, false); + var destination2 = TestHelper.createDestinationProperty('prop2', 'prop2', 'prop2', null, [{ + transformationType: 2, + memberConfigurationOptionsFunc: ignoreFunc + }], true, false); var source2 = TestHelper.createSourceProperty('prop2', 'prop2', 'prop2', null, destination2); expect(properties[0]).toEqualData(source1); diff --git a/test/tests/ts/automapper-createmap-specs.ts b/test/tests/ts/automapper-createmap-specs.ts index eb0f115..9ff9523 100644 --- a/test/tests/ts/automapper-createmap-specs.ts +++ b/test/tests/ts/automapper-createmap-specs.ts @@ -259,6 +259,31 @@ module AutoMapperJs { expect(objB).toEqualData({ prop1: objA.prop1, prop: objA.prop2 }); }); + it('should be able to use forMember to do custom mapping using lambda function', () => { + //arrange + var objA = { prop1: 'From A', prop2: 'From A too' }; + + var fromKey = '{7AC4134B-ECC1-464B-B144-5B9D8F5B578E}'; + var toKey = '{2BDE907C-1CE6-4CC5-A601-9A94CC665737}'; + + const mapFromNullable = (opts: IMemberConfigurationOptions, field: string) => { + if (opts.sourceObject[field]) { + return opts.sourceObject[field]; + } + return ''; + }; + + automapper + .createMap(fromKey, toKey) + .forMember('prop', (opts: IMemberConfigurationOptions) => mapFromNullable(opts, 'prop2')); + + // act + var objB = automapper.map(fromKey, toKey, objA); + + // assert + expect(objB).toEqualData({ prop1: objA.prop1, prop: objA.prop2 }); + }); + it('should use forAllMembers function for each mapped destination property when specified', () => { // arrange var objA = { prop1: 'From A', prop2: 'From A too' }; @@ -445,7 +470,7 @@ module AutoMapperJs { automapper .createMap(fromKey, toKey) - .convertUsing(function(resolutionContext: IResolutionContext): any { + .convertUsing(function (resolutionContext: IResolutionContext): any { return { propA: resolutionContext.sourceValue.propA + ' (custom mapped with resolution context)' }; }); diff --git a/tslint.json b/tslint.json index a58ddab..a382f37 100644 --- a/tslint.json +++ b/tslint.json @@ -4,20 +4,38 @@ "curly": true, "eofline": false, "forin": true, - "indent": [true, 4], - "interface-name": true, + "indent": [ + true, + 4 + ], + "interface-name": [ + true, + "always-prefix" + ], "jsdoc-format": true, "label-position": true, - "max-line-length": [true, 180], + "max-line-length": [ + true, + 180 + ], "member-access": true, - "member-ordering": [true, - "public-before-private", - "static-before-instance", - "variables-before-functions" + "member-ordering": [ + true, + { + "order": [ + "static-field", + "instance-field", + "constructor", + "public-instance-method", + "protected-instance-method", + "private-instance-method" + ] + } ], "no-arg": true, "no-bitwise": true, - "no-console": [true, + "no-console": [ + true, "debug", "info", "time", @@ -32,35 +50,58 @@ "no-empty": true, "no-eval": true, "no-string-literal": false, - "trailing-comma": false, + "trailing-comma": [ + false, + { + "singleline": "always", + "multiline": "always" + } + ], "no-trailing-whitespace": true, - "no-use-before-declare": true, - "one-line": [true, + //"no-use-before-declare": true, + "one-line": [ + true, "check-open-brace", "check-catch", "check-else", "check-whitespace" ], - "quotemark": [true, "single"], + "quotemark": [ + true, + "single" + ], "radix": true, - "semicolon": true, - "triple-equals": [true, "allow-null-check"], - "typedef": [true, - "call-signature", - "parameter", - "property-declaration", - ["variable-declaration", false], - ["member-variable-declaration", false] + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" ], - "typedef-whitespace": [true, { + "typedef": [ + true, + "call-signature", + "arrow-call-signature", + "parameter", + "property-declaration"//, + //"variable-declaration"//, + //"member-variable-declaration" + ], + "no-inferrable-types": [true, "ignore-params", "ignore-properties"], + "typedef-whitespace": [ + true, + { "call-signature": "nospace", "index-signature": "nospace", "parameter": "nospace", "property-declaration": "nospace", "variable-declaration": "nospace" - }], + } + ], "variable-name": false, - "whitespace": [true, + "whitespace": [ + true, "check-branch", "check-decl", "check-operator",