strapi-plugin-navigation 2.0.13 → 2.1.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.
Files changed (288) hide show
  1. package/README.md +105 -27
  2. package/admin/src/components/Alert/styles.d.ts +2 -0
  3. package/admin/src/components/Alert/styles.js +10 -4
  4. package/admin/src/components/CollapseButton/index.d.ts +7 -0
  5. package/admin/src/components/CollapseButton/index.js +21 -22
  6. package/admin/src/components/ConfirmationDialog/index.d.ts +28 -0
  7. package/admin/src/components/ConfirmationDialog/index.js +32 -54
  8. package/admin/src/components/EmptyView/index.d.ts +3 -0
  9. package/admin/src/components/EmptyView/index.js +9 -7
  10. package/admin/src/components/Item/ItemCardBadge/index.d.ts +3 -0
  11. package/admin/src/components/Item/ItemCardBadge/index.js +11 -7
  12. package/admin/src/components/Item/ItemCardHeader/Wrapper.d.ts +3 -0
  13. package/admin/src/components/Item/ItemCardHeader/Wrapper.js +10 -6
  14. package/admin/src/components/Item/ItemCardHeader/index.d.ts +12 -0
  15. package/admin/src/components/Item/ItemCardHeader/index.js +33 -52
  16. package/admin/src/components/Item/ItemCardRemovedOverlay/index.d.ts +2 -0
  17. package/admin/src/components/Item/ItemCardRemovedOverlay/index.js +10 -4
  18. package/admin/src/components/Item/Wrapper.d.ts +3 -0
  19. package/admin/src/components/Item/Wrapper.js +10 -6
  20. package/admin/src/components/Item/index.d.ts +31 -0
  21. package/admin/src/components/Item/index.js +163 -242
  22. package/admin/src/components/NavigationItemList/Wrapper.d.ts +3 -0
  23. package/admin/src/components/NavigationItemList/Wrapper.js +9 -5
  24. package/admin/src/components/NavigationItemList/index.d.ts +35 -0
  25. package/admin/src/components/NavigationItemList/index.js +28 -66
  26. package/admin/src/components/RestartAlert/index.d.ts +3 -0
  27. package/admin/src/components/RestartAlert/index.js +10 -5
  28. package/admin/src/components/Search/index.d.ts +6 -0
  29. package/admin/src/components/Search/index.js +57 -46
  30. package/admin/src/components/icons/navigation.d.ts +6 -0
  31. package/admin/src/components/icons/navigation.js +11 -13
  32. package/admin/src/contexts/DataManagerContext.d.ts +3 -0
  33. package/admin/src/contexts/DataManagerContext.js +6 -5
  34. package/admin/src/hooks/useAllContentTypes.d.ts +6 -0
  35. package/admin/src/hooks/useAllContentTypes.js +10 -11
  36. package/admin/src/hooks/useDataManager.d.ts +3 -0
  37. package/admin/src/hooks/useDataManager.js +10 -6
  38. package/admin/src/hooks/useI18nCopyNavigationItemsModal.d.ts +9 -0
  39. package/admin/src/hooks/useI18nCopyNavigationItemsModal.js +51 -0
  40. package/admin/src/hooks/useNavigationConfig.d.ts +10 -0
  41. package/admin/src/hooks/useNavigationConfig.js +52 -56
  42. package/admin/src/hooks/useNavigationManager.d.ts +7 -0
  43. package/admin/src/hooks/useNavigationManager.js +41 -0
  44. package/admin/src/index.d.ts +14 -0
  45. package/admin/src/index.js +92 -76
  46. package/admin/src/pages/App/index.d.ts +3 -0
  47. package/admin/src/pages/App/index.js +43 -31
  48. package/admin/src/pages/DataManagerProvider/actions.d.ts +19 -0
  49. package/admin/src/pages/DataManagerProvider/actions.js +22 -26
  50. package/admin/src/pages/DataManagerProvider/index.d.ts +12 -0
  51. package/admin/src/pages/DataManagerProvider/index.js +316 -298
  52. package/admin/src/pages/DataManagerProvider/init.d.ts +3 -0
  53. package/admin/src/pages/DataManagerProvider/init.js +5 -3
  54. package/admin/src/pages/DataManagerProvider/reducer.d.ts +19 -0
  55. package/admin/src/pages/DataManagerProvider/reducer.js +119 -121
  56. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.d.ts +24 -0
  57. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.js +88 -0
  58. package/admin/src/pages/SettingsPage/index.d.ts +3 -0
  59. package/admin/src/pages/SettingsPage/index.js +242 -335
  60. package/admin/src/pages/SettingsPage/utils/functions.d.ts +5 -0
  61. package/admin/src/pages/SettingsPage/utils/functions.js +3 -8
  62. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts +14 -0
  63. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js +15 -0
  64. package/admin/src/pages/View/components/NavigationContentHeader/index.d.ts +6 -0
  65. package/admin/src/pages/View/components/NavigationContentHeader/index.js +13 -17
  66. package/admin/src/pages/View/components/NavigationHeader/index.d.ts +12 -0
  67. package/admin/src/pages/View/components/NavigationHeader/index.js +79 -65
  68. package/admin/src/pages/View/components/NavigationHeader/styles.d.ts +2 -0
  69. package/admin/src/pages/View/components/NavigationHeader/styles.js +10 -5
  70. package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +57 -0
  71. package/admin/src/pages/View/components/NavigationItemForm/index.js +416 -453
  72. package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +45 -0
  73. package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +84 -52
  74. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.d.ts +23 -0
  75. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +24 -34
  76. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.d.ts +4 -0
  77. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +16 -16
  78. package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts +30 -0
  79. package/admin/src/pages/View/components/NavigationItemPopup/index.js +85 -108
  80. package/admin/src/pages/View/components/NavigationManager/Create/index.d.ts +9 -0
  81. package/admin/src/pages/View/components/NavigationManager/Create/index.js +57 -0
  82. package/admin/src/pages/View/components/NavigationManager/Delete/index.d.ts +8 -0
  83. package/admin/src/pages/View/components/NavigationManager/Delete/index.js +28 -0
  84. package/admin/src/pages/View/components/NavigationManager/Edit/index.d.ts +8 -0
  85. package/admin/src/pages/View/components/NavigationManager/Edit/index.js +54 -0
  86. package/admin/src/pages/View/components/NavigationManager/Error/index.d.ts +8 -0
  87. package/admin/src/pages/View/components/NavigationManager/Error/index.js +53 -0
  88. package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +19 -0
  89. package/admin/src/pages/View/components/NavigationManager/Form/index.js +98 -0
  90. package/admin/src/pages/View/components/NavigationManager/List/index.d.ts +8 -0
  91. package/admin/src/pages/View/components/NavigationManager/List/index.js +138 -0
  92. package/admin/src/pages/View/components/NavigationManager/index.d.ts +10 -0
  93. package/admin/src/pages/View/components/NavigationManager/index.js +189 -0
  94. package/admin/src/pages/View/components/NavigationManager/types.d.ts +53 -0
  95. package/admin/src/pages/View/components/NavigationManager/types.js +3 -0
  96. package/admin/src/pages/View/index.d.ts +4 -0
  97. package/admin/src/pages/View/index.js +231 -304
  98. package/admin/src/pages/View/utils/enums.d.ts +9 -0
  99. package/admin/src/pages/View/utils/enums.js +11 -8
  100. package/admin/src/pages/View/utils/form.d.ts +2 -0
  101. package/admin/src/pages/View/utils/form.js +15 -12
  102. package/admin/src/pages/View/utils/index.d.ts +2 -0
  103. package/admin/src/pages/View/utils/index.js +11 -3
  104. package/admin/src/pages/View/utils/parsers.d.ts +49 -0
  105. package/admin/src/pages/View/utils/parsers.js +239 -278
  106. package/admin/src/permissions.d.ts +12 -0
  107. package/admin/src/permissions.js +11 -7
  108. package/admin/src/pluginId.d.ts +3 -0
  109. package/admin/src/pluginId.js +2 -2
  110. package/admin/src/translations/en.json +157 -104
  111. package/admin/src/translations/fr.json +44 -44
  112. package/admin/src/translations/index.d.ts +12 -0
  113. package/admin/src/translations/index.js +17 -11
  114. package/admin/src/utils/api.d.ts +8 -0
  115. package/admin/src/utils/api.js +54 -50
  116. package/admin/src/utils/getTrad.d.ts +3 -0
  117. package/admin/src/utils/getTrad.js +9 -5
  118. package/admin/src/utils/index.d.ts +18 -0
  119. package/admin/src/utils/index.js +36 -15
  120. package/package.json +20 -19
  121. package/permissions.d.ts +9 -0
  122. package/permissions.js +5 -4
  123. package/server/bootstrap/index.d.ts +4 -0
  124. package/server/bootstrap/index.js +41 -0
  125. package/server/config/index.d.ts +5 -0
  126. package/server/config/index.js +33 -9
  127. package/server/config/setupStrategy.d.ts +3 -0
  128. package/server/config/setupStrategy.js +38 -0
  129. package/server/content-types/audience/index.d.ts +27 -0
  130. package/server/content-types/audience/index.js +9 -8
  131. package/server/content-types/audience/schema.d.ts +25 -0
  132. package/server/content-types/audience/schema.js +26 -0
  133. package/server/content-types/index.d.ts +255 -0
  134. package/server/content-types/index.js +15 -12
  135. package/server/content-types/navigation/index.d.ts +64 -0
  136. package/server/content-types/navigation/index.js +11 -8
  137. package/server/content-types/navigation/lifecycle.d.ts +9 -0
  138. package/server/content-types/navigation/lifecycle.js +8 -12
  139. package/server/content-types/navigation/schema.d.ts +55 -0
  140. package/server/content-types/navigation/schema.js +56 -0
  141. package/server/content-types/navigation-item/index.d.ts +112 -0
  142. package/server/content-types/navigation-item/index.js +11 -8
  143. package/server/content-types/navigation-item/lifecycle.d.ts +16 -0
  144. package/server/content-types/navigation-item/lifecycle.js +28 -32
  145. package/server/content-types/navigation-item/schema.d.ts +97 -0
  146. package/server/content-types/navigation-item/schema.js +102 -0
  147. package/server/content-types/navigations-items-related/index.d.ts +56 -0
  148. package/server/content-types/navigations-items-related/index.js +11 -8
  149. package/server/content-types/navigations-items-related/lifecycle.d.ts +8 -0
  150. package/server/content-types/navigations-items-related/lifecycle.js +20 -17
  151. package/server/content-types/navigations-items-related/schema.d.ts +49 -0
  152. package/server/content-types/navigations-items-related/schema.js +50 -0
  153. package/server/controllers/admin.d.ts +4 -0
  154. package/server/controllers/admin.js +130 -0
  155. package/server/controllers/client.d.ts +4 -0
  156. package/server/controllers/client.js +57 -0
  157. package/server/controllers/index.d.ts +4 -0
  158. package/server/controllers/index.js +12 -6
  159. package/server/destroy.d.ts +3 -0
  160. package/server/destroy.js +5 -0
  161. package/server/graphql/config.d.ts +4 -0
  162. package/server/graphql/config.js +28 -0
  163. package/server/graphql/index.d.ts +2 -0
  164. package/server/graphql/index.js +18 -22
  165. package/server/graphql/queries/index.d.ts +3 -0
  166. package/server/graphql/queries/index.js +15 -15
  167. package/server/graphql/queries/render-navigation-child.d.ts +15 -0
  168. package/server/graphql/queries/render-navigation-child.js +24 -15
  169. package/server/graphql/queries/render-navigation.d.ts +21 -0
  170. package/server/graphql/queries/render-navigation.js +31 -15
  171. package/server/graphql/resolvers-config.d.ts +10 -0
  172. package/server/graphql/resolvers-config.js +5 -3
  173. package/server/graphql/setupStrategy.d.ts +3 -0
  174. package/server/graphql/setupStrategy.js +15 -0
  175. package/server/graphql/types/content-types-name-fields.d.ts +6 -0
  176. package/server/graphql/types/content-types-name-fields.js +13 -9
  177. package/server/graphql/types/content-types.d.ts +5 -0
  178. package/server/graphql/types/content-types.js +17 -15
  179. package/server/graphql/types/create-navigation-item.d.ts +5 -0
  180. package/server/graphql/types/create-navigation-item.js +18 -16
  181. package/server/graphql/types/create-navigation-related.d.ts +5 -0
  182. package/server/graphql/types/create-navigation-related.js +9 -7
  183. package/server/graphql/types/create-navigation.d.ts +5 -0
  184. package/server/graphql/types/create-navigation.js +8 -6
  185. package/server/graphql/types/index.d.ts +3 -0
  186. package/server/graphql/types/index.js +15 -13
  187. package/server/graphql/types/navigation-config.d.ts +5 -0
  188. package/server/graphql/types/navigation-config.js +10 -8
  189. package/server/graphql/types/navigation-details.d.ts +5 -0
  190. package/server/graphql/types/navigation-details.js +11 -9
  191. package/server/graphql/types/navigation-item-related-data.d.ts +5 -0
  192. package/server/graphql/types/navigation-item-related-data.js +9 -0
  193. package/server/graphql/types/navigation-item-related.d.ts +7 -0
  194. package/server/graphql/types/navigation-item-related.js +25 -0
  195. package/server/graphql/types/navigation-item.d.ts +5 -0
  196. package/server/graphql/types/navigation-item.js +28 -29
  197. package/server/graphql/types/navigation-render-type.d.ts +5 -0
  198. package/server/graphql/types/navigation-render-type.js +7 -4
  199. package/server/graphql/types/navigation.d.ts +5 -0
  200. package/server/graphql/types/navigation.js +10 -8
  201. package/server/i18n/constant.d.ts +2 -0
  202. package/server/i18n/constant.js +5 -0
  203. package/server/i18n/errors.d.ts +7 -0
  204. package/server/i18n/errors.js +14 -0
  205. package/server/i18n/graphQLEnhancers.d.ts +10 -0
  206. package/server/i18n/graphQLEnhancers.js +10 -0
  207. package/server/i18n/index.d.ts +8 -0
  208. package/server/i18n/index.js +23 -0
  209. package/server/i18n/navigationSetupStrategy.d.ts +3 -0
  210. package/server/i18n/navigationSetupStrategy.js +119 -0
  211. package/server/i18n/serviceEnhancers.d.ts +13 -0
  212. package/server/i18n/serviceEnhancers.js +156 -0
  213. package/server/i18n/types.d.ts +60 -0
  214. package/server/i18n/types.js +3 -0
  215. package/server/i18n/utils.d.ts +12 -0
  216. package/server/i18n/utils.js +29 -0
  217. package/server/index.d.ts +273 -0
  218. package/server/index.js +26 -0
  219. package/server/navigation/index.d.ts +2 -0
  220. package/server/navigation/index.js +18 -0
  221. package/server/navigation/setupStrategy.d.ts +3 -0
  222. package/server/navigation/setupStrategy.js +39 -0
  223. package/server/register/index.d.ts +3 -0
  224. package/server/register/index.js +4 -0
  225. package/server/routes/admin.d.ts +4 -0
  226. package/server/routes/admin.js +82 -61
  227. package/server/routes/client.d.ts +4 -0
  228. package/server/routes/client.js +25 -21
  229. package/server/routes/index.d.ts +6 -0
  230. package/server/routes/index.js +13 -4
  231. package/server/services/admin.d.ts +5 -0
  232. package/server/services/admin.js +238 -0
  233. package/server/services/client.d.ts +5 -0
  234. package/server/services/client.js +249 -0
  235. package/server/services/common.d.ts +5 -0
  236. package/server/services/common.js +313 -0
  237. package/server/services/index.d.ts +7 -0
  238. package/server/services/index.js +14 -6
  239. package/server/utils/constant.d.ts +27 -0
  240. package/server/utils/constant.js +24 -0
  241. package/server/utils/functions.d.ts +139 -0
  242. package/server/utils/functions.js +226 -0
  243. package/server/utils/index.d.ts +3 -0
  244. package/server/utils/index.js +19 -0
  245. package/strapi-admin.d.ts +3 -0
  246. package/strapi-admin.js +8 -1
  247. package/strapi-server.d.ts +273 -0
  248. package/strapi-server.js +6 -17
  249. package/tsconfig.tsbuildinfo +1 -0
  250. package/types/bootstrap.d.ts +13 -0
  251. package/types/bootstrap.js +3 -0
  252. package/types/config.d.ts +21 -0
  253. package/types/config.js +3 -0
  254. package/types/contentTypes.d.ts +85 -0
  255. package/types/contentTypes.js +3 -0
  256. package/types/controllers.d.ts +48 -0
  257. package/types/controllers.js +5 -0
  258. package/types/graphQL.d.ts +3 -0
  259. package/types/graphQL.js +3 -0
  260. package/types/i18n.d.ts +9 -0
  261. package/types/i18n.js +3 -0
  262. package/types/index.d.ts +9 -0
  263. package/types/index.js +25 -0
  264. package/types/services.d.ts +74 -0
  265. package/types/services.js +3 -0
  266. package/types/utils.d.ts +62 -0
  267. package/types/utils.js +27 -0
  268. package/utils/InvalidParamNavigationError.d.ts +4 -0
  269. package/utils/InvalidParamNavigationError.js +8 -0
  270. package/utils/NavigationError.d.ts +5 -0
  271. package/utils/NavigationError.js +7 -7
  272. package/__mocks__/pages.settings.json +0 -25
  273. package/__mocks__/strapi.js +0 -207
  274. package/jest.config.js +0 -14
  275. package/server/bootstrap.js +0 -52
  276. package/server/config.js +0 -9
  277. package/server/content-types/audience/lifecycle.js +0 -8
  278. package/server/content-types/audience/schema.json +0 -23
  279. package/server/content-types/navigation/schema.json +0 -45
  280. package/server/content-types/navigation-item/schema.json +0 -99
  281. package/server/content-types/navigations-items-related/schema.json +0 -47
  282. package/server/controllers/navigation.js +0 -105
  283. package/server/graphql/types/navigation-related.js +0 -25
  284. package/server/services/__tests__/functions.test.js +0 -48
  285. package/server/services/__tests__/navigation.test.js +0 -91
  286. package/server/services/navigation.js +0 -791
  287. package/server/services/utils/constant.js +0 -21
  288. package/server/services/utils/functions.js +0 -226
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const bootstrap_1 = __importDefault(require("./bootstrap"));
7
+ const config_1 = __importDefault(require("./config"));
8
+ const content_types_1 = __importDefault(require("./content-types"));
9
+ const controllers_1 = __importDefault(require("./controllers"));
10
+ const destroy_1 = __importDefault(require("./destroy"));
11
+ const register_1 = __importDefault(require("./register"));
12
+ const routes_1 = __importDefault(require("./routes"));
13
+ const services_1 = __importDefault(require("./services"));
14
+ exports.default = {
15
+ bootstrap: bootstrap_1.default,
16
+ config: config_1.default,
17
+ contentTypes: content_types_1.default,
18
+ controllers: controllers_1.default,
19
+ destroy: destroy_1.default,
20
+ middlewares: {},
21
+ policies: {},
22
+ register: register_1.default,
23
+ routes: routes_1.default,
24
+ services: services_1.default,
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export * from "./setupStrategy";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./setupStrategy"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ import { INavigationSetupStrategy } from "../../types";
2
+ export declare const navigationSetupStrategy: INavigationSetupStrategy;
3
+ //# sourceMappingURL=setupStrategy.d.ts.map
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.navigationSetupStrategy = void 0;
4
+ const i18n_1 = require("../i18n");
5
+ const utils_1 = require("../utils");
6
+ const navigationSetupStrategy = async (context) => {
7
+ const i18nPlugin = context.strapi.plugin("i18n");
8
+ const defaultLocale = i18nPlugin ? await i18nPlugin.service("locales").getDefaultLocale() : null;
9
+ if (defaultLocale) {
10
+ return await (0, i18n_1.i18nNavigationSetupStrategy)(context);
11
+ }
12
+ else {
13
+ return await regularNavigationSetupStrategy(context);
14
+ }
15
+ };
16
+ exports.navigationSetupStrategy = navigationSetupStrategy;
17
+ const regularNavigationSetupStrategy = async ({ strapi, }) => {
18
+ const navigations = await getCurrentNavigations();
19
+ if (!navigations.length) {
20
+ return [
21
+ await createNavigation({
22
+ strapi,
23
+ payload: {
24
+ ...utils_1.DEFAULT_NAVIGATION_ITEM,
25
+ },
26
+ populate: utils_1.DEFAULT_POPULATE
27
+ }),
28
+ ];
29
+ }
30
+ return navigations;
31
+ };
32
+ const createNavigation = ({ strapi, payload, populate }) => strapi.query("plugin::navigation.navigation").create({
33
+ data: {
34
+ ...payload,
35
+ },
36
+ populate,
37
+ });
38
+ const getCurrentNavigations = () => (0, utils_1.getPluginService)('admin').get();
39
+ //# sourceMappingURL=setupStrategy.js.map
@@ -0,0 +1,3 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = async () => { };
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ import { StrapiRoutes } from "../../types";
2
+ declare const routes: StrapiRoutes;
3
+ export default routes;
4
+ //# sourceMappingURL=admin.d.ts.map
@@ -1,61 +1,82 @@
1
- module.exports = {
2
- type: 'admin',
3
- routes: [
4
- {
5
- method: 'GET',
6
- path: '/',
7
- handler: 'navigation.get',
8
- },
9
- {
10
- method: 'POST',
11
- path: '/',
12
- handler: 'navigation.post',
13
- },
14
- {
15
- method: 'GET',
16
- path: '/config',
17
- handler: 'navigation.config',
18
- },
19
- {
20
- method: 'PUT',
21
- path: '/config',
22
- handler: 'navigation.updateConfig',
23
- },
24
- {
25
- method: 'DELETE',
26
- path: '/config',
27
- handler: 'navigation.restoreConfig',
28
- },
29
- {
30
- method: 'GET',
31
- path: '/:id',
32
- handler: 'navigation.getById',
33
- },
34
- {
35
- method: 'PUT',
36
- path: '/:id',
37
- handler: 'navigation.put',
38
- },
39
- {
40
- method: 'GET',
41
- path: '/content-type-items/:model',
42
- handler: 'navigation.getContentTypeItems',
43
- policies: [
44
- 'admin::isAuthenticatedAdmin'
45
- ]
46
- },
47
- {
48
- method: 'GET',
49
- path: '/settings/config',
50
- handler: 'navigation.settingsConfig',
51
- },
52
- {
53
- method: 'GET',
54
- path: '/settings/restart',
55
- handler: 'navigation.settingsRestart',
56
- config: {
57
- policies: [],
58
- },
59
- },
60
- ]
61
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const routes = {
4
+ type: 'admin',
5
+ routes: [
6
+ {
7
+ method: 'GET',
8
+ path: '/',
9
+ handler: 'admin.get',
10
+ },
11
+ {
12
+ method: 'POST',
13
+ path: '/',
14
+ handler: 'admin.post',
15
+ },
16
+ {
17
+ method: 'GET',
18
+ path: '/config',
19
+ handler: 'admin.config',
20
+ },
21
+ {
22
+ method: 'PUT',
23
+ path: '/config',
24
+ handler: 'admin.updateConfig',
25
+ },
26
+ {
27
+ method: 'DELETE',
28
+ path: '/config',
29
+ handler: 'admin.restoreConfig',
30
+ },
31
+ {
32
+ method: 'GET',
33
+ path: '/:id',
34
+ handler: 'admin.getById',
35
+ },
36
+ {
37
+ method: 'PUT',
38
+ path: '/:id',
39
+ handler: 'admin.put',
40
+ },
41
+ {
42
+ method: 'DELETE',
43
+ path: '/:id',
44
+ handler: 'admin.delete',
45
+ },
46
+ {
47
+ method: 'GET',
48
+ path: '/content-type-items/:model',
49
+ handler: 'admin.getContentTypeItems',
50
+ config: {
51
+ policies: [
52
+ 'admin::isAuthenticatedAdmin'
53
+ ]
54
+ }
55
+ },
56
+ {
57
+ method: 'GET',
58
+ path: '/settings/config',
59
+ handler: 'admin.settingsConfig',
60
+ },
61
+ {
62
+ method: 'GET',
63
+ path: '/settings/restart',
64
+ handler: 'admin.settingsRestart',
65
+ config: {
66
+ policies: [],
67
+ },
68
+ },
69
+ {
70
+ method: 'PUT',
71
+ path: '/i18n/copy/:source/:target',
72
+ handler: 'admin.fillFromOtherLocale',
73
+ },
74
+ {
75
+ method: 'GET',
76
+ path: '/i18n/item/read/:source/:target',
77
+ handler: 'admin.readNavigationItemFromLocale',
78
+ },
79
+ ]
80
+ };
81
+ exports.default = routes;
82
+ //# sourceMappingURL=admin.js.map
@@ -0,0 +1,4 @@
1
+ import { StrapiRoutes } from "../../types";
2
+ declare const routes: StrapiRoutes;
3
+ export default routes;
4
+ //# sourceMappingURL=client.d.ts.map
@@ -1,21 +1,25 @@
1
- module.exports = {
2
- type: 'content-api',
3
- routes: [
4
- {
5
- method: "GET",
6
- path: "/render/:idOrSlug",
7
- handler: "navigation.render",
8
- config: {
9
- policies: []
10
- }
11
- },
12
- {
13
- method: "GET",
14
- path: "/render/:idOrSlug/:childUIKey",
15
- handler: "navigation.renderChild",
16
- config: {
17
- policies: []
18
- }
19
- }
20
- ]
21
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const routes = {
4
+ type: 'content-api',
5
+ routes: [
6
+ {
7
+ method: "GET",
8
+ path: "/render/:idOrSlug",
9
+ handler: "client.render",
10
+ config: {
11
+ policies: []
12
+ }
13
+ },
14
+ {
15
+ method: "GET",
16
+ path: "/render/:idOrSlug/:childUIKey",
17
+ handler: "client.renderChild",
18
+ config: {
19
+ policies: []
20
+ }
21
+ }
22
+ ]
23
+ };
24
+ exports.default = routes;
25
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,6 @@
1
+ declare const routes: {
2
+ admin: import("../../types").StrapiRoutes;
3
+ 'content-api': import("../../types").StrapiRoutes;
4
+ };
5
+ export default routes;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,13 @@
1
- module.exports = {
2
- 'admin': require('./admin'),
3
- 'content-api': require('./client'),
4
- };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const admin_1 = __importDefault(require("./admin"));
7
+ const client_1 = __importDefault(require("./client"));
8
+ const routes = {
9
+ admin: admin_1.default,
10
+ 'content-api': client_1.default,
11
+ };
12
+ exports.default = routes;
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,5 @@
1
+ import { StrapiContext } from "strapi-typed";
2
+ import { IAdminService } from "../../types";
3
+ declare const adminService: (context: StrapiContext) => IAdminService;
4
+ export default adminService;
5
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("@strapi/utils");
7
+ const slugify_1 = __importDefault(require("slugify"));
8
+ const lodash_1 = require("lodash");
9
+ const utils_2 = require("../utils");
10
+ const i18n_1 = require("../i18n");
11
+ const NavigationError_1 = require("../../utils/NavigationError");
12
+ const adminService = ({ strapi }) => ({
13
+ async config(viaSettingsPage = false) {
14
+ const commonService = (0, utils_2.getPluginService)('common');
15
+ const { audienceModel } = (0, utils_2.extractMeta)(strapi.plugins);
16
+ const pluginStore = await commonService.getPluginStore();
17
+ const config = await pluginStore.get({ key: 'config' });
18
+ const additionalFields = config.additionalFields;
19
+ const contentTypesNameFields = config.contentTypesNameFields;
20
+ const contentTypesPopulate = config.contentTypesPopulate;
21
+ const allowedLevels = config.allowedLevels;
22
+ const isGQLPluginEnabled = !(0, lodash_1.isNil)(strapi.plugin('graphql'));
23
+ let extendedResult = {
24
+ allowedContentTypes: utils_2.ALLOWED_CONTENT_TYPES,
25
+ restrictedContentTypes: utils_2.RESTRICTED_CONTENT_TYPES,
26
+ };
27
+ const configContentTypes = await commonService.configContentTypes();
28
+ const result = {
29
+ contentTypes: await commonService.configContentTypes(viaSettingsPage),
30
+ contentTypesNameFields: {
31
+ default: utils_2.CONTENT_TYPES_NAME_FIELDS_DEFAULTS,
32
+ ...((0, lodash_1.isObject)(contentTypesNameFields) ? contentTypesNameFields : {}),
33
+ },
34
+ contentTypesPopulate: {
35
+ ...((0, lodash_1.isObject)(contentTypesPopulate) ? contentTypesPopulate : {}),
36
+ },
37
+ allowedLevels,
38
+ additionalFields,
39
+ gql: {
40
+ navigationItemRelated: configContentTypes.map(({ labelSingular }) => labelSingular.replace(/\s+/g, ''))
41
+ },
42
+ isGQLPluginEnabled: viaSettingsPage ? isGQLPluginEnabled : undefined,
43
+ };
44
+ const i18nConfig = await (0, i18n_1.addI18NConfigFields)({ strapi, viaSettingsPage, previousConfig: {} });
45
+ if (additionalFields.includes(utils_2.ADDITIONAL_FIELDS.AUDIENCE)) {
46
+ const audienceItems = await strapi
47
+ .query(audienceModel.uid)
48
+ .findMany({
49
+ limit: Number.MAX_SAFE_INTEGER,
50
+ });
51
+ extendedResult = {
52
+ ...extendedResult,
53
+ availableAudience: audienceItems,
54
+ };
55
+ }
56
+ return {
57
+ ...result,
58
+ ...extendedResult,
59
+ ...i18nConfig,
60
+ };
61
+ },
62
+ async get() {
63
+ const { masterModel } = (0, utils_2.extractMeta)(strapi.plugins);
64
+ const entities = await strapi
65
+ .query(masterModel.uid)
66
+ .findMany({
67
+ limit: Number.MAX_SAFE_INTEGER,
68
+ populate: utils_2.DEFAULT_POPULATE,
69
+ });
70
+ return entities;
71
+ },
72
+ async getById(id) {
73
+ const commonService = (0, utils_2.getPluginService)('common');
74
+ const { masterModel, itemModel } = (0, utils_2.extractMeta)(strapi.plugins);
75
+ const entity = await strapi
76
+ .query(masterModel.uid)
77
+ .findOne({ where: { id }, populate: utils_2.DEFAULT_POPULATE });
78
+ const entityItems = await strapi
79
+ .query(itemModel.uid)
80
+ .findMany({
81
+ where: {
82
+ master: id,
83
+ },
84
+ limit: Number.MAX_SAFE_INTEGER,
85
+ orderBy: [{ order: 'asc', }],
86
+ populate: ['related', 'parent', 'audience']
87
+ });
88
+ const entities = await commonService.getRelatedItems(entityItems);
89
+ return {
90
+ ...entity,
91
+ items: (0, utils_2.buildNestedStructure)(entities),
92
+ };
93
+ },
94
+ async post(payload, auditLog) {
95
+ const commonService = (0, utils_2.getPluginService)('common');
96
+ const adminService = (0, utils_2.getPluginService)('admin');
97
+ const { enabled: i18nEnabled, defaultLocale } = await (0, i18n_1.getI18nStatus)({ strapi });
98
+ const { masterModel } = (0, utils_2.extractMeta)(strapi.plugins);
99
+ const { name, visible } = payload;
100
+ const data = {
101
+ name,
102
+ slug: (0, slugify_1.default)(name).toLowerCase(),
103
+ visible,
104
+ };
105
+ const existingEntity = await strapi
106
+ .query(masterModel.uid)
107
+ .create({ data });
108
+ const result = commonService
109
+ .createBranch(payload.items, existingEntity, null, {})
110
+ .then(() => adminService.getById(existingEntity.id))
111
+ .then((newEntity) => {
112
+ (0, utils_2.sendAuditLog)(auditLog, 'onChangeNavigation', { actionType: 'CREATE', oldEntity: existingEntity, newEntity });
113
+ return newEntity;
114
+ });
115
+ await commonService.emitEvent(masterModel.uid, 'entry.create', existingEntity);
116
+ if (i18nEnabled && defaultLocale) {
117
+ await (0, i18n_1.i18nNavigationSetupStrategy)({ strapi });
118
+ }
119
+ return result;
120
+ },
121
+ async put(id, payload, auditLog) {
122
+ const adminService = (0, utils_2.getPluginService)('admin');
123
+ const commonService = (0, utils_2.getPluginService)('common');
124
+ const { enabled: i18nEnabled } = await (0, i18n_1.getI18nStatus)({ strapi });
125
+ const { masterModel } = (0, utils_2.extractMeta)(strapi.plugins);
126
+ const { name, visible } = payload;
127
+ const existingEntity = await adminService.getById(id);
128
+ const detailsHaveChanged = existingEntity.name !== name || existingEntity.visible !== visible;
129
+ if (detailsHaveChanged) {
130
+ const newName = detailsHaveChanged ? name : existingEntity.name;
131
+ const newSlug = detailsHaveChanged ? (0, slugify_1.default)(name).toLowerCase() : existingEntity.slug;
132
+ await strapi.query(masterModel.uid).update({
133
+ where: { id },
134
+ data: {
135
+ name: newName,
136
+ slug: newSlug,
137
+ visible,
138
+ },
139
+ });
140
+ if (i18nEnabled && existingEntity.localizations) {
141
+ await Promise.all(existingEntity.localizations.map((locale) => strapi.query(masterModel.uid).update({
142
+ where: {
143
+ id: locale.id,
144
+ },
145
+ data: {
146
+ name: newName,
147
+ slug: `${newSlug}-${locale.localeCode}`,
148
+ visible,
149
+ },
150
+ })));
151
+ }
152
+ }
153
+ const result = commonService
154
+ .analyzeBranch(payload.items, existingEntity)
155
+ .then((auditLogsOperations) => Promise.all([
156
+ auditLog ? (0, utils_2.prepareAuditLog)((auditLogsOperations || []).flat(Number.MAX_SAFE_INTEGER)) : [],
157
+ adminService.getById(existingEntity.id)
158
+ ]))
159
+ .then(([actionType, newEntity]) => {
160
+ (0, utils_2.sendAuditLog)(auditLog, 'onChangeNavigation', { actionType, oldEntity: existingEntity, newEntity });
161
+ return newEntity;
162
+ });
163
+ const navigationEntity = await strapi.query(masterModel.uid).findOne({ where: { id } });
164
+ await commonService.emitEvent(masterModel.uid, 'entry.update', navigationEntity);
165
+ return result;
166
+ },
167
+ async delete(id, auditLog) {
168
+ const { masterModel } = (0, utils_2.extractMeta)(strapi.plugins);
169
+ const adminService = (0, utils_2.getPluginService)('admin');
170
+ const entity = await adminService.getById(id);
171
+ const { enabled: i18nEnabled } = await (0, i18n_1.getI18nStatus)({ strapi });
172
+ await strapi.query(masterModel.uid).delete({
173
+ where: {
174
+ id,
175
+ }
176
+ });
177
+ if (i18nEnabled && entity.localizations) {
178
+ await Promise.all(entity.localizations.map((localeVersion) => strapi.query(masterModel.uid).delete({
179
+ where: {
180
+ id: localeVersion.id,
181
+ }
182
+ })));
183
+ }
184
+ (0, utils_2.sendAuditLog)(auditLog, 'onNavigationDeletion', { entity, actionType: "DELETE" });
185
+ },
186
+ async restart() {
187
+ setImmediate(() => strapi.reload());
188
+ },
189
+ async restoreConfig() {
190
+ const commonService = (0, utils_2.getPluginService)('common');
191
+ const pluginStore = await commonService.getPluginStore();
192
+ await pluginStore.delete({ key: 'config' });
193
+ await commonService.setDefaultConfig();
194
+ },
195
+ async updateConfig(newConfig) {
196
+ const commonService = (0, utils_2.getPluginService)('common');
197
+ const pluginStore = await commonService.getPluginStore();
198
+ await pluginStore.set({ key: 'config', value: newConfig });
199
+ },
200
+ async fillFromOtherLocale({ target, source, auditLog }) {
201
+ const { enabled } = await (0, i18n_1.getI18nStatus)({ strapi });
202
+ if (!enabled) {
203
+ throw new NavigationError_1.NavigationError("Not yet implemented.");
204
+ }
205
+ const adminService = (0, utils_2.getPluginService)('admin');
206
+ const commonService = (0, utils_2.getPluginService)('common');
207
+ const targetEntity = await adminService.getById(target);
208
+ return await (0, i18n_1.i18nNavigationContentsCopy)({
209
+ source: await adminService.getById(source),
210
+ target: targetEntity,
211
+ service: commonService,
212
+ strapi,
213
+ })
214
+ .then(() => adminService.getById(target))
215
+ .then((updated) => {
216
+ (0, utils_2.sendAuditLog)(auditLog, 'onChangeNavigation', { actionType: 'UPDATE', oldEntity: targetEntity, newEntity: updated });
217
+ return updated;
218
+ });
219
+ },
220
+ async readNavigationItemFromLocale({ source, target, path }) {
221
+ const sourceNavigation = await this.getById(source);
222
+ const targetNavigation = await this.getById(target);
223
+ if (!sourceNavigation) {
224
+ throw new utils_1.errors.NotFoundError("Unable to find source navigation for specified query");
225
+ }
226
+ if (!targetNavigation) {
227
+ throw new utils_1.errors.NotFoundError("Unable to find target navigation for specified query");
228
+ }
229
+ return await (0, i18n_1.i18nNavigationItemRead)({
230
+ path,
231
+ source: sourceNavigation,
232
+ target: targetNavigation,
233
+ strapi,
234
+ });
235
+ },
236
+ });
237
+ exports.default = adminService;
238
+ //# sourceMappingURL=admin.js.map
@@ -0,0 +1,5 @@
1
+ import { StrapiContext } from "strapi-typed";
2
+ import { IClientService } from "../../types";
3
+ declare const clientService: (context: StrapiContext) => IClientService;
4
+ export default clientService;
5
+ //# sourceMappingURL=client.d.ts.map