@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,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;AAC/C,OAAO,EAAE,WAAW,EAAY,MAAM,qBAAqB,CAAC;AAE5D,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;IAQE,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,oCAAoB,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,WAAW,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,8CAAS,GAAT,UACE,MAAyD,EACzD,KAAwD,EACxD,UAAmC,EACnC,SAAmB,EACnB,KAAc,EACd,KAAiB;QANnB,iBAwIC;QAlIC,sBAAA,EAAA,SAAiB;QAEjB,IAAI,KAAK,CAAC,OAAO,CAA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,CAAC,WAAW,CAAC,EAA5B,CAA4B,CAAC,CAAC;IAC/E,CAAC;IAEO,0DAAqB,GAA7B,UAA8B,GAAQ,EAAE,GAAgB;QACtD,IAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC7D,IAAI,UAAU;YAAE,OAAO,UAAU,CAAC;QAElC,IAAM,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;IACH,iCAAC;AAAD,CAAC,AA1iBD,IA0iBC","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,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;AAC/C,OAAO,EAA0C,WAAW,EAAY,MAAM,qBAAqB,CAAC;AAEpG,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;IAQE,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,oCAAoB,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,WAAW,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,8CAAS,GAAT,UACE,MAAyD,EACzD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AqB,GAA7B,UAA8B,GAAQ,EAAE,GAAgB;QACtD,IAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC7D,IAAI,UAAU;YAAE,OAAO,UAAU,CAAC;QAElC,IAAM,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;IACH,iCAAC;AAAD,CAAC,AAtlBD,IAslBC","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hodfords/turbo-transformer",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Proper decorator-based transformation / serialization / deserialization of plain javascript objects to class constructors",
5
5
  "author": "TypeStack contributors",
6
6
  "license": "MIT",
@@ -31,9 +31,25 @@ export declare function getJitCache(transformationType: TransformationType, opti
31
31
  export declare class JitCache {
32
32
  private version;
33
33
  private classes;
34
+ private directs;
34
35
  private anonymous;
36
+ /**
37
+ * Returns the compiled transformer to call directly for elements of arrays of given type, or null.
38
+ */
39
+ direct(targetType: Function, executor: TransformOperationExecutor): DirectTransformer | null;
35
40
  /**
36
41
  * Returns the compiled transformer for given target type (undefined when it can not be compiled).
37
42
  */
38
43
  get(targetType: any, executor: TransformOperationExecutor): CompiledTransformer | undefined;
39
44
  }
45
+ /**
46
+ * Compiled transformer of a type, with the check of the values TransformOperationExecutor#transform would
47
+ * transform with it: plain objects and instances of the type which are not arrays, sets, dates, maps, buffers or
48
+ * promises.
49
+ */
50
+ export declare class DirectTransformer {
51
+ readonly transformer: CompiledTransformer;
52
+ private readonly prototype;
53
+ constructor(transformer: CompiledTransformer, prototype: any);
54
+ accepts(value: any): boolean;
55
+ }
@@ -7,6 +7,16 @@ export declare class TransformOperationExecutor {
7
7
  private jit;
8
8
  constructor(transformationType: TransformationType, options: ClassTransformOptions);
9
9
  transform(source: Record<string, any> | Record<string, any>[] | any, value: Record<string, any> | Record<string, any>[] | any, targetType: Function | TypeMetadata, arrayType: Function, isMap: boolean, level?: number): any;
10
+ /**
11
+ * Same as the forEach of the array branch of `transform`, when elements are transformed with a class having a
12
+ * compiled transformer (no source, no discriminator).
13
+ */
14
+ private transformArrayDirect;
15
+ /**
16
+ * Same as `transform(undefined, value, <type of the direct transformer>, undefined, false, level)`
17
+ * for a value accepted by the direct transformer.
18
+ */
19
+ private transformDirect;
10
20
  /**
11
21
  * Interpreted transformation of a single object, used when no compiled transformer is available.
12
22
  */