strapi-utils
Advanced tools
Comparing version 3.1.6 to 3.1.7
'use strict'; | ||
const _ = require('lodash'); | ||
const { sanitizeEntity } = require('../sanitize-entity'); | ||
const sanitizeEntity = require('../sanitize-entity'); | ||
@@ -43,2 +43,3 @@ describe('Sanitize Entity', () => { | ||
}, | ||
privateAttributes: ['email'], | ||
attributes: { | ||
@@ -87,2 +88,3 @@ email: { | ||
}, | ||
privateAttributes: ['secret'], | ||
attributes: { | ||
@@ -212,13 +214,6 @@ name: { | ||
}, | ||
privateAttributes: [].concat(models.user.privateAttributes, ['firstname'], ['id']), | ||
}; | ||
test.each(tests)(`Test n°%#`, (options, expected) => { | ||
global.strapi = { | ||
config: { | ||
get: jest.fn(path => { | ||
return path === 'api.responses.privateAttributes' ? ['id'] : []; | ||
}), | ||
}, | ||
}; | ||
expect(sanitizeEntity(input, { ...options, model })).toStrictEqual(expected); | ||
@@ -225,0 +220,0 @@ }); |
@@ -9,3 +9,3 @@ 'use strict'; | ||
const parseMultipartData = require('./parse-multipart'); | ||
const { sanitizeEntity, getPrivateAttributes } = require('./sanitize-entity'); | ||
const sanitizeEntity = require('./sanitize-entity'); | ||
const parseType = require('./parse-type'); | ||
@@ -29,2 +29,3 @@ const finder = require('./finder'); | ||
const { generateTimestampCode } = require('./code-generator'); | ||
const contentTypes = require('./content-types'); | ||
@@ -45,3 +46,2 @@ module.exports = { | ||
sanitizeEntity, | ||
getPrivateAttributes, | ||
parseType, | ||
@@ -59,2 +59,3 @@ nameToSlug, | ||
stringEquals, | ||
contentTypes, | ||
}; |
'use strict'; | ||
const _ = require('lodash'); | ||
const { isPrivateAttribute } = require('./content-types'); | ||
@@ -123,16 +124,5 @@ const sanitizeEntity = (dataSource, options) => { | ||
const getPrivateAttributes = model => { | ||
const allPrivatesAttributes = _.union( | ||
strapi.config.get('api.responses.privateAttributes', []), | ||
_.get(model, 'options.privateAttributes', []) | ||
); | ||
return allPrivatesAttributes; | ||
}; | ||
const shouldRemoveAttribute = (model, key, attribute = {}, { withPrivate, isOutput }) => { | ||
const privateAttributes = getPrivateAttributes(model); | ||
const isPassword = attribute.type === 'password'; | ||
const isPrivate = attribute.private === true || privateAttributes.includes(key); | ||
const isPrivate = isPrivateAttribute(model, key); | ||
@@ -145,5 +135,2 @@ const shouldRemovePassword = isOutput; | ||
module.exports = { | ||
sanitizeEntity, | ||
getPrivateAttributes, | ||
}; | ||
module.exports = sanitizeEntity; |
{ | ||
"name": "strapi-utils", | ||
"version": "3.1.6", | ||
"version": "3.1.7", | ||
"description": "Shared utilities for the Strapi packages", | ||
@@ -48,3 +48,3 @@ "homepage": "http://strapi.io", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"gitHead": "3c7c33eab7bc35c60237646b41699b991fb62ff0" | ||
"gitHead": "564f9228ca236f310d54e0ed94deee750f52301e" | ||
} |
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
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
84131
30
2451