Merge branch 'v4/backend' into pluginAPI/loadPlugin

This commit is contained in:
Pierre Noël 2021-08-04 15:05:56 +02:00
commit dd0c095f1e
153 changed files with 320 additions and 543 deletions

View File

@ -2,6 +2,7 @@ module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
admin: {
// autoOpen: true,
auth: {
secret: env('ADMIN_JWT_SECRET', 'example-token'),
},

View File

@ -1,3 +1,3 @@
module.exports = {
jwtSecret: process.env.JWT_SECRET || 'f12c8d28-5d60-401e-b480-3af1cb42febc',
jwtSecret: process.env.JWT_SECRET || '6dc1785c-5916-462f-a75e-7ae5fcb480ae',
};

View File

@ -1,8 +1,9 @@
{
"compilerOptions": {
"rootDir": ".",
"module": "commonjs",
"target": "es6"
},
"include": ["packages/**/*"],
"exclude": ["**/node_modules/*"]
"exclude": ["node_modules"]
}

View File

@ -2,11 +2,12 @@
// eslint-disable-next-line node/no-extraneous-require
const { features } = require('@strapi/strapi/lib/utils/ee');
const executeCEBootstrap = require('../../../config/functions/bootstrap');
const executeCEBootstrap = require('../../../../server/config/functions/bootstrap');
const {
features: { sso: ssoActions },
} = require('../admin-actions');
const { getService } = require('../../../utils');
const { getService } = require('../../../../server/utils');
module.exports = async () => {
const { actionProvider } = getService('permission');

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = {
functions: {
bootstrap: require('./functions/bootstrap'),
},
routes: require('./routes').routes,
};

View File

@ -2,7 +2,7 @@
const passport = require('koa-passport');
const { getService } = require('../../../utils');
const { getService } = require('../../../../server/utils');
const utils = require('./utils');
const defaultConnectionError = () => new Error('Invalid connection payload');

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = {
authentication: require('./authentication'),
permission: require('./permission'),
role: require('./role'),
user: require('./user'),
};

View File

@ -1,7 +1,7 @@
'use strict';
const { getService } = require('../../utils');
const { formatConditions } = require('../../controllers/formatters');
const { getService } = require('../../../server/utils');
const { formatConditions } = require('../../../server/controllers/formatters');
module.exports = {
async getAll(ctx) {

View File

@ -6,9 +6,9 @@ const {
validateRoleDeleteInput,
validateRolesDeleteInput,
} = require('../validation/role');
const { getService } = require('../../utils');
const { getService } = require('../../../server//utils');
const { validatedUpdatePermissionsInput } = require('../validation/permission');
const { SUPER_ADMIN_CODE } = require('../../services/constants');
const { SUPER_ADMIN_CODE } = require('../../../server/services/constants');
module.exports = {
/**

View File

@ -2,7 +2,7 @@
const { pick } = require('lodash/fp');
const { validateUserCreationInput } = require('../validation/user');
const { getService } = require('../../utils');
const { getService } = require('../../../server/utils');
const pickUserCreationAttributes = pick(['firstname', 'lastname', 'email', 'roles']);

View File

@ -0,0 +1,8 @@
'use strict';
module.exports = {
// TODO: update load middleware to not load the admin middleware from here
config: require('./config'),
services: require('./services'),
controllers: require('./controllers'),
};

View File

@ -7,7 +7,7 @@ jest.mock('koa-passport', () => ({
const passport = require('koa-passport');
const { init } = require('../../../services/passport');
const { init } = require('../../../../server/services/passport');
describe('Passport', () => {
afterEach(() => {

View File

@ -0,0 +1,6 @@
'use strict';
module.exports = {
passport: require('./passport'),
role: require('./role'),
};

View File

@ -3,7 +3,7 @@
// eslint-disable-next-line node/no-extraneous-require
const { features } = require('@strapi/strapi/lib/utils/ee');
const createLocalStrategy = require('../../services/passport/local-strategy');
const createLocalStrategy = require('../../../server/services/passport/local-strategy');
const sso = require('./passport/sso');
const getPassportStrategies = () => {

View File

@ -1,6 +1,6 @@
'use strict';
const { authEventsMapper } = require('../../../services/passport');
const { authEventsMapper } = require('../../../../server/services/passport');
const createProviderRegistry = require('./provider-registry');
const providerRegistry = createProviderRegistry();

View File

@ -1,8 +1,8 @@
'use strict';
const { createStrapiInstance } = require('../../../../../test/helpers/strapi');
const { createAuthRequest, createRequest } = require('../../../../../test/helpers/request');
const { createUtils } = require('../../../../../test/helpers/utils');
const { createStrapiInstance } = require('../../../../../../test/helpers/strapi');
const { createAuthRequest, createRequest } = require('../../../../../../test/helpers/request');
const { createUtils } = require('../../../../../../test/helpers/utils');
const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';

View File

@ -1,7 +1,7 @@
'use strict';
const { formatYupErrors } = require('@strapi/utils');
const validators = require('../../validation/common-validators');
const validators = require('../../../server/validation/common-validators');
const handleReject = error => Promise.reject(formatYupErrors(error));

View File

@ -3,7 +3,7 @@
const { yup, formatYupErrors } = require('@strapi/utils');
// eslint-disable-next-line node/no-extraneous-require
const { features } = require('@strapi/strapi/lib/utils/ee');
const { schemas } = require('../../validation/user');
const { schemas } = require('../../../server/validation/user');
const handleReject = error => Promise.reject(formatYupErrors(error));

View File

@ -0,0 +1,3 @@
'use strict';
module.exports = require('./server');

View File

@ -150,7 +150,7 @@ async function copyAdmin(dest) {
await fs.ensureDir(path.resolve(dest, 'config'));
await fs.copy(path.resolve(adminPath, 'admin'), path.resolve(dest, 'admin'));
await fs.copy(
path.resolve(adminPath, 'config', 'layout.js'),
path.resolve(adminPath, 'server', 'config', 'layout.js'),
path.resolve(dest, 'config', 'layout.js')
);

View File

@ -1,5 +0,0 @@
'use strict';
const bootstrap = require('../config/functions/bootstrap');
module.exports = bootstrap;

View File

@ -1,10 +0,0 @@
'use strict';
const settings = require('../config/settings');
module.exports = {
default: {
settings,
},
validator: () => {},
};

View File

@ -55,11 +55,4 @@ module.exports = async () => {
await userService.displayWarningIfUsersDontHaveRole();
await syncAuthSettings();
strapi.admin.destroy = async () => {
const { conditionProvider, actionProvider } = getService('permission');
await conditionProvider.clear();
await actionProvider.clear();
};
};

View File

@ -0,0 +1,15 @@
'use strict';
module.exports = {
functions: {
bootstrap: require('./functions/bootstrap'),
register: require('./functions/register'),
},
policies: {
hasPermissions: require('./policies/hasPermissions'),
isAuthenticatedAdmin: require('./policies/isAuthenticatedAdmin'),
},
routes: require('./routes').routes,
layout: require('./layout'),
...require('./settings'),
};

View File

@ -11,7 +11,7 @@ module.exports = {
description: '',
singularName: 'role',
pluralName: 'roles',
displayName: 'Role'
displayName: 'Role',
},
options: {},
pluginOptions: {

View File

@ -11,7 +11,7 @@ module.exports = {
description: '',
singularName: 'user',
pluralName: 'users',
displayName: 'User'
displayName: 'User',
},
pluginOptions: {
'content-manager': {

View File

@ -1,17 +1,7 @@
'use strict';
const permission = require('../../models/Permission');
const role = require('../../models/Role');
const user = require('../../models/User');
module.exports = [
{
schema: permission,
},
{
schema: role,
},
{
schema: user,
},
];
module.exports = {
permission: require('./Permission'),
user: require('./User'),
role: require('./Role'),
};

View File

@ -1,6 +1,6 @@
'use strict';
const createContext = require('../../../../../test/helpers/create-context');
const createContext = require('../../../../../../test/helpers/create-context');
const permissionController = require('../permission');
describe('Permission Controller', () => {

View File

@ -1,6 +1,6 @@
'use strict';
const createContext = require('../../../../../test/helpers/create-context');
const createContext = require('../../../../../../test/helpers/create-context');
const roleController = require('../role');
describe('Role controller', () => {

View File

@ -1,6 +1,6 @@
'use strict';
const createContext = require('../../../../../test/helpers/create-context');
const createContext = require('../../../../../../test/helpers/create-context');
const userController = require('../user');
describe('User Controller', () => {

View File

@ -2,12 +2,12 @@
const execa = require('execa');
const _ = require('lodash');
const { getService } = require('../utils');
// FIXME
// eslint-disable-next-line node/no-extraneous-require
const ee = require('@strapi/strapi/lib/utils/ee');
const { getService } = require('../utils');
const PLUGIN_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-_]+$/;
/**

View File

@ -1,19 +1,11 @@
'use strict';
const admin = require('../../controllers/admin');
const authentication = require('../../controllers/authentication');
const permission = require('../../controllers/permission');
const role = require('../../controllers/role');
const user = require('../../controllers/user');
const webhooks = require('../../controllers/Webhooks');
const authenticatedUser = require('../../controllers/authenticated-user');
module.exports = {
admin,
authentication,
permission,
role,
user,
webhooks,
'authenticated-user': authenticatedUser,
admin: require('./admin'),
'authenticated-user': require('./authenticated-user'),
authentication: require('./authentication'),
permission: require('./permission'),
role: require('./role'),
user: require('./user'),
webhooks: require('./Webhooks'),
};

View File

@ -0,0 +1,18 @@
'use strict';
const { getService } = require('./utils');
module.exports = {
// TODO: update load middleware to not load the admin middleware from here
// TODO: load bootstrap / register independently
async destroy() {
const { conditionProvider, actionProvider } = getService('permission');
await conditionProvider.clear();
await actionProvider.clear();
},
config: require('./config'),
services: require('./services'),
controllers: require('./controllers'),
models: require('./content-types'),
};

View File

@ -1,9 +0,0 @@
'use strict';
const hasPermissions = require('../../config/policies/hasPermissions');
const isAuthenticatedAdmin = require('../../config/policies/isAuthenticatedAdmin');
module.exports = {
hasPermissions,
isAuthenticatedAdmin,
};

View File

@ -1,5 +0,0 @@
'use strict';
const register = require('../config/functions/register');
module.exports = register;

View File

@ -1,5 +0,0 @@
'use strict';
const routes = require('../../config/routes');
module.exports = routes.routes;

View File

@ -1,25 +1,15 @@
'use strict';
const action = require('../../services/action');
const auth = require('../../services/auth');
const condition = require('../../services/condition');
const contentType = require('../../services/content-type');
const metrics = require('../../services/metrics');
const passport = require('../../services/passport');
const permission = require('../../services/permission');
const role = require('../../services/role');
const token = require('../../services/token');
const user = require('../../services/user');
module.exports = {
action,
auth,
condition,
'content-type': contentType,
metrics,
passport,
permission,
role,
token,
user,
user: require('./user'),
token: require('./token'),
role: require('./role'),
permission: require('./permission'),
passport: require('./passport'),
metrics: require('./metrics'),
'content-type': require('./content-type'),
constants: require('./constants'),
condition: require('./condition'),
auth: require('./auth'),
action: require('./action'),
};

Some files were not shown because too many files have changed in this diff Show More