strapi-utils
Advanced tools
Comparing version 3.2.5 to 3.3.0
@@ -34,2 +34,3 @@ 'use strict'; | ||
const webhook = require('./webhook'); | ||
const env = require('./env-helper'); | ||
@@ -65,2 +66,3 @@ module.exports = { | ||
webhook, | ||
env, | ||
}; |
@@ -82,3 +82,7 @@ 'use strict'; | ||
attribute.collection | ||
)}\` is missing from the ${attribute.plugin ? '(plugin - ' + attribute.plugin + ')' : ''} models` | ||
)}\`, used in the attribute \`${attributeName}\` in the model ${_.upperFirst( | ||
modelName | ||
)}, is missing from the${ | ||
attribute.plugin ? ' (plugin - ' + attribute.plugin + ')' : '' | ||
} models` | ||
); | ||
@@ -92,3 +96,3 @@ } | ||
attribute.collection | ||
)} ${attribute.plugin ? '(plugin - ' + attribute.plugin + ')' : ''}` | ||
)}${attribute.plugin ? ' (plugin - ' + attribute.plugin + ')' : ''}` | ||
); | ||
@@ -115,2 +119,10 @@ } | ||
types.other = 'morphTo'; | ||
} else { | ||
throw new Error( | ||
`The attribute \`${ | ||
attribute.via | ||
}\` is not correctly configured in the model ${_.upperFirst(attribute.collection)}${ | ||
attribute.plugin ? ' (plugin - ' + attribute.plugin + ')' : '' | ||
}` | ||
); | ||
} | ||
@@ -121,5 +133,22 @@ } else if (_.has(attribute, 'via') && _.has(attribute, 'model')) { | ||
// We have to find if they are a model linked to this attributeName | ||
const model = models[attribute.model]; | ||
if (!_.has(models, attribute.model)) { | ||
throw new Error( | ||
`The model \`${_.upperFirst( | ||
attribute.model | ||
)}\`, used in the attribute \`${attributeName}\` in the model ${_.upperFirst( | ||
modelName | ||
)}, is missing from the${ | ||
attribute.plugin ? ' (plugin - ' + attribute.plugin + ')' : '' | ||
} models` | ||
); | ||
} | ||
const reverseAttribute = models[attribute.model].attributes[attribute.via]; | ||
const reverseAttribute = model.attributes[attribute.via]; | ||
if (!reverseAttribute) { | ||
throw new Error( | ||
`The attribute \`${attribute.via}\` is missing in the model ${_.upperFirst( | ||
attribute.model | ||
)}${attribute.plugin ? ' (plugin - ' + attribute.plugin + ')' : ''}` | ||
); | ||
} | ||
@@ -137,2 +166,10 @@ if ( | ||
types.other = 'morphTo'; | ||
} else { | ||
throw new Error( | ||
`The attribute \`${ | ||
attribute.via | ||
}\` is not correctly configured in the model ${_.upperFirst(attribute.model)}${ | ||
attribute.plugin ? ' (plugin - ' + attribute.plugin + ')' : '' | ||
}` | ||
); | ||
} | ||
@@ -181,2 +218,8 @@ } else if (_.has(attribute, 'model')) { | ||
}); | ||
} else { | ||
throw new Error( | ||
`The attribute \`${attributeName}\` is not correctly configured in the model ${_.upperFirst( | ||
modelName | ||
)}${attribute.plugin ? ' (plugin - ' + attribute.plugin + ')' : ''}` | ||
); | ||
} | ||
@@ -390,3 +433,3 @@ | ||
if ((attr.collection || attr.model || '').toLowerCase() === model.toLowerCase()) { | ||
acc.push(strapi.plugins[current].models[entity].globalId); | ||
acc.push(strapi.plugins[current].models[entity]); | ||
} | ||
@@ -404,3 +447,3 @@ }); | ||
if ((attr.collection || attr.model || '').toLowerCase() === model.toLowerCase()) { | ||
acc.push(strapi.models[entity].globalId); | ||
acc.push(strapi.models[entity]); | ||
} | ||
@@ -417,3 +460,3 @@ }); | ||
if ((attr.collection || attr.model || '').toLowerCase() === model.toLowerCase()) { | ||
acc.push(strapi.components[entity].globalId); | ||
acc.push(strapi.components[entity]); | ||
} | ||
@@ -425,3 +468,3 @@ }); | ||
const models = _.uniq(appModels.concat(pluginsModels).concat(componentModels)); | ||
const models = _.uniqWith(appModels.concat(pluginsModels, componentModels), _.isEqual); | ||
@@ -428,0 +471,0 @@ definition.associations.push({ |
{ | ||
"name": "strapi-utils", | ||
"version": "3.2.5", | ||
"version": "3.3.0", | ||
"description": "Shared utilities for the Strapi packages", | ||
@@ -48,3 +48,3 @@ "homepage": "http://strapi.io", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"gitHead": "c78591553f5509fcadc8c719f6af6f1bf0e734f3" | ||
"gitHead": "ec1c2a22c3b381eabe872535c01bd9bd8e874f5f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 14 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99704
33
2942
36