-
Notifications
You must be signed in to change notification settings - Fork 0
/
decorators.js.map
1 lines (1 loc) · 7.13 KB
/
decorators.js.map
1
{"version":3,"sources":["../../src/decorators.ts"],"names":[],"mappings":";;AAAA,uDAAoD;AACpD,qCAAiD;AACjD,wDAAqD;AACrD,4DAAyD;AAEzD,8DAA2D;AAC3D,kEAA+D;AAI/D;;GAEG;AACH,mBAA0B,WAAkF,EAAE,OAA0B;IACpI,MAAM,CAAC,UAAS,MAAW,EAAE,GAAW;QACpC,IAAM,QAAQ,GAAG,IAAI,qCAAiB,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACtF,gCAAsB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC,CAAC;AACN,CAAC;AALD,8BAKC;AAED;;GAEG;AACH,cAAqB,YAA+C;IAChE,MAAM,CAAC,UAAS,MAAW,EAAE,GAAW;QACpC,IAAM,IAAI,GAAI,OAAe,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACtE,IAAM,QAAQ,GAAG,IAAI,2BAAY,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAC/E,gCAAsB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC,CAAC;AACN,CAAC;AAND,oBAMC;AAED;;;;GAIG;AACH,gBAAuB,OAAuB;IAC1C,MAAM,CAAC,UAAS,MAAuB,EAAE,YAAqB;QAC1D,IAAM,QAAQ,GAAG,IAAI,+BAAc,CAAC,MAAM,YAAY,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;QAC3H,gCAAsB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC,CAAC;AACN,CAAC;AALD,wBAKC;AAED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U,MAAgB,EAAE,WAAmB,EAAE,UAA8B;QAClF,IAAM,gBAAgB,GAAqB,IAAI,mCAAgB,EAAE,CAAC;QAClE,IAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG;YAAS,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YACtC,IAAM,MAAM,GAAQ,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACrD,IAAM,SAAS,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,UAAU,CAAC,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC;YAEhI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAC,IAAS,IAAK,OAAA,gBAAgB,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAA3C,CAA2C,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/I,CAAC,CAAC;IACN,CAAC,CAAC;AACN,CAAC;AAbD,sDAaC","file":"decorators.js","sourcesContent":["import {ClassTransformer} from \"./ClassTransformer\";\r\nimport {defaultMetadataStorage} from \"./storage\";\r\nimport {TypeMetadata} from \"./metadata/TypeMetadata\";\r\nimport {ExposeMetadata} from \"./metadata/ExposeMetadata\";\r\nimport {ExposeOptions, ExcludeOptions, TypeOptions, TransformOptions} from \"./metadata/ExposeExcludeOptions\";\r\nimport {ExcludeMetadata} from \"./metadata/ExcludeMetadata\";\r\nimport {TransformMetadata} from \"./metadata/TransformMetadata\";\r\nimport {ClassTransformOptions} from \"./ClassTransformOptions\";\r\nimport {TransformationType} from \"./TransformOperationExecutor\";\r\n\r\n/**\r\n * Defines a custom logic for value transformation.\r\n */\r\nexport function Transform(transformFn: (value: any, obj: any, transformationType: TransformationType) => any, options?: TransformOptions) {\r\n return function(target: any, key: string) {\r\n const metadata = new TransformMetadata(target.constructor, key, transformFn, options);\r\n defaultMetadataStorage.addTransformMetadata(metadata);\r\n };\r\n}\r\n\r\n/**\r\n * Specifies a type of the property.\r\n */\r\nexport function Type(typeFunction?: (type?: TypeOptions) => Function) {\r\n return function(target: any, key: string) {\r\n const type = (Reflect as any).getMetadata(\"design:type\", target, key);\r\n const metadata = new TypeMetadata(target.constructor, key, type, typeFunction);\r\n defaultMetadataStorage.addTypeMetadata(metadata);\r\n };\r\n}\r\n\r\n/**\r\n * Marks property as included in the process of transformation. By default it includes the property for both\r\n * constructorToPlain and plainToConstructor transformations, however you can specify on which of transformation types\r\n * you want to skip this property.\r\n */\r\nexport function Expose(options?: ExposeOptions) {\r\n return function(object: Object|Function, propertyName?: string) {\r\n const metadata = new ExposeMetadata(object instanceof Function ? object : object.constructor, propertyName, options || {});\r\n defaultMetadataStorage.addExposeMetadata(metadata);\r\n };\r\n}\r\n\r\n/**\r\n * Marks property as excluded from the process of transformation. By default it excludes the property for both\r\n * constructorToPlain and plainToConstructor transformations, however you can specify on which of transformation types\r\n * you want to skip this property.\r\n */\r\nexport function Exclude(options?: ExcludeOptions) {\r\n return function(object: Object|Function, propertyName?: string) {\r\n const metadata = new ExcludeMetadata(object instanceof Function ? object : object.constructor, propertyName, options || {});\r\n defaultMetadataStorage.addExcludeMetadata(metadata);\r\n };\r\n}\r\n\r\n/**\r\n * Transform the object from class to plain object and return only with the exposed properties.\r\n */\r\nexport function TransformClassToPlain(params?: ClassTransformOptions): Function {\r\n\r\n return function (target: Function, propertyKey: string, descriptor: PropertyDescriptor) {\r\n const classTransformer: ClassTransformer = new ClassTransformer();\r\n const originalMethod = descriptor.value;\r\n\r\n descriptor.value = function(...args: any[]) {\r\n const result: any = originalMethod.apply(this, args);\r\n const isPromise = !!result && (typeof result === \"object\" || typeof result === \"function\") && typeof result.then === \"function\";\r\n\r\n return isPromise ? result.then((data: any) => classTransformer.classToPlain(data, params)) : classTransformer.classToPlain(result, params);\r\n };\r\n };\r\n}\r\n\r\n/**\r\n * Return the class instance only with the exposed properties.\r\n */\r\nexport function TransformClassToClass(params?: ClassTransformOptions): Function {\r\n\r\n return function (target: Function, propertyKey: string, descriptor: PropertyDescriptor) {\r\n const classTransformer: ClassTransformer = new ClassTransformer();\r\n const originalMethod = descriptor.value;\r\n\r\n descriptor.value = function(...args: any[]) {\r\n const result: any = originalMethod.apply(this, args);\r\n const isPromise = !!result && (typeof result === \"object\" || typeof result === \"function\") && typeof result.then === \"function\";\r\n\r\n return isPromise ? result.then((data: any) => classTransformer.classToClass(data, params)) : classTransformer.classToClass(result, params);\r\n };\r\n };\r\n}\r\n"],"sourceRoot":"."}