2024-03-15 20:24:37 +01:00
|
|
|
import type { Core } from '@strapi/types';
|
2022-08-08 15:50:34 +02:00
|
|
|
|
2024-03-15 20:24:37 +01:00
|
|
|
import { getService } from './utils';
|
2021-07-20 12:12:30 +02:00
|
|
|
|
2021-08-19 16:49:33 +02:00
|
|
|
// Add permissions
|
|
|
|
const RBAC_ACTIONS = [
|
|
|
|
{
|
|
|
|
section: 'plugins',
|
|
|
|
displayName: 'Access the Documentation',
|
|
|
|
uid: 'read',
|
|
|
|
pluginName: 'documentation',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
section: 'plugins',
|
|
|
|
displayName: 'Update and delete',
|
|
|
|
uid: 'settings.update',
|
|
|
|
pluginName: 'documentation',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
section: 'plugins',
|
|
|
|
displayName: 'Regenerate',
|
|
|
|
uid: 'settings.regenerate',
|
|
|
|
pluginName: 'documentation',
|
|
|
|
},
|
2021-10-07 14:03:22 -04:00
|
|
|
{
|
|
|
|
section: 'settings',
|
|
|
|
displayName: 'Access the documentation settings page',
|
|
|
|
uid: 'settings.read',
|
|
|
|
pluginName: 'documentation',
|
|
|
|
category: 'documentation',
|
|
|
|
},
|
2021-08-19 16:49:33 +02:00
|
|
|
];
|
|
|
|
|
2024-03-15 20:24:37 +01:00
|
|
|
export async function bootstrap({ strapi }: { strapi: Core.Strapi }) {
|
2024-03-27 22:44:52 +01:00
|
|
|
await strapi.service('admin::permission').actionProvider.registerMany(RBAC_ACTIONS);
|
2021-08-19 16:49:33 +02:00
|
|
|
|
2024-03-15 20:24:37 +01:00
|
|
|
const pluginStore = strapi.store!({
|
2021-09-02 11:25:24 +02:00
|
|
|
environment: '',
|
|
|
|
type: 'plugin',
|
|
|
|
name: 'documentation',
|
|
|
|
});
|
2021-09-13 12:03:12 +02:00
|
|
|
|
2021-10-18 21:21:06 +02:00
|
|
|
const config = await pluginStore.get({ key: 'config' });
|
2021-08-19 16:49:33 +02:00
|
|
|
|
2021-10-18 21:21:06 +02:00
|
|
|
if (!config) {
|
2021-08-19 16:49:33 +02:00
|
|
|
pluginStore.set({ key: 'config', value: { restrictedAccess: false } });
|
|
|
|
}
|
|
|
|
|
2024-03-15 20:24:37 +01:00
|
|
|
await getService('documentation').generateFullDoc();
|
|
|
|
}
|