Add kind in bootstrap and relations can only be created with collection types

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre Bodin 2020-01-15 15:57:12 +01:00
parent 57122c4acb
commit 88a5a0a654
2 changed files with 7 additions and 4 deletions

View File

@ -2,14 +2,14 @@
const yup = require('yup');
const { validators, isValidName } = require('./common');
const { typeKinds } = require('./constants');
const REVERSE_RELATIONS = ['oneToOne', 'oneToMany', 'manyToOne', 'manyToMany'];
module.exports = (obj, validNatures) => {
const contentTypesUIDs = Object.keys(strapi.contentTypes).concat([
'__self__',
'__contentType__',
]);
const contentTypesUIDs = Object.keys(strapi.contentTypes)
.filter(key => strapi.contentTypes[key].kind === typeKinds.COLLECTION_TYPE)
.concat(['__self__', '__contentType__']);
return {
target: yup

View File

@ -79,6 +79,7 @@ module.exports = function(strapi) {
uid: `application::${apiName}.${modelName}`,
apiName,
modelName,
kind: model.kind || 'collectionType',
globalId: model.globalId || _.upperFirst(_.camelCase(modelName)),
collectionName:
model.collectionName || `${modelName}`.toLocaleLowerCase(),
@ -157,6 +158,7 @@ module.exports = function(strapi) {
Object.assign(model, {
__schema__: pickSchema(model),
modelType: 'contentType',
kind: model.kind || 'collectionType',
uid: `strapi::${key}`,
plugin: 'admin',
modelName: key,
@ -192,6 +194,7 @@ module.exports = function(strapi) {
Object.assign(model, {
__schema__: pickSchema(model),
modelType: 'contentType',
kind: model.kind || 'collectionType',
modelName: key,
uid: `plugins::${pluginName}.${key}`,
plugin: pluginName,