@akemona-org/strapi-plugin-content-manager 3.7.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/LICENSE +22 -0
- package/README.md +27 -0
- package/admin/src/InjectedComponents/ContentTypeBuilder/ConfigureViewButton/index.js +78 -0
- package/admin/src/assets/images/background_input.svg +1 -0
- package/admin/src/assets/images/icon-cross-blue.svg +1 -0
- package/admin/src/assets/images/icon_remove.svg +19 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/AddDropdown/components.js +113 -0
- package/admin/src/components/AddDropdown/index.js +76 -0
- package/admin/src/components/Block/components.js +28 -0
- package/admin/src/components/Block/index.js +45 -0
- package/admin/src/components/ComponentInitializer/P.js +9 -0
- package/admin/src/components/ComponentInitializer/index.js +43 -0
- package/admin/src/components/Container/index.js +7 -0
- package/admin/src/components/CustomInputCheckbox/components.js +77 -0
- package/admin/src/components/CustomInputCheckbox/index.js +53 -0
- package/admin/src/components/CustomTable/ActionCollapse/Delete.js +14 -0
- package/admin/src/components/CustomTable/ActionCollapse/DeleteAll.js +18 -0
- package/admin/src/components/CustomTable/ActionCollapse/Wrapper.js +20 -0
- package/admin/src/components/CustomTable/ActionCollapse/index.js +38 -0
- package/admin/src/components/CustomTable/Headers/Header.js +59 -0
- package/admin/src/components/CustomTable/Headers/Thead.js +35 -0
- package/admin/src/components/CustomTable/Headers/index.js +46 -0
- package/admin/src/components/CustomTable/Row/ActionContainer.js +19 -0
- package/admin/src/components/CustomTable/Row/Cell.js +55 -0
- package/admin/src/components/CustomTable/Row/index.js +112 -0
- package/admin/src/components/CustomTable/index.js +162 -0
- package/admin/src/components/CustomTable/styledComponents.js +85 -0
- package/admin/src/components/DragLayer/index.js +102 -0
- package/admin/src/components/DraggedField/Close/index.js +10 -0
- package/admin/src/components/DraggedField/GrabWrapper.js +38 -0
- package/admin/src/components/DraggedField/Link.js +17 -0
- package/admin/src/components/DraggedField/NameWrapper.js +29 -0
- package/admin/src/components/DraggedField/RemoveWrapper.js +32 -0
- package/admin/src/components/DraggedField/SubWrapper.js +36 -0
- package/admin/src/components/DraggedField/Wrapper.js +134 -0
- package/admin/src/components/DraggedField/index.js +196 -0
- package/admin/src/components/DraggedField/utils/getColor.js +12 -0
- package/admin/src/components/DraggedField/utils/getHeight.js +3 -0
- package/admin/src/components/DraggedFieldWithPreview/Carret.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicComponent.js +70 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicZoneWrapper.js +10 -0
- package/admin/src/components/DraggedFieldWithPreview/Tooltip.js +19 -0
- package/admin/src/components/DraggedFieldWithPreview/Wrapper.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/index.js +194 -0
- package/admin/src/components/DynamicComponentCard/Wrapper.js +63 -0
- package/admin/src/components/DynamicComponentCard/index.js +49 -0
- package/admin/src/components/DynamicZone/BaselineAlignement.js +11 -0
- package/admin/src/components/DynamicZone/Button.js +31 -0
- package/admin/src/components/DynamicZone/Component/RoundCTA.js +45 -0
- package/admin/src/components/DynamicZone/Component/index.js +79 -0
- package/admin/src/components/DynamicZone/ComponentWrapper.js +44 -0
- package/admin/src/components/DynamicZone/DynamicZoneWrapper.js +12 -0
- package/admin/src/components/DynamicZone/Label.js +42 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/Wrapper.js +78 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/index.js +33 -0
- package/admin/src/components/DynamicZone/Picker/Category/index.js +53 -0
- package/admin/src/components/DynamicZone/Picker/Wrapper.js +32 -0
- package/admin/src/components/DynamicZone/Picker/index.js +88 -0
- package/admin/src/components/DynamicZone/Wrapper.js +34 -0
- package/admin/src/components/DynamicZone/index.js +238 -0
- package/admin/src/components/DynamicZone/utils/connect.js +12 -0
- package/admin/src/components/DynamicZone/utils/select.js +49 -0
- package/admin/src/components/FieldComponent/ComponentIcon.js +44 -0
- package/admin/src/components/FieldComponent/EmptyComponent.js +19 -0
- package/admin/src/components/FieldComponent/Label.js +10 -0
- package/admin/src/components/FieldComponent/ResetComponent.js +41 -0
- package/admin/src/components/FieldComponent/Wrapper.js +18 -0
- package/admin/src/components/FieldComponent/index.js +171 -0
- package/admin/src/components/FieldComponent/utils/connect.js +12 -0
- package/admin/src/components/FieldComponent/utils/select.js +123 -0
- package/admin/src/components/FieldsReorder/Item.js +249 -0
- package/admin/src/components/FieldsReorder/components.js +8 -0
- package/admin/src/components/FieldsReorder/index.js +102 -0
- package/admin/src/components/FilterOptionsCTA/index.js +14 -0
- package/admin/src/components/FilterPicker/components.js +56 -0
- package/admin/src/components/FilterPicker/index.js +258 -0
- package/admin/src/components/FilterPicker/init.js +25 -0
- package/admin/src/components/FilterPicker/reducer.js +58 -0
- package/admin/src/components/FilterPickerOption/Input.js +58 -0
- package/admin/src/components/FilterPickerOption/Option.js +18 -0
- package/admin/src/components/FilterPickerOption/components.js +60 -0
- package/admin/src/components/FilterPickerOption/index.js +101 -0
- package/admin/src/components/FormTitle/index.js +26 -0
- package/admin/src/components/FormWrapper/index.js +20 -0
- package/admin/src/components/InputJSON/components.js +30 -0
- package/admin/src/components/InputJSON/index.js +184 -0
- package/admin/src/components/InputJSON/jsonlint.js +424 -0
- package/admin/src/components/InputJSONWithErrors/Wrapper.js +32 -0
- package/admin/src/components/InputJSONWithErrors/index.js +168 -0
- package/admin/src/components/InputUID/InputUID.js +26 -0
- package/admin/src/components/InputUID/Options/Option.js +22 -0
- package/admin/src/components/InputUID/Options/OptionsTitle.js +12 -0
- package/admin/src/components/InputUID/Options/RightOptionLabel.js +10 -0
- package/admin/src/components/InputUID/Options/index.js +34 -0
- package/admin/src/components/InputUID/Options/wrapper.js +13 -0
- package/admin/src/components/InputUID/RegenerateButton.js +18 -0
- package/admin/src/components/InputUID/RightContent.js +14 -0
- package/admin/src/components/InputUID/RightContentLabel.js +10 -0
- package/admin/src/components/InputUID/RightLabel.js +42 -0
- package/admin/src/components/InputUID/SubLabel.js +9 -0
- package/admin/src/components/InputUID/Wrapper.js +8 -0
- package/admin/src/components/InputUID/index.js +325 -0
- package/admin/src/components/InputUID/regex.js +3 -0
- package/admin/src/components/Inputs/index.js +283 -0
- package/admin/src/components/Inputs/utils/VALIDATIONS_TO_OMIT.js +12 -0
- package/admin/src/components/Inputs/utils/connect.js +12 -0
- package/admin/src/components/Inputs/utils/generateOptions.js +19 -0
- package/admin/src/components/Inputs/utils/getInputType.js +44 -0
- package/admin/src/components/Inputs/utils/getStep.js +15 -0
- package/admin/src/components/Inputs/utils/index.js +6 -0
- package/admin/src/components/Inputs/utils/select.js +38 -0
- package/admin/src/components/LayoutTitle/index.js +19 -0
- package/admin/src/components/MediaPreviewList/StyledMediaPreviewList.js +171 -0
- package/admin/src/components/MediaPreviewList/index.js +110 -0
- package/admin/src/components/NonRepeatableComponent/index.js +73 -0
- package/admin/src/components/NonRepeatableWrapper/index.js +73 -0
- package/admin/src/components/PlusButton/index.js +52 -0
- package/admin/src/components/PopupForm/index.js +93 -0
- package/admin/src/components/PreviewCarret/components.js +27 -0
- package/admin/src/components/PreviewCarret/index.js +22 -0
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +133 -0
- package/admin/src/components/PreviewWysiwyg/index.js +34 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +72 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +16 -0
- package/admin/src/components/RelationPreviewList/CountWrapper.js +7 -0
- package/admin/src/components/RelationPreviewList/RelationPreviewTooltip.js +117 -0
- package/admin/src/components/RelationPreviewList/index.js +111 -0
- package/admin/src/components/RepeatableComponent/AddFieldButton.js +64 -0
- package/admin/src/components/RepeatableComponent/Banner.js +112 -0
- package/admin/src/components/RepeatableComponent/BannerWrapper.js +194 -0
- package/admin/src/components/RepeatableComponent/CarretTop.js +14 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/index.js +245 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/index.js +2 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/select.js +30 -0
- package/admin/src/components/RepeatableComponent/EmptyComponent.js +27 -0
- package/admin/src/components/RepeatableComponent/FormWrapper.js +27 -0
- package/admin/src/components/RepeatableComponent/index.js +187 -0
- package/admin/src/components/RepeatableComponent/reducer.js +73 -0
- package/admin/src/components/RepeatableComponent/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/utils/select.js +12 -0
- package/admin/src/components/Search/index.js +88 -0
- package/admin/src/components/SectionTitle/Title.js +11 -0
- package/admin/src/components/SectionTitle/index.js +29 -0
- package/admin/src/components/SelectMany/ListItem.js +107 -0
- package/admin/src/components/SelectMany/Relation.js +106 -0
- package/admin/src/components/SelectMany/components.js +153 -0
- package/admin/src/components/SelectMany/index.js +159 -0
- package/admin/src/components/SelectOne/SingleValue.js +58 -0
- package/admin/src/components/SelectOne/index.js +71 -0
- package/admin/src/components/SelectWrapper/ClearIndicator.js +15 -0
- package/admin/src/components/SelectWrapper/IndicatorSeparator.js +3 -0
- package/admin/src/components/SelectWrapper/Option.js +76 -0
- package/admin/src/components/SelectWrapper/components.js +14 -0
- package/admin/src/components/SelectWrapper/index.js +393 -0
- package/admin/src/components/SelectWrapper/utils/connect.js +12 -0
- package/admin/src/components/SelectWrapper/utils/index.js +3 -0
- package/admin/src/components/SelectWrapper/utils/select.js +45 -0
- package/admin/src/components/SelectWrapper/utils/styles.js +105 -0
- package/admin/src/components/Separator/index.js +9 -0
- package/admin/src/components/SettingFormWrapper/index.js +9 -0
- package/admin/src/components/SettingsViewWrapper/index.js +283 -0
- package/admin/src/components/SortWrapper/index.js +9 -0
- package/admin/src/components/SortableList/Item.js +126 -0
- package/admin/src/components/SortableList/index.js +60 -0
- package/admin/src/components/State/Wrapper.js +30 -0
- package/admin/src/components/State/index.js +26 -0
- package/admin/src/components/Truncate/index.js +5 -0
- package/admin/src/components/Truncated/index.js +10 -0
- package/admin/src/components/Wysiwyg/EditorWrapper.js +122 -0
- package/admin/src/components/Wysiwyg/MediaLib.js +71 -0
- package/admin/src/components/Wysiwyg/PreviewControlWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/SelectWrapper.js +24 -0
- package/admin/src/components/Wysiwyg/ToggleModeWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/constants.js +98 -0
- package/admin/src/components/Wysiwyg/customSelect.js +39 -0
- package/admin/src/components/Wysiwyg/helpers.js +116 -0
- package/admin/src/components/Wysiwyg/index.js +819 -0
- package/admin/src/components/Wysiwyg/previewControl.js +29 -0
- package/admin/src/components/Wysiwyg/toggleMode.js +44 -0
- package/admin/src/components/Wysiwyg/utils.js +70 -0
- package/admin/src/components/WysiwygBottomControls/components.js +44 -0
- package/admin/src/components/WysiwygBottomControls/index.js +33 -0
- package/admin/src/components/WysiwygDropUpload/Label.js +16 -0
- package/admin/src/components/WysiwygDropUpload/index.js +18 -0
- package/admin/src/components/WysiwygEditor/index.js +26 -0
- package/admin/src/components/WysiwygInlineControls/Button.js +77 -0
- package/admin/src/components/WysiwygInlineControls/StyledButton.js +54 -0
- package/admin/src/components/WysiwygInlineControls/Wrapper.js +25 -0
- package/admin/src/components/WysiwygInlineControls/index.js +66 -0
- package/admin/src/components/WysiwygWithErrors/Wrapper.js +38 -0
- package/admin/src/components/WysiwygWithErrors/index.js +158 -0
- package/admin/src/containers/CollectionTypeFormWrapper/index.js +376 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/CollectionTypeRecursivePath/index.js +125 -0
- package/admin/src/containers/ComponentSetttingsView/index.js +55 -0
- package/admin/src/containers/EditSettingsView/index.js +408 -0
- package/admin/src/containers/EditSettingsView/init.js +18 -0
- package/admin/src/containers/EditSettingsView/reducer.js +126 -0
- package/admin/src/containers/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +26 -0
- package/admin/src/containers/EditSettingsView/utils/getInputProps.js +30 -0
- package/admin/src/containers/EditSettingsView/utils/index.js +2 -0
- package/admin/src/containers/EditSettingsView/utils/layout.js +98 -0
- package/admin/src/containers/EditView/DeleteLink/index.js +94 -0
- package/admin/src/containers/EditView/DeleteLink/utils/connect.js +12 -0
- package/admin/src/containers/EditView/DeleteLink/utils/index.js +2 -0
- package/admin/src/containers/EditView/DeleteLink/utils/select.js +21 -0
- package/admin/src/containers/EditView/Header/index.js +258 -0
- package/admin/src/containers/EditView/Header/utils/connect.js +12 -0
- package/admin/src/containers/EditView/Header/utils/getDraftRelations.js +62 -0
- package/admin/src/containers/EditView/Header/utils/index.js +3 -0
- package/admin/src/containers/EditView/Header/utils/select.js +31 -0
- package/admin/src/containers/EditView/InformationCard.js +100 -0
- package/admin/src/containers/EditView/components.js +74 -0
- package/admin/src/containers/EditView/index.js +297 -0
- package/admin/src/containers/EditView/utils/createAttributesLayout.js +39 -0
- package/admin/src/containers/EditView/utils/getFieldsActionMatchingPermissions.js +23 -0
- package/admin/src/containers/EditView/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/index.js +519 -0
- package/admin/src/containers/EditViewDataManagerProvider/reducer.js +218 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/cleanData.js +88 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/getYupInnerErrors.js +17 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/schema.js +368 -0
- package/admin/src/containers/EditViewLayoutManager/Permissions.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/actions.js +9 -0
- package/admin/src/containers/EditViewLayoutManager/constants.js +2 -0
- package/admin/src/containers/EditViewLayoutManager/index.js +44 -0
- package/admin/src/containers/EditViewLayoutManager/reducer.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/selectors.js +5 -0
- package/admin/src/containers/LayoutDndProvider/index.js +75 -0
- package/admin/src/containers/ListSettingsView/DragWrapper.js +21 -0
- package/admin/src/containers/ListSettingsView/DropdownButton.js +8 -0
- package/admin/src/containers/ListSettingsView/Label.js +91 -0
- package/admin/src/containers/ListSettingsView/MenuDropdown.js +41 -0
- package/admin/src/containers/ListSettingsView/Toggle.js +51 -0
- package/admin/src/containers/ListSettingsView/forms.json +64 -0
- package/admin/src/containers/ListSettingsView/index.js +298 -0
- package/admin/src/containers/ListSettingsView/init.js +11 -0
- package/admin/src/containers/ListSettingsView/reducer.js +77 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/StyledLink.js +28 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/Wrapper.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/index.js +29 -0
- package/admin/src/containers/ListView/FieldPicker/Field/Wrapper.js +15 -0
- package/admin/src/containers/ListView/FieldPicker/Field/index.js +24 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/Wrapper.js +18 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/index.js +27 -0
- package/admin/src/containers/ListView/FieldPicker/Header/Reset.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/Header/index.js +42 -0
- package/admin/src/containers/ListView/FieldPicker/Wrapper.js +9 -0
- package/admin/src/containers/ListView/FieldPicker/index.js +46 -0
- package/admin/src/containers/ListView/Filter.js +83 -0
- package/admin/src/containers/ListView/Footer.js +60 -0
- package/admin/src/containers/ListView/actions.js +91 -0
- package/admin/src/containers/ListView/components.js +138 -0
- package/admin/src/containers/ListView/constants.js +16 -0
- package/admin/src/containers/ListView/index.js +573 -0
- package/admin/src/containers/ListView/reducer.js +182 -0
- package/admin/src/containers/ListView/selectors.js +24 -0
- package/admin/src/containers/ListView/utils/buildQueryString.js +26 -0
- package/admin/src/containers/ListView/utils/createPluginsFilter.js +13 -0
- package/admin/src/containers/ListView/utils/getAllAllowedHeaders.js +17 -0
- package/admin/src/containers/ListView/utils/getFirstSortableHeader.js +14 -0
- package/admin/src/containers/ListView/utils/index.js +3 -0
- package/admin/src/containers/ListViewLayoutManager/Permissions.js +29 -0
- package/admin/src/containers/ListViewLayoutManager/index.js +60 -0
- package/admin/src/containers/ListViewProvider/index.js +16 -0
- package/admin/src/containers/Main/actions.js +13 -0
- package/admin/src/containers/Main/constants.js +3 -0
- package/admin/src/containers/Main/index.js +100 -0
- package/admin/src/containers/Main/reducer.js +37 -0
- package/admin/src/containers/Main/selectors.js +20 -0
- package/admin/src/containers/RBACManager/actions.js +14 -0
- package/admin/src/containers/RBACManager/constants.js +2 -0
- package/admin/src/containers/RBACManager/reducer.js +32 -0
- package/admin/src/containers/RBACManager/useSyncRbac.js +28 -0
- package/admin/src/containers/SingleTypeFormWrapper/index.js +317 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/SingleTypeRecursivePath/index.js +84 -0
- package/admin/src/containers/WysiwygProvider/index.js +16 -0
- package/admin/src/contexts/ContentTypeLayout.js +5 -0
- package/admin/src/contexts/LayoutDnd.js +5 -0
- package/admin/src/contexts/ListView.js +5 -0
- package/admin/src/contexts/Wysiwyg.js +5 -0
- package/admin/src/contexts/index.js +4 -0
- package/admin/src/hooks/index.js +6 -0
- package/admin/src/hooks/useContentTypeLayout/index.js +19 -0
- package/admin/src/hooks/useFetchContentTypeLayout/index.js +83 -0
- package/admin/src/hooks/useFetchContentTypeLayout/reducer.js +56 -0
- package/admin/src/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +235 -0
- package/admin/src/hooks/useFindRedirectionLink/index.js +14 -0
- package/admin/src/hooks/useFindRedirectionLink/selectors.js +7 -0
- package/admin/src/hooks/useFindRedirectionLink/utils/getRedirectionLink.js +45 -0
- package/admin/src/hooks/useLayoutDnd.js +6 -0
- package/admin/src/hooks/useListView.js +6 -0
- package/admin/src/hooks/useWysiwyg.js +6 -0
- package/admin/src/icons/Bold/index.js +22 -0
- package/admin/src/icons/Code/index.js +13 -0
- package/admin/src/icons/Cross/index.js +33 -0
- package/admin/src/icons/Italic/index.js +23 -0
- package/admin/src/icons/Link/index.js +21 -0
- package/admin/src/icons/Media/index.js +14 -0
- package/admin/src/icons/Na/index.js +58 -0
- package/admin/src/icons/Ol/index.js +13 -0
- package/admin/src/icons/Quote/index.js +13 -0
- package/admin/src/icons/Striked/index.js +24 -0
- package/admin/src/icons/Ul/index.js +15 -0
- package/admin/src/icons/Underline/index.js +22 -0
- package/admin/src/index.js +52 -0
- package/admin/src/lifecycles.js +19 -0
- package/admin/src/permissions.js +27 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/reducers.js +16 -0
- package/admin/src/selectors.js +6 -0
- package/admin/src/sharedReducers/crudReducer/actions.js +44 -0
- package/admin/src/sharedReducers/crudReducer/constants.js +7 -0
- package/admin/src/sharedReducers/crudReducer/reducer.js +75 -0
- package/admin/src/sharedReducers/crudReducer/selectors.js +5 -0
- package/admin/src/testUtils/data.js +305 -0
- package/admin/src/testUtils/index.js +4 -0
- package/admin/src/translations/ar.json +94 -0
- package/admin/src/translations/cs.json +130 -0
- package/admin/src/translations/de.json +177 -0
- package/admin/src/translations/dk.json +180 -0
- package/admin/src/translations/en.json +177 -0
- package/admin/src/translations/es.json +177 -0
- package/admin/src/translations/fr.json +162 -0
- package/admin/src/translations/id.json +175 -0
- package/admin/src/translations/index.js +53 -0
- package/admin/src/translations/it.json +177 -0
- package/admin/src/translations/ja.json +94 -0
- package/admin/src/translations/ko.json +110 -0
- package/admin/src/translations/ms.json +148 -0
- package/admin/src/translations/nl.json +94 -0
- package/admin/src/translations/pl.json +142 -0
- package/admin/src/translations/pt-BR.json +94 -0
- package/admin/src/translations/pt.json +94 -0
- package/admin/src/translations/ru.json +177 -0
- package/admin/src/translations/sk.json +172 -0
- package/admin/src/translations/th.json +155 -0
- package/admin/src/translations/tr.json +177 -0
- package/admin/src/translations/uk.json +148 -0
- package/admin/src/translations/vi.json +110 -0
- package/admin/src/translations/zh-Hans.json +177 -0
- package/admin/src/translations/zh.json +94 -0
- package/admin/src/utils/ItemTypes.js +7 -0
- package/admin/src/utils/checkIfAttributeIsDisplayable.js +13 -0
- package/admin/src/utils/createDefaultForm.js +50 -0
- package/admin/src/utils/dateFormats.js +18 -0
- package/admin/src/utils/formatFiltersFromQuery.js +55 -0
- package/admin/src/utils/formatFiltersToQuery.js +27 -0
- package/admin/src/utils/formatLayoutToApi.js +44 -0
- package/admin/src/utils/generatePermissionsObject.js +20 -0
- package/admin/src/utils/getComponents.js +50 -0
- package/admin/src/utils/getDisplayedValue.js +61 -0
- package/admin/src/utils/getFieldName.js +6 -0
- package/admin/src/utils/getMaxTempKey.js +12 -0
- package/admin/src/utils/getRequestUrl.js +5 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/index.js +17 -0
- package/admin/src/utils/mergeMetasWithSchema.js +20 -0
- package/admin/src/utils/removeKeyInObject.js +45 -0
- package/admin/src/utils/removePasswordFieldsFromData.js +54 -0
- package/config/admin.json +5 -0
- package/config/functions/bootstrap.js +9 -0
- package/config/policies/has-draft-and-publish.js +19 -0
- package/config/policies/hasPermissions.js +34 -0
- package/config/policies/routing.js +27 -0
- package/config/routes.json +275 -0
- package/controllers/collection-types.js +282 -0
- package/controllers/components.js +66 -0
- package/controllers/content-types.js +112 -0
- package/controllers/relations.js +63 -0
- package/controllers/single-types.js +170 -0
- package/controllers/uid.js +41 -0
- package/controllers/validation/index.js +104 -0
- package/controllers/validation/model-configuration.js +114 -0
- package/oas.yml +757 -0
- package/package.json +77 -0
- package/services/components.js +92 -0
- package/services/configuration.js +79 -0
- package/services/content-types.js +73 -0
- package/services/data-mapper.js +98 -0
- package/services/entity-manager.js +140 -0
- package/services/metrics.js +34 -0
- package/services/permission-checker.js +69 -0
- package/services/permission.js +95 -0
- package/services/uid.js +63 -0
- package/services/utils/configuration/attributes.js +175 -0
- package/services/utils/configuration/index.js +43 -0
- package/services/utils/configuration/layouts.js +185 -0
- package/services/utils/configuration/metadatas.js +142 -0
- package/services/utils/configuration/settings.js +52 -0
- package/services/utils/store.js +93 -0
- package/utils/index.js +16 -0
- package/utils/pick-writable-attributes.js +6 -0
- package/utils/wrap-bad-request.js +15 -0
- package/validation/policies/hasPermissions.js +17 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { has, pipe, prop, pick } = require('lodash/fp');
|
|
4
|
+
const { MANY_RELATIONS } = require('@akemona-org/strapi-utils').relations.constants;
|
|
5
|
+
const { setCreatorFields } = require('@akemona-org/strapi-utils');
|
|
6
|
+
|
|
7
|
+
const { getService, wrapBadRequest, pickWritableAttributes } = require('../utils');
|
|
8
|
+
const { validateBulkDeleteInput, validatePagination } = require('./validation');
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
async find(ctx) {
|
|
12
|
+
const { userAbility } = ctx.state;
|
|
13
|
+
const { model } = ctx.params;
|
|
14
|
+
const { query } = ctx.request;
|
|
15
|
+
|
|
16
|
+
const entityManager = getService('entity-manager');
|
|
17
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
18
|
+
|
|
19
|
+
if (permissionChecker.cannot.read()) {
|
|
20
|
+
return ctx.forbidden();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const method = has('_q', query) ? 'searchWithRelationCounts' : 'findWithRelationCounts';
|
|
24
|
+
|
|
25
|
+
const permissionQuery = permissionChecker.buildReadQuery(query);
|
|
26
|
+
|
|
27
|
+
const { results, pagination } = await entityManager[method](permissionQuery, model);
|
|
28
|
+
|
|
29
|
+
ctx.body = {
|
|
30
|
+
results: results.map((entity) => permissionChecker.sanitizeOutput(entity)),
|
|
31
|
+
pagination,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
async findOne(ctx) {
|
|
36
|
+
const { userAbility } = ctx.state;
|
|
37
|
+
const { model, id } = ctx.params;
|
|
38
|
+
|
|
39
|
+
const entityManager = getService('entity-manager');
|
|
40
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
41
|
+
|
|
42
|
+
if (permissionChecker.cannot.read()) {
|
|
43
|
+
return ctx.forbidden();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const entity = await entityManager.findOneWithCreatorRoles(id, model);
|
|
47
|
+
|
|
48
|
+
if (!entity) {
|
|
49
|
+
return ctx.notFound();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (permissionChecker.cannot.read(entity)) {
|
|
53
|
+
return ctx.forbidden();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ctx.body = permissionChecker.sanitizeOutput(entity);
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
async create(ctx) {
|
|
60
|
+
const { userAbility, user } = ctx.state;
|
|
61
|
+
const { model } = ctx.params;
|
|
62
|
+
const { body } = ctx.request;
|
|
63
|
+
|
|
64
|
+
const entityManager = getService('entity-manager');
|
|
65
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
66
|
+
|
|
67
|
+
if (permissionChecker.cannot.create()) {
|
|
68
|
+
return ctx.forbidden();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const pickWritables = pickWritableAttributes({ model });
|
|
72
|
+
const pickPermittedFields = permissionChecker.sanitizeCreateInput;
|
|
73
|
+
const setCreator = setCreatorFields({ user });
|
|
74
|
+
|
|
75
|
+
const sanitizeFn = pipe([pickWritables, pickPermittedFields, setCreator]);
|
|
76
|
+
|
|
77
|
+
await wrapBadRequest(async () => {
|
|
78
|
+
const entity = await entityManager.create(sanitizeFn(body), model);
|
|
79
|
+
ctx.body = permissionChecker.sanitizeOutput(entity);
|
|
80
|
+
|
|
81
|
+
// await strapi.telemetry.send('didCreateFirstContentTypeEntry', { model });
|
|
82
|
+
})();
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
async update(ctx) {
|
|
86
|
+
const { userAbility, user } = ctx.state;
|
|
87
|
+
const { id, model } = ctx.params;
|
|
88
|
+
const { body } = ctx.request;
|
|
89
|
+
|
|
90
|
+
const entityManager = getService('entity-manager');
|
|
91
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
92
|
+
|
|
93
|
+
if (permissionChecker.cannot.update()) {
|
|
94
|
+
return ctx.forbidden();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const entity = await entityManager.findOneWithCreatorRoles(id, model);
|
|
98
|
+
|
|
99
|
+
if (!entity) {
|
|
100
|
+
return ctx.notFound();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (permissionChecker.cannot.update(entity)) {
|
|
104
|
+
return ctx.forbidden();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const pickWritables = pickWritableAttributes({ model });
|
|
108
|
+
const pickPermittedFields = permissionChecker.sanitizeUpdateInput(entity);
|
|
109
|
+
const setCreator = setCreatorFields({ user, isEdition: true });
|
|
110
|
+
|
|
111
|
+
const sanitizeFn = pipe([pickWritables, pickPermittedFields, setCreator]);
|
|
112
|
+
|
|
113
|
+
await wrapBadRequest(async () => {
|
|
114
|
+
const updatedEntity = await entityManager.update(entity, sanitizeFn(body), model);
|
|
115
|
+
|
|
116
|
+
ctx.body = permissionChecker.sanitizeOutput(updatedEntity);
|
|
117
|
+
})();
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
async delete(ctx) {
|
|
121
|
+
const { userAbility } = ctx.state;
|
|
122
|
+
const { id, model } = ctx.params;
|
|
123
|
+
|
|
124
|
+
const entityManager = getService('entity-manager');
|
|
125
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
126
|
+
|
|
127
|
+
if (permissionChecker.cannot.delete()) {
|
|
128
|
+
return ctx.forbidden();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const entity = await entityManager.findOneWithCreatorRoles(id, model);
|
|
132
|
+
|
|
133
|
+
if (!entity) {
|
|
134
|
+
return ctx.notFound();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (permissionChecker.cannot.delete(entity)) {
|
|
138
|
+
return ctx.forbidden();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const result = await entityManager.delete(entity, model);
|
|
142
|
+
|
|
143
|
+
ctx.body = permissionChecker.sanitizeOutput(result);
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
async publish(ctx) {
|
|
147
|
+
const { userAbility } = ctx.state;
|
|
148
|
+
const { id, model } = ctx.params;
|
|
149
|
+
|
|
150
|
+
const entityManager = getService('entity-manager');
|
|
151
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
152
|
+
|
|
153
|
+
if (permissionChecker.cannot.publish()) {
|
|
154
|
+
return ctx.forbidden();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const entity = await entityManager.findOneWithCreatorRoles(id, model);
|
|
158
|
+
|
|
159
|
+
if (!entity) {
|
|
160
|
+
return ctx.notFound();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (permissionChecker.cannot.publish(entity)) {
|
|
164
|
+
return ctx.forbidden();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const result = await entityManager.publish(entity, model);
|
|
168
|
+
|
|
169
|
+
ctx.body = permissionChecker.sanitizeOutput(result);
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
async unpublish(ctx) {
|
|
173
|
+
const { userAbility } = ctx.state;
|
|
174
|
+
const { id, model } = ctx.params;
|
|
175
|
+
|
|
176
|
+
const entityManager = getService('entity-manager');
|
|
177
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
178
|
+
|
|
179
|
+
if (permissionChecker.cannot.unpublish()) {
|
|
180
|
+
return ctx.forbidden();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const entity = await entityManager.findOneWithCreatorRoles(id, model);
|
|
184
|
+
|
|
185
|
+
if (!entity) {
|
|
186
|
+
return ctx.notFound();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (permissionChecker.cannot.unpublish(entity)) {
|
|
190
|
+
return ctx.forbidden();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const result = await entityManager.unpublish(entity, model);
|
|
194
|
+
|
|
195
|
+
ctx.body = permissionChecker.sanitizeOutput(result);
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
async bulkDelete(ctx) {
|
|
199
|
+
const { userAbility } = ctx.state;
|
|
200
|
+
const { model } = ctx.params;
|
|
201
|
+
const { query, body } = ctx.request;
|
|
202
|
+
const { ids } = body;
|
|
203
|
+
|
|
204
|
+
await validateBulkDeleteInput(body);
|
|
205
|
+
|
|
206
|
+
const entityManager = getService('entity-manager');
|
|
207
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
208
|
+
|
|
209
|
+
if (permissionChecker.cannot.delete()) {
|
|
210
|
+
return ctx.forbidden();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const permissionQuery = permissionChecker.buildDeleteQuery(query);
|
|
214
|
+
|
|
215
|
+
const idsWhereClause = { [`id_in`]: ids };
|
|
216
|
+
const params = {
|
|
217
|
+
...permissionQuery,
|
|
218
|
+
_where: [idsWhereClause].concat(permissionQuery._where || {}),
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const results = await entityManager.findAndDelete(params, model);
|
|
222
|
+
|
|
223
|
+
ctx.body = results.map((result) => permissionChecker.sanitizeOutput(result));
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
async previewManyRelations(ctx) {
|
|
227
|
+
const { userAbility } = ctx.state;
|
|
228
|
+
const { model, id, targetField } = ctx.params;
|
|
229
|
+
const { pageSize = 10, page = 1 } = ctx.request.query;
|
|
230
|
+
|
|
231
|
+
validatePagination({ page, pageSize });
|
|
232
|
+
|
|
233
|
+
const contentTypeService = getService('content-types');
|
|
234
|
+
const entityManager = getService('entity-manager');
|
|
235
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
236
|
+
|
|
237
|
+
if (permissionChecker.cannot.read()) {
|
|
238
|
+
return ctx.forbidden();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const modelDef = strapi.getModel(model);
|
|
242
|
+
const assoc = modelDef.associations.find((a) => a.alias === targetField);
|
|
243
|
+
|
|
244
|
+
if (!assoc || !MANY_RELATIONS.includes(assoc.nature)) {
|
|
245
|
+
return ctx.badRequest('Invalid target field');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const entity = await entityManager.findOneWithCreatorRoles(id, model);
|
|
249
|
+
|
|
250
|
+
if (!entity) {
|
|
251
|
+
return ctx.notFound();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (permissionChecker.cannot.read(entity, targetField)) {
|
|
255
|
+
return ctx.forbidden();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let relationList;
|
|
259
|
+
if (assoc.nature === 'manyWay') {
|
|
260
|
+
const populatedEntity = await entityManager.findOne(id, model, [targetField]);
|
|
261
|
+
const relationsListIds = populatedEntity[targetField].map(prop('id'));
|
|
262
|
+
relationList = await entityManager.findPage(
|
|
263
|
+
{ page, pageSize, id_in: relationsListIds },
|
|
264
|
+
assoc.targetUid
|
|
265
|
+
);
|
|
266
|
+
} else {
|
|
267
|
+
const assocModel = strapi.db.getModelByAssoc(assoc);
|
|
268
|
+
relationList = await entityManager.findPage(
|
|
269
|
+
{ page, pageSize, [`${assoc.via}.${assocModel.primaryKey}`]: entity.id },
|
|
270
|
+
assoc.targetUid
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const config = await contentTypeService.findConfiguration({ uid: model });
|
|
275
|
+
const mainField = prop(['metadatas', assoc.alias, 'edit', 'mainField'], config);
|
|
276
|
+
|
|
277
|
+
ctx.body = {
|
|
278
|
+
pagination: relationList.pagination,
|
|
279
|
+
results: relationList.results.map(pick(['id', modelDef.primaryKey, mainField])),
|
|
280
|
+
};
|
|
281
|
+
},
|
|
282
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { getService } = require('../utils');
|
|
4
|
+
const { createModelConfigurationSchema } = require('./validation');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
findComponents(ctx) {
|
|
8
|
+
const components = getService('components').findAllComponents();
|
|
9
|
+
const { toDto } = getService('data-mapper');
|
|
10
|
+
|
|
11
|
+
ctx.body = { data: components.map(toDto) };
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
async findComponentConfiguration(ctx) {
|
|
15
|
+
const { uid } = ctx.params;
|
|
16
|
+
|
|
17
|
+
const componentService = getService('components');
|
|
18
|
+
|
|
19
|
+
const component = componentService.findComponent(uid);
|
|
20
|
+
|
|
21
|
+
if (!component) {
|
|
22
|
+
return ctx.notFound('component.notFound');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const configuration = await componentService.findConfiguration(component);
|
|
26
|
+
const componentsConfigurations = await componentService.findComponentsConfigurations(component);
|
|
27
|
+
|
|
28
|
+
ctx.body = {
|
|
29
|
+
data: {
|
|
30
|
+
component: configuration,
|
|
31
|
+
components: componentsConfigurations,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
async updateComponentConfiguration(ctx) {
|
|
37
|
+
const { uid } = ctx.params;
|
|
38
|
+
const { body } = ctx.request;
|
|
39
|
+
|
|
40
|
+
const componentService = getService('components');
|
|
41
|
+
|
|
42
|
+
const component = componentService.findComponent(uid);
|
|
43
|
+
|
|
44
|
+
if (!component) {
|
|
45
|
+
return ctx.notFound('component.notFound');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let input;
|
|
49
|
+
try {
|
|
50
|
+
input = await createModelConfigurationSchema(component).validate(body, {
|
|
51
|
+
abortEarly: false,
|
|
52
|
+
stripUnknown: true,
|
|
53
|
+
strict: true,
|
|
54
|
+
});
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return ctx.badRequest(null, {
|
|
57
|
+
name: 'validationError',
|
|
58
|
+
errors: error.errors,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const newConfiguration = await componentService.updateConfiguration(component, input);
|
|
63
|
+
|
|
64
|
+
ctx.body = { data: newConfiguration };
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { has, assoc, mapValues, prop } = require('lodash/fp');
|
|
4
|
+
const { getService } = require('../utils');
|
|
5
|
+
const { createModelConfigurationSchema, validateKind } = require('./validation');
|
|
6
|
+
|
|
7
|
+
const hasEditMainField = has('edit.mainField');
|
|
8
|
+
const getEditMainField = prop('edit.mainField');
|
|
9
|
+
const assocListMainField = assoc('list.mainField');
|
|
10
|
+
|
|
11
|
+
const assocMainField = metadata =>
|
|
12
|
+
hasEditMainField(metadata) ? assocListMainField(getEditMainField(metadata), metadata) : metadata;
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
async findContentTypes(ctx) {
|
|
16
|
+
const { kind } = ctx.query;
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await validateKind(kind);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return ctx.send({ error }, 400);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const contentTypes = getService('content-types').findContentTypesByKind(kind);
|
|
25
|
+
const { toDto } = getService('data-mapper');
|
|
26
|
+
|
|
27
|
+
ctx.body = { data: contentTypes.map(toDto) };
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
async findContentTypesSettings(ctx) {
|
|
31
|
+
const { findAllContentTypes, findConfiguration } = getService('content-types');
|
|
32
|
+
|
|
33
|
+
const contentTypes = await findAllContentTypes();
|
|
34
|
+
const configurations = await Promise.all(
|
|
35
|
+
contentTypes.map(async contentType => {
|
|
36
|
+
const { uid, settings } = await findConfiguration(contentType);
|
|
37
|
+
return { uid, settings };
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
ctx.body = {
|
|
42
|
+
data: configurations,
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
async findContentTypeConfiguration(ctx) {
|
|
47
|
+
const { uid } = ctx.params;
|
|
48
|
+
|
|
49
|
+
const contentTypeService = getService('content-types');
|
|
50
|
+
|
|
51
|
+
const contentType = await contentTypeService.findContentType(uid);
|
|
52
|
+
|
|
53
|
+
if (!contentType) {
|
|
54
|
+
return ctx.notFound('contentType.notFound');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const configuration = await contentTypeService.findConfiguration(contentType);
|
|
58
|
+
|
|
59
|
+
const confWithUpdatedMetadata = {
|
|
60
|
+
...configuration,
|
|
61
|
+
metadatas: mapValues(assocMainField, configuration.metadatas),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const components = await contentTypeService.findComponentsConfigurations(contentType);
|
|
65
|
+
|
|
66
|
+
ctx.body = {
|
|
67
|
+
data: {
|
|
68
|
+
contentType: confWithUpdatedMetadata,
|
|
69
|
+
components,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
async updateContentTypeConfiguration(ctx) {
|
|
75
|
+
const { userAbility } = ctx.state;
|
|
76
|
+
const { uid } = ctx.params;
|
|
77
|
+
const { body } = ctx.request;
|
|
78
|
+
|
|
79
|
+
const contentTypeService = getService('content-types');
|
|
80
|
+
const metricsService = getService('metrics');
|
|
81
|
+
|
|
82
|
+
const contentType = await contentTypeService.findContentType(uid);
|
|
83
|
+
|
|
84
|
+
if (!contentType) {
|
|
85
|
+
return ctx.notFound('contentType.notFound');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!getService('permission').canConfigureContentType({ userAbility, contentType })) {
|
|
89
|
+
return ctx.forbidden();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let input;
|
|
93
|
+
try {
|
|
94
|
+
input = await createModelConfigurationSchema(contentType).validate(body, {
|
|
95
|
+
abortEarly: false,
|
|
96
|
+
stripUnknown: true,
|
|
97
|
+
strict: true,
|
|
98
|
+
});
|
|
99
|
+
} catch (error) {
|
|
100
|
+
return ctx.badRequest(null, {
|
|
101
|
+
name: 'validationError',
|
|
102
|
+
errors: error.errors,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const newConfiguration = await contentTypeService.updateConfiguration(contentType, input);
|
|
107
|
+
|
|
108
|
+
await metricsService.sendDidConfigureListView(contentType, newConfiguration);
|
|
109
|
+
|
|
110
|
+
ctx.body = { data: newConfiguration };
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { has, prop, pick, concat } = require('lodash/fp');
|
|
4
|
+
const { PUBLISHED_AT_ATTRIBUTE } = require('@akemona-org/strapi-utils').contentTypes.constants;
|
|
5
|
+
|
|
6
|
+
const { getService } = require('../utils');
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
async find(ctx) {
|
|
10
|
+
const { model, targetField } = ctx.params;
|
|
11
|
+
const { _component, ...query } = ctx.request.query;
|
|
12
|
+
const { idsToOmit } = ctx.request.body;
|
|
13
|
+
|
|
14
|
+
if (!targetField) {
|
|
15
|
+
return ctx.badRequest();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const modelDef = _component ? strapi.db.getModel(_component) : strapi.db.getModel(model);
|
|
19
|
+
|
|
20
|
+
if (!modelDef) {
|
|
21
|
+
return ctx.notFound('model.notFound');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const attr = modelDef.attributes[targetField];
|
|
25
|
+
if (!attr) {
|
|
26
|
+
return ctx.badRequest('targetField.invalid');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const target = strapi.db.getModelByAssoc(attr);
|
|
30
|
+
|
|
31
|
+
if (!target) {
|
|
32
|
+
return ctx.notFound('target.notFound');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (idsToOmit && Array.isArray(idsToOmit)) {
|
|
36
|
+
query._where = query._where || {};
|
|
37
|
+
query._where.id_nin = concat(query._where.id_nin || [], idsToOmit);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const entityManager = getService('entity-manager');
|
|
41
|
+
|
|
42
|
+
let entities = [];
|
|
43
|
+
|
|
44
|
+
if (has('_q', ctx.request.query)) {
|
|
45
|
+
entities = await entityManager.search(query, target.uid);
|
|
46
|
+
} else {
|
|
47
|
+
entities = await entityManager.find(query, target.uid);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!entities) {
|
|
51
|
+
return ctx.notFound();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const modelConfig = _component
|
|
55
|
+
? await getService('components').findConfiguration(modelDef)
|
|
56
|
+
: await getService('content-types').findConfiguration(modelDef);
|
|
57
|
+
|
|
58
|
+
const field = prop(`metadatas.${targetField}.edit.mainField`, modelConfig) || 'id';
|
|
59
|
+
const pickFields = [field, 'id', target.primaryKey, PUBLISHED_AT_ATTRIBUTE];
|
|
60
|
+
|
|
61
|
+
ctx.body = entities.map(pick(pickFields));
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { pipe } = require('lodash/fp');
|
|
4
|
+
const { setCreatorFields } = require('@akemona-org/strapi-utils');
|
|
5
|
+
|
|
6
|
+
const { getService, wrapBadRequest, pickWritableAttributes } = require('../utils');
|
|
7
|
+
|
|
8
|
+
const findEntity = async (query, model) => {
|
|
9
|
+
const entityManager = getService('entity-manager');
|
|
10
|
+
const entity = await entityManager.find(query, model);
|
|
11
|
+
return entityManager.assocCreatorRoles(entity);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
async find(ctx) {
|
|
16
|
+
const { userAbility } = ctx.state;
|
|
17
|
+
const { model } = ctx.params;
|
|
18
|
+
const { query = {} } = ctx.request;
|
|
19
|
+
|
|
20
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
21
|
+
|
|
22
|
+
if (permissionChecker.cannot.read()) {
|
|
23
|
+
return ctx.forbidden();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const permissionQuery = permissionChecker.buildReadQuery(query);
|
|
27
|
+
|
|
28
|
+
const entity = await findEntity(permissionQuery, model);
|
|
29
|
+
|
|
30
|
+
// allow user with create permission to know a single type is not created
|
|
31
|
+
if (!entity) {
|
|
32
|
+
if (permissionChecker.cannot.create()) {
|
|
33
|
+
return ctx.forbidden();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return ctx.notFound();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (permissionChecker.cannot.read(entity)) {
|
|
40
|
+
return ctx.forbidden();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ctx.body = permissionChecker.sanitizeOutput(entity);
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
async createOrUpdate(ctx) {
|
|
47
|
+
const { user, userAbility } = ctx.state;
|
|
48
|
+
const { model } = ctx.params;
|
|
49
|
+
const { body, query } = ctx.request;
|
|
50
|
+
|
|
51
|
+
const entityManager = getService('entity-manager');
|
|
52
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
53
|
+
|
|
54
|
+
if (permissionChecker.cannot.create() && permissionChecker.cannot.update()) {
|
|
55
|
+
return ctx.forbidden();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const entity = await findEntity(query, model);
|
|
59
|
+
|
|
60
|
+
const pickWritables = pickWritableAttributes({ model });
|
|
61
|
+
|
|
62
|
+
const pickPermittedFields = entity
|
|
63
|
+
? permissionChecker.sanitizeUpdateInput(entity)
|
|
64
|
+
: permissionChecker.sanitizeCreateInput;
|
|
65
|
+
|
|
66
|
+
const setCreator = entity
|
|
67
|
+
? setCreatorFields({ user, isEdition: true })
|
|
68
|
+
: setCreatorFields({ user });
|
|
69
|
+
|
|
70
|
+
const sanitizeFn = pipe([pickWritables, pickPermittedFields, setCreator]);
|
|
71
|
+
|
|
72
|
+
await wrapBadRequest(async () => {
|
|
73
|
+
if (!entity) {
|
|
74
|
+
const newEntity = await entityManager.create(sanitizeFn(body), model, { params: query });
|
|
75
|
+
ctx.body = permissionChecker.sanitizeOutput(newEntity);
|
|
76
|
+
|
|
77
|
+
// await strapi.telemetry.send('didCreateFirstContentTypeEntry', { model });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (permissionChecker.cannot.update(entity)) {
|
|
82
|
+
return ctx.forbidden();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const updatedEntity = await entityManager.update(entity, sanitizeFn(body), model);
|
|
86
|
+
ctx.body = permissionChecker.sanitizeOutput(updatedEntity);
|
|
87
|
+
})();
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
async delete(ctx) {
|
|
91
|
+
const { userAbility } = ctx.state;
|
|
92
|
+
const { model } = ctx.params;
|
|
93
|
+
const { query = {} } = ctx.request;
|
|
94
|
+
|
|
95
|
+
const entityManager = getService('entity-manager');
|
|
96
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
97
|
+
|
|
98
|
+
if (permissionChecker.cannot.delete()) {
|
|
99
|
+
return ctx.forbidden();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const entity = await findEntity(query, model);
|
|
103
|
+
|
|
104
|
+
if (!entity) {
|
|
105
|
+
return ctx.notFound();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (permissionChecker.cannot.delete(entity)) {
|
|
109
|
+
return ctx.forbidden();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const deletedEntity = await entityManager.delete(entity, model);
|
|
113
|
+
|
|
114
|
+
ctx.body = permissionChecker.sanitizeOutput(deletedEntity);
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
async publish(ctx) {
|
|
118
|
+
const { userAbility } = ctx.state;
|
|
119
|
+
const { model } = ctx.params;
|
|
120
|
+
const { query = {} } = ctx.request;
|
|
121
|
+
|
|
122
|
+
const entityManager = getService('entity-manager');
|
|
123
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
124
|
+
|
|
125
|
+
if (permissionChecker.cannot.publish()) {
|
|
126
|
+
return ctx.forbidden();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const entity = await findEntity(query, model);
|
|
130
|
+
|
|
131
|
+
if (!entity) {
|
|
132
|
+
return ctx.notFound();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (permissionChecker.cannot.publish(entity)) {
|
|
136
|
+
return ctx.forbidden();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const publishedEntity = await entityManager.publish(entity, model);
|
|
140
|
+
|
|
141
|
+
ctx.body = permissionChecker.sanitizeOutput(publishedEntity);
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
async unpublish(ctx) {
|
|
145
|
+
const { userAbility } = ctx.state;
|
|
146
|
+
const { model } = ctx.params;
|
|
147
|
+
const { query = {} } = ctx.request;
|
|
148
|
+
|
|
149
|
+
const entityManager = getService('entity-manager');
|
|
150
|
+
const permissionChecker = getService('permission-checker').create({ userAbility, model });
|
|
151
|
+
|
|
152
|
+
if (permissionChecker.cannot.unpublish()) {
|
|
153
|
+
return ctx.forbidden();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const entity = await findEntity(query, model);
|
|
157
|
+
|
|
158
|
+
if (!entity) {
|
|
159
|
+
return ctx.notFound();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (permissionChecker.cannot.unpublish(entity)) {
|
|
163
|
+
return ctx.forbidden();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const unpublishedEntity = await entityManager.unpublish(entity, model);
|
|
167
|
+
|
|
168
|
+
ctx.body = permissionChecker.sanitizeOutput(unpublishedEntity);
|
|
169
|
+
},
|
|
170
|
+
};
|