@xleddyl/nuxt-cms 0.9.4 → 0.10.1
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 +1 -1
- package/dist/module.d.mts +20 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1037 -148
- package/dist/runtime/app/blocks/CmsBlocks.d.vue.ts +1 -1
- package/dist/runtime/app/blocks/CmsBlocks.vue +57 -9
- package/dist/runtime/app/blocks/CmsBlocks.vue.d.ts +1 -1
- package/dist/runtime/app/blocks/CmsField.d.ts +24 -0
- package/dist/runtime/app/blocks/CmsField.js +16 -0
- package/dist/runtime/app/blocks/node.d.ts +37 -0
- package/dist/runtime/app/blocks/node.js +17 -0
- package/dist/runtime/app/blocks/resolve.d.ts +18 -0
- package/dist/runtime/app/blocks/resolve.js +34 -0
- package/dist/runtime/app/components/cms/BlockPicker.d.vue.ts +22 -0
- package/dist/runtime/app/components/cms/BlockPicker.vue +87 -0
- package/dist/runtime/app/components/cms/BlockPicker.vue.d.ts +22 -0
- package/dist/runtime/app/components/cms/BlockPickerPopover.d.vue.ts +38 -0
- package/dist/runtime/app/components/cms/BlockPickerPopover.vue +44 -0
- package/dist/runtime/app/components/cms/BlockPickerPopover.vue.d.ts +38 -0
- package/dist/runtime/app/components/cms/BlockTree.d.vue.ts +29 -0
- package/dist/runtime/app/components/cms/BlockTree.vue +322 -0
- package/dist/runtime/app/components/cms/BlockTree.vue.d.ts +29 -0
- package/dist/runtime/app/components/cms/BlocksField.vue +569 -219
- package/dist/runtime/app/components/cms/BrandMark.vue +7 -13
- package/dist/runtime/app/components/cms/ConfirmGroups.vue +15 -13
- package/dist/runtime/app/components/cms/{BlockPalette.vue.d.ts → EditorHistory.d.vue.ts} +6 -5
- package/dist/runtime/app/components/cms/EditorHistory.vue +34 -0
- package/dist/runtime/app/components/cms/{BlockPalette.d.vue.ts → EditorHistory.vue.d.ts} +6 -5
- package/dist/runtime/app/components/cms/EntryDrawer.d.vue.ts +11 -5
- package/dist/runtime/app/components/cms/EntryDrawer.vue +183 -152
- package/dist/runtime/app/components/cms/EntryDrawer.vue.d.ts +11 -5
- package/dist/runtime/app/components/cms/EntryForm.d.vue.ts +16 -4
- package/dist/runtime/app/components/cms/EntryForm.vue +106 -147
- package/dist/runtime/app/components/cms/EntryForm.vue.d.ts +16 -4
- package/dist/runtime/app/components/cms/FieldInput.vue +10 -2
- package/dist/runtime/app/components/cms/FormSections.d.vue.ts +22 -0
- package/dist/runtime/app/components/cms/FormSections.vue +71 -0
- package/dist/runtime/app/components/cms/FormSections.vue.d.ts +22 -0
- package/dist/runtime/app/components/cms/ImportModal.vue +46 -58
- package/dist/runtime/app/components/cms/LinkField.d.vue.ts +16 -0
- package/dist/runtime/app/components/cms/LinkField.vue +250 -0
- package/dist/runtime/app/components/cms/LinkField.vue.d.ts +16 -0
- package/dist/runtime/app/components/cms/ListFilters.vue +10 -12
- package/dist/runtime/app/components/cms/LocaleSwitch.d.vue.ts +2 -1
- package/dist/runtime/app/components/cms/LocaleSwitch.vue +19 -11
- package/dist/runtime/app/components/cms/LocaleSwitch.vue.d.ts +2 -1
- package/dist/runtime/app/components/cms/MediaDetail.d.vue.ts +2 -0
- package/dist/runtime/app/components/cms/MediaDetail.vue +112 -83
- package/dist/runtime/app/components/cms/MediaDetail.vue.d.ts +2 -0
- package/dist/runtime/app/components/cms/MediaField.vue +35 -25
- package/dist/runtime/app/components/cms/MediaFolderPicker.vue +26 -71
- package/dist/runtime/app/components/cms/MediaGallery.d.vue.ts +1 -0
- package/dist/runtime/app/components/cms/MediaGallery.vue +442 -419
- package/dist/runtime/app/components/cms/MediaGallery.vue.d.ts +1 -0
- package/dist/runtime/app/components/cms/MediaThumb.vue +9 -25
- package/dist/runtime/app/components/cms/MediaUpload.vue +1 -1
- package/dist/runtime/app/components/cms/{BlockOutline.d.vue.ts → NestedBlockList.d.vue.ts} +5 -5
- package/dist/runtime/app/components/cms/NestedBlockList.vue +87 -0
- package/dist/runtime/app/components/cms/{BlockOutline.vue.d.ts → NestedBlockList.vue.d.ts} +5 -5
- package/dist/runtime/app/components/cms/PoweredBy.vue +12 -5
- package/dist/runtime/app/components/cms/PresetModal.d.vue.ts +18 -0
- package/dist/runtime/app/components/cms/PresetModal.vue +70 -0
- package/dist/runtime/app/components/cms/PresetModal.vue.d.ts +18 -0
- package/dist/runtime/app/components/cms/RelationField.vue +2 -8
- package/dist/runtime/app/components/cms/SettingsAccount.vue +60 -71
- package/dist/runtime/app/components/cms/SettingsColumns.vue +47 -69
- package/dist/runtime/app/components/cms/SettingsEmptyAdd.d.vue.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsEmptyAdd.vue +21 -0
- package/dist/runtime/app/components/cms/SettingsEmptyAdd.vue.d.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsEntries.d.vue.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsEntries.vue +50 -0
- package/dist/runtime/app/components/cms/SettingsEntries.vue.d.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsEntry.d.vue.ts +1 -10
- package/dist/runtime/app/components/cms/SettingsEntry.vue +11 -95
- package/dist/runtime/app/components/cms/SettingsEntry.vue.d.ts +1 -10
- package/dist/runtime/app/components/cms/SettingsEntryActions.d.vue.ts +7 -0
- package/dist/runtime/app/components/cms/SettingsEntryActions.vue +40 -0
- package/dist/runtime/app/components/cms/SettingsEntryActions.vue.d.ts +7 -0
- package/dist/runtime/app/components/cms/SettingsEntryTabs.d.vue.ts +7 -0
- package/dist/runtime/app/components/cms/SettingsEntryTabs.vue +21 -0
- package/dist/runtime/app/components/cms/SettingsEntryTabs.vue.d.ts +7 -0
- package/dist/runtime/app/components/cms/SettingsFormAction.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsFormAction.vue +17 -0
- package/dist/runtime/app/components/cms/SettingsFormAction.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsLayout.vue +18 -14
- package/dist/runtime/app/components/cms/SettingsPresetForm.d.vue.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsPresetForm.vue +60 -0
- package/dist/runtime/app/components/cms/SettingsPresetForm.vue.d.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsPresets.d.vue.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsPresets.vue +65 -0
- package/dist/runtime/app/components/cms/SettingsPresets.vue.d.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsRecordActions.d.vue.ts +32 -0
- package/dist/runtime/app/components/cms/SettingsRecordActions.vue +45 -0
- package/dist/runtime/app/components/cms/SettingsRecordActions.vue.d.ts +32 -0
- package/dist/runtime/app/components/cms/SettingsRedirectActions.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsRedirectActions.vue +59 -0
- package/dist/runtime/app/components/cms/SettingsRedirectActions.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsRedirectForm.d.vue.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsRedirectForm.vue +77 -0
- package/dist/runtime/app/components/cms/SettingsRedirectForm.vue.d.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsRedirects.d.vue.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsRedirects.vue +117 -0
- package/dist/runtime/app/components/cms/SettingsRedirects.vue.d.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsSecretCard.d.vue.ts +17 -0
- package/dist/runtime/app/components/cms/SettingsSecretCard.vue +43 -0
- package/dist/runtime/app/components/cms/SettingsSecretCard.vue.d.ts +17 -0
- package/dist/runtime/app/components/cms/SettingsSite.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsSite.vue +140 -0
- package/dist/runtime/app/components/cms/SettingsSite.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsUserCreate.d.vue.ts +8 -0
- package/dist/runtime/app/components/cms/SettingsUserCreate.vue +82 -0
- package/dist/runtime/app/components/cms/SettingsUserCreate.vue.d.ts +8 -0
- package/dist/runtime/app/components/cms/SettingsUserDetail.d.vue.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsUserDetail.vue +179 -0
- package/dist/runtime/app/components/cms/SettingsUserDetail.vue.d.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsUsers.d.vue.ts +9 -6
- package/dist/runtime/app/components/cms/SettingsUsers.vue +88 -234
- package/dist/runtime/app/components/cms/SettingsUsers.vue.d.ts +9 -6
- package/dist/runtime/app/components/cms/SharePreview.d.vue.ts +18 -0
- package/dist/runtime/app/components/cms/SharePreview.vue +219 -0
- package/dist/runtime/app/components/cms/SharePreview.vue.d.ts +18 -0
- package/dist/runtime/app/components/cms/SlugField.vue +5 -3
- package/dist/runtime/app/components/cms/StatusBadge.vue +8 -8
- package/dist/runtime/app/components/cms/TranslationBadges.d.vue.ts +7 -0
- package/dist/runtime/app/components/cms/TranslationBadges.vue +44 -0
- package/dist/runtime/app/components/cms/TranslationBadges.vue.d.ts +7 -0
- package/dist/runtime/app/components/cms/TranslationMenu.d.vue.ts +17 -0
- package/dist/runtime/app/components/cms/TranslationMenu.vue +28 -0
- package/dist/runtime/app/components/cms/TranslationMenu.vue.d.ts +17 -0
- package/dist/runtime/app/components/cms/VisualEditor.d.vue.ts +22 -4
- package/dist/runtime/app/components/cms/VisualEditor.vue +1153 -338
- package/dist/runtime/app/components/cms/VisualEditor.vue.d.ts +22 -4
- package/dist/runtime/app/components/cms/WelcomeModal.vue +32 -50
- package/dist/runtime/app/composables/cms-clipboard.d.ts +8 -0
- package/dist/runtime/app/composables/cms-clipboard.js +38 -0
- package/dist/runtime/app/composables/cms-confirm.d.ts +6 -8
- package/dist/runtime/app/composables/cms-confirm.js +5 -7
- package/dist/runtime/app/composables/cms-entry-disabled.d.ts +5 -1
- package/dist/runtime/app/composables/cms-entry-disabled.js +7 -0
- package/dist/runtime/app/composables/cms-entry-form.d.ts +15 -0
- package/dist/runtime/app/composables/cms-entry-form.js +40 -0
- package/dist/runtime/app/composables/cms-entry-settings.d.ts +30 -0
- package/dist/runtime/app/composables/cms-entry-settings.js +122 -0
- package/dist/runtime/app/composables/cms-entry.d.ts +5 -1
- package/dist/runtime/app/composables/cms-entry.js +36 -11
- package/dist/runtime/app/composables/cms-history.d.ts +10 -0
- package/dist/runtime/app/composables/cms-history.js +24 -0
- package/dist/runtime/app/composables/cms-link-targets.d.ts +10 -0
- package/dist/runtime/app/composables/cms-link-targets.js +40 -0
- package/dist/runtime/app/composables/cms-link-usage.d.ts +1 -0
- package/dist/runtime/app/composables/cms-link-usage.js +45 -0
- package/dist/runtime/app/composables/cms-media-library.d.ts +19 -9
- package/dist/runtime/app/composables/cms-media-library.js +31 -13
- package/dist/runtime/app/composables/cms-media-uploader.js +6 -20
- package/dist/runtime/app/composables/cms-permissions.d.ts +18 -0
- package/dist/runtime/app/composables/cms-permissions.js +54 -0
- package/dist/runtime/app/composables/cms-presets.d.ts +11 -0
- package/dist/runtime/app/composables/cms-presets.js +40 -0
- package/dist/runtime/app/composables/cms-preview-mode.d.ts +4 -0
- package/dist/runtime/app/composables/cms-preview-mode.js +8 -0
- package/dist/runtime/app/composables/cms-query.d.ts +3 -0
- package/dist/runtime/app/composables/cms-query.js +45 -20
- package/dist/runtime/app/composables/cms-record-list.d.ts +31 -0
- package/dist/runtime/app/composables/cms-record-list.js +75 -0
- package/dist/runtime/app/composables/cms-route.d.ts +6 -0
- package/dist/runtime/app/composables/cms-route.js +36 -0
- package/dist/runtime/app/composables/cms-runtime.d.ts +1 -0
- package/dist/runtime/app/composables/cms-save-handoff.d.ts +4 -0
- package/dist/runtime/app/composables/cms-save-handoff.js +19 -0
- package/dist/runtime/app/composables/cms-seo.d.ts +12 -0
- package/dist/runtime/app/composables/cms-seo.js +69 -0
- package/dist/runtime/app/composables/cms-settings-form.d.ts +13 -0
- package/dist/runtime/app/composables/cms-settings-form.js +29 -0
- package/dist/runtime/app/composables/cms-settings-sections.d.ts +26 -0
- package/dist/runtime/app/composables/cms-settings-sections.js +181 -0
- package/dist/runtime/app/composables/cms-settings-stores.d.ts +52 -0
- package/dist/runtime/app/composables/cms-settings-stores.js +156 -0
- package/dist/runtime/app/composables/cms-settings.d.ts +3 -3
- package/dist/runtime/app/composables/cms-settings.js +14 -8
- package/dist/runtime/app/composables/cms-site-disabled.d.ts +7 -0
- package/dist/runtime/app/composables/cms-site-disabled.js +8 -0
- package/dist/runtime/app/composables/cms-site.d.ts +7 -0
- package/dist/runtime/app/composables/cms-site.js +22 -0
- package/dist/runtime/app/composables/cms-toast.d.ts +2 -8
- package/dist/runtime/app/composables/cms-toast.js +3 -9
- package/dist/runtime/app/composables/cms-translation-actions.d.ts +15 -0
- package/dist/runtime/app/composables/cms-translation-actions.js +108 -0
- package/dist/runtime/app/css-url.d.ts +4 -0
- package/dist/runtime/app/image/CmsImage.d.vue.ts +89 -0
- package/dist/runtime/app/image/CmsImage.vue +91 -0
- package/dist/runtime/app/image/CmsImage.vue.d.ts +89 -0
- package/dist/runtime/app/layouts/cms-admin.d.vue.ts +2 -2
- package/dist/runtime/app/layouts/cms-admin.vue +98 -76
- package/dist/runtime/app/layouts/cms-admin.vue.d.ts +2 -2
- package/dist/runtime/app/layouts/cms-editor.vue +7 -2
- package/dist/runtime/app/links/CmsLink.d.vue.ts +18 -0
- package/dist/runtime/app/links/CmsLink.vue +18 -0
- package/dist/runtime/app/links/CmsLink.vue.d.ts +18 -0
- package/dist/runtime/app/middleware/cms-auth.js +13 -1
- package/dist/runtime/app/pages/admin-collection.vue +473 -297
- package/dist/runtime/app/pages/admin-content.vue +191 -54
- package/dist/runtime/app/pages/admin-entry.vue +79 -75
- package/dist/runtime/app/pages/admin-index.vue +18 -5
- package/dist/runtime/app/pages/admin-login.vue +1 -1
- package/dist/runtime/app/pages/admin-logout.vue +1 -1
- package/dist/runtime/app/pages/admin-media.vue +3 -3
- package/dist/runtime/app/pages/admin-preview.vue +112 -24
- package/dist/runtime/app/plugins/cms-field.d.ts +2 -0
- package/dist/runtime/app/plugins/cms-field.js +8 -0
- package/dist/runtime/app/plugins/cms-preview-banner.client.d.ts +2 -0
- package/dist/runtime/app/plugins/cms-preview-banner.client.js +19 -0
- package/dist/runtime/app/plugins/cms-preview.d.ts +2 -0
- package/dist/runtime/app/plugins/cms-preview.js +27 -0
- package/dist/runtime/app/preview/CmsPreviewBanner.d.vue.ts +7 -0
- package/dist/runtime/app/preview/CmsPreviewBanner.vue +63 -0
- package/dist/runtime/app/preview/CmsPreviewBanner.vue.d.ts +7 -0
- package/dist/runtime/app/preview/PreviewOverlay.d.vue.ts +17 -3
- package/dist/runtime/app/preview/PreviewOverlay.vue +629 -166
- package/dist/runtime/app/preview/PreviewOverlay.vue.d.ts +17 -3
- package/dist/runtime/app/preview/field-marker.d.ts +12 -0
- package/dist/runtime/app/preview/field-marker.js +20 -0
- package/dist/runtime/app/preview/inline-text.d.ts +15 -0
- package/dist/runtime/app/preview/inline-text.js +158 -0
- package/dist/runtime/app/utils/block-editor.d.ts +22 -0
- package/dist/runtime/app/utils/block-editor.js +12 -0
- package/dist/runtime/app/utils/keyboard.d.ts +6 -0
- package/dist/runtime/app/utils/keyboard.js +52 -0
- package/dist/runtime/app/utils/redirects.d.ts +6 -0
- package/dist/runtime/app/utils/redirects.js +7 -0
- package/dist/runtime/app/utils/ui.d.ts +8 -0
- package/dist/runtime/app/utils/ui.js +15 -1
- package/dist/runtime/app/utils/users.d.ts +15 -0
- package/dist/runtime/app/utils/users.js +14 -0
- package/dist/runtime/assets/cms.css +1 -1
- package/dist/runtime/generate.js +16 -2
- package/dist/runtime/server/api/collection-export.get.js +3 -2
- package/dist/runtime/server/api/collection-import.post.js +39 -11
- package/dist/runtime/server/api/collection.get.js +27 -9
- package/dist/runtime/server/api/collection.post.js +28 -11
- package/dist/runtime/server/api/collection.put.js +35 -13
- package/dist/runtime/server/api/item.delete.js +19 -7
- package/dist/runtime/server/api/item.get.js +3 -2
- package/dist/runtime/server/api/item.put.js +52 -18
- package/dist/runtime/server/api/link-usage.post.d.ts +5 -0
- package/dist/runtime/server/api/link-usage.post.js +21 -0
- package/dist/runtime/server/api/media-delete.post.js +4 -2
- package/dist/runtime/server/api/media-download.get.js +2 -2
- package/dist/runtime/server/api/media-folder.delete.js +8 -2
- package/dist/runtime/server/api/media-folder.patch.js +10 -2
- package/dist/runtime/server/api/media-folder.post.js +4 -2
- package/dist/runtime/server/api/media-move.post.js +7 -4
- package/dist/runtime/server/api/media-presign.post.js +2 -2
- package/dist/runtime/server/api/media-upload.put.js +2 -2
- package/dist/runtime/server/api/media-usage.post.d.ts +2 -4
- package/dist/runtime/server/api/media-usage.post.js +13 -9
- package/dist/runtime/server/api/media.delete.js +4 -2
- package/dist/runtime/server/api/media.get.js +22 -7
- package/dist/runtime/server/api/media.post.js +4 -2
- package/dist/runtime/server/api/media.put.js +33 -16
- package/dist/runtime/server/api/preset.delete.d.ts +4 -0
- package/dist/runtime/server/api/preset.delete.js +9 -0
- package/dist/runtime/server/api/preset.put.d.ts +3 -0
- package/dist/runtime/server/api/preset.put.js +23 -0
- package/dist/runtime/server/api/presets-field.get.d.ts +3 -0
- package/dist/runtime/server/api/presets-field.get.js +13 -0
- package/dist/runtime/server/api/presets-field.post.d.ts +3 -0
- package/dist/runtime/server/api/presets-field.post.js +36 -0
- package/dist/runtime/server/api/presets.get.d.ts +3 -0
- package/dist/runtime/server/api/presets.get.js +7 -0
- package/dist/runtime/server/api/preview-link.delete.d.ts +4 -0
- package/dist/runtime/server/api/preview-link.delete.js +15 -0
- package/dist/runtime/server/api/preview-links.get.d.ts +3 -0
- package/dist/runtime/server/api/preview-links.get.js +10 -0
- package/dist/runtime/server/api/preview-links.post.d.ts +3 -0
- package/dist/runtime/server/api/preview-links.post.js +17 -0
- package/dist/runtime/server/api/preview.get.d.ts +3 -0
- package/dist/runtime/server/api/preview.get.js +7 -0
- package/dist/runtime/server/api/redirect.delete.d.ts +4 -0
- package/dist/runtime/server/api/redirect.delete.js +10 -0
- package/dist/runtime/server/api/redirect.put.d.ts +3 -0
- package/dist/runtime/server/api/redirect.put.js +8 -0
- package/dist/runtime/server/api/redirects-import.post.d.ts +3 -0
- package/dist/runtime/server/api/redirects-import.post.js +13 -0
- package/dist/runtime/server/api/redirects.get.d.ts +3 -0
- package/dist/runtime/server/api/redirects.get.js +7 -0
- package/dist/runtime/server/api/redirects.post.d.ts +3 -0
- package/dist/runtime/server/api/redirects.post.js +7 -0
- package/dist/runtime/server/api/search.get.js +8 -3
- package/dist/runtime/server/api/settings.delete.js +2 -2
- package/dist/runtime/server/api/settings.get.js +4 -2
- package/dist/runtime/server/api/settings.put.js +2 -2
- package/dist/runtime/server/api/site.get.d.ts +3 -0
- package/dist/runtime/server/api/site.get.js +7 -0
- package/dist/runtime/server/api/site.put.d.ts +3 -0
- package/dist/runtime/server/api/site.put.js +16 -0
- package/dist/runtime/server/api/tags.get.js +3 -2
- package/dist/runtime/server/api/user.delete.js +8 -2
- package/dist/runtime/server/api/user.put.js +14 -4
- package/dist/runtime/server/api/users.get.js +2 -2
- package/dist/runtime/server/api/users.post.js +8 -4
- package/dist/runtime/server/middleware/hidden-site.d.ts +2 -0
- package/dist/runtime/server/middleware/hidden-site.js +8 -0
- package/dist/runtime/server/middleware/preview-links.d.ts +2 -0
- package/dist/runtime/server/middleware/preview-links.js +6 -0
- package/dist/runtime/server/middleware/redirects.d.ts +2 -0
- package/dist/runtime/server/middleware/redirects.js +18 -0
- package/dist/runtime/server/plugins/session-validate.js +4 -1
- package/dist/runtime/server/plugins/webhooks.d.ts +3 -0
- package/dist/runtime/server/plugins/webhooks.js +27 -0
- package/dist/runtime/server/routes/graphql.js +5 -3
- package/dist/runtime/server/routes/robots.d.ts +2 -0
- package/dist/runtime/server/routes/robots.js +16 -0
- package/dist/runtime/server/routes/sitemap.d.ts +2 -0
- package/dist/runtime/server/routes/sitemap.js +67 -0
- package/dist/runtime/server/utils/cached-value.d.ts +5 -0
- package/dist/runtime/server/utils/cached-value.js +24 -0
- package/dist/runtime/server/utils/content-routes.d.ts +5 -0
- package/dist/runtime/server/utils/content-routes.js +29 -0
- package/dist/runtime/server/utils/field-rules.d.ts +19 -0
- package/dist/runtime/server/utils/field-rules.js +72 -0
- package/dist/runtime/server/utils/graphql.d.ts +3 -1
- package/dist/runtime/server/utils/graphql.js +143 -28
- package/dist/runtime/server/utils/hooks.d.ts +14 -0
- package/dist/runtime/server/utils/hooks.js +71 -0
- package/dist/runtime/server/utils/import.d.ts +7 -2
- package/dist/runtime/server/utils/import.js +108 -14
- package/dist/runtime/server/utils/link-usage.d.ts +4 -0
- package/dist/runtime/server/utils/link-usage.js +28 -0
- package/dist/runtime/server/utils/media-references.d.ts +6 -1
- package/dist/runtime/server/utils/media-references.js +49 -20
- package/dist/runtime/server/utils/media-usage.d.ts +2 -0
- package/dist/runtime/server/utils/media-usage.js +5 -3
- package/dist/runtime/server/utils/page-rows.d.ts +2 -0
- package/dist/runtime/server/utils/page-rows.js +42 -29
- package/dist/runtime/server/utils/permissions.d.ts +14 -0
- package/dist/runtime/server/utils/permissions.js +43 -0
- package/dist/runtime/server/utils/presets.d.ts +18 -0
- package/dist/runtime/server/utils/presets.js +68 -0
- package/dist/runtime/server/utils/preview-links.d.ts +207 -0
- package/dist/runtime/server/utils/preview-links.js +161 -0
- package/dist/runtime/server/utils/redirects.d.ts +31 -0
- package/dist/runtime/server/utils/redirects.js +240 -0
- package/dist/runtime/server/utils/registry.js +4 -1
- package/dist/runtime/server/utils/relations.d.ts +8 -0
- package/dist/runtime/server/utils/relations.js +25 -6
- package/dist/runtime/server/utils/require-admin.d.ts +0 -1
- package/dist/runtime/server/utils/require-admin.js +4 -8
- package/dist/runtime/server/utils/search.d.ts +1 -0
- package/dist/runtime/server/utils/search.js +44 -19
- package/dist/runtime/server/utils/site.d.ts +23 -0
- package/dist/runtime/server/utils/site.js +79 -0
- package/dist/runtime/server/utils/sitemap.d.ts +12 -0
- package/dist/runtime/server/utils/sitemap.js +109 -0
- package/dist/runtime/server/utils/user-management.d.ts +4 -0
- package/dist/runtime/server/utils/user-management.js +20 -0
- package/dist/runtime/server/utils/users.d.ts +1 -1
- package/dist/runtime/server/utils/users.js +1 -1
- package/dist/runtime/server/utils/visibility.d.ts +1 -0
- package/dist/runtime/server/utils/visibility.js +6 -1
- package/dist/runtime/server/utils/webhooks.d.ts +24 -0
- package/dist/runtime/server/utils/webhooks.js +90 -0
- package/dist/runtime/shared/block-paths.d.ts +66 -0
- package/dist/runtime/shared/block-paths.js +310 -0
- package/dist/runtime/shared/block-picker.d.ts +18 -0
- package/dist/runtime/shared/block-picker.js +31 -0
- package/dist/runtime/shared/block-signature.d.ts +4 -0
- package/dist/runtime/shared/block-signature.js +46 -0
- package/dist/runtime/shared/clipboard.d.ts +31 -0
- package/dist/runtime/shared/clipboard.js +206 -0
- package/dist/runtime/shared/conditions.d.ts +36 -0
- package/dist/runtime/shared/conditions.js +100 -0
- package/dist/runtime/shared/content-routes.d.ts +42 -0
- package/dist/runtime/shared/content-routes.js +237 -0
- package/dist/runtime/shared/duplicate.js +2 -1
- package/dist/runtime/shared/editor-layout.d.ts +18 -0
- package/dist/runtime/shared/editor-layout.js +9 -0
- package/dist/runtime/shared/field-options.d.ts +21 -0
- package/dist/runtime/shared/field-options.js +90 -0
- package/dist/runtime/shared/graphql-sdl.d.ts +1 -0
- package/dist/runtime/shared/graphql-sdl.js +50 -26
- package/dist/runtime/shared/history.d.ts +27 -0
- package/dist/runtime/shared/history.js +123 -0
- package/dist/runtime/shared/hooks.d.ts +45 -0
- package/dist/runtime/shared/hooks.js +28 -0
- package/dist/runtime/shared/index.d.ts +90 -21
- package/dist/runtime/shared/index.js +121 -37
- package/dist/runtime/shared/inline-text.d.ts +38 -0
- package/dist/runtime/shared/inline-text.js +85 -0
- package/dist/runtime/shared/layout.d.ts +2 -1
- package/dist/runtime/shared/layout.js +3 -0
- package/dist/runtime/shared/links.d.ts +48 -0
- package/dist/runtime/shared/links.js +155 -0
- package/dist/runtime/shared/list-filters.d.ts +2 -0
- package/dist/runtime/shared/list-filters.js +2 -0
- package/dist/runtime/shared/media-focal.d.ts +30 -0
- package/dist/runtime/shared/media-focal.js +52 -0
- package/dist/runtime/shared/migrations-dir.d.ts +14 -0
- package/dist/runtime/shared/migrations-dir.js +48 -2
- package/dist/runtime/shared/presets.d.ts +67 -0
- package/dist/runtime/shared/presets.js +127 -0
- package/dist/runtime/shared/preview-links.d.ts +64 -0
- package/dist/runtime/shared/preview-links.js +54 -0
- package/dist/runtime/shared/preview.d.ts +124 -21
- package/dist/runtime/shared/preview.js +419 -81
- package/dist/runtime/shared/redirects.d.ts +75 -0
- package/dist/runtime/shared/redirects.js +230 -0
- package/dist/runtime/shared/roles.d.ts +57 -0
- package/dist/runtime/shared/roles.js +293 -0
- package/dist/runtime/shared/save-state.d.ts +8 -0
- package/dist/runtime/shared/save-state.js +15 -0
- package/dist/runtime/shared/search.d.ts +16 -1
- package/dist/runtime/shared/search.js +41 -7
- package/dist/runtime/shared/seo.d.ts +167 -0
- package/dist/runtime/shared/seo.js +335 -0
- package/dist/runtime/shared/transfer.js +2 -1
- package/dist/runtime/shared/translations.d.ts +29 -0
- package/dist/runtime/shared/translations.js +123 -0
- package/dist/runtime/shared/users.d.ts +1 -1
- package/dist/runtime/shared/validation.d.ts +23 -1
- package/dist/runtime/shared/validation.js +214 -64
- package/dist/runtime/webhooks.d.ts +33 -0
- package/dist/runtime/webhooks.js +57 -0
- package/dist/types.d.mts +5 -1
- package/package.json +6 -2
- package/dist/runtime/app/components/cms/BlockOutline.vue +0 -88
- package/dist/runtime/app/components/cms/BlockPalette.vue +0 -31
- package/dist/runtime/app/components/cms/SettingsModal.d.vue.ts +0 -12
- package/dist/runtime/app/components/cms/SettingsModal.vue +0 -126
- package/dist/runtime/app/components/cms/SettingsModal.vue.d.ts +0 -12
- package/dist/runtime/app/composables/cms-field-focus.d.ts +0 -4
- package/dist/runtime/app/composables/cms-field-focus.js +0 -20
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
readRawBody
|
|
7
7
|
} from "h3";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
+
import cmsConfig from "#cms-config";
|
|
9
10
|
import { runBatch, useDb } from "#cms-db";
|
|
10
11
|
import { isCollectionKind } from "../../shared/index.js";
|
|
11
12
|
import {
|
|
@@ -16,15 +17,21 @@ import {
|
|
|
16
17
|
TRANSFER_FORMATS
|
|
17
18
|
} from "../../shared/transfer.js";
|
|
18
19
|
import { mapConstraintErrors } from "../utils/db-errors.js";
|
|
20
|
+
import { emitEntryChange } from "../utils/hooks.js";
|
|
19
21
|
import {
|
|
22
|
+
assignImportIds,
|
|
20
23
|
checkImportRows,
|
|
24
|
+
existingImportIds,
|
|
21
25
|
importPreview,
|
|
22
26
|
importWriteStatements,
|
|
27
|
+
planImportRedirects,
|
|
23
28
|
validateImportRows
|
|
24
29
|
} from "../utils/import.js";
|
|
30
|
+
import { invalidateRedirects, redirectPlanStatements } from "../utils/redirects.js";
|
|
25
31
|
import { mediaLookup } from "../utils/media-check.js";
|
|
26
32
|
import { getContentI18n, getRegistryEntry } from "../utils/registry.js";
|
|
27
|
-
import {
|
|
33
|
+
import { assertCmsPermission, requireCmsAccess } from "../utils/permissions.js";
|
|
34
|
+
import { can } from "../../shared/roles.js";
|
|
28
35
|
const querySchema = z.object({
|
|
29
36
|
format: z.enum(TRANSFER_FORMATS),
|
|
30
37
|
mode: z.enum(IMPORT_MODES).default("create"),
|
|
@@ -37,12 +44,15 @@ function tooLarge() {
|
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
export default defineEventHandler(async (event) => {
|
|
40
|
-
await
|
|
47
|
+
const { user, access } = await requireCmsAccess(event);
|
|
41
48
|
const { name, entry, table } = getRegistryEntry(event);
|
|
42
49
|
if (!isCollectionKind(entry)) {
|
|
43
50
|
throw createError({ statusCode: 405, statusMessage: "Only collections can be imported" });
|
|
44
51
|
}
|
|
52
|
+
assertCmsPermission(access, `${name}.import`);
|
|
45
53
|
const { format, mode, dryRun } = await getValidatedQuery(event, querySchema.parse);
|
|
54
|
+
assertCmsPermission(access, `${name}.create`);
|
|
55
|
+
if (mode === "upsert") assertCmsPermission(access, `${name}.update`);
|
|
46
56
|
if (format === "csv" && !canTransferCsv(entry)) {
|
|
47
57
|
throw createError({
|
|
48
58
|
statusCode: 400,
|
|
@@ -56,14 +66,20 @@ export default defineEventHandler(async (event) => {
|
|
|
56
66
|
const i18n = getContentI18n();
|
|
57
67
|
const source = importSource(entry, format, text, i18n);
|
|
58
68
|
const db = useDb();
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
entry,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
const existing = mode === "upsert" ? await existingImportIds(db, table, source.rows) : null;
|
|
70
|
+
const isCreate = (id) => !existing || !id || !existing.has(id);
|
|
71
|
+
const rows = await checkImportRows(
|
|
72
|
+
validateImportRows(entry, source.rows, i18n, isCreate, cmsConfig),
|
|
73
|
+
{
|
|
74
|
+
db,
|
|
75
|
+
name,
|
|
76
|
+
entry,
|
|
77
|
+
table,
|
|
78
|
+
mode,
|
|
79
|
+
media: source.errors.length ? null : await mediaLookup(),
|
|
80
|
+
canPublish: can(access, `${name}.publish`)
|
|
81
|
+
}
|
|
82
|
+
);
|
|
67
83
|
const preview = importPreview(entry, rows, {
|
|
68
84
|
format,
|
|
69
85
|
mode,
|
|
@@ -78,8 +94,20 @@ export default defineEventHandler(async (event) => {
|
|
|
78
94
|
data: preview
|
|
79
95
|
});
|
|
80
96
|
}
|
|
97
|
+
const written = assignImportIds(entry, rows);
|
|
98
|
+
const redirects = await planImportRedirects(db, entry, table, written);
|
|
81
99
|
await mapConstraintErrors(
|
|
82
|
-
() => runBatch((tx) =>
|
|
100
|
+
() => runBatch((tx) => [
|
|
101
|
+
...importWriteStatements(tx, name, entry, table, written),
|
|
102
|
+
...redirects ? redirectPlanStatements(tx, redirects) : []
|
|
103
|
+
])
|
|
83
104
|
);
|
|
105
|
+
if (redirects) invalidateRedirects();
|
|
106
|
+
emitEntryChange(event, user, {
|
|
107
|
+
entry: name,
|
|
108
|
+
kind: entry.kind,
|
|
109
|
+
action: "import",
|
|
110
|
+
ids: written.flatMap((row) => row.values && row.id ? [row.id] : [])
|
|
111
|
+
});
|
|
84
112
|
return { ...preview, imported: true };
|
|
85
113
|
});
|
|
@@ -2,12 +2,13 @@ import { count } from "drizzle-orm";
|
|
|
2
2
|
import { defineEventHandler, getValidatedQuery } from "h3";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { cmsDialect, useDb } from "#cms-db";
|
|
5
|
-
import { pageRoutes } from "../../shared/index.js";
|
|
5
|
+
import { CONTENT_PUBLISHED_AT_FIELD, CONTENT_SLUG_FIELD, pageRoutes } from "../../shared/index.js";
|
|
6
|
+
import { LIST_IDS_MAX } from "../../shared/list-filters.js";
|
|
6
7
|
import { decodeRows, getRegistryEntry, idColumn, tableColumns } from "../utils/registry.js";
|
|
7
8
|
import { listOrderBy, listWhere, readListFilters } from "../utils/list-query.js";
|
|
8
9
|
import { readPages } from "../utils/page-storage.js";
|
|
9
10
|
import { attachManyToMany, relationTitles } from "../utils/relations.js";
|
|
10
|
-
import {
|
|
11
|
+
import { assertCmsPermission, requireCmsAccess } from "../utils/permissions.js";
|
|
11
12
|
import { singleRowFirst } from "../utils/single-row.js";
|
|
12
13
|
const querySchema = z.object({
|
|
13
14
|
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
@@ -15,18 +16,20 @@ const querySchema = z.object({
|
|
|
15
16
|
search: z.string().trim().max(200).optional(),
|
|
16
17
|
sort: z.string().trim().max(64).optional(),
|
|
17
18
|
order: z.enum(["asc", "desc"]).default("desc"),
|
|
18
|
-
light: z.stringbool().default(false)
|
|
19
|
+
light: z.stringbool().default(false),
|
|
20
|
+
ids: z.stringbool().default(false)
|
|
19
21
|
});
|
|
20
22
|
export default defineEventHandler(async (event) => {
|
|
21
|
-
await
|
|
23
|
+
const { access } = await requireCmsAccess(event);
|
|
22
24
|
const { name, entry, table } = getRegistryEntry(event);
|
|
25
|
+
assertCmsPermission(access, `${name}.read`);
|
|
23
26
|
const db = useDb();
|
|
24
27
|
if (entry.kind === "single") {
|
|
25
28
|
const rows = await db.select().from(table).orderBy(singleRowFirst(idColumn(table), entry.id)).limit(1);
|
|
26
29
|
await attachManyToMany(db, name, entry, rows);
|
|
27
30
|
return decodeRows(entry, rows)[0] ?? null;
|
|
28
31
|
}
|
|
29
|
-
const { limit, offset, search, sort, order, light } = await getValidatedQuery(
|
|
32
|
+
const { limit, offset, search, sort, order, light, ids } = await getValidatedQuery(
|
|
30
33
|
event,
|
|
31
34
|
querySchema.parse
|
|
32
35
|
);
|
|
@@ -42,6 +45,11 @@ export default defineEventHandler(async (event) => {
|
|
|
42
45
|
const matching = term ? items2.filter(
|
|
43
46
|
(item) => item.path.toLowerCase().includes(term) || item.label.toLowerCase().includes(term)
|
|
44
47
|
) : items2;
|
|
48
|
+
if (ids)
|
|
49
|
+
return {
|
|
50
|
+
ids: matching.slice(0, LIST_IDS_MAX).map((item) => item.id),
|
|
51
|
+
total: matching.length
|
|
52
|
+
};
|
|
45
53
|
return {
|
|
46
54
|
items: matching.slice(offset, offset + limit),
|
|
47
55
|
total: matching.length,
|
|
@@ -54,20 +62,30 @@ export default defineEventHandler(async (event) => {
|
|
|
54
62
|
search,
|
|
55
63
|
filters: readListFilters(event, entry)
|
|
56
64
|
});
|
|
65
|
+
const countRows = async () => {
|
|
66
|
+
const [counted2] = await (where ? db.select({ total: count() }).from(table).where(where) : db.select({ total: count() }).from(table));
|
|
67
|
+
return counted2?.total ?? 0;
|
|
68
|
+
};
|
|
69
|
+
if (ids) {
|
|
70
|
+
const base2 = db.select({ id: idColumn(table) }).from(table);
|
|
71
|
+
const found = await (where ? base2.where(where) : base2).orderBy(...listOrderBy(table, sort, order)).limit(LIST_IDS_MAX);
|
|
72
|
+
return { ids: found.map((row) => String(row.id)), total: await countRows() };
|
|
73
|
+
}
|
|
57
74
|
const selection = light ? Object.fromEntries([
|
|
58
75
|
["id", idColumn(table)],
|
|
59
76
|
...entry.titleField && titleColumn ? [[entry.titleField, titleColumn]] : [],
|
|
60
|
-
...entry.drafts && Object.hasOwn(columns, "status") ? [["status", columns.status]] : []
|
|
77
|
+
...entry.drafts && Object.hasOwn(columns, "status") ? [["status", columns.status]] : [],
|
|
78
|
+
...entry.kind === "content" ? [CONTENT_SLUG_FIELD, CONTENT_PUBLISHED_AT_FIELD].filter((key) => Object.hasOwn(columns, key)).map((key) => [key, columns[key]]) : []
|
|
61
79
|
]) : void 0;
|
|
62
80
|
const base = selection ? db.select(selection).from(table) : db.select().from(table);
|
|
63
81
|
const items = await (where ? base.where(where) : base).orderBy(...listOrderBy(table, sort, order)).limit(limit).offset(offset);
|
|
64
|
-
const
|
|
65
|
-
if (light) return { items, total: counted
|
|
82
|
+
const counted = await countRows();
|
|
83
|
+
if (light) return { items, total: counted, relations: {} };
|
|
66
84
|
await attachManyToMany(db, name, entry, items);
|
|
67
85
|
decodeRows(entry, items);
|
|
68
86
|
return {
|
|
69
87
|
items,
|
|
70
|
-
total: counted
|
|
88
|
+
total: counted,
|
|
71
89
|
relations: await relationTitles(db, entry, items)
|
|
72
90
|
};
|
|
73
91
|
});
|
|
@@ -1,43 +1,60 @@
|
|
|
1
|
-
import { createError, defineEventHandler
|
|
2
|
-
import { runBatch
|
|
1
|
+
import { createError, defineEventHandler } from "h3";
|
|
2
|
+
import { runBatch } from "#cms-db";
|
|
3
3
|
import { customId } from "../utils/custom-id.js";
|
|
4
4
|
import { mapConstraintErrors } from "../utils/db-errors.js";
|
|
5
|
+
import { emitEntryChange } from "../utils/hooks.js";
|
|
6
|
+
import { assertUniqueValues, readEntryBody } from "../utils/field-rules.js";
|
|
5
7
|
import {
|
|
6
|
-
buildValidator,
|
|
7
8
|
decodeRows,
|
|
8
9
|
encodeColumnValues,
|
|
9
10
|
getRegistryEntry,
|
|
10
11
|
withContentDefaults,
|
|
11
12
|
withTimestamps
|
|
12
13
|
} from "../utils/registry.js";
|
|
14
|
+
import { entryStatus } from "../../shared/hooks.js";
|
|
13
15
|
import { isCollectionKind } from "../../shared/index.js";
|
|
14
16
|
import {
|
|
15
17
|
assertRelationTargets,
|
|
16
|
-
|
|
18
|
+
readBackSaved,
|
|
19
|
+
savedReadBackError,
|
|
17
20
|
manyToManyStatements,
|
|
18
21
|
splitRelationValues
|
|
19
22
|
} from "../utils/relations.js";
|
|
20
|
-
import {
|
|
23
|
+
import { assertCmsPermission, assertPublishAllowed, requireCmsAccess } from "../utils/permissions.js";
|
|
21
24
|
export default defineEventHandler(async (event) => {
|
|
22
|
-
await
|
|
25
|
+
const { user, access } = await requireCmsAccess(event);
|
|
23
26
|
const { name, entry, table } = getRegistryEntry(event);
|
|
24
27
|
if (!isCollectionKind(entry)) {
|
|
25
28
|
throw createError({ statusCode: 405, statusMessage: "Single objects are updated with PUT" });
|
|
26
29
|
}
|
|
27
|
-
|
|
30
|
+
assertCmsPermission(access, `${name}.create`);
|
|
31
|
+
const body = await readEntryBody(event, entry, { create: true });
|
|
28
32
|
const { values, lists } = splitRelationValues(entry, encodeColumnValues(entry, body));
|
|
29
|
-
await assertRelationTargets(entry, lists);
|
|
30
33
|
if (entry.drafts) values.status ??= "draft";
|
|
34
|
+
assertPublishAllowed(access, name, entry, null, values.status);
|
|
35
|
+
await assertRelationTargets(entry, lists);
|
|
36
|
+
await assertUniqueValues(entry, table, body, null);
|
|
31
37
|
withContentDefaults(entry, values);
|
|
32
38
|
const id = customId(entry.id);
|
|
33
39
|
values.id = id;
|
|
34
|
-
|
|
40
|
+
const saved = await mapConstraintErrors(async () => {
|
|
35
41
|
const [inserted] = await runBatch((db) => [
|
|
36
42
|
db.insert(table).values(withTimestamps(table, values)).returning(),
|
|
37
43
|
...manyToManyStatements(db, name, id, lists)
|
|
38
44
|
]);
|
|
39
45
|
const [row] = inserted;
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
return row;
|
|
47
|
+
});
|
|
48
|
+
const readBack = await readBackSaved(name, entry, saved);
|
|
49
|
+
const item = decodeRows(entry, [readBack.row])[0];
|
|
50
|
+
emitEntryChange(event, user, {
|
|
51
|
+
entry: name,
|
|
52
|
+
kind: entry.kind,
|
|
53
|
+
action: "create",
|
|
54
|
+
ids: [id],
|
|
55
|
+
status: entry.drafts ? entryStatus(item?.status) : null,
|
|
56
|
+
item: item ?? null
|
|
42
57
|
});
|
|
58
|
+
if (readBack.error) throw savedReadBackError(readBack.error);
|
|
59
|
+
return item;
|
|
43
60
|
});
|
|
@@ -1,42 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { createError, defineEventHandler } from "h3";
|
|
2
3
|
import { runBatch, useDb } from "#cms-db";
|
|
3
4
|
import { mapConstraintErrors } from "../utils/db-errors.js";
|
|
5
|
+
import { emitEntryChange } from "../utils/hooks.js";
|
|
6
|
+
import { entryStatus, entryWriteAction } from "../../shared/hooks.js";
|
|
7
|
+
import { assertImmutableValues, immutableSelection, readEntryBody } from "../utils/field-rules.js";
|
|
4
8
|
import {
|
|
5
|
-
buildValidator,
|
|
6
9
|
decodeRows,
|
|
7
10
|
encodeColumnValues,
|
|
8
11
|
getRegistryEntry,
|
|
9
12
|
idColumn,
|
|
13
|
+
tableColumns,
|
|
10
14
|
withTimestamps,
|
|
11
15
|
withUpdatedAt
|
|
12
16
|
} from "../utils/registry.js";
|
|
13
17
|
import {
|
|
14
18
|
assertRelationTargets,
|
|
15
|
-
|
|
19
|
+
readBackSaved,
|
|
20
|
+
savedReadBackError,
|
|
16
21
|
manyToManyStatements,
|
|
17
22
|
splitRelationValues
|
|
18
23
|
} from "../utils/relations.js";
|
|
19
|
-
import {
|
|
24
|
+
import { assertCmsPermission, requireCmsAccess } from "../utils/permissions.js";
|
|
20
25
|
export default defineEventHandler(async (event) => {
|
|
21
|
-
await
|
|
26
|
+
const { user, access } = await requireCmsAccess(event);
|
|
22
27
|
const { name, entry, table } = getRegistryEntry(event);
|
|
23
28
|
if (entry.kind !== "single") {
|
|
24
29
|
throw createError({ statusCode: 405, statusMessage: "Collections are updated with PUT /:id" });
|
|
25
30
|
}
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
assertCmsPermission(access, `${name}.update`);
|
|
32
|
+
const statusColumn = entry.drafts ? tableColumns(table).status : void 0;
|
|
33
|
+
const [previous] = await useDb().select({
|
|
34
|
+
...immutableSelection(entry, table),
|
|
35
|
+
id: idColumn(table),
|
|
36
|
+
...statusColumn ? { status: statusColumn } : {}
|
|
37
|
+
}).from(table).where(eq(idColumn(table), entry.id)).limit(1);
|
|
38
|
+
const body = await readEntryBody(event, entry, { create: !previous });
|
|
39
|
+
assertImmutableValues(entry, previous, body);
|
|
40
|
+
const { values, lists } = splitRelationValues(entry, encodeColumnValues(entry, body));
|
|
31
41
|
await assertRelationTargets(entry, lists);
|
|
32
42
|
const set = withUpdatedAt(table, values);
|
|
33
|
-
|
|
43
|
+
const saved = await mapConstraintErrors(async () => {
|
|
34
44
|
const [upserted] = await runBatch((db) => [
|
|
35
45
|
db.insert(table).values(withTimestamps(table, { id: entry.id, ...set })).onConflictDoUpdate({ target: idColumn(table), set }).returning(),
|
|
36
46
|
...manyToManyStatements(db, name, entry.id, lists)
|
|
37
47
|
]);
|
|
38
48
|
const [row] = upserted;
|
|
39
|
-
|
|
40
|
-
return decodeRows(entry, [attached])[0];
|
|
49
|
+
return row;
|
|
41
50
|
});
|
|
51
|
+
const readBack = await readBackSaved(name, entry, saved);
|
|
52
|
+
const item = decodeRows(entry, [readBack.row])[0];
|
|
53
|
+
const status = entry.drafts ? entryStatus(item?.status) : null;
|
|
54
|
+
emitEntryChange(event, user, {
|
|
55
|
+
entry: name,
|
|
56
|
+
kind: entry.kind,
|
|
57
|
+
action: entryWriteAction(!previous, entryStatus(previous?.status), status),
|
|
58
|
+
ids: [entry.id],
|
|
59
|
+
status,
|
|
60
|
+
item: item ?? null
|
|
61
|
+
});
|
|
62
|
+
if (readBack.error) throw savedReadBackError(readBack.error);
|
|
63
|
+
return item;
|
|
42
64
|
});
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import { eq } from "drizzle-orm";
|
|
2
2
|
import { createError, defineEventHandler } from "h3";
|
|
3
|
-
import { useDb } from "#cms-db";
|
|
3
|
+
import { runBatch, useDb } from "#cms-db";
|
|
4
4
|
import { mapConstraintErrors } from "../utils/db-errors.js";
|
|
5
|
+
import { emitEntryChange } from "../utils/hooks.js";
|
|
6
|
+
import { deleteItemPreviewLinksStatement } from "../utils/preview-links.js";
|
|
5
7
|
import { getRegistryEntry, idColumn, parseId } from "../utils/registry.js";
|
|
6
8
|
import { isCollectionKind } from "../../shared/index.js";
|
|
7
|
-
import {
|
|
9
|
+
import { assertCmsPermission, assertDeleteAllowed, requireCmsAccess } from "../utils/permissions.js";
|
|
8
10
|
export default defineEventHandler(async (event) => {
|
|
9
|
-
await
|
|
10
|
-
const { entry, table } = getRegistryEntry(event);
|
|
11
|
+
const { user, access } = await requireCmsAccess(event);
|
|
12
|
+
const { name, entry, table } = getRegistryEntry(event);
|
|
11
13
|
if (!isCollectionKind(entry)) {
|
|
12
14
|
throw createError({
|
|
13
15
|
statusCode: 405,
|
|
14
16
|
statusMessage: "Only collection entries can be deleted"
|
|
15
17
|
});
|
|
16
18
|
}
|
|
19
|
+
assertCmsPermission(access, `${name}.delete`);
|
|
17
20
|
const id = parseId(event);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const [existing] = await useDb().select().from(table).where(eq(idColumn(table), id)).limit(1);
|
|
22
|
+
if (!existing) throw createError({ statusCode: 404, statusMessage: "Row not found" });
|
|
23
|
+
assertDeleteAllowed(access, name, entry, existing.status);
|
|
24
|
+
const result = await mapConstraintErrors(async () => {
|
|
25
|
+
const [deleted] = await runBatch((db) => [
|
|
26
|
+
db.delete(table).where(eq(idColumn(table), id)).returning(),
|
|
27
|
+
...entry.kind === "content" ? [deleteItemPreviewLinksStatement(db, name, id)] : []
|
|
28
|
+
]);
|
|
29
|
+
if (!deleted.length)
|
|
30
|
+
throw createError({ statusCode: 404, statusMessage: "Row not found" });
|
|
21
31
|
return { deleted: true };
|
|
22
32
|
});
|
|
33
|
+
emitEntryChange(event, user, { entry: name, kind: entry.kind, action: "delete", ids: [id] });
|
|
34
|
+
return result;
|
|
23
35
|
});
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
} from "../utils/registry.js";
|
|
11
11
|
import { readPages } from "../utils/page-storage.js";
|
|
12
12
|
import { attachManyToMany } from "../utils/relations.js";
|
|
13
|
-
import {
|
|
13
|
+
import { assertCmsPermission, requireCmsAccess } from "../utils/permissions.js";
|
|
14
14
|
export default defineEventHandler(async (event) => {
|
|
15
|
-
await
|
|
15
|
+
const { access } = await requireCmsAccess(event);
|
|
16
16
|
const { name, entry, table } = getRegistryEntry(event);
|
|
17
17
|
if (entry.kind === "single") {
|
|
18
18
|
throw createError({ statusCode: 404, statusMessage: "Single objects have no items" });
|
|
19
19
|
}
|
|
20
|
+
assertCmsPermission(access, `${name}.read`);
|
|
20
21
|
const id = parseId(event);
|
|
21
22
|
if (entry.kind === "page") {
|
|
22
23
|
const route = requirePageRoute(entry, id);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { eq } from "drizzle-orm";
|
|
2
|
-
import { createError, defineEventHandler
|
|
2
|
+
import { createError, defineEventHandler } from "h3";
|
|
3
3
|
import { runBatch, useDb } from "#cms-db";
|
|
4
|
+
import { assertImmutableValues, assertUniqueValues, readEntryBody } from "../utils/field-rules.js";
|
|
4
5
|
import {
|
|
5
|
-
buildValidator,
|
|
6
6
|
decodeRows,
|
|
7
7
|
encodeColumnValues,
|
|
8
8
|
getRegistryEntry,
|
|
@@ -12,19 +12,28 @@ import {
|
|
|
12
12
|
withContentDefaults,
|
|
13
13
|
withUpdatedAt
|
|
14
14
|
} from "../utils/registry.js";
|
|
15
|
-
import { pageFields } from "../../shared/index.js";
|
|
15
|
+
import { isRoutedContent, pageFields, rowAfterUpdate } from "../../shared/index.js";
|
|
16
16
|
import { assertMediaExists } from "../utils/media-check.js";
|
|
17
17
|
import { writePage } from "../utils/page-storage.js";
|
|
18
18
|
import {
|
|
19
19
|
assertRelationTargets,
|
|
20
|
-
attachManyToMany,
|
|
21
20
|
manyToManyStatements,
|
|
21
|
+
readBackSaved,
|
|
22
|
+
savedReadBackError,
|
|
22
23
|
splitRelationValues
|
|
23
24
|
} from "../utils/relations.js";
|
|
24
|
-
import {
|
|
25
|
+
import { assertCmsPermission, assertPublishAllowed, requireCmsAccess } from "../utils/permissions.js";
|
|
26
|
+
import {
|
|
27
|
+
contentMovesOf,
|
|
28
|
+
invalidateRedirects,
|
|
29
|
+
planContentRedirects,
|
|
30
|
+
redirectPlanStatements
|
|
31
|
+
} from "../utils/redirects.js";
|
|
25
32
|
import { mapConstraintErrors } from "../utils/db-errors.js";
|
|
33
|
+
import { emitEntryChange } from "../utils/hooks.js";
|
|
34
|
+
import { entryStatus, entryWriteAction } from "../../shared/hooks.js";
|
|
26
35
|
export default defineEventHandler(async (event) => {
|
|
27
|
-
await
|
|
36
|
+
const { user, access } = await requireCmsAccess(event);
|
|
28
37
|
const { name, entry, table } = getRegistryEntry(event);
|
|
29
38
|
if (entry.kind === "single") {
|
|
30
39
|
throw createError({
|
|
@@ -32,34 +41,59 @@ export default defineEventHandler(async (event) => {
|
|
|
32
41
|
statusMessage: "Single objects are updated with PUT without id"
|
|
33
42
|
});
|
|
34
43
|
}
|
|
44
|
+
assertCmsPermission(access, `${name}.update`);
|
|
35
45
|
const id = parseId(event);
|
|
36
46
|
if (entry.kind === "page") {
|
|
37
47
|
const route = requirePageRoute(entry, id);
|
|
38
|
-
const body2 = await
|
|
48
|
+
const body2 = await readEntryBody(event, entry, { path: route.path });
|
|
39
49
|
await assertMediaExists(pageFields(entry, route.path), body2);
|
|
40
50
|
const values2 = encodeColumnValues(entry, body2);
|
|
41
51
|
const set2 = withUpdatedAt(table, values2);
|
|
42
|
-
|
|
52
|
+
const page = await mapConstraintErrors(
|
|
43
53
|
async () => decodeRows(entry, [await writePage(name, entry, table, route, set2)])[0]
|
|
44
54
|
);
|
|
55
|
+
emitEntryChange(event, user, {
|
|
56
|
+
entry: name,
|
|
57
|
+
kind: entry.kind,
|
|
58
|
+
action: "update",
|
|
59
|
+
ids: [id],
|
|
60
|
+
path: route.path,
|
|
61
|
+
item: page ?? null
|
|
62
|
+
});
|
|
63
|
+
return page;
|
|
45
64
|
}
|
|
46
|
-
const body = await
|
|
47
|
-
const { values, lists } = splitRelationValues(
|
|
48
|
-
entry,
|
|
49
|
-
encodeColumnValues(entry, body)
|
|
50
|
-
);
|
|
65
|
+
const body = await readEntryBody(event, entry);
|
|
66
|
+
const { values, lists } = splitRelationValues(entry, encodeColumnValues(entry, body));
|
|
51
67
|
await assertRelationTargets(entry, lists);
|
|
52
68
|
const set = withUpdatedAt(table, withContentDefaults(entry, values));
|
|
53
|
-
const [existing] = await useDb().select(
|
|
69
|
+
const [existing] = await useDb().select().from(table).where(eq(idColumn(table), id)).limit(1);
|
|
54
70
|
if (!existing) throw createError({ statusCode: 404, statusMessage: "Row not found" });
|
|
55
|
-
|
|
71
|
+
assertImmutableValues(entry, existing, body);
|
|
72
|
+
await assertUniqueValues(entry, table, body, id);
|
|
73
|
+
assertPublishAllowed(access, name, entry, existing.status, values.status ?? existing.status);
|
|
74
|
+
const redirects = isRoutedContent(entry) ? await planContentRedirects(contentMovesOf(entry, existing, rowAfterUpdate(existing, set))) : null;
|
|
75
|
+
const saved = await mapConstraintErrors(async () => {
|
|
56
76
|
const [updated] = await runBatch((db) => [
|
|
57
77
|
db.update(table).set(set).where(eq(idColumn(table), id)).returning(),
|
|
58
|
-
...manyToManyStatements(db, name, id, lists)
|
|
78
|
+
...manyToManyStatements(db, name, id, lists),
|
|
79
|
+
...redirects ? redirectPlanStatements(db, redirects) : []
|
|
59
80
|
]);
|
|
81
|
+
if (redirects) invalidateRedirects();
|
|
60
82
|
const [row] = updated;
|
|
61
83
|
if (!row) throw createError({ statusCode: 404, statusMessage: "Row not found" });
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
return row;
|
|
85
|
+
});
|
|
86
|
+
const readBack = await readBackSaved(name, entry, saved);
|
|
87
|
+
const item = decodeRows(entry, [readBack.row])[0];
|
|
88
|
+
const status = entry.drafts ? entryStatus(item?.status) : null;
|
|
89
|
+
emitEntryChange(event, user, {
|
|
90
|
+
entry: name,
|
|
91
|
+
kind: entry.kind,
|
|
92
|
+
action: entryWriteAction(false, entryStatus(existing.status), status),
|
|
93
|
+
ids: [id],
|
|
94
|
+
status,
|
|
95
|
+
item: item ?? null
|
|
64
96
|
});
|
|
97
|
+
if (readBack.error) throw savedReadBackError(readBack.error);
|
|
98
|
+
return item;
|
|
65
99
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineEventHandler, readValidatedBody } from "h3";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { linkTargetKey } from "../../shared/index.js";
|
|
4
|
+
import { loadLinkUsage } from "../utils/link-usage.js";
|
|
5
|
+
import { assertCmsPermission, requireCmsAccess } from "../utils/permissions.js";
|
|
6
|
+
import { can } from "../../shared/roles.js";
|
|
7
|
+
const targetSchema = z.object({
|
|
8
|
+
entry: z.string().min(1).max(128),
|
|
9
|
+
id: z.string().min(1).max(256)
|
|
10
|
+
});
|
|
11
|
+
const bodySchema = z.object({ targets: z.array(targetSchema).min(1).max(1e3) });
|
|
12
|
+
export default defineEventHandler(
|
|
13
|
+
async (event) => {
|
|
14
|
+
const { access } = await requireCmsAccess(event);
|
|
15
|
+
const { targets } = await readValidatedBody(event, bodySchema.parse);
|
|
16
|
+
for (const entry of new Set(targets.map((target) => target.entry)))
|
|
17
|
+
assertCmsPermission(access, `${entry}.read`);
|
|
18
|
+
const keys = [...new Set(targets.map((target) => linkTargetKey(target.entry, target.id)))];
|
|
19
|
+
return { usage: await loadLinkUsage(keys, (name) => can(access, `${name}.read`)) };
|
|
20
|
+
}
|
|
21
|
+
);
|
|
@@ -7,10 +7,11 @@ import { isMediaFolderMarker } from "../../shared/index.js";
|
|
|
7
7
|
import { objectKeySchema } from "../../shared/validation.js";
|
|
8
8
|
import { useMediaStorage } from "../utils/media.js";
|
|
9
9
|
import { deleteMediaRows, keyChunks } from "../utils/media-folders.js";
|
|
10
|
-
import {
|
|
10
|
+
import { emitMediaChange } from "../utils/hooks.js";
|
|
11
|
+
import { requireCmsPermission } from "../utils/permissions.js";
|
|
11
12
|
const bodySchema = z.object({ keys: z.array(objectKeySchema).min(1).max(1e3) });
|
|
12
13
|
export default defineEventHandler(async (event) => {
|
|
13
|
-
await
|
|
14
|
+
const { user } = await requireCmsPermission(event, "media.delete");
|
|
14
15
|
const { store } = useMediaStorage(event);
|
|
15
16
|
const { keys } = await readValidatedBody(event, bodySchema.parse);
|
|
16
17
|
const found = [];
|
|
@@ -19,5 +20,6 @@ export default defineEventHandler(async (event) => {
|
|
|
19
20
|
found.push(...rows.map((row) => row.key).filter((key) => !isMediaFolderMarker(key)));
|
|
20
21
|
}
|
|
21
22
|
await deleteMediaRows(store, found);
|
|
23
|
+
if (found.length) emitMediaChange(event, user, { action: "delete", keys: found });
|
|
22
24
|
return { deleted: found.length };
|
|
23
25
|
});
|
|
@@ -21,7 +21,7 @@ import { attachmentDisposition } from "../utils/media-download.js";
|
|
|
21
21
|
import { mediaFilePath } from "../utils/media-fs.js";
|
|
22
22
|
import { useMediaIndex } from "../utils/media-index.js";
|
|
23
23
|
import { mediaMimeForKey } from "../utils/media-sync.js";
|
|
24
|
-
import {
|
|
24
|
+
import { requireCmsPermission } from "../utils/permissions.js";
|
|
25
25
|
const querySchema = z.object({ key: objectKeySchema });
|
|
26
26
|
function notFound() {
|
|
27
27
|
throw createError({ statusCode: 404, statusMessage: "Media not found" });
|
|
@@ -66,7 +66,7 @@ async function sendRemoteFile(event, baseUrl, key, disposition) {
|
|
|
66
66
|
return sendStream(event, upstream.body);
|
|
67
67
|
}
|
|
68
68
|
export default defineEventHandler(async (event) => {
|
|
69
|
-
await
|
|
69
|
+
await requireCmsPermission(event, "media.read");
|
|
70
70
|
const { media } = useMediaConfig(event);
|
|
71
71
|
const { key } = await getValidatedQuery(event, querySchema.parse);
|
|
72
72
|
if (isMediaFolderMarker(key)) notFound();
|
|
@@ -3,13 +3,14 @@ import { z } from "zod";
|
|
|
3
3
|
import { isMediaFolderMarker, normalizeMediaFolder } from "../../shared/index.js";
|
|
4
4
|
import { useMediaStorage } from "../utils/media.js";
|
|
5
5
|
import { deleteMediaRows, mediaRowsInFolder } from "../utils/media-folders.js";
|
|
6
|
-
import {
|
|
6
|
+
import { emitMediaChange } from "../utils/hooks.js";
|
|
7
|
+
import { requireCmsPermission } from "../utils/permissions.js";
|
|
7
8
|
const querySchema = z.object({
|
|
8
9
|
name: z.string().min(1).max(255),
|
|
9
10
|
recursive: z.stringbool().default(false)
|
|
10
11
|
});
|
|
11
12
|
export default defineEventHandler(async (event) => {
|
|
12
|
-
await
|
|
13
|
+
const { user } = await requireCmsPermission(event, "media.delete");
|
|
13
14
|
const { store } = useMediaStorage(event);
|
|
14
15
|
const { name, recursive } = await getValidatedQuery(event, querySchema.parse);
|
|
15
16
|
const folder = normalizeMediaFolder(name);
|
|
@@ -28,5 +29,10 @@ export default defineEventHandler(async (event) => {
|
|
|
28
29
|
store,
|
|
29
30
|
rows.map((row) => row.key)
|
|
30
31
|
);
|
|
32
|
+
emitMediaChange(event, user, {
|
|
33
|
+
action: "folder-delete",
|
|
34
|
+
keys: files.map((row) => row.key),
|
|
35
|
+
folder
|
|
36
|
+
});
|
|
31
37
|
return { deleted: rows.length };
|
|
32
38
|
});
|
|
@@ -3,6 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { runBatch } from "#cms-db";
|
|
4
4
|
import { cms_media } from "#cms-tables";
|
|
5
5
|
import {
|
|
6
|
+
isMediaFolderMarker,
|
|
6
7
|
isWithinMediaFolder,
|
|
7
8
|
MEDIA_FOLDER_MAX_DEPTH,
|
|
8
9
|
mediaFolderDepth,
|
|
@@ -13,7 +14,8 @@ import {
|
|
|
13
14
|
} from "../../shared/index.js";
|
|
14
15
|
import { useMediaStorage } from "../utils/media.js";
|
|
15
16
|
import { mediaRowsInFolder } from "../utils/media-folders.js";
|
|
16
|
-
import {
|
|
17
|
+
import { emitMediaChange } from "../utils/hooks.js";
|
|
18
|
+
import { requireCmsPermission } from "../utils/permissions.js";
|
|
17
19
|
import { mediaFolderRenameStatements, planMediaFolderRename } from "../utils/write-statements.js";
|
|
18
20
|
const bodySchema = z.object({
|
|
19
21
|
from: z.string().min(1).max(255),
|
|
@@ -26,7 +28,7 @@ function tooDeep() {
|
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
export default defineEventHandler(async (event) => {
|
|
29
|
-
await
|
|
31
|
+
const { user } = await requireCmsPermission(event, "media.write");
|
|
30
32
|
const { store } = useMediaStorage(event);
|
|
31
33
|
const body = await readValidatedBody(event, bodySchema.parse);
|
|
32
34
|
const from = normalizeMediaFolder(body.from);
|
|
@@ -58,5 +60,11 @@ export default defineEventHandler(async (event) => {
|
|
|
58
60
|
for (const key of plan.staleMarkers) {
|
|
59
61
|
await store.remove(key);
|
|
60
62
|
}
|
|
63
|
+
emitMediaChange(event, user, {
|
|
64
|
+
action: "folder-rename",
|
|
65
|
+
keys: rows.flatMap((row) => isMediaFolderMarker(row.key) ? [] : [row.key]),
|
|
66
|
+
folder: to,
|
|
67
|
+
from
|
|
68
|
+
});
|
|
61
69
|
return { folder: to, moved: rows.length };
|
|
62
70
|
});
|