2020-12-21 17:11:48 +01:00
|
|
|
'use strict';
|
|
|
|
|
2021-02-02 12:27:24 +01:00
|
|
|
// eslint-disable-next-line node/no-extraneous-require
|
2021-04-29 13:51:12 +02:00
|
|
|
const { features } = require('@strapi/strapi/lib/utils/ee');
|
2023-03-09 16:50:51 +00:00
|
|
|
const { mapAsync } = require('@strapi/utils');
|
2021-08-23 22:25:31 +02:00
|
|
|
const executeCEBootstrap = require('../../server/bootstrap');
|
|
|
|
const { getService } = require('../../server/utils');
|
2023-01-02 10:08:16 +01:00
|
|
|
const actions = require('./config/admin-actions');
|
2023-03-09 16:50:51 +00:00
|
|
|
const {
|
|
|
|
createReservedTable,
|
|
|
|
findTablesThatStartWithPrefix,
|
|
|
|
doesReservedTableEntryExist,
|
|
|
|
createReservedTableEntries,
|
|
|
|
} = require('./utils/reserved-tables');
|
|
|
|
|
|
|
|
module.exports = async ({ strapi }) => {
|
|
|
|
const connection = strapi.db.getSchemaConnection();
|
|
|
|
await createReservedTable(connection);
|
|
|
|
|
|
|
|
const tablesToPersist = [];
|
2023-01-29 19:24:55 +02:00
|
|
|
|
2021-03-25 14:59:44 +01:00
|
|
|
const { actionProvider } = getService('permission');
|
|
|
|
|
2021-01-27 11:52:02 +01:00
|
|
|
if (features.isEnabled('sso')) {
|
2023-01-02 10:08:16 +01:00
|
|
|
await actionProvider.registerMany(actions.sso);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (features.isEnabled('audit-logs')) {
|
2023-03-09 16:50:51 +00:00
|
|
|
const auditLogTables = await findTablesThatStartWithPrefix('strapi_audit_logs');
|
|
|
|
tablesToPersist.push(...auditLogTables);
|
|
|
|
|
2023-01-02 10:08:16 +01:00
|
|
|
await actionProvider.registerMany(actions.auditLogs);
|
2021-01-27 11:52:02 +01:00
|
|
|
}
|
2020-12-21 17:11:48 +01:00
|
|
|
|
2023-03-09 16:50:51 +00:00
|
|
|
if (features.isEnabled('review-workflows')) {
|
|
|
|
const reviewWorkflowTables = await findTablesThatStartWithPrefix('strapi_workflows');
|
|
|
|
tablesToPersist.push(...reviewWorkflowTables);
|
|
|
|
}
|
|
|
|
|
|
|
|
let recordsToInsert = await mapAsync(tablesToPersist, (tableName) =>
|
|
|
|
doesReservedTableEntryExist(tableName)
|
|
|
|
);
|
|
|
|
recordsToInsert = recordsToInsert.filter((record) => record);
|
|
|
|
|
|
|
|
if (recordsToInsert.length > 0) {
|
|
|
|
await createReservedTableEntries(recordsToInsert);
|
|
|
|
}
|
|
|
|
|
2023-02-24 18:55:55 +01:00
|
|
|
await getService('seat-enforcement').seatEnforcementWorkflow();
|
2023-01-29 19:24:55 +02:00
|
|
|
|
2020-12-21 17:11:48 +01:00
|
|
|
await executeCEBootstrap();
|
|
|
|
};
|