You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@nartc/automapper

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nartc/automapper - npm Package Compare versions

Comparing version

to
7.0.4

2

dist/automapper.cjs.development.js

@@ -709,3 +709,3 @@ 'use strict';

instanceStorage.resetCount(model, key);
instance[key] = undefined;
instance[key] = new metaResult();
return "continue";

@@ -712,0 +712,0 @@ }

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("reflect-metadata");var t,n=(t=require("lodash.set"))&&"object"==typeof t&&"default"in t?t.default:t;function r(){return(r=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t}).apply(this,arguments)}function e(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}function a(t,n){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,n){if(t){if("string"==typeof t)return o(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,void 0):void 0}}(t))||n&&t&&"number"==typeof t.length){r&&(t=r);var e=0;return function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}var i=function(){function t(){this.separatorCharacter="",this.splittingExpression=/(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/}return t.prototype.transformPropertyName=function(t){for(var n="",r=0,e=t.length;r<e;r++)n+=0===r?t[r].charAt(0).toLowerCase():t[r].charAt(0).toUpperCase(),n+=t[r].substr(1);return n},t}(),u=function(){function t(){this.separatorCharacter="_",this.splittingExpression=/_/}return t.prototype.transformPropertyName=function(t){return t.length<=1?t[0].toLowerCase()||"":t.map((function(t){return t.toLowerCase()})).join(this.separatorCharacter)},t}(),s=function(){function t(){this.separatorCharacter="",this.splittingExpression=/(^[A-Z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/}return t.prototype.transformPropertyName=function(t){for(var n="",r=0,e=t.length;r<e;r++)n+=t[r].charAt(0).toUpperCase()+t[r].substr(1);return n},t}(),c=i,f=function(){function t(){}return t.setShouldThrow=function(t){this.shouldThrow=t},t.handleError=function(t){if(this.shouldThrow)throw new Error(t);console.warn(t)},t}();f.shouldThrow=!0;var p=function(){function t(){this.storage=new WeakMap}var n=t.prototype;return n.set=function(t,n,r){this.setInternal(this.storage,t,n,r)},n.get=function(t,n){return this.getInternal(this.storage,t,n)},n.has=function(t,n){return this.hasInternal(this.storage,t,n)},n.getInternal=function(t,n,r){var e;return null==(e=t.get(n))?void 0:e.get(r)},n.hasInternal=function(t,n,r){var e;return(null==(e=t.get(n))?void 0:e.has(r))||!1},t}(),l=function(t){function n(){return t.call(this)||this}e(n,t);var r=n.prototype;return r.dispose=function(){this.storage=new WeakMap},r.setInternal=function(t,n,r,e){t.has(n)?this.hasInternal(t,n,r)||t.get(n).set(r,e):t.set(n,(new WeakMap).set(r,e))},n}(p),h=function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.setInternal=function(t,n,r,e){t.has(n)?this.hasInternal(t,n,r)||t.get(n).set(r,e):t.set(n,(new Map).set(r,e))},n}(p),v=function(t){function n(){return t.call(this)||this}return e(n,t),n}(l),g=new(function(){function t(){this._metadataMap=new Map}var n=t.prototype;return n.getMetadata=function(t){var n=this._metadataMap.get(t),r=(null==n?void 0:n.length)||0;if(!r){var e=Object.getPrototypeOf(t);return e?this.getMetadata(e):n}for(var o=[],a=function(){var t=n[r][0];if(o.some((function(n){return n[0]===t})))return"continue";o.push(n[r])};r--;)a();return o},n.getMetadataForKey=function(t,n){return this.getMetadata(t).find((function(t){return t[0]===n}))},n.addMetadata=function(t,n){for(var r,e=this._metadataMap.get(t)||[],o=Object.getPrototypeOf(t),i=o&&o.name&&this._metadataMap.get(o)||[],u=[].concat(i,e),s=a(u);!(r=s()).done;)if(n[0][0]===r.value[0])return;this._metadataMap.set(t,[].concat(u,n))},t}()),d=function(){function t(){this.profiles=new WeakMap}var n=t.prototype;return n.initialize=function(t){this.profiles.set(t,[])},n.add=function(t,n){var r=this.profiles.get(t);r.some((function(t){return t.profileName===n.profileName}))&&f.handleError(n.profileName+" already exists on this mapper instance"),r.push(n)},t}(),m=new(function(t){function n(){var n;return(n=t.call(this)||this).recursiveCounts=new WeakMap,n}e(n,t);var r=n.prototype;return r.getDepthAndCount=function(t,n){return[this.get(t,n),this.getCount(t,n)]},r.setCount=function(t,n,r){this.recursiveCounts.has(t)?this.recursiveCounts.get(t).set(n,r):this.setInternal(this.recursiveCounts,t,n,r)},r.resetCount=function(t,n){var r;null==(r=this.recursiveCounts.get(t))||r.set(n,0)},r.resetAllCount=function(t){var n;null==(n=this.recursiveCounts.get(t))||n.clear()},r.getCount=function(t,n){return this.getInternal(this.recursiveCounts,t,n)},r.dispose=function(){this.recursiveCounts=new WeakMap},n}(h));function y(t,n,r,e){switch(n){case"String":case"Number":case"Boolean":g.addMetadata(t,[[r,function(){return!1}]]);break;case"Date":g.addMetadata(t,[[r,function(){return Date}]]);break;case"Array":g.addMetadata(t,[[r,function(){return[]}]]);break;default:g.addMetadata(t,[[r,function(){return e}]])}}function A(t){return Array.isArray(t)?!t.length:!t||!Object.keys(t).length}function w(t){var n,r=typeof t,e=null==(n=t.constructor)?void 0:n.toString();return("object"===r||"function"===r)&&t.constructor&&(/^\s*function/.test(e)||/^\s*class/.test(e))&&e.includes(t.constructor.name)}function b(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return r.some((function(n){return t[0]===n}))}function M(t,n){function r(t,r){var e=r.split(".").filter(Boolean).reduce((function(t,n){return t&&t[n]}),t);return null!=e?e:n}for(var e=arguments.length,o=new Array(e>2?e-2:0),a=2;a<e;a++)o[a-2]=arguments[a];for(var i=r(t,o[0]),u=1,s=o.length;u<s;u++)i=r(null==i?t:i,o[u]);return i}function C(t,n){var r=t[0],e=t[1],o=n.split(".");if(o.length>1)return o.map((function(t){return C([r,e],t)})).join(".");var a=new e,i=new r,u=n.split(a.splittingExpression).filter(Boolean);return u.length?i.transformPropertyName(u):n}function S(t){var n=t.toString();if(n.includes("=>"))return n.substring(n.indexOf(".")+1).replace(/[?!]/g,"").replace(/(?:\s|;|{|}|\(|\)|)+/gm,"");var r=n.match(/function\s*\(\w+\)\s*{[\r\n\s]*return\s+\w+\.((\w+\.)*(\w+))/i);return r?r[1]:""}function O(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return[6,null,function(n){return M.apply(void 0,[n,t].concat(r))}]}function _(t,n){var r=g.getMetadata(t),e=n?Object.assign(new t,n):new t;if(A(r)||!r)return e;for(var o=r.length,a=function(){var a=r[o],i=a[0],u=e[i],s=(0,a[1])();if(!s)return e[i]=null!=u?u:void 0,"continue";if(Array.isArray(s))return e[i]=null!=u?u:s,"continue";if("Date"===s.prototype.constructor.name||"Moment"===s.prototype.constructor.name)return e[i]=null!=u?new s(u):new s,"continue";if(Array.isArray(u))return e[i]=u.map((function(t){return _(s,t)})),"continue";if(null==u&&null!=n)return e[i]=u,"continue";if(null!=u)return e[i]=_(s,u),"continue";var c=m.getDepthAndCount(t,i),f=c[0],p=c[1],l=void 0===p?0:p;return 0===f?(e[i]=new s,"continue"):f===l?(m.resetCount(t,i),e[i]=void 0,"continue"):(m.setCount(t,i,null!=l?l+1:1),void(e[i]=_(s,u)))};o--;)a();return m.resetAllCount(t),e}function j(t,n,r,e){void 0===e&&(e=!1);var o=r.get(n,t);if(!o&&!e)throw new Error("Mapping not found for source "+n.toString()+" and destination "+t.toString());return o}function x(t,n){for(var e=t[2],o=n[2],a=function(t,n){var a=o[t],i=a[0],u=Object.seal(r({},a[1])),s=e.find((function(t){return t[0]===i}));s?(s[0]=i,s[1]=u):e.push([i,u])},i=0,u=o.length;i<u;i++)a(i);t[4]=[n[0][0],n[0][1]]}function P(t){for(var n=_(t[0][0]),r=Object.getPrototypeOf(n),e=[],o=t[2],a=o.length,i=function(){var i,u=o[a][1],s=u.paths,c=u.transformation,f=s[0],p=s[1];return p||1===c.type||4===c.type?(i=p||S(c.mapFn[2]),!n.hasOwnProperty(i)&&!r.hasOwnProperty(i)||e.some((function(t){return t[0]===i}))?"continue":void e.push([i,Object.seal({paths:[i,f],transformation:{type:6,preCond:void 0,mapFn:O(t[1][0]?void 0:null,f)}})])):"continue"};a--;)i();return e}function k(t,n,r,e){var o=r[0],a=r[1],i=S(n);null==a&&(a=o,o=void 0);var u="";b(a,1,4)&&(u=S(a[1]));var s=Object.seal({paths:u?[i,u]:[i],transformation:{mapFn:a,type:a[0],preCond:o}}),c=t[2].find((function(t){return t[0]===i}));return null!=c?(c[1]=s,e):(t[2].push([i,s]),e)}function N(t,n,r,e){var o=g.getMetadataForKey(t,n)[1]();if(!o||Array.isArray(o))throw new Error("Metadata for "+n+" is a primitive or Array. Consider manual map this property");var a=e.get(r,o);if(!a)throw new Error("Mapping for "+n+" cannot be found. Consider manual map this property with MapWith");return a}function E(t,n){var e=t[0],o={skipUnmappedAssertion:n,beforeMap:void 0,afterMap:void 0};if(1===t.length)return[e,o];if(3===t.length)return[e,r({},o,t[2]),t[1]];var a=t[1];return"function"!=typeof a&&!w(a)||a.beforeMap||a.afterMap?[e,r({},o,a)]:[e,o,a]}function T(t,n,r,e,o,a){return b(t,7)?t[2](n,r):b(t,2)?t[2](n,a,r):b(t,1)?t[2](n,e):b(t,4)?t[2](n,o):b(t,5)?t[2](n):b(t,3)?t[2]():b(t,0)?a:T(t[2](n,r),n,r,e,o,a)}function U(t,e,o,a,i){void 0===i&&(i=!1);var u=e[0],s=u[0],c=u[1],f=e[1],p=f[0],l=f[1],h=f[2],v=e[2],g=e[3];t instanceof s||(t=_(s,t));var d=p?void 0:null,m=g[0],y=g[1],S=o.skipUnmappedAssertion,O=o.beforeMap,x=o.afterMap,P=[],k=_(c);i||(O?O(t,k,r({},e)):m&&m(t,k,r({},e)));for(var E=v.length;E--;){var D=v[E],F=D[0],G=D[1].transformation;if(P.push(F),!G.preCond||G.preCond[0](t)){var W=C([l,h],F);if(b(G.mapFn,6)){var R=G.mapFn[2](t);if(null==R){n(k,F,d);continue}if(R instanceof Date){n(k,F,new Date(R));continue}if(Array.isArray(R)){var z=R[0];if("object"!=typeof z){n(k,F,R.slice());continue}if(A(z)){n(k,F,[]);continue}var B=N(c,F,z.constructor,a);n(k,F,I(R,B,{skipUnmappedAssertion:o.skipUnmappedAssertion},a));continue}if(("object"==typeof R||"function"==typeof R)&&w(R)){var Z=j(M(k,null,F).constructor,R.constructor,a);n(k,F,U(R,Z,{skipUnmappedAssertion:o.skipUnmappedAssertion},a));continue}n(k,F,R)}else n(k,F,T(G.mapFn,t,W,k,a,d))}else{var L;n(k,F,null!=(L=G.preCond[1])?L:d)}}if(i||(x?x(t,k,r({},e)):y&&y(t,k,r({},e))),!S){var Y=Object.keys(k).filter((function(t){return!P.includes(t)}));if(Y.length>0)throw new Error("\nError mapping:\n- Source: "+s.toString()+"\n- Destination: "+c.toString()+"\n\nUnmapped properties:\n-------------------\n"+Y.join(",\n")+"\n")}return k}function I(t,n,e,o){var a=[],i=e.beforeMap,u=e.afterMap;i&&i(t,a,r({},n));for(var s=0,c=t.length;s<c;s++)a.push(U(t[s],n,{skipUnmappedAssertion:e.skipUnmappedAssertion},o,!0));return u&&u(t,a,r({},n)),a}var D=function(){function t(){}return t.explore=function(t,n){this.exploreInternal(t),this.exploreInternal(n)},t.exploreInternal=function(t){if(t.prototype&&!this.metadataTrackMap.has(t)){var n=t[this.AUTOMAPPER_METADATA_FACTORY];if(n){var r=n(),e=Object.entries(r),o=e.length;if(o){for(;o--;){var a=e[o],i=a[0],u=a[1];if(u){var s=u();y(t,s.prototype.constructor.name,i,s)}else y(t,"String",i)}this.metadataTrackMap.set(t,1)}}}},t}();D.metadataTrackMap=new Map,D.AUTOMAPPER_METADATA_FACTORY="__NARTC_AUTOMAPPER_METADATA_FACTORY";var F=function(){function t(){this._mappingStorage=new v,this._profileStorage=new d,this.setDefault()}var n,e=t.prototype;return e.withGlobalSettings=function(t){var n=t.useUndefined,r=t.skipUnmappedAssertion,e=t.sourceNamingConvention,o=t.destinationNamingConvention,a=t.throwError;return this.defaultGlobalSettings[0]=null!=n&&n,this.defaultGlobalSettings[1]=null!=r&&r,e&&(this.defaultGlobalSettings[2]=e),o&&(this.defaultGlobalSettings[3]=o),null!=a&&f.setShouldThrow(a),this},e.addProfile=function(t){return this._profileStorage.add(this,new t(this)),this},e.createMap=function(t,n,e){D.explore(t,n);var o=r({useUndefined:this.defaultGlobalSettings[0],sourceMemberNamingConvention:this.defaultGlobalSettings[2],destinationMemberNamingConvention:this.defaultGlobalSettings[3]},e);return function(t,n,r){var e;if(null==(e=n.includeBase)?void 0:e.length){var o=n.includeBase,a=j(o[1],o[0],r,!0);null!=a&&x(t,a)}var i={forMember:function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),o=1;o<r;o++)e[o-1]=arguments[o];return k(t,n,e,i)},beforeMap:function(n){return t[3][0]=n,i},afterMap:function(n){return t[3][1]=n,i},reverseMap:function(){return function(t){var n={forPath:function(r){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];return k(t,r,o,n)},beforeMap:function(r){return t[3][0]=r,n},afterMap:function(r){return t[3][1]=r,n}};return n}(function(t,n){var r=t[0],e=r[0],o=r[1],a=t[1],i=a[0],u=a[1],s=a[2],c=t[4],f=n.get(o,e);if(f)return f;var p=j((f=[[o,e],[i,s,u],P(t),[],(null==c?void 0:c.slice().reverse())||[]])[4][1],f[4][0],n,!0);return p&&x(f,p),n.set(o,e,f),f}(t,r))}};return i}(function(t,n,r,e){e.has(t,n)&&f.handleError("Mapping for source "+t.toString()+" and destination "+n.toString()+" already exists");var o=[[t,n],[r.useUndefined,r.sourceMemberNamingConvention,r.destinationMemberNamingConvention],[],[]];return function(t){var n=t[0],r=n[0],e=_(n[1]),o=_(r),i=Object.getPrototypeOf(o.constructor);i.name&&(o=Object.assign(o,_(i)));for(var u=Object.getPrototypeOf(o),s=function t(n,r,e){void 0===r&&(r="");for(var o=e||[],i=Object.getOwnPropertyNames(n),u=0,s=i.length;u<s;u++){var c=i[u],f=r+c;o.push(f);var p=n[c];if("object"==typeof p){var l=[p];Array.isArray(p)&&(l=p);for(var h,v=a(l);!(h=v()).done;)for(var g,d=a(t(h.value,f+"."));!(g=d()).done;)o.push(g.value)}}return o}(e),c=t[1],f=c[0],p=c[1],l=c[2],h=s.length;h--;){var v=s[h],g=C([p,l],v),d=g.split(".");if(!(d.length>1&&(!o.hasOwnProperty(d[0])||o[d[0]]&&w(o[d[0]])))){var m=f?void 0:null;if(!o.hasOwnProperty(g)&&!u.hasOwnProperty(g)&&"continue"===function(){var n=new p,r=g.split(n.splittingExpression).filter(Boolean).filter((function(t){return"."!==t})),e=r[0],a=r.slice(1);if(!a.length||!o.hasOwnProperty(e))return"continue";var i=[[e].concat(a.map((function(t){return n.transformPropertyName([t])}))).join(".")];return a.length>1&&i.push([e].concat(n.transformPropertyName(a)).join(".")),t[2].push([v,Object.seal({paths:[v],transformation:{type:6,preCond:void 0,mapFn:O.apply(void 0,[m].concat(i))}})]),"continue"}())continue;t[2].push([v,Object.seal({paths:[v,g],transformation:{type:6,preCond:void 0,mapFn:O(m,g)}})])}}}(o),e.set(t,n,o),o}(t,n,o,this._mappingStorage),o,this._mappingStorage)},e.map=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];var o=E(r,this.defaultGlobalSettings[1]),a=o[0],i=o[1],u=o[2],s=j(a,u||t.constructor,this._mappingStorage);return U(t,s,i,this._mappingStorage)},e.mapAsync=function(t){for(var n=this,r=arguments.length,e=new Array(r>1?r-1:0),o=1;o<r;o++)e[o-1]=arguments[o];var a=E(e,this.defaultGlobalSettings[1]),i=a[0],u=a[1],s=a[2],c=j(i,s||t.constructor,this._mappingStorage);return Promise.resolve().then((function(){return U(t,c,u,n._mappingStorage)}))},e.mapArray=function(t){if(!t.length)return[];for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];var o=E(r,this.defaultGlobalSettings[1]),a=o[0],i=o[1],u=o[2],s=j(a,u||t[0].constructor,this._mappingStorage);return I(t,s,i,this._mappingStorage)},e.mapArrayAsync=function(t){var n=this;if(!t.length)return Promise.resolve().then((function(){return[]}));for(var r=arguments.length,e=new Array(r>1?r-1:0),o=1;o<r;o++)e[o-1]=arguments[o];var a=E(e,this.defaultGlobalSettings[1]),i=a[0],u=a[1],s=a[2],c=j(i,s||t[0].constructor,this._mappingStorage);return Promise.resolve().then((function(){return I(t,c,u,n._mappingStorage)}))},e.getMapping=function(t,n){return this._mappingStorage.get(t,n)},e.dispose=function(){this.setDefault(),this._mappingStorage.dispose(),m.dispose()},e.setDefault=function(){this._profileStorage.initialize(this),this.defaultGlobalSettings=[!1,!1,c,c]},(n=[{key:"mappingStorage",get:function(){return this._mappingStorage}},{key:"profileStorage",get:function(){return this._profileStorage}}])&&function(t,n){for(var r=0;r<n.length;r++){var e=n[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}(t.prototype,n),t}(),G=new F;exports.AutoMap=function(t,n){return void 0===n&&(n=0),function(r,e){if(t)g.addMetadata(r.constructor,[[e,t]]),m.set(r.constructor,e,n);else{var o=Reflect.getMetadata("design:type",r,e);o&&y(r.constructor,o.prototype.constructor.name,e)}}},exports.AutoMapper=F,exports.CamelCaseNamingConvention=i,exports.Mapper=G,exports.PascalCaseNamingConvention=s,exports.ProfileBase=function(){this.profileName=this.constructor.name},exports.SnakeCaseNamingConvention=u,exports.condition=function(t,n){return[2,null,function(r,e){if(t(r)){for(var o=arguments.length,a=new Array(o>2?o-2:0),i=2;i<o;i++)a[i-2]=arguments[i];return M.apply(void 0,[r,e].concat(a))}return n||e}]},exports.convertUsing=function(t,n){return[5,null,function(r){var e;return e=n?n(r):r,t.convert(e)}]},exports.createMapMetadata=function(t,n){var r=Object.entries(n),e=r.length;if(e)for(;e--;){var o,a=r[e],i=a[1];y(t,(null==(o=i.prototype)?void 0:o.constructor.name)||i.constructor.name,a[0],i)}},exports.defaultNamingConvention=c,exports.fromValue=function(t){return[3,null,function(){return t}]},exports.ignore=function(){return[0,null,function(){}]},exports.mapDefer=function(t){return[8,null,t]},exports.mapFrom=function(t){return[1,t,function(n,r){return"resolve"in t?t.resolve(n,r):t(n)}]},exports.mapWith=function(t,n,r){return[4,n,function(e,o){var a=n(e);return Array.isArray(a)?A(a[0])?[]:I(a,j(t,(null==r?void 0:r())||a[0].constructor,o),{skipUnmappedAssertion:!0},o):A(a)?null:w(a)?U(a,j(t,(null==r?void 0:r())||a.constructor,o),{skipUnmappedAssertion:!0},o):(console.warn("MapWith was invoked with a primitive. No mapping was executed"),null)}]},exports.nullSubstitution=function(t){return[7,null,function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),o=1;o<r;o++)e[o-1]=arguments[o];return M.apply(void 0,[n,t].concat(e))}]},exports.preCondition=function(t,n){return[function(n){return t(n)},n]};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("reflect-metadata");var t,n=(t=require("lodash.set"))&&"object"==typeof t&&"default"in t?t.default:t;function r(){return(r=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t}).apply(this,arguments)}function e(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}function a(t,n){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=function(t,n){if(t){if("string"==typeof t)return o(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,void 0):void 0}}(t))||n&&t&&"number"==typeof t.length){r&&(t=r);var e=0;return function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=t[Symbol.iterator]()).next.bind(r)}var i=function(){function t(){this.separatorCharacter="",this.splittingExpression=/(^[a-z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/}return t.prototype.transformPropertyName=function(t){for(var n="",r=0,e=t.length;r<e;r++)n+=0===r?t[r].charAt(0).toLowerCase():t[r].charAt(0).toUpperCase(),n+=t[r].substr(1);return n},t}(),u=function(){function t(){this.separatorCharacter="_",this.splittingExpression=/_/}return t.prototype.transformPropertyName=function(t){return t.length<=1?t[0].toLowerCase()||"":t.map((function(t){return t.toLowerCase()})).join(this.separatorCharacter)},t}(),s=function(){function t(){this.separatorCharacter="",this.splittingExpression=/(^[A-Z]+(?=$|[A-Z]{1}[a-z0-9]+)|[A-Z]?[a-z0-9]+)/}return t.prototype.transformPropertyName=function(t){for(var n="",r=0,e=t.length;r<e;r++)n+=t[r].charAt(0).toUpperCase()+t[r].substr(1);return n},t}(),c=i,f=function(){function t(){}return t.setShouldThrow=function(t){this.shouldThrow=t},t.handleError=function(t){if(this.shouldThrow)throw new Error(t);console.warn(t)},t}();f.shouldThrow=!0;var p=function(){function t(){this.storage=new WeakMap}var n=t.prototype;return n.set=function(t,n,r){this.setInternal(this.storage,t,n,r)},n.get=function(t,n){return this.getInternal(this.storage,t,n)},n.has=function(t,n){return this.hasInternal(this.storage,t,n)},n.getInternal=function(t,n,r){var e;return null==(e=t.get(n))?void 0:e.get(r)},n.hasInternal=function(t,n,r){var e;return(null==(e=t.get(n))?void 0:e.has(r))||!1},t}(),l=function(t){function n(){return t.call(this)||this}e(n,t);var r=n.prototype;return r.dispose=function(){this.storage=new WeakMap},r.setInternal=function(t,n,r,e){t.has(n)?this.hasInternal(t,n,r)||t.get(n).set(r,e):t.set(n,(new WeakMap).set(r,e))},n}(p),h=function(t){function n(){return t.call(this)||this}return e(n,t),n.prototype.setInternal=function(t,n,r,e){t.has(n)?this.hasInternal(t,n,r)||t.get(n).set(r,e):t.set(n,(new Map).set(r,e))},n}(p),v=function(t){function n(){return t.call(this)||this}return e(n,t),n}(l),g=new(function(){function t(){this._metadataMap=new Map}var n=t.prototype;return n.getMetadata=function(t){var n=this._metadataMap.get(t),r=(null==n?void 0:n.length)||0;if(!r){var e=Object.getPrototypeOf(t);return e?this.getMetadata(e):n}for(var o=[],a=function(){var t=n[r][0];if(o.some((function(n){return n[0]===t})))return"continue";o.push(n[r])};r--;)a();return o},n.getMetadataForKey=function(t,n){return this.getMetadata(t).find((function(t){return t[0]===n}))},n.addMetadata=function(t,n){for(var r,e=this._metadataMap.get(t)||[],o=Object.getPrototypeOf(t),i=o&&o.name&&this._metadataMap.get(o)||[],u=[].concat(i,e),s=a(u);!(r=s()).done;)if(n[0][0]===r.value[0])return;this._metadataMap.set(t,[].concat(u,n))},t}()),d=function(){function t(){this.profiles=new WeakMap}var n=t.prototype;return n.initialize=function(t){this.profiles.set(t,[])},n.add=function(t,n){var r=this.profiles.get(t);r.some((function(t){return t.profileName===n.profileName}))&&f.handleError(n.profileName+" already exists on this mapper instance"),r.push(n)},t}(),m=new(function(t){function n(){var n;return(n=t.call(this)||this).recursiveCounts=new WeakMap,n}e(n,t);var r=n.prototype;return r.getDepthAndCount=function(t,n){return[this.get(t,n),this.getCount(t,n)]},r.setCount=function(t,n,r){this.recursiveCounts.has(t)?this.recursiveCounts.get(t).set(n,r):this.setInternal(this.recursiveCounts,t,n,r)},r.resetCount=function(t,n){var r;null==(r=this.recursiveCounts.get(t))||r.set(n,0)},r.resetAllCount=function(t){var n;null==(n=this.recursiveCounts.get(t))||n.clear()},r.getCount=function(t,n){return this.getInternal(this.recursiveCounts,t,n)},r.dispose=function(){this.recursiveCounts=new WeakMap},n}(h));function y(t,n,r,e){switch(n){case"String":case"Number":case"Boolean":g.addMetadata(t,[[r,function(){return!1}]]);break;case"Date":g.addMetadata(t,[[r,function(){return Date}]]);break;case"Array":g.addMetadata(t,[[r,function(){return[]}]]);break;default:g.addMetadata(t,[[r,function(){return e}]])}}function A(t){return Array.isArray(t)?!t.length:!t||!Object.keys(t).length}function w(t){var n,r=typeof t,e=null==(n=t.constructor)?void 0:n.toString();return("object"===r||"function"===r)&&t.constructor&&(/^\s*function/.test(e)||/^\s*class/.test(e))&&e.includes(t.constructor.name)}function b(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return r.some((function(n){return t[0]===n}))}function M(t,n){function r(t,r){var e=r.split(".").filter(Boolean).reduce((function(t,n){return t&&t[n]}),t);return null!=e?e:n}for(var e=arguments.length,o=new Array(e>2?e-2:0),a=2;a<e;a++)o[a-2]=arguments[a];for(var i=r(t,o[0]),u=1,s=o.length;u<s;u++)i=r(null==i?t:i,o[u]);return i}function C(t,n){var r=t[0],e=t[1],o=n.split(".");if(o.length>1)return o.map((function(t){return C([r,e],t)})).join(".");var a=new e,i=new r,u=n.split(a.splittingExpression).filter(Boolean);return u.length?i.transformPropertyName(u):n}function S(t){var n=t.toString();if(n.includes("=>"))return n.substring(n.indexOf(".")+1).replace(/[?!]/g,"").replace(/(?:\s|;|{|}|\(|\)|)+/gm,"");var r=n.match(/function\s*\(\w+\)\s*{[\r\n\s]*return\s+\w+\.((\w+\.)*(\w+))/i);return r?r[1]:""}function O(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return[6,null,function(n){return M.apply(void 0,[n,t].concat(r))}]}function _(t,n){var r=g.getMetadata(t),e=n?Object.assign(new t,n):new t;if(A(r)||!r)return e;for(var o=r.length,a=function(){var a=r[o],i=a[0],u=e[i],s=(0,a[1])();if(!s)return e[i]=null!=u?u:void 0,"continue";if(Array.isArray(s))return e[i]=null!=u?u:s,"continue";if("Date"===s.prototype.constructor.name||"Moment"===s.prototype.constructor.name)return e[i]=null!=u?new s(u):new s,"continue";if(Array.isArray(u))return e[i]=u.map((function(t){return _(s,t)})),"continue";if(null==u&&null!=n)return e[i]=u,"continue";if(null!=u)return e[i]=_(s,u),"continue";var c=m.getDepthAndCount(t,i),f=c[0],p=c[1],l=void 0===p?0:p;return 0===f?(e[i]=new s,"continue"):f===l?(m.resetCount(t,i),e[i]=new s,"continue"):(m.setCount(t,i,null!=l?l+1:1),void(e[i]=_(s,u)))};o--;)a();return m.resetAllCount(t),e}function j(t,n,r,e){void 0===e&&(e=!1);var o=r.get(n,t);if(!o&&!e)throw new Error("Mapping not found for source "+n.toString()+" and destination "+t.toString());return o}function x(t,n){for(var e=t[2],o=n[2],a=function(t,n){var a=o[t],i=a[0],u=Object.seal(r({},a[1])),s=e.find((function(t){return t[0]===i}));s?(s[0]=i,s[1]=u):e.push([i,u])},i=0,u=o.length;i<u;i++)a(i);t[4]=[n[0][0],n[0][1]]}function P(t){for(var n=_(t[0][0]),r=Object.getPrototypeOf(n),e=[],o=t[2],a=o.length,i=function(){var i,u=o[a][1],s=u.paths,c=u.transformation,f=s[0],p=s[1];return p||1===c.type||4===c.type?(i=p||S(c.mapFn[2]),!n.hasOwnProperty(i)&&!r.hasOwnProperty(i)||e.some((function(t){return t[0]===i}))?"continue":void e.push([i,Object.seal({paths:[i,f],transformation:{type:6,preCond:void 0,mapFn:O(t[1][0]?void 0:null,f)}})])):"continue"};a--;)i();return e}function k(t,n,r,e){var o=r[0],a=r[1],i=S(n);null==a&&(a=o,o=void 0);var u="";b(a,1,4)&&(u=S(a[1]));var s=Object.seal({paths:u?[i,u]:[i],transformation:{mapFn:a,type:a[0],preCond:o}}),c=t[2].find((function(t){return t[0]===i}));return null!=c?(c[1]=s,e):(t[2].push([i,s]),e)}function N(t,n,r,e){var o=g.getMetadataForKey(t,n)[1]();if(!o||Array.isArray(o))throw new Error("Metadata for "+n+" is a primitive or Array. Consider manual map this property");var a=e.get(r,o);if(!a)throw new Error("Mapping for "+n+" cannot be found. Consider manual map this property with MapWith");return a}function E(t,n){var e=t[0],o={skipUnmappedAssertion:n,beforeMap:void 0,afterMap:void 0};if(1===t.length)return[e,o];if(3===t.length)return[e,r({},o,t[2]),t[1]];var a=t[1];return"function"!=typeof a&&!w(a)||a.beforeMap||a.afterMap?[e,r({},o,a)]:[e,o,a]}function T(t,n,r,e,o,a){return b(t,7)?t[2](n,r):b(t,2)?t[2](n,a,r):b(t,1)?t[2](n,e):b(t,4)?t[2](n,o):b(t,5)?t[2](n):b(t,3)?t[2]():b(t,0)?a:T(t[2](n,r),n,r,e,o,a)}function U(t,e,o,a,i){void 0===i&&(i=!1);var u=e[0],s=u[0],c=u[1],f=e[1],p=f[0],l=f[1],h=f[2],v=e[2],g=e[3];t instanceof s||(t=_(s,t));var d=p?void 0:null,m=g[0],y=g[1],S=o.skipUnmappedAssertion,O=o.beforeMap,x=o.afterMap,P=[],k=_(c);i||(O?O(t,k,r({},e)):m&&m(t,k,r({},e)));for(var E=v.length;E--;){var D=v[E],F=D[0],G=D[1].transformation;if(P.push(F),!G.preCond||G.preCond[0](t)){var W=C([l,h],F);if(b(G.mapFn,6)){var R=G.mapFn[2](t);if(null==R){n(k,F,d);continue}if(R instanceof Date){n(k,F,new Date(R));continue}if(Array.isArray(R)){var z=R[0];if("object"!=typeof z){n(k,F,R.slice());continue}if(A(z)){n(k,F,[]);continue}var B=N(c,F,z.constructor,a);n(k,F,I(R,B,{skipUnmappedAssertion:o.skipUnmappedAssertion},a));continue}if(("object"==typeof R||"function"==typeof R)&&w(R)){var Z=j(M(k,null,F).constructor,R.constructor,a);n(k,F,U(R,Z,{skipUnmappedAssertion:o.skipUnmappedAssertion},a));continue}n(k,F,R)}else n(k,F,T(G.mapFn,t,W,k,a,d))}else{var L;n(k,F,null!=(L=G.preCond[1])?L:d)}}if(i||(x?x(t,k,r({},e)):y&&y(t,k,r({},e))),!S){var Y=Object.keys(k).filter((function(t){return!P.includes(t)}));if(Y.length>0)throw new Error("\nError mapping:\n- Source: "+s.toString()+"\n- Destination: "+c.toString()+"\n\nUnmapped properties:\n-------------------\n"+Y.join(",\n")+"\n")}return k}function I(t,n,e,o){var a=[],i=e.beforeMap,u=e.afterMap;i&&i(t,a,r({},n));for(var s=0,c=t.length;s<c;s++)a.push(U(t[s],n,{skipUnmappedAssertion:e.skipUnmappedAssertion},o,!0));return u&&u(t,a,r({},n)),a}var D=function(){function t(){}return t.explore=function(t,n){this.exploreInternal(t),this.exploreInternal(n)},t.exploreInternal=function(t){if(t.prototype&&!this.metadataTrackMap.has(t)){var n=t[this.AUTOMAPPER_METADATA_FACTORY];if(n){var r=n(),e=Object.entries(r),o=e.length;if(o){for(;o--;){var a=e[o],i=a[0],u=a[1];if(u){var s=u();y(t,s.prototype.constructor.name,i,s)}else y(t,"String",i)}this.metadataTrackMap.set(t,1)}}}},t}();D.metadataTrackMap=new Map,D.AUTOMAPPER_METADATA_FACTORY="__NARTC_AUTOMAPPER_METADATA_FACTORY";var F=function(){function t(){this._mappingStorage=new v,this._profileStorage=new d,this.setDefault()}var n,e=t.prototype;return e.withGlobalSettings=function(t){var n=t.useUndefined,r=t.skipUnmappedAssertion,e=t.sourceNamingConvention,o=t.destinationNamingConvention,a=t.throwError;return this.defaultGlobalSettings[0]=null!=n&&n,this.defaultGlobalSettings[1]=null!=r&&r,e&&(this.defaultGlobalSettings[2]=e),o&&(this.defaultGlobalSettings[3]=o),null!=a&&f.setShouldThrow(a),this},e.addProfile=function(t){return this._profileStorage.add(this,new t(this)),this},e.createMap=function(t,n,e){D.explore(t,n);var o=r({useUndefined:this.defaultGlobalSettings[0],sourceMemberNamingConvention:this.defaultGlobalSettings[2],destinationMemberNamingConvention:this.defaultGlobalSettings[3]},e);return function(t,n,r){var e;if(null==(e=n.includeBase)?void 0:e.length){var o=n.includeBase,a=j(o[1],o[0],r,!0);null!=a&&x(t,a)}var i={forMember:function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),o=1;o<r;o++)e[o-1]=arguments[o];return k(t,n,e,i)},beforeMap:function(n){return t[3][0]=n,i},afterMap:function(n){return t[3][1]=n,i},reverseMap:function(){return function(t){var n={forPath:function(r){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];return k(t,r,o,n)},beforeMap:function(r){return t[3][0]=r,n},afterMap:function(r){return t[3][1]=r,n}};return n}(function(t,n){var r=t[0],e=r[0],o=r[1],a=t[1],i=a[0],u=a[1],s=a[2],c=t[4],f=n.get(o,e);if(f)return f;var p=j((f=[[o,e],[i,s,u],P(t),[],(null==c?void 0:c.slice().reverse())||[]])[4][1],f[4][0],n,!0);return p&&x(f,p),n.set(o,e,f),f}(t,r))}};return i}(function(t,n,r,e){e.has(t,n)&&f.handleError("Mapping for source "+t.toString()+" and destination "+n.toString()+" already exists");var o=[[t,n],[r.useUndefined,r.sourceMemberNamingConvention,r.destinationMemberNamingConvention],[],[]];return function(t){var n=t[0],r=n[0],e=_(n[1]),o=_(r),i=Object.getPrototypeOf(o.constructor);i.name&&(o=Object.assign(o,_(i)));for(var u=Object.getPrototypeOf(o),s=function t(n,r,e){void 0===r&&(r="");for(var o=e||[],i=Object.getOwnPropertyNames(n),u=0,s=i.length;u<s;u++){var c=i[u],f=r+c;o.push(f);var p=n[c];if("object"==typeof p){var l=[p];Array.isArray(p)&&(l=p);for(var h,v=a(l);!(h=v()).done;)for(var g,d=a(t(h.value,f+"."));!(g=d()).done;)o.push(g.value)}}return o}(e),c=t[1],f=c[0],p=c[1],l=c[2],h=s.length;h--;){var v=s[h],g=C([p,l],v),d=g.split(".");if(!(d.length>1&&(!o.hasOwnProperty(d[0])||o[d[0]]&&w(o[d[0]])))){var m=f?void 0:null;if(!o.hasOwnProperty(g)&&!u.hasOwnProperty(g)&&"continue"===function(){var n=new p,r=g.split(n.splittingExpression).filter(Boolean).filter((function(t){return"."!==t})),e=r[0],a=r.slice(1);if(!a.length||!o.hasOwnProperty(e))return"continue";var i=[[e].concat(a.map((function(t){return n.transformPropertyName([t])}))).join(".")];return a.length>1&&i.push([e].concat(n.transformPropertyName(a)).join(".")),t[2].push([v,Object.seal({paths:[v],transformation:{type:6,preCond:void 0,mapFn:O.apply(void 0,[m].concat(i))}})]),"continue"}())continue;t[2].push([v,Object.seal({paths:[v,g],transformation:{type:6,preCond:void 0,mapFn:O(m,g)}})])}}}(o),e.set(t,n,o),o}(t,n,o,this._mappingStorage),o,this._mappingStorage)},e.map=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];var o=E(r,this.defaultGlobalSettings[1]),a=o[0],i=o[1],u=o[2],s=j(a,u||t.constructor,this._mappingStorage);return U(t,s,i,this._mappingStorage)},e.mapAsync=function(t){for(var n=this,r=arguments.length,e=new Array(r>1?r-1:0),o=1;o<r;o++)e[o-1]=arguments[o];var a=E(e,this.defaultGlobalSettings[1]),i=a[0],u=a[1],s=a[2],c=j(i,s||t.constructor,this._mappingStorage);return Promise.resolve().then((function(){return U(t,c,u,n._mappingStorage)}))},e.mapArray=function(t){if(!t.length)return[];for(var n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];var o=E(r,this.defaultGlobalSettings[1]),a=o[0],i=o[1],u=o[2],s=j(a,u||t[0].constructor,this._mappingStorage);return I(t,s,i,this._mappingStorage)},e.mapArrayAsync=function(t){var n=this;if(!t.length)return Promise.resolve().then((function(){return[]}));for(var r=arguments.length,e=new Array(r>1?r-1:0),o=1;o<r;o++)e[o-1]=arguments[o];var a=E(e,this.defaultGlobalSettings[1]),i=a[0],u=a[1],s=a[2],c=j(i,s||t[0].constructor,this._mappingStorage);return Promise.resolve().then((function(){return I(t,c,u,n._mappingStorage)}))},e.getMapping=function(t,n){return this._mappingStorage.get(t,n)},e.dispose=function(){this.setDefault(),this._mappingStorage.dispose(),m.dispose()},e.setDefault=function(){this._profileStorage.initialize(this),this.defaultGlobalSettings=[!1,!1,c,c]},(n=[{key:"mappingStorage",get:function(){return this._mappingStorage}},{key:"profileStorage",get:function(){return this._profileStorage}}])&&function(t,n){for(var r=0;r<n.length;r++){var e=n[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}(t.prototype,n),t}(),G=new F;exports.AutoMap=function(t,n){return void 0===n&&(n=0),function(r,e){if(t)g.addMetadata(r.constructor,[[e,t]]),m.set(r.constructor,e,n);else{var o=Reflect.getMetadata("design:type",r,e);o&&y(r.constructor,o.prototype.constructor.name,e)}}},exports.AutoMapper=F,exports.CamelCaseNamingConvention=i,exports.Mapper=G,exports.PascalCaseNamingConvention=s,exports.ProfileBase=function(){this.profileName=this.constructor.name},exports.SnakeCaseNamingConvention=u,exports.condition=function(t,n){return[2,null,function(r,e){if(t(r)){for(var o=arguments.length,a=new Array(o>2?o-2:0),i=2;i<o;i++)a[i-2]=arguments[i];return M.apply(void 0,[r,e].concat(a))}return n||e}]},exports.convertUsing=function(t,n){return[5,null,function(r){var e;return e=n?n(r):r,t.convert(e)}]},exports.createMapMetadata=function(t,n){var r=Object.entries(n),e=r.length;if(e)for(;e--;){var o,a=r[e],i=a[1];y(t,(null==(o=i.prototype)?void 0:o.constructor.name)||i.constructor.name,a[0],i)}},exports.defaultNamingConvention=c,exports.fromValue=function(t){return[3,null,function(){return t}]},exports.ignore=function(){return[0,null,function(){}]},exports.mapDefer=function(t){return[8,null,t]},exports.mapFrom=function(t){return[1,t,function(n,r){return"resolve"in t?t.resolve(n,r):t(n)}]},exports.mapWith=function(t,n,r){return[4,n,function(e,o){var a=n(e);return Array.isArray(a)?A(a[0])?[]:I(a,j(t,(null==r?void 0:r())||a[0].constructor,o),{skipUnmappedAssertion:!0},o):A(a)?null:w(a)?U(a,j(t,(null==r?void 0:r())||a.constructor,o),{skipUnmappedAssertion:!0},o):(console.warn("MapWith was invoked with a primitive. No mapping was executed"),null)}]},exports.nullSubstitution=function(t){return[7,null,function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),o=1;o<r;o++)e[o-1]=arguments[o];return M.apply(void 0,[n,t].concat(e))}]},exports.preCondition=function(t,n){return[function(n){return t(n)},n]};
//# sourceMappingURL=automapper.cjs.production.min.js.map

@@ -703,3 +703,3 @@ import 'reflect-metadata';

instanceStorage.resetCount(model, key);
instance[key] = undefined;
instance[key] = new metaResult();
return "continue";

@@ -706,0 +706,0 @@ }

{
"name": "@nartc/automapper",
"version": "7.0.3",
"version": "7.0.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": "Chau Tran",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet