@strapi/plugin-documentation 0.0.0-experimental.check-license → 0.0.0-experimental.d042f6a350fa3a48d61e7c56875e2a0a7ba3c8f5

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.
Files changed (184) hide show
  1. package/LICENSE +18 -3
  2. package/README.md +0 -1
  3. package/dist/_chunks/App-C51t4Zpc.js +201 -0
  4. package/dist/_chunks/App-D3sYdNAh.mjs +183 -0
  5. package/dist/_chunks/Settings-DfyHMjZj.js +239 -0
  6. package/dist/_chunks/Settings-DiK51xGj.mjs +220 -0
  7. package/dist/_chunks/ar-CkqTE6jh.js +23 -0
  8. package/{admin/src/translations/ar.json → dist/_chunks/ar-ckp9T43y.mjs} +5 -2
  9. package/dist/_chunks/cs-BbyKo6Hc.js +24 -0
  10. package/{admin/src/translations/cs.json → dist/_chunks/cs-ciLYCxgd.mjs} +5 -2
  11. package/dist/_chunks/de-CHwC0A85.js +29 -0
  12. package/{admin/src/translations/de.json → dist/_chunks/de-DqkAUMvP.mjs} +5 -2
  13. package/{admin/src/translations/dk.json → dist/_chunks/dk-DgCq8mF-.mjs} +5 -2
  14. package/dist/_chunks/dk-qlI2J6S0.js +42 -0
  15. package/{admin/src/translations/en.json → dist/_chunks/en-BQ_E53_2.mjs} +9 -3
  16. package/dist/_chunks/en-DKizRVCY.js +45 -0
  17. package/{admin/src/translations/es.json → dist/_chunks/es-CEiXVnsb.mjs} +5 -2
  18. package/dist/_chunks/es-DH1GVZe7.js +42 -0
  19. package/dist/_chunks/fr-B1x-Nj5w.js +29 -0
  20. package/{admin/src/translations/fr.json → dist/_chunks/fr-BlX-v4UF.mjs} +5 -2
  21. package/dist/_chunks/getTrad-BCVqzyys.mjs +50 -0
  22. package/dist/_chunks/getTrad-DoREjbyy.js +49 -0
  23. package/{admin/src/translations/id.json → dist/_chunks/id-CPOl6_EU.mjs} +5 -2
  24. package/dist/_chunks/id-D3yFE72d.js +27 -0
  25. package/{server/public/index.html → dist/_chunks/index-BTFWrNiz.mjs} +8 -4
  26. package/dist/_chunks/index-BlmI1vCi.js +103 -0
  27. package/dist/_chunks/index-CYcTK1eg.js +74 -0
  28. package/dist/_chunks/index-YnqsO7ap.mjs +104 -0
  29. package/{admin/src/translations/it.json → dist/_chunks/it-DWJI563z.mjs} +5 -2
  30. package/dist/_chunks/it-WuNBIqG8.js +29 -0
  31. package/{admin/src/translations/ko.json → dist/_chunks/ko-CFzSHayG.mjs} +5 -2
  32. package/dist/_chunks/ko-De5iYa_O.js +42 -0
  33. package/dist/_chunks/login-EQSKn2h7.js +149 -0
  34. package/{server/public/login.html → dist/_chunks/login-KS59cQ6U.mjs} +5 -1
  35. package/{admin/src/translations/ms.json → dist/_chunks/ms-CUgPFo4U.mjs} +5 -2
  36. package/dist/_chunks/ms-DQfa3FDx.js +26 -0
  37. package/dist/_chunks/nl-BZHlqphk.js +24 -0
  38. package/{admin/src/translations/nl.json → dist/_chunks/nl-B_7CHwVD.mjs} +5 -2
  39. package/dist/_chunks/pl-DDl5i_mP.js +42 -0
  40. package/{admin/src/translations/pl.json → dist/_chunks/pl-DwLr8sw9.mjs} +5 -2
  41. package/dist/_chunks/pt-4GQ8ermL.js +24 -0
  42. package/dist/_chunks/pt-BR-D24CJ0qp.js +24 -0
  43. package/{admin/src/translations/pt.json → dist/_chunks/pt-BR-MVXc6V9P.mjs} +5 -2
  44. package/{admin/src/translations/pt-BR.json → dist/_chunks/pt-C2N9fdeh.mjs} +5 -2
  45. package/{admin/src/translations/ru.json → dist/_chunks/ru-BddeNlU0.mjs} +5 -2
  46. package/dist/_chunks/ru-QwZYcU6K.js +42 -0
  47. package/{admin/src/translations/sk.json → dist/_chunks/sk-BmT4uZTG.mjs} +5 -2
  48. package/dist/_chunks/sk-DgAXilB1.js +27 -0
  49. package/dist/_chunks/sv-CCLcAo3U.js +42 -0
  50. package/{admin/src/translations/sv.json → dist/_chunks/sv-D_-KBtcw.mjs} +5 -2
  51. package/dist/_chunks/th-BhgV1BbW.js +27 -0
  52. package/{admin/src/translations/th.json → dist/_chunks/th-DkuoSGii.mjs} +5 -2
  53. package/dist/_chunks/tr-BysnAErC.js +42 -0
  54. package/{admin/src/translations/tr.json → dist/_chunks/tr-l-xxK4Yk.mjs} +5 -2
  55. package/dist/_chunks/uk-CNlbntFx.js +26 -0
  56. package/{admin/src/translations/uk.json → dist/_chunks/uk-Cpmsxyku.mjs} +5 -2
  57. package/{admin/src/translations/vi.json → dist/_chunks/vi-ClWGrFm9.mjs} +5 -2
  58. package/dist/_chunks/vi-_ib0GmNl.js +27 -0
  59. package/{admin/src/translations/zh.json → dist/_chunks/zh-Glkg1L2g.mjs} +5 -2
  60. package/dist/_chunks/zh-Hans-L_5U2KqC.js +31 -0
  61. package/{admin/src/translations/zh-Hans.json → dist/_chunks/zh-Hans-XLMwjASk.mjs} +5 -2
  62. package/dist/_chunks/zh-aEZZdkOu.js +42 -0
  63. package/dist/admin/index.js +4 -0
  64. package/dist/admin/index.mjs +5 -0
  65. package/dist/admin/src/components/SettingsForm.d.ts +8 -0
  66. package/dist/admin/src/constants.d.ts +18 -0
  67. package/dist/admin/src/index.d.ts +14 -0
  68. package/dist/admin/src/pages/App.d.ts +2 -0
  69. package/dist/admin/src/pages/Settings.d.ts +2 -0
  70. package/dist/admin/src/pluginId.d.ts +1 -0
  71. package/dist/admin/src/services/api.d.ts +13 -0
  72. package/dist/admin/src/types.d.ts +16 -0
  73. package/dist/admin/src/utils/baseQuery.d.ts +5 -0
  74. package/dist/admin/src/utils/getTrad.d.ts +1 -0
  75. package/dist/admin/src/utils/index.d.ts +2 -0
  76. package/dist/admin/src/utils/prefixPluginTranslations.d.ts +2 -0
  77. package/dist/server/index.js +1293 -0
  78. package/dist/server/index.mjs +1269 -0
  79. package/dist/server/src/bootstrap.d.ts +5 -0
  80. package/dist/server/src/bootstrap.d.ts.map +1 -0
  81. package/dist/server/src/config/default-plugin-config.d.ts +3 -0
  82. package/dist/server/src/config/default-plugin-config.d.ts.map +1 -0
  83. package/dist/server/src/config/index.d.ts +4 -0
  84. package/dist/server/src/config/index.d.ts.map +1 -0
  85. package/dist/server/src/controllers/documentation.d.ts +12 -0
  86. package/dist/server/src/controllers/documentation.d.ts.map +1 -0
  87. package/dist/server/src/controllers/index.d.ts +14 -0
  88. package/dist/server/src/controllers/index.d.ts.map +1 -0
  89. package/dist/server/src/index.d.ts +91 -0
  90. package/dist/server/src/index.d.ts.map +1 -0
  91. package/dist/server/src/middlewares/documentation.d.ts +5 -0
  92. package/dist/server/src/middlewares/documentation.d.ts.map +1 -0
  93. package/dist/server/src/middlewares/restrict-access.d.ts +4 -0
  94. package/dist/server/src/middlewares/restrict-access.d.ts.map +1 -0
  95. package/dist/server/src/register.d.ts +5 -0
  96. package/dist/server/src/register.d.ts.map +1 -0
  97. package/dist/server/src/routes/index.d.ts +36 -0
  98. package/dist/server/src/routes/index.d.ts.map +1 -0
  99. package/dist/server/src/services/__mocks__/mock-content-types.d.ts +449 -0
  100. package/dist/server/src/services/__mocks__/mock-content-types.d.ts.map +1 -0
  101. package/dist/server/src/services/__mocks__/mock-strapi-data.d.ts +592 -0
  102. package/dist/server/src/services/__mocks__/mock-strapi-data.d.ts.map +1 -0
  103. package/dist/server/src/services/documentation.d.ts +36 -0
  104. package/dist/server/src/services/documentation.d.ts.map +1 -0
  105. package/dist/server/src/services/helpers/build-api-endpoint-path.d.ts +7 -0
  106. package/dist/server/src/services/helpers/build-api-endpoint-path.d.ts.map +1 -0
  107. package/dist/server/src/services/helpers/build-component-schema.d.ts +4 -0
  108. package/dist/server/src/services/helpers/build-component-schema.d.ts.map +1 -0
  109. package/dist/server/src/services/helpers/index.d.ts +4 -0
  110. package/dist/server/src/services/helpers/index.d.ts.map +1 -0
  111. package/dist/server/src/services/helpers/utils/clean-schema-attributes.d.ts +15 -0
  112. package/dist/server/src/services/helpers/utils/clean-schema-attributes.d.ts.map +1 -0
  113. package/dist/server/src/services/helpers/utils/get-api-responses.d.ts +15 -0
  114. package/dist/server/src/services/helpers/utils/get-api-responses.d.ts.map +1 -0
  115. package/dist/server/src/services/helpers/utils/get-schema-data.d.ts +12 -0
  116. package/dist/server/src/services/helpers/utils/get-schema-data.d.ts.map +1 -0
  117. package/dist/server/src/services/helpers/utils/loop-content-type-names.d.ts +7 -0
  118. package/dist/server/src/services/helpers/utils/loop-content-type-names.d.ts.map +1 -0
  119. package/dist/server/src/services/helpers/utils/pascal-case.d.ts +3 -0
  120. package/dist/server/src/services/helpers/utils/pascal-case.d.ts.map +1 -0
  121. package/dist/server/src/services/helpers/utils/query-params.d.ts +4 -0
  122. package/dist/server/src/services/helpers/utils/query-params.d.ts.map +1 -0
  123. package/dist/server/src/services/helpers/utils/routes.d.ts +3 -0
  124. package/dist/server/src/services/helpers/utils/routes.d.ts.map +1 -0
  125. package/dist/server/src/services/index.d.ts +43 -0
  126. package/dist/server/src/services/index.d.ts.map +1 -0
  127. package/dist/server/src/services/override.d.ts +21 -0
  128. package/dist/server/src/services/override.d.ts.map +1 -0
  129. package/dist/server/src/services/utils/get-plugins-that-need-documentation.d.ts +4 -0
  130. package/dist/server/src/services/utils/get-plugins-that-need-documentation.d.ts.map +1 -0
  131. package/dist/server/src/types.d.ts +28 -0
  132. package/dist/server/src/types.d.ts.map +1 -0
  133. package/dist/server/src/utils.d.ts +12 -0
  134. package/dist/server/src/utils.d.ts.map +1 -0
  135. package/package.json +64 -27
  136. package/.eslintignore +0 -2
  137. package/.eslintrc.js +0 -14
  138. package/admin/src/constants.js +0 -17
  139. package/admin/src/hooks/useDocumentation.js +0 -77
  140. package/admin/src/index.js +0 -82
  141. package/admin/src/pages/PluginPage/index.js +0 -230
  142. package/admin/src/pages/PluginPage/tests/index.test.js +0 -206
  143. package/admin/src/pages/SettingsPage/index.js +0 -211
  144. package/admin/src/pages/SettingsPage/tests/index.test.js +0 -124
  145. package/admin/src/pluginId.js +0 -5
  146. package/admin/src/utils/getTrad.js +0 -5
  147. package/admin/src/utils/index.js +0 -2
  148. package/jest.config.front.js +0 -7
  149. package/jest.config.js +0 -6
  150. package/server/bootstrap.js +0 -54
  151. package/server/config/default-plugin-config.js +0 -35
  152. package/server/config/index.js +0 -7
  153. package/server/controllers/documentation.js +0 -241
  154. package/server/controllers/index.js +0 -7
  155. package/server/index.js +0 -17
  156. package/server/middlewares/documentation.js +0 -25
  157. package/server/middlewares/index.js +0 -7
  158. package/server/middlewares/restrict-access.js +0 -24
  159. package/server/register.js +0 -11
  160. package/server/routes/index.js +0 -84
  161. package/server/services/__mocks__/mock-content-types.js +0 -269
  162. package/server/services/__mocks__/mock-strapi-data.js +0 -183
  163. package/server/services/__tests__/build-component-schema.test.js +0 -761
  164. package/server/services/__tests__/documentation.test.js +0 -481
  165. package/server/services/__tests__/override.test.js +0 -85
  166. package/server/services/documentation.js +0 -247
  167. package/server/services/helpers/build-api-endpoint-path.js +0 -186
  168. package/server/services/helpers/build-component-schema.js +0 -254
  169. package/server/services/helpers/index.js +0 -9
  170. package/server/services/helpers/utils/clean-schema-attributes.js +0 -244
  171. package/server/services/helpers/utils/get-api-responses.js +0 -105
  172. package/server/services/helpers/utils/get-schema-data.js +0 -32
  173. package/server/services/helpers/utils/loop-content-type-names.js +0 -55
  174. package/server/services/helpers/utils/pascal-case.js +0 -9
  175. package/server/services/helpers/utils/query-params.js +0 -105
  176. package/server/services/helpers/utils/routes.js +0 -10
  177. package/server/services/index.js +0 -9
  178. package/server/services/override.js +0 -52
  179. package/server/services/utils/default-openapi-components.js +0 -40
  180. package/server/services/utils/get-plugins-that-need-documentation.js +0 -24
  181. package/strapi-admin.js +0 -3
  182. package/strapi-server.js +0 -3
  183. package/tests/server.js +0 -37
  184. package/tests/setup.js +0 -15
package/LICENSE CHANGED
@@ -2,7 +2,21 @@ Copyright (c) 2015-present Strapi Solutions SAS
2
2
 
3
3
  Portions of the Strapi software are licensed as follows:
4
4
 
5
- * All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
5
+ * All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined below.
6
+
7
+ Enterprise License
8
+
9
+ If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at
10
+ https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you
11
+ represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have
12
+ agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software.
13
+ Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software.
14
+
15
+ BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT.
16
+ IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU
17
+ HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF
18
+ THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS;
19
+ IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.
6
20
 
7
21
  * All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
8
22
 
@@ -18,5 +32,6 @@ furnished to do so, subject to the following conditions:
18
32
  The above copyright notice and this permission notice shall be included in all
19
33
  copies or substantial portions of the Software.
20
34
 
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
37
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -59,7 +59,6 @@ It has the following structure
59
59
  ...
60
60
  },
61
61
  "x-strapi-config": {
62
- "path": "/documentation", // Change this line to change to url of the doc
63
62
  "showGeneratedFiles": true // Do not change this line at the moment...
64
63
  },
65
64
  "servers": {}, // Your servers config (it will be automated)
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const icons = require("@strapi/icons");
7
+ const admin = require("@strapi/strapi/admin");
8
+ const reactIntl = require("react-intl");
9
+ const styledComponents = require("styled-components");
10
+ const index = require("./index-BlmI1vCi.js");
11
+ const getTrad = require("./getTrad-DoREjbyy.js");
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
15
+ if (e) {
16
+ for (const k in e) {
17
+ if (k !== "default") {
18
+ const d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: () => e[k]
22
+ });
23
+ }
24
+ }
25
+ }
26
+ n.default = e;
27
+ return Object.freeze(n);
28
+ }
29
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
30
+ const App = () => {
31
+ const { formatMessage } = reactIntl.useIntl();
32
+ const { toggleNotification } = admin.useNotification();
33
+ const { formatAPIError } = admin.useAPIErrorHandler();
34
+ const { data, isLoading: isLoadingInfo, isError } = getTrad.useGetInfoQuery();
35
+ const [regenerate] = getTrad.useRegenerateDocMutation();
36
+ const [deleteVersion] = getTrad.useDeleteVersionMutation();
37
+ const [showConfirmDelete, setShowConfirmDelete] = React__namespace.useState(false);
38
+ const [versionToDelete, setVersionToDelete] = React__namespace.useState();
39
+ const { allowedActions, isLoading: isLoadingRBAC } = admin.useRBAC(index.PERMISSIONS);
40
+ const isLoading = isLoadingInfo || isLoadingRBAC;
41
+ const colCount = 4;
42
+ const rowCount = (data?.docVersions?.length || 0) + 1;
43
+ const handleRegenerateDoc = (version) => {
44
+ regenerate({ version }).unwrap().then(() => {
45
+ toggleNotification({
46
+ type: "success",
47
+ message: formatMessage({
48
+ id: getTrad.getTrad("notification.generate.success"),
49
+ defaultMessage: "Successfully generated documentation"
50
+ })
51
+ });
52
+ }).catch((err) => {
53
+ toggleNotification({
54
+ type: "warning",
55
+ message: formatAPIError(err)
56
+ });
57
+ });
58
+ };
59
+ const handleConfirmDelete = async () => {
60
+ if (!versionToDelete) {
61
+ return;
62
+ }
63
+ await deleteVersion({ version: versionToDelete }).unwrap().then(() => {
64
+ toggleNotification({
65
+ type: "success",
66
+ message: formatMessage({
67
+ id: getTrad.getTrad("notification.delete.success"),
68
+ defaultMessage: "Successfully deleted documentation"
69
+ })
70
+ });
71
+ }).catch((err) => {
72
+ toggleNotification({
73
+ type: "warning",
74
+ message: formatAPIError(err)
75
+ });
76
+ });
77
+ setShowConfirmDelete(!showConfirmDelete);
78
+ };
79
+ const handleClickDelete = (version) => {
80
+ setVersionToDelete(version);
81
+ setShowConfirmDelete(!showConfirmDelete);
82
+ };
83
+ const title = formatMessage({
84
+ id: getTrad.getTrad("plugin.name"),
85
+ defaultMessage: "Documentation"
86
+ });
87
+ if (isLoading) {
88
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
89
+ }
90
+ if (isError) {
91
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
92
+ }
93
+ return /* @__PURE__ */ jsxRuntime.jsxs(admin.Layouts.Root, { children: [
94
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Title, { children: title }),
95
+ /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
96
+ /* @__PURE__ */ jsxRuntime.jsx(
97
+ admin.Layouts.Header,
98
+ {
99
+ title,
100
+ subtitle: formatMessage({
101
+ id: getTrad.getTrad("pages.PluginPage.header.description"),
102
+ defaultMessage: "Configure the documentation plugin"
103
+ }),
104
+ primaryAction: /* @__PURE__ */ jsxRuntime.jsx(
105
+ OpenDocLink,
106
+ {
107
+ disabled: !allowedActions.canRead || !data?.currentVersion || !data?.prefix,
108
+ href: createDocumentationHref(`${data?.prefix}/v${data?.currentVersion}`),
109
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}),
110
+ children: formatMessage({
111
+ id: getTrad.getTrad("pages.PluginPage.Button.open"),
112
+ defaultMessage: "Open Documentation"
113
+ })
114
+ }
115
+ )
116
+ }
117
+ ),
118
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: data?.docVersions.length ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount, rowCount, children: [
119
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
120
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({
121
+ id: getTrad.getTrad("pages.PluginPage.table.version"),
122
+ defaultMessage: "Version"
123
+ }) }) }),
124
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({
125
+ id: getTrad.getTrad("pages.PluginPage.table.generated"),
126
+ defaultMessage: "Last Generated"
127
+ }) }) })
128
+ ] }) }),
129
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: data.docVersions.slice(0).sort((a, b) => a.generatedDate < b.generatedDate ? 1 : -1).map((doc) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
130
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "50%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: doc.version }) }),
131
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { width: "50%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: doc.generatedDate }) }),
132
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "end", onClick: (e) => e.stopPropagation(), children: [
133
+ /* @__PURE__ */ jsxRuntime.jsx(
134
+ designSystem.IconButton,
135
+ {
136
+ tag: "a",
137
+ disabled: !allowedActions.canRead,
138
+ href: createDocumentationHref(`${data.prefix}/v${doc.version}`),
139
+ variant: "ghost",
140
+ target: "_blank",
141
+ rel: "noopener noreferrer",
142
+ label: formatMessage(
143
+ {
144
+ id: getTrad.getTrad("pages.PluginPage.table.icon.show"),
145
+ defaultMessage: "Open {target}"
146
+ },
147
+ { target: `${doc.version}` }
148
+ ),
149
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
150
+ }
151
+ ),
152
+ allowedActions.canRegenerate ? /* @__PURE__ */ jsxRuntime.jsx(
153
+ designSystem.IconButton,
154
+ {
155
+ onClick: () => handleRegenerateDoc(doc.version),
156
+ variant: "ghost",
157
+ label: formatMessage(
158
+ {
159
+ id: getTrad.getTrad("pages.PluginPage.table.icon.regenerate"),
160
+ defaultMessage: "Regenerate {target}"
161
+ },
162
+ { target: `${doc.version}` }
163
+ ),
164
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {})
165
+ }
166
+ ) : null,
167
+ allowedActions.canUpdate && doc.version !== data.currentVersion ? /* @__PURE__ */ jsxRuntime.jsx(
168
+ designSystem.IconButton,
169
+ {
170
+ onClick: () => handleClickDelete(doc.version),
171
+ variant: "ghost",
172
+ label: formatMessage(
173
+ {
174
+ id: "global.delete-target",
175
+ defaultMessage: "Delete {target}"
176
+ },
177
+ { target: `${doc.version}` }
178
+ ),
179
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
180
+ }
181
+ ) : null
182
+ ] }) })
183
+ ] }, doc.version)) })
184
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.EmptyStateLayout, { content: "", icon: null }) }),
185
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: showConfirmDelete, onOpenChange: setShowConfirmDelete, children: /* @__PURE__ */ jsxRuntime.jsx(admin.ConfirmDialog, { onConfirm: handleConfirmDelete }) })
186
+ ] })
187
+ ] });
188
+ };
189
+ const OpenDocLink = styledComponents.styled(designSystem.LinkButton)`
190
+ text-decoration: none;
191
+ `;
192
+ const createDocumentationHref = (path) => {
193
+ if (path.startsWith("http")) {
194
+ return path;
195
+ }
196
+ if (path.startsWith("/")) {
197
+ return `${window.strapi.backendURL}${path}`;
198
+ }
199
+ return `${window.strapi.backendURL}/${path}`;
200
+ };
201
+ exports.App = App;
@@ -0,0 +1,183 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Table, Thead, Tr, Th, Typography, Tbody, Td, Flex, IconButton, EmptyStateLayout, Dialog, LinkButton } from "@strapi/design-system";
4
+ import { Eye, ArrowClockwise, Trash } from "@strapi/icons";
5
+ import { useNotification, useAPIErrorHandler, useRBAC, Page, Layouts, ConfirmDialog } from "@strapi/strapi/admin";
6
+ import { useIntl } from "react-intl";
7
+ import { styled } from "styled-components";
8
+ import { P as PERMISSIONS } from "./index-YnqsO7ap.mjs";
9
+ import { u as useGetInfoQuery, a as useRegenerateDocMutation, b as useDeleteVersionMutation, g as getTrad } from "./getTrad-BCVqzyys.mjs";
10
+ const App = () => {
11
+ const { formatMessage } = useIntl();
12
+ const { toggleNotification } = useNotification();
13
+ const { formatAPIError } = useAPIErrorHandler();
14
+ const { data, isLoading: isLoadingInfo, isError } = useGetInfoQuery();
15
+ const [regenerate] = useRegenerateDocMutation();
16
+ const [deleteVersion] = useDeleteVersionMutation();
17
+ const [showConfirmDelete, setShowConfirmDelete] = React.useState(false);
18
+ const [versionToDelete, setVersionToDelete] = React.useState();
19
+ const { allowedActions, isLoading: isLoadingRBAC } = useRBAC(PERMISSIONS);
20
+ const isLoading = isLoadingInfo || isLoadingRBAC;
21
+ const colCount = 4;
22
+ const rowCount = (data?.docVersions?.length || 0) + 1;
23
+ const handleRegenerateDoc = (version) => {
24
+ regenerate({ version }).unwrap().then(() => {
25
+ toggleNotification({
26
+ type: "success",
27
+ message: formatMessage({
28
+ id: getTrad("notification.generate.success"),
29
+ defaultMessage: "Successfully generated documentation"
30
+ })
31
+ });
32
+ }).catch((err) => {
33
+ toggleNotification({
34
+ type: "warning",
35
+ message: formatAPIError(err)
36
+ });
37
+ });
38
+ };
39
+ const handleConfirmDelete = async () => {
40
+ if (!versionToDelete) {
41
+ return;
42
+ }
43
+ await deleteVersion({ version: versionToDelete }).unwrap().then(() => {
44
+ toggleNotification({
45
+ type: "success",
46
+ message: formatMessage({
47
+ id: getTrad("notification.delete.success"),
48
+ defaultMessage: "Successfully deleted documentation"
49
+ })
50
+ });
51
+ }).catch((err) => {
52
+ toggleNotification({
53
+ type: "warning",
54
+ message: formatAPIError(err)
55
+ });
56
+ });
57
+ setShowConfirmDelete(!showConfirmDelete);
58
+ };
59
+ const handleClickDelete = (version) => {
60
+ setVersionToDelete(version);
61
+ setShowConfirmDelete(!showConfirmDelete);
62
+ };
63
+ const title = formatMessage({
64
+ id: getTrad("plugin.name"),
65
+ defaultMessage: "Documentation"
66
+ });
67
+ if (isLoading) {
68
+ return /* @__PURE__ */ jsx(Page.Loading, {});
69
+ }
70
+ if (isError) {
71
+ return /* @__PURE__ */ jsx(Page.Error, {});
72
+ }
73
+ return /* @__PURE__ */ jsxs(Layouts.Root, { children: [
74
+ /* @__PURE__ */ jsx(Page.Title, { children: title }),
75
+ /* @__PURE__ */ jsxs(Page.Main, { children: [
76
+ /* @__PURE__ */ jsx(
77
+ Layouts.Header,
78
+ {
79
+ title,
80
+ subtitle: formatMessage({
81
+ id: getTrad("pages.PluginPage.header.description"),
82
+ defaultMessage: "Configure the documentation plugin"
83
+ }),
84
+ primaryAction: /* @__PURE__ */ jsx(
85
+ OpenDocLink,
86
+ {
87
+ disabled: !allowedActions.canRead || !data?.currentVersion || !data?.prefix,
88
+ href: createDocumentationHref(`${data?.prefix}/v${data?.currentVersion}`),
89
+ startIcon: /* @__PURE__ */ jsx(Eye, {}),
90
+ children: formatMessage({
91
+ id: getTrad("pages.PluginPage.Button.open"),
92
+ defaultMessage: "Open Documentation"
93
+ })
94
+ }
95
+ )
96
+ }
97
+ ),
98
+ /* @__PURE__ */ jsx(Layouts.Content, { children: data?.docVersions.length ? /* @__PURE__ */ jsxs(Table, { colCount, rowCount, children: [
99
+ /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
100
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({
101
+ id: getTrad("pages.PluginPage.table.version"),
102
+ defaultMessage: "Version"
103
+ }) }) }),
104
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral600", children: formatMessage({
105
+ id: getTrad("pages.PluginPage.table.generated"),
106
+ defaultMessage: "Last Generated"
107
+ }) }) })
108
+ ] }) }),
109
+ /* @__PURE__ */ jsx(Tbody, { children: data.docVersions.slice(0).sort((a, b) => a.generatedDate < b.generatedDate ? 1 : -1).map((doc) => /* @__PURE__ */ jsxs(Tr, { children: [
110
+ /* @__PURE__ */ jsx(Td, { width: "50%", children: /* @__PURE__ */ jsx(Typography, { children: doc.version }) }),
111
+ /* @__PURE__ */ jsx(Td, { width: "50%", children: /* @__PURE__ */ jsx(Typography, { children: doc.generatedDate }) }),
112
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "end", onClick: (e) => e.stopPropagation(), children: [
113
+ /* @__PURE__ */ jsx(
114
+ IconButton,
115
+ {
116
+ tag: "a",
117
+ disabled: !allowedActions.canRead,
118
+ href: createDocumentationHref(`${data.prefix}/v${doc.version}`),
119
+ variant: "ghost",
120
+ target: "_blank",
121
+ rel: "noopener noreferrer",
122
+ label: formatMessage(
123
+ {
124
+ id: getTrad("pages.PluginPage.table.icon.show"),
125
+ defaultMessage: "Open {target}"
126
+ },
127
+ { target: `${doc.version}` }
128
+ ),
129
+ children: /* @__PURE__ */ jsx(Eye, {})
130
+ }
131
+ ),
132
+ allowedActions.canRegenerate ? /* @__PURE__ */ jsx(
133
+ IconButton,
134
+ {
135
+ onClick: () => handleRegenerateDoc(doc.version),
136
+ variant: "ghost",
137
+ label: formatMessage(
138
+ {
139
+ id: getTrad("pages.PluginPage.table.icon.regenerate"),
140
+ defaultMessage: "Regenerate {target}"
141
+ },
142
+ { target: `${doc.version}` }
143
+ ),
144
+ children: /* @__PURE__ */ jsx(ArrowClockwise, {})
145
+ }
146
+ ) : null,
147
+ allowedActions.canUpdate && doc.version !== data.currentVersion ? /* @__PURE__ */ jsx(
148
+ IconButton,
149
+ {
150
+ onClick: () => handleClickDelete(doc.version),
151
+ variant: "ghost",
152
+ label: formatMessage(
153
+ {
154
+ id: "global.delete-target",
155
+ defaultMessage: "Delete {target}"
156
+ },
157
+ { target: `${doc.version}` }
158
+ ),
159
+ children: /* @__PURE__ */ jsx(Trash, {})
160
+ }
161
+ ) : null
162
+ ] }) })
163
+ ] }, doc.version)) })
164
+ ] }) : /* @__PURE__ */ jsx(EmptyStateLayout, { content: "", icon: null }) }),
165
+ /* @__PURE__ */ jsx(Dialog.Root, { open: showConfirmDelete, onOpenChange: setShowConfirmDelete, children: /* @__PURE__ */ jsx(ConfirmDialog, { onConfirm: handleConfirmDelete }) })
166
+ ] })
167
+ ] });
168
+ };
169
+ const OpenDocLink = styled(LinkButton)`
170
+ text-decoration: none;
171
+ `;
172
+ const createDocumentationHref = (path) => {
173
+ if (path.startsWith("http")) {
174
+ return path;
175
+ }
176
+ if (path.startsWith("/")) {
177
+ return `${window.strapi.backendURL}${path}`;
178
+ }
179
+ return `${window.strapi.backendURL}/${path}`;
180
+ };
181
+ export {
182
+ App
183
+ };
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const designSystem = require("@strapi/design-system");
5
+ const admin = require("@strapi/strapi/admin");
6
+ const reactIntl = require("react-intl");
7
+ const React = require("react");
8
+ const icons = require("@strapi/icons");
9
+ const formik = require("formik");
10
+ const styledComponents = require("styled-components");
11
+ const yup = require("yup");
12
+ const index = require("./index-BlmI1vCi.js");
13
+ const getTrad = require("./getTrad-DoREjbyy.js");
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
17
+ if (e) {
18
+ for (const k in e) {
19
+ if (k !== "default") {
20
+ const d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: () => e[k]
24
+ });
25
+ }
26
+ }
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
32
+ const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
33
+ const isBaseQueryError = (error) => {
34
+ return error.name !== void 0;
35
+ };
36
+ const schema = yup__namespace.object().shape({
37
+ restrictedAccess: yup__namespace.boolean(),
38
+ password: yup__namespace.string().when("restrictedAccess", (value, initSchema) => {
39
+ return value ? initSchema.required(admin.translatedErrors.required.id).min(8).matches(/[a-z]/, "components.Input.error.contain.lowercase").matches(/[A-Z]/, "components.Input.error.contain.uppercase").matches(/\d/, "components.Input.error.contain.number") : initSchema;
40
+ })
41
+ });
42
+ const FieldActionWrapper = styledComponents.styled(designSystem.Field.Action)`
43
+ svg {
44
+ height: 1.6rem;
45
+ width: 1.6rem;
46
+ path {
47
+ fill: ${({ theme }) => theme.colors.neutral600};
48
+ }
49
+ }
50
+ `;
51
+ const SettingsForm = ({ data, onSubmit }) => {
52
+ const { formatMessage } = reactIntl.useIntl();
53
+ const [passwordShown, setPasswordShown] = React__namespace.useState(false);
54
+ const { allowedActions } = admin.useRBAC(index.PERMISSIONS);
55
+ return /* @__PURE__ */ jsxRuntime.jsx(
56
+ formik.Formik,
57
+ {
58
+ enableReinitialize: true,
59
+ initialValues: {
60
+ restrictedAccess: data?.documentationAccess.restrictedAccess || false,
61
+ password: ""
62
+ },
63
+ onSubmit,
64
+ validationSchema: schema,
65
+ children: ({
66
+ handleSubmit,
67
+ values,
68
+ handleChange,
69
+ errors,
70
+ setFieldTouched,
71
+ setFieldValue,
72
+ setFieldError,
73
+ dirty
74
+ }) => {
75
+ return /* @__PURE__ */ jsxRuntime.jsxs(formik.Form, { noValidate: true, onSubmit: handleSubmit, children: [
76
+ /* @__PURE__ */ jsxRuntime.jsx(
77
+ admin.Layouts.Header,
78
+ {
79
+ title: formatMessage({
80
+ id: getTrad.getTrad("plugin.name"),
81
+ defaultMessage: "Documentation"
82
+ }),
83
+ subtitle: formatMessage({
84
+ id: getTrad.getTrad("pages.SettingsPage.header.description"),
85
+ defaultMessage: "Configure the documentation plugin"
86
+ }),
87
+ primaryAction: /* @__PURE__ */ jsxRuntime.jsx(
88
+ designSystem.Button,
89
+ {
90
+ type: "submit",
91
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}),
92
+ disabled: !dirty && allowedActions.canUpdate,
93
+ children: formatMessage({
94
+ id: getTrad.getTrad("pages.SettingsPage.Button.save"),
95
+ defaultMessage: "Save"
96
+ })
97
+ }
98
+ )
99
+ }
100
+ ),
101
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
102
+ designSystem.Box,
103
+ {
104
+ background: "neutral0",
105
+ hasRadius: true,
106
+ shadow: "filterShadow",
107
+ paddingTop: 6,
108
+ paddingBottom: 6,
109
+ paddingLeft: 7,
110
+ paddingRight: 7,
111
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
112
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", tag: "h2", children: formatMessage({
113
+ id: "global.settings",
114
+ defaultMessage: "Settings"
115
+ }) }),
116
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
117
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsxs(
118
+ designSystem.Field.Root,
119
+ {
120
+ name: "restrictedAccess",
121
+ hint: formatMessage({
122
+ id: getTrad.getTrad("pages.SettingsPage.toggle.hint"),
123
+ defaultMessage: "Make the documentation endpoint private"
124
+ }),
125
+ children: [
126
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
127
+ id: getTrad.getTrad("pages.SettingsPage.toggle.label"),
128
+ defaultMessage: "Restricted Access"
129
+ }) }),
130
+ /* @__PURE__ */ jsxRuntime.jsx(
131
+ designSystem.Toggle,
132
+ {
133
+ checked: values.restrictedAccess,
134
+ onChange: () => {
135
+ if (values.restrictedAccess === true) {
136
+ setFieldValue("password", "", false);
137
+ setFieldTouched("password", false, false);
138
+ setFieldError("password", void 0);
139
+ }
140
+ setFieldValue("restrictedAccess", !values.restrictedAccess, false);
141
+ },
142
+ onLabel: "On",
143
+ offLabel: "Off"
144
+ }
145
+ ),
146
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
147
+ ]
148
+ }
149
+ ) }),
150
+ values.restrictedAccess && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsxs(
151
+ designSystem.Field.Root,
152
+ {
153
+ name: "password",
154
+ error: errors.password ? formatMessage({
155
+ id: errors.password,
156
+ defaultMessage: errors.password
157
+ }) : void 0,
158
+ children: [
159
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
160
+ id: "global.password",
161
+ defaultMessage: "Password"
162
+ }) }),
163
+ /* @__PURE__ */ jsxRuntime.jsx(
164
+ designSystem.TextInput,
165
+ {
166
+ placeholder: "**********",
167
+ type: passwordShown ? "text" : "password",
168
+ value: values.password,
169
+ onChange: handleChange,
170
+ endAction: /* @__PURE__ */ jsxRuntime.jsx(
171
+ FieldActionWrapper,
172
+ {
173
+ onClick: (e) => {
174
+ e.stopPropagation();
175
+ setPasswordShown((prev) => !prev);
176
+ },
177
+ label: formatMessage(
178
+ passwordShown ? {
179
+ id: "Auth.form.password.show-password",
180
+ defaultMessage: "Show password"
181
+ } : {
182
+ id: "Auth.form.password.hide-password",
183
+ defaultMessage: "Hide password"
184
+ }
185
+ ),
186
+ children: passwordShown ? /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.EyeStriked, {})
187
+ }
188
+ )
189
+ }
190
+ ),
191
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
192
+ ]
193
+ }
194
+ ) })
195
+ ] })
196
+ ] })
197
+ }
198
+ ) })
199
+ ] });
200
+ }
201
+ }
202
+ );
203
+ };
204
+ const SettingsPage = () => {
205
+ const { toggleNotification } = admin.useNotification();
206
+ const { formatMessage } = reactIntl.useIntl();
207
+ const {
208
+ _unstableFormatAPIError: formatAPIError,
209
+ _unstableFormatValidationErrors: formatValidationErrors
210
+ } = admin.useAPIErrorHandler();
211
+ const { data, isError, isLoading, isFetching } = getTrad.useGetInfoQuery();
212
+ const [updateSettings] = getTrad.useUpdateSettingsMutation();
213
+ const onUpdateSettings = async (body, formik2) => {
214
+ return updateSettings({ body }).unwrap().then(() => {
215
+ toggleNotification({
216
+ type: "success",
217
+ message: formatMessage({
218
+ id: getTrad.getTrad("notification.update.success"),
219
+ defaultMessage: "Successfully updated settings"
220
+ })
221
+ });
222
+ }).catch((err) => {
223
+ if (isBaseQueryError(err) && err.name === "ValidationError") {
224
+ toggleNotification({
225
+ type: "danger",
226
+ message: formatAPIError(err)
227
+ });
228
+ }
229
+ });
230
+ };
231
+ if (isLoading || isFetching) {
232
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Loading, {});
233
+ }
234
+ if (isError) {
235
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Error, {});
236
+ }
237
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Main, { children: /* @__PURE__ */ jsxRuntime.jsx(SettingsForm, { data, onSubmit: onUpdateSettings }) });
238
+ };
239
+ exports.SettingsPage = SettingsPage;