@strapi/plugin-documentation 4.0.0-next.11 → 4.0.0-next.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,14 +6,45 @@
6
6
  */
7
7
 
8
8
  import React from 'react';
9
- import { CheckPagePermissions } from '@strapi/helper-plugin';
9
+ import { useIntl } from 'react-intl';
10
+ import { CheckPagePermissions, NoContent } from '@strapi/helper-plugin';
11
+ import { Layout, HeaderLayout, ContentLayout } from '@strapi/parts/Layout';
12
+ import { Main } from '@strapi/parts/Main';
10
13
  import pluginPermissions from '../../permissions';
11
- import HomePage from '../HomePage';
14
+ import { getTrad } from '../../utils';
15
+ // import HomePage from '../HomePage';
16
+
17
+ const ComingSoon = () => {
18
+ const { formatMessage } = useIntl();
19
+
20
+ return (
21
+ <Layout>
22
+ <Main>
23
+ <HeaderLayout
24
+ title={formatMessage({
25
+ id: getTrad('plugin.name'),
26
+ defaultMessage: 'Documentation',
27
+ })}
28
+ />
29
+ <ContentLayout>
30
+ <NoContent
31
+ content={{
32
+ id: getTrad('coming.soon'),
33
+ defaultMessage:
34
+ 'This content is currently under construction and will be back in a few weeks!',
35
+ }}
36
+ />
37
+ </ContentLayout>
38
+ </Main>
39
+ </Layout>
40
+ );
41
+ };
12
42
 
13
43
  function App() {
14
44
  return (
15
45
  <CheckPagePermissions permissions={pluginPermissions.main}>
16
- <HomePage />
46
+ {/* <HomePage /> */}
47
+ <ComingSoon />
17
48
  </CheckPagePermissions>
18
49
  );
19
50
  }
@@ -16,8 +16,8 @@ const useHomePage = () => {
16
16
  };
17
17
 
18
18
  const deleteMutation = useMutation(deleteDoc, {
19
- onSuccess: () => {
20
- queryClient.invalidateQueries('get-documentation');
19
+ onSuccess: async () => {
20
+ await queryClient.invalidateQueries('get-documentation');
21
21
  toggleNotification({
22
22
  type: 'info',
23
23
  message: { id: getTrad('notification.delete.success') },
@@ -1,4 +1,5 @@
1
1
  {
2
+ "coming-soon": "This content is currently under construction and will be back in a few weeks!",
2
3
  "components.Row.generatedDate": "Last generation",
3
4
  "components.Row.open": "Open",
4
5
  "components.Row.regenerate": "Regenerate",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-documentation",
3
- "version": "4.0.0-next.11",
3
+ "version": "4.0.0-next.15",
4
4
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
5
5
  "strapi": {
6
6
  "displayName": "Documentation",
@@ -13,7 +13,7 @@
13
13
  "test": "echo \"no tests yet\""
14
14
  },
15
15
  "dependencies": {
16
- "@strapi/helper-plugin": "4.0.0-next.11",
16
+ "@strapi/helper-plugin": "4.0.0-next.15",
17
17
  "cheerio": "^1.0.0-rc.5",
18
18
  "fs-extra": "^9.1.0",
19
19
  "koa-static": "^5.0.0",
@@ -26,7 +26,7 @@
26
26
  "react-intl": "5.20.2",
27
27
  "react-redux": "7.2.3",
28
28
  "react-router": "^5.2.0",
29
- "react-router-dom": "^5.0.0",
29
+ "react-router-dom": "5.2.0",
30
30
  "reactstrap": "8.4.1",
31
31
  "redux": "^4.0.1",
32
32
  "reselect": "^4.0.0",
@@ -70,5 +70,5 @@
70
70
  "npm": ">=6.0.0"
71
71
  },
72
72
  "license": "SEE LICENSE IN LICENSE",
73
- "gitHead": "3d8950e29d465a0917db9bbd0e034e5227506716"
73
+ "gitHead": "3d2740ae0d80d9ed61d1429a92756bbe39fa97be"
74
74
  }
@@ -41,11 +41,8 @@ module.exports = async () => {
41
41
  );
42
42
  }
43
43
 
44
- const pluginStore = strapi.store({
45
- environment: '',
46
- type: 'plugin',
47
- name: 'documentation',
48
- });
44
+ const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });
45
+
49
46
  const restrictedAccess = await pluginStore.get({ key: 'config' });
50
47
 
51
48
  if (!restrictedAccess) {
@@ -4,5 +4,5 @@ const defaultConfig = require('./default-config');
4
4
 
5
5
  module.exports = {
6
6
  default: defaultConfig,
7
- validator: () => {},
7
+ validator() {},
8
8
  };
@@ -15,7 +15,7 @@ const _ = require('lodash');
15
15
  const koaStatic = require('koa-static');
16
16
 
17
17
  module.exports = {
18
- getInfos: async ctx => {
18
+ async getInfos(ctx) {
19
19
  try {
20
20
  const service = strapi.plugins.documentation.services.documentation;
21
21
  const docVersions = service.retrieveDocumentationVersions();
@@ -84,7 +84,7 @@ module.exports = {
84
84
  'documentation',
85
85
  'public'
86
86
  );
87
- return await koaStatic(staticFolder)(ctx, next);
87
+ return koaStatic(staticFolder)(ctx, next);
88
88
  } catch (e) {
89
89
  strapi.log.error(e);
90
90
  }
@@ -136,7 +136,7 @@ module.exports = {
136
136
  'documentation',
137
137
  'public'
138
138
  );
139
- return await koaStatic(staticFolder)(ctx, next);
139
+ return koaStatic(staticFolder)(ctx, next);
140
140
  } catch (e) {
141
141
  strapi.log.error(e);
142
142
  }
@@ -154,12 +154,7 @@ module.exports = {
154
154
  } = ctx.request;
155
155
 
156
156
  const { password: storedPassword } = await strapi
157
- .store({
158
- environment: '',
159
- type: 'plugin',
160
- name: 'documentation',
161
- key: 'config',
162
- })
157
+ .store({ type: 'plugin', name: 'documentation', key: 'config' })
163
158
  .get();
164
159
 
165
160
  const isValid = await strapi.plugins['users-permissions'].services.user.validatePassword(
@@ -180,7 +175,7 @@ module.exports = {
180
175
  );
181
176
  },
182
177
 
183
- regenerateDoc: async ctx => {
178
+ async regenerateDoc(ctx) {
184
179
  const service = strapi.plugins.documentation.services.documentation;
185
180
  const documentationVersions = service.retrieveDocumentationVersions().map(el => el.version);
186
181
  const {
@@ -224,7 +219,7 @@ module.exports = {
224
219
  }
225
220
  },
226
221
 
227
- deleteDoc: async ctx => {
222
+ async deleteDoc(ctx) {
228
223
  strapi.reload.isWatching = false;
229
224
  const service = strapi.plugins.documentation.services.documentation;
230
225
  const documentationVersions = service.retrieveDocumentationVersions().map(el => el.version);
@@ -260,17 +255,16 @@ module.exports = {
260
255
  }
261
256
  },
262
257
 
263
- updateSettings: async ctx => {
258
+ async updateSettings(ctx) {
264
259
  const {
265
260
  admin,
266
261
  body: { restrictedAccess, password },
267
262
  } = ctx.request;
263
+
268
264
  const usersPermService = strapi.plugins['users-permissions'].services;
269
- const pluginStore = strapi.store({
270
- environment: '',
271
- type: 'plugin',
272
- name: 'documentation',
273
- });
265
+
266
+ const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });
267
+
274
268
  const prevConfig = await pluginStore.get({ key: 'config' });
275
269
 
276
270
  if (restrictedAccess && _.isEmpty(password)) {
@@ -45,10 +45,10 @@ module.exports = {
45
45
  {
46
46
  method: 'GET',
47
47
  path: '/plugins/documentation/(.*)',
48
- handler: async (ctx, next) => {
48
+ async handler(ctx, next) {
49
49
  ctx.url = path.basename(ctx.url);
50
50
 
51
- return await koaStatic(swaggerUi.getAbsoluteFSPath(), {
51
+ return koaStatic(swaggerUi.getAbsoluteFSPath(), {
52
52
  maxage: strapi.config.middleware.settings.public.maxAge,
53
53
  defer: true,
54
54
  })(ctx, next);
@@ -1,15 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = async (ctx, next) => {
4
- const pluginStore = strapi.store({
5
- environment: '',
6
- type: 'plugin',
7
- name: 'documentation',
8
- });
4
+ const pluginStore = strapi.store({ type: 'plugin', name: 'documentation' });
5
+
9
6
  const config = await pluginStore.get({ key: 'config' });
10
7
 
11
8
  if (!config.restrictedAccess) {
12
- return await next();
9
+ return next();
13
10
  }
14
11
 
15
12
  if (!ctx.session.documentation) {
@@ -31,18 +31,18 @@ const customComparator = (value1, value2) => {
31
31
  };
32
32
 
33
33
  module.exports = ({ strapi }) => ({
34
- areObjectsEquals: function(obj1, obj2) {
34
+ areObjectsEquals(obj1, obj2) {
35
35
  // stringify to remove nested empty objects
36
36
  return customIsEqual(this.cleanObject(obj1), this.cleanObject(obj2));
37
37
  },
38
38
 
39
39
  cleanObject: obj => JSON.parse(JSON.stringify(obj)),
40
40
 
41
- arrayCustomizer: (objValue, srcValue) => {
41
+ arrayCustomizer(objValue, srcValue) {
42
42
  if (_.isArray(objValue)) return objValue.concat(srcValue);
43
43
  },
44
44
 
45
- checkIfAPIDocNeedsUpdate: function(apiName) {
45
+ checkIfAPIDocNeedsUpdate(apiName) {
46
46
  const prevDocumentation = this.createDocObject(this.retrieveDocumentation(apiName));
47
47
  const currentDocumentation = this.createDocObject(this.createDocumentationFile(apiName, false));
48
48
 
@@ -53,7 +53,7 @@ module.exports = ({ strapi }) => ({
53
53
  * Check if the documentation folder with its related version of an API exists
54
54
  * @param {String} apiName
55
55
  */
56
- checkIfDocumentationFolderExists: function(apiName) {
56
+ checkIfDocumentationFolderExists(apiName) {
57
57
  try {
58
58
  fs.accessSync(this.getDocumentationPath(apiName));
59
59
  return true;
@@ -62,7 +62,7 @@ module.exports = ({ strapi }) => ({
62
62
  }
63
63
  },
64
64
 
65
- checkIfPluginDocumentationFolderExists: function(pluginName) {
65
+ checkIfPluginDocumentationFolderExists(pluginName) {
66
66
  try {
67
67
  fs.accessSync(this.getPluginDocumentationPath(pluginName));
68
68
  return true;
@@ -71,7 +71,7 @@ module.exports = ({ strapi }) => ({
71
71
  }
72
72
  },
73
73
 
74
- checkIfPluginDocNeedsUpdate: function(pluginName) {
74
+ checkIfPluginDocNeedsUpdate(pluginName) {
75
75
  const prevDocumentation = this.createDocObject(this.retrieveDocumentation(pluginName, true));
76
76
  const currentDocumentation = this.createDocObject(
77
77
  this.createPluginDocumentationFile(pluginName, false)
@@ -80,7 +80,7 @@ module.exports = ({ strapi }) => ({
80
80
  return !this.areObjectsEquals(prevDocumentation, currentDocumentation);
81
81
  },
82
82
 
83
- checkIfApiDefaultDocumentationFileExist: function(apiName, docName) {
83
+ checkIfApiDefaultDocumentationFileExist(apiName, docName) {
84
84
  try {
85
85
  fs.accessSync(this.getAPIOverrideDocumentationPath(apiName, docName));
86
86
  return true;
@@ -89,7 +89,7 @@ module.exports = ({ strapi }) => ({
89
89
  }
90
90
  },
91
91
 
92
- checkIfPluginDefaultDocumentFileExists: function(pluginName, docName) {
92
+ checkIfPluginDefaultDocumentFileExists(pluginName, docName) {
93
93
  try {
94
94
  fs.accessSync(this.getPluginOverrideDocumentationPath(pluginName, docName));
95
95
  return true;
@@ -102,7 +102,7 @@ module.exports = ({ strapi }) => ({
102
102
  * Check if the documentation folder exists in the documentation plugin
103
103
  * @returns {Boolean}
104
104
  */
105
- checkIfMergedDocumentationFolderExists: function() {
105
+ checkIfMergedDocumentationFolderExists() {
106
106
  try {
107
107
  fs.accessSync(this.getMergedDocumentationPath());
108
108
  return true;
@@ -116,7 +116,7 @@ module.exports = ({ strapi }) => ({
116
116
  * @param {String} targetDir
117
117
  *
118
118
  */
119
- createDocumentationDirectory: function(targetDir) {
119
+ createDocumentationDirectory(targetDir) {
120
120
  const sep = path.sep;
121
121
  const initDir = path.isAbsolute(targetDir) ? sep : '';
122
122
  const baseDir = '.';
@@ -155,7 +155,7 @@ module.exports = ({ strapi }) => ({
155
155
  * Create the apiName.json and unclassified.json files inside an api's documentation/version folder
156
156
  * @param {String} apiName
157
157
  */
158
- createDocumentationFile: function(apiName, writeFile = true) {
158
+ createDocumentationFile(apiName, writeFile = true) {
159
159
  // Retrieve all the routes from an API
160
160
  const apiRoutes = this.getApiRoutes(apiName);
161
161
  const apiDocumentation = this.generateApiDocumentation(apiName, apiRoutes);
@@ -180,7 +180,7 @@ module.exports = ({ strapi }) => ({
180
180
  }, []);
181
181
  },
182
182
 
183
- createPluginDocumentationFile: function(pluginName, writeFile = true) {
183
+ createPluginDocumentationFile(pluginName, writeFile = true) {
184
184
  const pluginRoutes = this.getPluginRoutesWithDescription(pluginName);
185
185
  const pluginDocumentation = this.generatePluginDocumentation(pluginName, pluginRoutes);
186
186
 
@@ -213,12 +213,12 @@ module.exports = ({ strapi }) => ({
213
213
  }, []);
214
214
  },
215
215
 
216
- createDocObject: function(array) {
216
+ createDocObject(array) {
217
217
  // use custom merge for arrays
218
218
  return array.reduce((acc, curr) => _.mergeWith(acc, curr, this.arrayCustomizer), {});
219
219
  },
220
220
 
221
- deleteDocumentation: async function(version = this.getDocumentationVersion()) {
221
+ async deleteDocumentation(version = this.getDocumentationVersion()) {
222
222
  const recursiveDeleteFiles = async (folderPath, removeCompleteFolder = true) => {
223
223
  // Check if folderExist
224
224
  try {
@@ -296,7 +296,7 @@ module.exports = ({ strapi }) => ({
296
296
  );
297
297
  arrayOfPromises.push(recursiveDeleteFiles(fullDocPath));
298
298
 
299
- return await Promise.all(arrayOfPromises);
299
+ return Promise.all(arrayOfPromises);
300
300
  },
301
301
 
302
302
  /**
@@ -305,7 +305,7 @@ module.exports = ({ strapi }) => ({
305
305
  * @param {String} endPoint
306
306
  * @returns {String} (/products/{id})
307
307
  */
308
- formatApiEndPoint: endPoint => {
308
+ formatApiEndPoint(endPoint) {
309
309
  return pathToRegexp
310
310
  .parse(endPoint)
311
311
  .map(token => {
@@ -325,7 +325,7 @@ module.exports = ({ strapi }) => ({
325
325
  * @param {Boolean} withoutSpace
326
326
  * @return {String}
327
327
  */
328
- formatTag: (plugin, name, withoutSpace = false) => {
328
+ formatTag(plugin, name, withoutSpace = false) {
329
329
  const formattedPluginName = plugin
330
330
  .split('-')
331
331
  .map(i => _.upperFirst(i))
@@ -339,7 +339,7 @@ module.exports = ({ strapi }) => ({
339
339
  return `${formattedPluginName} - ${formattedName}`;
340
340
  },
341
341
 
342
- generateAssociationSchema: function(attributes, getter) {
342
+ generateAssociationSchema(attributes, getter) {
343
343
  return Object.keys(attributes).reduce(
344
344
  (acc, curr) => {
345
345
  const attribute = attributes[curr];
@@ -388,7 +388,7 @@ module.exports = ({ strapi }) => ({
388
388
  * @param {Array} routes
389
389
  * @returns {Object}
390
390
  */
391
- generateApiDocumentation: function(apiName, routes) {
391
+ generateApiDocumentation(apiName, routes) {
392
392
  return routes.reduce((acc, current) => {
393
393
  const [controllerName, controllerMethod] = current.handler.split('.');
394
394
  // Retrieve the tag key in the config object
@@ -504,7 +504,7 @@ module.exports = ({ strapi }) => ({
504
504
  }, {});
505
505
  },
506
506
 
507
- generateFullDoc: function(version = this.getDocumentationVersion()) {
507
+ generateFullDoc(version = this.getDocumentationVersion()) {
508
508
  const apisDoc = this.retrieveDocumentationFiles(false, version);
509
509
  const pluginsDoc = this.retrieveDocumentationFiles(true, version);
510
510
  const appDoc = [...apisDoc, ...pluginsDoc];
@@ -538,7 +538,7 @@ module.exports = ({ strapi }) => ({
538
538
  * @param {Array} associations
539
539
  * @returns {Object}
540
540
  */
541
- generateMainComponent: function(attributes, associations) {
541
+ generateMainComponent(attributes, associations) {
542
542
  return Object.keys(attributes).reduce(
543
543
  (acc, current) => {
544
544
  const attribute = attributes[current];
@@ -661,7 +661,7 @@ module.exports = ({ strapi }) => ({
661
661
  );
662
662
  },
663
663
 
664
- generatePluginDocumentation: function(pluginName, routes) {
664
+ generatePluginDocumentation(pluginName, routes) {
665
665
  return routes.reduce((acc, current) => {
666
666
  const {
667
667
  config: { description, prefix },
@@ -776,7 +776,7 @@ module.exports = ({ strapi }) => ({
776
776
  }, {});
777
777
  },
778
778
 
779
- generatePluginResponseSchema: function(tag) {
779
+ generatePluginResponseSchema(tag) {
780
780
  const { actionType, name, plugin } = _.isObject(tag) ? tag : { tag };
781
781
  const getter = plugin ? ['plugins', plugin, 'models', name.toLowerCase()] : ['models', name];
782
782
  const isModelRelated =
@@ -829,7 +829,7 @@ module.exports = ({ strapi }) => ({
829
829
  };
830
830
  },
831
831
 
832
- generatePluginVerbResponses: function(routeObject) {
832
+ generatePluginVerbResponses(routeObject) {
833
833
  const {
834
834
  config: { tag },
835
835
  } = routeObject;
@@ -904,7 +904,7 @@ module.exports = ({ strapi }) => ({
904
904
  * @param {String} tag
905
905
  * @returns {Object}
906
906
  */
907
- generateResponses: function(verb, routeObject, tag) {
907
+ generateResponses(verb, routeObject, tag) {
908
908
  const endPoint = routeObject.path.split('/')[1];
909
909
  const description = this.generateResponseDescription(verb, tag, endPoint);
910
910
  const schema = this.generateResponseSchema(verb, routeObject, tag, endPoint);
@@ -962,7 +962,7 @@ module.exports = ({ strapi }) => ({
962
962
  * Retrieve all privates attributes from a model
963
963
  * @param {Object} attributes
964
964
  */
965
- getPrivateAttributes: function(attributes) {
965
+ getPrivateAttributes(attributes) {
966
966
  const privateAttributes = Object.keys(attributes).reduce((acc, current) => {
967
967
  if (attributes[current].private === true) {
968
968
  acc.push(current);
@@ -979,7 +979,7 @@ module.exports = ({ strapi }) => ({
979
979
  * @param {String} tag
980
980
  * @returns {Object}
981
981
  */
982
- generateResponseComponent: function(tag, pluginName = '', isPlugin = false) {
982
+ generateResponseComponent(tag, pluginName = '', isPlugin = false) {
983
983
  // The component's name have to be capitalised
984
984
  const [plugin, name] = isPlugin ? this.getModelAndNameForPlugin(tag, pluginName) : [null, null];
985
985
  const upperFirstTag = isPlugin ? this.formatTag(plugin, name, true) : _.upperFirst(tag);
@@ -1079,7 +1079,7 @@ module.exports = ({ strapi }) => ({
1079
1079
  * @param {String} endPoint
1080
1080
  * @returns {String}
1081
1081
  */
1082
- generateResponseDescription: function(verb, tag, endPoint) {
1082
+ generateResponseDescription(verb, tag, endPoint) {
1083
1083
  const isModelRelated = strapi.models[tag] !== undefined && tag === endPoint;
1084
1084
 
1085
1085
  if (Array.isArray(verb)) {
@@ -1107,7 +1107,7 @@ module.exports = ({ strapi }) => ({
1107
1107
  * @param {String} endPoint
1108
1108
  * @returns {Object}
1109
1109
  */
1110
- generateResponseSchema: function(verb, routeObject, tag) {
1110
+ generateResponseSchema(verb, routeObject, tag) {
1111
1111
  const { handler } = routeObject;
1112
1112
  let [controller, handlerMethod] = handler.split('.');
1113
1113
  let upperFirstTag = _.upperFirst(tag);
@@ -1207,7 +1207,7 @@ module.exports = ({ strapi }) => ({
1207
1207
  };
1208
1208
  },
1209
1209
 
1210
- generateTags: function(name, docName, tag = '', isPlugin = false) {
1210
+ generateTags(name, docName, tag = '', isPlugin = false) {
1211
1211
  return [
1212
1212
  {
1213
1213
  name: isPlugin ? tag : _.upperFirst(docName),
@@ -1224,7 +1224,7 @@ module.exports = ({ strapi }) => ({
1224
1224
  * @param {String} endPoint
1225
1225
  * @returns {String}
1226
1226
  */
1227
- generateVerbDescription: (verb, handler, tag, endPoint, description) => {
1227
+ generateVerbDescription(verb, handler, tag, endPoint, description) {
1228
1228
  const isModelRelated = strapi.models[tag] !== undefined && tag === endPoint;
1229
1229
 
1230
1230
  if (description) {
@@ -1289,7 +1289,7 @@ module.exports = ({ strapi }) => ({
1289
1289
  * @param {String} controllerMethod
1290
1290
  * @param {String} endPoint
1291
1291
  */
1292
- generateVerbParameters: function(verb, controllerMethod, endPoint) {
1292
+ generateVerbParameters(verb, controllerMethod, endPoint) {
1293
1293
  const params = pathToRegexp
1294
1294
  .parse(endPoint)
1295
1295
  .filter(token => _.isObject(token))
@@ -1319,11 +1319,11 @@ module.exports = ({ strapi }) => ({
1319
1319
  * Retrieve the apis in /api
1320
1320
  * @returns {Array}
1321
1321
  */
1322
- getApis: () => {
1322
+ getApis() {
1323
1323
  return Object.keys(strapi.api || {});
1324
1324
  },
1325
1325
 
1326
- getAPIOverrideComponentsDocumentation: function(apiName, docName) {
1326
+ getAPIOverrideComponentsDocumentation(apiName, docName) {
1327
1327
  try {
1328
1328
  const documentation = JSON.parse(
1329
1329
  fs.readFileSync(this.getAPIOverrideDocumentationPath(apiName, docName), 'utf8')
@@ -1335,7 +1335,7 @@ module.exports = ({ strapi }) => ({
1335
1335
  }
1336
1336
  },
1337
1337
 
1338
- getAPIDefaultTagsDocumentation: function(name, docName) {
1338
+ getAPIDefaultTagsDocumentation(name, docName) {
1339
1339
  try {
1340
1340
  const documentation = JSON.parse(
1341
1341
  fs.readFileSync(this.getAPIOverrideDocumentationPath(name, docName), 'utf8')
@@ -1347,7 +1347,7 @@ module.exports = ({ strapi }) => ({
1347
1347
  }
1348
1348
  },
1349
1349
 
1350
- getAPIDefaultVerbDocumentation: function(apiName, docName, routePath, verb) {
1350
+ getAPIDefaultVerbDocumentation(apiName, docName, routePath, verb) {
1351
1351
  try {
1352
1352
  const documentation = JSON.parse(
1353
1353
  fs.readFileSync(this.getAPIOverrideDocumentationPath(apiName, docName), 'utf8')
@@ -1359,7 +1359,7 @@ module.exports = ({ strapi }) => ({
1359
1359
  }
1360
1360
  },
1361
1361
 
1362
- getAPIOverrideDocumentationPath: function(apiName, docName) {
1362
+ getAPIOverrideDocumentationPath(apiName, docName) {
1363
1363
  return path.join(
1364
1364
  strapi.config.appPath,
1365
1365
  'api',
@@ -1376,11 +1376,11 @@ module.exports = ({ strapi }) => ({
1376
1376
  * @param {String}
1377
1377
  * @returns {Array}
1378
1378
  */
1379
- getApiRoutes: apiName => {
1379
+ getApiRoutes(apiName) {
1380
1380
  return _.get(strapi, ['api', apiName, 'config', 'routes'], []);
1381
1381
  },
1382
1382
 
1383
- getDocumentationOverridesPath: function(apiName) {
1383
+ getDocumentationOverridesPath(apiName) {
1384
1384
  return path.join(
1385
1385
  strapi.config.appPath,
1386
1386
  'api',
@@ -1396,7 +1396,7 @@ module.exports = ({ strapi }) => ({
1396
1396
  * @param {String} apiName
1397
1397
  * @returns {Path}
1398
1398
  */
1399
- getDocumentationPath: function(apiName) {
1399
+ getDocumentationPath(apiName) {
1400
1400
  return path.join(
1401
1401
  strapi.config.appPath,
1402
1402
  'api',
@@ -1406,14 +1406,14 @@ module.exports = ({ strapi }) => ({
1406
1406
  );
1407
1407
  },
1408
1408
 
1409
- getFullDocumentationPath: () => {
1409
+ getFullDocumentationPath() {
1410
1410
  return path.join(strapi.config.appPath, 'extensions', 'documentation', 'documentation');
1411
1411
  },
1412
1412
 
1413
1413
  /**
1414
1414
  * Retrieve the plugin's configuration version
1415
1415
  */
1416
- getDocumentationVersion: () => {
1416
+ getDocumentationVersion() {
1417
1417
  const version = strapi.config.get('plugin.documentation.info.version');
1418
1418
 
1419
1419
  return version;
@@ -1422,7 +1422,7 @@ module.exports = ({ strapi }) => ({
1422
1422
  /**
1423
1423
  * Retrieve the documentation plugin documentation directory
1424
1424
  */
1425
- getMergedDocumentationPath: function(version = this.getDocumentationVersion()) {
1425
+ getMergedDocumentationPath(version = this.getDocumentationVersion()) {
1426
1426
  return path.join(
1427
1427
  strapi.config.appPath,
1428
1428
  'extensions',
@@ -1437,7 +1437,7 @@ module.exports = ({ strapi }) => ({
1437
1437
  * @param {Objet} modelAttributes
1438
1438
  * @returns {Object} { associations: [{ name: 'foo', getter: [], tag: 'foos' }], attributes }
1439
1439
  */
1440
- getModelAttributes: function(modelAttributes) {
1440
+ getModelAttributes(modelAttributes) {
1441
1441
  const associations = [];
1442
1442
  const attributes = Object.keys(modelAttributes)
1443
1443
  .map(attr => {
@@ -1469,7 +1469,7 @@ module.exports = ({ strapi }) => ({
1469
1469
  * @param {String} type
1470
1470
  * @returns {String}
1471
1471
  */
1472
- getType: type => {
1472
+ getType(type) {
1473
1473
  switch (type) {
1474
1474
  case 'string':
1475
1475
  case 'byte':
@@ -1503,7 +1503,7 @@ module.exports = ({ strapi }) => ({
1503
1503
  * @param {String} type
1504
1504
  * @returns {String}
1505
1505
  */
1506
- getFormat: type => {
1506
+ getFormat(type) {
1507
1507
  switch (type) {
1508
1508
  case 'date':
1509
1509
  return 'date';
@@ -1516,7 +1516,7 @@ module.exports = ({ strapi }) => ({
1516
1516
  }
1517
1517
  },
1518
1518
 
1519
- getPluginDefaultVerbDocumentation: function(pluginName, docName, routePath, verb) {
1519
+ getPluginDefaultVerbDocumentation(pluginName, docName, routePath, verb) {
1520
1520
  try {
1521
1521
  const documentation = JSON.parse(
1522
1522
  fs.readFileSync(this.getPluginOverrideDocumentationPath(pluginName, docName), 'utf8')
@@ -1528,7 +1528,7 @@ module.exports = ({ strapi }) => ({
1528
1528
  }
1529
1529
  },
1530
1530
 
1531
- getPluginDefaultTagsDocumentation: function(pluginName, docName) {
1531
+ getPluginDefaultTagsDocumentation(pluginName, docName) {
1532
1532
  try {
1533
1533
  const documentation = JSON.parse(
1534
1534
  fs.readFileSync(this.getPluginOverrideDocumentationPath(pluginName, docName), 'utf8')
@@ -1540,7 +1540,7 @@ module.exports = ({ strapi }) => ({
1540
1540
  }
1541
1541
  },
1542
1542
 
1543
- getPluginOverrideComponents: function(pluginName, docName) {
1543
+ getPluginOverrideComponents(pluginName, docName) {
1544
1544
  try {
1545
1545
  const documentation = JSON.parse(
1546
1546
  fs.readFileSync(this.getPluginOverrideDocumentationPath(pluginName, docName), 'utf8')
@@ -1552,7 +1552,7 @@ module.exports = ({ strapi }) => ({
1552
1552
  }
1553
1553
  },
1554
1554
 
1555
- getPluginOverrideDocumentationPath: function(pluginName, docName) {
1555
+ getPluginOverrideDocumentationPath(pluginName, docName) {
1556
1556
  const defaultPath = path.join(
1557
1557
  strapi.config.appPath,
1558
1558
  'extensions',
@@ -1572,7 +1572,7 @@ module.exports = ({ strapi }) => ({
1572
1572
  /**
1573
1573
  * Given a plugin retrieve its documentation version
1574
1574
  */
1575
- getPluginDocumentationPath: function(pluginName) {
1575
+ getPluginDocumentationPath(pluginName) {
1576
1576
  return path.join(
1577
1577
  strapi.config.appPath,
1578
1578
  'extensions',
@@ -1586,7 +1586,7 @@ module.exports = ({ strapi }) => ({
1586
1586
  * Retrieve all plugins that have a description inside one of its route
1587
1587
  * @return {Arrray}
1588
1588
  */
1589
- getPluginsWithDocumentationNeeded: function() {
1589
+ getPluginsWithDocumentationNeeded() {
1590
1590
  return Object.keys(strapi.plugins).reduce((acc, current) => {
1591
1591
  const isDocumentationNeeded = this.isPluginDocumentationNeeded(current);
1592
1592
 
@@ -1603,7 +1603,7 @@ module.exports = ({ strapi }) => ({
1603
1603
  * @param {String} pluginName
1604
1604
  * @returns {Array}
1605
1605
  */
1606
- getPluginRoutesWithDescription: function(pluginName) {
1606
+ getPluginRoutesWithDescription(pluginName) {
1607
1607
  return _.get(strapi, ['plugins', pluginName, 'config', 'routes'], []).filter(
1608
1608
  route => _.get(route, ['config', 'description']) !== undefined
1609
1609
  );
@@ -1615,7 +1615,7 @@ module.exports = ({ strapi }) => ({
1615
1615
  * @param {Sting} pluginName
1616
1616
  * @returns {Array}
1617
1617
  */
1618
- getModelAndNameForPlugin: (string, pluginName) => {
1618
+ getModelAndNameForPlugin(string, pluginName) {
1619
1619
  return _.replace(string, `${pluginName}-`, `${pluginName}.`).split('.');
1620
1620
  },
1621
1621
 
@@ -1625,7 +1625,7 @@ module.exports = ({ strapi }) => ({
1625
1625
  * @param {String} plugin
1626
1626
  * @returns {Array}
1627
1627
  */
1628
- getModelForPlugin: function(string, pluginName) {
1628
+ getModelForPlugin(string, pluginName) {
1629
1629
  const [plugin, model] = this.getModelAndNameForPlugin(string, pluginName);
1630
1630
 
1631
1631
  return ['plugins', plugin, 'models', _.lowerCase(model)];
@@ -1636,7 +1636,7 @@ module.exports = ({ strapi }) => ({
1636
1636
  * @param {String} pluginName
1637
1637
  * @returns {Boolean}
1638
1638
  */
1639
- isPluginDocumentationNeeded: function(pluginName) {
1639
+ isPluginDocumentationNeeded(pluginName) {
1640
1640
  const { pluginsForWhichToGenerateDoc } = strapi.config.get(
1641
1641
  'plugins.documentation.x-strapi-config'
1642
1642
  );
@@ -1656,7 +1656,7 @@ module.exports = ({ strapi }) => ({
1656
1656
  * @param {Object} srcObj
1657
1657
  * @returns {Object}
1658
1658
  */
1659
- mergeComponents: (initObj, srcObj) => {
1659
+ mergeComponents(initObj, srcObj) {
1660
1660
  const cleanedObj = Object.keys(_.get(initObj, 'schemas', {})).reduce((acc, current) => {
1661
1661
  const targetObj = _.has(_.get(srcObj, ['schemas'], {}), current) ? srcObj : initObj;
1662
1662
 
@@ -1668,7 +1668,7 @@ module.exports = ({ strapi }) => ({
1668
1668
  return _.merge(cleanedObj, srcObj);
1669
1669
  },
1670
1670
 
1671
- mergePaths: function(initObj, srcObj) {
1671
+ mergePaths(initObj, srcObj) {
1672
1672
  return Object.keys(initObj.paths).reduce((acc, current) => {
1673
1673
  if (_.has(_.get(srcObj, ['paths'], {}), current)) {
1674
1674
  const verbs = Object.keys(initObj.paths[current]).reduce((acc1, curr) => {
@@ -1689,7 +1689,7 @@ module.exports = ({ strapi }) => ({
1689
1689
  }, {});
1690
1690
  },
1691
1691
 
1692
- mergeTags: (initObj, srcObj) => {
1692
+ mergeTags(initObj, srcObj) {
1693
1693
  return _.get(srcObj, 'tags', _.get(initObj, 'tags', []));
1694
1694
  },
1695
1695
 
@@ -1699,7 +1699,7 @@ module.exports = ({ strapi }) => ({
1699
1699
  * @param {Object} srcObj
1700
1700
  * @returns {Object}
1701
1701
  */
1702
- mergeVerbObject: function(initObj, srcObj) {
1702
+ mergeVerbObject(initObj, srcObj) {
1703
1703
  return _.mergeWith(initObj, srcObj, (objValue, srcValue) => {
1704
1704
  if (_.isPlainObject(objValue)) {
1705
1705
  return Object.assign(objValue, srcValue);
@@ -1709,7 +1709,7 @@ module.exports = ({ strapi }) => ({
1709
1709
  });
1710
1710
  },
1711
1711
 
1712
- retrieveDocumentation: function(name, isPlugin = false) {
1712
+ retrieveDocumentation(name, isPlugin = false) {
1713
1713
  const documentationPath = isPlugin
1714
1714
  ? [strapi.config.appPath, 'extensions', name, 'documentation', this.getDocumentationVersion()]
1715
1715
  : [strapi.config.appPath, 'api', name, 'documentation', this.getDocumentationVersion()];
@@ -1741,7 +1741,7 @@ module.exports = ({ strapi }) => ({
1741
1741
  * @param {Boolean} isPlugin
1742
1742
  * @returns {Array}
1743
1743
  */
1744
- retrieveDocumentationFiles: function(isPlugin = false, version = this.getDocumentationVersion()) {
1744
+ retrieveDocumentationFiles(isPlugin = false, version = this.getDocumentationVersion()) {
1745
1745
  const array = isPlugin ? this.getPluginsWithDocumentationNeeded() : this.getApis();
1746
1746
 
1747
1747
  return array.reduce((acc, current) => {
@@ -1826,7 +1826,7 @@ module.exports = ({ strapi }) => ({
1826
1826
  }, []);
1827
1827
  },
1828
1828
 
1829
- retrieveDocumentationVersions: function() {
1829
+ retrieveDocumentationVersions() {
1830
1830
  return fs
1831
1831
  .readdirSync(this.getFullDocumentationPath())
1832
1832
  .map(version => {
@@ -1846,15 +1846,11 @@ module.exports = ({ strapi }) => ({
1846
1846
  .filter(x => x);
1847
1847
  },
1848
1848
 
1849
- retrieveFrontForm: async function() {
1849
+ async retrieveFrontForm() {
1850
1850
  const config = await strapi
1851
- .store({
1852
- environment: '',
1853
- type: 'plugin',
1854
- name: 'documentation',
1855
- key: 'config',
1856
- })
1851
+ .store({ type: 'plugin', name: 'documentation', key: 'config' })
1857
1852
  .get();
1853
+
1858
1854
  const forms = JSON.parse(JSON.stringify(form));
1859
1855
 
1860
1856
  _.set(forms, [0, 0, 'value'], config.restrictedAccess);
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./admin/src').default;