UNPKG

@awhere/api

Version:

The awesome aWhere API for JavaScript.

54 lines 1.73 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var randomstring_1 = __importDefault(require("randomstring")); var FieldDefinition = /** @class */ (function () { function FieldDefinition(field) { if (field === null || field === void 0 ? void 0 : field._id) { this._id = field._id; } else { this._id = FieldDefinition.generateId(); } if (field !== undefined) { if (field._id) { this._id = field._id; } if (!field.name) { throw new Error('name is required.'); } this.name = field.name; if (!field.type) { throw new Error('type is required.'); } this.type = field.type; this.props = field.props; } if (!this.props) { this.props = { readonly: false, deletable: true, hidden: false, }; } else { if (this.props.readonly == null) { this.props.readonly = false; } if (this.props.deletable == null) { this.props.deletable = true; } if (this.props.hidden == null) { this.props.hidden = false; } } } FieldDefinition.generateId = function () { return randomstring_1.default.generate(8); }; return FieldDefinition; }()); exports.default = FieldDefinition; //# sourceMappingURL=FieldDefinition.js.map