UNPKG

kentico-cloud-delivery

Version:

Official Kentico Cloud Delivery SDK

31 lines 1.23 kB
"use strict"; exports.__esModule = true; require("reflect-metadata"); var FieldDecorators; (function (FieldDecorators) { var codenameMetadataKey = Symbol('codename'); var generateKey = function (name) { return codenameMetadataKey.toString() + ":" + name; }; /** * Get the metadata entry saved by the decorator * @param target - object instance * @param fieldName - field name (code name from Kentico Cloud) */ function getPropertyName(target, fieldName) { return Reflect.getMetadata(generateKey(fieldName), target); } FieldDecorators.getPropertyName = getPropertyName; /** * Decorator - reates metadata entry for the @target - Value is the property name. * This will then be retrieved in the FieldMap service when resolving the field name * @param value - field code name */ function codename(value) { return function (target, propertyKey) { Reflect.defineMetadata(generateKey(value), propertyKey, target); }; } FieldDecorators.codename = codename; })(FieldDecorators = exports.FieldDecorators || (exports.FieldDecorators = {})); //# sourceMappingURL=field-decorators.js.map