import { getFieldTypeName, isEditor } from './utils';
export function DefineField(field) {
    return (target, name) => {
        var _a, _b;
        if (!isEditor()) {
            return;
        }
        if (!Reflect.hasOwnMetadata('schema:fields', target.constructor)) {
            Reflect.defineMetadata('schema:fields', [], target.constructor);
        }
        const type = getFieldTypeName(Reflect.getMetadata('design:type', target, name));
        const fields = Reflect.getMetadata('schema:fields', target.constructor);
        fields.push(Object.assign(Object.assign({}, field), { name: (_a = field === null || field === void 0 ? void 0 : field.name) !== null && _a !== void 0 ? _a : name, type: (_b = field === null || field === void 0 ? void 0 : field.type) !== null && _b !== void 0 ? _b : type }));
    };
}
