Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@automapper/classes

Package Overview
Dependencies
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automapper/classes - npm Package Compare versions

Comparing version 3.0.11 to 3.1.0

src/lib/utils/explore-metadata.util.d.ts

8

experimental/transformer-plugin/package.json
{
"name": "@automapper/classes/experimental/transformer-plugin",
"version": "3.0.11",
"version": "3.1.0",
"sideEffects": false,

@@ -29,6 +29,6 @@ "publishConfig": {

"peerDependencies": {
"@automapper/classes": "3.0.11",
"@automapper/core": "3.0.11",
"@automapper/types": "3.0.11"
"@automapper/classes": "3.1.0",
"@automapper/core": "3.1.0",
"@automapper/types": "3.1.0"
}
}
{
"name": "@automapper/classes",
"version": "3.0.11",
"version": "3.1.0",
"peerDependencies": {
"reflect-metadata": "~0.1.13",
"@automapper/core": "3.0.11",
"@automapper/types": "3.0.11"
"@automapper/core": "3.1.0",
"@automapper/types": "3.1.0"
},

@@ -9,0 +9,0 @@ "sideEffects": false,

export * from './lib/classes';
export * from './lib/decorators';
export * from './lib/constants';
export * from './lib/types';

@@ -7,2 +7,3 @@ "use strict";

tslib_1.__exportStar(require("./lib/constants"), exports);
tslib_1.__exportStar(require("./lib/types"), exports);
//# sourceMappingURL=index.js.map

@@ -6,3 +6,2 @@ "use strict";

require("reflect-metadata");
const constants_1 = require("./constants");
const storages_1 = require("./storages");

@@ -22,2 +21,5 @@ const utils_1 = require("./utils");

return {
instantiate(model, obj) {
return utils_1.instantiate(instanceStorage, metadataStorage, model, obj);
},
initializeMapping(source, destination, options) {

@@ -31,3 +33,3 @@ // If a mapping already exists, handle error and return;

// with information/metadata about source and destination
exploreMetadata(metadataStorage, instanceStorage, source, destination);
utils_1.exploreMetadata(metadataStorage, instanceStorage, source, destination);
/**

@@ -43,4 +45,4 @@ * Instantiate a new instance of Destination/Source along with any nested constructible

*/
const [destinationInstance, destinationNestedConstructible] = utils_1.instantiate(instanceStorage, metadataStorage, destination);
const [sourceInstance, sourceNestedConstructible] = utils_1.instantiate(instanceStorage, metadataStorage, source);
const [destinationInstance, destinationNestedConstructible,] = this.instantiate(destination);
const [sourceInstance, sourceNestedConstructible] = this.instantiate(source);
// Get a hold of the prototype of Source (in case of inheritance with extends keyword)

@@ -54,3 +56,3 @@ const sourceProto = Object.getPrototypeOf(source);

// before looping through the properties on the Destination
prePropertiesLoop: prePropertiesLoop(source, metadataStorage, instanceStorage, sourceInstance, sourceNestedConstructible),
prePropertiesLoop: utils_1.prePropertiesLoop(source, metadataStorage, instanceStorage, sourceInstance, sourceNestedConstructible),
isMetadataNullAtKey: (key) => {

@@ -60,5 +62,5 @@ return metadataStorage.getMetadataForKey(destination, key) === null;

// classes plugin needs to check for sourcePaths on the prototype of Source
isMultipartSourcePathsInSource: (multipartSourcePaths, sourceObj) => isMultipartSourcePathsInSource(multipartSourcePaths, sourceObj),
isMultipartSourcePathsInSource: (multipartSourcePaths, sourceObj) => utils_1.isMultipartSourcePathsInSource(multipartSourcePaths, sourceObj),
// classes plugin needs to check for the destinationPath (sourcePath) on the prototype of Source
isDestinationPathOnSource: isDestinationPathOnSource(sourceProto),
isDestinationPathOnSource: utils_1.isDestinationPathOnSource(sourceProto),
});

@@ -82,4 +84,4 @@ },

// Prepare the sourceInstance/destinationInstance with plain object sourceObj and destinationObj
const [sourceInstance] = utils_1.instantiate(instanceStorage, metadataStorage, source, sourceObj);
const [destinationInstance] = utils_1.instantiate(instanceStorage, metadataStorage, destination, destinationObj);
const [sourceInstance] = this.instantiate(source, sourceObj);
const [destinationInstance] = this.instantiate(destination, destinationObj);
return [sourceInstance, destinationInstance];

@@ -94,58 +96,2 @@ },

};
function exploreMetadata(metadataStorage, instanceStorage, ...models) {
// Loop through each models passed in
for (const model of models) {
// if metadataStorage hasn't had metadata of the model
if (!metadataStorage.has(model)) {
// get the metadata from Reflection and AUTOMAPPER_METADATA_FACTORY then populate metadataStorage and instanceStorage
let metadataList = Reflect.getMetadata(constants_1.AUTOMAP_PROPERTIES_METADATA_KEY, model) || [];
if (model[constants_1.AUTOMAPPER_METADATA_FACTORY_KEY]) {
metadataList = metadataList.concat(model[constants_1.AUTOMAPPER_METADATA_FACTORY_KEY]() || []);
}
// if no metadata, skip
if (!core_1.isDefined(metadataList))
continue;
// loop through metadata list
for (const [propertyKey, { typeFn, depth }] of metadataList) {
metadataStorage.addMetadata(model, [propertyKey, typeFn]);
if (depth != null) {
instanceStorage.setDepth(model, propertyKey, depth);
}
}
}
}
}
function prePropertiesLoop(source, metadataStorage, instanceStorage, sourceInstance, sourceNestedConstructible) {
return (mapping) => {
// get prototype of the constructor
const sourceProtoConstructor = Object.getPrototypeOf(source.constructor);
// if it has name, then it's not anonymous Function
if (sourceProtoConstructor.name) {
// try to instantiate the proto constructor
const [sourceProtoInstance, sourceProtoNestedConstructible] = utils_1.instantiate(instanceStorage, metadataStorage, sourceProtoConstructor);
// merge the instance of the proto with the sourceInstance
sourceInstance = Object.assign(sourceInstance, sourceProtoInstance);
// update the sourceInstance on the mapping
mapping[0 /* mappings */][0] = sourceInstance;
if (sourceProtoNestedConstructible.length) {
// update the nested constructible
sourceNestedConstructible = sourceNestedConstructible.concat(sourceProtoNestedConstructible);
}
}
};
}
function isMultipartSourcePathsInSource(dottedSourcePaths, sourceInstance) {
return !(dottedSourcePaths.length > 1 &&
(!sourceInstance.hasOwnProperty(dottedSourcePaths[0]) ||
(sourceInstance[dottedSourcePaths[0]] &&
// eslint-disable-next-line @typescript-eslint/ban-types
utils_1.isClass(sourceInstance[dottedSourcePaths[0]]))));
}
function isDestinationPathOnSource(sourceProto) {
return (sourceObj, sourcePath) => {
return !(!sourceObj.hasOwnProperty(sourcePath) &&
!sourceProto.hasOwnProperty(sourcePath) &&
!Object.getPrototypeOf(sourceObj).hasOwnProperty(sourcePath));
};
}
//# sourceMappingURL=classes.js.map

@@ -1,4 +0,4 @@

import { Dictionary, TransformerMetadataFactory } from '@automapper/types';
import type { Dictionary, TransformerMetadataFactory } from '@automapper/types';
export interface Constructible<TModel extends Dictionary<TModel> = any> extends TransformerMetadataFactory<TModel> {
new (...args: unknown[]): TModel;
}
export * from './instantiate.util';
export * from './is-class.util';
export * from './pre-properties-loop.util';
export * from './is-multipart-source-paths-in-source.util';
export * from './is-destination-path-on-source.util';
export * from './explore-metadata.util';

@@ -6,2 +6,6 @@ "use strict";

tslib_1.__exportStar(require("./is-class.util"), exports);
tslib_1.__exportStar(require("./pre-properties-loop.util"), exports);
tslib_1.__exportStar(require("./is-multipart-source-paths-in-source.util"), exports);
tslib_1.__exportStar(require("./is-destination-path-on-source.util"), exports);
tslib_1.__exportStar(require("./explore-metadata.util"), exports);
//# sourceMappingURL=index.js.map

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc