@hodfords/turbo-transformer 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"TransformOperationExecutor.js","sourceRoot":"","sources":["../../src/TransformOperationExecutor.ts"],"names":[],"mappings":";;;AAAA,uCAAmD;AAEnD,mCAA6C;AAC7C,mCAA+C;AAC/C,2DAA4D;AAE5D,SAAS,oBAAoB,CAAC,SAAmB;IAC/C,MAAM,KAAK,GAAG,IAAK,SAAiB,EAAE,CAAC;IACvC,IAAI,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE;QACjD,OAAO,EAAE,CAAC;KACX;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAa,0BAA0B;IAQrC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAoB,kBAAsC,EAAU,OAA8B;QAA9E,uBAAkB,GAAlB,kBAAkB,CAAoB;QAAU,YAAO,GAAP,OAAO,CAAuB;QAXlG,4EAA4E;QAC5E,qBAAqB;QACrB,4EAA4E;QAEpE,mBAAc,GAAG,IAAI,GAAG,EAAuB,CAAC;QAQtD,IAAI,CAAC,GAAG,GAAG,IAAA,+BAAW,EAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,SAAS,CACP,MAAyD,EACzD,KAAwD,EACxD,UAAmC,EACnC,SAAmB,EACnB,KAAc,EACd,QAAgB,CAAC;QAEjB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,GAAG,EAAE;YAChD,MAAM,QAAQ,GACZ,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,0BAAkB,CAAC,cAAc;gBACxE,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC;gBACjC,C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M,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC7D,IAAI,UAAU;YAAE,OAAO,UAAU,CAAC;QAElC,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC7C,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,CAAC;CACF;AA1iBD,gEA0iBC","sourcesContent":["import { defaultMetadataStorage } from './storage';\nimport { ClassTransformOptions, TypeHelpOptions, TypeMetadata, TypeOptions } from './interfaces';\nimport { TransformationType } from './enums';\nimport { getGlobal, isPromise } from './utils';\nimport { getJitCache, JitCache } from './TransformCompiler';\n\nfunction instantiateArrayType(arrayType: Function): Array<any> | Set<any> {\n const array = new (arrayType as any)();\n if (!(array instanceof Set) && !('push' in array)) {\n return [];\n }\n return array;\n}\n\nexport class TransformOperationExecutor {\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private recursionStack = new Set<Record<string, any>>();\n private jit: JitCache | undefined;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(private transformationType: TransformationType, private options: ClassTransformOptions) {\n this.jit = getJitCache(transformationType, options);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n transform(\n source: Record<string, any> | Record<string, any>[] | any,\n value: Record<string, any> | Record<string, any>[] | any,\n targetType: Function | TypeMetadata,\n arrayType: Function,\n isMap: boolean,\n level: number = 0\n ): any {\n if (Array.isArray(value) || value instanceof Set) {\n const newValue =\n arrayType && this.transformationType === TransformationType.PLAIN_TO_CLASS\n ? instantiateArrayType(arrayType)\n : [];\n (value as any[]).forEach((subValue, index) => {\n const subSource = source ? source[index] : undefined;\n if (!this.options.enableCircularCheck || !this.isCircular(subValue)) {\n let realTargetType;\n if (\n typeof targetType !== 'function' &&\n targetType &&\n targetType.options &&\n targetType.options.discriminator &&\n targetType.options.discriminator.property &&\n targetType.options.discriminator.subTypes\n ) {\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n realTargetType = targetType.options.discriminator.subTypes.find(\n subType =>\n subType.name === subValue[(targetType as { options: TypeOptions }).options.discriminator.property]\n );\n const options: TypeHelpOptions = { newObject: newValue, object: subValue, property: undefined };\n const newType = targetType.typeFunction(options);\n realTargetType === undefined ? (realTargetType = newType) : (realTargetType = realTargetType.value);\n if (!targetType.options.keepDiscriminatorProperty)\n delete subValue[targetType.options.discriminator.property];\n }\n\n if (this.transformationType === TransformationType.CLASS_TO_CLASS) {\n realTargetType = subValue.constructor;\n }\n if (this.transformationType === TransformationType.CLASS_TO_PLAIN) {\n subValue[targetType.options.discriminator.property] = targetType.options.discriminator.subTypes.find(\n subType => subType.value === subValue.constructor\n ).name;\n }\n } else {\n realTargetType = targetType;\n }\n const value = this.transform(\n subSource,\n subValue,\n realTargetType,\n undefined,\n subValue instanceof Map,\n level + 1\n );\n\n if (newValue instanceof Set) {\n newValue.add(value);\n } else {\n newValue.push(value);\n }\n } else if (this.transformationType === TransformationType.CLASS_TO_CLASS) {\n if (newValue instanceof Set) {\n newValue.add(subValue);\n } else {\n newValue.push(subValue);\n }\n }\n });\n return newValue;\n } else if (targetType === String && !isMap) {\n if (value === null || value === undefined) return value;\n return String(value);\n } else if (targetType === Number && !isMap) {\n if (value === null || value === undefined) return value;\n return Number(value);\n } else if (targetType === Boolean && !isMap) {\n if (value === null || value === undefined) return value;\n return Boolean(value);\n } else if ((targetType === Date || value instanceof Date) && !isMap) {\n if (value instanceof Date) {\n return new Date(value.valueOf());\n }\n if (value === null || value === undefined) return value;\n return new Date(value);\n } else if (!!getGlobal().Buffer && (targetType === Buffer || value instanceof Buffer) && !isMap) {\n if (value === null || value === undefined) return value;\n return Buffer.from(value);\n } else if (isPromise(value) && !isMap) {\n return new Promise((resolve, reject) => {\n value.then(\n (data: any) => resolve(this.transform(undefined, data, targetType, undefined, undefined, level + 1)),\n reject\n );\n });\n } else if (!isMap && value !== null && typeof value === 'object' && typeof value.then === 'function') {\n // Note: We should not enter this, as promise has been handled above\n // This option simply returns the Promise preventing a JS error from happening and should be an inaccessible path.\n return value; // skip promise transformation\n } else if (typeof value === 'object' && value !== null) {\n // try to guess the type\n if (!targetType && value.constructor !== Object /* && TransformationType === TransformationType.CLASS_TO_PLAIN*/)\n if (!Array.isArray(value) && value.constructor === Array) {\n // Somebody attempts to convert special Array like object to Array, eg:\n // const evilObject = { '100000000': '100000000', __proto__: [] };\n // This could be used to cause Denial-of-service attack so we don't allow it.\n // See prevent-array-bomb.spec.ts for more details.\n } else {\n // We are good we can use the built-in constructor\n targetType = value.constructor;\n }\n if (!targetType && source) targetType = source.constructor;\n\n if (this.options.enableCircularCheck) {\n // add transformed type to prevent circular references\n this.recursionStack.add(value);\n }\n\n // use the compiled (JIT) transformer of this class when possible, see TransformCompiler\n const compiled =\n this.jit && !isMap && !(value instanceof Map) && !(source instanceof Map)\n ? this.jit.get(targetType, this)\n : undefined;\n const newValue = compiled\n ? compiled(this, source, value, level)\n : this.transformObject(source, value, targetType as Function, isMap, level);\n\n if (this.options.enableCircularCheck) {\n this.recursionStack.delete(value);\n }\n\n return newValue;\n } else {\n return value;\n }\n }\n\n // -------------------------------------------------------------------------\n // Private Methods\n // -------------------------------------------------------------------------\n\n /**\n * Interpreted transformation of a single object, used when no compiled transformer is available.\n */\n private transformObject(source: any, value: any, targetType: Function, isMap: boolean, level: number): any {\n {\n const keys = this.getKeys(targetType, value, isMap);\n let newValue: any = source ? source : {};\n if (\n !source &&\n (this.transformationType === TransformationType.PLAIN_TO_CLASS ||\n this.transformationType === TransformationType.CLASS_TO_CLASS)\n ) {\n if (isMap) {\n newValue = new Map();\n } else if (targetType) {\n newValue = new (targetType as any)();\n } else {\n newValue = {};\n }\n }\n\n // traverse over keys\n for (const key of keys) {\n if (key === '__proto__' || key === 'constructor') {\n continue;\n }\n\n const valueKey = key;\n let newValueKey = key,\n propertyName = key;\n if (!this.options.ignoreDecorators && targetType) {\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadataByCustomName(targetType, key);\n if (exposeMetadata) {\n propertyName = exposeMetadata.propertyName;\n newValueKey = exposeMetadata.propertyName;\n }\n } else if (\n this.transformationType === TransformationType.CLASS_TO_PLAIN ||\n this.transformationType === TransformationType.CLASS_TO_CLASS\n ) {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(targetType, key);\n if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) {\n newValueKey = exposeMetadata.options.name;\n }\n }\n }\n\n // get a subvalue\n let subValue: any = undefined;\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n /**\n * This section is added for the following report:\n * https://github.com/typestack/class-transformer/issues/596\n *\n * We should not call functions or constructors when transforming to class.\n */\n subValue = value[valueKey];\n } else {\n if (value instanceof Map) {\n subValue = value.get(valueKey);\n } else if (value[valueKey] instanceof Function) {\n subValue = value[valueKey]();\n } else {\n subValue = value[valueKey];\n }\n }\n\n // determine a type\n let type: any = undefined,\n isSubValueMap = subValue instanceof Map;\n if (targetType && isMap) {\n type = targetType;\n } else if (targetType) {\n const metadata = defaultMetadataStorage.findTypeMetadata(targetType, propertyName);\n if (metadata) {\n const options: TypeHelpOptions = { newObject: newValue, object: value, property: propertyName };\n const newType = metadata.typeFunction ? metadata.typeFunction(options) : metadata.reflectedType;\n if (\n metadata.options &&\n metadata.options.discriminator &&\n metadata.options.discriminator.property &&\n metadata.options.discriminator.subTypes\n ) {\n if (!(value[valueKey] instanceof Array)) {\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n type = metadata.options.discriminator.subTypes.find(subType => {\n if (subValue && subValue instanceof Object && metadata.options.discriminator.property in subValue) {\n return subType.name === subValue[metadata.options.discriminator.property];\n }\n });\n type === undefined ? (type = newType) : (type = type.value);\n if (!metadata.options.keepDiscriminatorProperty) {\n if (subValue && subValue instanceof Object && metadata.options.discriminator.property in subValue) {\n delete subValue[metadata.options.discriminator.property];\n }\n }\n }\n if (this.transformationType === TransformationType.CLASS_TO_CLASS) {\n type = subValue.constructor;\n }\n if (this.transformationType === TransformationType.CLASS_TO_PLAIN) {\n if (subValue) {\n subValue[metadata.options.discriminator.property] = metadata.options.discriminator.subTypes.find(\n subType => subType.value === subValue.constructor\n ).name;\n }\n }\n } else {\n type = metadata;\n }\n } else {\n type = newType;\n }\n isSubValueMap = isSubValueMap || metadata.reflectedType === Map;\n } else if (this.options.targetMaps) {\n // try to find a type in target maps\n this.options.targetMaps\n .filter(map => map.target === targetType && !!map.properties[propertyName])\n .forEach(map => (type = map.properties[propertyName]));\n } else if (\n this.options.enableImplicitConversion &&\n this.transformationType === TransformationType.PLAIN_TO_CLASS\n ) {\n // if we have no registererd type via the @Type() decorator then we check if we have any\n // type declarations in reflect-metadata (type declaration is emited only if some decorator is added to the property.)\n const reflectedType = (Reflect as any).getMetadata('design:type', targetType.prototype, propertyName);\n\n if (reflectedType) {\n type = reflectedType;\n }\n }\n }\n\n // if value is an array try to get its custom array type\n const arrayType = Array.isArray(value[valueKey]) ? this.getReflectedType(targetType, propertyName) : undefined;\n\n // const subValueKey = TransformationType === TransformationType.PLAIN_TO_CLASS && newKeyName ? newKeyName : key;\n const subSource = source ? source[valueKey] : undefined;\n\n // if its deserialization then type if required\n // if we uncomment this types like string[] will not work\n // if (this.transformationType === TransformationType.PLAIN_TO_CLASS && !type && subValue instanceof Object && !(subValue instanceof Date))\n // throw new Error(`Cannot determine type for ${(targetType as any).name }.${propertyName}, did you forget to specify a @Type?`);\n\n // if newValue is a source object that has method that match newKeyName then skip it\n if (newValue.constructor.prototype) {\n const descriptor = this.getPropertyDescriptor(newValue.constructor.prototype, newValueKey);\n if (\n (this.transformationType === TransformationType.PLAIN_TO_CLASS ||\n this.transformationType === TransformationType.CLASS_TO_CLASS) &&\n // eslint-disable-next-line @typescript-eslint/unbound-method\n ((descriptor && !descriptor.set) || newValue[newValueKey] instanceof Function)\n )\n // || TransformationType === TransformationType.CLASS_TO_CLASS\n continue;\n }\n\n if (!this.options.enableCircularCheck || !this.isCircular(subValue)) {\n const transformKey = this.transformationType === TransformationType.PLAIN_TO_CLASS ? newValueKey : key;\n let finalValue;\n\n if (this.transformationType === TransformationType.CLASS_TO_PLAIN) {\n // Get original value\n finalValue = value[transformKey];\n // Apply custom transformation\n finalValue = this.applyCustomTransformations(\n finalValue,\n targetType,\n transformKey,\n value,\n this.transformationType\n );\n // If nothing change, it means no custom transformation was applied, so use the subValue.\n finalValue = value[transformKey] === finalValue ? subValue : finalValue;\n // Apply the default transformation\n finalValue = this.transform(subSource, finalValue, type, arrayType, isSubValueMap, level + 1);\n } else {\n if (subValue === undefined && this.options.exposeDefaultValues) {\n // Set default value if nothing provided\n finalValue = newValue[newValueKey];\n } else {\n finalValue = this.transform(subSource, subValue, type, arrayType, isSubValueMap, level + 1);\n finalValue = this.applyCustomTransformations(\n finalValue,\n targetType,\n transformKey,\n value,\n this.transformationType\n );\n }\n }\n\n if (finalValue !== undefined || this.options.exposeUnsetFields) {\n if (newValue instanceof Map) {\n newValue.set(newValueKey, finalValue);\n } else {\n newValue[newValueKey] = finalValue;\n }\n }\n } else if (this.transformationType === TransformationType.CLASS_TO_CLASS) {\n let finalValue = subValue;\n finalValue = this.applyCustomTransformations(finalValue, targetType, key, value, this.transformationType);\n if (finalValue !== undefined || this.options.exposeUnsetFields) {\n if (newValue instanceof Map) {\n newValue.set(newValueKey, finalValue);\n } else {\n newValue[newValueKey] = finalValue;\n }\n }\n }\n }\n\n return newValue;\n }\n }\n\n private applyCustomTransformations(\n value: any,\n target: Function,\n key: string,\n obj: any,\n transformationType: TransformationType\n ): boolean {\n let metadatas = defaultMetadataStorage.findTransformMetadatas(target, key, this.transformationType);\n\n // apply versioning options\n if (this.options.version !== undefined) {\n metadatas = metadatas.filter(metadata => {\n if (!metadata.options) return true;\n\n return this.checkVersion(metadata.options.since, metadata.options.until);\n });\n }\n\n // apply grouping options\n if (this.options.groups && this.options.groups.length) {\n metadatas = metadatas.filter(metadata => {\n if (!metadata.options) return true;\n\n return this.checkGroups(metadata.options.groups);\n });\n } else {\n metadatas = metadatas.filter(metadata => {\n return !metadata.options || !metadata.options.groups || !metadata.options.groups.length;\n });\n }\n\n metadatas.forEach(metadata => {\n value = metadata.transformFn({ value, key, obj, type: transformationType, options: this.options });\n });\n\n return value;\n }\n\n // preventing circular references\n private isCircular(object: Record<string, any>): boolean {\n return this.recursionStack.has(object);\n }\n\n private getReflectedType(target: Function, propertyName: string): Function | undefined {\n if (!target) return undefined;\n const meta = defaultMetadataStorage.findTypeMetadata(target, propertyName);\n return meta ? meta.reflectedType : undefined;\n }\n\n private getKeys(target: Function, object: Record<string, any>, isMap: boolean): string[] {\n // determine exclusion strategy\n let strategy = defaultMetadataStorage.getStrategy(target);\n if (strategy === 'none') strategy = this.options.strategy || 'exposeAll'; // exposeAll is default strategy\n\n // get all keys that need to expose\n let keys: any[] = [];\n if (strategy === 'exposeAll' || isMap) {\n if (object instanceof Map) {\n keys = Array.from(object.keys());\n } else {\n keys = Object.keys(object);\n }\n }\n\n if (isMap) {\n // expose & exclude do not apply for map keys only to fields\n return keys;\n }\n\n /**\n * If decorators are ignored but we don't want the extraneous values, then we use the\n * metadata to decide which property is needed, but doesn't apply the decorator effect.\n */\n if (this.options.ignoreDecorators && this.options.excludeExtraneousValues && target) {\n const exposedProperties = defaultMetadataStorage.getExposedProperties(target, this.transformationType);\n const excludedProperties = defaultMetadataStorage.getExcludedProperties(target, this.transformationType);\n keys = [...exposedProperties, ...excludedProperties];\n }\n\n if (!this.options.ignoreDecorators && target) {\n // add all exposed to list of keys\n let exposedProperties = defaultMetadataStorage.getExposedProperties(target, this.transformationType);\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n exposedProperties = exposedProperties.map(key => {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(target, key);\n if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) {\n return exposeMetadata.options.name;\n }\n\n return key;\n });\n }\n if (this.options.excludeExtraneousValues) {\n keys = exposedProperties;\n } else {\n keys = keys.concat(exposedProperties);\n }\n\n // exclude excluded properties\n const excludedProperties = defaultMetadataStorage.getExcludedProperties(target, this.transformationType);\n if (excludedProperties.length > 0) {\n keys = keys.filter(key => {\n return !excludedProperties.includes(key);\n });\n }\n\n // apply versioning options\n if (this.options.version !== undefined) {\n keys = keys.filter(key => {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(target, key);\n if (!exposeMetadata || !exposeMetadata.options) return true;\n\n return this.checkVersion(exposeMetadata.options.since, exposeMetadata.options.until);\n });\n }\n\n // apply grouping options\n if (this.options.groups && this.options.groups.length) {\n keys = keys.filter(key => {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(target, key);\n if (!exposeMetadata || !exposeMetadata.options) return true;\n\n return this.checkGroups(exposeMetadata.options.groups);\n });\n } else {\n keys = keys.filter(key => {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(target, key);\n return (\n !exposeMetadata ||\n !exposeMetadata.options ||\n !exposeMetadata.options.groups ||\n !exposeMetadata.options.groups.length\n );\n });\n }\n }\n\n // exclude prefixed properties\n if (this.options.excludePrefixes && this.options.excludePrefixes.length) {\n keys = keys.filter(key =>\n this.options.excludePrefixes.every(prefix => {\n return key.substr(0, prefix.length) !== prefix;\n })\n );\n }\n\n // make sure we have unique keys\n keys = keys.filter((key, index, self) => {\n return self.indexOf(key) === index;\n });\n\n return keys;\n }\n\n private checkVersion(since: number, until: number): boolean {\n let decision = true;\n if (decision && since) decision = this.options.version >= since;\n if (decision && until) decision = this.options.version < until;\n\n return decision;\n }\n\n private checkGroups(groups: string[]): boolean {\n if (!groups) return true;\n\n return this.options.groups.some(optionGroup => groups.includes(optionGroup));\n }\n\n private getPropertyDescriptor(obj: any, key: PropertyKey): PropertyDescriptor | undefined {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n if (descriptor) return descriptor;\n\n const prototype = Object.getPrototypeOf(obj);\n return prototype ? this.getPropertyDescriptor(prototype, key) : undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"TransformOperationExecutor.js","sourceRoot":"","sources":["../../src/TransformOperationExecutor.ts"],"names":[],"mappings":";;;AAAA,uCAAmD;AAEnD,mCAA6C;AAC7C,mCAA+C;AAC/C,2DAAoG;AAEpG,SAAS,oBAAoB,CAAC,SAAmB;IAC/C,MAAM,KAAK,GAAG,IAAK,SAAiB,EAAE,CAAC;IACvC,IAAI,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE;QACjD,OAAO,EAAE,CAAC;KACX;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAa,0BAA0B;IAQrC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAoB,kBAAsC,EAAU,OAA8B;QAA9E,uBAAkB,GAAlB,kBAAkB,CAAoB;QAAU,YAAO,GAAP,OAAO,CAAuB;QAXlG,4EAA4E;QAC5E,qBAAqB;QACrB,4EAA4E;QAEpE,mBAAc,GAAG,IAAI,GAAG,EAAuB,CAAC;QAQtD,IAAI,CAAC,GAAG,GAAG,IAAA,+BAAW,EAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,SAAS,CACP,MAAyD,EACzD,KAAwD,EACxD,UAAmC,EACnC,SAAmB,EACnB,KAAc,EACd,QAAgB,CAAC;QAEjB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,GAAG,EAAE;YAChD,MAAM,QAAQ,GACZ,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,0BAAkB,CAAC,cAAc;gBACxE,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC;gBACjC,CAAC,CAAC,EAAE,CAA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AAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,CAAC;CACF;AAtlBD,gEAslBC","sourcesContent":["import { defaultMetadataStorage } from './storage';\nimport { ClassTransformOptions, TypeHelpOptions, TypeMetadata, TypeOptions } from './interfaces';\nimport { TransformationType } from './enums';\nimport { getGlobal, isPromise } from './utils';\nimport { CompiledTransformer, DirectTransformer, getJitCache, JitCache } from './TransformCompiler';\n\nfunction instantiateArrayType(arrayType: Function): Array<any> | Set<any> {\n const array = new (arrayType as any)();\n if (!(array instanceof Set) && !('push' in array)) {\n return [];\n }\n return array;\n}\n\nexport class TransformOperationExecutor {\n // -------------------------------------------------------------------------\n // Private Properties\n // -------------------------------------------------------------------------\n\n private recursionStack = new Set<Record<string, any>>();\n private jit: JitCache | undefined;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(private transformationType: TransformationType, private options: ClassTransformOptions) {\n this.jit = getJitCache(transformationType, options);\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n transform(\n source: Record<string, any> | Record<string, any>[] | any,\n value: Record<string, any> | Record<string, any>[] | any,\n targetType: Function | TypeMetadata,\n arrayType: Function,\n isMap: boolean,\n level: number = 0\n ): any {\n if (Array.isArray(value) || value instanceof Set) {\n const newValue =\n arrayType && this.transformationType === TransformationType.PLAIN_TO_CLASS\n ? instantiateArrayType(arrayType)\n : [];\n // compiled transformer called directly for the elements, see TransformCompiler\n const direct = this.jit && !source && typeof targetType === 'function' ? this.jit.direct(targetType, this) : null;\n if (direct && Array.isArray(value) && value.forEach === Array.prototype.forEach) {\n return this.transformArrayDirect(direct, value, newValue, targetType as Function, level);\n }\n (value as any[]).forEach((subValue, index) => {\n const subSource = source ? source[index] : undefined;\n if (!this.options.enableCircularCheck || !this.isCircular(subValue)) {\n let realTargetType;\n if (\n typeof targetType !== 'function' &&\n targetType &&\n targetType.options &&\n targetType.options.discriminator &&\n targetType.options.discriminator.property &&\n targetType.options.discriminator.subTypes\n ) {\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n realTargetType = targetType.options.discriminator.subTypes.find(\n subType =>\n subType.name === subValue[(targetType as { options: TypeOptions }).options.discriminator.property]\n );\n const options: TypeHelpOptions = { newObject: newValue, object: subValue, property: undefined };\n const newType = targetType.typeFunction(options);\n realTargetType === undefined ? (realTargetType = newType) : (realTargetType = realTargetType.value);\n if (!targetType.options.keepDiscriminatorProperty)\n delete subValue[targetType.options.discriminator.property];\n }\n\n if (this.transformationType === TransformationType.CLASS_TO_CLASS) {\n realTargetType = subValue.constructor;\n }\n if (this.transformationType === TransformationType.CLASS_TO_PLAIN) {\n subValue[targetType.options.discriminator.property] = targetType.options.discriminator.subTypes.find(\n subType => subType.value === subValue.constructor\n ).name;\n }\n } else {\n realTargetType = targetType;\n }\n const value =\n direct && realTargetType === targetType && direct.accepts(subValue)\n ? this.transformDirect(direct.transformer, subValue, level + 1)\n : this.transform(subSource, subValue, realTargetType, undefined, subValue instanceof Map, level + 1);\n\n if (newValue instanceof Set) {\n newValue.add(value);\n } else {\n newValue.push(value);\n }\n } else if (this.transformationType === TransformationType.CLASS_TO_CLASS) {\n if (newValue instanceof Set) {\n newValue.add(subValue);\n } else {\n newValue.push(subValue);\n }\n }\n });\n return newValue;\n } else if (targetType === String && !isMap) {\n if (value === null || value === undefined) return value;\n return String(value);\n } else if (targetType === Number && !isMap) {\n if (value === null || value === undefined) return value;\n return Number(value);\n } else if (targetType === Boolean && !isMap) {\n if (value === null || value === undefined) return value;\n return Boolean(value);\n } else if ((targetType === Date || value instanceof Date) && !isMap) {\n if (value instanceof Date) {\n return new Date(value.valueOf());\n }\n if (value === null || value === undefined) return value;\n return new Date(value);\n } else if (!!getGlobal().Buffer && (targetType === Buffer || value instanceof Buffer) && !isMap) {\n if (value === null || value === undefined) return value;\n return Buffer.from(value);\n } else if (isPromise(value) && !isMap) {\n return new Promise((resolve, reject) => {\n value.then(\n (data: any) => resolve(this.transform(undefined, data, targetType, undefined, undefined, level + 1)),\n reject\n );\n });\n } else if (!isMap && value !== null && typeof value === 'object' && typeof value.then === 'function') {\n // Note: We should not enter this, as promise has been handled above\n // This option simply returns the Promise preventing a JS error from happening and should be an inaccessible path.\n return value; // skip promise transformation\n } else if (typeof value === 'object' && value !== null) {\n // try to guess the type\n if (!targetType && value.constructor !== Object /* && TransformationType === TransformationType.CLASS_TO_PLAIN*/)\n if (!Array.isArray(value) && value.constructor === Array) {\n // Somebody attempts to convert special Array like object to Array, eg:\n // const evilObject = { '100000000': '100000000', __proto__: [] };\n // This could be used to cause Denial-of-service attack so we don't allow it.\n // See prevent-array-bomb.spec.ts for more details.\n } else {\n // We are good we can use the built-in constructor\n targetType = value.constructor;\n }\n if (!targetType && source) targetType = source.constructor;\n\n if (this.options.enableCircularCheck) {\n // add transformed type to prevent circular references\n this.recursionStack.add(value);\n }\n\n // use the compiled (JIT) transformer of this class when possible, see TransformCompiler\n const compiled =\n this.jit && !isMap && !(value instanceof Map) && !(source instanceof Map)\n ? this.jit.get(targetType, this)\n : undefined;\n const newValue = compiled\n ? compiled(this, source, value, level)\n : this.transformObject(source, value, targetType as Function, isMap, level);\n\n if (this.options.enableCircularCheck) {\n this.recursionStack.delete(value);\n }\n\n return newValue;\n } else {\n return value;\n }\n }\n\n // -------------------------------------------------------------------------\n // Private Methods\n // -------------------------------------------------------------------------\n\n /**\n * Same as the forEach of the array branch of `transform`, when elements are transformed with a class having a\n * compiled transformer (no source, no discriminator).\n */\n private transformArrayDirect(\n direct: DirectTransformer,\n value: any[],\n newValue: any[] | Set<any>,\n targetType: Function,\n level: number\n ): any[] | Set<any> {\n const isSet = newValue instanceof Set;\n const length = value.length;\n for (let index = 0; index < length; index++) {\n if (!(index in value)) continue; // forEach skips holes\n const subValue = value[index];\n let transformed: any;\n if (this.options.enableCircularCheck && this.isCircular(subValue)) {\n if (this.transformationType !== TransformationType.CLASS_TO_CLASS) continue;\n transformed = subValue;\n } else if (direct.accepts(subValue)) {\n transformed = this.transformDirect(direct.transformer, subValue, level + 1);\n } else {\n transformed = this.transform(undefined, subValue, targetType, undefined, subValue instanceof Map, level + 1);\n }\n if (isSet) newValue.add(transformed);\n else newValue.push(transformed);\n }\n return newValue;\n }\n\n /**\n * Same as `transform(undefined, value, <type of the direct transformer>, undefined, false, level)`\n * for a value accepted by the direct transformer.\n */\n private transformDirect(transformer: CompiledTransformer, value: any, level: number): any {\n if (!this.options.enableCircularCheck) return transformer(this, undefined, value, level);\n this.recursionStack.add(value);\n const newValue = transformer(this, undefined, value, level);\n this.recursionStack.delete(value);\n return newValue;\n }\n\n /**\n * Interpreted transformation of a single object, used when no compiled transformer is available.\n */\n private transformObject(source: any, value: any, targetType: Function, isMap: boolean, level: number): any {\n {\n const keys = this.getKeys(targetType, value, isMap);\n let newValue: any = source ? source : {};\n if (\n !source &&\n (this.transformationType === TransformationType.PLAIN_TO_CLASS ||\n this.transformationType === TransformationType.CLASS_TO_CLASS)\n ) {\n if (isMap) {\n newValue = new Map();\n } else if (targetType) {\n newValue = new (targetType as any)();\n } else {\n newValue = {};\n }\n }\n\n // traverse over keys\n for (const key of keys) {\n if (key === '__proto__' || key === 'constructor') {\n continue;\n }\n\n const valueKey = key;\n let newValueKey = key,\n propertyName = key;\n if (!this.options.ignoreDecorators && targetType) {\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadataByCustomName(targetType, key);\n if (exposeMetadata) {\n propertyName = exposeMetadata.propertyName;\n newValueKey = exposeMetadata.propertyName;\n }\n } else if (\n this.transformationType === TransformationType.CLASS_TO_PLAIN ||\n this.transformationType === TransformationType.CLASS_TO_CLASS\n ) {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(targetType, key);\n if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) {\n newValueKey = exposeMetadata.options.name;\n }\n }\n }\n\n // get a subvalue\n let subValue: any = undefined;\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n /**\n * This section is added for the following report:\n * https://github.com/typestack/class-transformer/issues/596\n *\n * We should not call functions or constructors when transforming to class.\n */\n subValue = value[valueKey];\n } else {\n if (value instanceof Map) {\n subValue = value.get(valueKey);\n } else if (value[valueKey] instanceof Function) {\n subValue = value[valueKey]();\n } else {\n subValue = value[valueKey];\n }\n }\n\n // determine a type\n let type: any = undefined,\n isSubValueMap = subValue instanceof Map;\n if (targetType && isMap) {\n type = targetType;\n } else if (targetType) {\n const metadata = defaultMetadataStorage.findTypeMetadata(targetType, propertyName);\n if (metadata) {\n const options: TypeHelpOptions = { newObject: newValue, object: value, property: propertyName };\n const newType = metadata.typeFunction ? metadata.typeFunction(options) : metadata.reflectedType;\n if (\n metadata.options &&\n metadata.options.discriminator &&\n metadata.options.discriminator.property &&\n metadata.options.discriminator.subTypes\n ) {\n if (!(value[valueKey] instanceof Array)) {\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n type = metadata.options.discriminator.subTypes.find(subType => {\n if (subValue && subValue instanceof Object && metadata.options.discriminator.property in subValue) {\n return subType.name === subValue[metadata.options.discriminator.property];\n }\n });\n type === undefined ? (type = newType) : (type = type.value);\n if (!metadata.options.keepDiscriminatorProperty) {\n if (subValue && subValue instanceof Object && metadata.options.discriminator.property in subValue) {\n delete subValue[metadata.options.discriminator.property];\n }\n }\n }\n if (this.transformationType === TransformationType.CLASS_TO_CLASS) {\n type = subValue.constructor;\n }\n if (this.transformationType === TransformationType.CLASS_TO_PLAIN) {\n if (subValue) {\n subValue[metadata.options.discriminator.property] = metadata.options.discriminator.subTypes.find(\n subType => subType.value === subValue.constructor\n ).name;\n }\n }\n } else {\n type = metadata;\n }\n } else {\n type = newType;\n }\n isSubValueMap = isSubValueMap || metadata.reflectedType === Map;\n } else if (this.options.targetMaps) {\n // try to find a type in target maps\n this.options.targetMaps\n .filter(map => map.target === targetType && !!map.properties[propertyName])\n .forEach(map => (type = map.properties[propertyName]));\n } else if (\n this.options.enableImplicitConversion &&\n this.transformationType === TransformationType.PLAIN_TO_CLASS\n ) {\n // if we have no registererd type via the @Type() decorator then we check if we have any\n // type declarations in reflect-metadata (type declaration is emited only if some decorator is added to the property.)\n const reflectedType = (Reflect as any).getMetadata('design:type', targetType.prototype, propertyName);\n\n if (reflectedType) {\n type = reflectedType;\n }\n }\n }\n\n // if value is an array try to get its custom array type\n const arrayType = Array.isArray(value[valueKey]) ? this.getReflectedType(targetType, propertyName) : undefined;\n\n // const subValueKey = TransformationType === TransformationType.PLAIN_TO_CLASS && newKeyName ? newKeyName : key;\n const subSource = source ? source[valueKey] : undefined;\n\n // if its deserialization then type if required\n // if we uncomment this types like string[] will not work\n // if (this.transformationType === TransformationType.PLAIN_TO_CLASS && !type && subValue instanceof Object && !(subValue instanceof Date))\n // throw new Error(`Cannot determine type for ${(targetType as any).name }.${propertyName}, did you forget to specify a @Type?`);\n\n // if newValue is a source object that has method that match newKeyName then skip it\n if (newValue.constructor.prototype) {\n const descriptor = this.getPropertyDescriptor(newValue.constructor.prototype, newValueKey);\n if (\n (this.transformationType === TransformationType.PLAIN_TO_CLASS ||\n this.transformationType === TransformationType.CLASS_TO_CLASS) &&\n // eslint-disable-next-line @typescript-eslint/unbound-method\n ((descriptor && !descriptor.set) || newValue[newValueKey] instanceof Function)\n )\n // || TransformationType === TransformationType.CLASS_TO_CLASS\n continue;\n }\n\n if (!this.options.enableCircularCheck || !this.isCircular(subValue)) {\n const transformKey = this.transformationType === TransformationType.PLAIN_TO_CLASS ? newValueKey : key;\n let finalValue;\n\n if (this.transformationType === TransformationType.CLASS_TO_PLAIN) {\n // Get original value\n finalValue = value[transformKey];\n // Apply custom transformation\n finalValue = this.applyCustomTransformations(\n finalValue,\n targetType,\n transformKey,\n value,\n this.transformationType\n );\n // If nothing change, it means no custom transformation was applied, so use the subValue.\n finalValue = value[transformKey] === finalValue ? subValue : finalValue;\n // Apply the default transformation\n finalValue = this.transform(subSource, finalValue, type, arrayType, isSubValueMap, level + 1);\n } else {\n if (subValue === undefined && this.options.exposeDefaultValues) {\n // Set default value if nothing provided\n finalValue = newValue[newValueKey];\n } else {\n finalValue = this.transform(subSource, subValue, type, arrayType, isSubValueMap, level + 1);\n finalValue = this.applyCustomTransformations(\n finalValue,\n targetType,\n transformKey,\n value,\n this.transformationType\n );\n }\n }\n\n if (finalValue !== undefined || this.options.exposeUnsetFields) {\n if (newValue instanceof Map) {\n newValue.set(newValueKey, finalValue);\n } else {\n newValue[newValueKey] = finalValue;\n }\n }\n } else if (this.transformationType === TransformationType.CLASS_TO_CLASS) {\n let finalValue = subValue;\n finalValue = this.applyCustomTransformations(finalValue, targetType, key, value, this.transformationType);\n if (finalValue !== undefined || this.options.exposeUnsetFields) {\n if (newValue instanceof Map) {\n newValue.set(newValueKey, finalValue);\n } else {\n newValue[newValueKey] = finalValue;\n }\n }\n }\n }\n\n return newValue;\n }\n }\n\n private applyCustomTransformations(\n value: any,\n target: Function,\n key: string,\n obj: any,\n transformationType: TransformationType\n ): boolean {\n let metadatas = defaultMetadataStorage.findTransformMetadatas(target, key, this.transformationType);\n\n // apply versioning options\n if (this.options.version !== undefined) {\n metadatas = metadatas.filter(metadata => {\n if (!metadata.options) return true;\n\n return this.checkVersion(metadata.options.since, metadata.options.until);\n });\n }\n\n // apply grouping options\n if (this.options.groups && this.options.groups.length) {\n metadatas = metadatas.filter(metadata => {\n if (!metadata.options) return true;\n\n return this.checkGroups(metadata.options.groups);\n });\n } else {\n metadatas = metadatas.filter(metadata => {\n return !metadata.options || !metadata.options.groups || !metadata.options.groups.length;\n });\n }\n\n metadatas.forEach(metadata => {\n value = metadata.transformFn({ value, key, obj, type: transformationType, options: this.options });\n });\n\n return value;\n }\n\n // preventing circular references\n private isCircular(object: Record<string, any>): boolean {\n return this.recursionStack.has(object);\n }\n\n private getReflectedType(target: Function, propertyName: string): Function | undefined {\n if (!target) return undefined;\n const meta = defaultMetadataStorage.findTypeMetadata(target, propertyName);\n return meta ? meta.reflectedType : undefined;\n }\n\n private getKeys(target: Function, object: Record<string, any>, isMap: boolean): string[] {\n // determine exclusion strategy\n let strategy = defaultMetadataStorage.getStrategy(target);\n if (strategy === 'none') strategy = this.options.strategy || 'exposeAll'; // exposeAll is default strategy\n\n // get all keys that need to expose\n let keys: any[] = [];\n if (strategy === 'exposeAll' || isMap) {\n if (object instanceof Map) {\n keys = Array.from(object.keys());\n } else {\n keys = Object.keys(object);\n }\n }\n\n if (isMap) {\n // expose & exclude do not apply for map keys only to fields\n return keys;\n }\n\n /**\n * If decorators are ignored but we don't want the extraneous values, then we use the\n * metadata to decide which property is needed, but doesn't apply the decorator effect.\n */\n if (this.options.ignoreDecorators && this.options.excludeExtraneousValues && target) {\n const exposedProperties = defaultMetadataStorage.getExposedProperties(target, this.transformationType);\n const excludedProperties = defaultMetadataStorage.getExcludedProperties(target, this.transformationType);\n keys = [...exposedProperties, ...excludedProperties];\n }\n\n if (!this.options.ignoreDecorators && target) {\n // add all exposed to list of keys\n let exposedProperties = defaultMetadataStorage.getExposedProperties(target, this.transformationType);\n if (this.transformationType === TransformationType.PLAIN_TO_CLASS) {\n exposedProperties = exposedProperties.map(key => {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(target, key);\n if (exposeMetadata && exposeMetadata.options && exposeMetadata.options.name) {\n return exposeMetadata.options.name;\n }\n\n return key;\n });\n }\n if (this.options.excludeExtraneousValues) {\n keys = exposedProperties;\n } else {\n keys = keys.concat(exposedProperties);\n }\n\n // exclude excluded properties\n const excludedProperties = defaultMetadataStorage.getExcludedProperties(target, this.transformationType);\n if (excludedProperties.length > 0) {\n keys = keys.filter(key => {\n return !excludedProperties.includes(key);\n });\n }\n\n // apply versioning options\n if (this.options.version !== undefined) {\n keys = keys.filter(key => {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(target, key);\n if (!exposeMetadata || !exposeMetadata.options) return true;\n\n return this.checkVersion(exposeMetadata.options.since, exposeMetadata.options.until);\n });\n }\n\n // apply grouping options\n if (this.options.groups && this.options.groups.length) {\n keys = keys.filter(key => {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(target, key);\n if (!exposeMetadata || !exposeMetadata.options) return true;\n\n return this.checkGroups(exposeMetadata.options.groups);\n });\n } else {\n keys = keys.filter(key => {\n const exposeMetadata = defaultMetadataStorage.findExposeMetadata(target, key);\n return (\n !exposeMetadata ||\n !exposeMetadata.options ||\n !exposeMetadata.options.groups ||\n !exposeMetadata.options.groups.length\n );\n });\n }\n }\n\n // exclude prefixed properties\n if (this.options.excludePrefixes && this.options.excludePrefixes.length) {\n keys = keys.filter(key =>\n this.options.excludePrefixes.every(prefix => {\n return key.substr(0, prefix.length) !== prefix;\n })\n );\n }\n\n // make sure we have unique keys\n keys = keys.filter((key, index, self) => {\n return self.indexOf(key) === index;\n });\n\n return keys;\n }\n\n private checkVersion(since: number, until: number): boolean {\n let decision = true;\n if (decision && since) decision = this.options.version >= since;\n if (decision && until) decision = this.options.version < until;\n\n return decision;\n }\n\n private checkGroups(groups: string[]): boolean {\n if (!groups) return true;\n\n return this.options.groups.some(optionGroup => groups.includes(optionGroup));\n }\n\n private getPropertyDescriptor(obj: any, key: PropertyKey): PropertyDescriptor | undefined {\n const descriptor = Object.getOwnPropertyDescriptor(obj, key);\n if (descriptor) return descriptor;\n\n const prototype = Object.getPrototypeOf(obj);\n return prototype ? this.getPropertyDescriptor(prototype, key) : undefined;\n }\n}\n"]}
@@ -66,8 +66,25 @@ export class JitCache {
66
66
  constructor() {
67
67
  this.version = -1;
68
68
  this.classes = new WeakMap();
69
+ this.directs = new WeakMap();
69
70
  this.anonymous = undefined;
70
71
  }
72
+ /**
73
+ * Returns the compiled transformer to call directly for elements of arrays of given type, or null.
74
+ */
75
+ direct(targetType, executor) {
76
+ // get() first: it drops everything when metadata changed
77
+ const transformer = this.get(targetType, executor);
78
+ if (!transformer)
79
+ return null;
80
+ let direct = this.directs.get(targetType);
81
+ if (direct === undefined || direct.transformer !== transformer) {
82
+ const resolved = helpers.resolveChild(executor, targetType);
83
+ direct = resolved ? new DirectTransformer(resolved, helpers.directPrototype(targetType)) : null;
84
+ this.directs.set(targetType, direct);
85
+ }
86
+ return direct;
87
+ }
71
88
  /**
72
89
  * Returns the compiled transformer for given target type (undefined when it can not be compiled).
73
90
  */
@@ -77,6 +94,7 @@ export class JitCache {
77
94
  if (version !== this.version) {
78
95
  this.version = version;
79
96
  this.classes = new WeakMap();
97
+ this.directs = new WeakMap();
80
98
  this.anonymous = undefined;
81
99
  }
82
100
  if (targetType === undefined || targetType === null) {
@@ -94,6 +112,23 @@ export class JitCache {
94
112
  return compiled || undefined;
95
113
  }
96
114
  }
115
+ /**
116
+ * Compiled transformer of a type, with the check of the values TransformOperationExecutor#transform would
117
+ * transform with it: plain objects and instances of the type which are not arrays, sets, dates, maps, buffers or
118
+ * promises.
119
+ */
120
+ export class DirectTransformer {
121
+ constructor(transformer, prototype) {
122
+ this.transformer = transformer;
123
+ this.prototype = prototype;
124
+ }
125
+ accepts(value) {
126
+ if (value === null || typeof value !== 'object')
127
+ return false;
128
+ const prototype = Object.getPrototypeOf(value);
129
+ return (prototype === Object.prototype || prototype === this.prototype) && typeof value.then !== 'function';
130
+ }
131
+ }
97
132
  // ---------------------------------------------------------------------------
98
133
  // Runtime helpers used by the generated code
99
134
  // ---------------------------------------------------------------------------
@@ -131,6 +166,46 @@ const helpers = {
131
166
  const descriptor = getPropertyDescriptor(prototype, key);
132
167
  return !!(descriptor && !descriptor.set);
133
168
  },
169
+ /**
170
+ * Returns the compiled transformer to call directly for objects of given (resolved) type, or null when
171
+ * TransformOperationExecutor#transform would not take its object branch with this type as target.
172
+ */
173
+ resolveChild(executor, type) {
174
+ if (typeof type !== 'function' || type === String || type === Number || type === Boolean || type === Date) {
175
+ return null;
176
+ }
177
+ if (!!getGlobal().Buffer && type === Buffer)
178
+ return null;
179
+ const jit = executor.jit;
180
+ return (jit && jit.get(type, executor)) || null;
181
+ },
182
+ /**
183
+ * Prototype of the instances that can be passed directly to the compiled transformer of given type, besides plain
184
+ * objects: null when instances of the type are arrays, sets, dates, maps or buffers (handled by other branches).
185
+ */
186
+ directPrototype(type) {
187
+ const prototype = type.prototype;
188
+ if (!prototype)
189
+ return null;
190
+ const excluded = [Array, Set, Date, Map];
191
+ if (getGlobal().Buffer)
192
+ excluded.push(Buffer);
193
+ for (const cls of excluded) {
194
+ if (prototype === cls.prototype || prototype instanceof cls)
195
+ return null;
196
+ }
197
+ return prototype;
198
+ },
199
+ /** Same as instantiateArrayType in TransformOperationExecutor. */
200
+ newArray(arrayType) {
201
+ if (!arrayType)
202
+ return [];
203
+ const array = new arrayType();
204
+ if (!(array instanceof Set) && !('push' in array)) {
205
+ return [];
206
+ }
207
+ return array;
208
+ },
134
209
  prefixBlocked(key, prefixes) {
135
210
  return !prefixes.every(prefix => key.substr(0, prefix.length) !== prefix);
136
211
  },
@@ -233,6 +308,9 @@ function compile(target, executor) {
233
308
  };
234
309
  const str = (value) => JSON.stringify(value);
235
310
  let labelCounter = 0;
311
+ // per call site caches of the last resolved child type => compiled transformer
312
+ const siteDeclarations = [];
313
+ const circularCheck = !!options.enableCircularCheck;
236
314
  // custom @Transform() functions applied to a key, filtered exactly like applyCustomTransformations
237
315
  const getTransforms = (key) => {
238
316
  let metadatas = storage.findTransformMetadatas(target, key, transformationType);
@@ -255,8 +333,11 @@ function compile(target, executor) {
255
333
  return options.exposeUnsetFields ? assign : `if (fv !== undefined) { ${assign} }\n`;
256
334
  };
257
335
  /**
258
- * Transformation of `fv` (sub value) into `fv`: primitives are converted inline,
259
- * everything else goes through TransformOperationExecutor#transform.
336
+ * Transformation of `fv` (sub value) into `fv`, same as TransformOperationExecutor#transform:
337
+ * - primitives are converted inline,
338
+ * - plain objects (or instances of the target type) and arrays of them, when the type has a compiled transformer,
339
+ * are passed directly to that compiled transformer,
340
+ * - everything else goes through TransformOperationExecutor#transform.
260
341
  */
261
342
  const emitChild = (typeExpr, kind, arrayTypeExpr, isMapExpr, valueKeyExpr) => {
262
343
  let primitive;
@@ -280,8 +361,46 @@ function compile(target, executor) {
280
361
  default:
281
362
  primitive = isMapExpr === 'true' ? 'fv' : `(${isMapExpr} ? fv : H.conv(fv, ${typeExpr}))`;
282
363
  }
364
+ const slow = `fv = ex.transform(source ? source[${valueKeyExpr}] : undefined, fv, ${typeExpr}, ${arrayTypeExpr}, ${isMapExpr}, level + 1);`;
365
+ // types which can never have a compiled transformer: no direct call
366
+ if (kind !== 'none' && kind !== 'dynamic') {
367
+ return `if (typeof fv !== 'object' || fv === null) { fv = ${primitive}; }\nelse { ${slow} }\n`;
368
+ }
369
+ if (typeExpr === 'undefined') {
370
+ return `if (typeof fv !== 'object' || fv === null) { fv = ${primitive}; }\nelse { ${slow} }\n`;
371
+ }
372
+ const site = String(siteDeclarations.length);
373
+ const sT = 'sT' + site; // last type seen at this call site
374
+ const sF = 'sF' + site; // its compiled transformer (null: not directly callable)
375
+ const sP = 'sP' + site; // prototype of instances which can be passed directly
376
+ siteDeclarations.push(`let ${sT} = UNSET, ${sF} = null, ${sP} = null;\n`);
377
+ const callDirect = (valueExpr, levelExpr) => circularCheck
378
+ ? `(ex.recursionStack.add(${valueExpr}), r = ${sF}(ex, undefined, ${valueExpr}, ${levelExpr}), ex.recursionStack.delete(${valueExpr}), r)`
379
+ : `${sF}(ex, undefined, ${valueExpr}, ${levelExpr})`;
380
+ const isDirect = (valueExpr) => `((pp = Object.getPrototypeOf(${valueExpr})) === OP || pp === ${sP}) && typeof ${valueExpr}.then !== 'function'`;
381
+ // array branch of TransformOperationExecutor#transform, with forEach and the element type checks unrolled
382
+ const newArray = isPlainToClass && arrayTypeExpr !== 'undefined' ? `H.newArray(${arrayTypeExpr})` : '[]';
383
+ const add = (valueExpr) => newArray === '[]' ? `arr.push(${valueExpr});` : `if (isSet) arr.add(${valueExpr}); else arr.push(${valueExpr});`;
384
+ let arrayCode = `const n = fv.length;\nconst arr = ${newArray};\n` +
385
+ (newArray === '[]' ? '' : 'const isSet = arr instanceof Set;\n') +
386
+ `for (let j = 0; j < n; j++) {\nif (!(j in fv)) continue;\nconst el = fv[j];\n`;
387
+ if (circularCheck) {
388
+ arrayCode += `if (ex.recursionStack.has(el)) { ${isClassToClass ? add('el') : ''} continue; }\n`;
389
+ }
390
+ arrayCode +=
391
+ `let r;\n` +
392
+ `if (typeof el !== 'object' || el === null) r = el;\n` +
393
+ `else if (${isDirect('el')}) r = ${callDirect('el', 'level + 2')};\n` +
394
+ `else r = ex.transform(undefined, el, t, undefined, el instanceof Map, level + 2);\n` +
395
+ `${add('r')}\n}\nfv = arr;\n`;
283
396
  return (`if (typeof fv !== 'object' || fv === null) { fv = ${primitive}; }\n` +
284
- `else { fv = ex.transform(source ? source[${valueKeyExpr}] : undefined, fv, ${typeExpr}, ${arrayTypeExpr}, ${isMapExpr}, level + 1); }\n`);
397
+ `else {\nconst t = ${typeExpr};\n` +
398
+ `if (t !== ${sT}) { ${sT} = t; ${sF} = H.resolveChild(ex, t); ${sP} = ${sF} === null ? null : H.directPrototype(t); }\n` +
399
+ `let pp, r;\n` +
400
+ `if (${sF} === null || source) { ${slow} }\n` +
401
+ `else if (Array.isArray(fv) && fv.forEach === AFE) {\n${arrayCode}}\n` +
402
+ `else if (!${isMapExpr} && ${isDirect('fv')}) { fv = ${callDirect('fv', 'level + 1')}; }\n` +
403
+ `else { ${slow} }\n}\n`);
285
404
  };
286
405
  /**
287
406
  * Generates the transformation of a single key. `key` is the static key, or undefined for the
@@ -370,10 +489,15 @@ function compile(target, executor) {
370
489
  // skip keys matching a getter / method of the new value
371
490
  if (createsInstance) {
372
491
  const staticSkip = key === undefined ? `H.descSkip(proto, key)` : String(helpers.descSkip(targetPrototype, newValueKey));
492
+ const descriptorSkip = staticSkip === 'false'
493
+ ? `(!protoIsTarget && H.descSkip(proto, ${newKeyExpr}))`
494
+ : staticSkip === 'true'
495
+ ? `(protoIsTarget || H.descSkip(proto, ${newKeyExpr}))`
496
+ : `(protoIsTarget ? ${staticSkip} : H.descSkip(proto, ${newKeyExpr}))`;
497
+ // `newValue.constructor.prototype` is read once per object, but must throw here like the interpreter
373
498
  code +=
374
- `const proto = newValue.constructor.prototype;\n` +
375
- `if (proto && ((proto === ${ref(targetPrototype)} ? ${staticSkip} : H.descSkip(proto, ${newKeyExpr})) ` +
376
- `|| newValue[${newKeyExpr}] instanceof Function)) break ${label};\n`;
499
+ `if (nvc == null) newValue.constructor.prototype;\n` +
500
+ `if (proto && (${descriptorSkip} || newValue[${newKeyExpr}] instanceof Function)) break ${label};\n`;
377
501
  }
378
502
  const transforms = key === undefined ? [] : getTransforms(transformKey);
379
503
  let main = 'let fv;\n';
@@ -415,6 +539,11 @@ function compile(target, executor) {
415
539
  // keys always transformed (exposed properties), or all keys when they are not dynamic
416
540
  const staticKeys = ex.getKeys(target, {}, false);
417
541
  let body = `const newValue = source ? source : ${createsInstance && target ? `new ${ref(target)}()` : '{}'};\nconst nvm = newValue instanceof Map;\n`;
542
+ if (createsInstance) {
543
+ body +=
544
+ `const nvc = newValue.constructor;\nconst proto = nvc == null ? undefined : nvc.prototype;\n` +
545
+ `const protoIsTarget = proto === ${ref(targetPrototype)};\n`;
546
+ }
418
547
  if (!dynamicKeys) {
419
548
  for (const key of staticKeys)
420
549
  body += emitKey(key);
@@ -433,15 +562,18 @@ function compile(target, executor) {
433
562
  knownKeys.delete('constructor');
434
563
  const extraKeys = staticKeys.filter(key => key !== '__proto__' && key !== 'constructor');
435
564
  // exposed keys missing from the object are transformed after the object keys
565
+ // set when the key is found in the object keys
436
566
  extraKeys.forEach((key, index) => {
437
- body += `const has${String(index)} = PIE.call(value, ${str(key)});\n`;
567
+ body += `let has${String(index)} = false;\n`;
438
568
  });
439
569
  let cases = `case "__proto__": case "constructor": continue;\n`;
440
570
  knownKeys.forEach(key => {
441
571
  const probe = {};
442
572
  probe[key] = true;
443
573
  const blocked = !ex.getKeys(target, probe, false).includes(key);
444
- cases += blocked ? `case ${str(key)}: continue;\n` : `case ${str(key)}: ${emitKey(key)}continue;\n`;
574
+ const extraIndex = extraKeys.indexOf(key);
575
+ const seen = extraIndex === -1 ? '' : `has${String(extraIndex)} = true;\n`;
576
+ cases += blocked ? `case ${str(key)}: continue;\n` : `case ${str(key)}: ${seen}${emitKey(key)}continue;\n`;
445
577
  });
446
578
  body += `const keys = Object.keys(value);\n`;
447
579
  body += `for (let i = 0; i < keys.length; i++) {\nconst key = keys[i];\nswitch (key) {\n${cases}}\n`;
@@ -456,8 +588,7 @@ function compile(target, executor) {
456
588
  }
457
589
  body += 'return newValue;\n';
458
590
  const declarations = constants.map((_, index) => `const k${index} = K[${index}];\n`).join('');
459
- const source = `'use strict';\n${declarations}const PIE = Object.prototype.propertyIsEnumerable;\n` +
460
- `return function compiledTransform(ex, source, value, level) {\n${body}};`;
591
+ const source = `'use strict';\n${declarations}const OP = Object.prototype;\nconst AFE = Array.prototype.forEach;\nconst UNSET = {};\n${siteDeclarations.join('')}` + `return function compiledTransform(ex, source, value, level) {\n${body}};`;
461
592
  // eslint-disable-next-line @typescript-eslint/no-implied-eval
462
593
  const factory = new Function('K', 'H', source);
463
594
  return factory(constants, helpers);