@strapi/plugin-documentation 4.10.0-beta.0 → 4.10.0

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.
package/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ .eslintrc.js
package/.eslintrc.js ADDED
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ root: true,
3
+ overrides: [
4
+ {
5
+ files: ['admin/**/*'],
6
+ extends: ['custom/front'],
7
+ },
8
+ {
9
+ files: ['**/*'],
10
+ excludedFiles: ['admin/**/*'],
11
+ extends: ['custom/back'],
12
+ },
13
+ ],
14
+ };
@@ -51,9 +51,9 @@ const PluginPage = () => {
51
51
  const colCount = 4;
52
52
  const rowCount = (data?.docVersions?.length || 0) + 1;
53
53
 
54
- const openDocVersion = () => {
54
+ const openDocVersion = (version) => {
55
55
  const slash = data?.prefix.startsWith('/') ? '' : '/';
56
- openWithNewTab(`${slash}${data?.prefix}/v${data?.currentVersion}`);
56
+ openWithNewTab(`${slash}${data?.prefix}/v${version}`);
57
57
  };
58
58
 
59
59
  const handleRegenerateDoc = (version) => {
@@ -141,7 +141,7 @@ const PluginPage = () => {
141
141
  <Td>
142
142
  <Flex justifyContent="end" {...stopPropagation}>
143
143
  <IconButton
144
- onClick={openDocVersion}
144
+ onClick={() => openDocVersion(doc.version)}
145
145
  noBorder
146
146
  icon={<Show />}
147
147
  label={formatMessage(
@@ -1,14 +1,28 @@
1
1
  import { useQuery, useMutation, useQueryClient } from 'react-query';
2
- import { useNotification } from '@strapi/helper-plugin';
3
- import { fetchDocumentationVersions, deleteDoc, regenerateDoc, updateSettings } from './api';
2
+ import { useNotification, useFetchClient } from '@strapi/helper-plugin';
3
+ import pluginId from '../../pluginId';
4
4
  import getTrad from '../../utils/getTrad';
5
5
 
6
6
  const useReactQuery = () => {
7
7
  const queryClient = useQueryClient();
8
8
  const toggleNotification = useNotification();
9
- const { isLoading, data } = useQuery('get-documentation', () =>
10
- fetchDocumentationVersions(toggleNotification)
11
- );
9
+ const { isLoading, data } = useQuery(['get-documentation', pluginId], async () => {
10
+ try {
11
+ const { data } = await get(`/${pluginId}/getInfos`);
12
+
13
+ return data;
14
+ } catch (err) {
15
+ toggleNotification({
16
+ type: 'warning',
17
+ message: { id: 'notification.error' },
18
+ });
19
+
20
+ // FIXME
21
+ return null;
22
+ }
23
+ });
24
+
25
+ const { del, post, put, get } = useFetchClient();
12
26
 
13
27
  const handleError = (err) => {
14
28
  toggleNotification({
@@ -25,20 +39,26 @@ const useReactQuery = () => {
25
39
  });
26
40
  };
27
41
 
28
- const deleteMutation = useMutation(deleteDoc, {
29
- onSuccess: () => handleSuccess('info', 'notification.delete.success'),
30
- onError: (error) => handleError(error),
31
- });
42
+ const deleteMutation = useMutation(
43
+ ({ prefix, version }) => del(`${prefix}/deleteDoc/${version}`),
44
+ {
45
+ onSuccess: () => handleSuccess('info', 'notification.delete.success'),
46
+ onError: (error) => handleError(error),
47
+ }
48
+ );
32
49
 
33
- const submitMutation = useMutation(updateSettings, {
50
+ const submitMutation = useMutation(({ prefix, body }) => put(`${prefix}/updateSettings`, body), {
34
51
  onSuccess: () => handleSuccess('success', 'notification.update.success'),
35
52
  onError: handleError,
36
53
  });
37
54
 
38
- const regenerateDocMutation = useMutation(regenerateDoc, {
39
- onSuccess: () => handleSuccess('info', 'notification.generate.success'),
40
- onError: (error) => handleError(error),
41
- });
55
+ const regenerateDocMutation = useMutation(
56
+ ({ prefix, version }) => post(`${prefix}/regenerateDoc`, { version }),
57
+ {
58
+ onSuccess: () => handleSuccess('info', 'notification.generate.success'),
59
+ onError: (error) => handleError(error),
60
+ }
61
+ );
42
62
 
43
63
  return { data, isLoading, deleteMutation, submitMutation, regenerateDocMutation };
44
64
  };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ preset: '../../../jest-preset.front.js',
5
+ };
package/jest.config.js ADDED
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ preset: '../../../jest-preset.unit.js',
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-documentation",
3
- "version": "4.10.0-beta.0",
3
+ "version": "4.10.0",
4
4
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,17 +21,19 @@
21
21
  }
22
22
  ],
23
23
  "scripts": {
24
- "test": "echo \"no tests yet\""
24
+ "lint": "run -T eslint .",
25
+ "test:unit": "jest --verbose"
25
26
  },
26
27
  "dependencies": {
27
28
  "@strapi/design-system": "1.6.6",
28
- "@strapi/helper-plugin": "4.10.0-beta.0",
29
+ "@strapi/helper-plugin": "4.10.0",
29
30
  "@strapi/icons": "1.6.6",
30
- "@strapi/utils": "4.10.0-beta.0",
31
+ "@strapi/utils": "4.10.0",
31
32
  "bcryptjs": "2.4.3",
32
33
  "cheerio": "^1.0.0-rc.12",
33
34
  "formik": "2.2.9",
34
35
  "fs-extra": "10.0.0",
36
+ "immer": "9.0.19",
35
37
  "koa-static": "^5.0.0",
36
38
  "lodash": "4.17.21",
37
39
  "path-to-regexp": "6.2.1",
@@ -43,7 +45,7 @@
43
45
  "react-redux": "8.0.5",
44
46
  "redux": "^4.2.1",
45
47
  "reselect": "^4.1.7",
46
- "swagger-ui-dist": "4.15.5",
48
+ "swagger-ui-dist": "4.18.1",
47
49
  "yaml": "1.10.2",
48
50
  "yup": "^0.32.9"
49
51
  },
@@ -51,10 +53,11 @@
51
53
  "@strapi/strapi": "^4.0.0",
52
54
  "react": "^17.0.2",
53
55
  "react-dom": "^17.0.2",
54
- "react-router-dom": "5.3.4",
55
- "styled-components": "5.3.3"
56
+ "react-router-dom": "^5.3.4",
57
+ "styled-components": "^5.3.3"
56
58
  },
57
59
  "devDependencies": {
60
+ "@apidevtools/swagger-parser": "^10.1.0",
58
61
  "@testing-library/react": "12.1.4",
59
62
  "history": "^4.9.0",
60
63
  "msw": "1.0.1",
@@ -73,5 +76,5 @@
73
76
  "description": "Create an OpenAPI Document and visualize your API with SWAGGER UI.",
74
77
  "kind": "plugin"
75
78
  },
76
- "gitHead": "1519ef0e56d27b738f24fc88223797651ad47aaf"
79
+ "gitHead": "9b5519778faaedfb837879f9c6f7e28fdfd6750d"
77
80
  }
@@ -19,9 +19,8 @@ module.exports = {
19
19
  },
20
20
  'x-strapi-config': {
21
21
  path: '/documentation',
22
- showGeneratedFiles: true,
23
- generateDefaultResponse: true,
24
- plugins: ['email', 'upload', 'users-permissions'],
22
+ plugins: null,
23
+ mutateDocumentation: null,
25
24
  },
26
25
  servers: [],
27
26
  externalDocs: {
@@ -33,42 +32,4 @@ module.exports = {
33
32
  bearerAuth: [],
34
33
  },
35
34
  ],
36
- components: {
37
- securitySchemes: {
38
- bearerAuth: {
39
- type: 'http',
40
- scheme: 'bearer',
41
- bearerFormat: 'JWT',
42
- },
43
- },
44
- schemas: {
45
- Error: {
46
- type: 'object',
47
- required: ['error'],
48
- properties: {
49
- data: {
50
- nullable: true,
51
- oneOf: [{ type: 'object' }, { type: 'array', items: [] }],
52
- },
53
- error: {
54
- type: 'object',
55
- properties: {
56
- status: {
57
- type: 'integer',
58
- },
59
- name: {
60
- type: 'string',
61
- },
62
- message: {
63
- type: 'string',
64
- },
65
- details: {
66
- type: 'object',
67
- },
68
- },
69
- },
70
- },
71
- },
72
- },
73
- },
74
35
  };
@@ -0,0 +1,269 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ 'plugin::upload.file': {
5
+ collectionName: 'files',
6
+ info: { singularName: 'file', pluralName: 'files', displayName: 'File', description: '' },
7
+ options: {},
8
+ pluginOptions: {
9
+ 'content-manager': { visible: false },
10
+ 'content-type-builder': { visible: false },
11
+ },
12
+ attributes: {
13
+ name: { type: 'string', configurable: false, required: true },
14
+ alternativeText: { type: 'string', configurable: false },
15
+ caption: { type: 'string', configurable: false },
16
+ width: { type: 'integer', configurable: false },
17
+ height: { type: 'integer', configurable: false },
18
+ formats: { type: 'json', configurable: false },
19
+ hash: { type: 'string', configurable: false, required: true },
20
+ ext: { type: 'string', configurable: false },
21
+ mime: { type: 'string', configurable: false, required: true },
22
+ size: { type: 'decimal', configurable: false, required: true },
23
+ url: { type: 'string', configurable: false, required: true },
24
+ previewUrl: { type: 'string', configurable: false },
25
+ provider: { type: 'string', configurable: false, required: true },
26
+ provider_metadata: { type: 'json', configurable: false },
27
+ related: { type: 'relation', relation: 'morphToMany', configurable: false },
28
+ folder: {
29
+ type: 'relation',
30
+ relation: 'manyToOne',
31
+ target: 'plugin::upload.folder',
32
+ inversedBy: 'files',
33
+ private: true,
34
+ },
35
+ folderPath: { type: 'string', min: 1, required: true, private: true },
36
+ createdAt: { type: 'datetime' },
37
+ updatedAt: { type: 'datetime' },
38
+ createdBy: {
39
+ type: 'relation',
40
+ relation: 'oneToOne',
41
+ target: 'admin::user',
42
+ configurable: false,
43
+ writable: false,
44
+ visible: false,
45
+ useJoinTable: false,
46
+ private: true,
47
+ },
48
+ updatedBy: {
49
+ type: 'relation',
50
+ relation: 'oneToOne',
51
+ target: 'admin::user',
52
+ configurable: false,
53
+ writable: false,
54
+ visible: false,
55
+ useJoinTable: false,
56
+ private: true,
57
+ },
58
+ },
59
+ indexes: [
60
+ { name: 'upload_files_folder_path_index', columns: ['folder_path'], type: null },
61
+ { name: 'upload_files_created_at_index', columns: ['created_at'], type: null },
62
+ { name: 'upload_files_updated_at_index', columns: ['updated_at'], type: null },
63
+ { name: 'upload_files_name_index', columns: ['name'], type: null },
64
+ { name: 'upload_files_size_index', columns: ['size'], type: null },
65
+ { name: 'upload_files_ext_index', columns: ['ext'], type: null },
66
+ ],
67
+ kind: 'collectionType',
68
+ modelType: 'contentType',
69
+ modelName: 'file',
70
+ connection: 'default',
71
+ uid: 'plugin::upload.file',
72
+ plugin: 'upload',
73
+ globalId: 'UploadFile',
74
+ },
75
+ 'plugin::upload.folder': {
76
+ collectionName: 'upload_folders',
77
+ info: { singularName: 'folder', pluralName: 'folders', displayName: 'Folder' },
78
+ options: {},
79
+ pluginOptions: {
80
+ 'content-manager': { visible: false },
81
+ 'content-type-builder': { visible: false },
82
+ },
83
+ attributes: {
84
+ name: { type: 'string', min: 1, required: true },
85
+ pathId: { type: 'integer', unique: true, required: true },
86
+ parent: {
87
+ type: 'relation',
88
+ relation: 'manyToOne',
89
+ target: 'plugin::upload.folder',
90
+ inversedBy: 'children',
91
+ },
92
+ children: {
93
+ type: 'relation',
94
+ relation: 'oneToMany',
95
+ target: 'plugin::upload.folder',
96
+ mappedBy: 'parent',
97
+ },
98
+ files: {
99
+ type: 'relation',
100
+ relation: 'oneToMany',
101
+ target: 'plugin::upload.file',
102
+ mappedBy: 'folder',
103
+ },
104
+ path: { type: 'string', min: 1, required: true },
105
+ createdAt: { type: 'datetime' },
106
+ updatedAt: { type: 'datetime' },
107
+ createdBy: {
108
+ type: 'relation',
109
+ relation: 'oneToOne',
110
+ target: 'admin::user',
111
+ configurable: false,
112
+ writable: false,
113
+ visible: false,
114
+ useJoinTable: false,
115
+ private: true,
116
+ },
117
+ updatedBy: {
118
+ type: 'relation',
119
+ relation: 'oneToOne',
120
+ target: 'admin::user',
121
+ configurable: false,
122
+ writable: false,
123
+ visible: false,
124
+ useJoinTable: false,
125
+ private: true,
126
+ },
127
+ },
128
+ indexes: [
129
+ { name: 'upload_folders_path_id_index', columns: ['path_id'], type: 'unique' },
130
+ { name: 'upload_folders_path_index', columns: ['path'], type: 'unique' },
131
+ ],
132
+ kind: 'collectionType',
133
+ modelType: 'contentType',
134
+ modelName: 'folder',
135
+ connection: 'default',
136
+ uid: 'plugin::upload.folder',
137
+ plugin: 'upload',
138
+ globalId: 'UploadFolder',
139
+ },
140
+ 'api::kitchensink.kitchensink': {
141
+ kind: 'collectionType',
142
+ collectionName: 'kitchensinks',
143
+ info: {
144
+ displayName: 'Kitchen Sink',
145
+ singularName: 'kitchensink',
146
+ pluralName: 'kitchensinks',
147
+ description: '',
148
+ name: 'Kitchen Sink',
149
+ },
150
+ options: { draftAndPublish: true },
151
+ pluginOptions: {},
152
+ attributes: {
153
+ short_text: { type: 'string' },
154
+ long_text: { type: 'text' },
155
+ rich_text: { type: 'richtext' },
156
+ integer: { type: 'integer' },
157
+ biginteger: { type: 'biginteger' },
158
+ decimal: { type: 'decimal' },
159
+ float: { type: 'float' },
160
+ date: { type: 'date' },
161
+ datetime: { type: 'datetime' },
162
+ time: { type: 'time' },
163
+ timestamp: { type: 'timestamp' },
164
+ boolean: { type: 'boolean' },
165
+ email: { type: 'email' },
166
+ password: { type: 'password' },
167
+ enumeration: { type: 'enumeration', enum: ['A', 'B', 'C', 'D', 'E'] },
168
+ single_media: {
169
+ type: 'media',
170
+ multiple: false,
171
+ required: false,
172
+ allowedTypes: ['images', 'files', 'videos'],
173
+ },
174
+ multiple_media: {
175
+ type: 'media',
176
+ multiple: true,
177
+ required: false,
178
+ allowedTypes: ['images', 'files', 'videos'],
179
+ },
180
+ json: { type: 'json' },
181
+ single_compo: { type: 'component', repeatable: false, component: 'basic.simple' },
182
+ repeatable_compo: { type: 'component', repeatable: true, component: 'basic.simple' },
183
+ dynamiczone: { type: 'dynamiczone', components: ['basic.simple', 'blog.test-como'] },
184
+ one_way_tag: { type: 'relation', relation: 'oneToOne', target: 'api::tag.tag' },
185
+ one_to_one_tag: {
186
+ type: 'relation',
187
+ relation: 'oneToOne',
188
+ target: 'api::tag.tag',
189
+ private: true,
190
+ inversedBy: 'one_to_one_kitchensink',
191
+ },
192
+ one_to_many_tags: {
193
+ type: 'relation',
194
+ relation: 'oneToMany',
195
+ target: 'api::tag.tag',
196
+ mappedBy: 'many_to_one_kitchensink',
197
+ },
198
+ many_to_one_tag: {
199
+ type: 'relation',
200
+ relation: 'manyToOne',
201
+ target: 'api::tag.tag',
202
+ inversedBy: 'one_to_many_kitchensinks',
203
+ },
204
+ many_to_many_tags: {
205
+ type: 'relation',
206
+ relation: 'manyToMany',
207
+ target: 'api::tag.tag',
208
+ inversedBy: 'many_to_many_kitchensinks',
209
+ },
210
+ many_way_tags: { type: 'relation', relation: 'oneToMany', target: 'api::tag.tag' },
211
+ morph_to_one: { type: 'relation', relation: 'morphToOne' },
212
+ morph_to_many: { type: 'relation', relation: 'morphToMany' },
213
+ custom_field: { type: 'string', customField: 'plugin::color-picker.color' },
214
+ custom_field_with_default_options: {
215
+ type: 'string',
216
+ regex: '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$',
217
+ customField: 'plugin::color-picker.color',
218
+ },
219
+ cats: { type: 'dynamiczone', components: ['basic.relation', 'basic.simple'] },
220
+ createdAt: { type: 'datetime' },
221
+ updatedAt: { type: 'datetime' },
222
+ publishedAt: { type: 'datetime', configurable: false, writable: true, visible: false },
223
+ createdBy: {
224
+ type: 'relation',
225
+ relation: 'oneToOne',
226
+ target: 'admin::user',
227
+ configurable: false,
228
+ writable: false,
229
+ visible: false,
230
+ useJoinTable: false,
231
+ private: true,
232
+ },
233
+ updatedBy: {
234
+ type: 'relation',
235
+ relation: 'oneToOne',
236
+ target: 'admin::user',
237
+ configurable: false,
238
+ writable: false,
239
+ visible: false,
240
+ useJoinTable: false,
241
+ private: true,
242
+ },
243
+ },
244
+ modelType: 'contentType',
245
+ modelName: 'kitchensink',
246
+ connection: 'default',
247
+ uid: 'api::kitchensink.kitchensink',
248
+ apiName: 'kitchensink',
249
+ globalId: 'Kitchensink',
250
+ actions: {},
251
+ lifecycles: {},
252
+ },
253
+ 'api::homepage.homepage': {
254
+ kind: 'singleType',
255
+ collectionName: 'homepages',
256
+ info: { displayName: 'Homepage', singularName: 'homepage', pluralName: 'homepages' },
257
+ options: { draftAndPublish: true },
258
+ pluginOptions: { i18n: { localized: true } },
259
+ attributes: {
260
+ title: { type: 'string', required: true, pluginOptions: { i18n: { localized: true } } },
261
+ slug: {
262
+ type: 'uid',
263
+ targetField: 'title',
264
+ required: true,
265
+ pluginOptions: { i18n: { localized: true } },
266
+ },
267
+ },
268
+ },
269
+ };