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.
- package/README.md +41 -63
- 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,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;
|
|
@@ -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;
|