UNPKG

37.7 kBSource Map (JSON)View Raw
1{"version":3,"file":"TransformOperationExecutor.js","sourceRoot":"","sources":["../../src/TransformOperationExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE/C,SAAS,oBAAoB,CAAC,SAAmB;IAC/C,IAAM,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;IAOE,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,oCAAoB,kBAAsC,EAAU,OAA8B;QAA9E,uBAAkB,GAAlB,kBAAkB,CAAoB;QAAU,YAAO,GAAP,OAAO,CAAuB;QAVlG,4EAA4E;QAC5E,qBAAqB;QACrB,4EAA4E;QAEpE,mBAAc,GAAG,IAAI,GAAG,EAAuB,CAAC;IAM6C,CAAC;IAEtG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,8CAAS,GAAT,UACE,MAAyD,EACzD,KAAwD,EACxD,UAAmC,EACnC,SAAmB,EACnB,KAAc,EACd,KAAiB;QANnB,iBAuUC;QAjUC,sBAAA,EAAA,SAAiB;QAEjB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,GAAG,EAAE;YAChD,IAAM,UAAQ,GACZ,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,kBAAkB,CAAC,cAAc;gBACxE,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC;gBACjC,CAAC,CAAC,EAAE,CAAC;YACR,KAAe,CAAC,OAAO,CAAC,U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,MAAM,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;gBACjD,CAAC,CAAC;YAFF,CAEE,CACH,CAAC;SACH;QAED,gCAAgC;QAChC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,KAAK,EAAE,IAAI;YAClC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,iDAAY,GAApB,UAAqB,KAAa,EAAE,KAAa;QAC/C,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,IAAI,QAAQ,IAAI,KAAK;YAAE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;QAChE,IAAI,QAAQ,IAAI,KAAK;YAAE,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAE/D,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,gDAAW,GAAnB,UAAoB,MAAgB;QAClC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAEzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAA,WAAW,IAAI,OAAA,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAA5B,CAA4B,CAAC,CAAC;IAC/E,CAAC;IACH,iCAAC;AAAD,CAAC,AAvfD,IAufC","sourcesContent":["import { defaultMetadataStorage } from './storage';\nimport { TypeHelpOptions, TypeOptions, ClassTransformOptions, TypeMetadata } from './interfaces';\nimport { TransformationType } from './enums';\nimport { getGlobal, isPromise } from './utils';\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\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(private transformationType: TransformationType, private options: ClassTransformOptions) {}\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 targetType = value.constructor;\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 const keys = this.getKeys(targetType as Function, 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 as Function, 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 as Function, 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 (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 // 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 as Function, 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 subValue[metadata.options.discriminator.property] = metadata.options.discriminator.subTypes.find(\n subType => subType.value === subValue.constructor\n ).name;\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(\n 'design:type',\n (targetType as Function).prototype,\n propertyName\n );\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])\n ? this.getReflectedType(targetType as Function, propertyName)\n : 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 = Object.getOwnPropertyDescriptor(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 as Function,\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 as Function,\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(\n finalValue,\n targetType as Function,\n key,\n value,\n this.transformationType\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 }\n }\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 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 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"]}
\No newline at end of file