Socket
Socket
Sign inDemoInstall

strapi-utils

Package Overview
Dependencies
Maintainers
1
Versions
282
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strapi-utils - npm Package Compare versions

Comparing version 3.0.0-alpha.5.5 to 3.0.0-alpha.6

script/plugin-install.js

2

lib/finder.js

@@ -19,3 +19,3 @@ 'use strict';

if (_.isObject(controller) && controller.hasOwnProperty('identity')) {
controller = controller.identity;
controller = controller.identity.toLowerCase();
} else if (_.isString(controller)) {

@@ -22,0 +22,0 @@ controller = controller.toLowerCase();

@@ -75,3 +75,3 @@ 'use strict';

getNature: (association, key, models) => {
getNature: (association, key, models, currentModelName) => {
const types = {

@@ -102,3 +102,3 @@ current: '',

// We have to find if they are a model linked to this key
_.forIn(models, model => {
_.forIn(_.omit(models, currentModelName || ''), model => {
_.forIn(model.attributes, attribute => {

@@ -172,3 +172,3 @@ if (attribute.hasOwnProperty('via') && attribute.via === key && attribute.hasOwnProperty('collection')) {

};
} else if (types.current === 'model' && types.other === 'collection') {
} else if ((types.current === 'model' || types.current === 'modelD') && types.other === 'collection') {
return {

@@ -178,2 +178,7 @@ nature: 'oneToMany',

};
} else if (types.current === 'modelD' && types.other === 'collection') {
return {
nature: 'oneToMany',
verbose: 'belongsTo'
};
} else if (types.current === 'collection' && types.other === 'model') {

@@ -233,3 +238,4 @@ return {

// Get relation nature
const infos = this.getNature(association, key);
const infos = this.getNature(association, key, undefined, model.toLowerCase());
const details = _.get(strapi.models, `${association.model || association.collection}.attributes.${association.via}`, {});

@@ -244,3 +250,4 @@ // Build associations object

nature: infos.nature,
autoPopulate: (_.get(association, 'autoPopulate') || _.get(strapi.config, 'jsonapi.enabled')) === true
autoPopulate: (_.get(association, 'autoPopulate') || _.get(strapi.config, 'jsonapi.enabled')) === true,
dominant: details.dominant !== true
});

@@ -254,3 +261,4 @@ } else if (association.hasOwnProperty('model')) {

nature: infos.nature,
autoPopulate: (_.get(association, 'autoPopulate') || _.get(strapi.config, 'jsonapi.enabled')) === true
autoPopulate: (_.get(association, 'autoPopulate') || _.get(strapi.config, 'jsonapi.enabled')) === true,
dominant: details.dominant !== true
});

@@ -262,3 +270,57 @@ }

return _.findKey(strapi.models[association.model || association.collection].attributes, {via: attribute});
},
convertParams: (entity, params) => {
if (!entity) {
throw new Error('You can\'t call the convert params method without passing the model\'s name as a first argument.');
}
const model = entity.toLowerCase();
if (!strapi.models.hasOwnProperty(model)) {
return this.log.error(`The model ${model} can't be found.`);
}
const connector = strapi.models[model].orm;
if (!connector) {
throw new Error(`Impossible to determine the use ORM for the model ${model}.`);
}
const convertor = strapi.hook[connector].load().getQueryParams;
const convertParams = {
where: {},
sort: '',
start: 0,
limit: 100
};
_.forEach(params, (value, key) => {
let result;
if (_.includes(['_start', '_limit'], key)) {
result = convertor(value, key);
} else if (key === '_sort') {
const [attr, order] = value.split(':');
result = convertor(order, key, attr);
} else {
const suffix = key.split('_');
let type;
if (_.includes(['ne', 'lt', 'gt', 'lte', 'gte'], _.last(suffix))) {
type = `_${_.last(suffix)}`;
key = _.dropRight(suffix).join('_');
} else {
type = '=';
}
result = convertor(value, type, key);
}
_.set(convertParams, result.key, result.value);
});
return convertParams;
}
};
{
"name": "strapi-utils",
"version": "3.0.0-alpha.5.5",
"version": "3.0.0-alpha.6",
"description": "Shared utilities for the Strapi packages",

@@ -5,0 +5,0 @@ "homepage": "http://strapi.io",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc