import { KEY_MODEL } from '../impl/model/model.decorator';
import { Metadata } from './metadata';
var MetadataHelper = /** @class */ (function () {
    function MetadataHelper() {
    }
    MetadataHelper.get = function (modelClass) {
        return new Metadata(modelClass);
    };
    MetadataHelper.forModel = function (modelClass) {
        var modelMetadata = Reflect.getMetadata(KEY_MODEL, modelClass);
        if (!modelMetadata) {
            throw new Error("make sure the @Model decorator is present on the model " + modelClass.name);
        }
        return modelMetadata;
    };
    /**
     *
     * @param {ModelConstructor<T>} modelClass
     * @param {keyof T} propertyKey Either the name of the property or the name of the
     * @returns {PropertyMetadata<T>}
     */
    MetadataHelper.forProperty = function (modelClass, propertyKey) {
        if (modelClass) {
            var modelMetadata = Reflect.getMetadata(KEY_MODEL, modelClass);
            if (modelClass && !modelMetadata) {
                throw new Error("make sure the @Model decorator was added to the given modelClass " + (Object.hasOwnProperty('name') ? modelClass.name : modelClass) + ", was not able to find model metadata");
            }
            var options = void 0;
            if (modelMetadata.properties) {
                options = modelMetadata.properties.find(function (property) { return property.name === propertyKey || property.nameDb === propertyKey; });
            }
            return options;
        }
        else {
            return null;
        }
    };
    return MetadataHelper;
}());
export { MetadataHelper };
//# sourceMappingURL=metadata-helper.js.map