const getForeignKey = (resourceName) => { const key = foreignKey(singularize(resourceName)); return `:${key}`; }
export default async function string(itemType, dato, apiKey, options = {}) { return dato.fields.create(itemType.id, { fieldType: 'string', apiKey, label: titleize(apiKey), ...options, }); }
const prepareResourceName = (resourceName, actionName) => { const shouldBePlural = ['index', 'create']; const modify = shouldBePlural.includes(actionName) ? pluralize : singularize; return modify(resourceName); }
function UserMessage(message, user) { const command = message.parsed['@'].replace('-', '_'); const methodName = Inflector.camelize(command, false); const commandMethod = CommandHandlers[methodName]; if (!commandMethod) { console.error('Invalid command', command, methodName); return; } commandMethod(user, GetRoom, message.parsed).catch(console.error); }
const getName = (prefix, parent, resourceName, actionName, actionPrefix = '') => { const parentPrefix = parent ? singularize(parent.resourceName) : ''; const preparedResourceName = prepareResourceName(resourceName, actionName); const words = [actionPrefix, prefix, parentPrefix, preparedResourceName].filter((w) => w).join('_'); return camelize(words, false); }
constructor (name, schema, db, opts) { opts = opts || {} this._db = db this._schema = schema this._name = name this._collName = opts.collName || inflected.pluralize(name).toLowerCase() this._opts = opts this._plugins = {} Query.bindQuery(this, mongodb.Collection) // alias this.create = this.insert this.index = this.createIndex _.defaults(this._plugins, this._db._plugins) }
firstUpperCase(str) { return Inflector.camelize(str); }
const migration = (tabName, structure) => { let tabNames = Inflector.pluralize(tabName); let result = ` 'use strict'; module.exports = { async up(queryInterface, Sequelize) { const { INTEGER, DATE, STRING,TEXT,BOOLEAN,DECIMAL } = Sequelize; await queryInterface.createTable('${tabNames}', ${structure}); }, async down(queryInterface) { await queryInterface.dropTable('${tabNames}'); } }; ` return result }
function _string() { _string = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(itemType, dato, apiKey) { var options, _args = arguments; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: options = _args.length > 3 && _args[3] !== undefined ? _args[3] : {}; return _context.abrupt("return", dato.fields.create(itemType.id, _objectSpread({ fieldType: 'string', apiKey: apiKey, label: (0, _inflected.titleize)(apiKey) }, options))); case 2: case "end": return _context.stop(); } } }, _callee); })); return _string.apply(this, arguments); }
getFilePath(packageName) { let PackageName = firstUpperCase(packageName); let packageNames = Inflector.pluralize(packageName); let modelFilePath = path.resolve(__dirname, `../model/${packageName}.js`); let migrationFilePath = path.resolve(__dirname, `../../database/migrations/${packageNames}.js`); let controllerFilePath = path.resolve(__dirname, `./${packageNames}.js`); let adminListPath = `admin/src/pages/${PackageName}`; let adminListJsFilePath = path.resolve(adminListPath, `${packageName}.js`); let adminListLessFilePath = path.resolve(adminListPath, `${packageName}.less`); let adminListmodelFilePath = path.resolve(adminListPath, `model.js`); let adminListServiceFilePath = path.resolve(adminListPath, `service.js`); let files = { modelFilePath, migrationFilePath, controllerFilePath, adminListJsFilePath, adminListLessFilePath, adminListmodelFilePath, adminListServiceFilePath, adminListPath }; return files; }
delete(routeName) { let packageName = this.ctx.request.body.packageName || routeName; let packageNames = Inflector.pluralize(packageName); let PackageName = firstUpperCase(packageName); let files = this.getFilePath(packageName);
function _text() { _text = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(itemType, dato, apiKey) { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", dato.fields.create(itemType.id, { apiKey: apiKey, label: (0, _inflected.titleize)(apiKey), appearance: { editor: 'wysiwyg', parameters: { toolbar: ['format', 'bold', 'italic', 'strikethrough', 'ordered_list', 'unordered_list', 'quote', 'table', 'link', 'image', 'show_source'] }, addons: [] }, fieldType: 'text' })); case 1: case "end": return _context.stop(); } } }, _callee); })); return _text.apply(this, arguments); }
export default async function text(itemType, dato, apiKey) { return dato.fields.create(itemType.id, { apiKey, label: titleize(apiKey), appearance: { editor: 'wysiwyg', parameters: { toolbar: [ 'format', 'bold', 'italic', 'strikethrough', 'ordered_list', 'unordered_list', 'quote', 'table', 'link', 'image', 'show_source', ], }, addons: [], }, fieldType: 'text', }); }