From 9ff3ead95f91c5394014361553850e2696ba15c5 Mon Sep 17 00:00:00 2001 From: Bert Loedeman Date: Mon, 29 May 2017 11:43:22 +0200 Subject: [PATCH] Upgraded NPM packages and small fix in AutoMapperHelper --- bower.json | 2 +- dist/automapper-classes.d.ts | 2 +- dist/automapper-declaration.d.ts | 2 +- dist/automapper-interfaces.d.ts | 2 +- dist/automapper.d.ts | 2 +- dist/automapper.js | 70 ++++++++++++------- dist/automapper.js.map | 2 +- dist/automapper.min.js | 6 +- dist/automapper.min.js.map | 2 +- gulp.config.js | 2 +- package.json | 10 +-- samples/js/configuration.js | 17 +++-- samples/js/configuration.js.map | 2 +- src/js/AsyncAutoMapper.js | 17 +++-- src/js/AsyncAutoMapper.js.map | 2 +- src/js/AutoMapper.js | 26 ++++--- src/js/AutoMapper.js.map | 2 +- src/js/AutoMapperBase.js | 4 +- src/js/AutoMapperBase.js.map | 2 +- src/js/AutoMapperHelper.js | 10 +-- src/js/AutoMapperHelper.js.map | 2 +- src/js/AutoMapperValidator.js | 6 +- src/js/AutoMapperValidator.js.map | 2 +- src/js/Profile.js.map | 2 +- .../PascalCaseNamingConvention.js | 3 + .../PascalCaseNamingConvention.js.map | 2 +- src/ts/AutoMapperBase.ts | 2 +- src/ts/AutoMapperHelper.ts | 11 +-- test/tests/js/automapper-createmap-specs.js | 20 ++++-- test/tests/js/automapper-initialize-specs.js | 25 ++++--- 30 files changed, 154 insertions(+), 105 deletions(-) diff --git a/bower.json b/bower.json index a768a1d..c9c76f8 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "automapper-ts", - "version": "1.8.1", + "version": "1.8.2", "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 1565f37..1edd1b2 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.1 +// Type definitions for AutoMapper.js 1.8.2 // 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 a4baa0c..42c164b 100644 --- a/dist/automapper-declaration.d.ts +++ b/dist/automapper-declaration.d.ts @@ -2,7 +2,7 @@ /// -// Type definitions for AutoMapper.js 1.8.1 +// Type definitions for AutoMapper.js 1.8.2 // 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 112f187..2abc840 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.1 +// Type definitions for AutoMapper.js 1.8.2 // 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 28d1012..2e0a9c5 100644 --- a/dist/automapper.d.ts +++ b/dist/automapper.d.ts @@ -1,4 +1,4 @@ -// Type definitions for AutoMapper.js 1.8.1 +// Type definitions for AutoMapper.js 1.8.2 // 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 9be35fd..e7cb7ad 100644 --- a/dist/automapper.js +++ b/dist/automapper.js @@ -1,11 +1,11 @@ /*! - * TypeScript / Javascript AutoMapper Library v1.8.1 + * TypeScript / Javascript AutoMapper Library v1.8.2 * https://github.com/loedeman/AutoMapper * * Copyright 2015-2017 Interest IT / Bert Loedeman and other contributors * Released under the MIT license * - * Date: 2017-01-05T17:00:00.000Z + * Date: 2017-05-29T16:00:00.000Z */ ;(function(root, factory) { if (typeof define === 'function' && define.amd) { @@ -47,17 +47,18 @@ var AutoMapperJs; } if (classType.constructor.toString()) { var str = classType.constructor.toString(); + var regExpMatchArray = void 0; if (str.charAt(0) === '[') { // executed if the return of object.constructor.toString() is "[object objectClass]" - var arr = str.match(/\[\w+\s*(\w+)\]/); + regExpMatchArray = str.match(/\[\w+\s*(\w+)\]/); } else { // executed if the return of object.constructor.toString() is "function objectClass () {}" // (IE and Firefox) - var arr = str.match(/function\s*(\w+)/); + regExpMatchArray = str.match(/function\s*(\w+)/); } - if (arr && arr.length === 2) { - return arr[1]; + if (regExpMatchArray && regExpMatchArray.length === 2) { + return regExpMatchArray[1]; } } } @@ -235,6 +236,7 @@ var AutoMapperJs; func(configFuncOptions); } catch (exc) { + // do not handle by default. } return condition; }; @@ -324,7 +326,7 @@ var AutoMapperJs; } // /* tslint:disable */ // console.error(key); - // /* tslint:enable */ + // /* tslint:enable */ }; AutoMapperValidator.validatePropertyMapping = function (propertyMapping, member, srcObj, dstObj) { // awkward way of locating sourceMapping ;) ... @@ -338,7 +340,7 @@ var AutoMapperJs; if (!srcObj.hasOwnProperty(member)) { return "Source member '" + member + "' is configured, but does not exist on source type"; } - // an ignored source member should not exist on the destination type. + // an ignored source member should not exist on the destination type. if (destinationProperty.ignore) { if (dstObj.hasOwnProperty(member)) { return "Source member '" + member + "' is ignored, but does exist on destination type"; @@ -357,7 +359,7 @@ var AutoMapperJs; if (!dstObj.hasOwnProperty(destinationProperty.name)) { return "Destination member '" + destinationProperty.destinationPropertyName + "' is configured, but does not exist on destination type"; } - // an ignored destination member should not exist on the source type. + // an ignored destination member should not exist on the source type. if (destinationProperty.ignore) { if (srcObj.hasOwnProperty(member)) { return "Destination member '" + member + "' is ignored, but does exist on source type"; @@ -621,8 +623,8 @@ var AutoMapperJs; }; AutoMapperBase.prototype.processMappedProperty = function (mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction) { if (propertyMapping.children && propertyMapping.children.length > 0) { - // always pass child source object, even if source object does not exist => - // constant transformations should always pass. + // always pass child source object, even if source object does not exist => + // constant transformations should always pass. var childSourceObject = sourceObject ? sourceObject[propertyMapping.name] : null; for (var _i = 0, _a = propertyMapping.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -667,11 +669,16 @@ var AutoMapperJs; /// /// /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var AutoMapperJs; (function (AutoMapperJs) { 'use strict'; @@ -810,7 +817,7 @@ var AutoMapperJs; if (childDestinationProperty) { var childDestinationObject = destinationObject[destinationProperty.name]; if (!childDestinationObject) { - // no child source object? create. + // no child source object? create. childDestinationObject = {}; } // transform child by recursively calling the transform function. @@ -919,11 +926,16 @@ var AutoMapperJs; /// /// /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var AutoMapperJs; (function (AutoMapperJs) { 'use strict'; @@ -1071,6 +1083,7 @@ var AutoMapperJs; typeConverter = new tcClassOrFunc(); } catch (e) { + // Obviously, typeConverterClassOrFunction is not a TypeConverter class definition } if (typeConverter instanceof AutoMapperJs.TypeConverter) { configureSynchronousConverterFunction(typeConverter.convert); @@ -1173,7 +1186,7 @@ var AutoMapperJs; if (childDestinationProperty) { var childDestinationObject = destinationObject[destinationProperty.name]; if (!childDestinationObject) { - // no child source object? create. + // no child source object? create. childDestinationObject = {}; } // transform child by recursively calling the transform function. @@ -1387,14 +1400,14 @@ var AutoMapperJs; } } if (property.destinationPropertyName !== property.sourcePropertyName) { - // this is a mapFrom() registration. It is handled using the nested source properties, + // this is a mapFrom() registration. It is handled using the nested source properties, // we only are responsible for syncing the name properties. existing.name = property.name; existing.sourcePropertyName = property.sourcePropertyName; } return true; } - // existing is not (further) nested. this is always a mapFrom() situation. + // existing is not (further) nested. this is always a mapFrom() situation. // if (property.sourcePropertyName !== existing.sourcePropertyName) { var newDestination = this.getDestinationProperty(existing.destinationPropertyName, property); if (property.destinationPropertyName !== property.sourcePropertyName) { @@ -1454,7 +1467,7 @@ var AutoMapperJs; this.handleMapFromProperties(destination, existingDestination); return true; } - // the current destination is not (further) nested. a destination property registration has one of both: + // the current destination is not (further) nested. a destination property registration has one of both: // a) children or b) transformations. returning false will cause creating a duplicate source property entry instead. return false; } @@ -1470,7 +1483,7 @@ var AutoMapperJs; existingDestination.sourceMapping = destination.sourceMapping; } if (destination.ignore) { - // only set ignore when not yet set, once ignored is ignored forever. + // only set ignore when not yet set, once ignored is ignored forever. existingDestination.ignore = destination.ignore; } if (destination.conditionFunction) { @@ -1654,6 +1667,9 @@ var AutoMapperJs; for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) { result += sourcePropertyNameParts[index].charAt(0).toUpperCase() + sourcePropertyNameParts[index].substr(1); + //if (index < (length - 1)) { + // this.separatorCharacter; + //} } return result; }; diff --git a/dist/automapper.js.map b/dist/automapper.js.map index fe3d7ec..73edc14 100644 --- a/dist/automapper.js.map +++ b/dist/automapper.js.map @@ -1 +1 @@ -{"version":3,"sources":["AutoMapperHelper.js","AutoMapperValidator.js","AutoMapperEnumerations.js","AutoMapperBase.js","AsyncAutoMapper.js","AutoMapper.js","Profile.js","TypeConverter.js","naming-conventions/CamelCaseNamingConvention.js","naming-conventions/PascalCaseNamingConvention.js"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACpOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACzJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACvPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACzPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AClnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AC9BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"automapper.js","sourcesContent":["/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper helper functions\n */\n var AutoMapperHelper = (function () {\n function AutoMapperHelper() {\n }\n AutoMapperHelper.getClassName = function (classType) {\n if (classType && classType.name) {\n return classType.name;\n }\n // source: http://stackoverflow.com/a/13914278/702357\n if (classType && classType.constructor) {\n var className = classType.toString();\n if (className) {\n // classType.toString() is \"function classType (...) { ... }\"\n var matchParts = className.match(/function\\s*(\\w+)/);\n if (matchParts && matchParts.length === 2) {\n return matchParts[1];\n }\n }\n // for browsers which have name property in the constructor\n // of the object, such as chrome\n if (classType.constructor.name) {\n return classType.constructor.name;\n }\n if (classType.constructor.toString()) {\n var str = classType.constructor.toString();\n if (str.charAt(0) === '[') {\n // executed if the return of object.constructor.toString() is \"[object objectClass]\"\n var arr = str.match(/\\[\\w+\\s*(\\w+)\\]/);\n }\n else {\n // executed if the return of object.constructor.toString() is \"function objectClass () {}\"\n // (IE and Firefox)\n var arr = str.match(/function\\s*(\\w+)/);\n }\n if (arr && arr.length === 2) {\n return arr[1];\n }\n }\n }\n throw new Error(\"Unable to extract class name from type '\" + classType + \"'\");\n };\n AutoMapperHelper.getFunctionParameters = function (functionStr) {\n var stripComments = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg;\n var argumentNames = /([^\\s,]+)/g;\n var functionString = functionStr.replace(stripComments, '');\n var functionParameterNames = functionString.slice(functionString.indexOf('(') + 1, functionString.indexOf(')')).match(argumentNames);\n if (functionParameterNames === null) {\n functionParameterNames = new Array();\n }\n return functionParameterNames;\n };\n AutoMapperHelper.handleCurrying = function (func, args, closure) {\n var argumentsStillToCome = func.length - args.length;\n // saved accumulator array\n // NOTE BL this does not deep copy array objects, only the array itself; should side effects occur, please report (or refactor).\n var argumentsCopy = Array.prototype.slice.apply(args);\n function accumulator(moreArgs, alreadyProvidedArgs, stillToCome) {\n var previousAlreadyProvidedArgs = alreadyProvidedArgs.slice(0); // to reset\n var previousStillToCome = stillToCome; // to reset\n for (var i = 0; i < moreArgs.length; i++, stillToCome--) {\n alreadyProvidedArgs[alreadyProvidedArgs.length] = moreArgs[i];\n }\n if (stillToCome - moreArgs.length <= 0) {\n var functionCallResult = func.apply(closure, alreadyProvidedArgs);\n // reset vars, so curried function can be applied to new params.\n alreadyProvidedArgs = previousAlreadyProvidedArgs;\n stillToCome = previousStillToCome;\n return functionCallResult;\n }\n else {\n return function () {\n // arguments are params, so closure bussiness is avoided.\n return accumulator(arguments, alreadyProvidedArgs.slice(0), stillToCome);\n };\n }\n }\n return accumulator([], argumentsCopy, argumentsStillToCome);\n };\n AutoMapperHelper.getMappingMetadataFromTransformationFunction = function (destination, func, sourceMapping) {\n if (typeof func !== 'function') {\n return {\n destination: destination,\n source: destination,\n transformation: AutoMapperHelper.getDestinationTransformation(func, false, sourceMapping, false),\n sourceMapping: sourceMapping,\n condition: null,\n ignore: false,\n async: false\n };\n }\n var functionStr = func.toString();\n var parameterNames = AutoMapperHelper.getFunctionParameters(functionStr);\n var optsParamName = parameterNames.length >= 1 ? parameterNames[0] : '';\n var source = sourceMapping\n ? destination\n : AutoMapperHelper.getMapFromString(functionStr, destination, optsParamName);\n var metadata = {\n destination: destination,\n source: source,\n transformation: AutoMapperHelper.getDestinationTransformation(func, true, sourceMapping, parameterNames.length === 2),\n sourceMapping: sourceMapping,\n condition: null,\n ignore: AutoMapperHelper.getIgnoreFromString(functionStr, destination),\n async: parameterNames.length === 2\n };\n // calling the member options function when used asynchronous would be too 'dangerous'.\n if (!metadata.async && AutoMapperHelper.getFunctionCallIndex(functionStr, 'condition', optsParamName) >= 0) {\n metadata.condition = AutoMapperHelper.getConditionFromFunction(func, source);\n }\n return metadata;\n };\n AutoMapperHelper.getDestinationTransformation = function (func, isFunction, sourceMapping, async) {\n if (!isFunction) {\n return {\n transformationType: AutoMapperJs.DestinationTransformationType.Constant,\n constant: func\n };\n }\n var transformation;\n if (sourceMapping) {\n if (async) {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.AsyncSourceMemberOptions,\n asyncSourceMemberConfigurationOptionsFunc: func\n };\n }\n else {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.SourceMemberOptions,\n sourceMemberConfigurationOptionsFunc: func\n };\n }\n }\n else {\n if (async) {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.AsyncMemberOptions,\n asyncMemberConfigurationOptionsFunc: func\n };\n }\n else {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.MemberOptions,\n memberConfigurationOptionsFunc: func\n };\n }\n }\n return transformation;\n };\n AutoMapperHelper.getIgnoreFromString = function (functionString, optionsParameterName) {\n var indexOfIgnore = AutoMapperHelper.getFunctionCallIndex(functionString, 'ignore', optionsParameterName);\n if (indexOfIgnore < 0) {\n return false;\n }\n var indexOfMapFromStart = functionString.indexOf('(', indexOfIgnore) + 1;\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\n return false;\n }\n var ignoreString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/\\r/g, '').replace(/\\n/g, '').trim();\n return ignoreString === null || ignoreString === ''\n ? true // .ignore()\n : false; // .ignore( -> unexpected content)\n };\n AutoMapperHelper.getMapFromString = function (functionString, defaultValue, optionsParameterName) {\n var indexOfMapFrom = AutoMapperHelper.getFunctionCallIndex(functionString, 'mapFrom', optionsParameterName);\n if (indexOfMapFrom < 0) {\n return defaultValue;\n }\n var indexOfMapFromStart = functionString.indexOf('(', indexOfMapFrom) + 1;\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\n return defaultValue;\n }\n var mapFromString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/'/g, '').replace(/\"/g, '').trim();\n return mapFromString === null || mapFromString === ''\n ? defaultValue\n : mapFromString;\n };\n AutoMapperHelper.getFunctionCallIndex = function (functionString, functionToLookFor, optionsParameterName) {\n var indexOfFunctionCall = functionString.indexOf(optionsParameterName + '.' + functionToLookFor);\n if (indexOfFunctionCall < 0) {\n indexOfFunctionCall = functionString.indexOf('.' + functionToLookFor);\n }\n return indexOfFunctionCall;\n };\n AutoMapperHelper.getConditionFromFunction = function (func, sourceProperty) {\n // Since we are calling the valueOrFunction function to determine whether to ignore or map from another property, we\n // want to prevent the call to be error prone when the end user uses the '(opts)=> opts.sourceObject.sourcePropertyName'\n // syntax. We don't actually have a source object when creating a mapping; therefore, we 'stub' a source object for the\n // function call.\n var sourceObject = {};\n sourceObject[sourceProperty] = {};\n var condition;\n // calling the function will result in calling our stubbed ignore() and mapFrom() functions if used inside the function.\n var configFuncOptions = {\n ignore: function () {\n // do nothing\n },\n condition: function (predicate) {\n condition = predicate;\n },\n mapFrom: function (sourcePropertyName) {\n // do nothing\n },\n sourceObject: sourceObject,\n sourcePropertyName: sourceProperty,\n intermediatePropertyValue: {}\n };\n try {\n func(configFuncOptions);\n }\n catch (exc) {\n }\n return condition;\n };\n return AutoMapperHelper;\n }());\n AutoMapperJs.AutoMapperHelper = AutoMapperHelper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperHelper.js.map\n","/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper configuration validator.\n */\n var AutoMapperValidator = (function () {\n function AutoMapperValidator() {\n }\n /**\n * Validates mapping configuration by dry-running. Since JS does not\n * fully support typing, it only checks if properties match on both\n * sides. The function needs IMapping.sourceTypeClass and\n * IMapping.destinationTypeClass to function.\n * @param {boolean} strictMode Whether or not to fail when properties\n * sourceTypeClass or destinationTypeClass\n * are unavailable.\n */\n AutoMapperValidator.assertConfigurationIsValid = function (mappings, strictMode) {\n for (var key in mappings) {\n if (!mappings.hasOwnProperty(key)) {\n continue;\n }\n AutoMapperValidator.assertMappingConfiguration(mappings[key], strictMode);\n }\n };\n AutoMapperValidator.assertMappingConfiguration = function (mapping, strictMode) {\n var mappingKey = mapping.sourceKey + \"=>\" + mapping.destinationKey;\n var sourceType = mapping.sourceTypeClass;\n var destinationType = mapping.destinationTypeClass;\n var sourceClassName = sourceType ? AutoMapperJs.AutoMapperHelper.getClassName(sourceType) : undefined;\n var destinationClassName = destinationType ? AutoMapperJs.AutoMapperHelper.getClassName(destinationType) : undefined;\n if (!sourceType || !destinationType) {\n if (strictMode === false) {\n return;\n }\n throw new Error(\"Mapping '\" + mappingKey + \"' cannot be validated, since mapping.sourceType or mapping.destinationType are unspecified.\");\n }\n var tryHandle = function (errorMessage) {\n if (errorMessage) {\n throw new Error(\"Mapping '\" + mappingKey + \"' is invalid: \" + errorMessage + \" (source: '\" + sourceClassName + \"', destination: '\" + destinationClassName + \"').\");\n }\n };\n var validatedMembers = new Array();\n var srcObj = new sourceType();\n var dstObj = new destinationType();\n // walk member mappings\n for (var _i = 0, _a = mapping.properties; _i < _a.length; _i++) {\n var property = _a[_i];\n tryHandle(AutoMapperValidator.validatePropertyMapping(property, property.name, srcObj, dstObj));\n validatedMembers.push(property.name);\n }\n // walk source members\n for (var srcMember in srcObj) {\n if (!srcObj.hasOwnProperty(srcMember)) {\n continue;\n }\n if (validatedMembers.indexOf(srcMember) >= 0) {\n // already validated\n continue;\n }\n tryHandle(AutoMapperValidator.validateProperty(srcMember, dstObj));\n validatedMembers.push(srcMember);\n }\n // walk destination members\n for (var dstMember in dstObj) {\n if (!dstObj.hasOwnProperty(dstMember)) {\n continue;\n }\n if (validatedMembers.indexOf(dstMember) >= 0) {\n // already validated\n continue;\n }\n tryHandle(\"Destination member '\" + dstMember + \"' does not exist on source type\");\n }\n // /* tslint:disable */\n // console.error(key);\n // /* tslint:enable */ \n };\n AutoMapperValidator.validatePropertyMapping = function (propertyMapping, member, srcObj, dstObj) {\n // awkward way of locating sourceMapping ;) ...\n var destinationProperty = AutoMapperValidator.getDestinationProperty(propertyMapping.destinationPropertyName, propertyMapping);\n return destinationProperty.sourceMapping\n ? AutoMapperValidator.validateSourcePropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj)\n : AutoMapperValidator.validateDestinationPropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj);\n };\n AutoMapperValidator.validateSourcePropertyMapping = function (ropertyMapping, destinationProperty, member, srcObj, dstObj) {\n // a member for which configuration is provided, should exist.\n if (!srcObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is configured, but does not exist on source type\";\n }\n // an ignored source member should not exist on the destination type. \n if (destinationProperty.ignore) {\n if (dstObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is ignored, but does exist on destination type\";\n }\n return undefined;\n }\n // a mapped source member should exist on the destination type.\n if (!dstObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is configured to be mapped, but does not exist on destination type\";\n }\n //var dstMember = propertyMapping.destinationProperty;\n return undefined;\n };\n AutoMapperValidator.validateDestinationPropertyMapping = function (propertyMapping, destinationProperty, member, srcObj, dstObj) {\n // a member for which configuration is provided, should exist.\n if (!dstObj.hasOwnProperty(destinationProperty.name)) {\n return \"Destination member '\" + destinationProperty.destinationPropertyName + \"' is configured, but does not exist on destination type\";\n }\n // an ignored destination member should not exist on the source type. \n if (destinationProperty.ignore) {\n if (srcObj.hasOwnProperty(member)) {\n return \"Destination member '\" + member + \"' is ignored, but does exist on source type\";\n }\n return undefined;\n }\n // a mapped destination member should exist on the source type.\n if (!srcObj.hasOwnProperty(member)) {\n return \"Destination member '\" + member + \"' is configured to be mapped, but does not exist on source type\";\n }\n //var dstMember = propertyMapping.destinationProperty;\n return undefined;\n };\n AutoMapperValidator.validateProperty = function (srcMember, dstObj) {\n if (!dstObj.hasOwnProperty(srcMember)) {\n return \"Source member '\" + srcMember + \"' is configured to be mapped, but does not exist on destination type\";\n }\n return undefined;\n };\n AutoMapperValidator.getDestinationProperty = function (destinationPropertyName, existingSource) {\n if (existingSource.destination) {\n return existingSource.destination;\n }\n if (existingSource.children) {\n for (var _i = 0, _a = existingSource.children; _i < _a.length; _i++) {\n var child = _a[_i];\n var destination = this.getDestinationProperty(destinationPropertyName, child);\n if (destination) {\n return destination;\n }\n }\n }\n return null;\n };\n return AutoMapperValidator;\n }());\n AutoMapperJs.AutoMapperValidator = AutoMapperValidator;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperValidator.js.map\n","var AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var DestinationTransformationType;\n (function (DestinationTransformationType) {\n DestinationTransformationType[DestinationTransformationType[\"Constant\"] = 1] = \"Constant\";\n DestinationTransformationType[DestinationTransformationType[\"MemberOptions\"] = 2] = \"MemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"AsyncMemberOptions\"] = 4] = \"AsyncMemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"SourceMemberOptions\"] = 8] = \"SourceMemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"AsyncSourceMemberOptions\"] = 16] = \"AsyncSourceMemberOptions\";\n })(DestinationTransformationType = AutoMapperJs.DestinationTransformationType || (AutoMapperJs.DestinationTransformationType = {}));\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperEnumerations.js.map\n","/// \n/// \n/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper implementation, for both creating maps and performing maps. Comparable usage and functionality to the original\n * .NET AutoMapper library is the pursuit of this implementation.\n */\n var AutoMapperBase = (function () {\n function AutoMapperBase() {\n }\n AutoMapperBase.prototype.getMapping = function (mappings, sourceKey, destinationKey) {\n var srcKey = this.getKey(sourceKey);\n var dstKey = this.getKey(destinationKey);\n var mapping = mappings[srcKey + dstKey];\n if (!mapping) {\n throw new Error(\"Could not find map object with a source of \" + srcKey + \" and a destination of \" + dstKey);\n }\n return mapping;\n };\n AutoMapperBase.prototype.getKey = function (keyStringOrType) {\n if (typeof keyStringOrType === 'string') {\n return keyStringOrType;\n }\n else {\n return AutoMapperJs.AutoMapperHelper.getClassName(keyStringOrType);\n }\n };\n AutoMapperBase.prototype.isArray = function (sourceObject) {\n return sourceObject instanceof Array;\n };\n AutoMapperBase.prototype.handleArray = function (mapping, sourceArray, itemFunc) {\n var arrayLength = sourceArray.length;\n var destinationArray = new Array(sourceArray.length);\n for (var index = 0; index < arrayLength; index++) {\n var sourceObject = sourceArray[index];\n var destinationObject = void 0;\n if (sourceObject === null || sourceObject === undefined) {\n destinationObject = sourceObject;\n }\n else {\n destinationObject = this.createDestinationObject(mapping.destinationTypeClass);\n itemFunc(sourceObject, destinationObject);\n }\n destinationArray[index] = destinationObject;\n }\n return destinationArray;\n };\n AutoMapperBase.prototype.handleItem = function (mapping, sourceObject, destinationObject, propertyFunction) {\n // var sourceProperties: string[] = [];\n var atLeastOnePropertyMapped = false;\n // handle mapped properties ...\n for (var _i = 0, _a = mapping.properties; _i < _a.length; _i++) {\n var property = _a[_i];\n // sourceProperties.push(property.name);\n atLeastOnePropertyMapped = true;\n propertyFunction(property.name);\n }\n // .. and, after that, handle unmapped properties\n for (var sourcePropertyName in sourceObject) {\n if (!sourceObject.hasOwnProperty(sourcePropertyName)) {\n continue;\n }\n if (destinationObject[sourcePropertyName]) {\n // ... but, if the destination property already exists, don't map again (probably a mapFrom situation).\n continue;\n }\n // if (sourceProperties.indexOf(sourcePropertyName) >= 0) {\n // continue;\n // }\n atLeastOnePropertyMapped = true;\n propertyFunction(sourcePropertyName);\n }\n // return null/undefined sourceObject if no properties added\n if (!atLeastOnePropertyMapped && (sourceObject === null || sourceObject === undefined)) {\n return sourceObject;\n }\n return destinationObject;\n };\n AutoMapperBase.prototype.handleProperty = function (mapping, sourceObject, sourcePropertyName, destinationObject, transformFunction, autoMappingCallbackFunction) {\n // TODO Property mappings are already located before\n // TODO handleProperty seems only to be called when processing a mapped property.\n var propertyMappings = this.getPropertyMappings(mapping.properties, sourcePropertyName);\n if (propertyMappings.length > 0) {\n for (var _i = 0, propertyMappings_1 = propertyMappings; _i < propertyMappings_1.length; _i++) {\n var propertyMapping = propertyMappings_1[_i];\n this.processMappedProperty(mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction);\n }\n }\n else {\n this.handlePropertyWithAutoMapping(mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction);\n }\n };\n AutoMapperBase.prototype.setPropertyValue = function (mapping, destinationProperty, destinationObject, destinationPropertyValue) {\n if (mapping.forAllMemberMappings.length > 0) {\n for (var _i = 0, _a = mapping.forAllMemberMappings; _i < _a.length; _i++) {\n var forAllMemberMapping = _a[_i];\n forAllMemberMapping(destinationObject, destinationProperty.name, destinationPropertyValue);\n }\n }\n else {\n destinationObject[destinationProperty.name] = destinationPropertyValue;\n }\n };\n AutoMapperBase.prototype.setPropertyValueByName = function (mapping, destinationObject, destinationProperty, destinationPropertyValue) {\n if (mapping.forAllMemberMappings.length > 0) {\n for (var _i = 0, _a = mapping.forAllMemberMappings; _i < _a.length; _i++) {\n var forAllMemberMapping = _a[_i];\n forAllMemberMapping(destinationObject, destinationProperty, destinationPropertyValue);\n }\n }\n else {\n destinationObject[destinationProperty] = destinationPropertyValue;\n }\n };\n AutoMapperBase.prototype.createDestinationObject = function (destinationType) {\n // create empty destination object.\n return destinationType\n ? new destinationType()\n : {};\n };\n AutoMapperBase.prototype.shouldProcessDestination = function (destination, sourceObject) {\n if (destination.ignore) {\n // ignore ignored properties\n return false;\n }\n if (destination.conditionFunction) {\n // check for condition function, and, if there is ...\n if (destination.conditionFunction(sourceObject) === false) {\n // ... return when the condition is not met.\n return false;\n }\n }\n return true;\n };\n // protected throwMappingException(propertyMapping: IProperty, message: string): void {\n // throw new Error(`Cannot map '${propertyMapping.sourcePropertyName}' to '${propertyMapping.destinationPropertyName}' => ${message}`);\n // }\n AutoMapperBase.prototype.handlePropertyWithAutoMapping = function (mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction) {\n // no forMember mapping exists, auto map properties, except for the situation where ignoreAllNonExisting is specified.\n if (mapping.ignoreAllNonExisting) {\n return;\n }\n if (mapping.destinationTypeClass && Object.keys(destinationObject).indexOf(sourcePropertyName) < 0) {\n return;\n }\n var objectValue = null;\n var isNestedObject = false;\n if (typeof destinationObject[sourcePropertyName] === 'object' && destinationObject[sourcePropertyName]) {\n isNestedObject = (destinationObject[sourcePropertyName].constructor.name !== 'Object');\n if (isNestedObject) {\n this\n .createMap(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name)\n .convertToType(destinationObject[sourcePropertyName].constructor);\n objectValue = this.map(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name, sourceObject[sourcePropertyName]);\n }\n }\n // use profile mapping when specified; otherwise, specify source property name as destination property name.\n var destinationPropertyName = this.getDestinationPropertyName(mapping.profile, sourcePropertyName);\n var destinationPropertyValue = this.getDestinationPropertyValue(sourceObject, sourcePropertyName, objectValue, isNestedObject);\n this.setPropertyValueByName(mapping, destinationObject, destinationPropertyName, destinationPropertyValue);\n if (autoMappingCallbackFunction) {\n autoMappingCallbackFunction(destinationPropertyValue);\n }\n };\n AutoMapperBase.prototype.getDestinationPropertyValue = function (sourceObject, sourcePropertyName, objectValue, isNestedObject) {\n if (isNestedObject) {\n return objectValue;\n }\n return sourceObject ? sourceObject[sourcePropertyName] : null;\n };\n AutoMapperBase.prototype.getDestinationPropertyName = function (profile, sourcePropertyName) {\n if (!profile) {\n return sourcePropertyName;\n }\n // TODO BL no support yet for INamingConvention.splittingCharacter\n try {\n // First, split the source property name based on the splitting expression.\n // TODO BL Caching of RegExp splitting!\n var sourcePropertyNameParts = sourcePropertyName.split(profile.sourceMemberNamingConvention.splittingExpression);\n // NOTE BL For some reason, splitting by (my ;)) RegExp results in empty strings in the array; remove them.\n for (var index = sourcePropertyNameParts.length - 1; index >= 0; index--) {\n if (sourcePropertyNameParts[index] === '') {\n sourcePropertyNameParts.splice(index, 1);\n }\n }\n return profile.destinationMemberNamingConvention.transformPropertyName(sourcePropertyNameParts);\n }\n catch (error) {\n return sourcePropertyName;\n }\n };\n AutoMapperBase.prototype.getPropertyMappings = function (properties, sourcePropertyName) {\n var result = [];\n for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {\n var property = properties_1[_i];\n if (property.name === sourcePropertyName) {\n result.push(property);\n }\n }\n return result;\n };\n AutoMapperBase.prototype.processMappedProperty = function (mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction) {\n if (propertyMapping.children && propertyMapping.children.length > 0) {\n // always pass child source object, even if source object does not exist => \n // constant transformations should always pass. \n var childSourceObject = sourceObject ? sourceObject[propertyMapping.name] : null;\n for (var _i = 0, _a = propertyMapping.children; _i < _a.length; _i++) {\n var child = _a[_i];\n this.processMappedProperty(mapping, child, childSourceObject, child.name, transformFunction);\n return;\n }\n }\n var destination = propertyMapping.destination;\n // if (!propertyMapping.destination) {\n // // it makes no sense to handle a property without destination(s).\n // this.throwMappingException(propertyMapping, 'no destination object');\n // }\n var configurationOptions = this.createMemberConfigurationOptions(sourceObject, sourcePropertyName);\n transformFunction(destination, configurationOptions);\n };\n AutoMapperBase.prototype.createMemberConfigurationOptions = function (sourceObject, sourcePropertyName) {\n var memberConfigurationOptions = {\n mapFrom: function (sourcePropertyName) {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.mapFrom(...)' function.\n },\n condition: function (predicate) {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.condition(...)' function.\n },\n ignore: function () {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.ignore()' function.\n },\n sourceObject: sourceObject,\n sourcePropertyName: sourcePropertyName,\n intermediatePropertyValue: sourceObject ? sourceObject[sourcePropertyName] : sourceObject\n };\n return memberConfigurationOptions;\n };\n return AutoMapperBase;\n }());\n AutoMapperJs.AutoMapperBase = AutoMapperBase;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperBase.js.map\n","/// \n/// \n/// \n/// \n/// \nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AsyncAutoMapper implementation, for asynchronous mapping support when using AutoMapper.\n */\n var AsyncAutoMapper = (function (_super) {\n __extends(AsyncAutoMapper, _super);\n function AsyncAutoMapper() {\n var _this = _super.call(this) || this;\n AsyncAutoMapper.asyncInstance = _this;\n return _this;\n }\n AsyncAutoMapper.prototype.createMap = function (sourceKeyOrType, destinationKeyOrType) {\n throw new Error('Method AsyncAutoMapper.createMap is not implemented.');\n };\n AsyncAutoMapper.prototype.createMapForMember = function (mapping, property) {\n var _this = this;\n mapping.async = true;\n mapping.mapItemFunction = function (m, srcObj, dstObj, cb) { return _this.mapItem(m, srcObj, dstObj, cb); };\n // property.async = true;\n // property.conversionValuesAndFunctions.push(func);\n };\n AsyncAutoMapper.prototype.createMapConvertUsing = function (mapping, converterFunction) {\n var _this = this;\n mapping.async = true;\n mapping.typeConverterFunction = converterFunction;\n mapping.mapItemFunction = function (m, srcObj, dstObj, cb) { return _this.mapItemUsingTypeConverter(m, srcObj, dstObj, cb); };\n };\n AsyncAutoMapper.prototype.map = function (mappings, sourceKey, destinationKey, sourceObject, callback) {\n var _this = this;\n switch (arguments.length) {\n case 5:\n this.mapWithMapping(_super.prototype.getMapping.call(this, mappings, sourceKey, destinationKey), sourceObject, callback);\n return;\n // provide performance optimized (preloading) currying support.\n case 4:\n return function (cb) { return _this.mapWithMapping(_super.prototype.getMapping.call(_this, mappings, sourceKey, destinationKey), sourceObject, cb); };\n case 3:\n return function (srcObj, cb) { return _this.mapWithMapping(_super.prototype.getMapping.call(_this, mappings, sourceKey, destinationKey), srcObj, cb); };\n case 2:\n return function (dstKey, srcObj, cb) { return _this.map(mappings, sourceKey, dstKey, srcObj, cb); };\n default:\n throw new Error('The AsyncAutoMapper.map function expects between 2 and 5 parameters, you provided ' + arguments.length + '.');\n }\n };\n AsyncAutoMapper.prototype.mapWithMapping = function (mapping, sourceObject, callback) {\n if (_super.prototype.isArray.call(this, sourceObject)) {\n this.mapArray(mapping, sourceObject, callback);\n return;\n }\n return mapping.mapItemFunction(mapping, sourceObject, _super.prototype.createDestinationObject.call(this, mapping.destinationTypeClass), callback);\n };\n /**\n * Execute a mapping from the source array to a new destination array with explicit mapping configuration and supplied mapping options (using createMap).\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceArray The source array to map.\n * @returns {Array} Destination array.\n */\n AsyncAutoMapper.prototype.mapArray = function (mapping, sourceArray, callback) {\n var callbacksToGo = 0;\n var destinationArray = _super.prototype.handleArray.call(this, mapping, sourceArray, function (sourceObject, destinationObject) {\n callbacksToGo++;\n mapping.mapItemFunction(mapping, sourceObject, destinationObject, function (result) {\n callbacksToGo--;\n });\n });\n var waitForCallbackToSend = function () {\n if (callbacksToGo === 0) {\n callback(destinationArray);\n }\n else {\n setTimeout(function () {\n waitForCallbackToSend();\n }, 10 * callbacksToGo);\n }\n };\n waitForCallbackToSend();\n };\n AsyncAutoMapper.prototype.mapItemUsingTypeConverter = function (mapping, sourceObject, destinationObject, callback) {\n var resolutionContext = {\n sourceValue: sourceObject,\n destinationValue: destinationObject\n };\n mapping.typeConverterFunction(resolutionContext, callback);\n };\n /**\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceObject The source object to map.\n * @param destinationObject The destination object to map to.\n * @param callback The callback to call after async mapping has been executed.\n */\n AsyncAutoMapper.prototype.mapItem = function (mapping, sourceObject, destinationObject, callback) {\n var _this = this;\n var callbacksToGo = 0;\n _super.prototype.handleItem.call(this, mapping, sourceObject, destinationObject, function (sourceProperty) {\n callbacksToGo++;\n _this.mapProperty(mapping, sourceObject, sourceProperty, destinationObject, function (result) {\n callbacksToGo--;\n });\n });\n var waitForCallbackToSend = function () {\n if (callbacksToGo === 0) {\n callback(destinationObject);\n }\n else {\n setTimeout(function () {\n waitForCallbackToSend();\n }, 10 * callbacksToGo);\n }\n };\n waitForCallbackToSend();\n };\n /**\n * Execute a mapping from the source object property to the destination object property with explicit mapping configuration and supplied mapping options.\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceObject The source object to map.\n * @param sourcePropertyName The source property to map.\n * @param destinationObject The destination object to map to.\n * @param callback The callback to call after async property mapping has been executed.\n */\n AsyncAutoMapper.prototype.mapProperty = function (mapping, sourceObject, sourceProperty, destinationObject, callback) {\n var _this = this;\n _super.prototype.handleProperty.call(this, mapping, sourceObject, sourceProperty, destinationObject, function (destinationProperty, options) {\n _this.transform(mapping, sourceObject, destinationProperty, destinationObject, options, function (destinationPropertyValue, success) {\n callback(destinationPropertyValue);\n });\n }, function (destinationPropertyValue) {\n callback(destinationPropertyValue);\n });\n };\n AsyncAutoMapper.prototype.transform = function (mapping, sourceObject, destinationProperty, destinationObject, options, callback) {\n var _this = this;\n var childDestinationProperty = destinationProperty.child;\n if (childDestinationProperty) {\n var childDestinationObject = destinationObject[destinationProperty.name];\n if (!childDestinationObject) {\n // no child source object? create. \n childDestinationObject = {};\n }\n // transform child by recursively calling the transform function.\n this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options, function (callbackValue, success) {\n if (success) {\n // only set child destination object when transformation has been successful.\n destinationObject[destinationProperty.name] = childDestinationObject;\n }\n callback(options.intermediatePropertyValue, success);\n });\n return;\n }\n if (!_super.prototype.shouldProcessDestination.call(this, destinationProperty, sourceObject)) {\n callback(undefined /* opts.intermediatePropertyValue */, false);\n return;\n }\n // actually transform destination property.\n this.processTransformations(destinationProperty, destinationProperty.transformations, options, function (callbackValue, success) {\n if (success) {\n _super.prototype.setPropertyValue.call(_this, mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\n }\n callback(options.intermediatePropertyValue, success);\n });\n };\n AsyncAutoMapper.prototype.processTransformations = function (property, transformations, options, callback) {\n var _this = this;\n if (transformations.length === 0) {\n callback(options.intermediatePropertyValue, true);\n return;\n }\n var transformation = transformations[0];\n this.processTransformation(property, transformation, options, function (callbackValue, success) {\n if (!success) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n _this.processTransformations(property, transformations.slice(1), options, callback);\n });\n };\n AsyncAutoMapper.prototype.processTransformation = function (property, transformation, options, callback) {\n switch (transformation.transformationType) {\n case AutoMapperJs.DestinationTransformationType.Constant:\n options.intermediatePropertyValue = transformation.constant;\n callback(options.intermediatePropertyValue, true);\n return;\n case AutoMapperJs.DestinationTransformationType.MemberOptions: {\n var result = transformation.memberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n }\n case AutoMapperJs.DestinationTransformationType.SourceMemberOptions: {\n var result = transformation.sourceMemberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n }\n case AutoMapperJs.DestinationTransformationType.AsyncMemberOptions:\n transformation.asyncMemberConfigurationOptionsFunc(options, function (result) {\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n });\n return;\n case AutoMapperJs.DestinationTransformationType.AsyncSourceMemberOptions:\n transformation.asyncSourceMemberConfigurationOptionsFunc(options, function (result) {\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n });\n return;\n default:\n // TODO: this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation}`);\n callback(options.intermediatePropertyValue, false);\n return;\n }\n };\n return AsyncAutoMapper;\n }(AutoMapperJs.AutoMapperBase));\n AsyncAutoMapper.asyncInstance = new AsyncAutoMapper();\n AutoMapperJs.AsyncAutoMapper = AsyncAutoMapper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AsyncAutoMapper.js.map\n","/// \n/// \n/// \n/// \n/// \n/// \n/// \nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var AutoMapper = (function (_super) {\n __extends(AutoMapper, _super);\n /**\n * This class is intended to be a Singleton. Preferrably use getInstance()\n * function instead of using the constructor directly from code.\n */\n function AutoMapper() {\n var _this = _super.call(this) || this;\n if (AutoMapper._instance) {\n return AutoMapper._instance;\n }\n else {\n AutoMapper._instance = _this;\n _this._profiles = {};\n _this._mappings = {};\n _this._asyncMapper = new AutoMapperJs.AsyncAutoMapper();\n }\n return _this;\n }\n AutoMapper.getInstance = function () {\n return AutoMapper._instance;\n };\n /**\n * Initializes the mapper with the supplied configuration.\n * @param {(config: IConfiguration) => void} configFunction Configuration function to call.\n */\n AutoMapper.prototype.initialize = function (configFunction) {\n var that = this;\n var configuration = {\n addProfile: function (profile) {\n profile.configure();\n that._profiles[profile.profileName] = profile;\n },\n createMap: function (sourceKey, destinationKey) {\n // pass through using arguments to keep createMap's currying support fully functional.\n return that.createMap.apply(that, arguments);\n }\n };\n configFunction(configuration);\n };\n /**\n * Create a mapping profile.\n * @param {string} sourceKey The map source key.\n * @param {string} destinationKey The map destination key.\n * @returns {Core.ICreateMapFluentFunctions}\n */\n AutoMapper.prototype.createMap = function (sourceKeyOrType, destinationKeyOrType) {\n // provide currying support.\n if (arguments.length < 2) {\n return AutoMapperJs.AutoMapperHelper.handleCurrying(this.createMap, arguments, this);\n }\n var mapping = this.createMappingObjectForGivenKeys(sourceKeyOrType, destinationKeyOrType);\n return this.createMapGetFluentApiFunctions(mapping);\n };\n /**\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param sourceKey Source key, for instance the source type name.\n * @param destinationKey Destination key, for instance the destination type name.\n * @param sourceObject The source object to map.\n * @returns {any} Destination object.\n */\n AutoMapper.prototype.map = function (sourceKeyOrType, destinationKeyOrType, sourceObject) {\n var _this = this;\n if (arguments.length === 3) {\n return this.mapInternal(_super.prototype.getMapping.call(this, this._mappings, sourceKeyOrType, destinationKeyOrType), sourceObject);\n }\n // provide performance optimized (preloading) currying support.\n if (arguments.length === 2) {\n return function (srcObj) { return _this.mapInternal(_super.prototype.getMapping.call(_this, _this._mappings, sourceKeyOrType, destinationKeyOrType), srcObj); };\n }\n if (arguments.length === 1) {\n return function (dstKey, srcObj) { return _this.map(sourceKeyOrType, dstKey, srcObj); };\n }\n return function (srcKey, dstKey, srcObj) { return _this.map(srcKey, dstKey, srcObj); };\n };\n /**\n * Execute an asynchronous mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param sourceKey Source key, for instance the source type name.\n * @param destinationKey Destination key, for instance the destination type name.\n * @param sourceObject The source object to map.\n * @param {IMapCallback} callback The callback to call when asynchronous mapping is complete.\n */\n AutoMapper.prototype.mapAsync = function (sourceKeyOrType, destinationKeyOrType, sourceObject, callback) {\n switch (arguments.length) {\n case 4:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject, callback);\n case 3:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject);\n case 2:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType);\n case 1:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType);\n default:\n throw new Error('The mapAsync function expects between 1 and 4 parameters, you provided ' + arguments.length + '.');\n }\n };\n /**\n * Validates mapping configuration by dry-running. Since JS does not fully support typing, it only checks if properties match on both\n * sides. The function needs IMapping.sourceTypeClass and IMapping.destinationTypeClass to function.\n * @param {boolean} strictMode Whether or not to fail when properties sourceTypeClass or destinationTypeClass are unavailable.\n */\n AutoMapper.prototype.assertConfigurationIsValid = function (strictMode) {\n if (strictMode === void 0) { strictMode = true; }\n AutoMapperJs.AutoMapperValidator.assertConfigurationIsValid(this._mappings, strictMode);\n };\n AutoMapper.prototype.createMapForAllMembers = function (mapping, fluentFunc, func) {\n mapping.forAllMemberMappings.push(func);\n return fluentFunc;\n };\n AutoMapper.prototype.createMapIgnoreAllNonExisting = function (mapping, fluentFunc) {\n mapping.ignoreAllNonExisting = true;\n return fluentFunc;\n };\n AutoMapper.prototype.createMapConvertToType = function (mapping, fluentFunc, typeClass) {\n if (mapping.destinationTypeClass) {\n throw new Error('Destination type class can only be set once.');\n }\n mapping.destinationTypeClass = typeClass;\n return fluentFunc;\n };\n AutoMapper.prototype.createMapConvertUsing = function (mapping, tcClassOrFunc) {\n var _this = this;\n var configureSynchronousConverterFunction = function (converterFunc) {\n if (!converterFunc || AutoMapperJs.AutoMapperHelper.getFunctionParameters(converterFunc.toString()).length !== 1) {\n throw new Error('The function provided does not provide exactly one (resolutionContext) parameter.');\n }\n mapping.typeConverterFunction = converterFunc;\n mapping.mapItemFunction = function (m, srcObj, dstObj) { return _this.mapItemUsingTypeConverter(m, srcObj, dstObj); };\n };\n try {\n // check if sync: TypeConverter instance\n if (tcClassOrFunc instanceof AutoMapperJs.TypeConverter) {\n configureSynchronousConverterFunction(tcClassOrFunc.convert);\n return;\n }\n var functionParameters = AutoMapperJs.AutoMapperHelper.getFunctionParameters(tcClassOrFunc.toString());\n switch (functionParameters.length) {\n case 0:\n // check if sync: TypeConverter class definition\n var typeConverter;\n try {\n typeConverter = new tcClassOrFunc();\n }\n catch (e) {\n }\n if (typeConverter instanceof AutoMapperJs.TypeConverter) {\n configureSynchronousConverterFunction(typeConverter.convert);\n return;\n }\n break;\n case 1:\n // sync: function with resolutionContext parameter\n configureSynchronousConverterFunction(tcClassOrFunc);\n return;\n case 2:\n // check if async: function with resolutionContext and callback parameters\n this._asyncMapper.createMapConvertUsing(mapping, tcClassOrFunc);\n return;\n }\n // okay, just try feeding the function to the configure function anyway...\n configureSynchronousConverterFunction(tcClassOrFunc);\n }\n catch (e) {\n throw new Error(\"The value provided for typeConverterClassOrFunction is invalid. \" + e);\n }\n };\n AutoMapper.prototype.createMapWithProfile = function (mapping, profileName) {\n // check if given profile exists\n var profile = this._profiles[profileName];\n if (typeof profile === 'undefined' || profile.profileName !== profileName) {\n throw new Error(\"Could not find profile with profile name '\" + profileName + \"'.\");\n }\n mapping.profile = profile;\n // merge mappings\n this.createMapWithProfileMergeMappings(mapping, profileName);\n };\n AutoMapper.prototype.createMapWithProfileMergeMappings = function (mapping, profileName) {\n var profileMappingKey = profileName + \"=>\" + mapping.sourceKey + profileName + \"=>\" + mapping.destinationKey;\n var profileMapping = this._mappings[profileMappingKey];\n if (!profileMapping) {\n return;\n }\n // append forAllMemberMappings calls to the original array.\n if (profileMapping.forAllMemberMappings.length > 0) {\n (_a = mapping.forAllMemberMappings).push.apply(_a, profileMapping.forAllMemberMappings);\n }\n // overwrite original type converter function\n if (profileMapping.typeConverterFunction) {\n mapping.typeConverterFunction = profileMapping.typeConverterFunction;\n mapping.mapItemFunction = profileMapping.mapItemFunction;\n }\n // overwrite original type converter function\n if (profileMapping.destinationTypeClass) {\n mapping.destinationTypeClass = profileMapping.destinationTypeClass;\n }\n // walk through all the profile's property mappings\n for (var _i = 0, _b = profileMapping.properties; _i < _b.length; _i++) {\n var property = _b[_i];\n // TODO Awkward way of locating sourceMapping ;) ...\n var sourceMapping = this.getDestinationProperty(property.destinationPropertyName, property).sourceMapping;\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\n mapping.properties.push(property);\n }\n }\n var _a;\n };\n AutoMapper.prototype.mapInternal = function (mapping, sourceObject) {\n if (mapping.async) {\n throw new Error('Impossible to use asynchronous mapping using automapper.map(); use automapper.mapAsync() instead.');\n }\n if (_super.prototype.isArray.call(this, sourceObject)) {\n return this.mapArray(mapping, sourceObject);\n }\n return mapping.mapItemFunction(mapping, sourceObject, _super.prototype.createDestinationObject.call(this, mapping.destinationTypeClass));\n };\n AutoMapper.prototype.mapArray = function (mapping, sourceArray) {\n var destinationArray = _super.prototype.handleArray.call(this, mapping, sourceArray, function (sourceObject, destinationObject) {\n mapping.mapItemFunction(mapping, sourceObject, destinationObject);\n });\n return destinationArray;\n };\n AutoMapper.prototype.mapItem = function (mapping, sourceObject, destinationObject) {\n var _this = this;\n destinationObject = _super.prototype.handleItem.call(this, mapping, sourceObject, destinationObject, function (propertyName) {\n _this.mapProperty(mapping, sourceObject, destinationObject, propertyName);\n });\n return destinationObject;\n };\n AutoMapper.prototype.mapItemUsingTypeConverter = function (mapping, sourceObject, destinationObject, arrayIndex) {\n var resolutionContext = {\n sourceValue: sourceObject,\n destinationValue: destinationObject\n };\n return mapping.typeConverterFunction(resolutionContext);\n };\n AutoMapper.prototype.mapProperty = function (mapping, sourceObject, destinationObject, sourceProperty) {\n var _this = this;\n _super.prototype.handleProperty.call(this, mapping, sourceObject, sourceProperty, destinationObject, function (destinationProperty, options) {\n return _this.transform(mapping, sourceObject, destinationProperty, destinationObject, options);\n });\n };\n AutoMapper.prototype.transform = function (mapping, sourceObject, destinationProperty, destinationObject, options) {\n var childDestinationProperty = destinationProperty.child;\n if (childDestinationProperty) {\n var childDestinationObject = destinationObject[destinationProperty.name];\n if (!childDestinationObject) {\n // no child source object? create. \n childDestinationObject = {};\n }\n // transform child by recursively calling the transform function.\n var transformed = this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options /*, callback*/);\n if (transformed) {\n // only set child destination object when transformation has been successful.\n destinationObject[destinationProperty.name] = childDestinationObject;\n }\n return transformed;\n }\n if (!_super.prototype.shouldProcessDestination.call(this, destinationProperty, sourceObject)) {\n return false;\n }\n // actually transform destination property.\n for (var _i = 0, _a = destinationProperty.transformations; _i < _a.length; _i++) {\n var transformation = _a[_i];\n if (!this.processTransformation(destinationProperty, transformation, options)) {\n return false;\n }\n }\n _super.prototype.setPropertyValue.call(this, mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\n return true;\n };\n AutoMapper.prototype.processTransformation = function (property, transformation, options) {\n switch (transformation.transformationType) {\n case AutoMapperJs.DestinationTransformationType.Constant:\n options.intermediatePropertyValue = transformation.constant;\n return true;\n case AutoMapperJs.DestinationTransformationType.MemberOptions: {\n var result = transformation.memberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n return false;\n }\n return true;\n }\n case AutoMapperJs.DestinationTransformationType.SourceMemberOptions: {\n var result = transformation.sourceMemberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n return false;\n }\n return true;\n }\n default:\n // this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation.transformationType}`);\n return false;\n }\n };\n AutoMapper.prototype.createMappingObjectForGivenKeys = function (srcKeyOrType, dstKeyOrType) {\n var _this = this;\n var mapping = {\n sourceKey: _super.prototype.getKey.call(this, srcKeyOrType),\n destinationKey: _super.prototype.getKey.call(this, dstKeyOrType),\n forAllMemberMappings: new Array(),\n properties: [],\n typeConverterFunction: undefined,\n mapItemFunction: function (m, srcObj, dstObj) { return _this.mapItem(m, srcObj, dstObj); },\n sourceTypeClass: (typeof srcKeyOrType === 'string' ? undefined : srcKeyOrType),\n destinationTypeClass: (typeof dstKeyOrType === 'string' ? undefined : dstKeyOrType),\n profile: undefined,\n async: false\n };\n this._mappings[mapping.sourceKey + mapping.destinationKey] = mapping;\n return mapping;\n };\n AutoMapper.prototype.createMapGetFluentApiFunctions = function (mapping) {\n var _this = this;\n // create a fluent interface / method chaining (e.g. automapper.createMap().forMember().forMember() ...)\n var fluentFunc = {\n forMember: function (prop, valFunc) {\n return _this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: valFunc, sourceMapping: false, fluentFunctions: fluentFunc });\n },\n forSourceMember: function (prop, cfgFunc) {\n return _this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: cfgFunc, sourceMapping: true, fluentFunctions: fluentFunc });\n },\n forAllMembers: function (func) {\n return _this.createMapForAllMembers(mapping, fluentFunc, func);\n },\n ignoreAllNonExisting: function () { return _this.createMapIgnoreAllNonExisting(mapping, fluentFunc); },\n convertToType: function (type) { return _this.createMapConvertToType(mapping, fluentFunc, type); },\n convertUsing: function (tcClassOrFunc) {\n return _this.createMapConvertUsing(mapping, tcClassOrFunc);\n },\n withProfile: function (profile) { return _this.createMapWithProfile(mapping, profile); }\n };\n return fluentFunc;\n };\n AutoMapper.prototype.createMapForMember = function (parameters) {\n var mapping = parameters.mapping, propertyName = parameters.propertyName, transformation = parameters.transformation, sourceMapping = parameters.sourceMapping, fluentFunctions = parameters.fluentFunctions;\n // extract source/destination property names\n var metadata = AutoMapperJs.AutoMapperHelper.getMappingMetadataFromTransformationFunction(propertyName, transformation, sourceMapping);\n this.validateForMemberParameters(metadata);\n var source = metadata.source, destination = metadata.destination;\n // create property (regardless of current existance)\n var property = this.createSourceProperty(metadata, null);\n // merge with existing property or add property\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\n mapping.properties.push(property);\n }\n if (metadata.async) {\n this._asyncMapper.createMapForMember(mapping, this.findProperty(property.name, mapping.properties));\n }\n return fluentFunctions;\n };\n AutoMapper.prototype.validateForMemberParameters = function (metadata) {\n if (!metadata.sourceMapping) {\n return;\n }\n // validate forSourceMember parameters\n if (metadata.transformation.transformationType === AutoMapperJs.DestinationTransformationType.Constant) {\n throw new Error('Configuration of forSourceMember has to be a function with one (sync) or two (async) options parameters.');\n }\n };\n AutoMapper.prototype.createSourceProperty = function (metadata, parent) {\n var level = !parent ? 0 : parent.level + 1;\n var sourceNameParts = metadata.source.split('.');\n var source = {\n name: sourceNameParts[level],\n sourcePropertyName: metadata.source,\n destinationPropertyName: metadata.destination,\n parent: parent,\n level: level,\n children: [],\n destination: null\n };\n if ((level + 1) < sourceNameParts.length) {\n // recursively add child source properties ...\n var child = this.createSourceProperty(metadata, source);\n if (child) {\n source.children.push(child);\n }\n source.destination = null;\n }\n else {\n // ... or (!) add destination\n source.destination = this.createDestinationProperty(metadata, null);\n }\n return source;\n };\n AutoMapper.prototype.createDestinationProperty = function (metadata, parent) {\n var level = !parent ? 0 : parent.level + 1;\n var destinationNameParts = metadata.destination.split('.');\n var destination = {\n name: destinationNameParts[level],\n sourcePropertyName: metadata.source,\n destinationPropertyName: metadata.destination,\n parent: parent,\n level: level,\n child: null,\n transformations: [],\n conditionFunction: null,\n ignore: false,\n sourceMapping: false\n };\n if ((level + 1) < destinationNameParts.length) {\n // recursively add child destination properties\n destination.child = this.createDestinationProperty(metadata, destination);\n }\n else {\n // add/merge properties\n destination.sourceMapping = metadata.sourceMapping;\n destination.conditionFunction = metadata.condition;\n destination.ignore = metadata.ignore;\n destination.transformations.push(metadata.transformation);\n }\n return destination;\n };\n AutoMapper.prototype.mergeSourceProperty = function (property, existingProperties, sourceMapping) {\n // find source property\n var existing = sourceMapping\n ? this.findProperty(property.name, existingProperties)\n : this.matchSourcePropertyByDestination(property, existingProperties);\n if (!existing) {\n return false;\n }\n if (property.destination) {\n if (existing.children.length > 0) {\n var existingDestination = this.getDestinationProperty(existing.destinationPropertyName, existing);\n // existing is (further) nested => rebase and/or merge\n if (this.handleMapFromProperties(property, existing)) {\n // merge and rebase existing destination to current source level\n if (!this.mergeDestinationProperty(property.destination, existingDestination)) {\n return false;\n }\n existing.destination = existingDestination;\n existing.children = [];\n return true;\n }\n // merge property.destination with existing mapFrom() destination (don't care about nesting depth here)\n return this.mergeDestinationProperty(property.destination, existingDestination);\n }\n // both are at same level => simple merge.\n if (!this.mergeDestinationProperty(property.destination, existing.destination)) {\n return false;\n }\n this.handleMapFromProperties(property, existing);\n return true;\n }\n // new source is (further) nested (has children).\n if (existing.children.length > 0) {\n // both have further nesting, delegate merging child(ren) by recursively calling this function.\n for (var _i = 0, _a = property.children; _i < _a.length; _i++) {\n var child = _a[_i];\n if (!this.mergeSourceProperty(child, existing.children, sourceMapping)) {\n return false;\n }\n }\n if (property.destinationPropertyName !== property.sourcePropertyName) {\n // this is a mapFrom() registration. It is handled using the nested source properties, \n // we only are responsible for syncing the name properties.\n existing.name = property.name;\n existing.sourcePropertyName = property.sourcePropertyName;\n }\n return true;\n }\n // existing is not (further) nested. this is always a mapFrom() situation. \n // if (property.sourcePropertyName !== existing.sourcePropertyName) {\n var newDestination = this.getDestinationProperty(existing.destinationPropertyName, property);\n if (property.destinationPropertyName !== property.sourcePropertyName) {\n // this is a mapFrom() registration. In that case:\n // 1) merge destinations, 2) add source child and 3) move destination to (youngest) child\n // NOTE special mergeDestinationProperty call => we use the new destination as 'target',\n // because that will save us trouble overwriting ;)...\n if (!this.mergeDestinationProperty(existing.destination, newDestination, true)) {\n return false;\n }\n existing.children = property.children;\n existing.name = property.name;\n existing.sourcePropertyName = property.sourcePropertyName;\n existing.destination = null;\n // TODO Should never be necessary (test): existing.destinationPropertyName = property.destinationPropertyName;\n return true;\n }\n // ... nope, it is a destination which has previously been registered using mapFrom. just merge\n return this.mergeDestinationProperty(newDestination, existing.destination);\n // }\n };\n /**\n * handle property naming when the current property to merge is a mapFrom property\n */\n AutoMapper.prototype.handleMapFromProperties = function (property, existingProperty) {\n if (property.destinationPropertyName === property.sourcePropertyName ||\n property.sourcePropertyName === existingProperty.sourcePropertyName) {\n return false;\n }\n // only overwrite name when a mapFrom situation applies\n existingProperty.name = property.name;\n existingProperty.sourcePropertyName = property.sourcePropertyName;\n // TODO Should never be necessary (test) => existingProperty.destinationPropertyName = property.destinationPropertyName;\n return true;\n };\n AutoMapper.prototype.getDestinationProperty = function (destinationPropertyName, existingSource) {\n if (existingSource.destination) {\n return existingSource.destination;\n }\n for (var _i = 0, _a = existingSource.children; _i < _a.length; _i++) {\n var child = _a[_i];\n var destination = this.getDestinationProperty(destinationPropertyName, child);\n if (destination) {\n return destination;\n }\n }\n return null;\n };\n AutoMapper.prototype.mergeDestinationProperty = function (destination, existingDestination, swapTransformations) {\n if (swapTransformations === void 0) { swapTransformations = false; }\n if (destination.child) {\n if (existingDestination.child) {\n // both have further nesting, delegate merging children by recursively calling this function.\n if (!this.mergeDestinationProperty(destination.child, existingDestination.child, swapTransformations)) {\n return false;\n }\n this.handleMapFromProperties(destination, existingDestination);\n return true;\n }\n // the current destination is not (further) nested. a destination property registration has one of both: \n // a) children or b) transformations. returning false will cause creating a duplicate source property entry instead.\n return false;\n }\n if (existingDestination.sourceMapping !== destination.sourceMapping &&\n existingDestination.sourcePropertyName !== destination.sourcePropertyName) {\n // unable to perform mapFrom() on a property which is being registered using forSourceMember.\n return false; // TODO: Unpredictable? Idea: throw new Error('Unable to perform mapFrom() on a property which is being registered using forSourceMember.');\n }\n // merge destination properties\n if (destination.sourceMapping) {\n // only set source mapping when not yet set to true, once source mapped is source mapped forever.\n // TODO Verify edge cases!\n existingDestination.sourceMapping = destination.sourceMapping;\n }\n if (destination.ignore) {\n // only set ignore when not yet set, once ignored is ignored forever. \n existingDestination.ignore = destination.ignore;\n }\n if (destination.conditionFunction) {\n // overwrite condition function by the latest one specified.\n existingDestination.conditionFunction = destination.conditionFunction;\n }\n var transformations = [];\n if (swapTransformations) {\n for (var _i = 0, _a = destination.transformations; _i < _a.length; _i++) {\n var transformation = _a[_i];\n transformations.push(transformation);\n }\n for (var _b = 0, _c = existingDestination.transformations; _b < _c.length; _b++) {\n var transformation = _c[_b];\n transformations.push(transformation);\n }\n }\n else {\n for (var _d = 0, _e = existingDestination.transformations; _d < _e.length; _d++) {\n var transformation = _e[_d];\n transformations.push(transformation);\n }\n for (var _f = 0, _g = destination.transformations; _f < _g.length; _f++) {\n var transformation = _g[_f];\n transformations.push(transformation);\n }\n }\n existingDestination.transformations = transformations;\n this.handleMapFromProperties(destination, existingDestination);\n return true;\n };\n AutoMapper.prototype.matchSourcePropertyByDestination = function (source, properties) {\n if (!properties) {\n return null;\n }\n for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {\n var property = properties_1[_i];\n if (property.destinationPropertyName === source.destinationPropertyName) {\n return property;\n }\n }\n return null;\n };\n AutoMapper.prototype.findProperty = function (name, properties) {\n if (!properties) {\n return null;\n }\n for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) {\n var property = properties_2[_i];\n if (property.name === name) {\n return property;\n }\n }\n return null;\n };\n return AutoMapper;\n }(AutoMapperJs.AutoMapperBase));\n AutoMapper._instance = new AutoMapper();\n AutoMapperJs.AutoMapper = AutoMapper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n// Add AutoMapper to the application's global scope. Of course, you could still use Core.AutoMapper.getInstance() as well.\nvar automapper = (function (app) {\n app.automapper = AutoMapperJs.AutoMapper.getInstance();\n return app.automapper;\n})(this);\n\n//# sourceMappingURL=AutoMapper.js.map\n","/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * Converts source type to destination type instead of normal member mapping\n */\n var Profile = (function () {\n function Profile() {\n }\n /**\n * Implement this method in a derived class and call the CreateMap method to associate that map with this profile.\n * Avoid calling the AutoMapper class / automapper instance from this method.\n */\n Profile.prototype.configure = function () {\n // do nothing\n };\n /**\n * Create a mapping profile.\n * @param {string} sourceKey The map source key.\n * @param {string} destinationKey The map destination key.\n * @returns {Core.ICreateMapFluentFunctions}\n */\n Profile.prototype.createMap = function (sourceKey, destinationKey) {\n var argsCopy = Array.prototype.slice.apply(arguments);\n for (var index = 0, length = argsCopy.length; index < length; index++) {\n if (argsCopy[index]) {\n // prefix sourceKey and destinationKey with 'profileName=>'\n argsCopy[index] = this.profileName + \"=>\" + argsCopy[index];\n }\n }\n // pass through using arguments to keep createMap's currying support fully functional.\n return automapper.createMap.apply(automapper, argsCopy);\n };\n return Profile;\n }());\n AutoMapperJs.Profile = Profile;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=Profile.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * Converts source type to destination type instead of normal member mapping\n */\n var TypeConverter = (function () {\n function TypeConverter() {\n }\n /**\n * Performs conversion from source to destination type.\n * @param {IResolutionContext} resolutionContext Resolution context.\n * @returns {any} Destination object.\n */\n TypeConverter.prototype.convert = function (resolutionContext) {\n // NOTE BL Unfortunately, TypeScript/JavaScript do not support abstract base classes.\n // This is just one way around, please convince me about a better solution.\n throw new Error('The TypeConverter.convert method is abstract. Use a TypeConverter extension class instead.');\n };\n return TypeConverter;\n }());\n AutoMapperJs.TypeConverter = TypeConverter;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=TypeConverter.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var CamelCaseNamingConvention = (function () {\n function CamelCaseNamingConvention() {\n this.splittingExpression = /(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\n this.separatorCharacter = '';\n }\n CamelCaseNamingConvention.prototype.transformPropertyName = function (sourcePropertyNameParts) {\n // Transform the splitted parts.\n var result = '';\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\n if (index === 0) {\n result += sourcePropertyNameParts[index].charAt(0).toLowerCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n else {\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n }\n return result;\n };\n return CamelCaseNamingConvention;\n }());\n AutoMapperJs.CamelCaseNamingConvention = CamelCaseNamingConvention;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=CamelCaseNamingConvention.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var PascalCaseNamingConvention = (function () {\n function PascalCaseNamingConvention() {\n this.splittingExpression = /(^[A-Z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\n this.separatorCharacter = '';\n }\n PascalCaseNamingConvention.prototype.transformPropertyName = function (sourcePropertyNameParts) {\n // Transform the splitted parts.\n var result = '';\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n return result;\n };\n return PascalCaseNamingConvention;\n }());\n AutoMapperJs.PascalCaseNamingConvention = PascalCaseNamingConvention;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=PascalCaseNamingConvention.js.map\n"]} \ No newline at end of file +{"version":3,"sources":["AutoMapperHelper.js","AutoMapperValidator.js","AutoMapperEnumerations.js","AutoMapperBase.js","AsyncAutoMapper.js","AutoMapper.js","Profile.js","TypeConverter.js","naming-conventions/CamelCaseNamingConvention.js","naming-conventions/PascalCaseNamingConvention.js"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACtOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACzJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACvPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AC9PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACxnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AC1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AC9BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"automapper.js","sourcesContent":["/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper helper functions\n */\n var AutoMapperHelper = (function () {\n function AutoMapperHelper() {\n }\n AutoMapperHelper.getClassName = function (classType) {\n if (classType && classType.name) {\n return classType.name;\n }\n // source: http://stackoverflow.com/a/13914278/702357\n if (classType && classType.constructor) {\n var className = classType.toString();\n if (className) {\n // classType.toString() is \"function classType (...) { ... }\"\n var matchParts = className.match(/function\\s*(\\w+)/);\n if (matchParts && matchParts.length === 2) {\n return matchParts[1];\n }\n }\n // for browsers which have name property in the constructor\n // of the object, such as chrome\n if (classType.constructor.name) {\n return classType.constructor.name;\n }\n if (classType.constructor.toString()) {\n var str = classType.constructor.toString();\n var regExpMatchArray = void 0;\n if (str.charAt(0) === '[') {\n // executed if the return of object.constructor.toString() is \"[object objectClass]\"\n regExpMatchArray = str.match(/\\[\\w+\\s*(\\w+)\\]/);\n }\n else {\n // executed if the return of object.constructor.toString() is \"function objectClass () {}\"\n // (IE and Firefox)\n regExpMatchArray = str.match(/function\\s*(\\w+)/);\n }\n if (regExpMatchArray && regExpMatchArray.length === 2) {\n return regExpMatchArray[1];\n }\n }\n }\n throw new Error(\"Unable to extract class name from type '\" + classType + \"'\");\n };\n AutoMapperHelper.getFunctionParameters = function (functionStr) {\n var stripComments = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg;\n var argumentNames = /([^\\s,]+)/g;\n var functionString = functionStr.replace(stripComments, '');\n var functionParameterNames = functionString.slice(functionString.indexOf('(') + 1, functionString.indexOf(')')).match(argumentNames);\n if (functionParameterNames === null) {\n functionParameterNames = new Array();\n }\n return functionParameterNames;\n };\n AutoMapperHelper.handleCurrying = function (func, args, closure) {\n var argumentsStillToCome = func.length - args.length;\n // saved accumulator array\n // NOTE BL this does not deep copy array objects, only the array itself; should side effects occur, please report (or refactor).\n var argumentsCopy = Array.prototype.slice.apply(args);\n function accumulator(moreArgs, alreadyProvidedArgs, stillToCome) {\n var previousAlreadyProvidedArgs = alreadyProvidedArgs.slice(0); // to reset\n var previousStillToCome = stillToCome; // to reset\n for (var i = 0; i < moreArgs.length; i++, stillToCome--) {\n alreadyProvidedArgs[alreadyProvidedArgs.length] = moreArgs[i];\n }\n if (stillToCome - moreArgs.length <= 0) {\n var functionCallResult = func.apply(closure, alreadyProvidedArgs);\n // reset vars, so curried function can be applied to new params.\n alreadyProvidedArgs = previousAlreadyProvidedArgs;\n stillToCome = previousStillToCome;\n return functionCallResult;\n }\n else {\n return function () {\n // arguments are params, so closure bussiness is avoided.\n return accumulator(arguments, alreadyProvidedArgs.slice(0), stillToCome);\n };\n }\n }\n return accumulator([], argumentsCopy, argumentsStillToCome);\n };\n AutoMapperHelper.getMappingMetadataFromTransformationFunction = function (destination, func, sourceMapping) {\n if (typeof func !== 'function') {\n return {\n destination: destination,\n source: destination,\n transformation: AutoMapperHelper.getDestinationTransformation(func, false, sourceMapping, false),\n sourceMapping: sourceMapping,\n condition: null,\n ignore: false,\n async: false\n };\n }\n var functionStr = func.toString();\n var parameterNames = AutoMapperHelper.getFunctionParameters(functionStr);\n var optsParamName = parameterNames.length >= 1 ? parameterNames[0] : '';\n var source = sourceMapping\n ? destination\n : AutoMapperHelper.getMapFromString(functionStr, destination, optsParamName);\n var metadata = {\n destination: destination,\n source: source,\n transformation: AutoMapperHelper.getDestinationTransformation(func, true, sourceMapping, parameterNames.length === 2),\n sourceMapping: sourceMapping,\n condition: null,\n ignore: AutoMapperHelper.getIgnoreFromString(functionStr, destination),\n async: parameterNames.length === 2\n };\n // calling the member options function when used asynchronous would be too 'dangerous'.\n if (!metadata.async && AutoMapperHelper.getFunctionCallIndex(functionStr, 'condition', optsParamName) >= 0) {\n metadata.condition = AutoMapperHelper.getConditionFromFunction(func, source);\n }\n return metadata;\n };\n AutoMapperHelper.getDestinationTransformation = function (func, isFunction, sourceMapping, async) {\n if (!isFunction) {\n return {\n transformationType: AutoMapperJs.DestinationTransformationType.Constant,\n constant: func\n };\n }\n var transformation;\n if (sourceMapping) {\n if (async) {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.AsyncSourceMemberOptions,\n asyncSourceMemberConfigurationOptionsFunc: func\n };\n }\n else {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.SourceMemberOptions,\n sourceMemberConfigurationOptionsFunc: func\n };\n }\n }\n else {\n if (async) {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.AsyncMemberOptions,\n asyncMemberConfigurationOptionsFunc: func\n };\n }\n else {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.MemberOptions,\n memberConfigurationOptionsFunc: func\n };\n }\n }\n return transformation;\n };\n AutoMapperHelper.getIgnoreFromString = function (functionString, optionsParameterName) {\n var indexOfIgnore = AutoMapperHelper.getFunctionCallIndex(functionString, 'ignore', optionsParameterName);\n if (indexOfIgnore < 0) {\n return false;\n }\n var indexOfMapFromStart = functionString.indexOf('(', indexOfIgnore) + 1;\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\n return false;\n }\n var ignoreString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/\\r/g, '').replace(/\\n/g, '').trim();\n return ignoreString === null || ignoreString === ''\n ? true // .ignore()\n : false; // .ignore( -> unexpected content)\n };\n AutoMapperHelper.getMapFromString = function (functionString, defaultValue, optionsParameterName) {\n var indexOfMapFrom = AutoMapperHelper.getFunctionCallIndex(functionString, 'mapFrom', optionsParameterName);\n if (indexOfMapFrom < 0) {\n return defaultValue;\n }\n var indexOfMapFromStart = functionString.indexOf('(', indexOfMapFrom) + 1;\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\n return defaultValue;\n }\n var mapFromString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/'/g, '').replace(/\"/g, '').trim();\n return mapFromString === null || mapFromString === ''\n ? defaultValue\n : mapFromString;\n };\n AutoMapperHelper.getFunctionCallIndex = function (functionString, functionToLookFor, optionsParameterName) {\n var indexOfFunctionCall = functionString.indexOf(optionsParameterName + '.' + functionToLookFor);\n if (indexOfFunctionCall < 0) {\n indexOfFunctionCall = functionString.indexOf('.' + functionToLookFor);\n }\n return indexOfFunctionCall;\n };\n AutoMapperHelper.getConditionFromFunction = function (func, sourceProperty) {\n // Since we are calling the valueOrFunction function to determine whether to ignore or map from another property, we\n // want to prevent the call to be error prone when the end user uses the '(opts)=> opts.sourceObject.sourcePropertyName'\n // syntax. We don't actually have a source object when creating a mapping; therefore, we 'stub' a source object for the\n // function call.\n var sourceObject = {};\n sourceObject[sourceProperty] = {};\n var condition;\n // calling the function will result in calling our stubbed ignore() and mapFrom() functions if used inside the function.\n var configFuncOptions = {\n ignore: function () {\n // do nothing\n },\n condition: function (predicate) {\n condition = predicate;\n },\n mapFrom: function (sourcePropertyName) {\n // do nothing\n },\n sourceObject: sourceObject,\n sourcePropertyName: sourceProperty,\n intermediatePropertyValue: {}\n };\n try {\n func(configFuncOptions);\n }\n catch (exc) {\n // do not handle by default.\n }\n return condition;\n };\n return AutoMapperHelper;\n }());\n AutoMapperJs.AutoMapperHelper = AutoMapperHelper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperHelper.js.map\n","/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper configuration validator.\n */\n var AutoMapperValidator = (function () {\n function AutoMapperValidator() {\n }\n /**\n * Validates mapping configuration by dry-running. Since JS does not\n * fully support typing, it only checks if properties match on both\n * sides. The function needs IMapping.sourceTypeClass and\n * IMapping.destinationTypeClass to function.\n * @param {boolean} strictMode Whether or not to fail when properties\n * sourceTypeClass or destinationTypeClass\n * are unavailable.\n */\n AutoMapperValidator.assertConfigurationIsValid = function (mappings, strictMode) {\n for (var key in mappings) {\n if (!mappings.hasOwnProperty(key)) {\n continue;\n }\n AutoMapperValidator.assertMappingConfiguration(mappings[key], strictMode);\n }\n };\n AutoMapperValidator.assertMappingConfiguration = function (mapping, strictMode) {\n var mappingKey = mapping.sourceKey + \"=>\" + mapping.destinationKey;\n var sourceType = mapping.sourceTypeClass;\n var destinationType = mapping.destinationTypeClass;\n var sourceClassName = sourceType ? AutoMapperJs.AutoMapperHelper.getClassName(sourceType) : undefined;\n var destinationClassName = destinationType ? AutoMapperJs.AutoMapperHelper.getClassName(destinationType) : undefined;\n if (!sourceType || !destinationType) {\n if (strictMode === false) {\n return;\n }\n throw new Error(\"Mapping '\" + mappingKey + \"' cannot be validated, since mapping.sourceType or mapping.destinationType are unspecified.\");\n }\n var tryHandle = function (errorMessage) {\n if (errorMessage) {\n throw new Error(\"Mapping '\" + mappingKey + \"' is invalid: \" + errorMessage + \" (source: '\" + sourceClassName + \"', destination: '\" + destinationClassName + \"').\");\n }\n };\n var validatedMembers = new Array();\n var srcObj = new sourceType();\n var dstObj = new destinationType();\n // walk member mappings\n for (var _i = 0, _a = mapping.properties; _i < _a.length; _i++) {\n var property = _a[_i];\n tryHandle(AutoMapperValidator.validatePropertyMapping(property, property.name, srcObj, dstObj));\n validatedMembers.push(property.name);\n }\n // walk source members\n for (var srcMember in srcObj) {\n if (!srcObj.hasOwnProperty(srcMember)) {\n continue;\n }\n if (validatedMembers.indexOf(srcMember) >= 0) {\n // already validated\n continue;\n }\n tryHandle(AutoMapperValidator.validateProperty(srcMember, dstObj));\n validatedMembers.push(srcMember);\n }\n // walk destination members\n for (var dstMember in dstObj) {\n if (!dstObj.hasOwnProperty(dstMember)) {\n continue;\n }\n if (validatedMembers.indexOf(dstMember) >= 0) {\n // already validated\n continue;\n }\n tryHandle(\"Destination member '\" + dstMember + \"' does not exist on source type\");\n }\n // /* tslint:disable */\n // console.error(key);\n // /* tslint:enable */\n };\n AutoMapperValidator.validatePropertyMapping = function (propertyMapping, member, srcObj, dstObj) {\n // awkward way of locating sourceMapping ;) ...\n var destinationProperty = AutoMapperValidator.getDestinationProperty(propertyMapping.destinationPropertyName, propertyMapping);\n return destinationProperty.sourceMapping\n ? AutoMapperValidator.validateSourcePropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj)\n : AutoMapperValidator.validateDestinationPropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj);\n };\n AutoMapperValidator.validateSourcePropertyMapping = function (ropertyMapping, destinationProperty, member, srcObj, dstObj) {\n // a member for which configuration is provided, should exist.\n if (!srcObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is configured, but does not exist on source type\";\n }\n // an ignored source member should not exist on the destination type.\n if (destinationProperty.ignore) {\n if (dstObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is ignored, but does exist on destination type\";\n }\n return undefined;\n }\n // a mapped source member should exist on the destination type.\n if (!dstObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is configured to be mapped, but does not exist on destination type\";\n }\n //var dstMember = propertyMapping.destinationProperty;\n return undefined;\n };\n AutoMapperValidator.validateDestinationPropertyMapping = function (propertyMapping, destinationProperty, member, srcObj, dstObj) {\n // a member for which configuration is provided, should exist.\n if (!dstObj.hasOwnProperty(destinationProperty.name)) {\n return \"Destination member '\" + destinationProperty.destinationPropertyName + \"' is configured, but does not exist on destination type\";\n }\n // an ignored destination member should not exist on the source type.\n if (destinationProperty.ignore) {\n if (srcObj.hasOwnProperty(member)) {\n return \"Destination member '\" + member + \"' is ignored, but does exist on source type\";\n }\n return undefined;\n }\n // a mapped destination member should exist on the source type.\n if (!srcObj.hasOwnProperty(member)) {\n return \"Destination member '\" + member + \"' is configured to be mapped, but does not exist on source type\";\n }\n //var dstMember = propertyMapping.destinationProperty;\n return undefined;\n };\n AutoMapperValidator.validateProperty = function (srcMember, dstObj) {\n if (!dstObj.hasOwnProperty(srcMember)) {\n return \"Source member '\" + srcMember + \"' is configured to be mapped, but does not exist on destination type\";\n }\n return undefined;\n };\n AutoMapperValidator.getDestinationProperty = function (destinationPropertyName, existingSource) {\n if (existingSource.destination) {\n return existingSource.destination;\n }\n if (existingSource.children) {\n for (var _i = 0, _a = existingSource.children; _i < _a.length; _i++) {\n var child = _a[_i];\n var destination = this.getDestinationProperty(destinationPropertyName, child);\n if (destination) {\n return destination;\n }\n }\n }\n return null;\n };\n return AutoMapperValidator;\n }());\n AutoMapperJs.AutoMapperValidator = AutoMapperValidator;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperValidator.js.map\n","var AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var DestinationTransformationType;\n (function (DestinationTransformationType) {\n DestinationTransformationType[DestinationTransformationType[\"Constant\"] = 1] = \"Constant\";\n DestinationTransformationType[DestinationTransformationType[\"MemberOptions\"] = 2] = \"MemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"AsyncMemberOptions\"] = 4] = \"AsyncMemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"SourceMemberOptions\"] = 8] = \"SourceMemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"AsyncSourceMemberOptions\"] = 16] = \"AsyncSourceMemberOptions\";\n })(DestinationTransformationType = AutoMapperJs.DestinationTransformationType || (AutoMapperJs.DestinationTransformationType = {}));\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperEnumerations.js.map\n","/// \n/// \n/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper implementation, for both creating maps and performing maps. Comparable usage and functionality to the original\n * .NET AutoMapper library is the pursuit of this implementation.\n */\n var AutoMapperBase = (function () {\n function AutoMapperBase() {\n }\n AutoMapperBase.prototype.getMapping = function (mappings, sourceKey, destinationKey) {\n var srcKey = this.getKey(sourceKey);\n var dstKey = this.getKey(destinationKey);\n var mapping = mappings[srcKey + dstKey];\n if (!mapping) {\n throw new Error(\"Could not find map object with a source of \" + srcKey + \" and a destination of \" + dstKey);\n }\n return mapping;\n };\n AutoMapperBase.prototype.getKey = function (keyStringOrType) {\n if (typeof keyStringOrType === 'string') {\n return keyStringOrType;\n }\n else {\n return AutoMapperJs.AutoMapperHelper.getClassName(keyStringOrType);\n }\n };\n AutoMapperBase.prototype.isArray = function (sourceObject) {\n return sourceObject instanceof Array;\n };\n AutoMapperBase.prototype.handleArray = function (mapping, sourceArray, itemFunc) {\n var arrayLength = sourceArray.length;\n var destinationArray = new Array(sourceArray.length);\n for (var index = 0; index < arrayLength; index++) {\n var sourceObject = sourceArray[index];\n var destinationObject = void 0;\n if (sourceObject === null || sourceObject === undefined) {\n destinationObject = sourceObject;\n }\n else {\n destinationObject = this.createDestinationObject(mapping.destinationTypeClass);\n itemFunc(sourceObject, destinationObject);\n }\n destinationArray[index] = destinationObject;\n }\n return destinationArray;\n };\n AutoMapperBase.prototype.handleItem = function (mapping, sourceObject, destinationObject, propertyFunction) {\n // var sourceProperties: string[] = [];\n var atLeastOnePropertyMapped = false;\n // handle mapped properties ...\n for (var _i = 0, _a = mapping.properties; _i < _a.length; _i++) {\n var property = _a[_i];\n // sourceProperties.push(property.name);\n atLeastOnePropertyMapped = true;\n propertyFunction(property.name);\n }\n // .. and, after that, handle unmapped properties\n for (var sourcePropertyName in sourceObject) {\n if (!sourceObject.hasOwnProperty(sourcePropertyName)) {\n continue;\n }\n if (destinationObject[sourcePropertyName]) {\n // ... but, if the destination property already exists, don't map again (probably a mapFrom situation).\n continue;\n }\n // if (sourceProperties.indexOf(sourcePropertyName) >= 0) {\n // continue;\n // }\n atLeastOnePropertyMapped = true;\n propertyFunction(sourcePropertyName);\n }\n // return null/undefined sourceObject if no properties added\n if (!atLeastOnePropertyMapped && (sourceObject === null || sourceObject === undefined)) {\n return sourceObject;\n }\n return destinationObject;\n };\n AutoMapperBase.prototype.handleProperty = function (mapping, sourceObject, sourcePropertyName, destinationObject, transformFunction, autoMappingCallbackFunction) {\n // TODO Property mappings are already located before\n // TODO handleProperty seems only to be called when processing a mapped property.\n var propertyMappings = this.getPropertyMappings(mapping.properties, sourcePropertyName);\n if (propertyMappings.length > 0) {\n for (var _i = 0, propertyMappings_1 = propertyMappings; _i < propertyMappings_1.length; _i++) {\n var propertyMapping = propertyMappings_1[_i];\n this.processMappedProperty(mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction);\n }\n }\n else {\n this.handlePropertyWithAutoMapping(mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction);\n }\n };\n AutoMapperBase.prototype.setPropertyValue = function (mapping, destinationProperty, destinationObject, destinationPropertyValue) {\n if (mapping.forAllMemberMappings.length > 0) {\n for (var _i = 0, _a = mapping.forAllMemberMappings; _i < _a.length; _i++) {\n var forAllMemberMapping = _a[_i];\n forAllMemberMapping(destinationObject, destinationProperty.name, destinationPropertyValue);\n }\n }\n else {\n destinationObject[destinationProperty.name] = destinationPropertyValue;\n }\n };\n AutoMapperBase.prototype.setPropertyValueByName = function (mapping, destinationObject, destinationProperty, destinationPropertyValue) {\n if (mapping.forAllMemberMappings.length > 0) {\n for (var _i = 0, _a = mapping.forAllMemberMappings; _i < _a.length; _i++) {\n var forAllMemberMapping = _a[_i];\n forAllMemberMapping(destinationObject, destinationProperty, destinationPropertyValue);\n }\n }\n else {\n destinationObject[destinationProperty] = destinationPropertyValue;\n }\n };\n AutoMapperBase.prototype.createDestinationObject = function (destinationType) {\n // create empty destination object.\n return destinationType\n ? new destinationType()\n : {};\n };\n AutoMapperBase.prototype.shouldProcessDestination = function (destination, sourceObject) {\n if (destination.ignore) {\n // ignore ignored properties\n return false;\n }\n if (destination.conditionFunction) {\n // check for condition function, and, if there is ...\n if (destination.conditionFunction(sourceObject) === false) {\n // ... return when the condition is not met.\n return false;\n }\n }\n return true;\n };\n // protected throwMappingException(propertyMapping: IProperty, message: string): void {\n // throw new Error(`Cannot map '${propertyMapping.sourcePropertyName}' to '${propertyMapping.destinationPropertyName}' => ${message}`);\n // }\n AutoMapperBase.prototype.handlePropertyWithAutoMapping = function (mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction) {\n // no forMember mapping exists, auto map properties, except for the situation where ignoreAllNonExisting is specified.\n if (mapping.ignoreAllNonExisting) {\n return;\n }\n if (mapping.destinationTypeClass && Object.keys(destinationObject).indexOf(sourcePropertyName) < 0) {\n return;\n }\n var objectValue = null;\n var isNestedObject = false;\n if (typeof destinationObject[sourcePropertyName] === 'object' && destinationObject[sourcePropertyName]) {\n isNestedObject = (destinationObject[sourcePropertyName].constructor.name !== 'Object');\n if (isNestedObject) {\n this\n .createMap(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name)\n .convertToType(destinationObject[sourcePropertyName].constructor);\n objectValue = this.map(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name, sourceObject[sourcePropertyName]);\n }\n }\n // use profile mapping when specified; otherwise, specify source property name as destination property name.\n var destinationPropertyName = this.getDestinationPropertyName(mapping.profile, sourcePropertyName);\n var destinationPropertyValue = this.getDestinationPropertyValue(sourceObject, sourcePropertyName, objectValue, isNestedObject);\n this.setPropertyValueByName(mapping, destinationObject, destinationPropertyName, destinationPropertyValue);\n if (autoMappingCallbackFunction) {\n autoMappingCallbackFunction(destinationPropertyValue);\n }\n };\n AutoMapperBase.prototype.getDestinationPropertyValue = function (sourceObject, sourcePropertyName, objectValue, isNestedObject) {\n if (isNestedObject) {\n return objectValue;\n }\n return sourceObject ? sourceObject[sourcePropertyName] : null;\n };\n AutoMapperBase.prototype.getDestinationPropertyName = function (profile, sourcePropertyName) {\n if (!profile) {\n return sourcePropertyName;\n }\n // TODO BL no support yet for INamingConvention.splittingCharacter\n try {\n // First, split the source property name based on the splitting expression.\n // TODO BL Caching of RegExp splitting!\n var sourcePropertyNameParts = sourcePropertyName.split(profile.sourceMemberNamingConvention.splittingExpression);\n // NOTE BL For some reason, splitting by (my ;)) RegExp results in empty strings in the array; remove them.\n for (var index = sourcePropertyNameParts.length - 1; index >= 0; index--) {\n if (sourcePropertyNameParts[index] === '') {\n sourcePropertyNameParts.splice(index, 1);\n }\n }\n return profile.destinationMemberNamingConvention.transformPropertyName(sourcePropertyNameParts);\n }\n catch (error) {\n return sourcePropertyName;\n }\n };\n AutoMapperBase.prototype.getPropertyMappings = function (properties, sourcePropertyName) {\n var result = [];\n for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {\n var property = properties_1[_i];\n if (property.name === sourcePropertyName) {\n result.push(property);\n }\n }\n return result;\n };\n AutoMapperBase.prototype.processMappedProperty = function (mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction) {\n if (propertyMapping.children && propertyMapping.children.length > 0) {\n // always pass child source object, even if source object does not exist =>\n // constant transformations should always pass.\n var childSourceObject = sourceObject ? sourceObject[propertyMapping.name] : null;\n for (var _i = 0, _a = propertyMapping.children; _i < _a.length; _i++) {\n var child = _a[_i];\n this.processMappedProperty(mapping, child, childSourceObject, child.name, transformFunction);\n return;\n }\n }\n var destination = propertyMapping.destination;\n // if (!propertyMapping.destination) {\n // // it makes no sense to handle a property without destination(s).\n // this.throwMappingException(propertyMapping, 'no destination object');\n // }\n var configurationOptions = this.createMemberConfigurationOptions(sourceObject, sourcePropertyName);\n transformFunction(destination, configurationOptions);\n };\n AutoMapperBase.prototype.createMemberConfigurationOptions = function (sourceObject, sourcePropertyName) {\n var memberConfigurationOptions = {\n mapFrom: function (sourcePropertyName) {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.mapFrom(...)' function.\n },\n condition: function (predicate) {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.condition(...)' function.\n },\n ignore: function () {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.ignore()' function.\n },\n sourceObject: sourceObject,\n sourcePropertyName: sourcePropertyName,\n intermediatePropertyValue: sourceObject ? sourceObject[sourcePropertyName] : sourceObject\n };\n return memberConfigurationOptions;\n };\n return AutoMapperBase;\n }());\n AutoMapperJs.AutoMapperBase = AutoMapperBase;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperBase.js.map\n","/// \n/// \n/// \n/// \n/// \nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AsyncAutoMapper implementation, for asynchronous mapping support when using AutoMapper.\n */\n var AsyncAutoMapper = (function (_super) {\n __extends(AsyncAutoMapper, _super);\n function AsyncAutoMapper() {\n var _this = _super.call(this) || this;\n AsyncAutoMapper.asyncInstance = _this;\n return _this;\n }\n AsyncAutoMapper.prototype.createMap = function (sourceKeyOrType, destinationKeyOrType) {\n throw new Error('Method AsyncAutoMapper.createMap is not implemented.');\n };\n AsyncAutoMapper.prototype.createMapForMember = function (mapping, property) {\n var _this = this;\n mapping.async = true;\n mapping.mapItemFunction = function (m, srcObj, dstObj, cb) { return _this.mapItem(m, srcObj, dstObj, cb); };\n // property.async = true;\n // property.conversionValuesAndFunctions.push(func);\n };\n AsyncAutoMapper.prototype.createMapConvertUsing = function (mapping, converterFunction) {\n var _this = this;\n mapping.async = true;\n mapping.typeConverterFunction = converterFunction;\n mapping.mapItemFunction = function (m, srcObj, dstObj, cb) { return _this.mapItemUsingTypeConverter(m, srcObj, dstObj, cb); };\n };\n AsyncAutoMapper.prototype.map = function (mappings, sourceKey, destinationKey, sourceObject, callback) {\n var _this = this;\n switch (arguments.length) {\n case 5:\n this.mapWithMapping(_super.prototype.getMapping.call(this, mappings, sourceKey, destinationKey), sourceObject, callback);\n return;\n // provide performance optimized (preloading) currying support.\n case 4:\n return function (cb) { return _this.mapWithMapping(_super.prototype.getMapping.call(_this, mappings, sourceKey, destinationKey), sourceObject, cb); };\n case 3:\n return function (srcObj, cb) { return _this.mapWithMapping(_super.prototype.getMapping.call(_this, mappings, sourceKey, destinationKey), srcObj, cb); };\n case 2:\n return function (dstKey, srcObj, cb) { return _this.map(mappings, sourceKey, dstKey, srcObj, cb); };\n default:\n throw new Error('The AsyncAutoMapper.map function expects between 2 and 5 parameters, you provided ' + arguments.length + '.');\n }\n };\n AsyncAutoMapper.prototype.mapWithMapping = function (mapping, sourceObject, callback) {\n if (_super.prototype.isArray.call(this, sourceObject)) {\n this.mapArray(mapping, sourceObject, callback);\n return;\n }\n return mapping.mapItemFunction(mapping, sourceObject, _super.prototype.createDestinationObject.call(this, mapping.destinationTypeClass), callback);\n };\n /**\n * Execute a mapping from the source array to a new destination array with explicit mapping configuration and supplied mapping options (using createMap).\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceArray The source array to map.\n * @returns {Array} Destination array.\n */\n AsyncAutoMapper.prototype.mapArray = function (mapping, sourceArray, callback) {\n var callbacksToGo = 0;\n var destinationArray = _super.prototype.handleArray.call(this, mapping, sourceArray, function (sourceObject, destinationObject) {\n callbacksToGo++;\n mapping.mapItemFunction(mapping, sourceObject, destinationObject, function (result) {\n callbacksToGo--;\n });\n });\n var waitForCallbackToSend = function () {\n if (callbacksToGo === 0) {\n callback(destinationArray);\n }\n else {\n setTimeout(function () {\n waitForCallbackToSend();\n }, 10 * callbacksToGo);\n }\n };\n waitForCallbackToSend();\n };\n AsyncAutoMapper.prototype.mapItemUsingTypeConverter = function (mapping, sourceObject, destinationObject, callback) {\n var resolutionContext = {\n sourceValue: sourceObject,\n destinationValue: destinationObject\n };\n mapping.typeConverterFunction(resolutionContext, callback);\n };\n /**\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceObject The source object to map.\n * @param destinationObject The destination object to map to.\n * @param callback The callback to call after async mapping has been executed.\n */\n AsyncAutoMapper.prototype.mapItem = function (mapping, sourceObject, destinationObject, callback) {\n var _this = this;\n var callbacksToGo = 0;\n _super.prototype.handleItem.call(this, mapping, sourceObject, destinationObject, function (sourceProperty) {\n callbacksToGo++;\n _this.mapProperty(mapping, sourceObject, sourceProperty, destinationObject, function (result) {\n callbacksToGo--;\n });\n });\n var waitForCallbackToSend = function () {\n if (callbacksToGo === 0) {\n callback(destinationObject);\n }\n else {\n setTimeout(function () {\n waitForCallbackToSend();\n }, 10 * callbacksToGo);\n }\n };\n waitForCallbackToSend();\n };\n /**\n * Execute a mapping from the source object property to the destination object property with explicit mapping configuration and supplied mapping options.\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceObject The source object to map.\n * @param sourcePropertyName The source property to map.\n * @param destinationObject The destination object to map to.\n * @param callback The callback to call after async property mapping has been executed.\n */\n AsyncAutoMapper.prototype.mapProperty = function (mapping, sourceObject, sourceProperty, destinationObject, callback) {\n var _this = this;\n _super.prototype.handleProperty.call(this, mapping, sourceObject, sourceProperty, destinationObject, function (destinationProperty, options) {\n _this.transform(mapping, sourceObject, destinationProperty, destinationObject, options, function (destinationPropertyValue, success) {\n callback(destinationPropertyValue);\n });\n }, function (destinationPropertyValue) {\n callback(destinationPropertyValue);\n });\n };\n AsyncAutoMapper.prototype.transform = function (mapping, sourceObject, destinationProperty, destinationObject, options, callback) {\n var _this = this;\n var childDestinationProperty = destinationProperty.child;\n if (childDestinationProperty) {\n var childDestinationObject = destinationObject[destinationProperty.name];\n if (!childDestinationObject) {\n // no child source object? create.\n childDestinationObject = {};\n }\n // transform child by recursively calling the transform function.\n this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options, function (callbackValue, success) {\n if (success) {\n // only set child destination object when transformation has been successful.\n destinationObject[destinationProperty.name] = childDestinationObject;\n }\n callback(options.intermediatePropertyValue, success);\n });\n return;\n }\n if (!_super.prototype.shouldProcessDestination.call(this, destinationProperty, sourceObject)) {\n callback(undefined /* opts.intermediatePropertyValue */, false);\n return;\n }\n // actually transform destination property.\n this.processTransformations(destinationProperty, destinationProperty.transformations, options, function (callbackValue, success) {\n if (success) {\n _super.prototype.setPropertyValue.call(_this, mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\n }\n callback(options.intermediatePropertyValue, success);\n });\n };\n AsyncAutoMapper.prototype.processTransformations = function (property, transformations, options, callback) {\n var _this = this;\n if (transformations.length === 0) {\n callback(options.intermediatePropertyValue, true);\n return;\n }\n var transformation = transformations[0];\n this.processTransformation(property, transformation, options, function (callbackValue, success) {\n if (!success) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n _this.processTransformations(property, transformations.slice(1), options, callback);\n });\n };\n AsyncAutoMapper.prototype.processTransformation = function (property, transformation, options, callback) {\n switch (transformation.transformationType) {\n case AutoMapperJs.DestinationTransformationType.Constant:\n options.intermediatePropertyValue = transformation.constant;\n callback(options.intermediatePropertyValue, true);\n return;\n case AutoMapperJs.DestinationTransformationType.MemberOptions: {\n var result = transformation.memberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n }\n case AutoMapperJs.DestinationTransformationType.SourceMemberOptions: {\n var result = transformation.sourceMemberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n }\n case AutoMapperJs.DestinationTransformationType.AsyncMemberOptions:\n transformation.asyncMemberConfigurationOptionsFunc(options, function (result) {\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n });\n return;\n case AutoMapperJs.DestinationTransformationType.AsyncSourceMemberOptions:\n transformation.asyncSourceMemberConfigurationOptionsFunc(options, function (result) {\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n });\n return;\n default:\n // TODO: this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation}`);\n callback(options.intermediatePropertyValue, false);\n return;\n }\n };\n return AsyncAutoMapper;\n }(AutoMapperJs.AutoMapperBase));\n AsyncAutoMapper.asyncInstance = new AsyncAutoMapper();\n AutoMapperJs.AsyncAutoMapper = AsyncAutoMapper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AsyncAutoMapper.js.map\n","/// \n/// \n/// \n/// \n/// \n/// \n/// \nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var AutoMapper = (function (_super) {\n __extends(AutoMapper, _super);\n /**\n * This class is intended to be a Singleton. Preferrably use getInstance()\n * function instead of using the constructor directly from code.\n */\n function AutoMapper() {\n var _this = _super.call(this) || this;\n if (AutoMapper._instance) {\n return AutoMapper._instance;\n }\n else {\n AutoMapper._instance = _this;\n _this._profiles = {};\n _this._mappings = {};\n _this._asyncMapper = new AutoMapperJs.AsyncAutoMapper();\n }\n return _this;\n }\n AutoMapper.getInstance = function () {\n return AutoMapper._instance;\n };\n /**\n * Initializes the mapper with the supplied configuration.\n * @param {(config: IConfiguration) => void} configFunction Configuration function to call.\n */\n AutoMapper.prototype.initialize = function (configFunction) {\n var that = this;\n var configuration = {\n addProfile: function (profile) {\n profile.configure();\n that._profiles[profile.profileName] = profile;\n },\n createMap: function (sourceKey, destinationKey) {\n // pass through using arguments to keep createMap's currying support fully functional.\n return that.createMap.apply(that, arguments);\n }\n };\n configFunction(configuration);\n };\n /**\n * Create a mapping profile.\n * @param {string} sourceKey The map source key.\n * @param {string} destinationKey The map destination key.\n * @returns {Core.ICreateMapFluentFunctions}\n */\n AutoMapper.prototype.createMap = function (sourceKeyOrType, destinationKeyOrType) {\n // provide currying support.\n if (arguments.length < 2) {\n return AutoMapperJs.AutoMapperHelper.handleCurrying(this.createMap, arguments, this);\n }\n var mapping = this.createMappingObjectForGivenKeys(sourceKeyOrType, destinationKeyOrType);\n return this.createMapGetFluentApiFunctions(mapping);\n };\n /**\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param sourceKey Source key, for instance the source type name.\n * @param destinationKey Destination key, for instance the destination type name.\n * @param sourceObject The source object to map.\n * @returns {any} Destination object.\n */\n AutoMapper.prototype.map = function (sourceKeyOrType, destinationKeyOrType, sourceObject) {\n var _this = this;\n if (arguments.length === 3) {\n return this.mapInternal(_super.prototype.getMapping.call(this, this._mappings, sourceKeyOrType, destinationKeyOrType), sourceObject);\n }\n // provide performance optimized (preloading) currying support.\n if (arguments.length === 2) {\n return function (srcObj) { return _this.mapInternal(_super.prototype.getMapping.call(_this, _this._mappings, sourceKeyOrType, destinationKeyOrType), srcObj); };\n }\n if (arguments.length === 1) {\n return function (dstKey, srcObj) { return _this.map(sourceKeyOrType, dstKey, srcObj); };\n }\n return function (srcKey, dstKey, srcObj) { return _this.map(srcKey, dstKey, srcObj); };\n };\n /**\n * Execute an asynchronous mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param sourceKey Source key, for instance the source type name.\n * @param destinationKey Destination key, for instance the destination type name.\n * @param sourceObject The source object to map.\n * @param {IMapCallback} callback The callback to call when asynchronous mapping is complete.\n */\n AutoMapper.prototype.mapAsync = function (sourceKeyOrType, destinationKeyOrType, sourceObject, callback) {\n switch (arguments.length) {\n case 4:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject, callback);\n case 3:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject);\n case 2:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType);\n case 1:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType);\n default:\n throw new Error('The mapAsync function expects between 1 and 4 parameters, you provided ' + arguments.length + '.');\n }\n };\n /**\n * Validates mapping configuration by dry-running. Since JS does not fully support typing, it only checks if properties match on both\n * sides. The function needs IMapping.sourceTypeClass and IMapping.destinationTypeClass to function.\n * @param {boolean} strictMode Whether or not to fail when properties sourceTypeClass or destinationTypeClass are unavailable.\n */\n AutoMapper.prototype.assertConfigurationIsValid = function (strictMode) {\n if (strictMode === void 0) { strictMode = true; }\n AutoMapperJs.AutoMapperValidator.assertConfigurationIsValid(this._mappings, strictMode);\n };\n AutoMapper.prototype.createMapForAllMembers = function (mapping, fluentFunc, func) {\n mapping.forAllMemberMappings.push(func);\n return fluentFunc;\n };\n AutoMapper.prototype.createMapIgnoreAllNonExisting = function (mapping, fluentFunc) {\n mapping.ignoreAllNonExisting = true;\n return fluentFunc;\n };\n AutoMapper.prototype.createMapConvertToType = function (mapping, fluentFunc, typeClass) {\n if (mapping.destinationTypeClass) {\n throw new Error('Destination type class can only be set once.');\n }\n mapping.destinationTypeClass = typeClass;\n return fluentFunc;\n };\n AutoMapper.prototype.createMapConvertUsing = function (mapping, tcClassOrFunc) {\n var _this = this;\n var configureSynchronousConverterFunction = function (converterFunc) {\n if (!converterFunc || AutoMapperJs.AutoMapperHelper.getFunctionParameters(converterFunc.toString()).length !== 1) {\n throw new Error('The function provided does not provide exactly one (resolutionContext) parameter.');\n }\n mapping.typeConverterFunction = converterFunc;\n mapping.mapItemFunction = function (m, srcObj, dstObj) { return _this.mapItemUsingTypeConverter(m, srcObj, dstObj); };\n };\n try {\n // check if sync: TypeConverter instance\n if (tcClassOrFunc instanceof AutoMapperJs.TypeConverter) {\n configureSynchronousConverterFunction(tcClassOrFunc.convert);\n return;\n }\n var functionParameters = AutoMapperJs.AutoMapperHelper.getFunctionParameters(tcClassOrFunc.toString());\n switch (functionParameters.length) {\n case 0:\n // check if sync: TypeConverter class definition\n var typeConverter;\n try {\n typeConverter = new tcClassOrFunc();\n }\n catch (e) {\n // Obviously, typeConverterClassOrFunction is not a TypeConverter class definition\n }\n if (typeConverter instanceof AutoMapperJs.TypeConverter) {\n configureSynchronousConverterFunction(typeConverter.convert);\n return;\n }\n break;\n case 1:\n // sync: function with resolutionContext parameter\n configureSynchronousConverterFunction(tcClassOrFunc);\n return;\n case 2:\n // check if async: function with resolutionContext and callback parameters\n this._asyncMapper.createMapConvertUsing(mapping, tcClassOrFunc);\n return;\n }\n // okay, just try feeding the function to the configure function anyway...\n configureSynchronousConverterFunction(tcClassOrFunc);\n }\n catch (e) {\n throw new Error(\"The value provided for typeConverterClassOrFunction is invalid. \" + e);\n }\n };\n AutoMapper.prototype.createMapWithProfile = function (mapping, profileName) {\n // check if given profile exists\n var profile = this._profiles[profileName];\n if (typeof profile === 'undefined' || profile.profileName !== profileName) {\n throw new Error(\"Could not find profile with profile name '\" + profileName + \"'.\");\n }\n mapping.profile = profile;\n // merge mappings\n this.createMapWithProfileMergeMappings(mapping, profileName);\n };\n AutoMapper.prototype.createMapWithProfileMergeMappings = function (mapping, profileName) {\n var profileMappingKey = profileName + \"=>\" + mapping.sourceKey + profileName + \"=>\" + mapping.destinationKey;\n var profileMapping = this._mappings[profileMappingKey];\n if (!profileMapping) {\n return;\n }\n // append forAllMemberMappings calls to the original array.\n if (profileMapping.forAllMemberMappings.length > 0) {\n (_a = mapping.forAllMemberMappings).push.apply(_a, profileMapping.forAllMemberMappings);\n }\n // overwrite original type converter function\n if (profileMapping.typeConverterFunction) {\n mapping.typeConverterFunction = profileMapping.typeConverterFunction;\n mapping.mapItemFunction = profileMapping.mapItemFunction;\n }\n // overwrite original type converter function\n if (profileMapping.destinationTypeClass) {\n mapping.destinationTypeClass = profileMapping.destinationTypeClass;\n }\n // walk through all the profile's property mappings\n for (var _i = 0, _b = profileMapping.properties; _i < _b.length; _i++) {\n var property = _b[_i];\n // TODO Awkward way of locating sourceMapping ;) ...\n var sourceMapping = this.getDestinationProperty(property.destinationPropertyName, property).sourceMapping;\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\n mapping.properties.push(property);\n }\n }\n var _a;\n };\n AutoMapper.prototype.mapInternal = function (mapping, sourceObject) {\n if (mapping.async) {\n throw new Error('Impossible to use asynchronous mapping using automapper.map(); use automapper.mapAsync() instead.');\n }\n if (_super.prototype.isArray.call(this, sourceObject)) {\n return this.mapArray(mapping, sourceObject);\n }\n return mapping.mapItemFunction(mapping, sourceObject, _super.prototype.createDestinationObject.call(this, mapping.destinationTypeClass));\n };\n AutoMapper.prototype.mapArray = function (mapping, sourceArray) {\n var destinationArray = _super.prototype.handleArray.call(this, mapping, sourceArray, function (sourceObject, destinationObject) {\n mapping.mapItemFunction(mapping, sourceObject, destinationObject);\n });\n return destinationArray;\n };\n AutoMapper.prototype.mapItem = function (mapping, sourceObject, destinationObject) {\n var _this = this;\n destinationObject = _super.prototype.handleItem.call(this, mapping, sourceObject, destinationObject, function (propertyName) {\n _this.mapProperty(mapping, sourceObject, destinationObject, propertyName);\n });\n return destinationObject;\n };\n AutoMapper.prototype.mapItemUsingTypeConverter = function (mapping, sourceObject, destinationObject, arrayIndex) {\n var resolutionContext = {\n sourceValue: sourceObject,\n destinationValue: destinationObject\n };\n return mapping.typeConverterFunction(resolutionContext);\n };\n AutoMapper.prototype.mapProperty = function (mapping, sourceObject, destinationObject, sourceProperty) {\n var _this = this;\n _super.prototype.handleProperty.call(this, mapping, sourceObject, sourceProperty, destinationObject, function (destinationProperty, options) {\n return _this.transform(mapping, sourceObject, destinationProperty, destinationObject, options);\n });\n };\n AutoMapper.prototype.transform = function (mapping, sourceObject, destinationProperty, destinationObject, options) {\n var childDestinationProperty = destinationProperty.child;\n if (childDestinationProperty) {\n var childDestinationObject = destinationObject[destinationProperty.name];\n if (!childDestinationObject) {\n // no child source object? create.\n childDestinationObject = {};\n }\n // transform child by recursively calling the transform function.\n var transformed = this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options /*, callback*/);\n if (transformed) {\n // only set child destination object when transformation has been successful.\n destinationObject[destinationProperty.name] = childDestinationObject;\n }\n return transformed;\n }\n if (!_super.prototype.shouldProcessDestination.call(this, destinationProperty, sourceObject)) {\n return false;\n }\n // actually transform destination property.\n for (var _i = 0, _a = destinationProperty.transformations; _i < _a.length; _i++) {\n var transformation = _a[_i];\n if (!this.processTransformation(destinationProperty, transformation, options)) {\n return false;\n }\n }\n _super.prototype.setPropertyValue.call(this, mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\n return true;\n };\n AutoMapper.prototype.processTransformation = function (property, transformation, options) {\n switch (transformation.transformationType) {\n case AutoMapperJs.DestinationTransformationType.Constant:\n options.intermediatePropertyValue = transformation.constant;\n return true;\n case AutoMapperJs.DestinationTransformationType.MemberOptions: {\n var result = transformation.memberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n return false;\n }\n return true;\n }\n case AutoMapperJs.DestinationTransformationType.SourceMemberOptions: {\n var result = transformation.sourceMemberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n return false;\n }\n return true;\n }\n default:\n // this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation.transformationType}`);\n return false;\n }\n };\n AutoMapper.prototype.createMappingObjectForGivenKeys = function (srcKeyOrType, dstKeyOrType) {\n var _this = this;\n var mapping = {\n sourceKey: _super.prototype.getKey.call(this, srcKeyOrType),\n destinationKey: _super.prototype.getKey.call(this, dstKeyOrType),\n forAllMemberMappings: new Array(),\n properties: [],\n typeConverterFunction: undefined,\n mapItemFunction: function (m, srcObj, dstObj) { return _this.mapItem(m, srcObj, dstObj); },\n sourceTypeClass: (typeof srcKeyOrType === 'string' ? undefined : srcKeyOrType),\n destinationTypeClass: (typeof dstKeyOrType === 'string' ? undefined : dstKeyOrType),\n profile: undefined,\n async: false\n };\n this._mappings[mapping.sourceKey + mapping.destinationKey] = mapping;\n return mapping;\n };\n AutoMapper.prototype.createMapGetFluentApiFunctions = function (mapping) {\n var _this = this;\n // create a fluent interface / method chaining (e.g. automapper.createMap().forMember().forMember() ...)\n var fluentFunc = {\n forMember: function (prop, valFunc) {\n return _this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: valFunc, sourceMapping: false, fluentFunctions: fluentFunc });\n },\n forSourceMember: function (prop, cfgFunc) {\n return _this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: cfgFunc, sourceMapping: true, fluentFunctions: fluentFunc });\n },\n forAllMembers: function (func) {\n return _this.createMapForAllMembers(mapping, fluentFunc, func);\n },\n ignoreAllNonExisting: function () { return _this.createMapIgnoreAllNonExisting(mapping, fluentFunc); },\n convertToType: function (type) { return _this.createMapConvertToType(mapping, fluentFunc, type); },\n convertUsing: function (tcClassOrFunc) {\n return _this.createMapConvertUsing(mapping, tcClassOrFunc);\n },\n withProfile: function (profile) { return _this.createMapWithProfile(mapping, profile); }\n };\n return fluentFunc;\n };\n AutoMapper.prototype.createMapForMember = function (parameters) {\n var mapping = parameters.mapping, propertyName = parameters.propertyName, transformation = parameters.transformation, sourceMapping = parameters.sourceMapping, fluentFunctions = parameters.fluentFunctions;\n // extract source/destination property names\n var metadata = AutoMapperJs.AutoMapperHelper.getMappingMetadataFromTransformationFunction(propertyName, transformation, sourceMapping);\n this.validateForMemberParameters(metadata);\n var source = metadata.source, destination = metadata.destination;\n // create property (regardless of current existance)\n var property = this.createSourceProperty(metadata, null);\n // merge with existing property or add property\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\n mapping.properties.push(property);\n }\n if (metadata.async) {\n this._asyncMapper.createMapForMember(mapping, this.findProperty(property.name, mapping.properties));\n }\n return fluentFunctions;\n };\n AutoMapper.prototype.validateForMemberParameters = function (metadata) {\n if (!metadata.sourceMapping) {\n return;\n }\n // validate forSourceMember parameters\n if (metadata.transformation.transformationType === AutoMapperJs.DestinationTransformationType.Constant) {\n throw new Error('Configuration of forSourceMember has to be a function with one (sync) or two (async) options parameters.');\n }\n };\n AutoMapper.prototype.createSourceProperty = function (metadata, parent) {\n var level = !parent ? 0 : parent.level + 1;\n var sourceNameParts = metadata.source.split('.');\n var source = {\n name: sourceNameParts[level],\n sourcePropertyName: metadata.source,\n destinationPropertyName: metadata.destination,\n parent: parent,\n level: level,\n children: [],\n destination: null\n };\n if ((level + 1) < sourceNameParts.length) {\n // recursively add child source properties ...\n var child = this.createSourceProperty(metadata, source);\n if (child) {\n source.children.push(child);\n }\n source.destination = null;\n }\n else {\n // ... or (!) add destination\n source.destination = this.createDestinationProperty(metadata, null);\n }\n return source;\n };\n AutoMapper.prototype.createDestinationProperty = function (metadata, parent) {\n var level = !parent ? 0 : parent.level + 1;\n var destinationNameParts = metadata.destination.split('.');\n var destination = {\n name: destinationNameParts[level],\n sourcePropertyName: metadata.source,\n destinationPropertyName: metadata.destination,\n parent: parent,\n level: level,\n child: null,\n transformations: [],\n conditionFunction: null,\n ignore: false,\n sourceMapping: false\n };\n if ((level + 1) < destinationNameParts.length) {\n // recursively add child destination properties\n destination.child = this.createDestinationProperty(metadata, destination);\n }\n else {\n // add/merge properties\n destination.sourceMapping = metadata.sourceMapping;\n destination.conditionFunction = metadata.condition;\n destination.ignore = metadata.ignore;\n destination.transformations.push(metadata.transformation);\n }\n return destination;\n };\n AutoMapper.prototype.mergeSourceProperty = function (property, existingProperties, sourceMapping) {\n // find source property\n var existing = sourceMapping\n ? this.findProperty(property.name, existingProperties)\n : this.matchSourcePropertyByDestination(property, existingProperties);\n if (!existing) {\n return false;\n }\n if (property.destination) {\n if (existing.children.length > 0) {\n var existingDestination = this.getDestinationProperty(existing.destinationPropertyName, existing);\n // existing is (further) nested => rebase and/or merge\n if (this.handleMapFromProperties(property, existing)) {\n // merge and rebase existing destination to current source level\n if (!this.mergeDestinationProperty(property.destination, existingDestination)) {\n return false;\n }\n existing.destination = existingDestination;\n existing.children = [];\n return true;\n }\n // merge property.destination with existing mapFrom() destination (don't care about nesting depth here)\n return this.mergeDestinationProperty(property.destination, existingDestination);\n }\n // both are at same level => simple merge.\n if (!this.mergeDestinationProperty(property.destination, existing.destination)) {\n return false;\n }\n this.handleMapFromProperties(property, existing);\n return true;\n }\n // new source is (further) nested (has children).\n if (existing.children.length > 0) {\n // both have further nesting, delegate merging child(ren) by recursively calling this function.\n for (var _i = 0, _a = property.children; _i < _a.length; _i++) {\n var child = _a[_i];\n if (!this.mergeSourceProperty(child, existing.children, sourceMapping)) {\n return false;\n }\n }\n if (property.destinationPropertyName !== property.sourcePropertyName) {\n // this is a mapFrom() registration. It is handled using the nested source properties,\n // we only are responsible for syncing the name properties.\n existing.name = property.name;\n existing.sourcePropertyName = property.sourcePropertyName;\n }\n return true;\n }\n // existing is not (further) nested. this is always a mapFrom() situation.\n // if (property.sourcePropertyName !== existing.sourcePropertyName) {\n var newDestination = this.getDestinationProperty(existing.destinationPropertyName, property);\n if (property.destinationPropertyName !== property.sourcePropertyName) {\n // this is a mapFrom() registration. In that case:\n // 1) merge destinations, 2) add source child and 3) move destination to (youngest) child\n // NOTE special mergeDestinationProperty call => we use the new destination as 'target',\n // because that will save us trouble overwriting ;)...\n if (!this.mergeDestinationProperty(existing.destination, newDestination, true)) {\n return false;\n }\n existing.children = property.children;\n existing.name = property.name;\n existing.sourcePropertyName = property.sourcePropertyName;\n existing.destination = null;\n // TODO Should never be necessary (test): existing.destinationPropertyName = property.destinationPropertyName;\n return true;\n }\n // ... nope, it is a destination which has previously been registered using mapFrom. just merge\n return this.mergeDestinationProperty(newDestination, existing.destination);\n // }\n };\n /**\n * handle property naming when the current property to merge is a mapFrom property\n */\n AutoMapper.prototype.handleMapFromProperties = function (property, existingProperty) {\n if (property.destinationPropertyName === property.sourcePropertyName ||\n property.sourcePropertyName === existingProperty.sourcePropertyName) {\n return false;\n }\n // only overwrite name when a mapFrom situation applies\n existingProperty.name = property.name;\n existingProperty.sourcePropertyName = property.sourcePropertyName;\n // TODO Should never be necessary (test) => existingProperty.destinationPropertyName = property.destinationPropertyName;\n return true;\n };\n AutoMapper.prototype.getDestinationProperty = function (destinationPropertyName, existingSource) {\n if (existingSource.destination) {\n return existingSource.destination;\n }\n for (var _i = 0, _a = existingSource.children; _i < _a.length; _i++) {\n var child = _a[_i];\n var destination = this.getDestinationProperty(destinationPropertyName, child);\n if (destination) {\n return destination;\n }\n }\n return null;\n };\n AutoMapper.prototype.mergeDestinationProperty = function (destination, existingDestination, swapTransformations) {\n if (swapTransformations === void 0) { swapTransformations = false; }\n if (destination.child) {\n if (existingDestination.child) {\n // both have further nesting, delegate merging children by recursively calling this function.\n if (!this.mergeDestinationProperty(destination.child, existingDestination.child, swapTransformations)) {\n return false;\n }\n this.handleMapFromProperties(destination, existingDestination);\n return true;\n }\n // the current destination is not (further) nested. a destination property registration has one of both:\n // a) children or b) transformations. returning false will cause creating a duplicate source property entry instead.\n return false;\n }\n if (existingDestination.sourceMapping !== destination.sourceMapping &&\n existingDestination.sourcePropertyName !== destination.sourcePropertyName) {\n // unable to perform mapFrom() on a property which is being registered using forSourceMember.\n return false; // TODO: Unpredictable? Idea: throw new Error('Unable to perform mapFrom() on a property which is being registered using forSourceMember.');\n }\n // merge destination properties\n if (destination.sourceMapping) {\n // only set source mapping when not yet set to true, once source mapped is source mapped forever.\n // TODO Verify edge cases!\n existingDestination.sourceMapping = destination.sourceMapping;\n }\n if (destination.ignore) {\n // only set ignore when not yet set, once ignored is ignored forever.\n existingDestination.ignore = destination.ignore;\n }\n if (destination.conditionFunction) {\n // overwrite condition function by the latest one specified.\n existingDestination.conditionFunction = destination.conditionFunction;\n }\n var transformations = [];\n if (swapTransformations) {\n for (var _i = 0, _a = destination.transformations; _i < _a.length; _i++) {\n var transformation = _a[_i];\n transformations.push(transformation);\n }\n for (var _b = 0, _c = existingDestination.transformations; _b < _c.length; _b++) {\n var transformation = _c[_b];\n transformations.push(transformation);\n }\n }\n else {\n for (var _d = 0, _e = existingDestination.transformations; _d < _e.length; _d++) {\n var transformation = _e[_d];\n transformations.push(transformation);\n }\n for (var _f = 0, _g = destination.transformations; _f < _g.length; _f++) {\n var transformation = _g[_f];\n transformations.push(transformation);\n }\n }\n existingDestination.transformations = transformations;\n this.handleMapFromProperties(destination, existingDestination);\n return true;\n };\n AutoMapper.prototype.matchSourcePropertyByDestination = function (source, properties) {\n if (!properties) {\n return null;\n }\n for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {\n var property = properties_1[_i];\n if (property.destinationPropertyName === source.destinationPropertyName) {\n return property;\n }\n }\n return null;\n };\n AutoMapper.prototype.findProperty = function (name, properties) {\n if (!properties) {\n return null;\n }\n for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) {\n var property = properties_2[_i];\n if (property.name === name) {\n return property;\n }\n }\n return null;\n };\n return AutoMapper;\n }(AutoMapperJs.AutoMapperBase));\n AutoMapper._instance = new AutoMapper();\n AutoMapperJs.AutoMapper = AutoMapper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n// Add AutoMapper to the application's global scope. Of course, you could still use Core.AutoMapper.getInstance() as well.\nvar automapper = (function (app) {\n app.automapper = AutoMapperJs.AutoMapper.getInstance();\n return app.automapper;\n})(this);\n\n//# sourceMappingURL=AutoMapper.js.map\n","/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * Converts source type to destination type instead of normal member mapping\n */\n var Profile = (function () {\n function Profile() {\n }\n /**\n * Implement this method in a derived class and call the CreateMap method to associate that map with this profile.\n * Avoid calling the AutoMapper class / automapper instance from this method.\n */\n Profile.prototype.configure = function () {\n // do nothing\n };\n /**\n * Create a mapping profile.\n * @param {string} sourceKey The map source key.\n * @param {string} destinationKey The map destination key.\n * @returns {Core.ICreateMapFluentFunctions}\n */\n Profile.prototype.createMap = function (sourceKey, destinationKey) {\n var argsCopy = Array.prototype.slice.apply(arguments);\n for (var index = 0, length = argsCopy.length; index < length; index++) {\n if (argsCopy[index]) {\n // prefix sourceKey and destinationKey with 'profileName=>'\n argsCopy[index] = this.profileName + \"=>\" + argsCopy[index];\n }\n }\n // pass through using arguments to keep createMap's currying support fully functional.\n return automapper.createMap.apply(automapper, argsCopy);\n };\n return Profile;\n }());\n AutoMapperJs.Profile = Profile;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=Profile.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * Converts source type to destination type instead of normal member mapping\n */\n var TypeConverter = (function () {\n function TypeConverter() {\n }\n /**\n * Performs conversion from source to destination type.\n * @param {IResolutionContext} resolutionContext Resolution context.\n * @returns {any} Destination object.\n */\n TypeConverter.prototype.convert = function (resolutionContext) {\n // NOTE BL Unfortunately, TypeScript/JavaScript do not support abstract base classes.\n // This is just one way around, please convince me about a better solution.\n throw new Error('The TypeConverter.convert method is abstract. Use a TypeConverter extension class instead.');\n };\n return TypeConverter;\n }());\n AutoMapperJs.TypeConverter = TypeConverter;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=TypeConverter.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var CamelCaseNamingConvention = (function () {\n function CamelCaseNamingConvention() {\n this.splittingExpression = /(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\n this.separatorCharacter = '';\n }\n CamelCaseNamingConvention.prototype.transformPropertyName = function (sourcePropertyNameParts) {\n // Transform the splitted parts.\n var result = '';\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\n if (index === 0) {\n result += sourcePropertyNameParts[index].charAt(0).toLowerCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n else {\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n }\n return result;\n };\n return CamelCaseNamingConvention;\n }());\n AutoMapperJs.CamelCaseNamingConvention = CamelCaseNamingConvention;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=CamelCaseNamingConvention.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var PascalCaseNamingConvention = (function () {\n function PascalCaseNamingConvention() {\n this.splittingExpression = /(^[A-Z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\n this.separatorCharacter = '';\n }\n PascalCaseNamingConvention.prototype.transformPropertyName = function (sourcePropertyNameParts) {\n // Transform the splitted parts.\n var result = '';\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\n sourcePropertyNameParts[index].substr(1);\n //if (index < (length - 1)) {\n // this.separatorCharacter;\n //}\n }\n return result;\n };\n return PascalCaseNamingConvention;\n }());\n AutoMapperJs.PascalCaseNamingConvention = PascalCaseNamingConvention;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=PascalCaseNamingConvention.js.map\n"]} \ No newline at end of file diff --git a/dist/automapper.min.js b/dist/automapper.min.js index 648780c..09acfcb 100644 --- a/dist/automapper.min.js +++ b/dist/automapper.min.js @@ -1,11 +1,11 @@ /*! - * TypeScript / Javascript AutoMapper Library v1.8.1 + * TypeScript / Javascript AutoMapper Library v1.8.2 * https://github.com/loedeman/AutoMapper * * Copyright 2015-2017 Interest IT / Bert Loedeman and other contributors * Released under the MIT license * - * Date: 2017-01-05T17:00:00.000Z + * Date: 2017-05-29T16: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();if("["===n.charAt(0))var o=n.match(/\[\w+\s*(\w+)\]/);else var o=n.match(/function\s*(\w+)/);if(o&&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};var i;return i=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(n===!1)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(d,l)),c.push(d)));for(var g in l)l.hasOwnProperty(g)&&(c.indexOf(g)>=0||u("Destination member '"+g+"' 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=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\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper helper functions\n */\n var AutoMapperHelper = (function () {\n function AutoMapperHelper() {\n }\n AutoMapperHelper.getClassName = function (classType) {\n if (classType && classType.name) {\n return classType.name;\n }\n // source: http://stackoverflow.com/a/13914278/702357\n if (classType && classType.constructor) {\n var className = classType.toString();\n if (className) {\n // classType.toString() is \"function classType (...) { ... }\"\n var matchParts = className.match(/function\\s*(\\w+)/);\n if (matchParts && matchParts.length === 2) {\n return matchParts[1];\n }\n }\n // for browsers which have name property in the constructor\n // of the object, such as chrome\n if (classType.constructor.name) {\n return classType.constructor.name;\n }\n if (classType.constructor.toString()) {\n var str = classType.constructor.toString();\n if (str.charAt(0) === '[') {\n // executed if the return of object.constructor.toString() is \"[object objectClass]\"\n var arr = str.match(/\\[\\w+\\s*(\\w+)\\]/);\n }\n else {\n // executed if the return of object.constructor.toString() is \"function objectClass () {}\"\n // (IE and Firefox)\n var arr = str.match(/function\\s*(\\w+)/);\n }\n if (arr && arr.length === 2) {\n return arr[1];\n }\n }\n }\n throw new Error(\"Unable to extract class name from type '\" + classType + \"'\");\n };\n AutoMapperHelper.getFunctionParameters = function (functionStr) {\n var stripComments = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg;\n var argumentNames = /([^\\s,]+)/g;\n var functionString = functionStr.replace(stripComments, '');\n var functionParameterNames = functionString.slice(functionString.indexOf('(') + 1, functionString.indexOf(')')).match(argumentNames);\n if (functionParameterNames === null) {\n functionParameterNames = new Array();\n }\n return functionParameterNames;\n };\n AutoMapperHelper.handleCurrying = function (func, args, closure) {\n var argumentsStillToCome = func.length - args.length;\n // saved accumulator array\n // NOTE BL this does not deep copy array objects, only the array itself; should side effects occur, please report (or refactor).\n var argumentsCopy = Array.prototype.slice.apply(args);\n function accumulator(moreArgs, alreadyProvidedArgs, stillToCome) {\n var previousAlreadyProvidedArgs = alreadyProvidedArgs.slice(0); // to reset\n var previousStillToCome = stillToCome; // to reset\n for (var i = 0; i < moreArgs.length; i++, stillToCome--) {\n alreadyProvidedArgs[alreadyProvidedArgs.length] = moreArgs[i];\n }\n if (stillToCome - moreArgs.length <= 0) {\n var functionCallResult = func.apply(closure, alreadyProvidedArgs);\n // reset vars, so curried function can be applied to new params.\n alreadyProvidedArgs = previousAlreadyProvidedArgs;\n stillToCome = previousStillToCome;\n return functionCallResult;\n }\n else {\n return function () {\n // arguments are params, so closure bussiness is avoided.\n return accumulator(arguments, alreadyProvidedArgs.slice(0), stillToCome);\n };\n }\n }\n return accumulator([], argumentsCopy, argumentsStillToCome);\n };\n AutoMapperHelper.getMappingMetadataFromTransformationFunction = function (destination, func, sourceMapping) {\n if (typeof func !== 'function') {\n return {\n destination: destination,\n source: destination,\n transformation: AutoMapperHelper.getDestinationTransformation(func, false, sourceMapping, false),\n sourceMapping: sourceMapping,\n condition: null,\n ignore: false,\n async: false\n };\n }\n var functionStr = func.toString();\n var parameterNames = AutoMapperHelper.getFunctionParameters(functionStr);\n var optsParamName = parameterNames.length >= 1 ? parameterNames[0] : '';\n var source = sourceMapping\n ? destination\n : AutoMapperHelper.getMapFromString(functionStr, destination, optsParamName);\n var metadata = {\n destination: destination,\n source: source,\n transformation: AutoMapperHelper.getDestinationTransformation(func, true, sourceMapping, parameterNames.length === 2),\n sourceMapping: sourceMapping,\n condition: null,\n ignore: AutoMapperHelper.getIgnoreFromString(functionStr, destination),\n async: parameterNames.length === 2\n };\n // calling the member options function when used asynchronous would be too 'dangerous'.\n if (!metadata.async && AutoMapperHelper.getFunctionCallIndex(functionStr, 'condition', optsParamName) >= 0) {\n metadata.condition = AutoMapperHelper.getConditionFromFunction(func, source);\n }\n return metadata;\n };\n AutoMapperHelper.getDestinationTransformation = function (func, isFunction, sourceMapping, async) {\n if (!isFunction) {\n return {\n transformationType: AutoMapperJs.DestinationTransformationType.Constant,\n constant: func\n };\n }\n var transformation;\n if (sourceMapping) {\n if (async) {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.AsyncSourceMemberOptions,\n asyncSourceMemberConfigurationOptionsFunc: func\n };\n }\n else {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.SourceMemberOptions,\n sourceMemberConfigurationOptionsFunc: func\n };\n }\n }\n else {\n if (async) {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.AsyncMemberOptions,\n asyncMemberConfigurationOptionsFunc: func\n };\n }\n else {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.MemberOptions,\n memberConfigurationOptionsFunc: func\n };\n }\n }\n return transformation;\n };\n AutoMapperHelper.getIgnoreFromString = function (functionString, optionsParameterName) {\n var indexOfIgnore = AutoMapperHelper.getFunctionCallIndex(functionString, 'ignore', optionsParameterName);\n if (indexOfIgnore < 0) {\n return false;\n }\n var indexOfMapFromStart = functionString.indexOf('(', indexOfIgnore) + 1;\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\n return false;\n }\n var ignoreString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/\\r/g, '').replace(/\\n/g, '').trim();\n return ignoreString === null || ignoreString === ''\n ? true // .ignore()\n : false; // .ignore( -> unexpected content)\n };\n AutoMapperHelper.getMapFromString = function (functionString, defaultValue, optionsParameterName) {\n var indexOfMapFrom = AutoMapperHelper.getFunctionCallIndex(functionString, 'mapFrom', optionsParameterName);\n if (indexOfMapFrom < 0) {\n return defaultValue;\n }\n var indexOfMapFromStart = functionString.indexOf('(', indexOfMapFrom) + 1;\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\n return defaultValue;\n }\n var mapFromString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/'/g, '').replace(/\"/g, '').trim();\n return mapFromString === null || mapFromString === ''\n ? defaultValue\n : mapFromString;\n };\n AutoMapperHelper.getFunctionCallIndex = function (functionString, functionToLookFor, optionsParameterName) {\n var indexOfFunctionCall = functionString.indexOf(optionsParameterName + '.' + functionToLookFor);\n if (indexOfFunctionCall < 0) {\n indexOfFunctionCall = functionString.indexOf('.' + functionToLookFor);\n }\n return indexOfFunctionCall;\n };\n AutoMapperHelper.getConditionFromFunction = function (func, sourceProperty) {\n // Since we are calling the valueOrFunction function to determine whether to ignore or map from another property, we\n // want to prevent the call to be error prone when the end user uses the '(opts)=> opts.sourceObject.sourcePropertyName'\n // syntax. We don't actually have a source object when creating a mapping; therefore, we 'stub' a source object for the\n // function call.\n var sourceObject = {};\n sourceObject[sourceProperty] = {};\n var condition;\n // calling the function will result in calling our stubbed ignore() and mapFrom() functions if used inside the function.\n var configFuncOptions = {\n ignore: function () {\n // do nothing\n },\n condition: function (predicate) {\n condition = predicate;\n },\n mapFrom: function (sourcePropertyName) {\n // do nothing\n },\n sourceObject: sourceObject,\n sourcePropertyName: sourceProperty,\n intermediatePropertyValue: {}\n };\n try {\n func(configFuncOptions);\n }\n catch (exc) {\n }\n return condition;\n };\n return AutoMapperHelper;\n }());\n AutoMapperJs.AutoMapperHelper = AutoMapperHelper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperHelper.js.map\n","/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper configuration validator.\n */\n var AutoMapperValidator = (function () {\n function AutoMapperValidator() {\n }\n /**\n * Validates mapping configuration by dry-running. Since JS does not\n * fully support typing, it only checks if properties match on both\n * sides. The function needs IMapping.sourceTypeClass and\n * IMapping.destinationTypeClass to function.\n * @param {boolean} strictMode Whether or not to fail when properties\n * sourceTypeClass or destinationTypeClass\n * are unavailable.\n */\n AutoMapperValidator.assertConfigurationIsValid = function (mappings, strictMode) {\n for (var key in mappings) {\n if (!mappings.hasOwnProperty(key)) {\n continue;\n }\n AutoMapperValidator.assertMappingConfiguration(mappings[key], strictMode);\n }\n };\n AutoMapperValidator.assertMappingConfiguration = function (mapping, strictMode) {\n var mappingKey = mapping.sourceKey + \"=>\" + mapping.destinationKey;\n var sourceType = mapping.sourceTypeClass;\n var destinationType = mapping.destinationTypeClass;\n var sourceClassName = sourceType ? AutoMapperJs.AutoMapperHelper.getClassName(sourceType) : undefined;\n var destinationClassName = destinationType ? AutoMapperJs.AutoMapperHelper.getClassName(destinationType) : undefined;\n if (!sourceType || !destinationType) {\n if (strictMode === false) {\n return;\n }\n throw new Error(\"Mapping '\" + mappingKey + \"' cannot be validated, since mapping.sourceType or mapping.destinationType are unspecified.\");\n }\n var tryHandle = function (errorMessage) {\n if (errorMessage) {\n throw new Error(\"Mapping '\" + mappingKey + \"' is invalid: \" + errorMessage + \" (source: '\" + sourceClassName + \"', destination: '\" + destinationClassName + \"').\");\n }\n };\n var validatedMembers = new Array();\n var srcObj = new sourceType();\n var dstObj = new destinationType();\n // walk member mappings\n for (var _i = 0, _a = mapping.properties; _i < _a.length; _i++) {\n var property = _a[_i];\n tryHandle(AutoMapperValidator.validatePropertyMapping(property, property.name, srcObj, dstObj));\n validatedMembers.push(property.name);\n }\n // walk source members\n for (var srcMember in srcObj) {\n if (!srcObj.hasOwnProperty(srcMember)) {\n continue;\n }\n if (validatedMembers.indexOf(srcMember) >= 0) {\n // already validated\n continue;\n }\n tryHandle(AutoMapperValidator.validateProperty(srcMember, dstObj));\n validatedMembers.push(srcMember);\n }\n // walk destination members\n for (var dstMember in dstObj) {\n if (!dstObj.hasOwnProperty(dstMember)) {\n continue;\n }\n if (validatedMembers.indexOf(dstMember) >= 0) {\n // already validated\n continue;\n }\n tryHandle(\"Destination member '\" + dstMember + \"' does not exist on source type\");\n }\n // /* tslint:disable */\n // console.error(key);\n // /* tslint:enable */ \n };\n AutoMapperValidator.validatePropertyMapping = function (propertyMapping, member, srcObj, dstObj) {\n // awkward way of locating sourceMapping ;) ...\n var destinationProperty = AutoMapperValidator.getDestinationProperty(propertyMapping.destinationPropertyName, propertyMapping);\n return destinationProperty.sourceMapping\n ? AutoMapperValidator.validateSourcePropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj)\n : AutoMapperValidator.validateDestinationPropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj);\n };\n AutoMapperValidator.validateSourcePropertyMapping = function (ropertyMapping, destinationProperty, member, srcObj, dstObj) {\n // a member for which configuration is provided, should exist.\n if (!srcObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is configured, but does not exist on source type\";\n }\n // an ignored source member should not exist on the destination type. \n if (destinationProperty.ignore) {\n if (dstObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is ignored, but does exist on destination type\";\n }\n return undefined;\n }\n // a mapped source member should exist on the destination type.\n if (!dstObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is configured to be mapped, but does not exist on destination type\";\n }\n //var dstMember = propertyMapping.destinationProperty;\n return undefined;\n };\n AutoMapperValidator.validateDestinationPropertyMapping = function (propertyMapping, destinationProperty, member, srcObj, dstObj) {\n // a member for which configuration is provided, should exist.\n if (!dstObj.hasOwnProperty(destinationProperty.name)) {\n return \"Destination member '\" + destinationProperty.destinationPropertyName + \"' is configured, but does not exist on destination type\";\n }\n // an ignored destination member should not exist on the source type. \n if (destinationProperty.ignore) {\n if (srcObj.hasOwnProperty(member)) {\n return \"Destination member '\" + member + \"' is ignored, but does exist on source type\";\n }\n return undefined;\n }\n // a mapped destination member should exist on the source type.\n if (!srcObj.hasOwnProperty(member)) {\n return \"Destination member '\" + member + \"' is configured to be mapped, but does not exist on source type\";\n }\n //var dstMember = propertyMapping.destinationProperty;\n return undefined;\n };\n AutoMapperValidator.validateProperty = function (srcMember, dstObj) {\n if (!dstObj.hasOwnProperty(srcMember)) {\n return \"Source member '\" + srcMember + \"' is configured to be mapped, but does not exist on destination type\";\n }\n return undefined;\n };\n AutoMapperValidator.getDestinationProperty = function (destinationPropertyName, existingSource) {\n if (existingSource.destination) {\n return existingSource.destination;\n }\n if (existingSource.children) {\n for (var _i = 0, _a = existingSource.children; _i < _a.length; _i++) {\n var child = _a[_i];\n var destination = this.getDestinationProperty(destinationPropertyName, child);\n if (destination) {\n return destination;\n }\n }\n }\n return null;\n };\n return AutoMapperValidator;\n }());\n AutoMapperJs.AutoMapperValidator = AutoMapperValidator;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperValidator.js.map\n","var AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var DestinationTransformationType;\n (function (DestinationTransformationType) {\n DestinationTransformationType[DestinationTransformationType[\"Constant\"] = 1] = \"Constant\";\n DestinationTransformationType[DestinationTransformationType[\"MemberOptions\"] = 2] = \"MemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"AsyncMemberOptions\"] = 4] = \"AsyncMemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"SourceMemberOptions\"] = 8] = \"SourceMemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"AsyncSourceMemberOptions\"] = 16] = \"AsyncSourceMemberOptions\";\n })(DestinationTransformationType = AutoMapperJs.DestinationTransformationType || (AutoMapperJs.DestinationTransformationType = {}));\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperEnumerations.js.map\n","/// \n/// \n/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper implementation, for both creating maps and performing maps. Comparable usage and functionality to the original\n * .NET AutoMapper library is the pursuit of this implementation.\n */\n var AutoMapperBase = (function () {\n function AutoMapperBase() {\n }\n AutoMapperBase.prototype.getMapping = function (mappings, sourceKey, destinationKey) {\n var srcKey = this.getKey(sourceKey);\n var dstKey = this.getKey(destinationKey);\n var mapping = mappings[srcKey + dstKey];\n if (!mapping) {\n throw new Error(\"Could not find map object with a source of \" + srcKey + \" and a destination of \" + dstKey);\n }\n return mapping;\n };\n AutoMapperBase.prototype.getKey = function (keyStringOrType) {\n if (typeof keyStringOrType === 'string') {\n return keyStringOrType;\n }\n else {\n return AutoMapperJs.AutoMapperHelper.getClassName(keyStringOrType);\n }\n };\n AutoMapperBase.prototype.isArray = function (sourceObject) {\n return sourceObject instanceof Array;\n };\n AutoMapperBase.prototype.handleArray = function (mapping, sourceArray, itemFunc) {\n var arrayLength = sourceArray.length;\n var destinationArray = new Array(sourceArray.length);\n for (var index = 0; index < arrayLength; index++) {\n var sourceObject = sourceArray[index];\n var destinationObject = void 0;\n if (sourceObject === null || sourceObject === undefined) {\n destinationObject = sourceObject;\n }\n else {\n destinationObject = this.createDestinationObject(mapping.destinationTypeClass);\n itemFunc(sourceObject, destinationObject);\n }\n destinationArray[index] = destinationObject;\n }\n return destinationArray;\n };\n AutoMapperBase.prototype.handleItem = function (mapping, sourceObject, destinationObject, propertyFunction) {\n // var sourceProperties: string[] = [];\n var atLeastOnePropertyMapped = false;\n // handle mapped properties ...\n for (var _i = 0, _a = mapping.properties; _i < _a.length; _i++) {\n var property = _a[_i];\n // sourceProperties.push(property.name);\n atLeastOnePropertyMapped = true;\n propertyFunction(property.name);\n }\n // .. and, after that, handle unmapped properties\n for (var sourcePropertyName in sourceObject) {\n if (!sourceObject.hasOwnProperty(sourcePropertyName)) {\n continue;\n }\n if (destinationObject[sourcePropertyName]) {\n // ... but, if the destination property already exists, don't map again (probably a mapFrom situation).\n continue;\n }\n // if (sourceProperties.indexOf(sourcePropertyName) >= 0) {\n // continue;\n // }\n atLeastOnePropertyMapped = true;\n propertyFunction(sourcePropertyName);\n }\n // return null/undefined sourceObject if no properties added\n if (!atLeastOnePropertyMapped && (sourceObject === null || sourceObject === undefined)) {\n return sourceObject;\n }\n return destinationObject;\n };\n AutoMapperBase.prototype.handleProperty = function (mapping, sourceObject, sourcePropertyName, destinationObject, transformFunction, autoMappingCallbackFunction) {\n // TODO Property mappings are already located before\n // TODO handleProperty seems only to be called when processing a mapped property.\n var propertyMappings = this.getPropertyMappings(mapping.properties, sourcePropertyName);\n if (propertyMappings.length > 0) {\n for (var _i = 0, propertyMappings_1 = propertyMappings; _i < propertyMappings_1.length; _i++) {\n var propertyMapping = propertyMappings_1[_i];\n this.processMappedProperty(mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction);\n }\n }\n else {\n this.handlePropertyWithAutoMapping(mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction);\n }\n };\n AutoMapperBase.prototype.setPropertyValue = function (mapping, destinationProperty, destinationObject, destinationPropertyValue) {\n if (mapping.forAllMemberMappings.length > 0) {\n for (var _i = 0, _a = mapping.forAllMemberMappings; _i < _a.length; _i++) {\n var forAllMemberMapping = _a[_i];\n forAllMemberMapping(destinationObject, destinationProperty.name, destinationPropertyValue);\n }\n }\n else {\n destinationObject[destinationProperty.name] = destinationPropertyValue;\n }\n };\n AutoMapperBase.prototype.setPropertyValueByName = function (mapping, destinationObject, destinationProperty, destinationPropertyValue) {\n if (mapping.forAllMemberMappings.length > 0) {\n for (var _i = 0, _a = mapping.forAllMemberMappings; _i < _a.length; _i++) {\n var forAllMemberMapping = _a[_i];\n forAllMemberMapping(destinationObject, destinationProperty, destinationPropertyValue);\n }\n }\n else {\n destinationObject[destinationProperty] = destinationPropertyValue;\n }\n };\n AutoMapperBase.prototype.createDestinationObject = function (destinationType) {\n // create empty destination object.\n return destinationType\n ? new destinationType()\n : {};\n };\n AutoMapperBase.prototype.shouldProcessDestination = function (destination, sourceObject) {\n if (destination.ignore) {\n // ignore ignored properties\n return false;\n }\n if (destination.conditionFunction) {\n // check for condition function, and, if there is ...\n if (destination.conditionFunction(sourceObject) === false) {\n // ... return when the condition is not met.\n return false;\n }\n }\n return true;\n };\n // protected throwMappingException(propertyMapping: IProperty, message: string): void {\n // throw new Error(`Cannot map '${propertyMapping.sourcePropertyName}' to '${propertyMapping.destinationPropertyName}' => ${message}`);\n // }\n AutoMapperBase.prototype.handlePropertyWithAutoMapping = function (mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction) {\n // no forMember mapping exists, auto map properties, except for the situation where ignoreAllNonExisting is specified.\n if (mapping.ignoreAllNonExisting) {\n return;\n }\n if (mapping.destinationTypeClass && Object.keys(destinationObject).indexOf(sourcePropertyName) < 0) {\n return;\n }\n var objectValue = null;\n var isNestedObject = false;\n if (typeof destinationObject[sourcePropertyName] === 'object' && destinationObject[sourcePropertyName]) {\n isNestedObject = (destinationObject[sourcePropertyName].constructor.name !== 'Object');\n if (isNestedObject) {\n this\n .createMap(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name)\n .convertToType(destinationObject[sourcePropertyName].constructor);\n objectValue = this.map(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name, sourceObject[sourcePropertyName]);\n }\n }\n // use profile mapping when specified; otherwise, specify source property name as destination property name.\n var destinationPropertyName = this.getDestinationPropertyName(mapping.profile, sourcePropertyName);\n var destinationPropertyValue = this.getDestinationPropertyValue(sourceObject, sourcePropertyName, objectValue, isNestedObject);\n this.setPropertyValueByName(mapping, destinationObject, destinationPropertyName, destinationPropertyValue);\n if (autoMappingCallbackFunction) {\n autoMappingCallbackFunction(destinationPropertyValue);\n }\n };\n AutoMapperBase.prototype.getDestinationPropertyValue = function (sourceObject, sourcePropertyName, objectValue, isNestedObject) {\n if (isNestedObject) {\n return objectValue;\n }\n return sourceObject ? sourceObject[sourcePropertyName] : null;\n };\n AutoMapperBase.prototype.getDestinationPropertyName = function (profile, sourcePropertyName) {\n if (!profile) {\n return sourcePropertyName;\n }\n // TODO BL no support yet for INamingConvention.splittingCharacter\n try {\n // First, split the source property name based on the splitting expression.\n // TODO BL Caching of RegExp splitting!\n var sourcePropertyNameParts = sourcePropertyName.split(profile.sourceMemberNamingConvention.splittingExpression);\n // NOTE BL For some reason, splitting by (my ;)) RegExp results in empty strings in the array; remove them.\n for (var index = sourcePropertyNameParts.length - 1; index >= 0; index--) {\n if (sourcePropertyNameParts[index] === '') {\n sourcePropertyNameParts.splice(index, 1);\n }\n }\n return profile.destinationMemberNamingConvention.transformPropertyName(sourcePropertyNameParts);\n }\n catch (error) {\n return sourcePropertyName;\n }\n };\n AutoMapperBase.prototype.getPropertyMappings = function (properties, sourcePropertyName) {\n var result = [];\n for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {\n var property = properties_1[_i];\n if (property.name === sourcePropertyName) {\n result.push(property);\n }\n }\n return result;\n };\n AutoMapperBase.prototype.processMappedProperty = function (mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction) {\n if (propertyMapping.children && propertyMapping.children.length > 0) {\n // always pass child source object, even if source object does not exist => \n // constant transformations should always pass. \n var childSourceObject = sourceObject ? sourceObject[propertyMapping.name] : null;\n for (var _i = 0, _a = propertyMapping.children; _i < _a.length; _i++) {\n var child = _a[_i];\n this.processMappedProperty(mapping, child, childSourceObject, child.name, transformFunction);\n return;\n }\n }\n var destination = propertyMapping.destination;\n // if (!propertyMapping.destination) {\n // // it makes no sense to handle a property without destination(s).\n // this.throwMappingException(propertyMapping, 'no destination object');\n // }\n var configurationOptions = this.createMemberConfigurationOptions(sourceObject, sourcePropertyName);\n transformFunction(destination, configurationOptions);\n };\n AutoMapperBase.prototype.createMemberConfigurationOptions = function (sourceObject, sourcePropertyName) {\n var memberConfigurationOptions = {\n mapFrom: function (sourcePropertyName) {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.mapFrom(...)' function.\n },\n condition: function (predicate) {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.condition(...)' function.\n },\n ignore: function () {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.ignore()' function.\n },\n sourceObject: sourceObject,\n sourcePropertyName: sourcePropertyName,\n intermediatePropertyValue: sourceObject ? sourceObject[sourcePropertyName] : sourceObject\n };\n return memberConfigurationOptions;\n };\n return AutoMapperBase;\n }());\n AutoMapperJs.AutoMapperBase = AutoMapperBase;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperBase.js.map\n","/// \n/// \n/// \n/// \n/// \nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AsyncAutoMapper implementation, for asynchronous mapping support when using AutoMapper.\n */\n var AsyncAutoMapper = (function (_super) {\n __extends(AsyncAutoMapper, _super);\n function AsyncAutoMapper() {\n var _this = _super.call(this) || this;\n AsyncAutoMapper.asyncInstance = _this;\n return _this;\n }\n AsyncAutoMapper.prototype.createMap = function (sourceKeyOrType, destinationKeyOrType) {\n throw new Error('Method AsyncAutoMapper.createMap is not implemented.');\n };\n AsyncAutoMapper.prototype.createMapForMember = function (mapping, property) {\n var _this = this;\n mapping.async = true;\n mapping.mapItemFunction = function (m, srcObj, dstObj, cb) { return _this.mapItem(m, srcObj, dstObj, cb); };\n // property.async = true;\n // property.conversionValuesAndFunctions.push(func);\n };\n AsyncAutoMapper.prototype.createMapConvertUsing = function (mapping, converterFunction) {\n var _this = this;\n mapping.async = true;\n mapping.typeConverterFunction = converterFunction;\n mapping.mapItemFunction = function (m, srcObj, dstObj, cb) { return _this.mapItemUsingTypeConverter(m, srcObj, dstObj, cb); };\n };\n AsyncAutoMapper.prototype.map = function (mappings, sourceKey, destinationKey, sourceObject, callback) {\n var _this = this;\n switch (arguments.length) {\n case 5:\n this.mapWithMapping(_super.prototype.getMapping.call(this, mappings, sourceKey, destinationKey), sourceObject, callback);\n return;\n // provide performance optimized (preloading) currying support.\n case 4:\n return function (cb) { return _this.mapWithMapping(_super.prototype.getMapping.call(_this, mappings, sourceKey, destinationKey), sourceObject, cb); };\n case 3:\n return function (srcObj, cb) { return _this.mapWithMapping(_super.prototype.getMapping.call(_this, mappings, sourceKey, destinationKey), srcObj, cb); };\n case 2:\n return function (dstKey, srcObj, cb) { return _this.map(mappings, sourceKey, dstKey, srcObj, cb); };\n default:\n throw new Error('The AsyncAutoMapper.map function expects between 2 and 5 parameters, you provided ' + arguments.length + '.');\n }\n };\n AsyncAutoMapper.prototype.mapWithMapping = function (mapping, sourceObject, callback) {\n if (_super.prototype.isArray.call(this, sourceObject)) {\n this.mapArray(mapping, sourceObject, callback);\n return;\n }\n return mapping.mapItemFunction(mapping, sourceObject, _super.prototype.createDestinationObject.call(this, mapping.destinationTypeClass), callback);\n };\n /**\n * Execute a mapping from the source array to a new destination array with explicit mapping configuration and supplied mapping options (using createMap).\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceArray The source array to map.\n * @returns {Array} Destination array.\n */\n AsyncAutoMapper.prototype.mapArray = function (mapping, sourceArray, callback) {\n var callbacksToGo = 0;\n var destinationArray = _super.prototype.handleArray.call(this, mapping, sourceArray, function (sourceObject, destinationObject) {\n callbacksToGo++;\n mapping.mapItemFunction(mapping, sourceObject, destinationObject, function (result) {\n callbacksToGo--;\n });\n });\n var waitForCallbackToSend = function () {\n if (callbacksToGo === 0) {\n callback(destinationArray);\n }\n else {\n setTimeout(function () {\n waitForCallbackToSend();\n }, 10 * callbacksToGo);\n }\n };\n waitForCallbackToSend();\n };\n AsyncAutoMapper.prototype.mapItemUsingTypeConverter = function (mapping, sourceObject, destinationObject, callback) {\n var resolutionContext = {\n sourceValue: sourceObject,\n destinationValue: destinationObject\n };\n mapping.typeConverterFunction(resolutionContext, callback);\n };\n /**\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceObject The source object to map.\n * @param destinationObject The destination object to map to.\n * @param callback The callback to call after async mapping has been executed.\n */\n AsyncAutoMapper.prototype.mapItem = function (mapping, sourceObject, destinationObject, callback) {\n var _this = this;\n var callbacksToGo = 0;\n _super.prototype.handleItem.call(this, mapping, sourceObject, destinationObject, function (sourceProperty) {\n callbacksToGo++;\n _this.mapProperty(mapping, sourceObject, sourceProperty, destinationObject, function (result) {\n callbacksToGo--;\n });\n });\n var waitForCallbackToSend = function () {\n if (callbacksToGo === 0) {\n callback(destinationObject);\n }\n else {\n setTimeout(function () {\n waitForCallbackToSend();\n }, 10 * callbacksToGo);\n }\n };\n waitForCallbackToSend();\n };\n /**\n * Execute a mapping from the source object property to the destination object property with explicit mapping configuration and supplied mapping options.\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceObject The source object to map.\n * @param sourcePropertyName The source property to map.\n * @param destinationObject The destination object to map to.\n * @param callback The callback to call after async property mapping has been executed.\n */\n AsyncAutoMapper.prototype.mapProperty = function (mapping, sourceObject, sourceProperty, destinationObject, callback) {\n var _this = this;\n _super.prototype.handleProperty.call(this, mapping, sourceObject, sourceProperty, destinationObject, function (destinationProperty, options) {\n _this.transform(mapping, sourceObject, destinationProperty, destinationObject, options, function (destinationPropertyValue, success) {\n callback(destinationPropertyValue);\n });\n }, function (destinationPropertyValue) {\n callback(destinationPropertyValue);\n });\n };\n AsyncAutoMapper.prototype.transform = function (mapping, sourceObject, destinationProperty, destinationObject, options, callback) {\n var _this = this;\n var childDestinationProperty = destinationProperty.child;\n if (childDestinationProperty) {\n var childDestinationObject = destinationObject[destinationProperty.name];\n if (!childDestinationObject) {\n // no child source object? create. \n childDestinationObject = {};\n }\n // transform child by recursively calling the transform function.\n this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options, function (callbackValue, success) {\n if (success) {\n // only set child destination object when transformation has been successful.\n destinationObject[destinationProperty.name] = childDestinationObject;\n }\n callback(options.intermediatePropertyValue, success);\n });\n return;\n }\n if (!_super.prototype.shouldProcessDestination.call(this, destinationProperty, sourceObject)) {\n callback(undefined /* opts.intermediatePropertyValue */, false);\n return;\n }\n // actually transform destination property.\n this.processTransformations(destinationProperty, destinationProperty.transformations, options, function (callbackValue, success) {\n if (success) {\n _super.prototype.setPropertyValue.call(_this, mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\n }\n callback(options.intermediatePropertyValue, success);\n });\n };\n AsyncAutoMapper.prototype.processTransformations = function (property, transformations, options, callback) {\n var _this = this;\n if (transformations.length === 0) {\n callback(options.intermediatePropertyValue, true);\n return;\n }\n var transformation = transformations[0];\n this.processTransformation(property, transformation, options, function (callbackValue, success) {\n if (!success) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n _this.processTransformations(property, transformations.slice(1), options, callback);\n });\n };\n AsyncAutoMapper.prototype.processTransformation = function (property, transformation, options, callback) {\n switch (transformation.transformationType) {\n case AutoMapperJs.DestinationTransformationType.Constant:\n options.intermediatePropertyValue = transformation.constant;\n callback(options.intermediatePropertyValue, true);\n return;\n case AutoMapperJs.DestinationTransformationType.MemberOptions: {\n var result = transformation.memberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n }\n case AutoMapperJs.DestinationTransformationType.SourceMemberOptions: {\n var result = transformation.sourceMemberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n }\n case AutoMapperJs.DestinationTransformationType.AsyncMemberOptions:\n transformation.asyncMemberConfigurationOptionsFunc(options, function (result) {\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n });\n return;\n case AutoMapperJs.DestinationTransformationType.AsyncSourceMemberOptions:\n transformation.asyncSourceMemberConfigurationOptionsFunc(options, function (result) {\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n });\n return;\n default:\n // TODO: this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation}`);\n callback(options.intermediatePropertyValue, false);\n return;\n }\n };\n return AsyncAutoMapper;\n }(AutoMapperJs.AutoMapperBase));\n AsyncAutoMapper.asyncInstance = new AsyncAutoMapper();\n AutoMapperJs.AsyncAutoMapper = AsyncAutoMapper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AsyncAutoMapper.js.map\n","/// \n/// \n/// \n/// \n/// \n/// \n/// \nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var AutoMapper = (function (_super) {\n __extends(AutoMapper, _super);\n /**\n * This class is intended to be a Singleton. Preferrably use getInstance()\n * function instead of using the constructor directly from code.\n */\n function AutoMapper() {\n var _this = _super.call(this) || this;\n if (AutoMapper._instance) {\n return AutoMapper._instance;\n }\n else {\n AutoMapper._instance = _this;\n _this._profiles = {};\n _this._mappings = {};\n _this._asyncMapper = new AutoMapperJs.AsyncAutoMapper();\n }\n return _this;\n }\n AutoMapper.getInstance = function () {\n return AutoMapper._instance;\n };\n /**\n * Initializes the mapper with the supplied configuration.\n * @param {(config: IConfiguration) => void} configFunction Configuration function to call.\n */\n AutoMapper.prototype.initialize = function (configFunction) {\n var that = this;\n var configuration = {\n addProfile: function (profile) {\n profile.configure();\n that._profiles[profile.profileName] = profile;\n },\n createMap: function (sourceKey, destinationKey) {\n // pass through using arguments to keep createMap's currying support fully functional.\n return that.createMap.apply(that, arguments);\n }\n };\n configFunction(configuration);\n };\n /**\n * Create a mapping profile.\n * @param {string} sourceKey The map source key.\n * @param {string} destinationKey The map destination key.\n * @returns {Core.ICreateMapFluentFunctions}\n */\n AutoMapper.prototype.createMap = function (sourceKeyOrType, destinationKeyOrType) {\n // provide currying support.\n if (arguments.length < 2) {\n return AutoMapperJs.AutoMapperHelper.handleCurrying(this.createMap, arguments, this);\n }\n var mapping = this.createMappingObjectForGivenKeys(sourceKeyOrType, destinationKeyOrType);\n return this.createMapGetFluentApiFunctions(mapping);\n };\n /**\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param sourceKey Source key, for instance the source type name.\n * @param destinationKey Destination key, for instance the destination type name.\n * @param sourceObject The source object to map.\n * @returns {any} Destination object.\n */\n AutoMapper.prototype.map = function (sourceKeyOrType, destinationKeyOrType, sourceObject) {\n var _this = this;\n if (arguments.length === 3) {\n return this.mapInternal(_super.prototype.getMapping.call(this, this._mappings, sourceKeyOrType, destinationKeyOrType), sourceObject);\n }\n // provide performance optimized (preloading) currying support.\n if (arguments.length === 2) {\n return function (srcObj) { return _this.mapInternal(_super.prototype.getMapping.call(_this, _this._mappings, sourceKeyOrType, destinationKeyOrType), srcObj); };\n }\n if (arguments.length === 1) {\n return function (dstKey, srcObj) { return _this.map(sourceKeyOrType, dstKey, srcObj); };\n }\n return function (srcKey, dstKey, srcObj) { return _this.map(srcKey, dstKey, srcObj); };\n };\n /**\n * Execute an asynchronous mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param sourceKey Source key, for instance the source type name.\n * @param destinationKey Destination key, for instance the destination type name.\n * @param sourceObject The source object to map.\n * @param {IMapCallback} callback The callback to call when asynchronous mapping is complete.\n */\n AutoMapper.prototype.mapAsync = function (sourceKeyOrType, destinationKeyOrType, sourceObject, callback) {\n switch (arguments.length) {\n case 4:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject, callback);\n case 3:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject);\n case 2:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType);\n case 1:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType);\n default:\n throw new Error('The mapAsync function expects between 1 and 4 parameters, you provided ' + arguments.length + '.');\n }\n };\n /**\n * Validates mapping configuration by dry-running. Since JS does not fully support typing, it only checks if properties match on both\n * sides. The function needs IMapping.sourceTypeClass and IMapping.destinationTypeClass to function.\n * @param {boolean} strictMode Whether or not to fail when properties sourceTypeClass or destinationTypeClass are unavailable.\n */\n AutoMapper.prototype.assertConfigurationIsValid = function (strictMode) {\n if (strictMode === void 0) { strictMode = true; }\n AutoMapperJs.AutoMapperValidator.assertConfigurationIsValid(this._mappings, strictMode);\n };\n AutoMapper.prototype.createMapForAllMembers = function (mapping, fluentFunc, func) {\n mapping.forAllMemberMappings.push(func);\n return fluentFunc;\n };\n AutoMapper.prototype.createMapIgnoreAllNonExisting = function (mapping, fluentFunc) {\n mapping.ignoreAllNonExisting = true;\n return fluentFunc;\n };\n AutoMapper.prototype.createMapConvertToType = function (mapping, fluentFunc, typeClass) {\n if (mapping.destinationTypeClass) {\n throw new Error('Destination type class can only be set once.');\n }\n mapping.destinationTypeClass = typeClass;\n return fluentFunc;\n };\n AutoMapper.prototype.createMapConvertUsing = function (mapping, tcClassOrFunc) {\n var _this = this;\n var configureSynchronousConverterFunction = function (converterFunc) {\n if (!converterFunc || AutoMapperJs.AutoMapperHelper.getFunctionParameters(converterFunc.toString()).length !== 1) {\n throw new Error('The function provided does not provide exactly one (resolutionContext) parameter.');\n }\n mapping.typeConverterFunction = converterFunc;\n mapping.mapItemFunction = function (m, srcObj, dstObj) { return _this.mapItemUsingTypeConverter(m, srcObj, dstObj); };\n };\n try {\n // check if sync: TypeConverter instance\n if (tcClassOrFunc instanceof AutoMapperJs.TypeConverter) {\n configureSynchronousConverterFunction(tcClassOrFunc.convert);\n return;\n }\n var functionParameters = AutoMapperJs.AutoMapperHelper.getFunctionParameters(tcClassOrFunc.toString());\n switch (functionParameters.length) {\n case 0:\n // check if sync: TypeConverter class definition\n var typeConverter;\n try {\n typeConverter = new tcClassOrFunc();\n }\n catch (e) {\n }\n if (typeConverter instanceof AutoMapperJs.TypeConverter) {\n configureSynchronousConverterFunction(typeConverter.convert);\n return;\n }\n break;\n case 1:\n // sync: function with resolutionContext parameter\n configureSynchronousConverterFunction(tcClassOrFunc);\n return;\n case 2:\n // check if async: function with resolutionContext and callback parameters\n this._asyncMapper.createMapConvertUsing(mapping, tcClassOrFunc);\n return;\n }\n // okay, just try feeding the function to the configure function anyway...\n configureSynchronousConverterFunction(tcClassOrFunc);\n }\n catch (e) {\n throw new Error(\"The value provided for typeConverterClassOrFunction is invalid. \" + e);\n }\n };\n AutoMapper.prototype.createMapWithProfile = function (mapping, profileName) {\n // check if given profile exists\n var profile = this._profiles[profileName];\n if (typeof profile === 'undefined' || profile.profileName !== profileName) {\n throw new Error(\"Could not find profile with profile name '\" + profileName + \"'.\");\n }\n mapping.profile = profile;\n // merge mappings\n this.createMapWithProfileMergeMappings(mapping, profileName);\n };\n AutoMapper.prototype.createMapWithProfileMergeMappings = function (mapping, profileName) {\n var profileMappingKey = profileName + \"=>\" + mapping.sourceKey + profileName + \"=>\" + mapping.destinationKey;\n var profileMapping = this._mappings[profileMappingKey];\n if (!profileMapping) {\n return;\n }\n // append forAllMemberMappings calls to the original array.\n if (profileMapping.forAllMemberMappings.length > 0) {\n (_a = mapping.forAllMemberMappings).push.apply(_a, profileMapping.forAllMemberMappings);\n }\n // overwrite original type converter function\n if (profileMapping.typeConverterFunction) {\n mapping.typeConverterFunction = profileMapping.typeConverterFunction;\n mapping.mapItemFunction = profileMapping.mapItemFunction;\n }\n // overwrite original type converter function\n if (profileMapping.destinationTypeClass) {\n mapping.destinationTypeClass = profileMapping.destinationTypeClass;\n }\n // walk through all the profile's property mappings\n for (var _i = 0, _b = profileMapping.properties; _i < _b.length; _i++) {\n var property = _b[_i];\n // TODO Awkward way of locating sourceMapping ;) ...\n var sourceMapping = this.getDestinationProperty(property.destinationPropertyName, property).sourceMapping;\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\n mapping.properties.push(property);\n }\n }\n var _a;\n };\n AutoMapper.prototype.mapInternal = function (mapping, sourceObject) {\n if (mapping.async) {\n throw new Error('Impossible to use asynchronous mapping using automapper.map(); use automapper.mapAsync() instead.');\n }\n if (_super.prototype.isArray.call(this, sourceObject)) {\n return this.mapArray(mapping, sourceObject);\n }\n return mapping.mapItemFunction(mapping, sourceObject, _super.prototype.createDestinationObject.call(this, mapping.destinationTypeClass));\n };\n AutoMapper.prototype.mapArray = function (mapping, sourceArray) {\n var destinationArray = _super.prototype.handleArray.call(this, mapping, sourceArray, function (sourceObject, destinationObject) {\n mapping.mapItemFunction(mapping, sourceObject, destinationObject);\n });\n return destinationArray;\n };\n AutoMapper.prototype.mapItem = function (mapping, sourceObject, destinationObject) {\n var _this = this;\n destinationObject = _super.prototype.handleItem.call(this, mapping, sourceObject, destinationObject, function (propertyName) {\n _this.mapProperty(mapping, sourceObject, destinationObject, propertyName);\n });\n return destinationObject;\n };\n AutoMapper.prototype.mapItemUsingTypeConverter = function (mapping, sourceObject, destinationObject, arrayIndex) {\n var resolutionContext = {\n sourceValue: sourceObject,\n destinationValue: destinationObject\n };\n return mapping.typeConverterFunction(resolutionContext);\n };\n AutoMapper.prototype.mapProperty = function (mapping, sourceObject, destinationObject, sourceProperty) {\n var _this = this;\n _super.prototype.handleProperty.call(this, mapping, sourceObject, sourceProperty, destinationObject, function (destinationProperty, options) {\n return _this.transform(mapping, sourceObject, destinationProperty, destinationObject, options);\n });\n };\n AutoMapper.prototype.transform = function (mapping, sourceObject, destinationProperty, destinationObject, options) {\n var childDestinationProperty = destinationProperty.child;\n if (childDestinationProperty) {\n var childDestinationObject = destinationObject[destinationProperty.name];\n if (!childDestinationObject) {\n // no child source object? create. \n childDestinationObject = {};\n }\n // transform child by recursively calling the transform function.\n var transformed = this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options /*, callback*/);\n if (transformed) {\n // only set child destination object when transformation has been successful.\n destinationObject[destinationProperty.name] = childDestinationObject;\n }\n return transformed;\n }\n if (!_super.prototype.shouldProcessDestination.call(this, destinationProperty, sourceObject)) {\n return false;\n }\n // actually transform destination property.\n for (var _i = 0, _a = destinationProperty.transformations; _i < _a.length; _i++) {\n var transformation = _a[_i];\n if (!this.processTransformation(destinationProperty, transformation, options)) {\n return false;\n }\n }\n _super.prototype.setPropertyValue.call(this, mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\n return true;\n };\n AutoMapper.prototype.processTransformation = function (property, transformation, options) {\n switch (transformation.transformationType) {\n case AutoMapperJs.DestinationTransformationType.Constant:\n options.intermediatePropertyValue = transformation.constant;\n return true;\n case AutoMapperJs.DestinationTransformationType.MemberOptions: {\n var result = transformation.memberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n return false;\n }\n return true;\n }\n case AutoMapperJs.DestinationTransformationType.SourceMemberOptions: {\n var result = transformation.sourceMemberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n return false;\n }\n return true;\n }\n default:\n // this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation.transformationType}`);\n return false;\n }\n };\n AutoMapper.prototype.createMappingObjectForGivenKeys = function (srcKeyOrType, dstKeyOrType) {\n var _this = this;\n var mapping = {\n sourceKey: _super.prototype.getKey.call(this, srcKeyOrType),\n destinationKey: _super.prototype.getKey.call(this, dstKeyOrType),\n forAllMemberMappings: new Array(),\n properties: [],\n typeConverterFunction: undefined,\n mapItemFunction: function (m, srcObj, dstObj) { return _this.mapItem(m, srcObj, dstObj); },\n sourceTypeClass: (typeof srcKeyOrType === 'string' ? undefined : srcKeyOrType),\n destinationTypeClass: (typeof dstKeyOrType === 'string' ? undefined : dstKeyOrType),\n profile: undefined,\n async: false\n };\n this._mappings[mapping.sourceKey + mapping.destinationKey] = mapping;\n return mapping;\n };\n AutoMapper.prototype.createMapGetFluentApiFunctions = function (mapping) {\n var _this = this;\n // create a fluent interface / method chaining (e.g. automapper.createMap().forMember().forMember() ...)\n var fluentFunc = {\n forMember: function (prop, valFunc) {\n return _this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: valFunc, sourceMapping: false, fluentFunctions: fluentFunc });\n },\n forSourceMember: function (prop, cfgFunc) {\n return _this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: cfgFunc, sourceMapping: true, fluentFunctions: fluentFunc });\n },\n forAllMembers: function (func) {\n return _this.createMapForAllMembers(mapping, fluentFunc, func);\n },\n ignoreAllNonExisting: function () { return _this.createMapIgnoreAllNonExisting(mapping, fluentFunc); },\n convertToType: function (type) { return _this.createMapConvertToType(mapping, fluentFunc, type); },\n convertUsing: function (tcClassOrFunc) {\n return _this.createMapConvertUsing(mapping, tcClassOrFunc);\n },\n withProfile: function (profile) { return _this.createMapWithProfile(mapping, profile); }\n };\n return fluentFunc;\n };\n AutoMapper.prototype.createMapForMember = function (parameters) {\n var mapping = parameters.mapping, propertyName = parameters.propertyName, transformation = parameters.transformation, sourceMapping = parameters.sourceMapping, fluentFunctions = parameters.fluentFunctions;\n // extract source/destination property names\n var metadata = AutoMapperJs.AutoMapperHelper.getMappingMetadataFromTransformationFunction(propertyName, transformation, sourceMapping);\n this.validateForMemberParameters(metadata);\n var source = metadata.source, destination = metadata.destination;\n // create property (regardless of current existance)\n var property = this.createSourceProperty(metadata, null);\n // merge with existing property or add property\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\n mapping.properties.push(property);\n }\n if (metadata.async) {\n this._asyncMapper.createMapForMember(mapping, this.findProperty(property.name, mapping.properties));\n }\n return fluentFunctions;\n };\n AutoMapper.prototype.validateForMemberParameters = function (metadata) {\n if (!metadata.sourceMapping) {\n return;\n }\n // validate forSourceMember parameters\n if (metadata.transformation.transformationType === AutoMapperJs.DestinationTransformationType.Constant) {\n throw new Error('Configuration of forSourceMember has to be a function with one (sync) or two (async) options parameters.');\n }\n };\n AutoMapper.prototype.createSourceProperty = function (metadata, parent) {\n var level = !parent ? 0 : parent.level + 1;\n var sourceNameParts = metadata.source.split('.');\n var source = {\n name: sourceNameParts[level],\n sourcePropertyName: metadata.source,\n destinationPropertyName: metadata.destination,\n parent: parent,\n level: level,\n children: [],\n destination: null\n };\n if ((level + 1) < sourceNameParts.length) {\n // recursively add child source properties ...\n var child = this.createSourceProperty(metadata, source);\n if (child) {\n source.children.push(child);\n }\n source.destination = null;\n }\n else {\n // ... or (!) add destination\n source.destination = this.createDestinationProperty(metadata, null);\n }\n return source;\n };\n AutoMapper.prototype.createDestinationProperty = function (metadata, parent) {\n var level = !parent ? 0 : parent.level + 1;\n var destinationNameParts = metadata.destination.split('.');\n var destination = {\n name: destinationNameParts[level],\n sourcePropertyName: metadata.source,\n destinationPropertyName: metadata.destination,\n parent: parent,\n level: level,\n child: null,\n transformations: [],\n conditionFunction: null,\n ignore: false,\n sourceMapping: false\n };\n if ((level + 1) < destinationNameParts.length) {\n // recursively add child destination properties\n destination.child = this.createDestinationProperty(metadata, destination);\n }\n else {\n // add/merge properties\n destination.sourceMapping = metadata.sourceMapping;\n destination.conditionFunction = metadata.condition;\n destination.ignore = metadata.ignore;\n destination.transformations.push(metadata.transformation);\n }\n return destination;\n };\n AutoMapper.prototype.mergeSourceProperty = function (property, existingProperties, sourceMapping) {\n // find source property\n var existing = sourceMapping\n ? this.findProperty(property.name, existingProperties)\n : this.matchSourcePropertyByDestination(property, existingProperties);\n if (!existing) {\n return false;\n }\n if (property.destination) {\n if (existing.children.length > 0) {\n var existingDestination = this.getDestinationProperty(existing.destinationPropertyName, existing);\n // existing is (further) nested => rebase and/or merge\n if (this.handleMapFromProperties(property, existing)) {\n // merge and rebase existing destination to current source level\n if (!this.mergeDestinationProperty(property.destination, existingDestination)) {\n return false;\n }\n existing.destination = existingDestination;\n existing.children = [];\n return true;\n }\n // merge property.destination with existing mapFrom() destination (don't care about nesting depth here)\n return this.mergeDestinationProperty(property.destination, existingDestination);\n }\n // both are at same level => simple merge.\n if (!this.mergeDestinationProperty(property.destination, existing.destination)) {\n return false;\n }\n this.handleMapFromProperties(property, existing);\n return true;\n }\n // new source is (further) nested (has children).\n if (existing.children.length > 0) {\n // both have further nesting, delegate merging child(ren) by recursively calling this function.\n for (var _i = 0, _a = property.children; _i < _a.length; _i++) {\n var child = _a[_i];\n if (!this.mergeSourceProperty(child, existing.children, sourceMapping)) {\n return false;\n }\n }\n if (property.destinationPropertyName !== property.sourcePropertyName) {\n // this is a mapFrom() registration. It is handled using the nested source properties, \n // we only are responsible for syncing the name properties.\n existing.name = property.name;\n existing.sourcePropertyName = property.sourcePropertyName;\n }\n return true;\n }\n // existing is not (further) nested. this is always a mapFrom() situation. \n // if (property.sourcePropertyName !== existing.sourcePropertyName) {\n var newDestination = this.getDestinationProperty(existing.destinationPropertyName, property);\n if (property.destinationPropertyName !== property.sourcePropertyName) {\n // this is a mapFrom() registration. In that case:\n // 1) merge destinations, 2) add source child and 3) move destination to (youngest) child\n // NOTE special mergeDestinationProperty call => we use the new destination as 'target',\n // because that will save us trouble overwriting ;)...\n if (!this.mergeDestinationProperty(existing.destination, newDestination, true)) {\n return false;\n }\n existing.children = property.children;\n existing.name = property.name;\n existing.sourcePropertyName = property.sourcePropertyName;\n existing.destination = null;\n // TODO Should never be necessary (test): existing.destinationPropertyName = property.destinationPropertyName;\n return true;\n }\n // ... nope, it is a destination which has previously been registered using mapFrom. just merge\n return this.mergeDestinationProperty(newDestination, existing.destination);\n // }\n };\n /**\n * handle property naming when the current property to merge is a mapFrom property\n */\n AutoMapper.prototype.handleMapFromProperties = function (property, existingProperty) {\n if (property.destinationPropertyName === property.sourcePropertyName ||\n property.sourcePropertyName === existingProperty.sourcePropertyName) {\n return false;\n }\n // only overwrite name when a mapFrom situation applies\n existingProperty.name = property.name;\n existingProperty.sourcePropertyName = property.sourcePropertyName;\n // TODO Should never be necessary (test) => existingProperty.destinationPropertyName = property.destinationPropertyName;\n return true;\n };\n AutoMapper.prototype.getDestinationProperty = function (destinationPropertyName, existingSource) {\n if (existingSource.destination) {\n return existingSource.destination;\n }\n for (var _i = 0, _a = existingSource.children; _i < _a.length; _i++) {\n var child = _a[_i];\n var destination = this.getDestinationProperty(destinationPropertyName, child);\n if (destination) {\n return destination;\n }\n }\n return null;\n };\n AutoMapper.prototype.mergeDestinationProperty = function (destination, existingDestination, swapTransformations) {\n if (swapTransformations === void 0) { swapTransformations = false; }\n if (destination.child) {\n if (existingDestination.child) {\n // both have further nesting, delegate merging children by recursively calling this function.\n if (!this.mergeDestinationProperty(destination.child, existingDestination.child, swapTransformations)) {\n return false;\n }\n this.handleMapFromProperties(destination, existingDestination);\n return true;\n }\n // the current destination is not (further) nested. a destination property registration has one of both: \n // a) children or b) transformations. returning false will cause creating a duplicate source property entry instead.\n return false;\n }\n if (existingDestination.sourceMapping !== destination.sourceMapping &&\n existingDestination.sourcePropertyName !== destination.sourcePropertyName) {\n // unable to perform mapFrom() on a property which is being registered using forSourceMember.\n return false; // TODO: Unpredictable? Idea: throw new Error('Unable to perform mapFrom() on a property which is being registered using forSourceMember.');\n }\n // merge destination properties\n if (destination.sourceMapping) {\n // only set source mapping when not yet set to true, once source mapped is source mapped forever.\n // TODO Verify edge cases!\n existingDestination.sourceMapping = destination.sourceMapping;\n }\n if (destination.ignore) {\n // only set ignore when not yet set, once ignored is ignored forever. \n existingDestination.ignore = destination.ignore;\n }\n if (destination.conditionFunction) {\n // overwrite condition function by the latest one specified.\n existingDestination.conditionFunction = destination.conditionFunction;\n }\n var transformations = [];\n if (swapTransformations) {\n for (var _i = 0, _a = destination.transformations; _i < _a.length; _i++) {\n var transformation = _a[_i];\n transformations.push(transformation);\n }\n for (var _b = 0, _c = existingDestination.transformations; _b < _c.length; _b++) {\n var transformation = _c[_b];\n transformations.push(transformation);\n }\n }\n else {\n for (var _d = 0, _e = existingDestination.transformations; _d < _e.length; _d++) {\n var transformation = _e[_d];\n transformations.push(transformation);\n }\n for (var _f = 0, _g = destination.transformations; _f < _g.length; _f++) {\n var transformation = _g[_f];\n transformations.push(transformation);\n }\n }\n existingDestination.transformations = transformations;\n this.handleMapFromProperties(destination, existingDestination);\n return true;\n };\n AutoMapper.prototype.matchSourcePropertyByDestination = function (source, properties) {\n if (!properties) {\n return null;\n }\n for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {\n var property = properties_1[_i];\n if (property.destinationPropertyName === source.destinationPropertyName) {\n return property;\n }\n }\n return null;\n };\n AutoMapper.prototype.findProperty = function (name, properties) {\n if (!properties) {\n return null;\n }\n for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) {\n var property = properties_2[_i];\n if (property.name === name) {\n return property;\n }\n }\n return null;\n };\n return AutoMapper;\n }(AutoMapperJs.AutoMapperBase));\n AutoMapper._instance = new AutoMapper();\n AutoMapperJs.AutoMapper = AutoMapper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n// Add AutoMapper to the application's global scope. Of course, you could still use Core.AutoMapper.getInstance() as well.\nvar automapper = (function (app) {\n app.automapper = AutoMapperJs.AutoMapper.getInstance();\n return app.automapper;\n})(this);\n\n//# sourceMappingURL=AutoMapper.js.map\n","/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * Converts source type to destination type instead of normal member mapping\n */\n var Profile = (function () {\n function Profile() {\n }\n /**\n * Implement this method in a derived class and call the CreateMap method to associate that map with this profile.\n * Avoid calling the AutoMapper class / automapper instance from this method.\n */\n Profile.prototype.configure = function () {\n // do nothing\n };\n /**\n * Create a mapping profile.\n * @param {string} sourceKey The map source key.\n * @param {string} destinationKey The map destination key.\n * @returns {Core.ICreateMapFluentFunctions}\n */\n Profile.prototype.createMap = function (sourceKey, destinationKey) {\n var argsCopy = Array.prototype.slice.apply(arguments);\n for (var index = 0, length = argsCopy.length; index < length; index++) {\n if (argsCopy[index]) {\n // prefix sourceKey and destinationKey with 'profileName=>'\n argsCopy[index] = this.profileName + \"=>\" + argsCopy[index];\n }\n }\n // pass through using arguments to keep createMap's currying support fully functional.\n return automapper.createMap.apply(automapper, argsCopy);\n };\n return Profile;\n }());\n AutoMapperJs.Profile = Profile;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=Profile.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * Converts source type to destination type instead of normal member mapping\n */\n var TypeConverter = (function () {\n function TypeConverter() {\n }\n /**\n * Performs conversion from source to destination type.\n * @param {IResolutionContext} resolutionContext Resolution context.\n * @returns {any} Destination object.\n */\n TypeConverter.prototype.convert = function (resolutionContext) {\n // NOTE BL Unfortunately, TypeScript/JavaScript do not support abstract base classes.\n // This is just one way around, please convince me about a better solution.\n throw new Error('The TypeConverter.convert method is abstract. Use a TypeConverter extension class instead.');\n };\n return TypeConverter;\n }());\n AutoMapperJs.TypeConverter = TypeConverter;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=TypeConverter.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var CamelCaseNamingConvention = (function () {\n function CamelCaseNamingConvention() {\n this.splittingExpression = /(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\n this.separatorCharacter = '';\n }\n CamelCaseNamingConvention.prototype.transformPropertyName = function (sourcePropertyNameParts) {\n // Transform the splitted parts.\n var result = '';\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\n if (index === 0) {\n result += sourcePropertyNameParts[index].charAt(0).toLowerCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n else {\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n }\n return result;\n };\n return CamelCaseNamingConvention;\n }());\n AutoMapperJs.CamelCaseNamingConvention = CamelCaseNamingConvention;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=CamelCaseNamingConvention.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var PascalCaseNamingConvention = (function () {\n function PascalCaseNamingConvention() {\n this.splittingExpression = /(^[A-Z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\n this.separatorCharacter = '';\n }\n PascalCaseNamingConvention.prototype.transformPropertyName = function (sourcePropertyNameParts) {\n // Transform the splitted parts.\n var result = '';\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n return result;\n };\n return PascalCaseNamingConvention;\n }());\n AutoMapperJs.PascalCaseNamingConvention = PascalCaseNamingConvention;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=PascalCaseNamingConvention.js.map\n"]} \ No newline at end of file +{"version":3,"sources":["AutoMapperHelper.js","AutoMapperValidator.js","AutoMapperEnumerations.js","AutoMapperBase.js","AsyncAutoMapper.js","AutoMapper.js","Profile.js","TypeConverter.js","naming-conventions/CamelCaseNamingConvention.js","naming-conventions/PascalCaseNamingConvention.js"],"names":["AutoMapperJs","AutoMapperHelper","getClassName","classType","name","constructor","className","toString","matchParts","match","length","str","regExpMatchArray","charAt","Error","getFunctionParameters","functionStr","stripComments","argumentNames","functionString","replace","functionParameterNames","slice","indexOf","Array","handleCurrying","func","args","closure","accumulator","moreArgs","alreadyProvidedArgs","stillToCome","previousAlreadyProvidedArgs","previousStillToCome","i","functionCallResult","apply","arguments","argumentsStillToCome","prototype","getMappingMetadataFromTransformationFunction","destination","sourceMapping","source","transformation","getDestinationTransformation","condition","ignore","async","parameterNames","optsParamName","getMapFromString","metadata","getIgnoreFromString","getFunctionCallIndex","getConditionFromFunction","isFunction","transformationType","DestinationTransformationType","Constant","constant","AsyncSourceMemberOptions","asyncSourceMemberConfigurationOptionsFunc","SourceMemberOptions","sourceMemberConfigurationOptionsFunc","AsyncMemberOptions","asyncMemberConfigurationOptionsFunc","MemberOptions","memberConfigurationOptionsFunc","optionsParameterName","indexOfIgnore","indexOfMapFromStart","indexOfMapFromEnd","ignoreString","substring","trim","defaultValue","indexOfMapFrom","mapFromString","functionToLookFor","indexOfFunctionCall","sourceProperty","sourceObject","configFuncOptions","predicate","mapFrom","sourcePropertyName","intermediatePropertyValue","exc","AutoMapperValidator","assertConfigurationIsValid","mappings","strictMode","key","hasOwnProperty","assertMappingConfiguration","mapping","mappingKey","sourceKey","destinationKey","sourceType","sourceTypeClass","destinationType","destinationTypeClass","sourceClassName","undefined","destinationClassName","tryHandle","errorMessage","validatedMembers","srcObj","dstObj","_i","_a","properties","property","validatePropertyMapping","push","srcMember","validateProperty","dstMember","propertyMapping","member","destinationProperty","getDestinationProperty","destinationPropertyName","validateSourcePropertyMapping","validateDestinationPropertyMapping","ropertyMapping","existingSource","children","child","this","AutoMapperBase","getMapping","srcKey","getKey","dstKey","keyStringOrType","isArray","handleArray","sourceArray","itemFunc","arrayLength","destinationArray","index","destinationObject","createDestinationObject","handleItem","propertyFunction","atLeastOnePropertyMapped","handleProperty","transformFunction","autoMappingCallbackFunction","propertyMappings","getPropertyMappings","propertyMappings_1","processMappedProperty","handlePropertyWithAutoMapping","setPropertyValue","destinationPropertyValue","forAllMemberMappings","forAllMemberMapping","setPropertyValueByName","shouldProcessDestination","conditionFunction","ignoreAllNonExisting","Object","keys","objectValue","isNestedObject","createMap","convertToType","map","getDestinationPropertyName","profile","getDestinationPropertyValue","sourcePropertyNameParts","split","sourceMemberNamingConvention","splittingExpression","splice","destinationMemberNamingConvention","transformPropertyName","error","result","properties_1","childSourceObject","createMemberConfigurationOptions","__extends","extendStatics","setPrototypeOf","__proto__","d","b","p","__","create","AsyncAutoMapper","_super","_this","call","asyncInstance","sourceKeyOrType","destinationKeyOrType","createMapForMember","mapItemFunction","m","cb","mapItem","createMapConvertUsing","converterFunction","typeConverterFunction","mapItemUsingTypeConverter","callback","mapWithMapping","mapArray","callbacksToGo","waitForCallbackToSend","setTimeout","resolutionContext","sourceValue","destinationValue","mapProperty","options","transform","success","childDestinationProperty","childDestinationObject","callbackValue","processTransformations","transformations","processTransformation","AutoMapper","_instance","_profiles","_mappings","_asyncMapper","getInstance","initialize","configFunction","that","addProfile","configure","profileName","createMappingObjectForGivenKeys","createMapGetFluentApiFunctions","mapInternal","mapAsync","createMapForAllMembers","fluentFunc","createMapIgnoreAllNonExisting","createMapConvertToType","typeClass","tcClassOrFunc","configureSynchronousConverterFunction","converterFunc","TypeConverter","convert","typeConverter","e","createMapWithProfile","createMapWithProfileMergeMappings","profileMappingKey","profileMapping","_b","mergeSourceProperty","propertyName","arrayIndex","transformed","srcKeyOrType","dstKeyOrType","forMember","prop","valFunc","fluentFunctions","forSourceMember","cfgFunc","forAllMembers","type","convertUsing","withProfile","parameters","validateForMemberParameters","createSourceProperty","findProperty","parent","level","sourceNameParts","createDestinationProperty","destinationNameParts","existingProperties","existing","matchSourcePropertyByDestination","existingDestination","handleMapFromProperties","mergeDestinationProperty","newDestination","existingProperty","swapTransformations","_c","_d","_e","_f","_g","properties_2","automapper","app","Profile","argsCopy","CamelCaseNamingConvention","separatorCharacter","toLowerCase","substr","toUpperCase","PascalCaseNamingConvention"],"mappings":";;;;;;;;;AACA,IAAAA,cACA,SAAAA,GACA,aAIA,IAAAC,EAAA,WACA,SAAAA,KAwNA,OAtNAA,EAAAC,aAAA,SAAAC,GACA,GAAAA,GAAAA,EAAAC,KACA,OAAAD,EAAAC,K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AAAiK,WAAAvI,UAAAvI,MAAA8Q,WAAAG,IAEAD,KAEArT,EAAAqT,QAAAA,GACArT,eAAAA,kBCrCA,IAAAA,cACA,SAAAA,GACA,aAIA,IAAAkQ,EAAA,WACA,SAAAA,KAYA,OALAA,EAAA1N,UAAA2N,QAAA,SAAAtC,GAGA,MAAA,IAAA/M,MAAA,+FAEAoP,KAEAlQ,EAAAkQ,cAAAA,GACAlQ,eAAAA,kBCtBA,IAAAA,cACA,SAAAA,GACA,aACA,IAAAuT,EAAA,WACA,SAAAA,IACAlL,KAAAgD,oBAAA,mDACAhD,KAAAmL,mBAAA,GAiBA,OAfAD,EAAA/Q,UAAAgJ,sBAAA,SAAAN,GAGA,IAAA,IADAQ,EAAA,GACAxC,EAAA,EAAAxI,EAAAwK,EAAAxK,OAAAwI,EAAAxI,EAAAwI,IAEAwC,GADA,IAAAxC,EACAgC,EAAAhC,GAAArI,OAAA,GAAA4S,cACAvI,EAAAhC,GAAAwK,OAAA,GAGAxI,EAAAhC,GAAArI,OAAA,GAAA8S,cACAzI,EAAAhC,GAAAwK,OAAA,GAGA,OAAAhI,GAEA6H,KAEAvT,EAAAuT,0BAAAA,GACAvT,eAAAA,kBC1BA,IAAAA,cACA,SAAAA,GACA,aACA,IAAA4T,EAAA,WACA,SAAAA,IACAvL,KAAAgD,oBAAA,mDACAhD,KAAAmL,mBAAA,GAcA,OAZAI,EAAApR,UAAAgJ,sBAAA,SAAAN,GAGA,IAAA,IADAQ,EAAA,GACAxC,EAAA,EAAAxI,EAAAwK,EAAAxK,OAAAwI,EAAAxI,EAAAwI,IACAwC,GAAAR,EAAAhC,GAAArI,OAAA,GAAA8S,cACAzI,EAAAhC,GAAAwK,OAAA,GAKA,OAAAhI,GAEAkI,KAEA5T,EAAA4T,2BAAAA,GACA5T,eAAAA","file":"automapper.min.js","sourcesContent":["/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper helper functions\n */\n var AutoMapperHelper = (function () {\n function AutoMapperHelper() {\n }\n AutoMapperHelper.getClassName = function (classType) {\n if (classType && classType.name) {\n return classType.name;\n }\n // source: http://stackoverflow.com/a/13914278/702357\n if (classType && classType.constructor) {\n var className = classType.toString();\n if (className) {\n // classType.toString() is \"function classType (...) { ... }\"\n var matchParts = className.match(/function\\s*(\\w+)/);\n if (matchParts && matchParts.length === 2) {\n return matchParts[1];\n }\n }\n // for browsers which have name property in the constructor\n // of the object, such as chrome\n if (classType.constructor.name) {\n return classType.constructor.name;\n }\n if (classType.constructor.toString()) {\n var str = classType.constructor.toString();\n var regExpMatchArray = void 0;\n if (str.charAt(0) === '[') {\n // executed if the return of object.constructor.toString() is \"[object objectClass]\"\n regExpMatchArray = str.match(/\\[\\w+\\s*(\\w+)\\]/);\n }\n else {\n // executed if the return of object.constructor.toString() is \"function objectClass () {}\"\n // (IE and Firefox)\n regExpMatchArray = str.match(/function\\s*(\\w+)/);\n }\n if (regExpMatchArray && regExpMatchArray.length === 2) {\n return regExpMatchArray[1];\n }\n }\n }\n throw new Error(\"Unable to extract class name from type '\" + classType + \"'\");\n };\n AutoMapperHelper.getFunctionParameters = function (functionStr) {\n var stripComments = /((\\/\\/.*$)|(\\/\\*[\\s\\S]*?\\*\\/))/mg;\n var argumentNames = /([^\\s,]+)/g;\n var functionString = functionStr.replace(stripComments, '');\n var functionParameterNames = functionString.slice(functionString.indexOf('(') + 1, functionString.indexOf(')')).match(argumentNames);\n if (functionParameterNames === null) {\n functionParameterNames = new Array();\n }\n return functionParameterNames;\n };\n AutoMapperHelper.handleCurrying = function (func, args, closure) {\n var argumentsStillToCome = func.length - args.length;\n // saved accumulator array\n // NOTE BL this does not deep copy array objects, only the array itself; should side effects occur, please report (or refactor).\n var argumentsCopy = Array.prototype.slice.apply(args);\n function accumulator(moreArgs, alreadyProvidedArgs, stillToCome) {\n var previousAlreadyProvidedArgs = alreadyProvidedArgs.slice(0); // to reset\n var previousStillToCome = stillToCome; // to reset\n for (var i = 0; i < moreArgs.length; i++, stillToCome--) {\n alreadyProvidedArgs[alreadyProvidedArgs.length] = moreArgs[i];\n }\n if (stillToCome - moreArgs.length <= 0) {\n var functionCallResult = func.apply(closure, alreadyProvidedArgs);\n // reset vars, so curried function can be applied to new params.\n alreadyProvidedArgs = previousAlreadyProvidedArgs;\n stillToCome = previousStillToCome;\n return functionCallResult;\n }\n else {\n return function () {\n // arguments are params, so closure bussiness is avoided.\n return accumulator(arguments, alreadyProvidedArgs.slice(0), stillToCome);\n };\n }\n }\n return accumulator([], argumentsCopy, argumentsStillToCome);\n };\n AutoMapperHelper.getMappingMetadataFromTransformationFunction = function (destination, func, sourceMapping) {\n if (typeof func !== 'function') {\n return {\n destination: destination,\n source: destination,\n transformation: AutoMapperHelper.getDestinationTransformation(func, false, sourceMapping, false),\n sourceMapping: sourceMapping,\n condition: null,\n ignore: false,\n async: false\n };\n }\n var functionStr = func.toString();\n var parameterNames = AutoMapperHelper.getFunctionParameters(functionStr);\n var optsParamName = parameterNames.length >= 1 ? parameterNames[0] : '';\n var source = sourceMapping\n ? destination\n : AutoMapperHelper.getMapFromString(functionStr, destination, optsParamName);\n var metadata = {\n destination: destination,\n source: source,\n transformation: AutoMapperHelper.getDestinationTransformation(func, true, sourceMapping, parameterNames.length === 2),\n sourceMapping: sourceMapping,\n condition: null,\n ignore: AutoMapperHelper.getIgnoreFromString(functionStr, destination),\n async: parameterNames.length === 2\n };\n // calling the member options function when used asynchronous would be too 'dangerous'.\n if (!metadata.async && AutoMapperHelper.getFunctionCallIndex(functionStr, 'condition', optsParamName) >= 0) {\n metadata.condition = AutoMapperHelper.getConditionFromFunction(func, source);\n }\n return metadata;\n };\n AutoMapperHelper.getDestinationTransformation = function (func, isFunction, sourceMapping, async) {\n if (!isFunction) {\n return {\n transformationType: AutoMapperJs.DestinationTransformationType.Constant,\n constant: func\n };\n }\n var transformation;\n if (sourceMapping) {\n if (async) {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.AsyncSourceMemberOptions,\n asyncSourceMemberConfigurationOptionsFunc: func\n };\n }\n else {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.SourceMemberOptions,\n sourceMemberConfigurationOptionsFunc: func\n };\n }\n }\n else {\n if (async) {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.AsyncMemberOptions,\n asyncMemberConfigurationOptionsFunc: func\n };\n }\n else {\n transformation = {\n transformationType: AutoMapperJs.DestinationTransformationType.MemberOptions,\n memberConfigurationOptionsFunc: func\n };\n }\n }\n return transformation;\n };\n AutoMapperHelper.getIgnoreFromString = function (functionString, optionsParameterName) {\n var indexOfIgnore = AutoMapperHelper.getFunctionCallIndex(functionString, 'ignore', optionsParameterName);\n if (indexOfIgnore < 0) {\n return false;\n }\n var indexOfMapFromStart = functionString.indexOf('(', indexOfIgnore) + 1;\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\n return false;\n }\n var ignoreString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/\\r/g, '').replace(/\\n/g, '').trim();\n return ignoreString === null || ignoreString === ''\n ? true // .ignore()\n : false; // .ignore( -> unexpected content)\n };\n AutoMapperHelper.getMapFromString = function (functionString, defaultValue, optionsParameterName) {\n var indexOfMapFrom = AutoMapperHelper.getFunctionCallIndex(functionString, 'mapFrom', optionsParameterName);\n if (indexOfMapFrom < 0) {\n return defaultValue;\n }\n var indexOfMapFromStart = functionString.indexOf('(', indexOfMapFrom) + 1;\n var indexOfMapFromEnd = functionString.indexOf(')', indexOfMapFromStart);\n if (indexOfMapFromStart < 0 || indexOfMapFromEnd < 0) {\n return defaultValue;\n }\n var mapFromString = functionString.substring(indexOfMapFromStart, indexOfMapFromEnd).replace(/'/g, '').replace(/\"/g, '').trim();\n return mapFromString === null || mapFromString === ''\n ? defaultValue\n : mapFromString;\n };\n AutoMapperHelper.getFunctionCallIndex = function (functionString, functionToLookFor, optionsParameterName) {\n var indexOfFunctionCall = functionString.indexOf(optionsParameterName + '.' + functionToLookFor);\n if (indexOfFunctionCall < 0) {\n indexOfFunctionCall = functionString.indexOf('.' + functionToLookFor);\n }\n return indexOfFunctionCall;\n };\n AutoMapperHelper.getConditionFromFunction = function (func, sourceProperty) {\n // Since we are calling the valueOrFunction function to determine whether to ignore or map from another property, we\n // want to prevent the call to be error prone when the end user uses the '(opts)=> opts.sourceObject.sourcePropertyName'\n // syntax. We don't actually have a source object when creating a mapping; therefore, we 'stub' a source object for the\n // function call.\n var sourceObject = {};\n sourceObject[sourceProperty] = {};\n var condition;\n // calling the function will result in calling our stubbed ignore() and mapFrom() functions if used inside the function.\n var configFuncOptions = {\n ignore: function () {\n // do nothing\n },\n condition: function (predicate) {\n condition = predicate;\n },\n mapFrom: function (sourcePropertyName) {\n // do nothing\n },\n sourceObject: sourceObject,\n sourcePropertyName: sourceProperty,\n intermediatePropertyValue: {}\n };\n try {\n func(configFuncOptions);\n }\n catch (exc) {\n // do not handle by default.\n }\n return condition;\n };\n return AutoMapperHelper;\n }());\n AutoMapperJs.AutoMapperHelper = AutoMapperHelper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperHelper.js.map\n","/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper configuration validator.\n */\n var AutoMapperValidator = (function () {\n function AutoMapperValidator() {\n }\n /**\n * Validates mapping configuration by dry-running. Since JS does not\n * fully support typing, it only checks if properties match on both\n * sides. The function needs IMapping.sourceTypeClass and\n * IMapping.destinationTypeClass to function.\n * @param {boolean} strictMode Whether or not to fail when properties\n * sourceTypeClass or destinationTypeClass\n * are unavailable.\n */\n AutoMapperValidator.assertConfigurationIsValid = function (mappings, strictMode) {\n for (var key in mappings) {\n if (!mappings.hasOwnProperty(key)) {\n continue;\n }\n AutoMapperValidator.assertMappingConfiguration(mappings[key], strictMode);\n }\n };\n AutoMapperValidator.assertMappingConfiguration = function (mapping, strictMode) {\n var mappingKey = mapping.sourceKey + \"=>\" + mapping.destinationKey;\n var sourceType = mapping.sourceTypeClass;\n var destinationType = mapping.destinationTypeClass;\n var sourceClassName = sourceType ? AutoMapperJs.AutoMapperHelper.getClassName(sourceType) : undefined;\n var destinationClassName = destinationType ? AutoMapperJs.AutoMapperHelper.getClassName(destinationType) : undefined;\n if (!sourceType || !destinationType) {\n if (strictMode === false) {\n return;\n }\n throw new Error(\"Mapping '\" + mappingKey + \"' cannot be validated, since mapping.sourceType or mapping.destinationType are unspecified.\");\n }\n var tryHandle = function (errorMessage) {\n if (errorMessage) {\n throw new Error(\"Mapping '\" + mappingKey + \"' is invalid: \" + errorMessage + \" (source: '\" + sourceClassName + \"', destination: '\" + destinationClassName + \"').\");\n }\n };\n var validatedMembers = new Array();\n var srcObj = new sourceType();\n var dstObj = new destinationType();\n // walk member mappings\n for (var _i = 0, _a = mapping.properties; _i < _a.length; _i++) {\n var property = _a[_i];\n tryHandle(AutoMapperValidator.validatePropertyMapping(property, property.name, srcObj, dstObj));\n validatedMembers.push(property.name);\n }\n // walk source members\n for (var srcMember in srcObj) {\n if (!srcObj.hasOwnProperty(srcMember)) {\n continue;\n }\n if (validatedMembers.indexOf(srcMember) >= 0) {\n // already validated\n continue;\n }\n tryHandle(AutoMapperValidator.validateProperty(srcMember, dstObj));\n validatedMembers.push(srcMember);\n }\n // walk destination members\n for (var dstMember in dstObj) {\n if (!dstObj.hasOwnProperty(dstMember)) {\n continue;\n }\n if (validatedMembers.indexOf(dstMember) >= 0) {\n // already validated\n continue;\n }\n tryHandle(\"Destination member '\" + dstMember + \"' does not exist on source type\");\n }\n // /* tslint:disable */\n // console.error(key);\n // /* tslint:enable */\n };\n AutoMapperValidator.validatePropertyMapping = function (propertyMapping, member, srcObj, dstObj) {\n // awkward way of locating sourceMapping ;) ...\n var destinationProperty = AutoMapperValidator.getDestinationProperty(propertyMapping.destinationPropertyName, propertyMapping);\n return destinationProperty.sourceMapping\n ? AutoMapperValidator.validateSourcePropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj)\n : AutoMapperValidator.validateDestinationPropertyMapping(propertyMapping, destinationProperty, member, srcObj, dstObj);\n };\n AutoMapperValidator.validateSourcePropertyMapping = function (ropertyMapping, destinationProperty, member, srcObj, dstObj) {\n // a member for which configuration is provided, should exist.\n if (!srcObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is configured, but does not exist on source type\";\n }\n // an ignored source member should not exist on the destination type.\n if (destinationProperty.ignore) {\n if (dstObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is ignored, but does exist on destination type\";\n }\n return undefined;\n }\n // a mapped source member should exist on the destination type.\n if (!dstObj.hasOwnProperty(member)) {\n return \"Source member '\" + member + \"' is configured to be mapped, but does not exist on destination type\";\n }\n //var dstMember = propertyMapping.destinationProperty;\n return undefined;\n };\n AutoMapperValidator.validateDestinationPropertyMapping = function (propertyMapping, destinationProperty, member, srcObj, dstObj) {\n // a member for which configuration is provided, should exist.\n if (!dstObj.hasOwnProperty(destinationProperty.name)) {\n return \"Destination member '\" + destinationProperty.destinationPropertyName + \"' is configured, but does not exist on destination type\";\n }\n // an ignored destination member should not exist on the source type.\n if (destinationProperty.ignore) {\n if (srcObj.hasOwnProperty(member)) {\n return \"Destination member '\" + member + \"' is ignored, but does exist on source type\";\n }\n return undefined;\n }\n // a mapped destination member should exist on the source type.\n if (!srcObj.hasOwnProperty(member)) {\n return \"Destination member '\" + member + \"' is configured to be mapped, but does not exist on source type\";\n }\n //var dstMember = propertyMapping.destinationProperty;\n return undefined;\n };\n AutoMapperValidator.validateProperty = function (srcMember, dstObj) {\n if (!dstObj.hasOwnProperty(srcMember)) {\n return \"Source member '\" + srcMember + \"' is configured to be mapped, but does not exist on destination type\";\n }\n return undefined;\n };\n AutoMapperValidator.getDestinationProperty = function (destinationPropertyName, existingSource) {\n if (existingSource.destination) {\n return existingSource.destination;\n }\n if (existingSource.children) {\n for (var _i = 0, _a = existingSource.children; _i < _a.length; _i++) {\n var child = _a[_i];\n var destination = this.getDestinationProperty(destinationPropertyName, child);\n if (destination) {\n return destination;\n }\n }\n }\n return null;\n };\n return AutoMapperValidator;\n }());\n AutoMapperJs.AutoMapperValidator = AutoMapperValidator;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperValidator.js.map\n","var AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var DestinationTransformationType;\n (function (DestinationTransformationType) {\n DestinationTransformationType[DestinationTransformationType[\"Constant\"] = 1] = \"Constant\";\n DestinationTransformationType[DestinationTransformationType[\"MemberOptions\"] = 2] = \"MemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"AsyncMemberOptions\"] = 4] = \"AsyncMemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"SourceMemberOptions\"] = 8] = \"SourceMemberOptions\";\n DestinationTransformationType[DestinationTransformationType[\"AsyncSourceMemberOptions\"] = 16] = \"AsyncSourceMemberOptions\";\n })(DestinationTransformationType = AutoMapperJs.DestinationTransformationType || (AutoMapperJs.DestinationTransformationType = {}));\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperEnumerations.js.map\n","/// \n/// \n/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AutoMapper implementation, for both creating maps and performing maps. Comparable usage and functionality to the original\n * .NET AutoMapper library is the pursuit of this implementation.\n */\n var AutoMapperBase = (function () {\n function AutoMapperBase() {\n }\n AutoMapperBase.prototype.getMapping = function (mappings, sourceKey, destinationKey) {\n var srcKey = this.getKey(sourceKey);\n var dstKey = this.getKey(destinationKey);\n var mapping = mappings[srcKey + dstKey];\n if (!mapping) {\n throw new Error(\"Could not find map object with a source of \" + srcKey + \" and a destination of \" + dstKey);\n }\n return mapping;\n };\n AutoMapperBase.prototype.getKey = function (keyStringOrType) {\n if (typeof keyStringOrType === 'string') {\n return keyStringOrType;\n }\n else {\n return AutoMapperJs.AutoMapperHelper.getClassName(keyStringOrType);\n }\n };\n AutoMapperBase.prototype.isArray = function (sourceObject) {\n return sourceObject instanceof Array;\n };\n AutoMapperBase.prototype.handleArray = function (mapping, sourceArray, itemFunc) {\n var arrayLength = sourceArray.length;\n var destinationArray = new Array(sourceArray.length);\n for (var index = 0; index < arrayLength; index++) {\n var sourceObject = sourceArray[index];\n var destinationObject = void 0;\n if (sourceObject === null || sourceObject === undefined) {\n destinationObject = sourceObject;\n }\n else {\n destinationObject = this.createDestinationObject(mapping.destinationTypeClass);\n itemFunc(sourceObject, destinationObject);\n }\n destinationArray[index] = destinationObject;\n }\n return destinationArray;\n };\n AutoMapperBase.prototype.handleItem = function (mapping, sourceObject, destinationObject, propertyFunction) {\n // var sourceProperties: string[] = [];\n var atLeastOnePropertyMapped = false;\n // handle mapped properties ...\n for (var _i = 0, _a = mapping.properties; _i < _a.length; _i++) {\n var property = _a[_i];\n // sourceProperties.push(property.name);\n atLeastOnePropertyMapped = true;\n propertyFunction(property.name);\n }\n // .. and, after that, handle unmapped properties\n for (var sourcePropertyName in sourceObject) {\n if (!sourceObject.hasOwnProperty(sourcePropertyName)) {\n continue;\n }\n if (destinationObject[sourcePropertyName]) {\n // ... but, if the destination property already exists, don't map again (probably a mapFrom situation).\n continue;\n }\n // if (sourceProperties.indexOf(sourcePropertyName) >= 0) {\n // continue;\n // }\n atLeastOnePropertyMapped = true;\n propertyFunction(sourcePropertyName);\n }\n // return null/undefined sourceObject if no properties added\n if (!atLeastOnePropertyMapped && (sourceObject === null || sourceObject === undefined)) {\n return sourceObject;\n }\n return destinationObject;\n };\n AutoMapperBase.prototype.handleProperty = function (mapping, sourceObject, sourcePropertyName, destinationObject, transformFunction, autoMappingCallbackFunction) {\n // TODO Property mappings are already located before\n // TODO handleProperty seems only to be called when processing a mapped property.\n var propertyMappings = this.getPropertyMappings(mapping.properties, sourcePropertyName);\n if (propertyMappings.length > 0) {\n for (var _i = 0, propertyMappings_1 = propertyMappings; _i < propertyMappings_1.length; _i++) {\n var propertyMapping = propertyMappings_1[_i];\n this.processMappedProperty(mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction);\n }\n }\n else {\n this.handlePropertyWithAutoMapping(mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction);\n }\n };\n AutoMapperBase.prototype.setPropertyValue = function (mapping, destinationProperty, destinationObject, destinationPropertyValue) {\n if (mapping.forAllMemberMappings.length > 0) {\n for (var _i = 0, _a = mapping.forAllMemberMappings; _i < _a.length; _i++) {\n var forAllMemberMapping = _a[_i];\n forAllMemberMapping(destinationObject, destinationProperty.name, destinationPropertyValue);\n }\n }\n else {\n destinationObject[destinationProperty.name] = destinationPropertyValue;\n }\n };\n AutoMapperBase.prototype.setPropertyValueByName = function (mapping, destinationObject, destinationProperty, destinationPropertyValue) {\n if (mapping.forAllMemberMappings.length > 0) {\n for (var _i = 0, _a = mapping.forAllMemberMappings; _i < _a.length; _i++) {\n var forAllMemberMapping = _a[_i];\n forAllMemberMapping(destinationObject, destinationProperty, destinationPropertyValue);\n }\n }\n else {\n destinationObject[destinationProperty] = destinationPropertyValue;\n }\n };\n AutoMapperBase.prototype.createDestinationObject = function (destinationType) {\n // create empty destination object.\n return destinationType\n ? new destinationType()\n : {};\n };\n AutoMapperBase.prototype.shouldProcessDestination = function (destination, sourceObject) {\n if (destination.ignore) {\n // ignore ignored properties\n return false;\n }\n if (destination.conditionFunction) {\n // check for condition function, and, if there is ...\n if (destination.conditionFunction(sourceObject) === false) {\n // ... return when the condition is not met.\n return false;\n }\n }\n return true;\n };\n // protected throwMappingException(propertyMapping: IProperty, message: string): void {\n // throw new Error(`Cannot map '${propertyMapping.sourcePropertyName}' to '${propertyMapping.destinationPropertyName}' => ${message}`);\n // }\n AutoMapperBase.prototype.handlePropertyWithAutoMapping = function (mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction) {\n // no forMember mapping exists, auto map properties, except for the situation where ignoreAllNonExisting is specified.\n if (mapping.ignoreAllNonExisting) {\n return;\n }\n if (mapping.destinationTypeClass && Object.keys(destinationObject).indexOf(sourcePropertyName) < 0) {\n return;\n }\n var objectValue = null;\n var isNestedObject = false;\n if (typeof destinationObject[sourcePropertyName] === 'object' && destinationObject[sourcePropertyName]) {\n isNestedObject = (destinationObject[sourcePropertyName].constructor.name !== 'Object');\n if (isNestedObject) {\n this\n .createMap(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name)\n .convertToType(destinationObject[sourcePropertyName].constructor);\n objectValue = this.map(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name, sourceObject[sourcePropertyName]);\n }\n }\n // use profile mapping when specified; otherwise, specify source property name as destination property name.\n var destinationPropertyName = this.getDestinationPropertyName(mapping.profile, sourcePropertyName);\n var destinationPropertyValue = this.getDestinationPropertyValue(sourceObject, sourcePropertyName, objectValue, isNestedObject);\n this.setPropertyValueByName(mapping, destinationObject, destinationPropertyName, destinationPropertyValue);\n if (autoMappingCallbackFunction) {\n autoMappingCallbackFunction(destinationPropertyValue);\n }\n };\n AutoMapperBase.prototype.getDestinationPropertyValue = function (sourceObject, sourcePropertyName, objectValue, isNestedObject) {\n if (isNestedObject) {\n return objectValue;\n }\n return sourceObject ? sourceObject[sourcePropertyName] : null;\n };\n AutoMapperBase.prototype.getDestinationPropertyName = function (profile, sourcePropertyName) {\n if (!profile) {\n return sourcePropertyName;\n }\n // TODO BL no support yet for INamingConvention.splittingCharacter\n try {\n // First, split the source property name based on the splitting expression.\n // TODO BL Caching of RegExp splitting!\n var sourcePropertyNameParts = sourcePropertyName.split(profile.sourceMemberNamingConvention.splittingExpression);\n // NOTE BL For some reason, splitting by (my ;)) RegExp results in empty strings in the array; remove them.\n for (var index = sourcePropertyNameParts.length - 1; index >= 0; index--) {\n if (sourcePropertyNameParts[index] === '') {\n sourcePropertyNameParts.splice(index, 1);\n }\n }\n return profile.destinationMemberNamingConvention.transformPropertyName(sourcePropertyNameParts);\n }\n catch (error) {\n return sourcePropertyName;\n }\n };\n AutoMapperBase.prototype.getPropertyMappings = function (properties, sourcePropertyName) {\n var result = [];\n for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {\n var property = properties_1[_i];\n if (property.name === sourcePropertyName) {\n result.push(property);\n }\n }\n return result;\n };\n AutoMapperBase.prototype.processMappedProperty = function (mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction) {\n if (propertyMapping.children && propertyMapping.children.length > 0) {\n // always pass child source object, even if source object does not exist =>\n // constant transformations should always pass.\n var childSourceObject = sourceObject ? sourceObject[propertyMapping.name] : null;\n for (var _i = 0, _a = propertyMapping.children; _i < _a.length; _i++) {\n var child = _a[_i];\n this.processMappedProperty(mapping, child, childSourceObject, child.name, transformFunction);\n return;\n }\n }\n var destination = propertyMapping.destination;\n // if (!propertyMapping.destination) {\n // // it makes no sense to handle a property without destination(s).\n // this.throwMappingException(propertyMapping, 'no destination object');\n // }\n var configurationOptions = this.createMemberConfigurationOptions(sourceObject, sourcePropertyName);\n transformFunction(destination, configurationOptions);\n };\n AutoMapperBase.prototype.createMemberConfigurationOptions = function (sourceObject, sourcePropertyName) {\n var memberConfigurationOptions = {\n mapFrom: function (sourcePropertyName) {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.mapFrom(...)' function.\n },\n condition: function (predicate) {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.condition(...)' function.\n },\n ignore: function () {\n // no action required, just here as a stub to prevent calling a non-existing 'opts.ignore()' function.\n },\n sourceObject: sourceObject,\n sourcePropertyName: sourcePropertyName,\n intermediatePropertyValue: sourceObject ? sourceObject[sourcePropertyName] : sourceObject\n };\n return memberConfigurationOptions;\n };\n return AutoMapperBase;\n }());\n AutoMapperJs.AutoMapperBase = AutoMapperBase;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AutoMapperBase.js.map\n","/// \n/// \n/// \n/// \n/// \nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * AsyncAutoMapper implementation, for asynchronous mapping support when using AutoMapper.\n */\n var AsyncAutoMapper = (function (_super) {\n __extends(AsyncAutoMapper, _super);\n function AsyncAutoMapper() {\n var _this = _super.call(this) || this;\n AsyncAutoMapper.asyncInstance = _this;\n return _this;\n }\n AsyncAutoMapper.prototype.createMap = function (sourceKeyOrType, destinationKeyOrType) {\n throw new Error('Method AsyncAutoMapper.createMap is not implemented.');\n };\n AsyncAutoMapper.prototype.createMapForMember = function (mapping, property) {\n var _this = this;\n mapping.async = true;\n mapping.mapItemFunction = function (m, srcObj, dstObj, cb) { return _this.mapItem(m, srcObj, dstObj, cb); };\n // property.async = true;\n // property.conversionValuesAndFunctions.push(func);\n };\n AsyncAutoMapper.prototype.createMapConvertUsing = function (mapping, converterFunction) {\n var _this = this;\n mapping.async = true;\n mapping.typeConverterFunction = converterFunction;\n mapping.mapItemFunction = function (m, srcObj, dstObj, cb) { return _this.mapItemUsingTypeConverter(m, srcObj, dstObj, cb); };\n };\n AsyncAutoMapper.prototype.map = function (mappings, sourceKey, destinationKey, sourceObject, callback) {\n var _this = this;\n switch (arguments.length) {\n case 5:\n this.mapWithMapping(_super.prototype.getMapping.call(this, mappings, sourceKey, destinationKey), sourceObject, callback);\n return;\n // provide performance optimized (preloading) currying support.\n case 4:\n return function (cb) { return _this.mapWithMapping(_super.prototype.getMapping.call(_this, mappings, sourceKey, destinationKey), sourceObject, cb); };\n case 3:\n return function (srcObj, cb) { return _this.mapWithMapping(_super.prototype.getMapping.call(_this, mappings, sourceKey, destinationKey), srcObj, cb); };\n case 2:\n return function (dstKey, srcObj, cb) { return _this.map(mappings, sourceKey, dstKey, srcObj, cb); };\n default:\n throw new Error('The AsyncAutoMapper.map function expects between 2 and 5 parameters, you provided ' + arguments.length + '.');\n }\n };\n AsyncAutoMapper.prototype.mapWithMapping = function (mapping, sourceObject, callback) {\n if (_super.prototype.isArray.call(this, sourceObject)) {\n this.mapArray(mapping, sourceObject, callback);\n return;\n }\n return mapping.mapItemFunction(mapping, sourceObject, _super.prototype.createDestinationObject.call(this, mapping.destinationTypeClass), callback);\n };\n /**\n * Execute a mapping from the source array to a new destination array with explicit mapping configuration and supplied mapping options (using createMap).\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceArray The source array to map.\n * @returns {Array} Destination array.\n */\n AsyncAutoMapper.prototype.mapArray = function (mapping, sourceArray, callback) {\n var callbacksToGo = 0;\n var destinationArray = _super.prototype.handleArray.call(this, mapping, sourceArray, function (sourceObject, destinationObject) {\n callbacksToGo++;\n mapping.mapItemFunction(mapping, sourceObject, destinationObject, function (result) {\n callbacksToGo--;\n });\n });\n var waitForCallbackToSend = function () {\n if (callbacksToGo === 0) {\n callback(destinationArray);\n }\n else {\n setTimeout(function () {\n waitForCallbackToSend();\n }, 10 * callbacksToGo);\n }\n };\n waitForCallbackToSend();\n };\n AsyncAutoMapper.prototype.mapItemUsingTypeConverter = function (mapping, sourceObject, destinationObject, callback) {\n var resolutionContext = {\n sourceValue: sourceObject,\n destinationValue: destinationObject\n };\n mapping.typeConverterFunction(resolutionContext, callback);\n };\n /**\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceObject The source object to map.\n * @param destinationObject The destination object to map to.\n * @param callback The callback to call after async mapping has been executed.\n */\n AsyncAutoMapper.prototype.mapItem = function (mapping, sourceObject, destinationObject, callback) {\n var _this = this;\n var callbacksToGo = 0;\n _super.prototype.handleItem.call(this, mapping, sourceObject, destinationObject, function (sourceProperty) {\n callbacksToGo++;\n _this.mapProperty(mapping, sourceObject, sourceProperty, destinationObject, function (result) {\n callbacksToGo--;\n });\n });\n var waitForCallbackToSend = function () {\n if (callbacksToGo === 0) {\n callback(destinationObject);\n }\n else {\n setTimeout(function () {\n waitForCallbackToSend();\n }, 10 * callbacksToGo);\n }\n };\n waitForCallbackToSend();\n };\n /**\n * Execute a mapping from the source object property to the destination object property with explicit mapping configuration and supplied mapping options.\n * @param mapping The mapping configuration for the current mapping keys/types.\n * @param sourceObject The source object to map.\n * @param sourcePropertyName The source property to map.\n * @param destinationObject The destination object to map to.\n * @param callback The callback to call after async property mapping has been executed.\n */\n AsyncAutoMapper.prototype.mapProperty = function (mapping, sourceObject, sourceProperty, destinationObject, callback) {\n var _this = this;\n _super.prototype.handleProperty.call(this, mapping, sourceObject, sourceProperty, destinationObject, function (destinationProperty, options) {\n _this.transform(mapping, sourceObject, destinationProperty, destinationObject, options, function (destinationPropertyValue, success) {\n callback(destinationPropertyValue);\n });\n }, function (destinationPropertyValue) {\n callback(destinationPropertyValue);\n });\n };\n AsyncAutoMapper.prototype.transform = function (mapping, sourceObject, destinationProperty, destinationObject, options, callback) {\n var _this = this;\n var childDestinationProperty = destinationProperty.child;\n if (childDestinationProperty) {\n var childDestinationObject = destinationObject[destinationProperty.name];\n if (!childDestinationObject) {\n // no child source object? create.\n childDestinationObject = {};\n }\n // transform child by recursively calling the transform function.\n this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options, function (callbackValue, success) {\n if (success) {\n // only set child destination object when transformation has been successful.\n destinationObject[destinationProperty.name] = childDestinationObject;\n }\n callback(options.intermediatePropertyValue, success);\n });\n return;\n }\n if (!_super.prototype.shouldProcessDestination.call(this, destinationProperty, sourceObject)) {\n callback(undefined /* opts.intermediatePropertyValue */, false);\n return;\n }\n // actually transform destination property.\n this.processTransformations(destinationProperty, destinationProperty.transformations, options, function (callbackValue, success) {\n if (success) {\n _super.prototype.setPropertyValue.call(_this, mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\n }\n callback(options.intermediatePropertyValue, success);\n });\n };\n AsyncAutoMapper.prototype.processTransformations = function (property, transformations, options, callback) {\n var _this = this;\n if (transformations.length === 0) {\n callback(options.intermediatePropertyValue, true);\n return;\n }\n var transformation = transformations[0];\n this.processTransformation(property, transformation, options, function (callbackValue, success) {\n if (!success) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n _this.processTransformations(property, transformations.slice(1), options, callback);\n });\n };\n AsyncAutoMapper.prototype.processTransformation = function (property, transformation, options, callback) {\n switch (transformation.transformationType) {\n case AutoMapperJs.DestinationTransformationType.Constant:\n options.intermediatePropertyValue = transformation.constant;\n callback(options.intermediatePropertyValue, true);\n return;\n case AutoMapperJs.DestinationTransformationType.MemberOptions: {\n var result = transformation.memberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n }\n case AutoMapperJs.DestinationTransformationType.SourceMemberOptions: {\n var result = transformation.sourceMemberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n callback(options.intermediatePropertyValue, false);\n return;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n }\n case AutoMapperJs.DestinationTransformationType.AsyncMemberOptions:\n transformation.asyncMemberConfigurationOptionsFunc(options, function (result) {\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n });\n return;\n case AutoMapperJs.DestinationTransformationType.AsyncSourceMemberOptions:\n transformation.asyncSourceMemberConfigurationOptionsFunc(options, function (result) {\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n callback(options.intermediatePropertyValue, true);\n return;\n });\n return;\n default:\n // TODO: this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation}`);\n callback(options.intermediatePropertyValue, false);\n return;\n }\n };\n return AsyncAutoMapper;\n }(AutoMapperJs.AutoMapperBase));\n AsyncAutoMapper.asyncInstance = new AsyncAutoMapper();\n AutoMapperJs.AsyncAutoMapper = AsyncAutoMapper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=AsyncAutoMapper.js.map\n","/// \n/// \n/// \n/// \n/// \n/// \n/// \nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var AutoMapper = (function (_super) {\n __extends(AutoMapper, _super);\n /**\n * This class is intended to be a Singleton. Preferrably use getInstance()\n * function instead of using the constructor directly from code.\n */\n function AutoMapper() {\n var _this = _super.call(this) || this;\n if (AutoMapper._instance) {\n return AutoMapper._instance;\n }\n else {\n AutoMapper._instance = _this;\n _this._profiles = {};\n _this._mappings = {};\n _this._asyncMapper = new AutoMapperJs.AsyncAutoMapper();\n }\n return _this;\n }\n AutoMapper.getInstance = function () {\n return AutoMapper._instance;\n };\n /**\n * Initializes the mapper with the supplied configuration.\n * @param {(config: IConfiguration) => void} configFunction Configuration function to call.\n */\n AutoMapper.prototype.initialize = function (configFunction) {\n var that = this;\n var configuration = {\n addProfile: function (profile) {\n profile.configure();\n that._profiles[profile.profileName] = profile;\n },\n createMap: function (sourceKey, destinationKey) {\n // pass through using arguments to keep createMap's currying support fully functional.\n return that.createMap.apply(that, arguments);\n }\n };\n configFunction(configuration);\n };\n /**\n * Create a mapping profile.\n * @param {string} sourceKey The map source key.\n * @param {string} destinationKey The map destination key.\n * @returns {Core.ICreateMapFluentFunctions}\n */\n AutoMapper.prototype.createMap = function (sourceKeyOrType, destinationKeyOrType) {\n // provide currying support.\n if (arguments.length < 2) {\n return AutoMapperJs.AutoMapperHelper.handleCurrying(this.createMap, arguments, this);\n }\n var mapping = this.createMappingObjectForGivenKeys(sourceKeyOrType, destinationKeyOrType);\n return this.createMapGetFluentApiFunctions(mapping);\n };\n /**\n * Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param sourceKey Source key, for instance the source type name.\n * @param destinationKey Destination key, for instance the destination type name.\n * @param sourceObject The source object to map.\n * @returns {any} Destination object.\n */\n AutoMapper.prototype.map = function (sourceKeyOrType, destinationKeyOrType, sourceObject) {\n var _this = this;\n if (arguments.length === 3) {\n return this.mapInternal(_super.prototype.getMapping.call(this, this._mappings, sourceKeyOrType, destinationKeyOrType), sourceObject);\n }\n // provide performance optimized (preloading) currying support.\n if (arguments.length === 2) {\n return function (srcObj) { return _this.mapInternal(_super.prototype.getMapping.call(_this, _this._mappings, sourceKeyOrType, destinationKeyOrType), srcObj); };\n }\n if (arguments.length === 1) {\n return function (dstKey, srcObj) { return _this.map(sourceKeyOrType, dstKey, srcObj); };\n }\n return function (srcKey, dstKey, srcObj) { return _this.map(srcKey, dstKey, srcObj); };\n };\n /**\n * Execute an asynchronous mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).\n * @param sourceKey Source key, for instance the source type name.\n * @param destinationKey Destination key, for instance the destination type name.\n * @param sourceObject The source object to map.\n * @param {IMapCallback} callback The callback to call when asynchronous mapping is complete.\n */\n AutoMapper.prototype.mapAsync = function (sourceKeyOrType, destinationKeyOrType, sourceObject, callback) {\n switch (arguments.length) {\n case 4:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject, callback);\n case 3:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType, sourceObject);\n case 2:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType, destinationKeyOrType);\n case 1:\n return this._asyncMapper.map(this._mappings, sourceKeyOrType);\n default:\n throw new Error('The mapAsync function expects between 1 and 4 parameters, you provided ' + arguments.length + '.');\n }\n };\n /**\n * Validates mapping configuration by dry-running. Since JS does not fully support typing, it only checks if properties match on both\n * sides. The function needs IMapping.sourceTypeClass and IMapping.destinationTypeClass to function.\n * @param {boolean} strictMode Whether or not to fail when properties sourceTypeClass or destinationTypeClass are unavailable.\n */\n AutoMapper.prototype.assertConfigurationIsValid = function (strictMode) {\n if (strictMode === void 0) { strictMode = true; }\n AutoMapperJs.AutoMapperValidator.assertConfigurationIsValid(this._mappings, strictMode);\n };\n AutoMapper.prototype.createMapForAllMembers = function (mapping, fluentFunc, func) {\n mapping.forAllMemberMappings.push(func);\n return fluentFunc;\n };\n AutoMapper.prototype.createMapIgnoreAllNonExisting = function (mapping, fluentFunc) {\n mapping.ignoreAllNonExisting = true;\n return fluentFunc;\n };\n AutoMapper.prototype.createMapConvertToType = function (mapping, fluentFunc, typeClass) {\n if (mapping.destinationTypeClass) {\n throw new Error('Destination type class can only be set once.');\n }\n mapping.destinationTypeClass = typeClass;\n return fluentFunc;\n };\n AutoMapper.prototype.createMapConvertUsing = function (mapping, tcClassOrFunc) {\n var _this = this;\n var configureSynchronousConverterFunction = function (converterFunc) {\n if (!converterFunc || AutoMapperJs.AutoMapperHelper.getFunctionParameters(converterFunc.toString()).length !== 1) {\n throw new Error('The function provided does not provide exactly one (resolutionContext) parameter.');\n }\n mapping.typeConverterFunction = converterFunc;\n mapping.mapItemFunction = function (m, srcObj, dstObj) { return _this.mapItemUsingTypeConverter(m, srcObj, dstObj); };\n };\n try {\n // check if sync: TypeConverter instance\n if (tcClassOrFunc instanceof AutoMapperJs.TypeConverter) {\n configureSynchronousConverterFunction(tcClassOrFunc.convert);\n return;\n }\n var functionParameters = AutoMapperJs.AutoMapperHelper.getFunctionParameters(tcClassOrFunc.toString());\n switch (functionParameters.length) {\n case 0:\n // check if sync: TypeConverter class definition\n var typeConverter;\n try {\n typeConverter = new tcClassOrFunc();\n }\n catch (e) {\n // Obviously, typeConverterClassOrFunction is not a TypeConverter class definition\n }\n if (typeConverter instanceof AutoMapperJs.TypeConverter) {\n configureSynchronousConverterFunction(typeConverter.convert);\n return;\n }\n break;\n case 1:\n // sync: function with resolutionContext parameter\n configureSynchronousConverterFunction(tcClassOrFunc);\n return;\n case 2:\n // check if async: function with resolutionContext and callback parameters\n this._asyncMapper.createMapConvertUsing(mapping, tcClassOrFunc);\n return;\n }\n // okay, just try feeding the function to the configure function anyway...\n configureSynchronousConverterFunction(tcClassOrFunc);\n }\n catch (e) {\n throw new Error(\"The value provided for typeConverterClassOrFunction is invalid. \" + e);\n }\n };\n AutoMapper.prototype.createMapWithProfile = function (mapping, profileName) {\n // check if given profile exists\n var profile = this._profiles[profileName];\n if (typeof profile === 'undefined' || profile.profileName !== profileName) {\n throw new Error(\"Could not find profile with profile name '\" + profileName + \"'.\");\n }\n mapping.profile = profile;\n // merge mappings\n this.createMapWithProfileMergeMappings(mapping, profileName);\n };\n AutoMapper.prototype.createMapWithProfileMergeMappings = function (mapping, profileName) {\n var profileMappingKey = profileName + \"=>\" + mapping.sourceKey + profileName + \"=>\" + mapping.destinationKey;\n var profileMapping = this._mappings[profileMappingKey];\n if (!profileMapping) {\n return;\n }\n // append forAllMemberMappings calls to the original array.\n if (profileMapping.forAllMemberMappings.length > 0) {\n (_a = mapping.forAllMemberMappings).push.apply(_a, profileMapping.forAllMemberMappings);\n }\n // overwrite original type converter function\n if (profileMapping.typeConverterFunction) {\n mapping.typeConverterFunction = profileMapping.typeConverterFunction;\n mapping.mapItemFunction = profileMapping.mapItemFunction;\n }\n // overwrite original type converter function\n if (profileMapping.destinationTypeClass) {\n mapping.destinationTypeClass = profileMapping.destinationTypeClass;\n }\n // walk through all the profile's property mappings\n for (var _i = 0, _b = profileMapping.properties; _i < _b.length; _i++) {\n var property = _b[_i];\n // TODO Awkward way of locating sourceMapping ;) ...\n var sourceMapping = this.getDestinationProperty(property.destinationPropertyName, property).sourceMapping;\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\n mapping.properties.push(property);\n }\n }\n var _a;\n };\n AutoMapper.prototype.mapInternal = function (mapping, sourceObject) {\n if (mapping.async) {\n throw new Error('Impossible to use asynchronous mapping using automapper.map(); use automapper.mapAsync() instead.');\n }\n if (_super.prototype.isArray.call(this, sourceObject)) {\n return this.mapArray(mapping, sourceObject);\n }\n return mapping.mapItemFunction(mapping, sourceObject, _super.prototype.createDestinationObject.call(this, mapping.destinationTypeClass));\n };\n AutoMapper.prototype.mapArray = function (mapping, sourceArray) {\n var destinationArray = _super.prototype.handleArray.call(this, mapping, sourceArray, function (sourceObject, destinationObject) {\n mapping.mapItemFunction(mapping, sourceObject, destinationObject);\n });\n return destinationArray;\n };\n AutoMapper.prototype.mapItem = function (mapping, sourceObject, destinationObject) {\n var _this = this;\n destinationObject = _super.prototype.handleItem.call(this, mapping, sourceObject, destinationObject, function (propertyName) {\n _this.mapProperty(mapping, sourceObject, destinationObject, propertyName);\n });\n return destinationObject;\n };\n AutoMapper.prototype.mapItemUsingTypeConverter = function (mapping, sourceObject, destinationObject, arrayIndex) {\n var resolutionContext = {\n sourceValue: sourceObject,\n destinationValue: destinationObject\n };\n return mapping.typeConverterFunction(resolutionContext);\n };\n AutoMapper.prototype.mapProperty = function (mapping, sourceObject, destinationObject, sourceProperty) {\n var _this = this;\n _super.prototype.handleProperty.call(this, mapping, sourceObject, sourceProperty, destinationObject, function (destinationProperty, options) {\n return _this.transform(mapping, sourceObject, destinationProperty, destinationObject, options);\n });\n };\n AutoMapper.prototype.transform = function (mapping, sourceObject, destinationProperty, destinationObject, options) {\n var childDestinationProperty = destinationProperty.child;\n if (childDestinationProperty) {\n var childDestinationObject = destinationObject[destinationProperty.name];\n if (!childDestinationObject) {\n // no child source object? create.\n childDestinationObject = {};\n }\n // transform child by recursively calling the transform function.\n var transformed = this.transform(mapping, sourceObject, childDestinationProperty, childDestinationObject, options /*, callback*/);\n if (transformed) {\n // only set child destination object when transformation has been successful.\n destinationObject[destinationProperty.name] = childDestinationObject;\n }\n return transformed;\n }\n if (!_super.prototype.shouldProcessDestination.call(this, destinationProperty, sourceObject)) {\n return false;\n }\n // actually transform destination property.\n for (var _i = 0, _a = destinationProperty.transformations; _i < _a.length; _i++) {\n var transformation = _a[_i];\n if (!this.processTransformation(destinationProperty, transformation, options)) {\n return false;\n }\n }\n _super.prototype.setPropertyValue.call(this, mapping, destinationProperty, destinationObject, options.intermediatePropertyValue);\n return true;\n };\n AutoMapper.prototype.processTransformation = function (property, transformation, options) {\n switch (transformation.transformationType) {\n case AutoMapperJs.DestinationTransformationType.Constant:\n options.intermediatePropertyValue = transformation.constant;\n return true;\n case AutoMapperJs.DestinationTransformationType.MemberOptions: {\n var result = transformation.memberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n return false;\n }\n return true;\n }\n case AutoMapperJs.DestinationTransformationType.SourceMemberOptions: {\n var result = transformation.sourceMemberConfigurationOptionsFunc(options);\n if (typeof result !== 'undefined') {\n options.intermediatePropertyValue = result;\n }\n else if (!options.sourceObject) {\n return false;\n }\n return true;\n }\n default:\n // this.throwMappingException(property, `AutoMapper.handlePropertyMappings: Unexpected transformation type ${transformation.transformationType}`);\n return false;\n }\n };\n AutoMapper.prototype.createMappingObjectForGivenKeys = function (srcKeyOrType, dstKeyOrType) {\n var _this = this;\n var mapping = {\n sourceKey: _super.prototype.getKey.call(this, srcKeyOrType),\n destinationKey: _super.prototype.getKey.call(this, dstKeyOrType),\n forAllMemberMappings: new Array(),\n properties: [],\n typeConverterFunction: undefined,\n mapItemFunction: function (m, srcObj, dstObj) { return _this.mapItem(m, srcObj, dstObj); },\n sourceTypeClass: (typeof srcKeyOrType === 'string' ? undefined : srcKeyOrType),\n destinationTypeClass: (typeof dstKeyOrType === 'string' ? undefined : dstKeyOrType),\n profile: undefined,\n async: false\n };\n this._mappings[mapping.sourceKey + mapping.destinationKey] = mapping;\n return mapping;\n };\n AutoMapper.prototype.createMapGetFluentApiFunctions = function (mapping) {\n var _this = this;\n // create a fluent interface / method chaining (e.g. automapper.createMap().forMember().forMember() ...)\n var fluentFunc = {\n forMember: function (prop, valFunc) {\n return _this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: valFunc, sourceMapping: false, fluentFunctions: fluentFunc });\n },\n forSourceMember: function (prop, cfgFunc) {\n return _this.createMapForMember({ mapping: mapping, propertyName: prop, transformation: cfgFunc, sourceMapping: true, fluentFunctions: fluentFunc });\n },\n forAllMembers: function (func) {\n return _this.createMapForAllMembers(mapping, fluentFunc, func);\n },\n ignoreAllNonExisting: function () { return _this.createMapIgnoreAllNonExisting(mapping, fluentFunc); },\n convertToType: function (type) { return _this.createMapConvertToType(mapping, fluentFunc, type); },\n convertUsing: function (tcClassOrFunc) {\n return _this.createMapConvertUsing(mapping, tcClassOrFunc);\n },\n withProfile: function (profile) { return _this.createMapWithProfile(mapping, profile); }\n };\n return fluentFunc;\n };\n AutoMapper.prototype.createMapForMember = function (parameters) {\n var mapping = parameters.mapping, propertyName = parameters.propertyName, transformation = parameters.transformation, sourceMapping = parameters.sourceMapping, fluentFunctions = parameters.fluentFunctions;\n // extract source/destination property names\n var metadata = AutoMapperJs.AutoMapperHelper.getMappingMetadataFromTransformationFunction(propertyName, transformation, sourceMapping);\n this.validateForMemberParameters(metadata);\n var source = metadata.source, destination = metadata.destination;\n // create property (regardless of current existance)\n var property = this.createSourceProperty(metadata, null);\n // merge with existing property or add property\n if (!this.mergeSourceProperty(property, mapping.properties, sourceMapping)) {\n mapping.properties.push(property);\n }\n if (metadata.async) {\n this._asyncMapper.createMapForMember(mapping, this.findProperty(property.name, mapping.properties));\n }\n return fluentFunctions;\n };\n AutoMapper.prototype.validateForMemberParameters = function (metadata) {\n if (!metadata.sourceMapping) {\n return;\n }\n // validate forSourceMember parameters\n if (metadata.transformation.transformationType === AutoMapperJs.DestinationTransformationType.Constant) {\n throw new Error('Configuration of forSourceMember has to be a function with one (sync) or two (async) options parameters.');\n }\n };\n AutoMapper.prototype.createSourceProperty = function (metadata, parent) {\n var level = !parent ? 0 : parent.level + 1;\n var sourceNameParts = metadata.source.split('.');\n var source = {\n name: sourceNameParts[level],\n sourcePropertyName: metadata.source,\n destinationPropertyName: metadata.destination,\n parent: parent,\n level: level,\n children: [],\n destination: null\n };\n if ((level + 1) < sourceNameParts.length) {\n // recursively add child source properties ...\n var child = this.createSourceProperty(metadata, source);\n if (child) {\n source.children.push(child);\n }\n source.destination = null;\n }\n else {\n // ... or (!) add destination\n source.destination = this.createDestinationProperty(metadata, null);\n }\n return source;\n };\n AutoMapper.prototype.createDestinationProperty = function (metadata, parent) {\n var level = !parent ? 0 : parent.level + 1;\n var destinationNameParts = metadata.destination.split('.');\n var destination = {\n name: destinationNameParts[level],\n sourcePropertyName: metadata.source,\n destinationPropertyName: metadata.destination,\n parent: parent,\n level: level,\n child: null,\n transformations: [],\n conditionFunction: null,\n ignore: false,\n sourceMapping: false\n };\n if ((level + 1) < destinationNameParts.length) {\n // recursively add child destination properties\n destination.child = this.createDestinationProperty(metadata, destination);\n }\n else {\n // add/merge properties\n destination.sourceMapping = metadata.sourceMapping;\n destination.conditionFunction = metadata.condition;\n destination.ignore = metadata.ignore;\n destination.transformations.push(metadata.transformation);\n }\n return destination;\n };\n AutoMapper.prototype.mergeSourceProperty = function (property, existingProperties, sourceMapping) {\n // find source property\n var existing = sourceMapping\n ? this.findProperty(property.name, existingProperties)\n : this.matchSourcePropertyByDestination(property, existingProperties);\n if (!existing) {\n return false;\n }\n if (property.destination) {\n if (existing.children.length > 0) {\n var existingDestination = this.getDestinationProperty(existing.destinationPropertyName, existing);\n // existing is (further) nested => rebase and/or merge\n if (this.handleMapFromProperties(property, existing)) {\n // merge and rebase existing destination to current source level\n if (!this.mergeDestinationProperty(property.destination, existingDestination)) {\n return false;\n }\n existing.destination = existingDestination;\n existing.children = [];\n return true;\n }\n // merge property.destination with existing mapFrom() destination (don't care about nesting depth here)\n return this.mergeDestinationProperty(property.destination, existingDestination);\n }\n // both are at same level => simple merge.\n if (!this.mergeDestinationProperty(property.destination, existing.destination)) {\n return false;\n }\n this.handleMapFromProperties(property, existing);\n return true;\n }\n // new source is (further) nested (has children).\n if (existing.children.length > 0) {\n // both have further nesting, delegate merging child(ren) by recursively calling this function.\n for (var _i = 0, _a = property.children; _i < _a.length; _i++) {\n var child = _a[_i];\n if (!this.mergeSourceProperty(child, existing.children, sourceMapping)) {\n return false;\n }\n }\n if (property.destinationPropertyName !== property.sourcePropertyName) {\n // this is a mapFrom() registration. It is handled using the nested source properties,\n // we only are responsible for syncing the name properties.\n existing.name = property.name;\n existing.sourcePropertyName = property.sourcePropertyName;\n }\n return true;\n }\n // existing is not (further) nested. this is always a mapFrom() situation.\n // if (property.sourcePropertyName !== existing.sourcePropertyName) {\n var newDestination = this.getDestinationProperty(existing.destinationPropertyName, property);\n if (property.destinationPropertyName !== property.sourcePropertyName) {\n // this is a mapFrom() registration. In that case:\n // 1) merge destinations, 2) add source child and 3) move destination to (youngest) child\n // NOTE special mergeDestinationProperty call => we use the new destination as 'target',\n // because that will save us trouble overwriting ;)...\n if (!this.mergeDestinationProperty(existing.destination, newDestination, true)) {\n return false;\n }\n existing.children = property.children;\n existing.name = property.name;\n existing.sourcePropertyName = property.sourcePropertyName;\n existing.destination = null;\n // TODO Should never be necessary (test): existing.destinationPropertyName = property.destinationPropertyName;\n return true;\n }\n // ... nope, it is a destination which has previously been registered using mapFrom. just merge\n return this.mergeDestinationProperty(newDestination, existing.destination);\n // }\n };\n /**\n * handle property naming when the current property to merge is a mapFrom property\n */\n AutoMapper.prototype.handleMapFromProperties = function (property, existingProperty) {\n if (property.destinationPropertyName === property.sourcePropertyName ||\n property.sourcePropertyName === existingProperty.sourcePropertyName) {\n return false;\n }\n // only overwrite name when a mapFrom situation applies\n existingProperty.name = property.name;\n existingProperty.sourcePropertyName = property.sourcePropertyName;\n // TODO Should never be necessary (test) => existingProperty.destinationPropertyName = property.destinationPropertyName;\n return true;\n };\n AutoMapper.prototype.getDestinationProperty = function (destinationPropertyName, existingSource) {\n if (existingSource.destination) {\n return existingSource.destination;\n }\n for (var _i = 0, _a = existingSource.children; _i < _a.length; _i++) {\n var child = _a[_i];\n var destination = this.getDestinationProperty(destinationPropertyName, child);\n if (destination) {\n return destination;\n }\n }\n return null;\n };\n AutoMapper.prototype.mergeDestinationProperty = function (destination, existingDestination, swapTransformations) {\n if (swapTransformations === void 0) { swapTransformations = false; }\n if (destination.child) {\n if (existingDestination.child) {\n // both have further nesting, delegate merging children by recursively calling this function.\n if (!this.mergeDestinationProperty(destination.child, existingDestination.child, swapTransformations)) {\n return false;\n }\n this.handleMapFromProperties(destination, existingDestination);\n return true;\n }\n // the current destination is not (further) nested. a destination property registration has one of both:\n // a) children or b) transformations. returning false will cause creating a duplicate source property entry instead.\n return false;\n }\n if (existingDestination.sourceMapping !== destination.sourceMapping &&\n existingDestination.sourcePropertyName !== destination.sourcePropertyName) {\n // unable to perform mapFrom() on a property which is being registered using forSourceMember.\n return false; // TODO: Unpredictable? Idea: throw new Error('Unable to perform mapFrom() on a property which is being registered using forSourceMember.');\n }\n // merge destination properties\n if (destination.sourceMapping) {\n // only set source mapping when not yet set to true, once source mapped is source mapped forever.\n // TODO Verify edge cases!\n existingDestination.sourceMapping = destination.sourceMapping;\n }\n if (destination.ignore) {\n // only set ignore when not yet set, once ignored is ignored forever.\n existingDestination.ignore = destination.ignore;\n }\n if (destination.conditionFunction) {\n // overwrite condition function by the latest one specified.\n existingDestination.conditionFunction = destination.conditionFunction;\n }\n var transformations = [];\n if (swapTransformations) {\n for (var _i = 0, _a = destination.transformations; _i < _a.length; _i++) {\n var transformation = _a[_i];\n transformations.push(transformation);\n }\n for (var _b = 0, _c = existingDestination.transformations; _b < _c.length; _b++) {\n var transformation = _c[_b];\n transformations.push(transformation);\n }\n }\n else {\n for (var _d = 0, _e = existingDestination.transformations; _d < _e.length; _d++) {\n var transformation = _e[_d];\n transformations.push(transformation);\n }\n for (var _f = 0, _g = destination.transformations; _f < _g.length; _f++) {\n var transformation = _g[_f];\n transformations.push(transformation);\n }\n }\n existingDestination.transformations = transformations;\n this.handleMapFromProperties(destination, existingDestination);\n return true;\n };\n AutoMapper.prototype.matchSourcePropertyByDestination = function (source, properties) {\n if (!properties) {\n return null;\n }\n for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {\n var property = properties_1[_i];\n if (property.destinationPropertyName === source.destinationPropertyName) {\n return property;\n }\n }\n return null;\n };\n AutoMapper.prototype.findProperty = function (name, properties) {\n if (!properties) {\n return null;\n }\n for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) {\n var property = properties_2[_i];\n if (property.name === name) {\n return property;\n }\n }\n return null;\n };\n return AutoMapper;\n }(AutoMapperJs.AutoMapperBase));\n AutoMapper._instance = new AutoMapper();\n AutoMapperJs.AutoMapper = AutoMapper;\n})(AutoMapperJs || (AutoMapperJs = {}));\n// Add AutoMapper to the application's global scope. Of course, you could still use Core.AutoMapper.getInstance() as well.\nvar automapper = (function (app) {\n app.automapper = AutoMapperJs.AutoMapper.getInstance();\n return app.automapper;\n})(this);\n\n//# sourceMappingURL=AutoMapper.js.map\n","/// \n/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * Converts source type to destination type instead of normal member mapping\n */\n var Profile = (function () {\n function Profile() {\n }\n /**\n * Implement this method in a derived class and call the CreateMap method to associate that map with this profile.\n * Avoid calling the AutoMapper class / automapper instance from this method.\n */\n Profile.prototype.configure = function () {\n // do nothing\n };\n /**\n * Create a mapping profile.\n * @param {string} sourceKey The map source key.\n * @param {string} destinationKey The map destination key.\n * @returns {Core.ICreateMapFluentFunctions}\n */\n Profile.prototype.createMap = function (sourceKey, destinationKey) {\n var argsCopy = Array.prototype.slice.apply(arguments);\n for (var index = 0, length = argsCopy.length; index < length; index++) {\n if (argsCopy[index]) {\n // prefix sourceKey and destinationKey with 'profileName=>'\n argsCopy[index] = this.profileName + \"=>\" + argsCopy[index];\n }\n }\n // pass through using arguments to keep createMap's currying support fully functional.\n return automapper.createMap.apply(automapper, argsCopy);\n };\n return Profile;\n }());\n AutoMapperJs.Profile = Profile;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=Profile.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n /**\n * Converts source type to destination type instead of normal member mapping\n */\n var TypeConverter = (function () {\n function TypeConverter() {\n }\n /**\n * Performs conversion from source to destination type.\n * @param {IResolutionContext} resolutionContext Resolution context.\n * @returns {any} Destination object.\n */\n TypeConverter.prototype.convert = function (resolutionContext) {\n // NOTE BL Unfortunately, TypeScript/JavaScript do not support abstract base classes.\n // This is just one way around, please convince me about a better solution.\n throw new Error('The TypeConverter.convert method is abstract. Use a TypeConverter extension class instead.');\n };\n return TypeConverter;\n }());\n AutoMapperJs.TypeConverter = TypeConverter;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=TypeConverter.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var CamelCaseNamingConvention = (function () {\n function CamelCaseNamingConvention() {\n this.splittingExpression = /(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\n this.separatorCharacter = '';\n }\n CamelCaseNamingConvention.prototype.transformPropertyName = function (sourcePropertyNameParts) {\n // Transform the splitted parts.\n var result = '';\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\n if (index === 0) {\n result += sourcePropertyNameParts[index].charAt(0).toLowerCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n else {\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\n sourcePropertyNameParts[index].substr(1);\n }\n }\n return result;\n };\n return CamelCaseNamingConvention;\n }());\n AutoMapperJs.CamelCaseNamingConvention = CamelCaseNamingConvention;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=CamelCaseNamingConvention.js.map\n","/// \nvar AutoMapperJs;\n(function (AutoMapperJs) {\n 'use strict';\n var PascalCaseNamingConvention = (function () {\n function PascalCaseNamingConvention() {\n this.splittingExpression = /(^[A-Z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/;\n this.separatorCharacter = '';\n }\n PascalCaseNamingConvention.prototype.transformPropertyName = function (sourcePropertyNameParts) {\n // Transform the splitted parts.\n var result = '';\n for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) {\n result += sourcePropertyNameParts[index].charAt(0).toUpperCase() +\n sourcePropertyNameParts[index].substr(1);\n //if (index < (length - 1)) {\n // this.separatorCharacter;\n //}\n }\n return result;\n };\n return PascalCaseNamingConvention;\n }());\n AutoMapperJs.PascalCaseNamingConvention = PascalCaseNamingConvention;\n})(AutoMapperJs || (AutoMapperJs = {}));\n\n//# sourceMappingURL=PascalCaseNamingConvention.js.map\n"]} \ No newline at end of file diff --git a/gulp.config.js b/gulp.config.js index 23be05e..69a4a21 100644 --- a/gulp.config.js +++ b/gulp.config.js @@ -2,7 +2,7 @@ var GulpConfig = (function () { function gulpConfig() { - this.libraryVersion = '1.8.1'; + this.libraryVersion = '1.8.2'; // folder definitions this.baseFolder = './'; diff --git a/package.json b/package.json index e88d977..f5d4e36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "automapper-ts", - "version": "1.8.1", + "version": "1.8.2", "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", @@ -35,10 +35,10 @@ "gulp-header": "^1.8.8", "gulp-inject": "^4.2.0", "gulp-replace": "^0.5.4", - "gulp-sourcemaps": "^1.9.1", - "gulp-tslint": "^7.0.1", + "gulp-sourcemaps": "^2.6.0", + "gulp-tslint": "^8.1.0", "gulp-typescript": "^3.1.3", - "gulp-uglify": "^2.0.0", + "gulp-uglify": "^3.0.0", "gulp-umd": "^0.2.0", "gulp-util": "^3.0.8", "jasmine-core": "^2.5.2", @@ -49,7 +49,7 @@ "karma-phantomjs-launcher": "^1.0.2", "path": "^0.12.7", "phantomjs-prebuilt": "^2.1.14", - "tslint": "^4.2.0", + "tslint": "^5.3.2", "typescript": "^2.1.4" } } diff --git a/samples/js/configuration.js b/samples/js/configuration.js index f202927..2d49342 100644 --- a/samples/js/configuration.js +++ b/samples/js/configuration.js @@ -1,11 +1,16 @@ /// /// /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var AutoMapperJs; (function (AutoMapperJs) { var Samples; @@ -20,7 +25,7 @@ var AutoMapperJs; var Person = (function (_super) { __extends(Person, _super); function Person() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return Person; }(Base)); diff --git a/samples/js/configuration.js.map b/samples/js/configuration.js.map index 7af3e42..647d4fb 100644 --- a/samples/js/configuration.js.map +++ b/samples/js/configuration.js.map @@ -1 +1 @@ -{"version":3,"sources":["configuration.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,8DAA8D;AAC9D,+DAA+D;;;;;;AAE/D,IAAO,YAAY,CA4ElB;AA5ED,WAAO,YAAY;IAAC,IAAA,OAAO,CA4E1B;IA5EmB,WAAA,OAAO;QACvB,YAAY,CAAC;QAEb;YAAA;YAEA,CAAC;YAAD,WAAC;QAAD,CAFA,AAEC,IAAA;QAFY,YAAI,OAEhB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apperJs.Samples {\r\n 'use strict';\r\n\r\n export class Base {\r\n public apiJsonResult: any;\r\n }\r\n\r\n export class Person extends Base {\r\n\r\n }\r\n\r\n class MappingProfile implements IProfile {\r\n public sourceMemberNamingConvention = new PascalCaseNamingConvention();\r\n public destinationMemberNamingConvention = new CamelCaseNamingConvention();\r\n\r\n public profileName = 'PascalCaseToCamelCase';\r\n\r\n public configure(): void {\r\n this.sourceMemberNamingConvention = new PascalCaseNamingConvention();\r\n this.destinationMemberNamingConvention = new CamelCaseNamingConvention();\r\n }\r\n }\r\n\r\n export class InitializeSamples {\r\n public static initialize(): any {\r\n automapper.initialize((cfg: IConfiguration) => {\r\n cfg.addProfile(new MappingProfile());\r\n });\r\n\r\n const sourceKey = 'initialize';\r\n const destinationKey = '{}';\r\n\r\n const sourceObject = { FullName: 'John Doe' };\r\n\r\n automapper\r\n .createMap(sourceKey, destinationKey)\r\n .withProfile('PascalCaseToCamelCase');\r\n\r\n var result = automapper.map(sourceKey, destinationKey, sourceObject);\r\n\r\n return result;\r\n }\r\n }\r\n\r\n export class ForMemberSamples {\r\n public static simpleMapFrom(): any {\r\n const sourceKey = 'simpleMapFrom';\r\n const destinationKey = '{}';\r\n\r\n const sourceObject = { fullName: 'John Doe' };\r\n\r\n automapper\r\n .createMap(sourceKey, destinationKey)\r\n .forMember('name', (opts: AutoMapperJs.IMemberConfigurationOptions) => opts.mapFrom('fullName'));\r\n\r\n var result = automapper.map(sourceKey, destinationKey, sourceObject);\r\n\r\n return result;\r\n }\r\n\r\n public static stackedForMemberCalls(): any {\r\n const sourceKey = 'stackedForMemberCalls';\r\n const destinationKey = 'Person';\r\n\r\n const sourceObject = { birthdayString: '2000-01-01T00:00:00.000Z' };\r\n\r\n automapper\r\n .createMap(sourceKey, destinationKey)\r\n .forMember('birthday', (opts: IMemberConfigurationOptions) => opts.mapFrom('birthdayString'))\r\n .forMember('birthday', (opts: IMemberConfigurationOptions) => new Date(opts.sourceObject[opts.sourcePropertyName]));\r\n\r\n var result = automapper.map(sourceKey, destinationKey, sourceObject);\r\n\r\n return result;\r\n }\r\n }\r\n}"]} \ No newline at end of file +{"version":3,"sources":["configuration.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,8DAA8D;AAC9D,+DAA+D;;;;;;;;;;;AAE/D,IAAO,YAAY,CA4ElB;AA5ED,WAAO,YAAY;IAAC,IAAA,OAAO,CA4E1B;IA5EmB,WAAA,OAAO;QACvB,YAAY,CAAC;QAEb;YAAA;YAEA,CAAC;YAAD,WAAC;QAAD,CAFA,AAEC,IAAA;QAFY,YAAI,OAEhB,CAAA;QAED;YAA4B,0BAAI;YAAhC;;YAEA,CAAC;YAAD,aAAC;QAAD,CAFA,AAEC,CAF2B,IAAI,GAE/B;QAFY,cAAM,SAElB,CAAA;QAED;YAAA;gBACW,iCAA4B,GAAG,IAAI,aAAA,0BAA0B,EAAE,CAAC;gBAChE,sCAAiC,GAAG,IAAI,aAAA,yBAAyB,EAAE,CAAC;gBAEpE,gBAAW,GAAG,uBAAuB,CAAC;YAMjD,CAAC;YAJU,kCAAS,GAAhB;gBACI,IAAI,CAAC,4BAA4B,GAAG,IAAI,aAAA,0BAA0B,EAAE,CAAC;gBACrE,IAAI,CAAC,iCAAiC,GAAG,IAAI,aAAA,yBAAyB,EAAE,CAAC;YAC7E,CAAC;YACL,qBAAC;QAAD,CAVA,AAUC,IAAA;QAED;YAAA;YAmBA,CAAC;YAlBiB,4BAAU,GAAxB;gBACI,UAAU,CAAC,UAAU,CAAC,UAAC,GAAmB;oBACtC,GAAG,CAAC,UAAU,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;gBACzC,CAAC,CAAC,CAAC;gBAEH,IAAM,SAAS,GAAG,YAAY,CAAC;gBAC/B,IAAM,cAAc,GAAG,IAAI,CAAC;gBAE5B,IAAM,YAAY,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;gBAE9C,UAAU;qBACL,SAAS,CAAC,SAAS,EAAE,cAAc,CAAC;qBAC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BAExH,IAAI,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;gBAErE,MAAM,CAAC,MAAM,CAAC;YAClB,CAAC;YACL,uBAAC;QAAD,CA/BA,AA+BC,IAAA;QA/BY,wBAAgB,mBA+B5B,CAAA;IACL,CAAC,EA5EmB,OAAO,GAAP,oBAAO,KAAP,oBAAO,QA4E1B;AAAD,CAAC,EA5EM,YAAY,KAAZ,YAAY,QA4ElB","file":"configuration.js","sourcesContent":["/// \r\n/// \r\n/// \r\n\r\nmodule AutoMapperJs.Samples {\r\n 'use strict';\r\n\r\n export class Base {\r\n public apiJsonResult: any;\r\n }\r\n\r\n export class Person extends Base {\r\n\r\n }\r\n\r\n class MappingProfile implements IProfile {\r\n public sourceMemberNamingConvention = new PascalCaseNamingConvention();\r\n public destinationMemberNamingConvention = new CamelCaseNamingConvention();\r\n\r\n public profileName = 'PascalCaseToCamelCase';\r\n\r\n public configure(): void {\r\n this.sourceMemberNamingConvention = new PascalCaseNamingConvention();\r\n this.destinationMemberNamingConvention = new CamelCaseNamingConvention();\r\n }\r\n }\r\n\r\n export class InitializeSamples {\r\n public static initialize(): any {\r\n automapper.initialize((cfg: IConfiguration) => {\r\n cfg.addProfile(new MappingProfile());\r\n });\r\n\r\n const sourceKey = 'initialize';\r\n const destinationKey = '{}';\r\n\r\n const sourceObject = { FullName: 'John Doe' };\r\n\r\n automapper\r\n .createMap(sourceKey, destinationKey)\r\n .withProfile('PascalCaseToCamelCase');\r\n\r\n var result = automapper.map(sourceKey, destinationKey, sourceObject);\r\n\r\n return result;\r\n }\r\n }\r\n\r\n export class ForMemberSamples {\r\n public static simpleMapFrom(): any {\r\n const sourceKey = 'simpleMapFrom';\r\n const destinationKey = '{}';\r\n\r\n const sourceObject = { fullName: 'John Doe' };\r\n\r\n automapper\r\n .createMap(sourceKey, destinationKey)\r\n .forMember('name', (opts: AutoMapperJs.IMemberConfigurationOptions) => opts.mapFrom('fullName'));\r\n\r\n var result = automapper.map(sourceKey, destinationKey, sourceObject);\r\n\r\n return result;\r\n }\r\n\r\n public static stackedForMemberCalls(): any {\r\n const sourceKey = 'stackedForMemberCalls';\r\n const destinationKey = 'Person';\r\n\r\n const sourceObject = { birthdayString: '2000-01-01T00:00:00.000Z' };\r\n\r\n automapper\r\n .createMap(sourceKey, destinationKey)\r\n .forMember('birthday', (opts: IMemberConfigurationOptions) => opts.mapFrom('birthdayString'))\r\n .forMember('birthday', (opts: IMemberConfigurationOptions) => new Date(opts.sourceObject[opts.sourcePropertyName]));\r\n\r\n var result = automapper.map(sourceKey, destinationKey, sourceObject);\r\n\r\n return result;\r\n }\r\n }\r\n}"]} \ No newline at end of file diff --git a/src/js/AsyncAutoMapper.js b/src/js/AsyncAutoMapper.js index d98f489..eae5942 100644 --- a/src/js/AsyncAutoMapper.js +++ b/src/js/AsyncAutoMapper.js @@ -3,11 +3,16 @@ /// /// /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var AutoMapperJs; (function (AutoMapperJs) { 'use strict'; @@ -146,7 +151,7 @@ var AutoMapperJs; if (childDestinationProperty) { var childDestinationObject = destinationObject[destinationProperty.name]; if (!childDestinationObject) { - // no child source object? create. + // no child source object? create. childDestinationObject = {}; } // transform child by recursively calling the transform function. diff --git a/src/js/AsyncAutoMapper.js.map b/src/js/AsyncAutoMapper.js.map index fa763d7..151c635 100644 --- a/src/js/AsyncAutoMap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,CAAC;oBACX,CAAC,CAAC,CAAC;oBACH,MAAM,CAAC;gBACX,KAAK,aAAA,6BAA6B,CAAC,wBAAwB;oBACvD,cAAc,CAAC,yCAAyC,CAAC,OAAO,EAAE,UAAC,MAAW;wBAC1E,EAAE,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC;4BAChC,OAAO,CAAC,yBAAyB,GAAG,MAAM,CAAC;wBAC/C,CAAC;wBAED,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;wBAClD,MAAM,CAAC;oBACX,CAAC,CAAC,CAAC;oBACH,MAAM,CAAC;gBACX;oBACI,qIAAqI;oBACrI,QAAQ,CAAC,OAAO,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) => 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,CAAC,CAAC;QAC5E,CAAC;QAEM,4CAAkB,GAAzB,UAA0B,OAAiB,EAAE,QAAyB;YAAtE,iBAKC;YAJG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;YACrB,OAAO,CAAC,eAAe,GAAG,UAAC,CAAW,EAAE,MAAW,EAAE,MAAW,EAAE,EAAg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AAA;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) => 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 diff --git a/src/js/AutoMapper.js b/src/js/AutoMapper.js index 4e03fe0..4908e9c 100644 --- a/src/js/AutoMapper.js +++ b/src/js/AutoMapper.js @@ -5,11 +5,16 @@ /// /// /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var AutoMapperJs; (function (AutoMapperJs) { 'use strict'; @@ -157,6 +162,7 @@ var AutoMapperJs; typeConverter = new tcClassOrFunc(); } catch (e) { + // Obviously, typeConverterClassOrFunction is not a TypeConverter class definition } if (typeConverter instanceof AutoMapperJs.TypeConverter) { configureSynchronousConverterFunction(typeConverter.convert); @@ -259,7 +265,7 @@ var AutoMapperJs; if (childDestinationProperty) { var childDestinationObject = destinationObject[destinationProperty.name]; if (!childDestinationObject) { - // no child source object? create. + // no child source object? create. childDestinationObject = {}; } // transform child by recursively calling the transform function. @@ -473,14 +479,14 @@ var AutoMapperJs; } } if (property.destinationPropertyName !== property.sourcePropertyName) { - // this is a mapFrom() registration. It is handled using the nested source properties, + // this is a mapFrom() registration. It is handled using the nested source properties, // we only are responsible for syncing the name properties. existing.name = property.name; existing.sourcePropertyName = property.sourcePropertyName; } return true; } - // existing is not (further) nested. this is always a mapFrom() situation. + // existing is not (further) nested. this is always a mapFrom() situation. // if (property.sourcePropertyName !== existing.sourcePropertyName) { var newDestination = this.getDestinationProperty(existing.destinationPropertyName, property); if (property.destinationPropertyName !== property.sourcePropertyName) { @@ -540,7 +546,7 @@ var AutoMapperJs; this.handleMapFromProperties(destination, existingDestination); return true; } - // the current destination is not (further) nested. a destination property registration has one of both: + // the current destination is not (further) nested. a destination property registration has one of both: // a) children or b) transformations. returning false will cause creating a duplicate source property entry instead. return false; } @@ -556,7 +562,7 @@ var AutoMapperJs; existingDestination.sourceMapping = destination.sourceMapping; } if (destination.ignore) { - // only set ignore when not yet set, once ignored is ignored forever. + // only set ignore when not yet set, once ignored is ignored forever. existingDestination.ignore = destination.ignore; } if (destination.conditionFunction) { diff --git a/src/js/AutoMapper.js.map b/src/js/AutoMapper.js.map index 0188b1a..8a671fa 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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AAC;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) => 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,cAA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AC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;oBACzB,MAAM,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) => 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 diff --git a/src/js/AutoMapperBase.js b/src/js/AutoMapperBase.js index 24d594b..d781d3c 100644 --- a/src/js/AutoMapperBase.js +++ b/src/js/AutoMapperBase.js @@ -205,8 +205,8 @@ var AutoMapperJs; }; AutoMapperBase.prototype.processMappedProperty = function (mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction) { if (propertyMapping.children && propertyMapping.children.length > 0) { - // always pass child source object, even if source object does not exist => - // constant transformations should always pass. + // always pass child source object, even if source object does not exist => + // constant transformations should always pass. var childSourceObject = sourceObject ? sourceObject[propertyMapping.name] : null; for (var _i = 0, _a = propertyMapping.children; _i < _a.length; _i++) { var child = _a[_i]; diff --git a/src/js/AutoMapperBase.js.map b/src/js/AutoMapperBase.js.map index c08083e..e091402 100644 --- a/src/js/AutoMapperBase.js.map +++ b/src/js/AutoMapperBase.js.map @@ -1 +1 @@ -{"version":3,"sources":["AutoMapperBase.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,yCAAyC;AACzC,4CAA4C;AAC5C,+CAA+C;AAE/C,IAAO,YAAY,CA+SlB;AA/SD,WAAO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E,iBAAiB,CAAC,CAAC;oBAC7F,MAAM,CAAC;iBACV;YACL,CAAC;YAED,IAAI,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;YAC9C,sCAAsC;YACtC,wEAAwE;YACxE,4EAA4E;YAC5E,IAAI;YAEJ,IAAI,oBAAoB,GAAG,IAAI,CAAC,gCAAgC,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;YACnG,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAEO,yDAAgC,GAAxC,UAAyC,YAAiB,EAAE,kBAA0B;YAClF,IAAI,0BAA0B,GAAG;gBAC7B,OAAO,EAAE,UAAC,kBAA0B;oBAChC,0GAA0G;gBAC9G,CAAC;gBACD,SAAS,EAAE,UAAC,SAA2C;oBACnD,4GAA4G;gBAChH,CAAC;gBACD,MAAM,EAAE;oBACJ,sGAAsG;gBAC1G,CAAC;gBACD,YAAY,EAAE,YAAY;gBAC1B,kBAAkB,EAAE,kBAAkB;gBACtC,yBAAyB,EAAE,YAAY,GAAG,YAAY,CAAC,kBAAkB,CAAC,GAAG,YAAY;aAC5F,CAAC;YACF,MAAM,CAAC,0BAA0B,CAAC;QACtC,CAAC;QACL,qBAAC;IAAD,CAhSA,AAgSC,IAAA;IAhSqB,2BAAc,iBAgSnC,CAAA;AACL,CAAC,EA/SM,YAAY,KAAZ,YAAY,QA+SlB","file":"AutoMapperBase.js","sourcesContent":["/// \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\r\n type stringOrClass = string | (new () => any);\r\n\r\n /**\r\n * AutoMapper implementation, for both creating maps and performing maps. Comparable usage and functionality to the original\r\n * .NET AutoMapper library is the pursuit of this implementation.\r\n */\r\n export abstract class AutoMapperBase {\r\n\r\n public abstract map(sourceKeyOrType: any, destinationKeyOrType: any, sourceObject: any): any\r\n\r\n public abstract createMap(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any)): any;\r\n\r\n protected getMapping(mappings: { [key: string]: IMapping }, sourceKey: stringOrClass, destinationKey: stringOrClass): IMapping {\r\n let srcKey = this.getKey(sourceKey);\r\n let dstKey = this.getKey(destinationKey);\r\n let mapping: IMapping = mappings[srcKey + dstKey];\r\n\r\n if (!mapping) {\r\n throw new Error(`Could not find map object with a source of ${srcKey} and a destination of ${dstKey}`);\r\n }\r\n return mapping;\r\n }\r\n\r\n protected getKey(keyStringOrType: string | (new () => any)): string {\r\n if (typeof keyStringOrType === 'string') {\r\n return keyStringOrType;\r\n } else {\r\n return AutoMapperHelper.getClassName(keyStringOrType);\r\n }\r\n }\r\n\r\n protected isArray(sourceObject: any): boolean {\r\n return sourceObject instanceof Array;\r\n }\r\n\r\n protected handleArray(mapping: IMapping, sourceArray: Array, itemFunc: (sourceObject: any, destinationObject: any) => void): Array {\r\n var arrayLength = sourceArray.length;\r\n var destinationArray = new Array(sourceArray.length);\r\n\r\n for (let index = 0; index < arrayLength; index++) {\r\n let sourceObject = sourceArray[index];\r\n let destinationObject: any;\r\n\r\n if (sourceObject === null || sourceObject === undefined) {\r\n destinationObject = sourceObject;\r\n } else {\r\n destinationObject = this.createDestinationObject(mapping.destinationTypeClass);\r\n itemFunc(sourceObject, destinationObject);\r\n }\r\n\r\n destinationArray[index] = destinationObject;\r\n }\r\n\r\n return destinationArray;\r\n }\r\n\r\n protected handleItem(mapping: IMapping, sourceObject: any, destinationObject: any, propertyFunction: (propertyName: string) => void): any {\r\n // var sourceProperties: string[] = [];\r\n var atLeastOnePropertyMapped = false;\r\n\r\n // handle mapped properties ...\r\n for (let property of mapping.properties) {\r\n // sourceProperties.push(property.name);\r\n\r\n atLeastOnePropertyMapped = true;\r\n propertyFunction(property.name);\r\n }\r\n\r\n // .. and, after that, handle unmapped properties\r\n for (let sourcePropertyName in sourceObject) {\r\n if (!sourceObject.hasOwnProperty(sourcePropertyName)) {\r\n continue;\r\n }\r\n\r\n if (destinationObject[sourcePropertyName]) {\r\n // ... but, if the destination property already exists, don't map again (probably a mapFrom situation).\r\n continue;\r\n }\r\n\r\n // if (sourceProperties.indexOf(sourcePropertyName) >= 0) {\r\n // continue;\r\n // }\r\n\r\n atLeastOnePropertyMapped = true;\r\n propertyFunction(sourcePropertyName);\r\n }\r\n\r\n // return null/undefined sourceObject if no properties added\r\n if (!atLeastOnePropertyMapped && (sourceObject === null || sourceObject === undefined)) {\r\n return sourceObject;\r\n }\r\n\r\n return destinationObject;\r\n }\r\n\r\n protected handleProperty(\r\n mapping: IMapping,\r\n sourceObject: any,\r\n sourcePropertyName: string,\r\n destinationObject: any,\r\n transformFunction: (destinationProperty: IDestinationProperty, memberOptions: IDMCO, callback?: IMemberCallback) => void,\r\n autoMappingCallbackFunction?: (dstPropVal: any) => void): void {\r\n\r\n // TODO Property mappings are already located before\r\n // TODO handleProperty seems only to be called when processing a mapped property.\r\n var propertyMappings = this.getPropertyMappings(mapping.properties, sourcePropertyName);\r\n if (propertyMappings.length > 0) {\r\n for (let propertyMapping of propertyMappings) {\r\n this.processMappedProperty(mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction);\r\n }\r\n } else {\r\n this.handlePropertyWithAutoMapping(mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction);\r\n }\r\n }\r\n\r\n protected setPropertyValue(mapping: IMapping, destinationProperty: IDestinationProperty, destinationObject: any, destinationPropertyValue: any): void {\r\n if (mapping.forAllMemberMappings.length > 0) {\r\n for (let forAllMemberMapping of mapping.forAllMemberMappings) {\r\n forAllMemberMapping(destinationObject, destinationProperty.name, destinationPropertyValue);\r\n }\r\n } else {\r\n destinationObject[destinationProperty.name] = destinationPropertyValue;\r\n }\r\n }\r\n\r\n protected setPropertyValueByName(mapping: IMapping, destinationObject: any, destinationProperty: string, destinationPropertyValue: any): void {\r\n if (mapping.forAllMemberMappings.length > 0) {\r\n for (let forAllMemberMapping of mapping.forAllMemberMappings) {\r\n forAllMemberMapping(destinationObject, destinationProperty, destinationPropertyValue);\r\n }\r\n } else {\r\n destinationObject[destinationProperty] = destinationPropertyValue;\r\n }\r\n }\r\n\r\n protected createDestinationObject(destinationType: new () => any): any {\r\n // create empty destination object.\r\n return destinationType\r\n ? new destinationType()\r\n : {};\r\n }\r\n\r\n protected shouldProcessDestination(destination: IDestinationProperty, sourceObject: any): boolean {\r\n if (destination.ignore) {\r\n // ignore ignored properties\r\n return false;\r\n }\r\n\r\n if (destination.conditionFunction) {\r\n // check for condition function, and, if there is ...\r\n if (destination.conditionFunction(sourceObject) === false) {\r\n // ... return when the condition is not met.\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n // protected throwMappingException(propertyMapping: IProperty, message: string): void {\r\n // throw new Error(`Cannot map '${propertyMapping.sourcePropertyName}' to '${propertyMapping.destinationPropertyName}' => ${message}`);\r\n // }\r\n\r\n private handlePropertyWithAutoMapping(mapping: IMapping,\r\n sourceObject: any,\r\n sourcePropertyName: string,\r\n destinationObject: any,\r\n autoMappingCallbackFunction?: (dstPropVal: any) => void): void {\r\n // no forMember mapping exists, auto map properties, except for the situation where ignoreAllNonExisting is specified.\r\n if (mapping.ignoreAllNonExisting) {\r\n return;\r\n }\r\n\r\n if (mapping.destinationTypeClass && Object.keys(destinationObject).indexOf(sourcePropertyName) < 0) {\r\n return;\r\n }\r\n\r\n let objectValue: any = null;\r\n let isNestedObject = false;\r\n\r\n if (typeof destinationObject[sourcePropertyName] === 'object' && destinationObject[sourcePropertyName]) {\r\n isNestedObject = (destinationObject[sourcePropertyName].constructor.name !== 'Object');\r\n\r\n if (isNestedObject) {\r\n this\r\n .createMap(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name)\r\n .convertToType(destinationObject[sourcePropertyName].constructor);\r\n\r\n objectValue = this.map(\r\n sourceObject[sourcePropertyName].constructor.name,\r\n destinationObject[sourcePropertyName].constructor.name,\r\n sourceObject[sourcePropertyName]\r\n );\r\n }\r\n }\r\n\r\n // use profile mapping when specified; otherwise, specify source property name as destination property name.\r\n let destinationPropertyName = this.getDestinationPropertyName(mapping.profile, sourcePropertyName);\r\n let destinationPropertyValue = this.getDestinationPropertyValue(sourceObject, sourcePropertyName, objectValue, isNestedObject);\r\n this.setPropertyValueByName(mapping, destinationObject, destinationPropertyName, destinationPropertyValue);\r\n if (autoMappingCallbackFunction) {\r\n autoMappingCallbackFunction(destinationPropertyValue);\r\n }\r\n }\r\n\r\n private getDestinationPropertyValue(sourceObject: any,\r\n sourcePropertyName: string,\r\n objectValue: any,\r\n isNestedObject: boolean): any {\r\n if (isNestedObject) {\r\n return objectValue;\r\n }\r\n\r\n return sourceObject ? sourceObject[sourcePropertyName] : null;\r\n\r\n }\r\n\r\n private getDestinationPropertyName(profile: IProfile, sourcePropertyName: string): string {\r\n if (!profile) {\r\n return sourcePropertyName;\r\n }\r\n\r\n // TODO BL no support yet for INamingConvention.splittingCharacter\r\n\r\n try {\r\n // First, split the source property name based on the splitting expression.\r\n // TODO BL Caching of RegExp splitting!\r\n var sourcePropertyNameParts = sourcePropertyName.split(profile.sourceMemberNamingConvention.splittingExpression);\r\n\r\n // NOTE BL For some reason, splitting by (my ;)) RegExp results in empty strings in the array; remove them.\r\n for (let index = sourcePropertyNameParts.length - 1; index >= 0; index--) {\r\n if (sourcePropertyNameParts[index] === '') {\r\n sourcePropertyNameParts.splice(index, 1);\r\n }\r\n }\r\n\r\n return profile.destinationMemberNamingConvention.transformPropertyName(sourcePropertyNameParts);\r\n } catch (error) {\r\n return sourcePropertyName;\r\n }\r\n }\r\n\r\n private getPropertyMappings(properties: ISourceProperty[], sourcePropertyName: string): ISourceProperty[] {\r\n var result = [];\r\n for (let property of properties) {\r\n if (property.name === sourcePropertyName) {\r\n result.push(property);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n private processMappedProperty(mapping: IMapping,\r\n propertyMapping: ISourceProperty,\r\n sourceObject: any,\r\n sourcePropertyName: string,\r\n transformFunction: (destinationProperty: IDestinationProperty, memberOptions: IDMCO) => void): void {\r\n if (propertyMapping.children && propertyMapping.children.length > 0) {\r\n // always pass child source object, even if source object does not exist => \r\n // constant transformations should always pass. \r\n var childSourceObject = sourceObject ? sourceObject[propertyMapping.name] : null;\r\n for (let child of propertyMapping.children) {\r\n this.processMappedProperty(mapping, child, childSourceObject, child.name, transformFunction);\r\n return;\r\n }\r\n }\r\n\r\n var destination = propertyMapping.destination;\r\n // if (!propertyMapping.destination) {\r\n // // it makes no sense to handle a property without destination(s).\r\n // this.throwMappingException(propertyMapping, 'no destination object');\r\n // }\r\n\r\n let configurationOptions = this.createMemberConfigurationOptions(sourceObject, sourcePropertyName);\r\n transformFunction(destination, configurationOptions);\r\n }\r\n\r\n private createMemberConfigurationOptions(sourceObject: any, sourcePropertyName: string): IMemberConfigurationOptions {\r\n var memberConfigurationOptions = {\r\n mapFrom: (sourcePropertyName: string): void => {\r\n // no action required, just here as a stub to prevent calling a non-existing 'opts.mapFrom(...)' function.\r\n },\r\n condition: (predicate: ((sourceObject: any) => boolean)): void => {\r\n // no action required, just here as a stub to prevent calling a non-existing 'opts.condition(...)' function.\r\n },\r\n ignore: (): void => {\r\n // no action required, just here as a stub to prevent calling a non-existing 'opts.ignore()' function.\r\n },\r\n sourceObject: sourceObject,\r\n sourcePropertyName: sourcePropertyName,\r\n intermediatePropertyValue: sourceObject ? sourceObject[sourcePropertyName] : sourceObject\r\n };\r\n return memberConfigurationOptions;\r\n }\r\n }\r\n}\r\n"]} \ No newline at end of file +{"version":3,"sources":["AutoMapperBase.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,yCAAyC;AACzC,4CAA4C;AAC5C,+CAA+C;AAE/C,IAAO,YAAY,CA+SlB;AA/SD,WAAO,YAAY;IACf,YAAY,CAAC;IASb;;;OAGG;IACH;QAAA;QAgSA,CAAC;QA1Ra,mCAAU,GAApB,U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eAAe,CAAC,WAAW,CAAC;YAC9C,sCAAsC;YACtC,wEAAwE;YACxE,4EAA4E;YAC5E,IAAI;YAEJ,IAAI,oBAAoB,GAAG,IAAI,CAAC,gCAAgC,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;YACnG,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;QACzD,CAAC;QAEO,yDAAgC,GAAxC,UAAyC,YAAiB,EAAE,kBAA0B;YAClF,IAAI,0BAA0B,GAAG;gBAC7B,OAAO,EAAE,UAAC,kBAA0B;oBAChC,0GAA0G;gBAC9G,CAAC;gBACD,SAAS,EAAE,UAAC,SAA2C;oBACnD,4GAA4G;gBAChH,CAAC;gBACD,MAAM,EAAE;oBACJ,sGAAsG;gBAC1G,CAAC;gBACD,YAAY,EAAE,YAAY;gBAC1B,kBAAkB,EAAE,kBAAkB;gBACtC,yBAAyB,EAAE,YAAY,GAAG,YAAY,CAAC,kBAAkB,CAAC,GAAG,YAAY;aAC5F,CAAC;YACF,MAAM,CAAC,0BAA0B,CAAC;QACtC,CAAC;QACL,qBAAC;IAAD,CAhSA,AAgSC,IAAA;IAhSqB,2BAAc,iBAgSnC,CAAA;AACL,CAAC,EA/SM,YAAY,KAAZ,YAAY,QA+SlB","file":"AutoMapperBase.js","sourcesContent":["/// \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\r\n type stringOrClass = string | (new () => any);\r\n\r\n /**\r\n * AutoMapper implementation, for both creating maps and performing maps. Comparable usage and functionality to the original\r\n * .NET AutoMapper library is the pursuit of this implementation.\r\n */\r\n export abstract class AutoMapperBase {\r\n\r\n public abstract map(sourceKeyOrType: any, destinationKeyOrType: any, sourceObject: any): any;\r\n\r\n public abstract createMap(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any)): any;\r\n\r\n protected getMapping(mappings: { [key: string]: IMapping }, sourceKey: stringOrClass, destinationKey: stringOrClass): IMapping {\r\n let srcKey = this.getKey(sourceKey);\r\n let dstKey = this.getKey(destinationKey);\r\n let mapping: IMapping = mappings[srcKey + dstKey];\r\n\r\n if (!mapping) {\r\n throw new Error(`Could not find map object with a source of ${srcKey} and a destination of ${dstKey}`);\r\n }\r\n return mapping;\r\n }\r\n\r\n protected getKey(keyStringOrType: string | (new () => any)): string {\r\n if (typeof keyStringOrType === 'string') {\r\n return keyStringOrType;\r\n } else {\r\n return AutoMapperHelper.getClassName(keyStringOrType);\r\n }\r\n }\r\n\r\n protected isArray(sourceObject: any): boolean {\r\n return sourceObject instanceof Array;\r\n }\r\n\r\n protected handleArray(mapping: IMapping, sourceArray: Array, itemFunc: (sourceObject: any, destinationObject: any) => void): Array {\r\n var arrayLength = sourceArray.length;\r\n var destinationArray = new Array(sourceArray.length);\r\n\r\n for (let index = 0; index < arrayLength; index++) {\r\n let sourceObject = sourceArray[index];\r\n let destinationObject: any;\r\n\r\n if (sourceObject === null || sourceObject === undefined) {\r\n destinationObject = sourceObject;\r\n } else {\r\n destinationObject = this.createDestinationObject(mapping.destinationTypeClass);\r\n itemFunc(sourceObject, destinationObject);\r\n }\r\n\r\n destinationArray[index] = destinationObject;\r\n }\r\n\r\n return destinationArray;\r\n }\r\n\r\n protected handleItem(mapping: IMapping, sourceObject: any, destinationObject: any, propertyFunction: (propertyName: string) => void): any {\r\n // var sourceProperties: string[] = [];\r\n var atLeastOnePropertyMapped = false;\r\n\r\n // handle mapped properties ...\r\n for (let property of mapping.properties) {\r\n // sourceProperties.push(property.name);\r\n\r\n atLeastOnePropertyMapped = true;\r\n propertyFunction(property.name);\r\n }\r\n\r\n // .. and, after that, handle unmapped properties\r\n for (let sourcePropertyName in sourceObject) {\r\n if (!sourceObject.hasOwnProperty(sourcePropertyName)) {\r\n continue;\r\n }\r\n\r\n if (destinationObject[sourcePropertyName]) {\r\n // ... but, if the destination property already exists, don't map again (probably a mapFrom situation).\r\n continue;\r\n }\r\n\r\n // if (sourceProperties.indexOf(sourcePropertyName) >= 0) {\r\n // continue;\r\n // }\r\n\r\n atLeastOnePropertyMapped = true;\r\n propertyFunction(sourcePropertyName);\r\n }\r\n\r\n // return null/undefined sourceObject if no properties added\r\n if (!atLeastOnePropertyMapped && (sourceObject === null || sourceObject === undefined)) {\r\n return sourceObject;\r\n }\r\n\r\n return destinationObject;\r\n }\r\n\r\n protected handleProperty(\r\n mapping: IMapping,\r\n sourceObject: any,\r\n sourcePropertyName: string,\r\n destinationObject: any,\r\n transformFunction: (destinationProperty: IDestinationProperty, memberOptions: IDMCO, callback?: IMemberCallback) => void,\r\n autoMappingCallbackFunction?: (dstPropVal: any) => void): void {\r\n\r\n // TODO Property mappings are already located before\r\n // TODO handleProperty seems only to be called when processing a mapped property.\r\n var propertyMappings = this.getPropertyMappings(mapping.properties, sourcePropertyName);\r\n if (propertyMappings.length > 0) {\r\n for (let propertyMapping of propertyMappings) {\r\n this.processMappedProperty(mapping, propertyMapping, sourceObject, sourcePropertyName, transformFunction);\r\n }\r\n } else {\r\n this.handlePropertyWithAutoMapping(mapping, sourceObject, sourcePropertyName, destinationObject, autoMappingCallbackFunction);\r\n }\r\n }\r\n\r\n protected setPropertyValue(mapping: IMapping, destinationProperty: IDestinationProperty, destinationObject: any, destinationPropertyValue: any): void {\r\n if (mapping.forAllMemberMappings.length > 0) {\r\n for (let forAllMemberMapping of mapping.forAllMemberMappings) {\r\n forAllMemberMapping(destinationObject, destinationProperty.name, destinationPropertyValue);\r\n }\r\n } else {\r\n destinationObject[destinationProperty.name] = destinationPropertyValue;\r\n }\r\n }\r\n\r\n protected setPropertyValueByName(mapping: IMapping, destinationObject: any, destinationProperty: string, destinationPropertyValue: any): void {\r\n if (mapping.forAllMemberMappings.length > 0) {\r\n for (let forAllMemberMapping of mapping.forAllMemberMappings) {\r\n forAllMemberMapping(destinationObject, destinationProperty, destinationPropertyValue);\r\n }\r\n } else {\r\n destinationObject[destinationProperty] = destinationPropertyValue;\r\n }\r\n }\r\n\r\n protected createDestinationObject(destinationType: new () => any): any {\r\n // create empty destination object.\r\n return destinationType\r\n ? new destinationType()\r\n : {};\r\n }\r\n\r\n protected shouldProcessDestination(destination: IDestinationProperty, sourceObject: any): boolean {\r\n if (destination.ignore) {\r\n // ignore ignored properties\r\n return false;\r\n }\r\n\r\n if (destination.conditionFunction) {\r\n // check for condition function, and, if there is ...\r\n if (destination.conditionFunction(sourceObject) === false) {\r\n // ... return when the condition is not met.\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n // protected throwMappingException(propertyMapping: IProperty, message: string): void {\r\n // throw new Error(`Cannot map '${propertyMapping.sourcePropertyName}' to '${propertyMapping.destinationPropertyName}' => ${message}`);\r\n // }\r\n\r\n private handlePropertyWithAutoMapping(mapping: IMapping,\r\n sourceObject: any,\r\n sourcePropertyName: string,\r\n destinationObject: any,\r\n autoMappingCallbackFunction?: (dstPropVal: any) => void): void {\r\n // no forMember mapping exists, auto map properties, except for the situation where ignoreAllNonExisting is specified.\r\n if (mapping.ignoreAllNonExisting) {\r\n return;\r\n }\r\n\r\n if (mapping.destinationTypeClass && Object.keys(destinationObject).indexOf(sourcePropertyName) < 0) {\r\n return;\r\n }\r\n\r\n let objectValue: any = null;\r\n let isNestedObject = false;\r\n\r\n if (typeof destinationObject[sourcePropertyName] === 'object' && destinationObject[sourcePropertyName]) {\r\n isNestedObject = (destinationObject[sourcePropertyName].constructor.name !== 'Object');\r\n\r\n if (isNestedObject) {\r\n this\r\n .createMap(sourceObject[sourcePropertyName].constructor.name, destinationObject[sourcePropertyName].constructor.name)\r\n .convertToType(destinationObject[sourcePropertyName].constructor);\r\n\r\n objectValue = this.map(\r\n sourceObject[sourcePropertyName].constructor.name,\r\n destinationObject[sourcePropertyName].constructor.name,\r\n sourceObject[sourcePropertyName]\r\n );\r\n }\r\n }\r\n\r\n // use profile mapping when specified; otherwise, specify source property name as destination property name.\r\n let destinationPropertyName = this.getDestinationPropertyName(mapping.profile, sourcePropertyName);\r\n let destinationPropertyValue = this.getDestinationPropertyValue(sourceObject, sourcePropertyName, objectValue, isNestedObject);\r\n this.setPropertyValueByName(mapping, destinationObject, destinationPropertyName, destinationPropertyValue);\r\n if (autoMappingCallbackFunction) {\r\n autoMappingCallbackFunction(destinationPropertyValue);\r\n }\r\n }\r\n\r\n private getDestinationPropertyValue(sourceObject: any,\r\n sourcePropertyName: string,\r\n objectValue: any,\r\n isNestedObject: boolean): any {\r\n if (isNestedObject) {\r\n return objectValue;\r\n }\r\n\r\n return sourceObject ? sourceObject[sourcePropertyName] : null;\r\n\r\n }\r\n\r\n private getDestinationPropertyName(profile: IProfile, sourcePropertyName: string): string {\r\n if (!profile) {\r\n return sourcePropertyName;\r\n }\r\n\r\n // TODO BL no support yet for INamingConvention.splittingCharacter\r\n\r\n try {\r\n // First, split the source property name based on the splitting expression.\r\n // TODO BL Caching of RegExp splitting!\r\n var sourcePropertyNameParts = sourcePropertyName.split(profile.sourceMemberNamingConvention.splittingExpression);\r\n\r\n // NOTE BL For some reason, splitting by (my ;)) RegExp results in empty strings in the array; remove them.\r\n for (let index = sourcePropertyNameParts.length - 1; index >= 0; index--) {\r\n if (sourcePropertyNameParts[index] === '') {\r\n sourcePropertyNameParts.splice(index, 1);\r\n }\r\n }\r\n\r\n return profile.destinationMemberNamingConvention.transformPropertyName(sourcePropertyNameParts);\r\n } catch (error) {\r\n return sourcePropertyName;\r\n }\r\n }\r\n\r\n private getPropertyMappings(properties: ISourceProperty[], sourcePropertyName: string): ISourceProperty[] {\r\n var result = [];\r\n for (let property of properties) {\r\n if (property.name === sourcePropertyName) {\r\n result.push(property);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n private processMappedProperty(mapping: IMapping,\r\n propertyMapping: ISourceProperty,\r\n sourceObject: any,\r\n sourcePropertyName: string,\r\n transformFunction: (destinationProperty: IDestinationProperty, memberOptions: IDMCO) => void): void {\r\n if (propertyMapping.children && propertyMapping.children.length > 0) {\r\n // always pass child source object, even if source object does not exist =>\r\n // constant transformations should always pass.\r\n var childSourceObject = sourceObject ? sourceObject[propertyMapping.name] : null;\r\n for (let child of propertyMapping.children) {\r\n this.processMappedProperty(mapping, child, childSourceObject, child.name, transformFunction);\r\n return;\r\n }\r\n }\r\n\r\n var destination = propertyMapping.destination;\r\n // if (!propertyMapping.destination) {\r\n // // it makes no sense to handle a property without destination(s).\r\n // this.throwMappingException(propertyMapping, 'no destination object');\r\n // }\r\n\r\n let configurationOptions = this.createMemberConfigurationOptions(sourceObject, sourcePropertyName);\r\n transformFunction(destination, configurationOptions);\r\n }\r\n\r\n private createMemberConfigurationOptions(sourceObject: any, sourcePropertyName: string): IMemberConfigurationOptions {\r\n var memberConfigurationOptions = {\r\n mapFrom: (sourcePropertyName: string): void => {\r\n // no action required, just here as a stub to prevent calling a non-existing 'opts.mapFrom(...)' function.\r\n },\r\n condition: (predicate: ((sourceObject: any) => boolean)): void => {\r\n // no action required, just here as a stub to prevent calling a non-existing 'opts.condition(...)' function.\r\n },\r\n ignore: (): void => {\r\n // no action required, just here as a stub to prevent calling a non-existing 'opts.ignore()' function.\r\n },\r\n sourceObject: sourceObject,\r\n sourcePropertyName: sourcePropertyName,\r\n intermediatePropertyValue: sourceObject ? sourceObject[sourcePropertyName] : sourceObject\r\n };\r\n return memberConfigurationOptions;\r\n }\r\n }\r\n}\r\n"]} \ No newline at end of file diff --git a/src/js/AutoMapperHelper.js b/src/js/AutoMapperHelper.js index fae511c..f0f2cfa 100644 --- a/src/js/AutoMapperHelper.js +++ b/src/js/AutoMapperHelper.js @@ -29,17 +29,18 @@ var AutoMapperJs; } if (classType.constructor.toString()) { var str = classType.constructor.toString(); + var regExpMatchArray = void 0; if (str.charAt(0) === '[') { // executed if the return of object.constructor.toString() is "[object objectClass]" - var arr = str.match(/\[\w+\s*(\w+)\]/); + regExpMatchArray = str.match(/\[\w+\s*(\w+)\]/); } else { // executed if the return of object.constructor.toString() is "function objectClass () {}" // (IE and Firefox) - var arr = str.match(/function\s*(\w+)/); + regExpMatchArray = str.match(/function\s*(\w+)/); } - if (arr && arr.length === 2) { - return arr[1]; + if (regExpMatchArray && regExpMatchArray.length === 2) { + return regExpMatchArray[1]; } } } @@ -217,6 +218,7 @@ var AutoMapperJs; func(configFuncOptions); } catch (exc) { + // do not handle by default. } return condition; }; diff --git a/src/js/AutoMapperHelper.js.map b/src/js/AutoMapperHelper.js.map index 562ca88..2fcd38c 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,CA6PlB;AA7PD,WAAO,YAAY;IACf,YAAY,CAAC;IAEb;;OAEG;IACH;QAAA;QAsPA,CAAC;QArPiB,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,CAAC,kBAAkB,CAAC,CAAC;oBACrD,EAAE,CAAC,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;wBACxC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;oBACzB,CAAC;gBACL,CAAC;gBAED,2DAA2D;gBAC3D,gCAAgC;gBAChC,EAAE,CAAC,CAAO,SAAS,CA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,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,CAAE;YAAA,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAEf,CAAC;YAED,MAAM,CAAC,SAAS,CAAC;QACrB,CAAC;QACL,uBAAC;IAAD,CAtPA,AAsPC,IAAA;IAtPY,6BAAgB,mBAsP5B,CAAA;AACL,CAAC,EA7PM,YAAY,KAAZ,YAAY,QA6PlB","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 var str = classType.constructor.toString();\r\n\r\n if (str.charAt(0) === '[') {\r\n // executed if the return of object.constructor.toString() is \"[object objectClass]\"\r\n var arr = 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 var arr = str.match(/function\\s*(\\w+)/);\r\n }\r\n\r\n if (arr && arr.length === 2) {\r\n return arr[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 }\r\n }\r\n}"]} \ No newline at end of file +{"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,q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lB","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 }\r\n }\r\n}"]} \ No newline at end of file diff --git a/src/js/AutoMapperValidator.js b/src/js/AutoMapperValidator.js index 6e2305c..99e9f91 100644 --- a/src/js/AutoMapperValidator.js +++ b/src/js/AutoMapperValidator.js @@ -77,7 +77,7 @@ var AutoMapperJs; } // /* tslint:disable */ // console.error(key); - // /* tslint:enable */ + // /* tslint:enable */ }; AutoMapperValidator.validatePropertyMapping = function (propertyMapping, member, srcObj, dstObj) { // awkward way of locating sourceMapping ;) ... @@ -91,7 +91,7 @@ var AutoMapperJs; if (!srcObj.hasOwnProperty(member)) { return "Source member '" + member + "' is configured, but does not exist on source type"; } - // an ignored source member should not exist on the destination type. + // an ignored source member should not exist on the destination type. if (destinationProperty.ignore) { if (dstObj.hasOwnProperty(member)) { return "Source member '" + member + "' is ignored, but does exist on destination type"; @@ -110,7 +110,7 @@ var AutoMapperJs; if (!dstObj.hasOwnProperty(destinationProperty.name)) { return "Destination member '" + destinationProperty.destinationPropertyName + "' is configured, but does not exist on destination type"; } - // an ignored destination member should not exist on the source type. + // an ignored destination member should not exist on the source type. if (destinationProperty.ignore) { if (srcObj.hasOwnProperty(member)) { return "Destination member '" + member + "' is ignored, but does exist on source type"; diff --git a/src/js/AutoMapperValidator.js.map b/src/js/AutoMapperValidator.js.map index c89738f..b893f35 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,WA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AA+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) => {\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,UA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Content":["/// \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 diff --git a/src/js/Profile.js.map b/src/js/Profile.js.map index 2c79114..4c661bc 100644 --- a/src/js/Profile.js.map +++ b/src/js/Profile.js.map @@ -1 +1 @@ -{"version":3,"sources":["Profile.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,mDAAmD;AAEnD,IAAO,YAAY,CA4ClB;AA5CD,WAAO,YAAY;IACf,YAAY,CAAC;IAEb;;OAEG;IACH;QAAA;QAqCA,CAAC;QA3BG;;;WAGG;QACI,2BAAS,GAAhB;YACI,aAAa;QACjB,CAAC;QAED;;;;;WAKG;QACO,2BAAS,GAAnB,UAAoB,SAAiB,EAAE,cAAsB;YACzD,IAAI,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAEtD,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBACpE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAClB,2DAA2D;oBAC3D,QAAQ,CAAC,KAAK,CAAC,GAAM,IAAI,CAAC,WAAW,UAAK,QAAQ,CAAC,KAAK,CAAG,CAAC;gBAChE,CAAC;YACL,CAAC;YAED,sFAAsF;YACtF,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;QACL,cAAC;IAAD,CArCA,AAqCC,IAAA;IArCY,oBAAO,UAqCnB,CAAA;AACL,CAAC,EA5CM,YAAY,KAAZ,YAAY,QA4ClB","file":"Profile.js","sourcesContent":["/// \r\n/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n /**\r\n * Converts source type to destination type instead of normal member mapping\r\n */\r\n export class Profile implements IProfile {\r\n /** Profile name */\r\n public profileName: string;\r\n\r\n /** Naming convention for source members */\r\n public sourceMemberNamingConvention: INamingConvention;\r\n\r\n /** Naming convention for destination members */\r\n public destinationMemberNamingConvention: INamingConvention;\r\n\r\n /**\r\n * Implement this method in a derived class and call the CreateMap method to associate that map with this profile.\r\n * Avoid calling the AutoMapper class / automapper instance from this method. \r\n */\r\n public configure(): void {\r\n // do nothing\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 protected createMap(sourceKey: string, destinationKey: string): ICreateMapFluentFunctions {\r\n var argsCopy = Array.prototype.slice.apply(arguments);\r\n\r\n for (var index = 0, length = argsCopy.length; index < length; index++) {\r\n if (argsCopy[index]) {\r\n // prefix sourceKey and destinationKey with 'profileName=>'\r\n argsCopy[index] = `${this.profileName}=>${argsCopy[index]}`;\r\n }\r\n }\r\n\r\n // pass through using arguments to keep createMap's currying support fully functional.\r\n return automapper.createMap.apply(automapper, argsCopy);\r\n }\r\n }\r\n}"]} \ No newline at end of file +{"version":3,"sources":["Profile.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,mDAAmD;AAEnD,IAAO,YAAY,CA4ClB;AA5CD,WAAO,YAAY;IACf,YAAY,CAAC;IAEb;;OAEG;IACH;QAAA;QAqCA,CAAC;QA3BG;;;WAGG;QACI,2BAAS,GAAhB;YACI,aAAa;QACjB,CAAC;QAED;;;;;WAKG;QACO,2BAAS,GAAnB,UAAoB,SAAiB,EAAE,cAAsB;YACzD,IAAI,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAEtD,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBACpE,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAClB,2DAA2D;oBAC3D,QAAQ,CAAC,KAAK,CAAC,GAAM,IAAI,CAAC,WAAW,UAAK,QAAQ,CAAC,KAAK,CAAG,CAAC;gBAChE,CAAC;YACL,CAAC;YAED,sFAAsF;YACtF,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;QACL,cAAC;IAAD,CArCA,AAqCC,IAAA;IArCY,oBAAO,UAqCnB,CAAA;AACL,CAAC,EA5CM,YAAY,KAAZ,YAAY,QA4ClB","file":"Profile.js","sourcesContent":["/// \r\n/// \r\n\r\nmodule AutoMapperJs {\r\n 'use strict';\r\n\r\n /**\r\n * Converts source type to destination type instead of normal member mapping\r\n */\r\n export class Profile implements IProfile {\r\n /** Profile name */\r\n public profileName: string;\r\n\r\n /** Naming convention for source members */\r\n public sourceMemberNamingConvention: INamingConvention;\r\n\r\n /** Naming convention for destination members */\r\n public destinationMemberNamingConvention: INamingConvention;\r\n\r\n /**\r\n * Implement this method in a derived class and call the CreateMap method to associate that map with this profile.\r\n * Avoid calling the AutoMapper class / automapper instance from this method.\r\n */\r\n public configure(): void {\r\n // do nothing\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 protected createMap(sourceKey: string, destinationKey: string): ICreateMapFluentFunctions {\r\n var argsCopy = Array.prototype.slice.apply(arguments);\r\n\r\n for (var index = 0, length = argsCopy.length; index < length; index++) {\r\n if (argsCopy[index]) {\r\n // prefix sourceKey and destinationKey with 'profileName=>'\r\n argsCopy[index] = `${this.profileName}=>${argsCopy[index]}`;\r\n }\r\n }\r\n\r\n // pass through using arguments to keep createMap's currying support fully functional.\r\n return automapper.createMap.apply(automapper, argsCopy);\r\n }\r\n }\r\n}"]} \ No newline at end of file diff --git a/src/js/naming-conventions/PascalCaseNamingConvention.js b/src/js/naming-conventions/PascalCaseNamingConvention.js index 40ea777..171427b 100644 --- a/src/js/naming-conventions/PascalCaseNamingConvention.js +++ b/src/js/naming-conventions/PascalCaseNamingConvention.js @@ -13,6 +13,9 @@ var AutoMapperJs; for (var index = 0, length = sourcePropertyNameParts.length; index < length; index++) { result += sourcePropertyNameParts[index].charAt(0).toUpperCase() + sourcePropertyNameParts[index].substr(1); + //if (index < (length - 1)) { + // this.separatorCharacter; + //} } return result; }; diff --git a/src/js/naming-conventions/PascalCaseNamingConvention.js.map b/src/js/naming-conventions/PascalCaseNamingConvention.js.map index 4a1d623..4125f80 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;YAKvD,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,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 diff --git a/src/ts/AutoMapperBase.ts b/src/ts/AutoMapperBase.ts index add0a35..1d1abcd 100644 --- a/src/ts/AutoMapperBase.ts +++ b/src/ts/AutoMapperBase.ts @@ -19,7 +19,7 @@ module AutoMapperJs { */ export abstract class AutoMapperBase { - public abstract map(sourceKeyOrType: any, destinationKeyOrType: any, sourceObject: any): any + public abstract map(sourceKeyOrType: any, destinationKeyOrType: any, sourceObject: any): any; public abstract createMap(sourceKeyOrType: string | (new () => any), destinationKeyOrType: string | (new () => any)): any; diff --git a/src/ts/AutoMapperHelper.ts b/src/ts/AutoMapperHelper.ts index e4d1c0e..9711e28 100644 --- a/src/ts/AutoMapperHelper.ts +++ b/src/ts/AutoMapperHelper.ts @@ -29,19 +29,20 @@ module AutoMapperJs { } if (classType.constructor.toString()) { - var str = classType.constructor.toString(); + let str = classType.constructor.toString(); + let regExpMatchArray: RegExpMatchArray; if (str.charAt(0) === '[') { // executed if the return of object.constructor.toString() is "[object objectClass]" - var arr = str.match(/\[\w+\s*(\w+)\]/); + regExpMatchArray = str.match(/\[\w+\s*(\w+)\]/); } else { // executed if the return of object.constructor.toString() is "function objectClass () {}" // (IE and Firefox) - var arr = str.match(/function\s*(\w+)/); + regExpMatchArray = str.match(/function\s*(\w+)/); } - if (arr && arr.length === 2) { - return arr[1]; + if (regExpMatchArray && regExpMatchArray.length === 2) { + return regExpMatchArray[1]; } } } diff --git a/test/tests/js/automapper-createmap-specs.js b/test/tests/js/automapper-createmap-specs.js index ca351f4..abf6028 100644 --- a/test/tests/js/automapper-createmap-specs.js +++ b/test/tests/js/automapper-createmap-specs.js @@ -1,10 +1,15 @@ /// /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// /// /// @@ -406,6 +411,7 @@ var AutoMapperJs; .convertUsing(function () { return {}; }); + //var objB = automapper.map(fromKey, toKey, objA); } catch (e) { // assert @@ -767,7 +773,7 @@ var AutoMapperJs; var CustomTypeConverterInstance = (function (_super) { __extends(CustomTypeConverterInstance, _super); function CustomTypeConverterInstance() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } CustomTypeConverterInstance.prototype.convert = function (resolutionContext) { return { propA: resolutionContext.sourceValue.propA + ' (convertUsing with a class instance)' }; @@ -777,7 +783,7 @@ var AutoMapperJs; var CustomTypeConverterDefinition = (function (_super) { __extends(CustomTypeConverterDefinition, _super); function CustomTypeConverterDefinition() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } CustomTypeConverterDefinition.prototype.convert = function (resolutionContext) { return { propA: resolutionContext.sourceValue.propA + ' (convertUsing with a class definition)' }; diff --git a/test/tests/js/automapper-initialize-specs.js b/test/tests/js/automapper-initialize-specs.js index 1002e0c..5baae2a 100644 --- a/test/tests/js/automapper-initialize-specs.js +++ b/test/tests/js/automapper-initialize-specs.js @@ -1,10 +1,15 @@ /// /// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); /// /// /// @@ -14,7 +19,7 @@ var AutoMapperJs; var PascalCaseToCamelCaseMappingProfile = (function (_super) { __extends(PascalCaseToCamelCaseMappingProfile, _super); function PascalCaseToCamelCaseMappingProfile() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.profileName = 'PascalCaseToCamelCase'; return _this; } @@ -71,7 +76,7 @@ var AutoMapperJs; var CamelCaseToPascalCaseMappingProfile = (function (_super) { __extends(CamelCaseToPascalCaseMappingProfile, _super); function CamelCaseToPascalCaseMappingProfile() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.profileName = 'CamelCaseToPascalCase'; return _this; } @@ -84,7 +89,7 @@ var AutoMapperJs; var ValidatedAgeMappingProfile = (function (_super) { __extends(ValidatedAgeMappingProfile, _super); function ValidatedAgeMappingProfile() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.profileName = 'ValidatedAgeMappingProfile'; return _this; } @@ -101,7 +106,7 @@ var AutoMapperJs; var ValidatedAgeMappingProfile2 = (function (_super) { __extends(ValidatedAgeMappingProfile2, _super); function ValidatedAgeMappingProfile2() { - var _this = _super.apply(this, arguments) || this; + var _this = _super !== null && _super.apply(this, arguments) || this; _this.profileName = 'ValidatedAgeMappingProfile2'; return _this; } @@ -125,7 +130,7 @@ var AutoMapperJs; var BeerBuyingYoungster = (function (_super) { __extends(BeerBuyingYoungster, _super); function BeerBuyingYoungster() { - return _super.apply(this, arguments) || this; + return _super !== null && _super.apply(this, arguments) || this; } return BeerBuyingYoungster; }(Person));