node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
'use strict';
var require$$0 = require('lodash');
var require$$1 = require('@strapi/utils');
var index = require('../utils/index.js');
var user = require('./validation/user.js');
var role;
var hasRequiredRole;
function requireRole() {
if (hasRequiredRole) return role;
hasRequiredRole = 1;
const _ = require$$0;
const { async, errors } = require$$1;
const { getService } = index.__require();
const { validateDeleteRoleBody } = user.__require();
const { ApplicationError, ValidationError } = errors;
const sanitizeOutput = async (role)=>{
const { sanitizeLocalizationFields } = strapi.plugin('i18n').service('sanitize');
const schema = strapi.getModel('plugin::users-permissions.role');
return async.pipe(sanitizeLocalizationFields(schema))(role);
};
role = {
/**
* Default action.
*
* @return {Object}
*/ async createRole (ctx) {
if (_.isEmpty(ctx.request.body)) {
throw new ValidationError('Request body cannot be empty');
}
await getService('role').createRole(ctx.request.body);
ctx.send({
ok: true
});
},
async findOne (ctx) {
const { id } = ctx.params;
const role = await getService('role').findOne(id);
if (!role) {
return ctx.notFound();
}
const safeRole = await sanitizeOutput(role);
ctx.send({
role: safeRole
});
},
async find (ctx) {
const roles = await getService('role').find();
const safeRoles = await Promise.all(roles.map(sanitizeOutput));
ctx.send({
roles: safeRoles
});
},
async updateRole (ctx) {
const roleID = ctx.params.role;
if (_.isEmpty(ctx.request.body)) {
throw new ValidationError('Request body cannot be empty');
}
await getService('role').updateRole(roleID, ctx.request.body);
ctx.send({
ok: true
});
},
async deleteRole (ctx) {
const roleID = ctx.params.role;
if (!roleID) {
await validateDeleteRoleBody(ctx.params);
}
// Fetch public role.
const publicRole = await strapi.db.query('plugin::users-permissions.role').findOne({
where: {
type: 'public'
}
});
const publicRoleID = publicRole.id;
// Prevent from removing the public role.
if (roleID.toString() === publicRoleID.toString()) {
throw new ApplicationError('Cannot delete public role');
}
await getService('role').deleteRole(roleID, publicRoleID);
ctx.send({
ok: true
});
}
};
return role;
}
exports.__require = requireRole;
//# sourceMappingURL=role.js.map