Socket
Socket
Sign inDemoInstall

strapi-utils

Package Overview
Dependencies
Maintainers
8
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.1.5 to 3.2.0-beta.0

lib/__tests__/content-types.test.js

20

lib/__tests__/convert-rest-query-params.test.js

@@ -153,2 +153,22 @@ const { convertRestQueryParams } = require('../convert-rest-query-params');

describe('Publication State param', () => {
test.each([
{ _publicationState: 'foobar' },
{ _publicationState: undefined },
{ _publicationState: null },
])('Throws on invalid params (%#)', params => {
expect(() => convertRestQueryParams(params)).toThrow();
});
test.each([
['Live Mode', { _publicationState: 'live' }],
['Preview Mode', { _publicationState: 'preview' }, []],
])('%s', (name, params) => {
const result = convertRestQueryParams(params);
expect(result._publicationState).toBeUndefined();
expect(result.publicationState).toBe(params._publicationState);
});
});
describe('Filters', () => {

@@ -155,0 +175,0 @@ test('Can combine filters', () => {

25

lib/convert-rest-query-params.js

@@ -7,2 +7,5 @@ /**

const _ = require('lodash');
const {
constants: { DP_PUB_STATES },
} = require('./content-types');

@@ -39,3 +42,7 @@ /**

const whereParams = _.omit(params, ['_sort', '_start', '_limit', '_where']);
if (_.has(params, '_publicationState')) {
Object.assign(finalParams, convertPublicationStateParams(params._publicationState));
}
const whereParams = _.omit(params, ['_sort', '_start', '_limit', '_where', '_publicationState']);
const whereClauses = [];

@@ -119,2 +126,18 @@

/**
* publicationState query parser
* @param {string} publicationState - eg: 'live', 'preview'
*/
const convertPublicationStateParams = publicationState => {
if (!DP_PUB_STATES.includes(publicationState)) {
throw new Error(
`convertPublicationStateParams expected a value from: ${DP_PUB_STATES.join(
', '
)}. Got ${publicationState} instead`
);
}
return { publicationState };
};
// List of all the possible filters

@@ -121,0 +144,0 @@ const VALID_REST_OPERATORS = [

@@ -28,2 +28,4 @@ 'use strict';

const { generateTimestampCode } = require('./code-generator');
const contentTypes = require('./content-types');
const webhook = require('./webhook');

@@ -56,2 +58,4 @@ module.exports = {

stringEquals,
contentTypes,
webhook,
};
'use strict';
const _ = require('lodash');
const { constants } = require('./content-types');
const {
ID_ATTRIBUTE,
PUBLISHED_AT_ATTRIBUTE,
CREATED_BY_ATTRIBUTE,
UPDATED_BY_ATTRIBUTE,
} = constants;

@@ -93,5 +100,4 @@ const sanitizeEntity = (dataSource, options) => {

const CREATOR_FIELDS = ['created_by', 'updated_by'];
const COMPONENT_FIELDS = ['__component'];
const STATIC_FIELDS = ['id', '__v'];
const STATIC_FIELDS = [ID_ATTRIBUTE, '__v'];

@@ -106,3 +112,11 @@ const getAllowedFields = ({ includeFields, model, isOutput }) => {

...(isOutput
? [primaryKey, timestamps, STATIC_FIELDS, COMPONENT_FIELDS, CREATOR_FIELDS]
? [
primaryKey,
timestamps,
STATIC_FIELDS,
COMPONENT_FIELDS,
CREATED_BY_ATTRIBUTE,
UPDATED_BY_ATTRIBUTE,
PUBLISHED_AT_ATTRIBUTE,
]
: [primaryKey, STATIC_FIELDS, COMPONENT_FIELDS])

@@ -109,0 +123,0 @@ );

4

lib/validators.js

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

function arrayRequiredAllowEmpty(message) {
return this.test('field is required', message || '', value => _.isArray(value));
function arrayRequiredAllowEmpty(message = '${path} is required') {
return this.test('field is required', message, value => _.isArray(value));
}

@@ -23,0 +23,0 @@

{
"name": "strapi-utils",
"version": "3.1.5",
"version": "3.2.0-beta.0",
"description": "Shared utilities for the Strapi packages",

@@ -22,3 +22,3 @@ "homepage": "http://strapi.io",

"pluralize": "^8.0.0",
"yup": "0.28.1"
"yup": "0.29.3"
},

@@ -45,7 +45,7 @@ "author": {

"engines": {
"node": ">=10.10.0 <13",
"node": ">=10.16.0 <13",
"npm": ">=6.0.0"
},
"license": "SEE LICENSE IN LICENSE",
"gitHead": "736a580001cd6f0d94ff2d5a930554f6d42e0477"
"gitHead": "90761175f6a0f3a36d9742f3e169cc0cc8068972"
}
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