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 8.0.0-beta.13 to 8.0.0-beta.14

lib/automap.d.ts

143

index.cjs.js

@@ -12,9 +12,72 @@ 'use strict';

function AutoMapStandalone(...constructors) {
return target => {
Reflect.defineMetadata(AUTOMAP_STANDALONE_METADATA_KEY, constructors, target);
};
function getMetadataList(model) {
var _a;
let metadataList = (((_a = model.constructor) === null || _a === void 0 ? void 0 : _a.prototype) ? Reflect.getMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, model.constructor.prototype) || [] : []).concat(Reflect.getMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, model) || []);
const metadataFactoryFn = model[AUTOMAPPER_METADATA_FACTORY_KEY];
if (metadataFactoryFn) {
metadataList = metadataList.concat(metadataFactoryFn() || []);
}
return metadataList.reduce((result, [propertyKey, {
type,
depth,
isGetterOnly
}]) => {
// can be [type] or type
const meta = type();
const isArray = Array.isArray(meta);
const trueMeta = isArray ? meta[0] : meta;
if (!core.isDateConstructor(trueMeta) && !core.isPrimitiveConstructor(trueMeta)) {
result[1].push(trueMeta);
}
result[0].push([propertyKey, {
type: () => trueMeta,
depth,
isGetterOnly,
isArray
}]);
return result;
}, [[], []]);
}
function getStandaloneConstructors(model) {
return Reflect.getMetadata(AUTOMAP_STANDALONE_METADATA_KEY, model) || [];
function classes({
destinationConstructor = (_, destinationIdentifier) => new destinationIdentifier(),
applyMetadata,
postMap,
preMap
} = core.defaultSerializerOptions) {
return mapper => ({
destinationConstructor,
mapper,
get applyMetadata() {
return applyMetadata(this);
},
retrieveMetadata(...identifiers) {
const metadataMap = new Map();
for (let i = 0, length = identifiers.length; i < length; i++) {
const identifier = identifiers[i];
const [metadataList, nestedConstructors] = getMetadataList(identifier);
metadataMap.set(identifier, metadataList);
if (nestedConstructors.length) {
const nestedConstructorsMetadataMap = this.retrieveMetadata(...nestedConstructors);
nestedConstructorsMetadataMap.forEach((nestedConstructorMetadataList, nestedConstructor) => {
metadataMap.set(nestedConstructor, nestedConstructorMetadataList);
});
}
}
return metadataMap;
},
preMap: preMap,
postMap: postMap
});
}

@@ -38,4 +101,4 @@

console.warn(`
Cannot determine type metadata of "${String(propertyKey)}" on ${target}.
${String(propertyKey)} metadata has been skipped.
Cannot determine type metadata of "${String(propertyKey)}" on ${target.constructor}.
"${String(propertyKey)}" metadata has been skipped.
Manually provide the "type" metadata to prevent unexpected behavior.

@@ -78,64 +141,2 @@ `);

function getMetadataList(model) {
var _a;
let metadataList = (((_a = model.constructor) === null || _a === void 0 ? void 0 : _a.prototype) ? Reflect.getMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, model.constructor.prototype) || [] : []).concat(Reflect.getMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, model) || []);
const metadataFactoryFn = model[AUTOMAPPER_METADATA_FACTORY_KEY];
if (metadataFactoryFn) {
metadataList = metadataList.concat(metadataFactoryFn() || []);
}
return metadataList.map(([propertyKey, {
type,
depth,
isGetterOnly
}]) => {
const meta = type();
const isArray = Array.isArray(meta);
return [propertyKey, {
type: isArray ? () => meta[0] : () => meta,
depth,
isGetterOnly,
isArray
}];
});
}
function classes({
destinationConstructor = (_, destinationIdentifier) => new destinationIdentifier(),
applyMetadata,
postMap,
preMap
} = core.defaultSerializerOptions) {
return mapper => ({
destinationConstructor,
mapper,
get applyMetadata() {
return applyMetadata(this);
},
retrieveMetadata(...identifiers) {
const metadataMap = new Map();
for (let i = 0, length = identifiers.length; i < length; i++) {
const identifier = identifiers[i];
metadataMap.set(identifier, getMetadataList(identifier));
const standaloneConstructors = getStandaloneConstructors(identifier);
for (let j = 0, standaloneConstructorsLength = standaloneConstructors.length; j < standaloneConstructorsLength; j++) {
const standaloneIdentifier = standaloneConstructors[j];
metadataMap.set(standaloneIdentifier, getMetadataList(standaloneIdentifier));
}
}
return metadataMap;
},
preMap: preMap,
postMap: postMap
});
}
exports.AUTOMAPPER_METADATA_FACTORY_KEY = AUTOMAPPER_METADATA_FACTORY_KEY;

@@ -145,5 +146,3 @@ exports.AUTOMAP_PROPERTIES_METADATA_KEY = AUTOMAP_PROPERTIES_METADATA_KEY;

exports.AutoMap = AutoMap;
exports.AutoMapStandalone = AutoMapStandalone;
exports.classes = classes;
exports.getMetadataList = getMetadataList;
exports.getStandaloneConstructors = getStandaloneConstructors;
export * from './lib/classes';
export * from './lib/decorators';
export * from './lib/automap';
export * from './lib/keys';
export * from './lib/get-metadata-list';

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

import { defaultSerializerOptions } from '@automapper/core';
import { isDateConstructor, isPrimitiveConstructor, defaultSerializerOptions } from '@automapper/core';
import 'reflect-metadata';

@@ -8,9 +8,72 @@

function AutoMapStandalone(...constructors) {
return target => {
Reflect.defineMetadata(AUTOMAP_STANDALONE_METADATA_KEY, constructors, target);
};
function getMetadataList(model) {
var _a;
let metadataList = (((_a = model.constructor) === null || _a === void 0 ? void 0 : _a.prototype) ? Reflect.getMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, model.constructor.prototype) || [] : []).concat(Reflect.getMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, model) || []);
const metadataFactoryFn = model[AUTOMAPPER_METADATA_FACTORY_KEY];
if (metadataFactoryFn) {
metadataList = metadataList.concat(metadataFactoryFn() || []);
}
return metadataList.reduce((result, [propertyKey, {
type,
depth,
isGetterOnly
}]) => {
// can be [type] or type
const meta = type();
const isArray = Array.isArray(meta);
const trueMeta = isArray ? meta[0] : meta;
if (!isDateConstructor(trueMeta) && !isPrimitiveConstructor(trueMeta)) {
result[1].push(trueMeta);
}
result[0].push([propertyKey, {
type: () => trueMeta,
depth,
isGetterOnly,
isArray
}]);
return result;
}, [[], []]);
}
function getStandaloneConstructors(model) {
return Reflect.getMetadata(AUTOMAP_STANDALONE_METADATA_KEY, model) || [];
function classes({
destinationConstructor = (_, destinationIdentifier) => new destinationIdentifier(),
applyMetadata,
postMap,
preMap
} = defaultSerializerOptions) {
return mapper => ({
destinationConstructor,
mapper,
get applyMetadata() {
return applyMetadata(this);
},
retrieveMetadata(...identifiers) {
const metadataMap = new Map();
for (let i = 0, length = identifiers.length; i < length; i++) {
const identifier = identifiers[i];
const [metadataList, nestedConstructors] = getMetadataList(identifier);
metadataMap.set(identifier, metadataList);
if (nestedConstructors.length) {
const nestedConstructorsMetadataMap = this.retrieveMetadata(...nestedConstructors);
nestedConstructorsMetadataMap.forEach((nestedConstructorMetadataList, nestedConstructor) => {
metadataMap.set(nestedConstructor, nestedConstructorMetadataList);
});
}
}
return metadataMap;
},
preMap: preMap,
postMap: postMap
});
}

@@ -34,4 +97,4 @@

console.warn(`
Cannot determine type metadata of "${String(propertyKey)}" on ${target}.
${String(propertyKey)} metadata has been skipped.
Cannot determine type metadata of "${String(propertyKey)}" on ${target.constructor}.
"${String(propertyKey)}" metadata has been skipped.
Manually provide the "type" metadata to prevent unexpected behavior.

@@ -74,64 +137,2 @@ `);

function getMetadataList(model) {
var _a;
let metadataList = (((_a = model.constructor) === null || _a === void 0 ? void 0 : _a.prototype) ? Reflect.getMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, model.constructor.prototype) || [] : []).concat(Reflect.getMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, model) || []);
const metadataFactoryFn = model[AUTOMAPPER_METADATA_FACTORY_KEY];
if (metadataFactoryFn) {
metadataList = metadataList.concat(metadataFactoryFn() || []);
}
return metadataList.map(([propertyKey, {
type,
depth,
isGetterOnly
}]) => {
const meta = type();
const isArray = Array.isArray(meta);
return [propertyKey, {
type: isArray ? () => meta[0] : () => meta,
depth,
isGetterOnly,
isArray
}];
});
}
function classes({
destinationConstructor = (_, destinationIdentifier) => new destinationIdentifier(),
applyMetadata,
postMap,
preMap
} = defaultSerializerOptions) {
return mapper => ({
destinationConstructor,
mapper,
get applyMetadata() {
return applyMetadata(this);
},
retrieveMetadata(...identifiers) {
const metadataMap = new Map();
for (let i = 0, length = identifiers.length; i < length; i++) {
const identifier = identifiers[i];
metadataMap.set(identifier, getMetadataList(identifier));
const standaloneConstructors = getStandaloneConstructors(identifier);
for (let j = 0, standaloneConstructorsLength = standaloneConstructors.length; j < standaloneConstructorsLength; j++) {
const standaloneIdentifier = standaloneConstructors[j];
metadataMap.set(standaloneIdentifier, getMetadataList(standaloneIdentifier));
}
}
return metadataMap;
},
preMap: preMap,
postMap: postMap
});
}
export { AUTOMAPPER_METADATA_FACTORY_KEY, AUTOMAP_PROPERTIES_METADATA_KEY, AUTOMAP_STANDALONE_METADATA_KEY, AutoMap, AutoMapStandalone, classes, getMetadataList, getStandaloneConstructors };
export { AUTOMAPPER_METADATA_FACTORY_KEY, AUTOMAP_PROPERTIES_METADATA_KEY, AUTOMAP_STANDALONE_METADATA_KEY, AutoMap, classes, getMetadataList };

@@ -1,3 +0,3 @@

import { Constructor, MappingStrategyInitializer, MappingStrategyInitializerOptions } from '@automapper/core';
import type { Constructor, MappingStrategyInitializer, MappingStrategyInitializerOptions } from '@automapper/core';
import 'reflect-metadata';
export declare function classes({ destinationConstructor, applyMetadata, postMap, preMap, }?: MappingStrategyInitializerOptions): MappingStrategyInitializer<Constructor>;
import type { Constructor } from '@automapper/core';
import 'reflect-metadata';
export declare function getMetadataList(model: Constructor): [
string,
{
type: () => Constructor;
isArray: boolean;
depth: number;
isGetterOnly?: boolean;
}
][];
metadataList: [
string,
{
type: () => Constructor;
isArray: boolean;
depth: number;
isGetterOnly?: boolean;
}
][],
nestedConstructor: Constructor[]
];

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

try {
const parentClassMetadataList = classes.getMetadataList(parentClass);
const [parentClassMetadataList] = classes.getMetadataList(parentClass);

@@ -17,3 +17,3 @@ if (!parentClassMetadataList.length) {

const existingMetadataList = classes.getMetadataList(targetClass);
const [existingMetadataList] = classes.getMetadataList(targetClass);
Reflect.defineMetadata(classes.AUTOMAP_PROPERTIES_METADATA_KEY, [...existingMetadataList, ...parentClassMetadataList.filter(([propertyKey]) => isPropertyInherited(propertyKey))], targetClass);

@@ -20,0 +20,0 @@ } catch (e) {

@@ -6,3 +6,3 @@ import { getMetadataList, AUTOMAP_PROPERTIES_METADATA_KEY } from '@automapper/classes';

try {
const parentClassMetadataList = getMetadataList(parentClass);
const [parentClassMetadataList] = getMetadataList(parentClass);

@@ -13,3 +13,3 @@ if (!parentClassMetadataList.length) {

const existingMetadataList = getMetadataList(targetClass);
const [existingMetadataList] = getMetadataList(targetClass);
Reflect.defineMetadata(AUTOMAP_PROPERTIES_METADATA_KEY, [...existingMetadataList, ...parentClassMetadataList.filter(([propertyKey]) => isPropertyInherited(propertyKey))], targetClass);

@@ -16,0 +16,0 @@ } catch (e) {

{
"name": "@automapper/classes/mapped-types",
"version": "8.0.0-beta.13",
"version": "8.0.0-beta.14",
"exports": {

@@ -34,5 +34,5 @@ "import": "./index.esm.js",

"peerDependencies": {
"@automapper/core": "8.0.0-beta.13",
"@automapper/classes": "8.0.0-beta.13"
"@automapper/core": "8.0.0-beta.14",
"@automapper/classes": "8.0.0-beta.14"
}
}
{
"name": "@automapper/classes",
"version": "8.0.0-beta.13",
"version": "8.0.0-beta.14",
"peerDependencies": {
"reflect-metadata": "~0.1.13",
"@automapper/core": "8.0.0-beta.13"
"@automapper/core": "8.0.0-beta.14"
},

@@ -8,0 +8,0 @@ "exports": {

@@ -8,3 +8,3 @@ "use strict";

exports.__esModule = true;
exports.getStandaloneConstructors = exports.AutoMapStandalone = exports.AutoMap = void 0;
exports.AutoMap = void 0;
/* eslint-disable @typescript-eslint/no-empty-function */

@@ -15,7 +15,1 @@ function AutoMap() {

exports.AutoMap = AutoMap;
function AutoMapStandalone() {
return function () { };
}
exports.AutoMapStandalone = AutoMapStandalone;
function getStandaloneConstructors() { }
exports.getStandaloneConstructors = getStandaloneConstructors;

@@ -10,3 +10,2 @@ 'use strict';

const AUTOMAPPER_DECORATOR_NAME = 'AutoMap';
const AUTOMAPPER_STANDALONE_DECORATOR_NAME = 'AutoMapStandalone';
const JSDOC_KEY = 'jsDoc';

@@ -405,3 +404,2 @@ const AUTOMAP_IGNORE_TAG = 'autoMapIgnore';

exports.AUTOMAPPER_DECORATOR_NAME = AUTOMAPPER_DECORATOR_NAME;
exports.AUTOMAPPER_STANDALONE_DECORATOR_NAME = AUTOMAPPER_STANDALONE_DECORATOR_NAME;
exports.AUTOMAP_IGNORE_TAG = AUTOMAP_IGNORE_TAG;

@@ -408,0 +406,0 @@ exports.JSDOC_KEY = JSDOC_KEY;

@@ -6,3 +6,2 @@ import { AUTOMAPPER_METADATA_FACTORY_KEY } from '@automapper/classes';

const AUTOMAPPER_DECORATOR_NAME = 'AutoMap';
const AUTOMAPPER_STANDALONE_DECORATOR_NAME = 'AutoMapStandalone';
const JSDOC_KEY = 'jsDoc';

@@ -400,2 +399,2 @@ const AUTOMAP_IGNORE_TAG = 'autoMapIgnore';

export { AUTOMAPPER_DECORATOR_NAME, AUTOMAPPER_STANDALONE_DECORATOR_NAME, AUTOMAP_IGNORE_TAG, JSDOC_KEY, before, automapperTransformerPlugin as default };
export { AUTOMAPPER_DECORATOR_NAME, AUTOMAP_IGNORE_TAG, JSDOC_KEY, before, automapperTransformerPlugin as default };
export declare const AUTOMAPPER_DECORATOR_NAME = "AutoMap";
export declare const AUTOMAPPER_STANDALONE_DECORATOR_NAME = "AutoMapStandalone";
export declare const JSDOC_KEY = "jsDoc";
export declare const AUTOMAP_IGNORE_TAG = "autoMapIgnore";
{
"name": "@automapper/classes/transformer-plugin",
"version": "8.0.0-beta.13",
"version": "8.0.0-beta.14",
"exports": {

@@ -34,4 +34,4 @@ "import": "./index.esm.js",

"peerDependencies": {
"@automapper/classes": "8.0.0-beta.13"
"@automapper/classes": "8.0.0-beta.14"
}
}
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