strapi-plugin-navigation 2.5.3 → 3.0.0-beta.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 (422) hide show
  1. package/README.md +41 -63
  2. package/admin/api/client.js +107 -0
  3. package/admin/api/index.js +1 -0
  4. package/admin/api/validators.js +248 -0
  5. package/admin/components/ConfirmationDialog/index.js +21 -0
  6. package/admin/components/Initializer.js +10 -0
  7. package/admin/components/RestartAlert/index.js +7 -0
  8. package/admin/components/TextArrayInput/index.js +18 -0
  9. package/admin/components/icons/index.js +1 -0
  10. package/admin/components/icons/navigation.js +9 -0
  11. package/admin/components/icons/pluginIcon.js +9 -0
  12. package/admin/index.js +48 -0
  13. package/admin/pages/App.js +10 -0
  14. package/admin/pages/HomePage/components/AdditionalFieldInput/index.js +58 -0
  15. package/admin/pages/HomePage/components/CollapseButton/index.js +15 -0
  16. package/admin/{src → pages/HomePage}/components/DragButton/index.js +9 -16
  17. package/admin/pages/HomePage/components/I18nCopyNavigationItems/index.js +9 -0
  18. package/admin/pages/HomePage/components/NavigationContentHeader/index.js +5 -0
  19. package/admin/pages/HomePage/components/NavigationHeader/hooks.js +14 -0
  20. package/admin/pages/HomePage/components/NavigationHeader/index.js +29 -0
  21. package/admin/pages/HomePage/components/NavigationHeader/styles.js +11 -0
  22. package/admin/pages/HomePage/components/NavigationItemForm/index.js +277 -0
  23. package/admin/pages/HomePage/components/NavigationItemForm/types.js +1 -0
  24. package/admin/pages/HomePage/components/NavigationItemForm/utils/form.js +105 -0
  25. package/admin/pages/HomePage/components/NavigationItemForm/utils/hooks.js +12 -0
  26. package/admin/pages/HomePage/components/NavigationItemForm/utils/properties.js +51 -0
  27. package/admin/pages/HomePage/components/NavigationItemList/Wrapper.js +21 -0
  28. package/admin/pages/HomePage/components/NavigationItemList/index.js +6 -0
  29. package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardBadge/index.js +20 -0
  30. package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/Wrapper.js +14 -0
  31. package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/icons.js +6 -0
  32. package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/index.js +19 -0
  33. package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardRemovedOverlay/index.js +11 -0
  34. package/admin/pages/HomePage/components/NavigationItemListItem/Wrapper.js +38 -0
  35. package/admin/pages/HomePage/components/NavigationItemListItem/index.js +165 -0
  36. package/admin/pages/HomePage/components/NavigationItemPopup/NavigationItemPopupFooter.js +11 -0
  37. package/admin/pages/HomePage/components/NavigationItemPopup/NavigationItemPopupHeader.js +12 -0
  38. package/admin/pages/HomePage/components/NavigationItemPopup/index.js +34 -0
  39. package/admin/pages/HomePage/components/NavigationManager/AllNavigations/icons.js +5 -0
  40. package/admin/pages/HomePage/components/NavigationManager/AllNavigations/index.js +79 -0
  41. package/admin/pages/HomePage/components/NavigationManager/DeletionConfirm/index.js +25 -0
  42. package/admin/pages/HomePage/components/NavigationManager/ErrorDetails/index.js +29 -0
  43. package/admin/pages/HomePage/components/NavigationManager/Footer/index.js +6 -0
  44. package/admin/pages/HomePage/components/NavigationManager/Form/hooks.js +19 -0
  45. package/admin/pages/HomePage/components/NavigationManager/Form/index.js +26 -0
  46. package/admin/pages/HomePage/components/NavigationManager/NavigationUpdate/index.js +32 -0
  47. package/admin/pages/HomePage/components/NavigationManager/NewNavigation/index.js +35 -0
  48. package/admin/pages/HomePage/components/NavigationManager/PurgeCacheConfirm/index.js +25 -0
  49. package/admin/pages/HomePage/components/NavigationManager/index.js +236 -0
  50. package/admin/pages/HomePage/components/NavigationManager/types.js +1 -0
  51. package/admin/pages/HomePage/components/Search/index.js +58 -0
  52. package/admin/pages/HomePage/components/index.js +1 -0
  53. package/admin/pages/HomePage/hooks/index.js +165 -0
  54. package/admin/pages/HomePage/index.js +231 -0
  55. package/admin/pages/HomePage/utils/index.js +16 -0
  56. package/admin/pages/HomePage/utils/parsers.js +187 -0
  57. package/admin/pages/SettingsPage/common/const.js +1 -0
  58. package/admin/pages/SettingsPage/common/index.js +1 -0
  59. package/admin/pages/SettingsPage/components/CustomFieldForm/hooks/index.js +10 -0
  60. package/admin/pages/SettingsPage/components/CustomFieldForm/index.js +36 -0
  61. package/admin/pages/SettingsPage/components/CustomFieldModal/index.js +16 -0
  62. package/admin/pages/SettingsPage/components/CustomFieldTable/index.js +45 -0
  63. package/admin/pages/SettingsPage/hooks/index.js +111 -0
  64. package/admin/pages/SettingsPage/index.js +189 -0
  65. package/admin/pages/SettingsPage/types.js +1 -0
  66. package/admin/pages/SettingsPage/utils/index.js +25 -0
  67. package/admin/pluginId.js +1 -0
  68. package/admin/schemas/config.js +53 -0
  69. package/admin/schemas/content-type.js +14 -0
  70. package/admin/schemas/index.js +2 -0
  71. package/admin/{src/translations → translations}/en.json +7 -9
  72. package/admin/translations/index.js +15 -0
  73. package/admin/types.js +1 -0
  74. package/admin/utils/constants.js +1 -0
  75. package/admin/utils/getTranslation.js +4 -0
  76. package/admin/utils/permissions.js +16 -0
  77. package/admin/utils/prefixPluginTranslations.js +3 -0
  78. package/package.json +13 -11
  79. package/server/app-errors.js +20 -0
  80. package/server/bootstrap.js +13 -0
  81. package/server/cache/index.js +34 -15
  82. package/server/config/index.js +7 -5
  83. package/server/config/{setupStrategy.js → setup.js} +30 -26
  84. package/server/content-types/audience/index.js +0 -1
  85. package/server/content-types/audience/schema.js +0 -1
  86. package/server/content-types/index.js +4 -7
  87. package/server/content-types/navigation/index.js +0 -1
  88. package/server/content-types/navigation/lifecycles.js +1 -2
  89. package/server/content-types/navigation/schema.js +29 -32
  90. package/server/content-types/navigation-item/index.js +0 -1
  91. package/server/content-types/navigation-item/lifecycles.js +1 -2
  92. package/server/content-types/navigation-item/schema.js +51 -58
  93. package/server/controllers/admin.js +119 -158
  94. package/server/controllers/client.js +71 -60
  95. package/server/controllers/index.js +1 -3
  96. package/server/controllers/utils.js +22 -0
  97. package/{admin/src/hooks/useNavigationManager.js → server/controllers/validators.js} +23 -16
  98. package/server/destroy.js +3 -2
  99. package/{types/i18n.js → server/dtos/config.js} +0 -1
  100. package/server/{navigation → dtos}/index.js +3 -2
  101. package/server/dtos/navigation-item.js +2 -0
  102. package/{admin/src/pages/SettingsPage/types.js → server/dtos/navigation.js} +0 -1
  103. package/server/graphql/config.js +14 -16
  104. package/server/graphql/index.js +1 -2
  105. package/server/graphql/queries/index.js +8 -4
  106. package/server/graphql/queries/render-navigation-child.js +19 -8
  107. package/server/graphql/queries/render-navigation.js +30 -14
  108. package/server/graphql/resolvers-config.js +4 -2
  109. package/server/graphql/{setupStrategy.js → setup.js} +4 -5
  110. package/server/graphql/types/content-types-name-fields.js +10 -9
  111. package/server/graphql/types/content-types.js +15 -15
  112. package/server/graphql/types/create-navigation-item.js +16 -16
  113. package/server/graphql/types/create-navigation-related.js +7 -7
  114. package/server/graphql/types/create-navigation.js +6 -6
  115. package/server/graphql/types/index.js +35 -15
  116. package/server/graphql/types/navigation-config.js +8 -8
  117. package/server/graphql/types/navigation-details.js +2 -2
  118. package/server/graphql/types/navigation-item-additional-field-media.js +10 -10
  119. package/server/graphql/types/navigation-item-related-data.js +6 -6
  120. package/server/graphql/types/navigation-item-related.js +3 -3
  121. package/server/graphql/types/navigation-item.js +30 -27
  122. package/server/graphql/types/navigation-render-type.js +4 -5
  123. package/server/graphql/types/navigation.js +8 -8
  124. package/server/i18n/index.js +29 -20
  125. package/server/index.js +15 -8
  126. package/server/middlewares/index.js +3 -0
  127. package/server/permissions/index.js +10 -0
  128. package/{permissions.js → server/permissions/permissions.js} +0 -1
  129. package/server/permissions/setup.js +32 -0
  130. package/server/permissions.js +39 -0
  131. package/server/policies/index.js +3 -0
  132. package/server/register.js +6 -0
  133. package/server/repositories/audience.js +12 -0
  134. package/server/repositories/generic.js +20 -0
  135. package/server/repositories/index.js +11 -0
  136. package/server/repositories/navigation-item.js +51 -0
  137. package/server/repositories/navigation.js +65 -0
  138. package/server/routes/admin.js +86 -79
  139. package/server/routes/client.js +0 -1
  140. package/server/routes/index.js +0 -1
  141. package/server/schemas/config.js +68 -0
  142. package/server/schemas/content-type.js +140 -0
  143. package/{admin/src/pages/SettingsPage/common → server/schemas}/index.js +3 -2
  144. package/server/schemas/navigation.js +107 -0
  145. package/server/services/admin/admin.js +483 -0
  146. package/server/{content-types/navigations-items-related → services/admin}/index.js +2 -5
  147. package/{admin/src/pages/View/components/NavigationItemForm → server/services/admin}/types.js +0 -1
  148. package/server/services/admin/utils.js +84 -0
  149. package/server/services/client/client.js +397 -0
  150. package/server/services/client/index.js +7 -0
  151. package/{admin/src/pages/View/components/NavigationManager → server/services/client}/types.js +0 -1
  152. package/server/services/client/utils.js +88 -0
  153. package/server/services/common/common.js +307 -0
  154. package/server/services/common/index.js +7 -0
  155. package/{admin/src/components/AdditionalFieldInput → server/services/common}/types.js +0 -1
  156. package/server/services/common/utils.js +24 -0
  157. package/server/services/index.js +4 -6
  158. package/server/types.js +2 -0
  159. package/server/utils/constants.js +35 -0
  160. package/server/utils/functions.js +71 -299
  161. package/server/utils/index.js +1 -2
  162. package/strapi-admin.js +5 -8
  163. package/strapi-server.js +3 -7
  164. package/tsconfig.tsbuildinfo +1 -1
  165. package/admin/src/components/AdditionalFieldInput/index.d.ts +0 -5
  166. package/admin/src/components/AdditionalFieldInput/index.js +0 -99
  167. package/admin/src/components/AdditionalFieldInput/types.d.ts +0 -15
  168. package/admin/src/components/Alert/styles.d.ts +0 -2
  169. package/admin/src/components/Alert/styles.js +0 -14
  170. package/admin/src/components/CollapseButton/index.d.ts +0 -7
  171. package/admin/src/components/CollapseButton/index.js +0 -30
  172. package/admin/src/components/ConfirmationDialog/index.d.ts +0 -28
  173. package/admin/src/components/ConfirmationDialog/index.js +0 -34
  174. package/admin/src/components/DragButton/index.d.ts +0 -6
  175. package/admin/src/components/EmptyView/index.d.ts +0 -3
  176. package/admin/src/components/EmptyView/index.js +0 -30
  177. package/admin/src/components/Item/ItemCardBadge/index.d.ts +0 -3
  178. package/admin/src/components/Item/ItemCardBadge/index.js +0 -26
  179. package/admin/src/components/Item/ItemCardHeader/Wrapper.d.ts +0 -3
  180. package/admin/src/components/Item/ItemCardHeader/Wrapper.js +0 -21
  181. package/admin/src/components/Item/ItemCardHeader/icons.d.ts +0 -5
  182. package/admin/src/components/Item/ItemCardHeader/icons.js +0 -13
  183. package/admin/src/components/Item/ItemCardHeader/index.d.ts +0 -17
  184. package/admin/src/components/Item/ItemCardHeader/index.js +0 -38
  185. package/admin/src/components/Item/ItemCardRemovedOverlay/index.d.ts +0 -2
  186. package/admin/src/components/Item/ItemCardRemovedOverlay/index.js +0 -18
  187. package/admin/src/components/Item/Wrapper.d.ts +0 -3
  188. package/admin/src/components/Item/Wrapper.js +0 -43
  189. package/admin/src/components/Item/index.d.ts +0 -31
  190. package/admin/src/components/Item/index.js +0 -188
  191. package/admin/src/components/NavigationItemList/Wrapper.d.ts +0 -3
  192. package/admin/src/components/NavigationItemList/Wrapper.js +0 -26
  193. package/admin/src/components/NavigationItemList/index.d.ts +0 -36
  194. package/admin/src/components/NavigationItemList/index.js +0 -32
  195. package/admin/src/components/RestartAlert/index.d.ts +0 -3
  196. package/admin/src/components/RestartAlert/index.js +0 -13
  197. package/admin/src/components/Search/index.d.ts +0 -12
  198. package/admin/src/components/Search/index.js +0 -97
  199. package/admin/src/components/TextArrayInput/index.d.ts +0 -15
  200. package/admin/src/components/TextArrayInput/index.js +0 -45
  201. package/admin/src/components/icons/navigation.d.ts +0 -6
  202. package/admin/src/components/icons/navigation.js +0 -12
  203. package/admin/src/contexts/DataManagerContext.d.ts +0 -3
  204. package/admin/src/contexts/DataManagerContext.js +0 -6
  205. package/admin/src/hooks/useAllContentTypes.d.ts +0 -3
  206. package/admin/src/hooks/useAllContentTypes.js +0 -8
  207. package/admin/src/hooks/useDataManager.d.ts +0 -3
  208. package/admin/src/hooks/useDataManager.js +0 -10
  209. package/admin/src/hooks/useI18nCopyNavigationItemsModal.d.ts +0 -9
  210. package/admin/src/hooks/useI18nCopyNavigationItemsModal.js +0 -51
  211. package/admin/src/hooks/useNavigationConfig.d.ts +0 -10
  212. package/admin/src/hooks/useNavigationConfig.js +0 -54
  213. package/admin/src/hooks/useNavigationManager.d.ts +0 -6
  214. package/admin/src/index.d.ts +0 -14
  215. package/admin/src/index.js +0 -87
  216. package/admin/src/pages/App/index.d.ts +0 -3
  217. package/admin/src/pages/App/index.js +0 -43
  218. package/admin/src/pages/DataManagerProvider/actions.d.ts +0 -21
  219. package/admin/src/pages/DataManagerProvider/actions.js +0 -24
  220. package/admin/src/pages/DataManagerProvider/index.d.ts +0 -12
  221. package/admin/src/pages/DataManagerProvider/index.js +0 -382
  222. package/admin/src/pages/DataManagerProvider/init.d.ts +0 -3
  223. package/admin/src/pages/DataManagerProvider/init.js +0 -7
  224. package/admin/src/pages/DataManagerProvider/reducer.d.ts +0 -20
  225. package/admin/src/pages/DataManagerProvider/reducer.js +0 -132
  226. package/admin/src/pages/NoAccessPage/index.d.ts +0 -3
  227. package/admin/src/pages/NoAccessPage/index.js +0 -31
  228. package/admin/src/pages/SettingsPage/common/const.d.ts +0 -2
  229. package/admin/src/pages/SettingsPage/common/const.js +0 -5
  230. package/admin/src/pages/SettingsPage/common/index.d.ts +0 -2
  231. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts +0 -12
  232. package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +0 -129
  233. package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts +0 -12
  234. package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js +0 -20
  235. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts +0 -11
  236. package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +0 -105
  237. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.d.ts +0 -23
  238. package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.js +0 -86
  239. package/admin/src/pages/SettingsPage/index.d.ts +0 -3
  240. package/admin/src/pages/SettingsPage/index.js +0 -321
  241. package/admin/src/pages/SettingsPage/types.d.ts +0 -35
  242. package/admin/src/pages/SettingsPage/utils/form.d.ts +0 -20
  243. package/admin/src/pages/SettingsPage/utils/form.js +0 -37
  244. package/admin/src/pages/SettingsPage/utils/functions.d.ts +0 -3
  245. package/admin/src/pages/SettingsPage/utils/functions.js +0 -26
  246. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts +0 -14
  247. package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js +0 -15
  248. package/admin/src/pages/View/components/NavigationContentHeader/index.d.ts +0 -6
  249. package/admin/src/pages/View/components/NavigationContentHeader/index.js +0 -14
  250. package/admin/src/pages/View/components/NavigationHeader/index.d.ts +0 -14
  251. package/admin/src/pages/View/components/NavigationHeader/index.js +0 -92
  252. package/admin/src/pages/View/components/NavigationHeader/styles.d.ts +0 -2
  253. package/admin/src/pages/View/components/NavigationHeader/styles.js +0 -18
  254. package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +0 -5
  255. package/admin/src/pages/View/components/NavigationItemForm/index.js +0 -470
  256. package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +0 -99
  257. package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +0 -28
  258. package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +0 -123
  259. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.d.ts +0 -25
  260. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +0 -31
  261. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.d.ts +0 -5
  262. package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +0 -20
  263. package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts +0 -33
  264. package/admin/src/pages/View/components/NavigationItemPopup/index.js +0 -90
  265. package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts +0 -4
  266. package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js +0 -12
  267. package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts +0 -8
  268. package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.js +0 -151
  269. package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts +0 -8
  270. package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.js +0 -34
  271. package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts +0 -8
  272. package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.js +0 -53
  273. package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts +0 -24
  274. package/admin/src/pages/View/components/NavigationManager/Footer/index.js +0 -13
  275. package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +0 -19
  276. package/admin/src/pages/View/components/NavigationManager/Form/index.js +0 -103
  277. package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts +0 -8
  278. package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.js +0 -59
  279. package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts +0 -9
  280. package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.js +0 -62
  281. package/admin/src/pages/View/components/NavigationManager/PurgeCacheConfirm/index.d.ts +0 -8
  282. package/admin/src/pages/View/components/NavigationManager/PurgeCacheConfirm/index.js +0 -34
  283. package/admin/src/pages/View/components/NavigationManager/index.d.ts +0 -10
  284. package/admin/src/pages/View/components/NavigationManager/index.js +0 -203
  285. package/admin/src/pages/View/components/NavigationManager/types.d.ts +0 -44
  286. package/admin/src/pages/View/index.d.ts +0 -4
  287. package/admin/src/pages/View/index.js +0 -269
  288. package/admin/src/pages/View/utils/form.d.ts +0 -2
  289. package/admin/src/pages/View/utils/form.js +0 -16
  290. package/admin/src/pages/View/utils/index.d.ts +0 -2
  291. package/admin/src/pages/View/utils/index.js +0 -11
  292. package/admin/src/pages/View/utils/parsers.d.ts +0 -51
  293. package/admin/src/pages/View/utils/parsers.js +0 -272
  294. package/admin/src/pages/View/utils/types.d.ts +0 -3
  295. package/admin/src/pages/View/utils/types.js +0 -3
  296. package/admin/src/permissions.d.ts +0 -16
  297. package/admin/src/permissions.js +0 -13
  298. package/admin/src/pluginId.d.ts +0 -3
  299. package/admin/src/pluginId.js +0 -5
  300. package/admin/src/translations/index.d.ts +0 -15
  301. package/admin/src/translations/index.js +0 -21
  302. package/admin/src/utils/api.d.ts +0 -9
  303. package/admin/src/utils/api.js +0 -20
  304. package/admin/src/utils/enums.d.ts +0 -25
  305. package/admin/src/utils/enums.js +0 -30
  306. package/admin/src/utils/functions.d.ts +0 -16
  307. package/admin/src/utils/functions.js +0 -46
  308. package/admin/src/utils/index.d.ts +0 -4
  309. package/admin/src/utils/index.js +0 -20
  310. package/permissions.d.ts +0 -10
  311. package/server/bootstrap/index.d.ts +0 -4
  312. package/server/bootstrap/index.js +0 -50
  313. package/server/cache/index.d.ts +0 -2
  314. package/server/cache/serviceEnhancers.d.ts +0 -3
  315. package/server/cache/serviceEnhancers.js +0 -16
  316. package/server/cache/setupStrategy.d.ts +0 -3
  317. package/server/cache/setupStrategy.js +0 -38
  318. package/server/cache/types.d.ts +0 -11
  319. package/server/cache/types.js +0 -3
  320. package/server/cache/utils.d.ts +0 -11
  321. package/server/cache/utils.js +0 -19
  322. package/server/config/index.d.ts +0 -5
  323. package/server/config/setupStrategy.d.ts +0 -3
  324. package/server/content-types/audience/index.d.ts +0 -27
  325. package/server/content-types/audience/schema.d.ts +0 -25
  326. package/server/content-types/index.d.ts +0 -244
  327. package/server/content-types/navigation/index.d.ts +0 -59
  328. package/server/content-types/navigation/lifecycles.d.ts +0 -3
  329. package/server/content-types/navigation/schema.d.ts +0 -56
  330. package/server/content-types/navigation-item/index.d.ts +0 -111
  331. package/server/content-types/navigation-item/lifecycles.d.ts +0 -3
  332. package/server/content-types/navigation-item/schema.d.ts +0 -108
  333. package/server/content-types/navigations-items-related/index.d.ts +0 -51
  334. package/server/content-types/navigations-items-related/schema.d.ts +0 -49
  335. package/server/content-types/navigations-items-related/schema.js +0 -50
  336. package/server/controllers/admin.d.ts +0 -4
  337. package/server/controllers/client.d.ts +0 -4
  338. package/server/controllers/index.d.ts +0 -4
  339. package/server/destroy.d.ts +0 -3
  340. package/server/graphql/config.d.ts +0 -4
  341. package/server/graphql/index.d.ts +0 -2
  342. package/server/graphql/queries/index.d.ts +0 -3
  343. package/server/graphql/queries/render-navigation-child.d.ts +0 -15
  344. package/server/graphql/queries/render-navigation.d.ts +0 -21
  345. package/server/graphql/resolvers-config.d.ts +0 -10
  346. package/server/graphql/setupStrategy.d.ts +0 -3
  347. package/server/graphql/types/content-types-name-fields.d.ts +0 -6
  348. package/server/graphql/types/content-types.d.ts +0 -5
  349. package/server/graphql/types/create-navigation-item.d.ts +0 -5
  350. package/server/graphql/types/create-navigation-related.d.ts +0 -5
  351. package/server/graphql/types/create-navigation.d.ts +0 -5
  352. package/server/graphql/types/index.d.ts +0 -3
  353. package/server/graphql/types/navigation-config.d.ts +0 -5
  354. package/server/graphql/types/navigation-details.d.ts +0 -5
  355. package/server/graphql/types/navigation-item-additional-field-media.d.ts +0 -5
  356. package/server/graphql/types/navigation-item-related-data.d.ts +0 -5
  357. package/server/graphql/types/navigation-item-related.d.ts +0 -7
  358. package/server/graphql/types/navigation-item.d.ts +0 -6
  359. package/server/graphql/types/navigation-render-type.d.ts +0 -5
  360. package/server/graphql/types/navigation.d.ts +0 -5
  361. package/server/i18n/constant.d.ts +0 -2
  362. package/server/i18n/constant.js +0 -5
  363. package/server/i18n/errors.d.ts +0 -7
  364. package/server/i18n/errors.js +0 -14
  365. package/server/i18n/graphQLEnhancers.d.ts +0 -10
  366. package/server/i18n/graphQLEnhancers.js +0 -10
  367. package/server/i18n/index.d.ts +0 -8
  368. package/server/i18n/navigationSetupStrategy.d.ts +0 -3
  369. package/server/i18n/navigationSetupStrategy.js +0 -147
  370. package/server/i18n/serviceEnhancers.d.ts +0 -13
  371. package/server/i18n/serviceEnhancers.js +0 -156
  372. package/server/i18n/types.d.ts +0 -60
  373. package/server/i18n/types.js +0 -3
  374. package/server/i18n/utils.d.ts +0 -13
  375. package/server/i18n/utils.js +0 -33
  376. package/server/index.d.ts +0 -262
  377. package/server/navigation/index.d.ts +0 -2
  378. package/server/navigation/setupStrategy.d.ts +0 -3
  379. package/server/navigation/setupStrategy.js +0 -39
  380. package/server/register/index.d.ts +0 -3
  381. package/server/register/index.js +0 -4
  382. package/server/routes/admin.d.ts +0 -4
  383. package/server/routes/client.d.ts +0 -4
  384. package/server/routes/index.d.ts +0 -6
  385. package/server/services/admin.d.ts +0 -5
  386. package/server/services/admin.js +0 -347
  387. package/server/services/client.d.ts +0 -5
  388. package/server/services/client.js +0 -335
  389. package/server/services/common.d.ts +0 -5
  390. package/server/services/common.js +0 -385
  391. package/server/services/index.d.ts +0 -7
  392. package/server/utils/constant.d.ts +0 -27
  393. package/server/utils/constant.js +0 -43
  394. package/server/utils/functions.d.ts +0 -157
  395. package/server/utils/index.d.ts +0 -3
  396. package/strapi-admin.d.ts +0 -3
  397. package/strapi-server.d.ts +0 -262
  398. package/types/bootstrap.d.ts +0 -16
  399. package/types/bootstrap.js +0 -3
  400. package/types/config.d.ts +0 -27
  401. package/types/config.js +0 -3
  402. package/types/contentTypes.d.ts +0 -112
  403. package/types/contentTypes.js +0 -3
  404. package/types/controllers.d.ts +0 -65
  405. package/types/controllers.js +0 -5
  406. package/types/graphQL.d.ts +0 -3
  407. package/types/graphQL.js +0 -3
  408. package/types/i18n.d.ts +0 -9
  409. package/types/index.d.ts +0 -10
  410. package/types/index.js +0 -26
  411. package/types/lifecycle.d.ts +0 -22
  412. package/types/lifecycle.js +0 -3
  413. package/types/services.d.ts +0 -106
  414. package/types/services.js +0 -3
  415. package/types/utils.d.ts +0 -72
  416. package/types/utils.js +0 -41
  417. package/utils/InvalidParamNavigationError.d.ts +0 -4
  418. package/utils/InvalidParamNavigationError.js +0 -8
  419. package/utils/NavigationError.d.ts +0 -5
  420. package/utils/NavigationError.js +0 -11
  421. /package/admin/{src/translations → translations}/ca.json +0 -0
  422. /package/admin/{src/translations → translations}/fr.json +0 -0
@@ -0,0 +1,397 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@strapi/utils");
4
+ const lodash_1 = require("lodash");
5
+ const app_errors_1 = require("../../app-errors");
6
+ const repositories_1 = require("../../repositories");
7
+ const utils_2 = require("../../utils");
8
+ const utils_3 = require("./utils");
9
+ const clientService = (context) => ({
10
+ async readAll({ locale, orderBy = 'createdAt', orderDirection = 'DESC' }) {
11
+ const repository = (0, repositories_1.getNavigationRepository)(context);
12
+ const navigations = repository.find({
13
+ where: locale
14
+ ? {
15
+ localeCode: locale,
16
+ }
17
+ : {},
18
+ orderBy: { [orderBy]: orderDirection },
19
+ });
20
+ return navigations;
21
+ },
22
+ renderRFRNavigationItem({ item }) {
23
+ const { uiRouterKey, title, path, type, audience } = item;
24
+ const itemCommon = {
25
+ label: title,
26
+ type: type,
27
+ audience: audience?.map(({ key }) => key),
28
+ };
29
+ if (type === 'EXTERNAL') {
30
+ (0, utils_2.assertNotEmpty)(path, new app_errors_1.NavigationError("External navigation item's path is undefined", item));
31
+ return {
32
+ ...itemCommon,
33
+ url: path,
34
+ };
35
+ }
36
+ if (type === 'INTERNAL') {
37
+ return {
38
+ ...itemCommon,
39
+ page: uiRouterKey,
40
+ };
41
+ }
42
+ if (type === 'WRAPPER') {
43
+ return {
44
+ ...itemCommon,
45
+ };
46
+ }
47
+ throw new app_errors_1.NavigationError('Unknown item type', item);
48
+ },
49
+ renderRFRPage({ item, parent, enabledCustomFieldsNames }) {
50
+ const { uiRouterKey, title, path, related, type, audience, menuAttached } = item;
51
+ return {
52
+ id: uiRouterKey,
53
+ title,
54
+ related: type === 'INTERNAL' && related?.id && related?.uid
55
+ ? {
56
+ contentType: related.uid,
57
+ id: related.id,
58
+ }
59
+ : undefined,
60
+ path,
61
+ parent,
62
+ audience,
63
+ menuAttached,
64
+ ...enabledCustomFieldsNames.reduce((acc, field) => ({ ...acc, [field]: (0, lodash_1.get)(item, field) }), {}),
65
+ };
66
+ },
67
+ renderRFR({ items, parent, parentNavItem, contentTypes = [], enabledCustomFieldsNames, }) {
68
+ const navItems = [];
69
+ let nav = {};
70
+ let pages = {};
71
+ items.forEach((item) => {
72
+ const { items: itemChildren, ...restOfItem } = item;
73
+ const itemNav = this.renderRFRNavigationItem({
74
+ item: restOfItem,
75
+ });
76
+ const itemPage = this.renderRFRPage({
77
+ item: restOfItem,
78
+ parent,
79
+ enabledCustomFieldsNames,
80
+ });
81
+ if (item.type !== 'EXTERNAL') {
82
+ pages = {
83
+ ...pages,
84
+ [itemPage.id]: {
85
+ ...itemPage,
86
+ },
87
+ };
88
+ }
89
+ if (item.menuAttached) {
90
+ navItems.push(itemNav);
91
+ }
92
+ if (!parent) {
93
+ nav = {
94
+ ...nav,
95
+ root: navItems,
96
+ };
97
+ }
98
+ else {
99
+ const navigationLevel = navItems.filter((navItem) => navItem.type !== 'EXTERNAL');
100
+ if (!(0, lodash_1.isEmpty)(navigationLevel))
101
+ nav = {
102
+ ...nav,
103
+ [parent]: navigationLevel.concat(parentNavItem ? parentNavItem : []),
104
+ };
105
+ }
106
+ if (!(0, lodash_1.isEmpty)(itemChildren)) {
107
+ const { nav: nestedNavs } = this.renderRFR({
108
+ items: itemChildren ?? [],
109
+ parent: itemPage.id,
110
+ parentNavItem: itemNav,
111
+ contentTypes,
112
+ enabledCustomFieldsNames,
113
+ });
114
+ const { pages: nestedPages } = this.renderRFR({
115
+ items: itemChildren?.filter((child) => child.type !== 'EXTERNAL') || [],
116
+ parent: itemPage.id,
117
+ parentNavItem: itemNav,
118
+ contentTypes,
119
+ enabledCustomFieldsNames,
120
+ });
121
+ pages = {
122
+ ...pages,
123
+ ...nestedPages,
124
+ };
125
+ nav = {
126
+ ...nav,
127
+ ...nestedNavs,
128
+ };
129
+ }
130
+ });
131
+ return {
132
+ pages,
133
+ nav,
134
+ };
135
+ },
136
+ renderTree({ items = [], id, path = '', itemParser = (i) => Promise.resolve(i), }) {
137
+ return Promise.all(items.reduce((acc, item) => {
138
+ if (item.parent?.id === id && (0, utils_3.filterOutUnpublished)(item)) {
139
+ acc.push(itemParser((0, lodash_1.cloneDeep)(item), path));
140
+ }
141
+ return acc;
142
+ }, [])).then((result) => result.sort((x, y) => {
143
+ if (x.order !== undefined && y.order !== undefined) {
144
+ return x.order - y.order;
145
+ }
146
+ return 0;
147
+ }));
148
+ },
149
+ getCustomFields(additionalFields) {
150
+ return additionalFields.reduce((acc, field) => {
151
+ if (field !== 'audience') {
152
+ acc.push(field);
153
+ }
154
+ return acc;
155
+ }, []);
156
+ },
157
+ async templateNameFactory(items = [], contentTypes = []) {
158
+ const flatRelated = (0, lodash_1.flatten)(items.map((i) => i.related)).filter(Boolean);
159
+ const relatedMap = flatRelated.reduce((acc, curr) => {
160
+ const [contentType, id] = [curr?.uid, curr?.id];
161
+ if ((0, lodash_1.isNil)(curr) || !contentType || !id)
162
+ return acc;
163
+ if ((0, lodash_1.isNil)(acc[contentType]))
164
+ acc[contentType] = [];
165
+ return { ...acc, [contentType]: [...acc[contentType], id] };
166
+ }, {});
167
+ const relatedResponseMap = await Promise.all(Object.entries(relatedMap).map(async ([contentType, ids]) => {
168
+ (0, utils_2.assertNotEmpty)((0, lodash_1.find)(contentTypes, ({ uid }) => uid === contentType));
169
+ const repository = (0, repositories_1.getGenericRepository)(context, contentType);
170
+ const relatedItems = await repository.findManyById(ids, ['template']);
171
+ return { [contentType]: relatedItems };
172
+ })).then((res) => {
173
+ return res.reduce((acc, curr) => ({ ...acc, ...curr }), {});
174
+ });
175
+ const singleTypes = new Map(contentTypes
176
+ .filter((x) => x.isSingle)
177
+ .map(({ contentTypeName, templateName }) => [
178
+ contentTypeName,
179
+ templateName || contentTypeName,
180
+ ]));
181
+ const getTemplateComponentFromTemplate = (template = []) => {
182
+ const componentName = (0, lodash_1.get)((0, lodash_1.first)(template), '__component');
183
+ return !!componentName ? context.strapi.components[componentName] : null;
184
+ };
185
+ return (contentType, id) => {
186
+ const template = (0, lodash_1.get)(relatedResponseMap[contentType].find((data) => data.id === id), 'template');
187
+ if (template && template instanceof Array) {
188
+ const templateComponent = getTemplateComponentFromTemplate(template);
189
+ return (0, lodash_1.get)(templateComponent, 'options.templateName', utils_2.TEMPLATE_DEFAULT);
190
+ }
191
+ if (singleTypes.get(contentType)) {
192
+ return singleTypes.get(contentType);
193
+ }
194
+ return utils_2.TEMPLATE_DEFAULT;
195
+ };
196
+ },
197
+ async renderType({ criteria = {}, filter, itemCriteria = {}, locale, populate, rootPath, type = 'FLAT', wrapRelated, }) {
198
+ const adminService = (0, utils_2.getPluginService)(context, 'admin');
199
+ const commonService = (0, utils_2.getPluginService)(context, 'common');
200
+ const entityWhereClause = {
201
+ ...criteria,
202
+ visible: true,
203
+ };
204
+ const navigationRepository = (0, repositories_1.getNavigationRepository)(context);
205
+ const navigationItemRepository = (0, repositories_1.getNavigationItemRepository)(context);
206
+ let navigation = await navigationRepository.findOne({
207
+ where: entityWhereClause,
208
+ populate: true,
209
+ });
210
+ if (locale && locale !== navigation.localeCode) {
211
+ navigation = await navigationRepository.findOne({
212
+ where: {
213
+ documentId: navigation.documentId,
214
+ localeCode: locale,
215
+ },
216
+ populate: true,
217
+ });
218
+ }
219
+ if (navigation && navigation.id) {
220
+ const navigationItems = await navigationItemRepository.find({
221
+ where: {
222
+ master: navigation.id,
223
+ ...itemCriteria,
224
+ },
225
+ limit: Number.MAX_SAFE_INTEGER,
226
+ order: [{ order: 'asc' }],
227
+ populate: ['related', 'audience', 'parent'],
228
+ });
229
+ const mappedItems = await commonService.mapToNavigationItemDTO({
230
+ navigationItems,
231
+ populate,
232
+ master: navigation,
233
+ });
234
+ const { contentTypes, contentTypesNameFields, additionalFields } = await adminService.config({
235
+ viaSettingsPage: false,
236
+ });
237
+ const enabledCustomFieldsNames = this.getCustomFields(additionalFields).reduce((acc, curr) => (curr.enabled ? [...acc, curr.name] : acc), []);
238
+ const wrapContentType = (itemContentType) => wrapRelated && itemContentType
239
+ ? {
240
+ id: itemContentType.id,
241
+ attributes: { ...itemContentType },
242
+ }
243
+ : itemContentType;
244
+ const mediaFields = ['name', 'url', 'mime', 'width', 'height', 'previewUrl'];
245
+ const customFieldsDefinitions = additionalFields.filter((_) => typeof _ !== 'string');
246
+ switch (type) {
247
+ case 'TREE':
248
+ case 'RFR':
249
+ const getTemplateName = await this.templateNameFactory(mappedItems, contentTypes);
250
+ const itemParser = async (item, path = '') => {
251
+ const isExternal = item.type === 'EXTERNAL';
252
+ const parentPath = isExternal
253
+ ? undefined
254
+ : `${path === '/' ? '' : path}/${(0, lodash_1.first)(item.path) === '/' ? item.path.substring(1) : item.path}`;
255
+ const slug = typeof parentPath === 'string'
256
+ ? await commonService.getSlug({
257
+ query: ((0, lodash_1.first)(parentPath) === '/'
258
+ ? parentPath.substring(1)
259
+ : parentPath).replace(/\//g, '-'),
260
+ })
261
+ : undefined;
262
+ const lastRelated = (0, lodash_1.isArray)(item.related) ? (0, lodash_1.last)(item.related) : item.related;
263
+ const relatedContentType = wrapContentType(lastRelated);
264
+ const customFields = enabledCustomFieldsNames.reduce((acc, field) => {
265
+ const mapper = customFieldsDefinitions.find(({ name }) => name === field)?.type === 'media'
266
+ ? (_) => (0, lodash_1.pick)(JSON.parse(_), mediaFields)
267
+ : (_) => _;
268
+ const content = (0, lodash_1.get)(item, `additionalFields.${field}`);
269
+ return { ...acc, [field]: content ? mapper(content) : content };
270
+ }, {});
271
+ return {
272
+ id: item.id,
273
+ title: (0, utils_3.composeItemTitle)(item, contentTypesNameFields, contentTypes) ?? 'Title missing',
274
+ menuAttached: item.menuAttached,
275
+ order: item.order,
276
+ path: (isExternal ? item.externalPath : parentPath) ?? 'Path is missing',
277
+ type: item.type,
278
+ uiRouterKey: item.uiRouterKey,
279
+ slug: !slug && item.uiRouterKey
280
+ ? await commonService.getSlug({ query: item.uiRouterKey })
281
+ : slug,
282
+ related: isExternal || !lastRelated
283
+ ? undefined
284
+ : {
285
+ ...relatedContentType,
286
+ __templateName: getTemplateName(lastRelated.relatedType || lastRelated.uid, lastRelated.id),
287
+ },
288
+ audience: !(0, lodash_1.isEmpty)(item.audience) ? item.audience : undefined,
289
+ items: isExternal
290
+ ? []
291
+ : await this.renderTree({
292
+ itemParser,
293
+ path: parentPath,
294
+ id: item.id,
295
+ items: mappedItems,
296
+ }),
297
+ collapsed: item.collapsed,
298
+ ...customFields,
299
+ };
300
+ };
301
+ const { items: itemsFilteredByPath, root: rootElement } = (0, utils_3.filterByPath)(mappedItems, rootPath);
302
+ const treeStructure = (await this.renderTree({
303
+ itemParser,
304
+ items: (0, lodash_1.isNil)(rootPath) ? mappedItems : itemsFilteredByPath,
305
+ path: rootElement?.parent?.path,
306
+ id: rootElement?.parent?.id,
307
+ }));
308
+ const filteredStructure = filter
309
+ ? treeStructure.filter((item) => item.uiRouterKey === filter)
310
+ : treeStructure;
311
+ if (type === 'RFR') {
312
+ return this.renderRFR({
313
+ items: filteredStructure,
314
+ contentTypes: contentTypes.map((_) => _.contentTypeName),
315
+ enabledCustomFieldsNames,
316
+ });
317
+ }
318
+ return filteredStructure;
319
+ default:
320
+ const publishedItems = mappedItems.filter(utils_3.filterOutUnpublished);
321
+ const result = (0, lodash_1.isNil)(rootPath)
322
+ ? mappedItems
323
+ : (0, utils_3.filterByPath)(publishedItems, rootPath).items;
324
+ const defaultCache = new Map();
325
+ const getNestedOrders = (id, cache = defaultCache) => {
326
+ const cached = cache.get(id);
327
+ if (!(0, lodash_1.isNil)(cached))
328
+ return cached;
329
+ const item = result.find((item) => item.id === id);
330
+ if ((0, lodash_1.isNil)(item))
331
+ return [0];
332
+ const { order, parent } = item;
333
+ const nestedOrders = parent ? getNestedOrders(parent.id, cache).concat(order) : [order];
334
+ cache.set(id, nestedOrders);
335
+ return nestedOrders;
336
+ };
337
+ return result
338
+ .map(({ additionalFields, ...item }) => {
339
+ const customFields = enabledCustomFieldsNames.reduce((acc, field) => {
340
+ const mapper = customFieldsDefinitions.find(({ name }) => name === field)?.type === 'media'
341
+ ? (_) => (0, lodash_1.pick)(JSON.parse(_.toString()), mediaFields)
342
+ : (_) => _;
343
+ const content = (0, lodash_1.get)(additionalFields, field);
344
+ return {
345
+ ...acc,
346
+ [field]: content
347
+ ? mapper(typeof content === 'boolean' ? content : content.toString())
348
+ : content,
349
+ };
350
+ }, {});
351
+ return {
352
+ ...item,
353
+ audience: item.audience?.map((_) => _.key),
354
+ title: (0, utils_3.composeItemTitle)({ ...item, additionalFields }, contentTypesNameFields, contentTypes) || '',
355
+ related: wrapContentType(item.related),
356
+ items: null,
357
+ ...customFields,
358
+ };
359
+ })
360
+ .sort((a, b) => (0, utils_3.compareArraysOfNumbers)(getNestedOrders(a.id), getNestedOrders(b.id)));
361
+ }
362
+ }
363
+ throw new utils_1.errors.NotFoundError();
364
+ },
365
+ renderChildren({ childUIKey, idOrSlug, locale, menuOnly, type = 'FLAT', wrapRelated, }) {
366
+ const findById = typeof idOrSlug === 'number';
367
+ const criteria = findById ? { id: idOrSlug } : { slug: idOrSlug };
368
+ const filter = type === 'FLAT' ? undefined : childUIKey;
369
+ const itemCriteria = {
370
+ ...(menuOnly && { menuAttached: true }),
371
+ ...(type === 'FLAT' ? { uiRouterKey: childUIKey } : {}),
372
+ };
373
+ return this.renderType({
374
+ type,
375
+ criteria,
376
+ itemCriteria,
377
+ filter,
378
+ wrapRelated,
379
+ locale,
380
+ });
381
+ },
382
+ render({ idOrSlug, locale, menuOnly, populate, rootPath, type = 'FLAT', wrapRelated, }) {
383
+ const findById = typeof idOrSlug === 'number';
384
+ const criteria = findById ? { id: idOrSlug } : { slug: idOrSlug };
385
+ const itemCriteria = menuOnly ? { menuAttached: true } : {};
386
+ return this.renderType({
387
+ type,
388
+ criteria,
389
+ itemCriteria,
390
+ rootPath,
391
+ wrapRelated,
392
+ locale,
393
+ populate,
394
+ });
395
+ },
396
+ });
397
+ exports.default = clientService;
@@ -0,0 +1,7 @@
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 client_1 = __importDefault(require("./client"));
7
+ exports.default = client_1.default;
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterOutUnpublished = exports.compareArraysOfNumbers = exports.buildNestedPaths = exports.filterByPath = exports.extractItemRelationTitle = exports.composeItemTitle = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const composeItemTitle = (item, fields = {}, contentTypes = []) => {
6
+ const { title, related } = item;
7
+ const lastRelated = (0, lodash_1.isArray)(related) ? (0, lodash_1.last)(related) : related;
8
+ if (title) {
9
+ return (0, lodash_1.isString)(title) && !(0, lodash_1.isEmpty)(title) ? title : undefined;
10
+ }
11
+ else if (lastRelated) {
12
+ const relationTitle = (0, exports.extractItemRelationTitle)(lastRelated, fields, contentTypes);
13
+ return (0, lodash_1.isString)(relationTitle) && !(0, lodash_1.isEmpty)(relationTitle) ? relationTitle : undefined;
14
+ }
15
+ return undefined;
16
+ };
17
+ exports.composeItemTitle = composeItemTitle;
18
+ const extractItemRelationTitle = (relatedItem, fields = {}, contentTypes = []) => {
19
+ const { __contentType } = relatedItem;
20
+ const contentType = (0, lodash_1.find)(contentTypes, (_) => _.contentTypeName === __contentType);
21
+ const { default: defaultFields = [] } = fields;
22
+ return ((0, lodash_1.get)(fields, `${contentType ? contentType.collectionName : ''}`, defaultFields)
23
+ .map((_) => relatedItem[_])
24
+ .filter((_) => _)[0] || '');
25
+ };
26
+ exports.extractItemRelationTitle = extractItemRelationTitle;
27
+ const filterByPath = (items, path) => {
28
+ const itemsWithPaths = path
29
+ ? (0, exports.buildNestedPaths)(items).filter(({ path: itemPath }) => itemPath.includes(path))
30
+ : [];
31
+ const root = itemsWithPaths.find(({ path: itemPath }) => itemPath === path);
32
+ return {
33
+ root,
34
+ items: (0, lodash_1.isNil)(root) ? [] : items.filter(({ id }) => itemsWithPaths.find((v) => v.id === id)),
35
+ };
36
+ };
37
+ exports.filterByPath = filterByPath;
38
+ const buildNestedPaths = (items, id, parentPath = null) => {
39
+ return items
40
+ .filter((entity) => {
41
+ let data = entity.parent;
42
+ if (!data == null && !id) {
43
+ return true;
44
+ }
45
+ return entity.parent?.id === id;
46
+ })
47
+ .reduce((acc, entity) => {
48
+ const path = `${parentPath || ''}/${entity.path}`.replace('//', '/');
49
+ return [
50
+ {
51
+ id: entity.id,
52
+ parent: parentPath && entity.parent?.id
53
+ ? {
54
+ id: entity.parent?.id,
55
+ path: parentPath,
56
+ }
57
+ : undefined,
58
+ path,
59
+ },
60
+ ...(0, exports.buildNestedPaths)(items, entity.id, path),
61
+ ...acc,
62
+ ];
63
+ }, []);
64
+ };
65
+ exports.buildNestedPaths = buildNestedPaths;
66
+ const compareArraysOfNumbers = (arrA, arrB) => {
67
+ const diff = (0, lodash_1.zipWith)(arrA, arrB, (a, b) => {
68
+ if ((0, lodash_1.isNil)(a))
69
+ return -1;
70
+ if ((0, lodash_1.isNil)(b))
71
+ return 1;
72
+ return a - b;
73
+ });
74
+ return (0, lodash_1.find)(diff, (a) => a !== 0) || 0;
75
+ };
76
+ exports.compareArraysOfNumbers = compareArraysOfNumbers;
77
+ const filterOutUnpublished = (item) => {
78
+ const relatedItem = item.related && ((0, lodash_1.isArray)(item.related) ? (0, lodash_1.last)(item.related) : item.related);
79
+ const isHandledByPublishFlow = relatedItem ? 'publishedAt' in relatedItem : false;
80
+ if (isHandledByPublishFlow) {
81
+ const isRelatedDefinedAndPublished = relatedItem
82
+ ? isHandledByPublishFlow && !!(0, lodash_1.get)(relatedItem, 'publishedAt')
83
+ : false;
84
+ return item.type === 'INTERNAL' ? isRelatedDefinedAndPublished : true;
85
+ }
86
+ return item.type !== 'INTERNAL' || relatedItem;
87
+ };
88
+ exports.filterOutUnpublished = filterOutUnpublished;