strapi-plugin-navigation 2.5.4 → 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.
- package/README.md +21 -43
- package/admin/api/client.js +107 -0
- package/admin/api/index.js +1 -0
- package/admin/api/validators.js +248 -0
- package/admin/components/ConfirmationDialog/index.js +21 -0
- package/admin/components/Initializer.js +10 -0
- package/admin/components/RestartAlert/index.js +7 -0
- package/admin/components/TextArrayInput/index.js +18 -0
- package/admin/components/icons/index.js +1 -0
- package/admin/components/icons/navigation.js +9 -0
- package/admin/components/icons/pluginIcon.js +9 -0
- package/admin/index.js +48 -0
- package/admin/pages/App.js +10 -0
- package/admin/pages/HomePage/components/AdditionalFieldInput/index.js +58 -0
- package/admin/pages/HomePage/components/CollapseButton/index.js +15 -0
- package/admin/{src → pages/HomePage}/components/DragButton/index.js +9 -16
- package/admin/pages/HomePage/components/I18nCopyNavigationItems/index.js +9 -0
- package/admin/pages/HomePage/components/NavigationContentHeader/index.js +5 -0
- package/admin/pages/HomePage/components/NavigationHeader/hooks.js +14 -0
- package/admin/pages/HomePage/components/NavigationHeader/index.js +29 -0
- package/admin/pages/HomePage/components/NavigationHeader/styles.js +11 -0
- package/admin/pages/HomePage/components/NavigationItemForm/index.js +277 -0
- package/admin/pages/HomePage/components/NavigationItemForm/types.js +1 -0
- package/admin/pages/HomePage/components/NavigationItemForm/utils/form.js +105 -0
- package/admin/pages/HomePage/components/NavigationItemForm/utils/hooks.js +12 -0
- package/admin/pages/HomePage/components/NavigationItemForm/utils/properties.js +51 -0
- package/admin/pages/HomePage/components/NavigationItemList/Wrapper.js +21 -0
- package/admin/pages/HomePage/components/NavigationItemList/index.js +6 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardBadge/index.js +20 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/Wrapper.js +14 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/icons.js +6 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardHeader/index.js +19 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/ItemCardRemovedOverlay/index.js +11 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/Wrapper.js +38 -0
- package/admin/pages/HomePage/components/NavigationItemListItem/index.js +165 -0
- package/admin/pages/HomePage/components/NavigationItemPopup/NavigationItemPopupFooter.js +11 -0
- package/admin/pages/HomePage/components/NavigationItemPopup/NavigationItemPopupHeader.js +12 -0
- package/admin/pages/HomePage/components/NavigationItemPopup/index.js +34 -0
- package/admin/pages/HomePage/components/NavigationManager/AllNavigations/icons.js +5 -0
- package/admin/pages/HomePage/components/NavigationManager/AllNavigations/index.js +79 -0
- package/admin/pages/HomePage/components/NavigationManager/DeletionConfirm/index.js +25 -0
- package/admin/pages/HomePage/components/NavigationManager/ErrorDetails/index.js +29 -0
- package/admin/pages/HomePage/components/NavigationManager/Footer/index.js +6 -0
- package/admin/pages/HomePage/components/NavigationManager/Form/hooks.js +19 -0
- package/admin/pages/HomePage/components/NavigationManager/Form/index.js +26 -0
- package/admin/pages/HomePage/components/NavigationManager/NavigationUpdate/index.js +32 -0
- package/admin/pages/HomePage/components/NavigationManager/NewNavigation/index.js +35 -0
- package/admin/pages/HomePage/components/NavigationManager/PurgeCacheConfirm/index.js +25 -0
- package/admin/pages/HomePage/components/NavigationManager/index.js +236 -0
- package/admin/pages/HomePage/components/NavigationManager/types.js +1 -0
- package/admin/pages/HomePage/components/Search/index.js +58 -0
- package/admin/pages/HomePage/components/index.js +1 -0
- package/admin/pages/HomePage/hooks/index.js +165 -0
- package/admin/pages/HomePage/index.js +231 -0
- package/admin/pages/HomePage/utils/index.js +16 -0
- package/admin/pages/HomePage/utils/parsers.js +187 -0
- package/admin/pages/SettingsPage/common/const.js +1 -0
- package/admin/pages/SettingsPage/common/index.js +1 -0
- package/admin/pages/SettingsPage/components/CustomFieldForm/hooks/index.js +10 -0
- package/admin/pages/SettingsPage/components/CustomFieldForm/index.js +36 -0
- package/admin/pages/SettingsPage/components/CustomFieldModal/index.js +16 -0
- package/admin/pages/SettingsPage/components/CustomFieldTable/index.js +45 -0
- package/admin/pages/SettingsPage/hooks/index.js +111 -0
- package/admin/pages/SettingsPage/index.js +189 -0
- package/admin/pages/SettingsPage/types.js +1 -0
- package/admin/pages/SettingsPage/utils/index.js +25 -0
- package/admin/pluginId.js +1 -0
- package/admin/schemas/config.js +53 -0
- package/admin/schemas/content-type.js +14 -0
- package/admin/schemas/index.js +2 -0
- package/admin/{src/translations → translations}/en.json +7 -9
- package/admin/translations/index.js +15 -0
- package/admin/types.js +1 -0
- package/admin/utils/constants.js +1 -0
- package/admin/utils/getTranslation.js +4 -0
- package/admin/utils/permissions.js +16 -0
- package/admin/utils/prefixPluginTranslations.js +3 -0
- package/package.json +13 -11
- package/server/app-errors.js +20 -0
- package/server/bootstrap.js +13 -0
- package/server/cache/index.js +34 -15
- package/server/config/index.js +7 -5
- package/server/config/{setupStrategy.js → setup.js} +30 -26
- package/server/content-types/audience/index.js +0 -1
- package/server/content-types/audience/schema.js +0 -1
- package/server/content-types/index.js +4 -7
- package/server/content-types/navigation/index.js +0 -1
- package/server/content-types/navigation/lifecycles.js +1 -2
- package/server/content-types/navigation/schema.js +29 -32
- package/server/content-types/navigation-item/index.js +0 -1
- package/server/content-types/navigation-item/lifecycles.js +1 -2
- package/server/content-types/navigation-item/schema.js +51 -58
- package/server/controllers/admin.js +119 -158
- package/server/controllers/client.js +71 -60
- package/server/controllers/index.js +1 -3
- package/server/controllers/utils.js +22 -0
- package/{admin/src/hooks/useNavigationManager.js → server/controllers/validators.js} +23 -16
- package/server/destroy.js +3 -2
- package/{types/i18n.js → server/dtos/config.js} +0 -1
- package/server/{navigation → dtos}/index.js +3 -2
- package/server/dtos/navigation-item.js +2 -0
- package/{admin/src/pages/SettingsPage/types.js → server/dtos/navigation.js} +0 -1
- package/server/graphql/config.js +14 -16
- package/server/graphql/index.js +1 -2
- package/server/graphql/queries/index.js +8 -4
- package/server/graphql/queries/render-navigation-child.js +19 -8
- package/server/graphql/queries/render-navigation.js +30 -14
- package/server/graphql/resolvers-config.js +4 -2
- package/server/graphql/{setupStrategy.js → setup.js} +4 -5
- package/server/graphql/types/content-types-name-fields.js +10 -9
- package/server/graphql/types/content-types.js +15 -15
- package/server/graphql/types/create-navigation-item.js +16 -16
- package/server/graphql/types/create-navigation-related.js +7 -7
- package/server/graphql/types/create-navigation.js +6 -6
- package/server/graphql/types/index.js +35 -15
- package/server/graphql/types/navigation-config.js +8 -8
- package/server/graphql/types/navigation-details.js +2 -2
- package/server/graphql/types/navigation-item-additional-field-media.js +10 -10
- package/server/graphql/types/navigation-item-related-data.js +6 -6
- package/server/graphql/types/navigation-item-related.js +3 -3
- package/server/graphql/types/navigation-item.js +30 -27
- package/server/graphql/types/navigation-render-type.js +4 -5
- package/server/graphql/types/navigation.js +8 -8
- package/server/i18n/index.js +29 -20
- package/server/index.js +15 -8
- package/server/middlewares/index.js +3 -0
- package/server/permissions/index.js +10 -0
- package/{permissions.js → server/permissions/permissions.js} +0 -1
- package/server/permissions/setup.js +32 -0
- package/server/permissions.js +39 -0
- package/server/policies/index.js +3 -0
- package/server/register.js +6 -0
- package/server/repositories/audience.js +12 -0
- package/server/repositories/generic.js +20 -0
- package/server/repositories/index.js +11 -0
- package/server/repositories/navigation-item.js +51 -0
- package/server/repositories/navigation.js +65 -0
- package/server/routes/admin.js +86 -79
- package/server/routes/client.js +0 -1
- package/server/routes/index.js +0 -1
- package/server/schemas/config.js +68 -0
- package/server/schemas/content-type.js +140 -0
- package/{admin/src/pages/SettingsPage/common → server/schemas}/index.js +3 -2
- package/server/schemas/navigation.js +107 -0
- package/server/services/admin/admin.js +483 -0
- package/server/{content-types/navigations-items-related → services/admin}/index.js +2 -5
- package/{admin/src/pages/View/components/NavigationItemForm → server/services/admin}/types.js +0 -1
- package/server/services/admin/utils.js +84 -0
- package/server/services/client/client.js +397 -0
- package/server/services/client/index.js +7 -0
- package/{admin/src/pages/View/components/NavigationManager → server/services/client}/types.js +0 -1
- package/server/services/client/utils.js +88 -0
- package/server/services/common/common.js +307 -0
- package/server/services/common/index.js +7 -0
- package/{admin/src/components/AdditionalFieldInput → server/services/common}/types.js +0 -1
- package/server/services/common/utils.js +24 -0
- package/server/services/index.js +4 -6
- package/server/types.js +2 -0
- package/server/utils/constants.js +35 -0
- package/server/utils/functions.js +71 -299
- package/server/utils/index.js +1 -2
- package/strapi-admin.js +5 -8
- package/strapi-server.js +3 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/admin/src/components/AdditionalFieldInput/index.d.ts +0 -5
- package/admin/src/components/AdditionalFieldInput/index.js +0 -99
- package/admin/src/components/AdditionalFieldInput/types.d.ts +0 -15
- package/admin/src/components/Alert/styles.d.ts +0 -2
- package/admin/src/components/Alert/styles.js +0 -14
- package/admin/src/components/CollapseButton/index.d.ts +0 -7
- package/admin/src/components/CollapseButton/index.js +0 -30
- package/admin/src/components/ConfirmationDialog/index.d.ts +0 -28
- package/admin/src/components/ConfirmationDialog/index.js +0 -34
- package/admin/src/components/DragButton/index.d.ts +0 -6
- package/admin/src/components/EmptyView/index.d.ts +0 -3
- package/admin/src/components/EmptyView/index.js +0 -30
- package/admin/src/components/Item/ItemCardBadge/index.d.ts +0 -3
- package/admin/src/components/Item/ItemCardBadge/index.js +0 -26
- package/admin/src/components/Item/ItemCardHeader/Wrapper.d.ts +0 -3
- package/admin/src/components/Item/ItemCardHeader/Wrapper.js +0 -21
- package/admin/src/components/Item/ItemCardHeader/icons.d.ts +0 -5
- package/admin/src/components/Item/ItemCardHeader/icons.js +0 -13
- package/admin/src/components/Item/ItemCardHeader/index.d.ts +0 -17
- package/admin/src/components/Item/ItemCardHeader/index.js +0 -38
- package/admin/src/components/Item/ItemCardRemovedOverlay/index.d.ts +0 -2
- package/admin/src/components/Item/ItemCardRemovedOverlay/index.js +0 -18
- package/admin/src/components/Item/Wrapper.d.ts +0 -3
- package/admin/src/components/Item/Wrapper.js +0 -43
- package/admin/src/components/Item/index.d.ts +0 -31
- package/admin/src/components/Item/index.js +0 -188
- package/admin/src/components/NavigationItemList/Wrapper.d.ts +0 -3
- package/admin/src/components/NavigationItemList/Wrapper.js +0 -26
- package/admin/src/components/NavigationItemList/index.d.ts +0 -36
- package/admin/src/components/NavigationItemList/index.js +0 -32
- package/admin/src/components/RestartAlert/index.d.ts +0 -3
- package/admin/src/components/RestartAlert/index.js +0 -13
- package/admin/src/components/Search/index.d.ts +0 -12
- package/admin/src/components/Search/index.js +0 -97
- package/admin/src/components/TextArrayInput/index.d.ts +0 -15
- package/admin/src/components/TextArrayInput/index.js +0 -45
- package/admin/src/components/icons/navigation.d.ts +0 -6
- package/admin/src/components/icons/navigation.js +0 -12
- package/admin/src/contexts/DataManagerContext.d.ts +0 -3
- package/admin/src/contexts/DataManagerContext.js +0 -6
- package/admin/src/hooks/useAllContentTypes.d.ts +0 -3
- package/admin/src/hooks/useAllContentTypes.js +0 -8
- package/admin/src/hooks/useDataManager.d.ts +0 -3
- package/admin/src/hooks/useDataManager.js +0 -10
- package/admin/src/hooks/useI18nCopyNavigationItemsModal.d.ts +0 -9
- package/admin/src/hooks/useI18nCopyNavigationItemsModal.js +0 -51
- package/admin/src/hooks/useNavigationConfig.d.ts +0 -10
- package/admin/src/hooks/useNavigationConfig.js +0 -54
- package/admin/src/hooks/useNavigationManager.d.ts +0 -6
- package/admin/src/index.d.ts +0 -14
- package/admin/src/index.js +0 -87
- package/admin/src/pages/App/index.d.ts +0 -3
- package/admin/src/pages/App/index.js +0 -43
- package/admin/src/pages/DataManagerProvider/actions.d.ts +0 -21
- package/admin/src/pages/DataManagerProvider/actions.js +0 -24
- package/admin/src/pages/DataManagerProvider/index.d.ts +0 -12
- package/admin/src/pages/DataManagerProvider/index.js +0 -382
- package/admin/src/pages/DataManagerProvider/init.d.ts +0 -3
- package/admin/src/pages/DataManagerProvider/init.js +0 -7
- package/admin/src/pages/DataManagerProvider/reducer.d.ts +0 -20
- package/admin/src/pages/DataManagerProvider/reducer.js +0 -132
- package/admin/src/pages/NoAccessPage/index.d.ts +0 -3
- package/admin/src/pages/NoAccessPage/index.js +0 -31
- package/admin/src/pages/SettingsPage/common/const.d.ts +0 -2
- package/admin/src/pages/SettingsPage/common/const.js +0 -5
- package/admin/src/pages/SettingsPage/common/index.d.ts +0 -2
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.d.ts +0 -12
- package/admin/src/pages/SettingsPage/components/CustomFieldForm/index.js +0 -129
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.d.ts +0 -12
- package/admin/src/pages/SettingsPage/components/CustomFieldModal/index.js +0 -20
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.d.ts +0 -11
- package/admin/src/pages/SettingsPage/components/CustomFieldTable/index.js +0 -105
- package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.d.ts +0 -23
- package/admin/src/pages/SettingsPage/components/DisableI18nModal/index.js +0 -86
- package/admin/src/pages/SettingsPage/index.d.ts +0 -3
- package/admin/src/pages/SettingsPage/index.js +0 -321
- package/admin/src/pages/SettingsPage/types.d.ts +0 -35
- package/admin/src/pages/SettingsPage/utils/form.d.ts +0 -20
- package/admin/src/pages/SettingsPage/utils/form.js +0 -37
- package/admin/src/pages/SettingsPage/utils/functions.d.ts +0 -3
- package/admin/src/pages/SettingsPage/utils/functions.js +0 -26
- package/admin/src/pages/View/components/I18nCopyNavigationItems/index.d.ts +0 -14
- package/admin/src/pages/View/components/I18nCopyNavigationItems/index.js +0 -15
- package/admin/src/pages/View/components/NavigationContentHeader/index.d.ts +0 -6
- package/admin/src/pages/View/components/NavigationContentHeader/index.js +0 -14
- package/admin/src/pages/View/components/NavigationHeader/index.d.ts +0 -14
- package/admin/src/pages/View/components/NavigationHeader/index.js +0 -92
- package/admin/src/pages/View/components/NavigationHeader/styles.d.ts +0 -2
- package/admin/src/pages/View/components/NavigationHeader/styles.js +0 -18
- package/admin/src/pages/View/components/NavigationItemForm/index.d.ts +0 -5
- package/admin/src/pages/View/components/NavigationItemForm/index.js +0 -470
- package/admin/src/pages/View/components/NavigationItemForm/types.d.ts +0 -99
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.d.ts +0 -28
- package/admin/src/pages/View/components/NavigationItemForm/utils/form.js +0 -123
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.d.ts +0 -25
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupFooter.js +0 -31
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.d.ts +0 -5
- package/admin/src/pages/View/components/NavigationItemPopup/NavigationItemPopupHeader.js +0 -20
- package/admin/src/pages/View/components/NavigationItemPopup/index.d.ts +0 -33
- package/admin/src/pages/View/components/NavigationItemPopup/index.js +0 -90
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.d.ts +0 -4
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/icons.js +0 -12
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/AllNavigations/index.js +0 -151
- package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/DeletionConfirm/index.js +0 -34
- package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/ErrorDetails/index.js +0 -53
- package/admin/src/pages/View/components/NavigationManager/Footer/index.d.ts +0 -24
- package/admin/src/pages/View/components/NavigationManager/Footer/index.js +0 -13
- package/admin/src/pages/View/components/NavigationManager/Form/index.d.ts +0 -19
- package/admin/src/pages/View/components/NavigationManager/Form/index.js +0 -103
- package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/NavigationUpdate/index.js +0 -59
- package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.d.ts +0 -9
- package/admin/src/pages/View/components/NavigationManager/NewNavigation/index.js +0 -62
- package/admin/src/pages/View/components/NavigationManager/PurgeCacheConfirm/index.d.ts +0 -8
- package/admin/src/pages/View/components/NavigationManager/PurgeCacheConfirm/index.js +0 -34
- package/admin/src/pages/View/components/NavigationManager/index.d.ts +0 -10
- package/admin/src/pages/View/components/NavigationManager/index.js +0 -203
- package/admin/src/pages/View/components/NavigationManager/types.d.ts +0 -44
- package/admin/src/pages/View/index.d.ts +0 -4
- package/admin/src/pages/View/index.js +0 -269
- package/admin/src/pages/View/utils/form.d.ts +0 -2
- package/admin/src/pages/View/utils/form.js +0 -16
- package/admin/src/pages/View/utils/index.d.ts +0 -2
- package/admin/src/pages/View/utils/index.js +0 -11
- package/admin/src/pages/View/utils/parsers.d.ts +0 -51
- package/admin/src/pages/View/utils/parsers.js +0 -272
- package/admin/src/pages/View/utils/types.d.ts +0 -3
- package/admin/src/pages/View/utils/types.js +0 -3
- package/admin/src/permissions.d.ts +0 -16
- package/admin/src/permissions.js +0 -13
- package/admin/src/pluginId.d.ts +0 -3
- package/admin/src/pluginId.js +0 -5
- package/admin/src/translations/index.d.ts +0 -15
- package/admin/src/translations/index.js +0 -21
- package/admin/src/utils/api.d.ts +0 -9
- package/admin/src/utils/api.js +0 -20
- package/admin/src/utils/enums.d.ts +0 -25
- package/admin/src/utils/enums.js +0 -30
- package/admin/src/utils/functions.d.ts +0 -16
- package/admin/src/utils/functions.js +0 -46
- package/admin/src/utils/index.d.ts +0 -4
- package/admin/src/utils/index.js +0 -20
- package/permissions.d.ts +0 -10
- package/server/bootstrap/index.d.ts +0 -4
- package/server/bootstrap/index.js +0 -50
- package/server/cache/index.d.ts +0 -2
- package/server/cache/serviceEnhancers.d.ts +0 -3
- package/server/cache/serviceEnhancers.js +0 -16
- package/server/cache/setupStrategy.d.ts +0 -3
- package/server/cache/setupStrategy.js +0 -38
- package/server/cache/types.d.ts +0 -11
- package/server/cache/types.js +0 -3
- package/server/cache/utils.d.ts +0 -11
- package/server/cache/utils.js +0 -19
- package/server/config/index.d.ts +0 -5
- package/server/config/setupStrategy.d.ts +0 -3
- package/server/content-types/audience/index.d.ts +0 -27
- package/server/content-types/audience/schema.d.ts +0 -25
- package/server/content-types/index.d.ts +0 -244
- package/server/content-types/navigation/index.d.ts +0 -59
- package/server/content-types/navigation/lifecycles.d.ts +0 -3
- package/server/content-types/navigation/schema.d.ts +0 -56
- package/server/content-types/navigation-item/index.d.ts +0 -111
- package/server/content-types/navigation-item/lifecycles.d.ts +0 -3
- package/server/content-types/navigation-item/schema.d.ts +0 -108
- package/server/content-types/navigations-items-related/index.d.ts +0 -51
- package/server/content-types/navigations-items-related/schema.d.ts +0 -49
- package/server/content-types/navigations-items-related/schema.js +0 -50
- package/server/controllers/admin.d.ts +0 -4
- package/server/controllers/client.d.ts +0 -4
- package/server/controllers/index.d.ts +0 -4
- package/server/destroy.d.ts +0 -3
- package/server/graphql/config.d.ts +0 -4
- package/server/graphql/index.d.ts +0 -2
- package/server/graphql/queries/index.d.ts +0 -3
- package/server/graphql/queries/render-navigation-child.d.ts +0 -15
- package/server/graphql/queries/render-navigation.d.ts +0 -21
- package/server/graphql/resolvers-config.d.ts +0 -10
- package/server/graphql/setupStrategy.d.ts +0 -3
- package/server/graphql/types/content-types-name-fields.d.ts +0 -6
- package/server/graphql/types/content-types.d.ts +0 -5
- package/server/graphql/types/create-navigation-item.d.ts +0 -5
- package/server/graphql/types/create-navigation-related.d.ts +0 -5
- package/server/graphql/types/create-navigation.d.ts +0 -5
- package/server/graphql/types/index.d.ts +0 -3
- package/server/graphql/types/navigation-config.d.ts +0 -5
- package/server/graphql/types/navigation-details.d.ts +0 -5
- package/server/graphql/types/navigation-item-additional-field-media.d.ts +0 -5
- package/server/graphql/types/navigation-item-related-data.d.ts +0 -5
- package/server/graphql/types/navigation-item-related.d.ts +0 -7
- package/server/graphql/types/navigation-item.d.ts +0 -6
- package/server/graphql/types/navigation-render-type.d.ts +0 -5
- package/server/graphql/types/navigation.d.ts +0 -5
- package/server/i18n/constant.d.ts +0 -2
- package/server/i18n/constant.js +0 -5
- package/server/i18n/errors.d.ts +0 -7
- package/server/i18n/errors.js +0 -14
- package/server/i18n/graphQLEnhancers.d.ts +0 -10
- package/server/i18n/graphQLEnhancers.js +0 -10
- package/server/i18n/index.d.ts +0 -8
- package/server/i18n/navigationSetupStrategy.d.ts +0 -3
- package/server/i18n/navigationSetupStrategy.js +0 -147
- package/server/i18n/serviceEnhancers.d.ts +0 -13
- package/server/i18n/serviceEnhancers.js +0 -156
- package/server/i18n/types.d.ts +0 -60
- package/server/i18n/types.js +0 -3
- package/server/i18n/utils.d.ts +0 -13
- package/server/i18n/utils.js +0 -33
- package/server/index.d.ts +0 -262
- package/server/navigation/index.d.ts +0 -2
- package/server/navigation/setupStrategy.d.ts +0 -3
- package/server/navigation/setupStrategy.js +0 -39
- package/server/register/index.d.ts +0 -3
- package/server/register/index.js +0 -4
- package/server/routes/admin.d.ts +0 -4
- package/server/routes/client.d.ts +0 -4
- package/server/routes/index.d.ts +0 -6
- package/server/services/admin.d.ts +0 -5
- package/server/services/admin.js +0 -347
- package/server/services/client.d.ts +0 -5
- package/server/services/client.js +0 -335
- package/server/services/common.d.ts +0 -5
- package/server/services/common.js +0 -385
- package/server/services/index.d.ts +0 -7
- package/server/utils/constant.d.ts +0 -27
- package/server/utils/constant.js +0 -43
- package/server/utils/functions.d.ts +0 -157
- package/server/utils/index.d.ts +0 -3
- package/strapi-admin.d.ts +0 -3
- package/strapi-server.d.ts +0 -262
- package/types/bootstrap.d.ts +0 -16
- package/types/bootstrap.js +0 -3
- package/types/config.d.ts +0 -27
- package/types/config.js +0 -3
- package/types/contentTypes.d.ts +0 -112
- package/types/contentTypes.js +0 -3
- package/types/controllers.d.ts +0 -65
- package/types/controllers.js +0 -5
- package/types/graphQL.d.ts +0 -3
- package/types/graphQL.js +0 -3
- package/types/i18n.d.ts +0 -9
- package/types/index.d.ts +0 -10
- package/types/index.js +0 -26
- package/types/lifecycle.d.ts +0 -22
- package/types/lifecycle.js +0 -3
- package/types/services.d.ts +0 -106
- package/types/services.js +0 -3
- package/types/utils.d.ts +0 -72
- package/types/utils.js +0 -41
- package/utils/InvalidParamNavigationError.d.ts +0 -4
- package/utils/InvalidParamNavigationError.js +0 -8
- package/utils/NavigationError.d.ts +0 -5
- package/utils/NavigationError.js +0 -11
- /package/admin/{src/translations → translations}/ca.json +0 -0
- /package/admin/{src/translations → translations}/fr.json +0 -0
|
@@ -0,0 +1,483 @@
|
|
|
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 lodash_1 = require("lodash");
|
|
8
|
+
const pluralize_1 = __importDefault(require("pluralize"));
|
|
9
|
+
const app_errors_1 = require("../../app-errors");
|
|
10
|
+
const repositories_1 = require("../../repositories");
|
|
11
|
+
const schemas_1 = require("../../schemas");
|
|
12
|
+
const utils_2 = require("../../utils");
|
|
13
|
+
const utils_3 = require("./utils");
|
|
14
|
+
const adminService = (context) => ({
|
|
15
|
+
async config({ viaSettingsPage = false }) {
|
|
16
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
17
|
+
const cacheStatus = await (0, utils_3.getCacheStatus)(context);
|
|
18
|
+
const pluginStore = await commonService.getPluginStore();
|
|
19
|
+
const config = await pluginStore
|
|
20
|
+
.get({
|
|
21
|
+
key: 'config',
|
|
22
|
+
})
|
|
23
|
+
.then(schemas_1.configSchema.parse);
|
|
24
|
+
const { additionalFields, cascadeMenuAttached, contentTypesPopulate, contentTypesNameFields, pathDefaultFields, allowedLevels, preferCustomContentTypes, } = config;
|
|
25
|
+
const isGQLPluginEnabled = !!strapi.plugin('graphql');
|
|
26
|
+
let extendedResult = {
|
|
27
|
+
allowedContentTypes: utils_2.ALLOWED_CONTENT_TYPES,
|
|
28
|
+
restrictedContentTypes: utils_2.RESTRICTED_CONTENT_TYPES,
|
|
29
|
+
availableAudience: [],
|
|
30
|
+
};
|
|
31
|
+
const configContentTypes = await this.configContentTypes({});
|
|
32
|
+
const result = {
|
|
33
|
+
contentTypes: await this.configContentTypes({ viaSettingsPage }),
|
|
34
|
+
contentTypesNameFields: {
|
|
35
|
+
default: utils_2.CONTENT_TYPES_NAME_FIELDS_DEFAULTS,
|
|
36
|
+
...((0, lodash_1.isObject)(contentTypesNameFields) ? contentTypesNameFields : {}),
|
|
37
|
+
},
|
|
38
|
+
contentTypesPopulate: (0, lodash_1.isObject)(contentTypesPopulate) ? contentTypesPopulate : {},
|
|
39
|
+
pathDefaultFields: (0, lodash_1.isObject)(pathDefaultFields) ? pathDefaultFields : {},
|
|
40
|
+
allowedLevels,
|
|
41
|
+
additionalFields: viaSettingsPage
|
|
42
|
+
? additionalFields
|
|
43
|
+
: additionalFields.filter((field) => typeof field === 'string' || !!field.enabled),
|
|
44
|
+
gql: {
|
|
45
|
+
navigationItemRelated: configContentTypes.map(({ labelSingular }) => labelSingular.replace(/\s+/g, '')),
|
|
46
|
+
},
|
|
47
|
+
isGQLPluginEnabled: viaSettingsPage ? isGQLPluginEnabled : undefined,
|
|
48
|
+
cascadeMenuAttached,
|
|
49
|
+
preferCustomContentTypes,
|
|
50
|
+
};
|
|
51
|
+
if (additionalFields.includes('audience')) {
|
|
52
|
+
const audienceItems = await (0, repositories_1.getAudienceRepository)(context).find({}, Number.MAX_SAFE_INTEGER);
|
|
53
|
+
extendedResult = {
|
|
54
|
+
...extendedResult,
|
|
55
|
+
availableAudience: audienceItems,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
...result,
|
|
60
|
+
...extendedResult,
|
|
61
|
+
isCacheEnabled: cacheStatus.enabled,
|
|
62
|
+
isCachePluginEnabled: cacheStatus.hasCachePlugin,
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
async configContentTypes({ viaSettingsPage = false, }) {
|
|
66
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
67
|
+
const pluginStore = await commonService.getPluginStore();
|
|
68
|
+
const config = await pluginStore.get({ key: 'config' }).then(schemas_1.configSchema.parse);
|
|
69
|
+
const eligibleContentTypes = await Promise.all(config.contentTypes
|
|
70
|
+
.filter((contentType) => !!context.strapi.contentTypes[contentType] && (0, utils_2.isContentTypeEligible)(contentType))
|
|
71
|
+
.map(async (key) => {
|
|
72
|
+
const item = schemas_1.contentTypeFullSchema.parse(strapi.contentTypes[key]);
|
|
73
|
+
const { kind, options, uid } = item;
|
|
74
|
+
const draftAndPublish = options?.draftAndPublish;
|
|
75
|
+
const isSingleType = kind === utils_2.KIND_TYPES.SINGLE;
|
|
76
|
+
const isSingleTypeWithPublishFlow = isSingleType && draftAndPublish;
|
|
77
|
+
const returnType = (available) => ({
|
|
78
|
+
key,
|
|
79
|
+
available,
|
|
80
|
+
});
|
|
81
|
+
if (isSingleType) {
|
|
82
|
+
const repository = (0, repositories_1.getGenericRepository)(context, uid);
|
|
83
|
+
if (isSingleTypeWithPublishFlow) {
|
|
84
|
+
const itemsCountOrBypass = isSingleTypeWithPublishFlow
|
|
85
|
+
? await repository.count({
|
|
86
|
+
publishedAt: {
|
|
87
|
+
$notNull: true,
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
: true;
|
|
91
|
+
return returnType(itemsCountOrBypass !== 0);
|
|
92
|
+
}
|
|
93
|
+
const isAvailable = await repository.count({});
|
|
94
|
+
return isAvailable !== 0
|
|
95
|
+
? returnType(true)
|
|
96
|
+
: viaSettingsPage
|
|
97
|
+
? returnType(false)
|
|
98
|
+
: undefined;
|
|
99
|
+
}
|
|
100
|
+
return returnType(true);
|
|
101
|
+
}));
|
|
102
|
+
return eligibleContentTypes.reduce((acc, current) => {
|
|
103
|
+
if (!current?.key) {
|
|
104
|
+
return acc;
|
|
105
|
+
}
|
|
106
|
+
const { key, available } = current;
|
|
107
|
+
const item = schemas_1.contentTypeFullSchema.parse(context.strapi.contentTypes[key]);
|
|
108
|
+
const relatedField = (item.associations || []).find(({ model }) => model === 'navigationitem');
|
|
109
|
+
const { uid, options, info, collectionName, modelName, apiName, plugin, kind, pluginOptions = {}, } = item;
|
|
110
|
+
const isAvailable = available && !options?.hidden;
|
|
111
|
+
if (!isAvailable) {
|
|
112
|
+
return acc;
|
|
113
|
+
}
|
|
114
|
+
const { visible = true } = pluginOptions['content-manager'] || {};
|
|
115
|
+
const { name = '', description = '' } = info;
|
|
116
|
+
const findRouteConfig = (0, lodash_1.find)((0, lodash_1.get)(context.strapi.api, `[${modelName}].config.routes`, []), (route) => route.handler.includes('.find'));
|
|
117
|
+
const findRoutePath = findRouteConfig && findRouteConfig.path.split('/')[1];
|
|
118
|
+
const apiPath = findRoutePath && findRoutePath !== apiName ? findRoutePath : apiName || modelName;
|
|
119
|
+
const isSingle = kind === utils_2.KIND_TYPES.SINGLE;
|
|
120
|
+
const endpoint = isSingle ? apiPath : (0, pluralize_1.default)(apiPath);
|
|
121
|
+
const relationName = (0, utils_2.singularize)(modelName);
|
|
122
|
+
const relationNameParts = typeof uid === 'string' ? (0, lodash_1.last)(uid.split('.')).split('-') : [];
|
|
123
|
+
const contentTypeName = relationNameParts.length > 1
|
|
124
|
+
? relationNameParts.reduce((prev, curr) => `${prev}${(0, lodash_1.upperFirst)(curr)}`, '')
|
|
125
|
+
: (0, lodash_1.upperFirst)(modelName);
|
|
126
|
+
const labelSingular = name ||
|
|
127
|
+
(0, lodash_1.upperFirst)(relationNameParts.length > 1 ? relationNameParts.join(' ') : relationName);
|
|
128
|
+
acc.push({
|
|
129
|
+
uid,
|
|
130
|
+
name: relationName,
|
|
131
|
+
draftAndPublish: options?.draftAndPublish,
|
|
132
|
+
isSingle,
|
|
133
|
+
description,
|
|
134
|
+
collectionName,
|
|
135
|
+
contentTypeName,
|
|
136
|
+
label: isSingle ? labelSingular : (0, pluralize_1.default)(name || labelSingular),
|
|
137
|
+
relatedField: relatedField ? relatedField.alias : undefined,
|
|
138
|
+
labelSingular: (0, utils_2.singularize)(labelSingular),
|
|
139
|
+
endpoint: endpoint,
|
|
140
|
+
plugin,
|
|
141
|
+
available: isAvailable,
|
|
142
|
+
visible,
|
|
143
|
+
templateName: options?.templateName,
|
|
144
|
+
});
|
|
145
|
+
return acc;
|
|
146
|
+
}, []);
|
|
147
|
+
},
|
|
148
|
+
async get({ ids, localeCode }) {
|
|
149
|
+
let where = {};
|
|
150
|
+
if (ids && ids.length) {
|
|
151
|
+
where.id = { $in: ids };
|
|
152
|
+
}
|
|
153
|
+
if (localeCode) {
|
|
154
|
+
where.localeCode = localeCode;
|
|
155
|
+
}
|
|
156
|
+
const dbResults = await (0, repositories_1.getNavigationRepository)(context).find({
|
|
157
|
+
where,
|
|
158
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
159
|
+
populate: ['items', 'items.parent', 'items.audience'],
|
|
160
|
+
});
|
|
161
|
+
const buildItemsStructure = ({ allItems, item, parent, }) => {
|
|
162
|
+
const children = allItems.filter((child) => child.parent?.id === item.id);
|
|
163
|
+
return {
|
|
164
|
+
...item,
|
|
165
|
+
parent,
|
|
166
|
+
items: children
|
|
167
|
+
.map((child) => buildItemsStructure({
|
|
168
|
+
parent: item,
|
|
169
|
+
item: child,
|
|
170
|
+
allItems,
|
|
171
|
+
}))
|
|
172
|
+
.sort((a, b) => a.order - b.order),
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
return dbResults.map((navigation) => ({
|
|
176
|
+
...navigation,
|
|
177
|
+
items: navigation.items
|
|
178
|
+
?.filter((item) => !item.parent)
|
|
179
|
+
.map((item) => buildItemsStructure({
|
|
180
|
+
allItems: navigation.items ?? [],
|
|
181
|
+
item,
|
|
182
|
+
})),
|
|
183
|
+
}));
|
|
184
|
+
},
|
|
185
|
+
async getById({ id }) {
|
|
186
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
187
|
+
const navigation = await (0, repositories_1.getNavigationRepository)(context).findOne({
|
|
188
|
+
where: { id },
|
|
189
|
+
});
|
|
190
|
+
const dbNavigationItems = await (0, repositories_1.getNavigationItemRepository)(context).find({
|
|
191
|
+
where: { master: navigation.id },
|
|
192
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
193
|
+
order: [{ order: 'asc' }],
|
|
194
|
+
populate: ['parent', 'audience'],
|
|
195
|
+
});
|
|
196
|
+
return {
|
|
197
|
+
...navigation,
|
|
198
|
+
items: commonService
|
|
199
|
+
.buildNestedStructure({
|
|
200
|
+
navigationItems: dbNavigationItems,
|
|
201
|
+
})
|
|
202
|
+
.filter(({ parent }) => !parent),
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
async post({ auditLog, payload }) {
|
|
206
|
+
const { masterModel } = (0, utils_2.getPluginModels)(context);
|
|
207
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
208
|
+
const { defaultLocale, restLocale } = await commonService.readLocale();
|
|
209
|
+
const repository = (0, repositories_1.getNavigationRepository)(context);
|
|
210
|
+
const navigationSummary = [];
|
|
211
|
+
const { name, visible } = payload;
|
|
212
|
+
const slug = await commonService.getSlug({ query: name });
|
|
213
|
+
const mainNavigation = await repository.save({
|
|
214
|
+
name,
|
|
215
|
+
visible,
|
|
216
|
+
localeCode: defaultLocale,
|
|
217
|
+
slug,
|
|
218
|
+
});
|
|
219
|
+
navigationSummary.push(await this.getById({ id: mainNavigation.id }));
|
|
220
|
+
for (const localeCode of restLocale) {
|
|
221
|
+
const newLocaleNavigation = await repository.save({
|
|
222
|
+
name,
|
|
223
|
+
visible,
|
|
224
|
+
localeCode,
|
|
225
|
+
slug: `${slug}-${localeCode}`,
|
|
226
|
+
documentId: mainNavigation.documentId,
|
|
227
|
+
});
|
|
228
|
+
navigationSummary.push(await this.getById({ id: newLocaleNavigation.id }));
|
|
229
|
+
}
|
|
230
|
+
navigationSummary.map((navigation) => {
|
|
231
|
+
(0, utils_3.sendAuditLog)(auditLog, 'onChangeNavigation', {
|
|
232
|
+
actionType: 'CREATE',
|
|
233
|
+
oldEntity: navigation,
|
|
234
|
+
newEntity: navigation,
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
await commonService.emitEvent({
|
|
238
|
+
entity: mainNavigation,
|
|
239
|
+
event: 'entry.create',
|
|
240
|
+
uid: masterModel.uid,
|
|
241
|
+
});
|
|
242
|
+
return {
|
|
243
|
+
...mainNavigation,
|
|
244
|
+
items: [],
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
async put({ auditLog, payload }) {
|
|
248
|
+
const { masterModel } = (0, utils_2.getPluginModels)(context);
|
|
249
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
250
|
+
const { defaultLocale } = await commonService.readLocale();
|
|
251
|
+
const repository = (0, repositories_1.getNavigationRepository)(context);
|
|
252
|
+
const { name, visible, items } = payload;
|
|
253
|
+
const currentNavigation = await repository.findOne({
|
|
254
|
+
where: { id: payload.id },
|
|
255
|
+
populate: true,
|
|
256
|
+
});
|
|
257
|
+
const currentNavigationAsDTO = await this.getById({ id: payload.id });
|
|
258
|
+
const detailsHaveChanged = currentNavigation.name !== name || currentNavigation.visible !== visible;
|
|
259
|
+
if (detailsHaveChanged) {
|
|
260
|
+
const allNavigations = await repository.find({
|
|
261
|
+
where: { documentId: currentNavigation.documentId },
|
|
262
|
+
});
|
|
263
|
+
for (const navigation of allNavigations) {
|
|
264
|
+
const newSlug = name
|
|
265
|
+
? await commonService.getSlug({
|
|
266
|
+
query: `${name}${navigation.localeCode !== defaultLocale ? ` ${navigation.localeCode}` : ''}`,
|
|
267
|
+
})
|
|
268
|
+
: currentNavigation.slug;
|
|
269
|
+
await repository.save({
|
|
270
|
+
id: navigation.id,
|
|
271
|
+
slug: newSlug,
|
|
272
|
+
name,
|
|
273
|
+
visible,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const updatedNavigationAsDTO = await commonService
|
|
278
|
+
.analyzeBranch({
|
|
279
|
+
navigationItems: items ?? [],
|
|
280
|
+
masterEntity: currentNavigation,
|
|
281
|
+
prevAction: {},
|
|
282
|
+
})
|
|
283
|
+
.then(utils_3.prepareAuditLog)
|
|
284
|
+
.then(async (actionType) => {
|
|
285
|
+
const newEntity = await this.getById({ id: currentNavigation.id });
|
|
286
|
+
(0, utils_3.sendAuditLog)(auditLog, 'onChangeNavigation', {
|
|
287
|
+
actionType,
|
|
288
|
+
oldEntity: currentNavigationAsDTO,
|
|
289
|
+
newEntity,
|
|
290
|
+
});
|
|
291
|
+
return newEntity;
|
|
292
|
+
});
|
|
293
|
+
await commonService.emitEvent({
|
|
294
|
+
entity: await repository.findOne({ where: { id: payload.id }, populate: true }),
|
|
295
|
+
event: 'entry.update',
|
|
296
|
+
uid: masterModel.uid,
|
|
297
|
+
});
|
|
298
|
+
return updatedNavigationAsDTO;
|
|
299
|
+
},
|
|
300
|
+
async delete({ auditLog, id }) {
|
|
301
|
+
const navigationRepository = (0, repositories_1.getNavigationRepository)(context);
|
|
302
|
+
const navigationItemRepository = (0, repositories_1.getNavigationItemRepository)(context);
|
|
303
|
+
const navigationAsDTO = await this.getById({ id });
|
|
304
|
+
// TODO: remove when cascade deletion is present
|
|
305
|
+
// NOTE: Delete many with relation `where` crashes ORM
|
|
306
|
+
const cleanNavigationItems = async (masterIds) => {
|
|
307
|
+
if (masterIds.length < 1) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
await navigationItemRepository.removeForIds(await navigationItemRepository.findForMasterIds(masterIds).then((_) => _.reduce((acc, { id }) => {
|
|
311
|
+
if (id) {
|
|
312
|
+
acc.push(id);
|
|
313
|
+
}
|
|
314
|
+
return acc;
|
|
315
|
+
}, [])));
|
|
316
|
+
};
|
|
317
|
+
const navigation = await navigationRepository.findOne({ where: { id }, populate: true });
|
|
318
|
+
const allNavigations = await navigationRepository.find({
|
|
319
|
+
where: { documentId: navigation.documentId },
|
|
320
|
+
populate: true,
|
|
321
|
+
});
|
|
322
|
+
await cleanNavigationItems(allNavigations.map(({ id }) => id));
|
|
323
|
+
await navigationRepository.remove({ documentId: navigation.documentId });
|
|
324
|
+
(0, utils_3.sendAuditLog)(auditLog, 'onNavigationDeletion', {
|
|
325
|
+
entity: navigationAsDTO,
|
|
326
|
+
actionType: 'DELETE',
|
|
327
|
+
});
|
|
328
|
+
},
|
|
329
|
+
async restart() {
|
|
330
|
+
setImmediate(() => context.strapi.reload());
|
|
331
|
+
},
|
|
332
|
+
async restoreConfig() {
|
|
333
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
334
|
+
const pluginStore = await commonService.getPluginStore();
|
|
335
|
+
await pluginStore.delete({ key: 'config' });
|
|
336
|
+
await commonService.setDefaultConfig();
|
|
337
|
+
},
|
|
338
|
+
async updateConfig({ config: newConfig }) {
|
|
339
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
340
|
+
const pluginStore = await commonService.getPluginStore();
|
|
341
|
+
const config = await pluginStore
|
|
342
|
+
.get({
|
|
343
|
+
key: 'config',
|
|
344
|
+
})
|
|
345
|
+
.then(schemas_1.configSchema.parse);
|
|
346
|
+
(0, utils_2.validateAdditionalFields)(newConfig.additionalFields);
|
|
347
|
+
await pluginStore.set({ key: 'config', value: newConfig });
|
|
348
|
+
const removedFields = (0, lodash_1.differenceBy)(config.additionalFields, newConfig.additionalFields, 'name').reduce((acc, field) => {
|
|
349
|
+
if (typeof field === 'string') {
|
|
350
|
+
return acc;
|
|
351
|
+
}
|
|
352
|
+
acc.push(field);
|
|
353
|
+
return acc;
|
|
354
|
+
}, []);
|
|
355
|
+
if (!(0, lodash_1.isEmpty)(removedFields)) {
|
|
356
|
+
await commonService.pruneCustomFields({ removedFields });
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
async fillFromOtherLocale({ auditLog, source, target, }) {
|
|
360
|
+
const targetEntity = await this.getById({ id: target });
|
|
361
|
+
return await this.i18nNavigationContentsCopy({
|
|
362
|
+
source: await this.getById({ id: source }),
|
|
363
|
+
target: targetEntity,
|
|
364
|
+
})
|
|
365
|
+
.then(() => this.getById({ id: target }))
|
|
366
|
+
.then((newEntity) => {
|
|
367
|
+
(0, utils_3.sendAuditLog)(auditLog, 'onChangeNavigation', {
|
|
368
|
+
actionType: 'UPDATE',
|
|
369
|
+
oldEntity: targetEntity,
|
|
370
|
+
newEntity,
|
|
371
|
+
});
|
|
372
|
+
return newEntity;
|
|
373
|
+
});
|
|
374
|
+
},
|
|
375
|
+
async i18nNavigationContentsCopy({ source, target, }) {
|
|
376
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
377
|
+
const sourceItems = source.items ?? [];
|
|
378
|
+
const navigationRepository = (0, repositories_1.getNavigationRepository)(context);
|
|
379
|
+
if (target.items?.length) {
|
|
380
|
+
throw new app_errors_1.FillNavigationError('Current navigation is non-empty');
|
|
381
|
+
}
|
|
382
|
+
if (!target.localeCode) {
|
|
383
|
+
throw new app_errors_1.FillNavigationError('Current navigation does not have specified locale');
|
|
384
|
+
}
|
|
385
|
+
if (!sourceItems.length) {
|
|
386
|
+
throw new app_errors_1.FillNavigationError('Source navigation is empty');
|
|
387
|
+
}
|
|
388
|
+
const entities = new Map();
|
|
389
|
+
const itemProcessor = (0, utils_3.processItems)({
|
|
390
|
+
master: target,
|
|
391
|
+
localeCode: target.localeCode,
|
|
392
|
+
strapi,
|
|
393
|
+
entities,
|
|
394
|
+
});
|
|
395
|
+
await commonService.createBranch({
|
|
396
|
+
action: { create: true },
|
|
397
|
+
masterEntity: await navigationRepository.findOne({
|
|
398
|
+
where: { id: target.id },
|
|
399
|
+
populate: true,
|
|
400
|
+
}),
|
|
401
|
+
navigationItems: await Promise.all(sourceItems.map(itemProcessor)),
|
|
402
|
+
parentItem: undefined,
|
|
403
|
+
});
|
|
404
|
+
},
|
|
405
|
+
async readNavigationItemFromLocale({ path, source, target, }) {
|
|
406
|
+
const sourceNavigation = await this.getById({ id: source });
|
|
407
|
+
const targetNavigation = await this.getById({ id: target });
|
|
408
|
+
if (!sourceNavigation) {
|
|
409
|
+
throw new utils_1.errors.NotFoundError('Unable to find source navigation for specified query');
|
|
410
|
+
}
|
|
411
|
+
if (!targetNavigation) {
|
|
412
|
+
throw new utils_1.errors.NotFoundError('Unable to find target navigation for specified query');
|
|
413
|
+
}
|
|
414
|
+
const requiredFields = [
|
|
415
|
+
'path',
|
|
416
|
+
'related',
|
|
417
|
+
'type',
|
|
418
|
+
'uiRouterKey',
|
|
419
|
+
'title',
|
|
420
|
+
'externalPath',
|
|
421
|
+
];
|
|
422
|
+
const structurePath = path.split('.').map((p) => parseInt(p, 10));
|
|
423
|
+
if (!structurePath.some(Number.isNaN) || !structurePath.length) {
|
|
424
|
+
new app_errors_1.InvalidParamNavigationError('Path is invalid');
|
|
425
|
+
}
|
|
426
|
+
let result = (0, lodash_1.get)(sourceNavigation.items, (0, utils_3.intercalate)('items', structurePath.map(lodash_1.toString)));
|
|
427
|
+
if (!result) {
|
|
428
|
+
throw new utils_1.errors.NotFoundError('Unable to find navigation item');
|
|
429
|
+
}
|
|
430
|
+
return schemas_1.readNavigationItemFromLocaleSchema.parse((0, lodash_1.pick)(result, requiredFields));
|
|
431
|
+
},
|
|
432
|
+
async getContentTypeItems({ query, uid }) {
|
|
433
|
+
const commonService = (0, utils_2.getPluginService)(context, 'common');
|
|
434
|
+
const pluginStore = await commonService.getPluginStore();
|
|
435
|
+
const config = await pluginStore.get({ key: 'config' }).then(schemas_1.configSchema.parse);
|
|
436
|
+
const where = {
|
|
437
|
+
publishedAt: {
|
|
438
|
+
$notNull: true,
|
|
439
|
+
},
|
|
440
|
+
};
|
|
441
|
+
if (query.localeCode) {
|
|
442
|
+
where.locale = query.localeCode;
|
|
443
|
+
}
|
|
444
|
+
const repository = (0, repositories_1.getGenericRepository)(context, uid);
|
|
445
|
+
try {
|
|
446
|
+
const contentTypeItems = await repository.findMany(where, config.contentTypesPopulate[uid] || []);
|
|
447
|
+
return contentTypeItems;
|
|
448
|
+
}
|
|
449
|
+
catch (err) {
|
|
450
|
+
return [];
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
async purgeNavigationCache(id, clearLocalisations) {
|
|
454
|
+
const navigationRepository = (0, repositories_1.getNavigationRepository)(context);
|
|
455
|
+
const entity = await navigationRepository.findOne({ where: { id } });
|
|
456
|
+
if (!entity) {
|
|
457
|
+
throw new utils_1.errors.NotFoundError('Navigation is not defined');
|
|
458
|
+
}
|
|
459
|
+
const mapToRegExp = (id) => new RegExp(`/api/navigation/render/${id}`);
|
|
460
|
+
let regexps = [mapToRegExp(entity.id)];
|
|
461
|
+
if (clearLocalisations) {
|
|
462
|
+
const navigations = await navigationRepository.find({
|
|
463
|
+
where: {
|
|
464
|
+
documentId: entity.documentId,
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
regexps = navigations.map(({ id }) => mapToRegExp(id));
|
|
468
|
+
}
|
|
469
|
+
const restCachePlugin = strapi.plugin('rest-cache');
|
|
470
|
+
const cacheStore = restCachePlugin.service('cacheStore');
|
|
471
|
+
regexps.push(mapToRegExp(id));
|
|
472
|
+
await cacheStore.clearByRegexp(regexps);
|
|
473
|
+
return { success: true };
|
|
474
|
+
},
|
|
475
|
+
async purgeNavigationsCache() {
|
|
476
|
+
const restCachePlugin = strapi.plugin('rest-cache');
|
|
477
|
+
const cacheStore = restCachePlugin.service('cacheStore');
|
|
478
|
+
const regex = new RegExp('/api/navigation/render(.*)');
|
|
479
|
+
await cacheStore.clearByRegexp([regex]);
|
|
480
|
+
return { success: true };
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
exports.default = adminService;
|
|
@@ -3,8 +3,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
exports.default =
|
|
8
|
-
schema: schema_1.default
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
6
|
+
const admin_1 = __importDefault(require("./admin"));
|
|
7
|
+
exports.default = admin_1.default;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCacheStatus = exports.intercalate = exports.processItems = exports.prepareAuditLog = exports.sendAuditLog = void 0;
|
|
4
|
+
const repositories_1 = require("../../repositories");
|
|
5
|
+
const schemas_1 = require("../../schemas");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const sendAuditLog = (auditLogInstance, event, data) => {
|
|
8
|
+
if (auditLogInstance && auditLogInstance.emit) {
|
|
9
|
+
auditLogInstance.emit(event, data);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
exports.sendAuditLog = sendAuditLog;
|
|
13
|
+
const prepareAuditLog = (actions) => {
|
|
14
|
+
return [
|
|
15
|
+
...new Set(actions
|
|
16
|
+
.filter((_) => !!_)
|
|
17
|
+
.flatMap(({ remove, create, update }) => {
|
|
18
|
+
return [create ? 'CREATE' : '', update ? 'UPDATE' : '', remove ? 'REMOVE' : ''].filter((_) => !!_);
|
|
19
|
+
})),
|
|
20
|
+
].join('_');
|
|
21
|
+
};
|
|
22
|
+
exports.prepareAuditLog = prepareAuditLog;
|
|
23
|
+
const processItems = (context) => async (item) => {
|
|
24
|
+
const { related } = item;
|
|
25
|
+
let nextRelated = related;
|
|
26
|
+
if (related && !context.entities.has(related)) {
|
|
27
|
+
const [uid, id] = related.split(utils_1.RELATED_ITEM_SEPARATOR);
|
|
28
|
+
const entity = await (0, repositories_1.getGenericRepository)(context, uid).findById(parseInt(id, 10), true);
|
|
29
|
+
if (!context.entities.has(related)) {
|
|
30
|
+
context.entities.set(related, {
|
|
31
|
+
...entity,
|
|
32
|
+
uid,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (related && context.entities.has(related)) {
|
|
37
|
+
const entity = context.entities.get(related);
|
|
38
|
+
const localeVersion = await strapi.documents(entity.uid).findOne({
|
|
39
|
+
documentId: entity.documentId,
|
|
40
|
+
locale: context.localeCode,
|
|
41
|
+
status: 'published',
|
|
42
|
+
});
|
|
43
|
+
if (localeVersion) {
|
|
44
|
+
nextRelated = [entity.uid, localeVersion.id].join(utils_1.RELATED_ITEM_SEPARATOR);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
title: item.title,
|
|
49
|
+
path: item.path,
|
|
50
|
+
audience: item.audience,
|
|
51
|
+
type: item.type,
|
|
52
|
+
uiRouterKey: item.uiRouterKey,
|
|
53
|
+
order: item.order,
|
|
54
|
+
collapsed: item.collapsed,
|
|
55
|
+
menuAttached: item.menuAttached,
|
|
56
|
+
removed: false,
|
|
57
|
+
updated: true,
|
|
58
|
+
externalPath: item.externalPath,
|
|
59
|
+
items: item.items
|
|
60
|
+
? await Promise.all(item.items.map((0, exports.processItems)(context)))
|
|
61
|
+
: [],
|
|
62
|
+
master: context.master,
|
|
63
|
+
parent: undefined,
|
|
64
|
+
related: nextRelated,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.processItems = processItems;
|
|
68
|
+
const intercalate = (glue, arr) => arr.slice(1).reduce((acc, element) => acc.concat([glue, element]), arr.slice(0, 1));
|
|
69
|
+
exports.intercalate = intercalate;
|
|
70
|
+
const getCacheStatus = async ({ strapi, }) => {
|
|
71
|
+
const cachePlugin = strapi.plugin('rest-cache');
|
|
72
|
+
const hasCachePlugin = !!cachePlugin;
|
|
73
|
+
const pluginStore = strapi.store({
|
|
74
|
+
type: 'plugin',
|
|
75
|
+
name: 'navigation',
|
|
76
|
+
});
|
|
77
|
+
const config = schemas_1.configSchema.parse(await pluginStore.get({
|
|
78
|
+
key: 'config',
|
|
79
|
+
}));
|
|
80
|
+
return hasCachePlugin
|
|
81
|
+
? { hasCachePlugin, enabled: !!config.isCacheEnabled }
|
|
82
|
+
: { hasCachePlugin, enabled: false };
|
|
83
|
+
};
|
|
84
|
+
exports.getCacheStatus = getCacheStatus;
|