@digicms/cms
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
25 lines (17 loc) • 538 B
JavaScript
;
const { cloneDeep, camelCase } = require('lodash/fp');
const { validateComponentDefinition } = require('./validator');
const createComponent = (definition = {}) => {
validateComponentDefinition(definition);
const createdComponent = cloneDeep(definition);
const category = camelCase(definition.info.category);
const uid = `${category}.${definition.info.singularModelName}`;
Object.assign(createdComponent, {
uid,
category,
});
return createdComponent;
};
module.exports = {
createComponent,
};