@strapi/plugin-documentation 4.12.0-beta.3 → 4.12.0-beta.5

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.
@@ -3,4 +3,5 @@
3
3
  module.exports = {
4
4
  preset: '../../../jest-preset.front.js',
5
5
  displayName: 'Documentation plugin',
6
+ setupFilesAfterEnv: ['./tests/setup.js'],
6
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-documentation",
3
- "version": "4.12.0-beta.3",
3
+ "version": "4.12.0-beta.5",
4
4
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,15 +25,13 @@
25
25
  "test:unit": "jest --verbose",
26
26
  "test:unit:watch": "run -T jest --watch",
27
27
  "test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
28
- "test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
29
- "test:front:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js",
30
- "test:front:watch:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll"
28
+ "test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll"
31
29
  },
32
30
  "dependencies": {
33
31
  "@strapi/design-system": "1.8.2",
34
- "@strapi/helper-plugin": "4.12.0-beta.3",
32
+ "@strapi/helper-plugin": "4.12.0-beta.5",
35
33
  "@strapi/icons": "1.8.2",
36
- "@strapi/utils": "4.12.0-beta.3",
34
+ "@strapi/utils": "4.12.0-beta.5",
37
35
  "bcryptjs": "2.4.3",
38
36
  "cheerio": "^1.0.0-rc.12",
39
37
  "formik": "2.4.0",
@@ -42,13 +40,9 @@
42
40
  "koa-static": "^5.0.0",
43
41
  "lodash": "4.17.21",
44
42
  "path-to-regexp": "6.2.1",
45
- "pluralize": "8.0.0",
46
43
  "react-helmet": "^6.1.0",
47
44
  "react-intl": "6.4.1",
48
45
  "react-query": "3.39.3",
49
- "react-redux": "8.1.1",
50
- "redux": "^4.2.1",
51
- "reselect": "^4.1.7",
52
46
  "swagger-ui-dist": "4.19.0",
53
47
  "yaml": "1.10.2",
54
48
  "yup": "^0.32.9"
@@ -63,7 +57,7 @@
63
57
  "devDependencies": {
64
58
  "@apidevtools/swagger-parser": "^10.1.0",
65
59
  "@testing-library/react": "14.0.0",
66
- "history": "^4.9.0",
60
+ "@testing-library/user-event": "14.4.3",
67
61
  "msw": "1.2.1",
68
62
  "react": "^18.2.0",
69
63
  "react-dom": "^18.2.0",
@@ -80,5 +74,5 @@
80
74
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
81
75
  "kind": "plugin"
82
76
  },
83
- "gitHead": "e8f4408751727a0104775a23cfa96d4741b1f21b"
77
+ "gitHead": "690c85458416da815f0e944fa8fc6dbe0fb2d001"
84
78
  }
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ const { setupServer } = require('msw/node');
4
+ const { rest } = require('msw');
5
+
6
+ const handlers = [
7
+ rest.get('*/getInfos', (req, res, ctx) => {
8
+ return res(
9
+ ctx.status(200),
10
+ ctx.json({
11
+ documentationAccess: { restrictedAccess: false },
12
+ currentVersion: '1.0.0',
13
+ docVersions: [
14
+ { version: '1.0.0', generatedDoc: '10/05/2021 2:52:44 PM' },
15
+ { version: '1.2.0', generatedDoc: '11/05/2021 3:00:00 PM' },
16
+ { version: '2.0.0', generatedDoc: '11/06/2021 3:00:00 PM' },
17
+ ],
18
+ prefix: '/documentation',
19
+ })
20
+ );
21
+ }),
22
+ rest.post('*/regenerateDoc', (req, res, ctx) => {
23
+ return res(ctx.status(200));
24
+ }),
25
+ rest.delete('*/deleteDoc/:version', (req, res, ctx) => {
26
+ return res(ctx.status(200));
27
+ }),
28
+ rest.put('*/updateSettings', (req, res, ctx) => {
29
+ return res(ctx.status(200));
30
+ }),
31
+ ];
32
+
33
+ const server = setupServer(...handlers);
34
+
35
+ module.exports = {
36
+ server,
37
+ };
package/tests/setup.js ADDED
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ const { server } = require('./server');
4
+
5
+ beforeAll(() => {
6
+ server.listen();
7
+ });
8
+
9
+ afterEach(() => {
10
+ server.resetHandlers();
11
+ });
12
+
13
+ afterAll(() => {
14
+ server.close();
15
+ });
@@ -1,14 +0,0 @@
1
- import { FieldAction } from '@strapi/design-system';
2
- import styled from 'styled-components';
3
-
4
- const FieldActionWrapper = styled(FieldAction)`
5
- svg {
6
- height: 1rem;
7
- width: 1rem;
8
- path {
9
- fill: ${({ theme }) => theme.colors.neutral600};
10
- }
11
- }
12
- `;
13
-
14
- export default FieldActionWrapper;
@@ -1,13 +0,0 @@
1
- /**
2
- *
3
- * PluginIcon
4
- *
5
- */
6
-
7
- import React from 'react';
8
-
9
- import { Information } from '@strapi/icons';
10
-
11
- const PluginIcon = () => <Information />;
12
-
13
- export default PluginIcon;
@@ -1,23 +0,0 @@
1
- import { rest } from 'msw';
2
- import { setupServer } from 'msw/node';
3
-
4
- const handlers = [
5
- rest.get('*/getInfos', (req, res, ctx) => {
6
- return res(
7
- ctx.delay(100),
8
- ctx.status(200),
9
- ctx.json({
10
- currentVersion: '1.0.0',
11
- docVersions: [
12
- { version: '1.0.0', generatedDoc: '10/05/2021 2:52:44 PM' },
13
- { version: '1.2.0', generatedDoc: '11/05/2021 3:00:00 PM' },
14
- ],
15
- prefix: '/documentation',
16
- })
17
- );
18
- }),
19
- ];
20
-
21
- const server = setupServer(...handlers);
22
-
23
- export default server;
@@ -1,18 +0,0 @@
1
- import { rest } from 'msw';
2
- import { setupServer } from 'msw/node';
3
-
4
- const handlers = [
5
- rest.get('*/getInfos', (req, res, ctx) => {
6
- return res(
7
- ctx.delay(100),
8
- ctx.status(200),
9
- ctx.json({
10
- documentationAccess: { restrictedAccess: false },
11
- })
12
- );
13
- }),
14
- ];
15
-
16
- const server = setupServer(...handlers);
17
-
18
- export default server;
@@ -1,11 +0,0 @@
1
- import { translatedErrors } from '@strapi/helper-plugin';
2
- import * as yup from 'yup';
3
-
4
- const schema = yup.object().shape({
5
- restrictedAccess: yup.boolean(),
6
- password: yup.string().when('restrictedAccess', (value, initSchema) => {
7
- return value ? initSchema.required(translatedErrors.required) : initSchema;
8
- }),
9
- });
10
-
11
- export default schema;
@@ -1,67 +0,0 @@
1
- import { useFetchClient, useNotification } from '@strapi/helper-plugin';
2
- import { useMutation, useQuery, useQueryClient } from 'react-query';
3
-
4
- import pluginId from '../../pluginId';
5
- import getTrad from '../../utils/getTrad';
6
-
7
- const useReactQuery = () => {
8
- const queryClient = useQueryClient();
9
- const toggleNotification = useNotification();
10
- const { isLoading, isError, data } = useQuery(['get-documentation', pluginId], async () => {
11
- try {
12
- const { data } = await get(`/${pluginId}/getInfos`);
13
-
14
- return data;
15
- } catch (err) {
16
- toggleNotification({
17
- type: 'warning',
18
- message: { id: 'notification.error' },
19
- });
20
-
21
- // FIXME
22
- return null;
23
- }
24
- });
25
-
26
- const { del, post, put, get } = useFetchClient();
27
-
28
- const handleError = (err) => {
29
- toggleNotification({
30
- type: 'warning',
31
- message: err.response.payload.message,
32
- });
33
- };
34
-
35
- const handleSuccess = (type, tradId) => {
36
- queryClient.invalidateQueries('get-documentation');
37
- toggleNotification({
38
- type,
39
- message: { id: getTrad(tradId) },
40
- });
41
- };
42
-
43
- const deleteMutation = useMutation(
44
- ({ prefix, version }) => del(`${prefix}/deleteDoc/${version}`),
45
- {
46
- onSuccess: () => handleSuccess('info', 'notification.delete.success'),
47
- onError: (error) => handleError(error),
48
- }
49
- );
50
-
51
- const submitMutation = useMutation(({ prefix, body }) => put(`${prefix}/updateSettings`, body), {
52
- onSuccess: () => handleSuccess('success', 'notification.update.success'),
53
- onError: handleError,
54
- });
55
-
56
- const regenerateDocMutation = useMutation(
57
- ({ prefix, version }) => post(`${prefix}/regenerateDoc`, { version }),
58
- {
59
- onSuccess: () => handleSuccess('info', 'notification.generate.success'),
60
- onError: (error) => handleError(error),
61
- }
62
- );
63
-
64
- return { data, isLoading, isError, deleteMutation, submitMutation, regenerateDocMutation };
65
- };
66
-
67
- export default useReactQuery;
@@ -1,19 +0,0 @@
1
- const openWithNewTab = (path) => {
2
- const url = (() => {
3
- if (path.startsWith('/')) {
4
- return `${window.strapi.backendURL}${path}`;
5
- }
6
-
7
- if (path.startsWith('http')) {
8
- return path;
9
- }
10
-
11
- return `${window.strapi.backendURL}/${path}`;
12
- })();
13
-
14
- window.open(url, '_blank');
15
-
16
- return window.focus();
17
- };
18
-
19
- export default openWithNewTab;