@@ -6,6 +6,7 @@ import { getLogger } from "../Utility/LogUtil";
66import { StringUtil } from "../Utility/StringUtil" ;
77import { DocumentConventions } from "../Documents/Conventions/DocumentConventions" ;
88import { ObjectUtil } from "../Utility/ObjectUtil" ;
9+ import { CONSTANTS } from "../Constants" ;
910
1011const log = getLogger ( { module : "ObjectMapper" } ) ;
1112
@@ -379,29 +380,38 @@ export class TypesAwareObjectMapper implements ITypesAwareObjectMapper {
379380 obj : object ,
380381 objPathPrefix : string ,
381382 typeInfoCallback : ( types : NestedTypes ) => void ,
382- knownTypes : ObjectTypeDescriptor [ ] ) : any {
383+ knownTypes : ObjectTypeDescriptor [ ] ,
384+ skipTypes : boolean = false ) : any {
383385
384386 if ( TypeUtil . isDate ( obj ) ) {
385- typeInfoCallback ( {
386- [ objPathPrefix ] : "date"
387- } ) ;
387+ if ( ! skipTypes ) {
388+ typeInfoCallback ( {
389+ [ objPathPrefix ] : "date"
390+ } ) ;
391+ }
388392
389393 return this . _conventions . dateUtil . stringify ( obj as Date ) ;
390394 }
391395
392396 if ( TypeUtil . isSet ( obj ) ) {
393- typeInfoCallback ( {
394- [ objPathPrefix ] : "Set"
395- } ) ;
397+ if ( ! skipTypes ) {
398+ typeInfoCallback ( {
399+ [ objPathPrefix ] : "Set"
400+ } ) ;
401+ }
402+
396403 const newObjPathPrefix = `${ objPathPrefix } $SET` ;
397404 return Array . from ( ( obj as Set < any > ) )
398405 . map ( x => this . _makeObjectLiteral ( x , newObjPathPrefix , typeInfoCallback , knownTypes ) ) ;
399406 }
400407
401408 if ( TypeUtil . isMap ( obj ) ) {
402- typeInfoCallback ( {
403- [ objPathPrefix ] : "Map"
404- } ) ;
409+ if ( ! skipTypes ) {
410+ typeInfoCallback ( {
411+ [ objPathPrefix ] : "Map"
412+ } ) ;
413+ }
414+
405415 const valuePathPrefix = `${ objPathPrefix } $MAP` ;
406416 const map = obj as Map < any , any > ;
407417 return Array . from ( map . entries ( ) ) . reduce ( ( result , [ name , value ] ) => {
@@ -423,7 +433,8 @@ export class TypesAwareObjectMapper implements ITypesAwareObjectMapper {
423433 if ( TypeUtil . isObject ( obj ) ) {
424434 if ( objPathPrefix ) { // if it's non-root object
425435 const matchedType = TypeUtil . findType ( obj , knownTypes ) ;
426- if ( matchedType
436+ if ( ! skipTypes
437+ && matchedType
427438 && matchedType . name !== "Function" ) {
428439 typeInfoCallback ( { [ objPathPrefix ] : matchedType . name } ) ;
429440 }
@@ -436,8 +447,12 @@ export class TypesAwareObjectMapper implements ITypesAwareObjectMapper {
436447 nestedTypeInfoKey = ObjectUtil [ this . _conventions . remoteEntityFieldNameConvention ] ( key ) ;
437448 }
438449
450+ if ( ! skipTypes ) {
451+ skipTypes = key === CONSTANTS . Documents . Metadata . KEY ;
452+ }
453+
439454 const fullPath = objPathPrefix ? `${ objPathPrefix } .${ nestedTypeInfoKey } ` : nestedTypeInfoKey ;
440- result [ key ] = this . _makeObjectLiteral ( obj [ key ] , fullPath , typeInfoCallback , knownTypes ) ;
455+ result [ key ] = this . _makeObjectLiteral ( obj [ key ] , fullPath , typeInfoCallback , knownTypes , skipTypes ) ;
441456 return result ;
442457 } , { } ) ;
443458 }
0 commit comments