When I console.log(allApisSchemas) there seems to be an empty schema:
const validateContentTypesUnicity = apis => {
const allApisSchemas = Object.values(apis).flatMap(api => Object.values(api.contentTypes));
**console.log(allApisSchemas)**
const names = [];
allApisSchemas.forEach(({ schema }) => {
// console.log(Object.keys(schema))
if (schema.info.singularName) {
const singularName = _.kebabCase(schema.info.singularName);
if (names.includes(singularName)) {
throw new Error(`The singular name "${schema.info.singularName}" should be unique`);
}
names.push(singularName);
}
if (schema.info.pluralName) {
const pluralName = _.kebabCase(schema.info.pluralName);
if (names.includes(pluralName)) {
throw new Error(`The plural name "${schema.info.pluralName}" should be unique`);
}
names.push(pluralName);
}
});
};
[
{
schema: {
kind: 'collectionType',
collectionName: 'authors',
info: [Object],
options: [Object],
pluginOptions: {},
attributes: [Object]
},
actions: {},
lifecycles: {}
},
{
lifecycles: { afterCreate: [AsyncFunction: afterCreate] },
schema: {
kind: 'collectionType',
collectionName: 'blogs',
info: [Object],
options: [Object],
pluginOptions: [Object],
attributes: [Object]
},
actions: {}
},
{
lifecycles: {},
schema: {
kind: 'collectionType',
collectionName: 'categories',
info: [Object],
options: [Object],
pluginOptions: [Object],
attributes: [Object]
},
actions: {}
},
{
schema: {
kind: 'collectionType',
collectionName: 'comments',
info: [Object],
options: [Object],
pluginOptions: {},
attributes: [Object]
},
actions: {},
lifecycles: {}
},
{
schema: {
kind: 'singleType',
collectionName: 'globals',
info: [Object],
options: [Object],
pluginOptions: [Object],
attributes: [Object]
},
actions: {},
lifecycles: {}
},
{
schema: {
kind: 'collectionType',
collectionName: 'helps',
info: [Object],
options: [Object],
pluginOptions: [Object],
attributes: [Object]
},
actions: {},
lifecycles: {}
},
{
schema: {
kind: 'collectionType',
collectionName: 'help_categories',
info: [Object],
options: [Object],
pluginOptions: [Object],
attributes: [Object]
},
actions: {},
lifecycles: {}
},
{
schema: {
kind: 'collectionType',
collectionName: 'landing_pages',
info: [Object],
options: [Object],
pluginOptions: [Object],
attributes: [Object]
},
actions: {},
lifecycles: {}
},
**{ schema: {}, actions: {}, lifecycles: {} },**
{
schema: {
kind: 'collectionType',
collectionName: 'tags',
info: [Object],
options: [Object],
pluginOptions: [Object],
attributes: [Object]
},
actions: {},
lifecycles: {}
}
]
This appears to be the root of the problem but I can’t see where this empty object is being generated from!