katecms 0.0.0-stage → 1.0.0-beta.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 +5 -3
- package/dist/module.d.mts +93 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +579 -0
- package/dist/runtime/assets/img/katecms-logo.svg +17 -0
- package/dist/runtime/composables/getCollection.d.ts +62 -0
- package/dist/runtime/composables/getCollection.js +167 -0
- package/dist/runtime/composables/getOptions.d.ts +22 -0
- package/dist/runtime/composables/getOptions.js +22 -0
- package/dist/runtime/composables/getQueryCollection.d.ts +95 -0
- package/dist/runtime/composables/getQueryCollection.js +199 -0
- package/dist/runtime/composables/getTerms.d.ts +79 -0
- package/dist/runtime/composables/getTerms.js +148 -0
- package/dist/runtime/composables/useAuth.d.ts +14 -0
- package/dist/runtime/composables/useAuth.js +33 -0
- package/dist/runtime/composables/useAuthCooldown.d.ts +6 -0
- package/dist/runtime/composables/useAuthCooldown.js +44 -0
- package/dist/runtime/composables/useCmsPaths.d.ts +15 -0
- package/dist/runtime/composables/useCmsPaths.js +21 -0
- package/dist/runtime/composables/useKateCmsExtensions.d.ts +49 -0
- package/dist/runtime/composables/useKateCmsExtensions.js +29 -0
- package/dist/runtime/composables/useMediaLibrary.d.ts +84 -0
- package/dist/runtime/composables/useMediaLibrary.js +140 -0
- package/dist/runtime/composables/useMenuAccess.d.ts +8 -0
- package/dist/runtime/composables/useMenuAccess.js +16 -0
- package/dist/runtime/internal/admin/AdminHeader.d.vue.ts +24 -0
- package/dist/runtime/internal/admin/AdminHeader.vue +91 -0
- package/dist/runtime/internal/admin/AdminHeader.vue.d.ts +24 -0
- package/dist/runtime/internal/admin/AppMenu.d.vue.ts +3 -0
- package/dist/runtime/internal/admin/AppMenu.vue +244 -0
- package/dist/runtime/internal/admin/AppMenu.vue.d.ts +3 -0
- package/dist/runtime/internal/admin/AppUser.d.vue.ts +3 -0
- package/dist/runtime/internal/admin/AppUser.vue +227 -0
- package/dist/runtime/internal/admin/AppUser.vue.d.ts +3 -0
- package/dist/runtime/internal/admin/CollectionEntryForm.d.vue.ts +41 -0
- package/dist/runtime/internal/admin/CollectionEntryForm.vue +916 -0
- package/dist/runtime/internal/admin/CollectionEntryForm.vue.d.ts +41 -0
- package/dist/runtime/internal/admin/ConfirmDialog.d.vue.ts +28 -0
- package/dist/runtime/internal/admin/ConfirmDialog.vue +136 -0
- package/dist/runtime/internal/admin/ConfirmDialog.vue.d.ts +28 -0
- package/dist/runtime/internal/admin/DictionaryTermForm.d.vue.ts +33 -0
- package/dist/runtime/internal/admin/DictionaryTermForm.vue +328 -0
- package/dist/runtime/internal/admin/DictionaryTermForm.vue.d.ts +33 -0
- package/dist/runtime/internal/admin/EntryRevisions.d.vue.ts +15 -0
- package/dist/runtime/internal/admin/EntryRevisions.vue +125 -0
- package/dist/runtime/internal/admin/EntryRevisions.vue.d.ts +15 -0
- package/dist/runtime/internal/admin/MediaLibraryFilters.d.vue.ts +16 -0
- package/dist/runtime/internal/admin/MediaLibraryFilters.vue +153 -0
- package/dist/runtime/internal/admin/MediaLibraryFilters.vue.d.ts +16 -0
- package/dist/runtime/internal/admin/MediaLibraryModal.d.vue.ts +65 -0
- package/dist/runtime/internal/admin/MediaLibraryModal.vue +451 -0
- package/dist/runtime/internal/admin/MediaLibraryModal.vue.d.ts +65 -0
- package/dist/runtime/internal/admin/OptionPageForm.d.vue.ts +26 -0
- package/dist/runtime/internal/admin/OptionPageForm.vue +222 -0
- package/dist/runtime/internal/admin/OptionPageForm.vue.d.ts +26 -0
- package/dist/runtime/internal/admin/UserAvatarField.d.vue.ts +12 -0
- package/dist/runtime/internal/admin/UserAvatarField.vue +305 -0
- package/dist/runtime/internal/admin/UserAvatarField.vue.d.ts +12 -0
- package/dist/runtime/internal/fields/AccordionField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/AccordionField.vue +220 -0
- package/dist/runtime/internal/fields/AccordionField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/ButtonGroupField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/ButtonGroupField.vue +109 -0
- package/dist/runtime/internal/fields/ButtonGroupField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/CheckboxField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/CheckboxField.vue +190 -0
- package/dist/runtime/internal/fields/CheckboxField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/ColorPickerField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/ColorPickerField.vue +791 -0
- package/dist/runtime/internal/fields/ColorPickerField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/DatePickerField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/DatePickerField.vue +26 -0
- package/dist/runtime/internal/fields/DatePickerField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/DateTimePickerField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/DateTimePickerField.vue +26 -0
- package/dist/runtime/internal/fields/DateTimePickerField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/DictionaryField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/DictionaryField.vue +345 -0
- package/dist/runtime/internal/fields/DictionaryField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/EmailField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/EmailField.vue +21 -0
- package/dist/runtime/internal/fields/EmailField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/FileField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/FileField.vue +408 -0
- package/dist/runtime/internal/fields/FileField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/FlexibleContentField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/FlexibleContentField.vue +1114 -0
- package/dist/runtime/internal/fields/FlexibleContentField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/GalleryField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/GalleryField.vue +584 -0
- package/dist/runtime/internal/fields/GalleryField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/GroupField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/GroupField.vue +111 -0
- package/dist/runtime/internal/fields/GroupField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/ImageField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/ImageField.vue +638 -0
- package/dist/runtime/internal/fields/ImageField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/ImageSelectField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/ImageSelectField.vue +179 -0
- package/dist/runtime/internal/fields/ImageSelectField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/LinkField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/LinkField.vue +303 -0
- package/dist/runtime/internal/fields/LinkField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/NumberField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/NumberField.vue +25 -0
- package/dist/runtime/internal/fields/NumberField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/OembedField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/OembedField.vue +161 -0
- package/dist/runtime/internal/fields/OembedField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/OpenStreetMapField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/OpenStreetMapField.vue +1502 -0
- package/dist/runtime/internal/fields/OpenStreetMapField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/PageLinkField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/PageLinkField.vue +153 -0
- package/dist/runtime/internal/fields/PageLinkField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/PasswordField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/PasswordField.vue +108 -0
- package/dist/runtime/internal/fields/PasswordField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/PostObjectField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/PostObjectField.vue +151 -0
- package/dist/runtime/internal/fields/PostObjectField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/RadioField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/RadioField.vue +163 -0
- package/dist/runtime/internal/fields/RadioField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/RangeField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/RangeField.vue +48 -0
- package/dist/runtime/internal/fields/RangeField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/RelationshipField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/RelationshipField.vue +525 -0
- package/dist/runtime/internal/fields/RelationshipField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/RepeaterField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/RepeaterField.vue +856 -0
- package/dist/runtime/internal/fields/RepeaterField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/SelectField.d.vue.ts +21 -0
- package/dist/runtime/internal/fields/SelectField.vue +101 -0
- package/dist/runtime/internal/fields/SelectField.vue.d.ts +21 -0
- package/dist/runtime/internal/fields/SeparatorField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/SeparatorField.vue +63 -0
- package/dist/runtime/internal/fields/SeparatorField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TabField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TabField.vue +210 -0
- package/dist/runtime/internal/fields/TabField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TextField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TextField.vue +22 -0
- package/dist/runtime/internal/fields/TextField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TextareaField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TextareaField.vue +62 -0
- package/dist/runtime/internal/fields/TextareaField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TimePickerField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TimePickerField.vue +24 -0
- package/dist/runtime/internal/fields/TimePickerField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/TrueFalseField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/TrueFalseField.vue +151 -0
- package/dist/runtime/internal/fields/TrueFalseField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/UrlField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/UrlField.vue +21 -0
- package/dist/runtime/internal/fields/UrlField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/UserField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/UserField.vue +164 -0
- package/dist/runtime/internal/fields/UserField.vue.d.ts +0 -0
- package/dist/runtime/internal/fields/WysiwygField.d.vue.ts +0 -0
- package/dist/runtime/internal/fields/WysiwygField.vue +971 -0
- package/dist/runtime/internal/fields/WysiwygField.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/DateTimeControl.d.vue.ts +90 -0
- package/dist/runtime/internal/parts/DateTimeControl.vue +568 -0
- package/dist/runtime/internal/parts/DateTimeControl.vue.d.ts +90 -0
- package/dist/runtime/internal/parts/FieldAddon.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/FieldAddon.vue +43 -0
- package/dist/runtime/internal/parts/FieldAddon.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/FieldInstructions.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/FieldInstructions.vue +24 -0
- package/dist/runtime/internal/parts/FieldInstructions.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/FieldLabel.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/FieldLabel.vue +40 -0
- package/dist/runtime/internal/parts/FieldLabel.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/FieldWrapper.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/FieldWrapper.vue +47 -0
- package/dist/runtime/internal/parts/FieldWrapper.vue.d.ts +0 -0
- package/dist/runtime/internal/parts/ImageCropper.d.vue.ts +17 -0
- package/dist/runtime/internal/parts/ImageCropper.vue +363 -0
- package/dist/runtime/internal/parts/ImageCropper.vue.d.ts +17 -0
- package/dist/runtime/internal/parts/InputControl.d.vue.ts +0 -0
- package/dist/runtime/internal/parts/InputControl.vue +163 -0
- package/dist/runtime/internal/parts/InputControl.vue.d.ts +0 -0
- package/dist/runtime/internal/ui/UiButton.d.vue.ts +35 -0
- package/dist/runtime/internal/ui/UiButton.vue +204 -0
- package/dist/runtime/internal/ui/UiButton.vue.d.ts +35 -0
- package/dist/runtime/internal/ui/UiNotice.d.vue.ts +40 -0
- package/dist/runtime/internal/ui/UiNotice.vue +253 -0
- package/dist/runtime/internal/ui/UiNotice.vue.d.ts +40 -0
- package/dist/runtime/internal/ui/UiSelect.d.vue.ts +61 -0
- package/dist/runtime/internal/ui/UiSelect.vue +1212 -0
- package/dist/runtime/internal/ui/UiSelect.vue.d.ts +61 -0
- package/dist/runtime/middleware/auth-guard.d.ts +9 -0
- package/dist/runtime/middleware/auth-guard.js +37 -0
- package/dist/runtime/pages/admin/collections/[id].d.vue.ts +3 -0
- package/dist/runtime/pages/admin/collections/[id].vue +423 -0
- package/dist/runtime/pages/admin/collections/[id].vue.d.ts +3 -0
- package/dist/runtime/pages/admin/collections/create.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/collections/create.vue +179 -0
- package/dist/runtime/pages/admin/collections/create.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/collections/index.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/collections/index.vue +828 -0
- package/dist/runtime/pages/admin/collections/index.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/demo-fields.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/demo-fields.vue +1327 -0
- package/dist/runtime/pages/admin/demo-fields.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/dictionaries/[id].d.vue.ts +3 -0
- package/dist/runtime/pages/admin/dictionaries/[id].vue +213 -0
- package/dist/runtime/pages/admin/dictionaries/[id].vue.d.ts +3 -0
- package/dist/runtime/pages/admin/dictionaries/index.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/dictionaries/index.vue +387 -0
- package/dist/runtime/pages/admin/dictionaries/index.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/index.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/index.vue +138 -0
- package/dist/runtime/pages/admin/index.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/login.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/login.vue +373 -0
- package/dist/runtime/pages/admin/login.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/media.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/media.vue +1054 -0
- package/dist/runtime/pages/admin/media.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/options/[page].d.vue.ts +3 -0
- package/dist/runtime/pages/admin/options/[page].vue +151 -0
- package/dist/runtime/pages/admin/options/[page].vue.d.ts +3 -0
- package/dist/runtime/pages/admin/register.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/register.vue +391 -0
- package/dist/runtime/pages/admin/register.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/users/[id].d.vue.ts +3 -0
- package/dist/runtime/pages/admin/users/[id].vue +337 -0
- package/dist/runtime/pages/admin/users/[id].vue.d.ts +3 -0
- package/dist/runtime/pages/admin/users/create.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/users/create.vue +201 -0
- package/dist/runtime/pages/admin/users/create.vue.d.ts +3 -0
- package/dist/runtime/pages/admin/users/index.d.vue.ts +3 -0
- package/dist/runtime/pages/admin/users/index.vue +329 -0
- package/dist/runtime/pages/admin/users/index.vue.d.ts +3 -0
- package/dist/runtime/pages/index.d.vue.ts +3 -0
- package/dist/runtime/pages/index.vue +399 -0
- package/dist/runtime/pages/index.vue.d.ts +3 -0
- package/dist/runtime/server/api/_katecms/auth/login.post.d.ts +5 -0
- package/dist/runtime/server/api/_katecms/auth/login.post.js +44 -0
- package/dist/runtime/server/api/_katecms/auth/logout.post.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/auth/logout.post.js +6 -0
- package/dist/runtime/server/api/_katecms/auth/register.post.d.ts +19 -0
- package/dist/runtime/server/api/_katecms/auth/register.post.js +83 -0
- package/dist/runtime/server/api/_katecms/auth/state.get.d.ts +9 -0
- package/dist/runtime/server/api/_katecms/auth/state.get.js +12 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].delete.d.ts +15 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].delete.js +59 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].get.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].get.js +50 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].patch.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/[id].patch.js +130 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/revisions/[revisionId].post.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/revisions/[revisionId].post.js +123 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/revisions.get.d.ts +6 -0
- package/dist/runtime/server/api/_katecms/collections/[collection]/revisions.get.js +31 -0
- package/dist/runtime/server/api/_katecms/collections/[collection].get.d.ts +8 -0
- package/dist/runtime/server/api/_katecms/collections/[collection].get.js +135 -0
- package/dist/runtime/server/api/_katecms/collections/[collection].post.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/collections/[collection].post.js +91 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].delete.d.ts +7 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].delete.js +31 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].get.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].get.js +45 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].patch.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].patch.js +83 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary].get.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary].get.js +38 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary].post.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/dictionaries/[dictionary].post.js +64 -0
- package/dist/runtime/server/api/_katecms/media/[id]/regenerate.post.d.ts +8 -0
- package/dist/runtime/server/api/_katecms/media/[id]/regenerate.post.js +30 -0
- package/dist/runtime/server/api/_katecms/media/[id].delete.d.ts +7 -0
- package/dist/runtime/server/api/_katecms/media/[id].delete.js +22 -0
- package/dist/runtime/server/api/_katecms/media/[id].get.d.ts +9 -0
- package/dist/runtime/server/api/_katecms/media/[id].get.js +17 -0
- package/dist/runtime/server/api/_katecms/media/[id].patch.d.ts +6 -0
- package/dist/runtime/server/api/_katecms/media/[id].patch.js +48 -0
- package/dist/runtime/server/api/_katecms/media/index.get.d.ts +5 -0
- package/dist/runtime/server/api/_katecms/media/index.get.js +75 -0
- package/dist/runtime/server/api/_katecms/media/index.post.d.ts +9 -0
- package/dist/runtime/server/api/_katecms/media/index.post.js +84 -0
- package/dist/runtime/server/api/_katecms/media/regenerate.post.d.ts +7 -0
- package/dist/runtime/server/api/_katecms/media/regenerate.post.js +30 -0
- package/dist/runtime/server/api/_katecms/menu.get.d.ts +8 -0
- package/dist/runtime/server/api/_katecms/menu.get.js +14 -0
- package/dist/runtime/server/api/_katecms/oembed.get.d.ts +2 -0
- package/dist/runtime/server/api/_katecms/oembed.get.js +53 -0
- package/dist/runtime/server/api/_katecms/options/[page].get.d.ts +7 -0
- package/dist/runtime/server/api/_katecms/options/[page].get.js +28 -0
- package/dist/runtime/server/api/_katecms/options/[page].patch.d.ts +4 -0
- package/dist/runtime/server/api/_katecms/options/[page].patch.js +36 -0
- package/dist/runtime/server/api/_katecms/query.get.d.ts +24 -0
- package/dist/runtime/server/api/_katecms/query.get.js +270 -0
- package/dist/runtime/server/api/_katecms/relation/entries.get.d.ts +17 -0
- package/dist/runtime/server/api/_katecms/relation/entries.get.js +74 -0
- package/dist/runtime/server/api/_katecms/relation/terms.get.d.ts +17 -0
- package/dist/runtime/server/api/_katecms/relation/terms.get.js +51 -0
- package/dist/runtime/server/api/_katecms/resolve.get.d.ts +17 -0
- package/dist/runtime/server/api/_katecms/resolve.get.js +116 -0
- package/dist/runtime/server/api/_katecms/terms.get.d.ts +20 -0
- package/dist/runtime/server/api/_katecms/terms.get.js +201 -0
- package/dist/runtime/server/api/_katecms/users/[id].delete.d.ts +11 -0
- package/dist/runtime/server/api/_katecms/users/[id].delete.js +45 -0
- package/dist/runtime/server/api/_katecms/users/[id].patch.d.ts +19 -0
- package/dist/runtime/server/api/_katecms/users/[id].patch.js +129 -0
- package/dist/runtime/server/api/_katecms/users.get.d.ts +10 -0
- package/dist/runtime/server/api/_katecms/users.get.js +34 -0
- package/dist/runtime/server/api/_katecms/users.post.d.ts +10 -0
- package/dist/runtime/server/api/_katecms/users.post.js +62 -0
- package/dist/runtime/server/api/uploads/[...key].get.d.ts +3 -0
- package/dist/runtime/server/api/uploads/[...key].get.js +28 -0
- package/dist/runtime/server/kit.d.ts +5 -0
- package/dist/runtime/server/kit.js +5 -0
- package/dist/runtime/server/middleware/admin-headers.d.ts +3 -0
- package/dist/runtime/server/middleware/admin-headers.js +12 -0
- package/dist/runtime/server/plugins/auto-migrate.d.ts +2 -0
- package/dist/runtime/server/plugins/auto-migrate.js +45 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/auth-attempts.d.ts +22 -0
- package/dist/runtime/server/utils/auth-attempts.js +42 -0
- package/dist/runtime/server/utils/auth-rate-limit.d.ts +11 -0
- package/dist/runtime/server/utils/auth-rate-limit.js +36 -0
- package/dist/runtime/server/utils/client-address.d.ts +16 -0
- package/dist/runtime/server/utils/client-address.js +23 -0
- package/dist/runtime/server/utils/collections.d.ts +42 -0
- package/dist/runtime/server/utils/collections.js +300 -0
- package/dist/runtime/server/utils/db.d.ts +3 -0
- package/dist/runtime/server/utils/db.js +25 -0
- package/dist/runtime/server/utils/dictionaries.d.ts +53 -0
- package/dist/runtime/server/utils/dictionaries.js +301 -0
- package/dist/runtime/server/utils/media-list.d.ts +18 -0
- package/dist/runtime/server/utils/media-list.js +84 -0
- package/dist/runtime/server/utils/media.d.ts +12 -0
- package/dist/runtime/server/utils/media.js +77 -0
- package/dist/runtime/server/utils/oembed-fetch.d.ts +4 -0
- package/dist/runtime/server/utils/oembed-fetch.js +142 -0
- package/dist/runtime/server/utils/options.d.ts +17 -0
- package/dist/runtime/server/utils/options.js +66 -0
- package/dist/runtime/server/utils/permissions.d.ts +13 -0
- package/dist/runtime/server/utils/permissions.js +20 -0
- package/dist/runtime/server/utils/public-fields-query.d.ts +6 -0
- package/dist/runtime/server/utils/public-fields-query.js +8 -0
- package/dist/runtime/server/utils/public-term.d.ts +8 -0
- package/dist/runtime/server/utils/public-term.js +80 -0
- package/dist/runtime/server/utils/regenerate.d.ts +12 -0
- package/dist/runtime/server/utils/regenerate.js +40 -0
- package/dist/runtime/server/utils/relation.d.ts +18 -0
- package/dist/runtime/server/utils/relation.js +77 -0
- package/dist/runtime/server/utils/request-address.d.ts +6 -0
- package/dist/runtime/server/utils/request-address.js +10 -0
- package/dist/runtime/server/utils/revisions.d.ts +20 -0
- package/dist/runtime/server/utils/revisions.js +172 -0
- package/dist/runtime/server/utils/session.d.ts +18 -0
- package/dist/runtime/server/utils/session.js +71 -0
- package/dist/runtime/server/utils/upload-headers.d.ts +2 -0
- package/dist/runtime/server/utils/upload-headers.js +30 -0
- package/dist/runtime/server/utils/users.d.ts +13 -0
- package/dist/runtime/server/utils/users.js +47 -0
- package/dist/runtime/utils/admin-users.d.ts +20 -0
- package/dist/runtime/utils/admin-users.js +19 -0
- package/dist/runtime/utils/auth-error.d.ts +6 -0
- package/dist/runtime/utils/auth-error.js +11 -0
- package/dist/runtime/utils/cms-paths.d.ts +5 -0
- package/dist/runtime/utils/cms-paths.js +13 -0
- package/dist/runtime/utils/collections.d.ts +176 -0
- package/dist/runtime/utils/collections.js +30 -0
- package/dist/runtime/utils/dictionaries.d.ts +65 -0
- package/dist/runtime/utils/dictionaries.js +14 -0
- package/dist/runtime/utils/field-errors.d.ts +4 -0
- package/dist/runtime/utils/field-errors.js +9 -0
- package/dist/runtime/utils/field-values.d.ts +19 -0
- package/dist/runtime/utils/field-values.js +82 -0
- package/dist/runtime/utils/helpers.d.ts +4 -0
- package/dist/runtime/utils/helpers.js +20 -0
- package/dist/runtime/utils/media-library-query.d.ts +54 -0
- package/dist/runtime/utils/media-library-query.js +190 -0
- package/dist/runtime/utils/options.d.ts +19 -0
- package/dist/runtime/utils/options.js +3 -0
- package/dist/runtime/utils/preview.d.ts +22 -0
- package/dist/runtime/utils/preview.js +33 -0
- package/dist/runtime/utils/relation.d.ts +33 -0
- package/dist/runtime/utils/relation.js +23 -0
- package/dist/runtime/utils/slugify.d.ts +2 -0
- package/dist/runtime/utils/slugify.js +4 -0
- package/dist/types.d.mts +7 -0
- package/package.json +84 -3
- package/src/admin-components.ts +124 -0
- package/src/module.ts +592 -0
- package/src/runtime/assets/img/katecms-logo.svg +17 -0
- package/src/runtime/assets/styles/_functions.scss +70 -0
- package/src/runtime/assets/styles/_index.scss +3 -0
- package/src/runtime/assets/styles/_mixins.scss +256 -0
- package/src/runtime/assets/styles/_variables.scss +35 -0
- package/src/runtime/composables/getCollection.ts +253 -0
- package/src/runtime/composables/getOptions.ts +42 -0
- package/src/runtime/composables/getQueryCollection.ts +325 -0
- package/src/runtime/composables/getTerms.ts +231 -0
- package/src/runtime/composables/useAuth.ts +43 -0
- package/src/runtime/composables/useAuthCooldown.ts +52 -0
- package/src/runtime/composables/useCmsPaths.ts +24 -0
- package/src/runtime/composables/useKateCmsExtensions.ts +81 -0
- package/src/runtime/composables/useMediaLibrary.ts +168 -0
- package/src/runtime/composables/useMenuAccess.ts +25 -0
- package/src/runtime/internal/admin/AdminHeader.vue +106 -0
- package/src/runtime/internal/admin/AppMenu.vue +290 -0
- package/src/runtime/internal/admin/AppUser.vue +260 -0
- package/src/runtime/internal/admin/CollectionEntryForm.vue +1044 -0
- package/src/runtime/internal/admin/ConfirmDialog.vue +164 -0
- package/src/runtime/internal/admin/DictionaryTermForm.vue +400 -0
- package/src/runtime/internal/admin/EntryRevisions.vue +145 -0
- package/src/runtime/internal/admin/MediaLibraryFilters.vue +186 -0
- package/src/runtime/internal/admin/MediaLibraryModal.vue +526 -0
- package/src/runtime/internal/admin/OptionPageForm.vue +277 -0
- package/src/runtime/internal/admin/UserAvatarField.vue +337 -0
- package/src/runtime/internal/fields/AccordionField.vue +258 -0
- package/src/runtime/internal/fields/ButtonGroupField.vue +144 -0
- package/src/runtime/internal/fields/CheckboxField.vue +228 -0
- package/src/runtime/internal/fields/ColorPickerField.vue +926 -0
- package/src/runtime/internal/fields/DatePickerField.vue +33 -0
- package/src/runtime/internal/fields/DateTimePickerField.vue +33 -0
- package/src/runtime/internal/fields/DictionaryField.vue +403 -0
- package/src/runtime/internal/fields/EmailField.vue +28 -0
- package/src/runtime/internal/fields/FileField.vue +480 -0
- package/src/runtime/internal/fields/FlexibleContentField.vue +1296 -0
- package/src/runtime/internal/fields/GalleryField.vue +677 -0
- package/src/runtime/internal/fields/GroupField.vue +136 -0
- package/src/runtime/internal/fields/ImageField.vue +730 -0
- package/src/runtime/internal/fields/ImageSelectField.vue +213 -0
- package/src/runtime/internal/fields/LinkField.vue +338 -0
- package/src/runtime/internal/fields/NumberField.vue +32 -0
- package/src/runtime/internal/fields/OembedField.vue +187 -0
- package/src/runtime/internal/fields/OpenStreetMapField.vue +1716 -0
- package/src/runtime/internal/fields/PageLinkField.vue +186 -0
- package/src/runtime/internal/fields/PasswordField.vue +127 -0
- package/src/runtime/internal/fields/PostObjectField.vue +187 -0
- package/src/runtime/internal/fields/RadioField.vue +195 -0
- package/src/runtime/internal/fields/RangeField.vue +62 -0
- package/src/runtime/internal/fields/RelationshipField.vue +604 -0
- package/src/runtime/internal/fields/RepeaterField.vue +999 -0
- package/src/runtime/internal/fields/SelectField.vue +118 -0
- package/src/runtime/internal/fields/SeparatorField.vue +77 -0
- package/src/runtime/internal/fields/TabField.vue +249 -0
- package/src/runtime/internal/fields/TextField.vue +29 -0
- package/src/runtime/internal/fields/TextareaField.vue +61 -0
- package/src/runtime/internal/fields/TimePickerField.vue +31 -0
- package/src/runtime/internal/fields/TrueFalseField.vue +181 -0
- package/src/runtime/internal/fields/UrlField.vue +28 -0
- package/src/runtime/internal/fields/UserField.vue +203 -0
- package/src/runtime/internal/fields/WysiwygField.vue +1061 -0
- package/src/runtime/internal/parts/DateTimeControl.vue +657 -0
- package/src/runtime/internal/parts/FieldAddon.vue +60 -0
- package/src/runtime/internal/parts/FieldInstructions.vue +38 -0
- package/src/runtime/internal/parts/FieldLabel.vue +56 -0
- package/src/runtime/internal/parts/FieldWrapper.vue +63 -0
- package/src/runtime/internal/parts/ImageCropper.vue +415 -0
- package/src/runtime/internal/parts/InputControl.vue +189 -0
- package/src/runtime/internal/ui/UiButton.vue +274 -0
- package/src/runtime/internal/ui/UiNotice.vue +302 -0
- package/src/runtime/internal/ui/UiSelect.vue +1420 -0
- package/src/runtime/middleware/auth-guard.ts +52 -0
- package/src/runtime/pages/admin/collections/[id].vue +486 -0
- package/src/runtime/pages/admin/collections/create.vue +208 -0
- package/src/runtime/pages/admin/collections/index.vue +955 -0
- package/src/runtime/pages/admin/demo-fields.vue +1354 -0
- package/src/runtime/pages/admin/dictionaries/[id].vue +246 -0
- package/src/runtime/pages/admin/dictionaries/index.vue +438 -0
- package/src/runtime/pages/admin/index.vue +155 -0
- package/src/runtime/pages/admin/login.vue +159 -0
- package/src/runtime/pages/admin/media.vue +1176 -0
- package/src/runtime/pages/admin/options/[page].vue +174 -0
- package/src/runtime/pages/admin/register.vue +179 -0
- package/src/runtime/pages/admin/users/[id].vue +382 -0
- package/src/runtime/pages/admin/users/create.vue +232 -0
- package/src/runtime/pages/admin/users/index.vue +374 -0
- package/src/runtime/pages/index.vue +265 -0
- package/src/runtime/server/api/_katecms/auth/login.post.ts +62 -0
- package/src/runtime/server/api/_katecms/auth/logout.post.ts +7 -0
- package/src/runtime/server/api/_katecms/auth/register.post.ts +112 -0
- package/src/runtime/server/api/_katecms/auth/state.get.ts +19 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/[id].delete.ts +77 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/[id].get.ts +57 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/[id].patch.ts +157 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/revisions/[revisionId].post.ts +133 -0
- package/src/runtime/server/api/_katecms/collections/[collection]/revisions.get.ts +35 -0
- package/src/runtime/server/api/_katecms/collections/[collection].get.ts +177 -0
- package/src/runtime/server/api/_katecms/collections/[collection].post.ts +111 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].delete.ts +37 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].get.ts +51 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary]/[id].patch.ts +101 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary].get.ts +43 -0
- package/src/runtime/server/api/_katecms/dictionaries/[dictionary].post.ts +78 -0
- package/src/runtime/server/api/_katecms/media/[id]/regenerate.post.ts +39 -0
- package/src/runtime/server/api/_katecms/media/[id].delete.ts +28 -0
- package/src/runtime/server/api/_katecms/media/[id].get.ts +25 -0
- package/src/runtime/server/api/_katecms/media/[id].patch.ts +60 -0
- package/src/runtime/server/api/_katecms/media/index.get.ts +96 -0
- package/src/runtime/server/api/_katecms/media/index.post.ts +104 -0
- package/src/runtime/server/api/_katecms/media/regenerate.post.ts +38 -0
- package/src/runtime/server/api/_katecms/menu.get.ts +19 -0
- package/src/runtime/server/api/_katecms/oembed.get.ts +62 -0
- package/src/runtime/server/api/_katecms/options/[page].get.ts +35 -0
- package/src/runtime/server/api/_katecms/options/[page].patch.ts +46 -0
- package/src/runtime/server/api/_katecms/query.get.ts +332 -0
- package/src/runtime/server/api/_katecms/relation/entries.get.ts +98 -0
- package/src/runtime/server/api/_katecms/relation/terms.get.ts +61 -0
- package/src/runtime/server/api/_katecms/resolve.get.ts +148 -0
- package/src/runtime/server/api/_katecms/terms.get.ts +258 -0
- package/src/runtime/server/api/_katecms/users/[id].delete.ts +57 -0
- package/src/runtime/server/api/_katecms/users/[id].patch.ts +177 -0
- package/src/runtime/server/api/_katecms/users.get.ts +48 -0
- package/src/runtime/server/api/_katecms/users.post.ts +85 -0
- package/src/runtime/server/api/uploads/[...key].get.ts +33 -0
- package/src/runtime/server/kit.ts +5 -0
- package/src/runtime/server/middleware/admin-headers.ts +14 -0
- package/src/runtime/server/plugins/auto-migrate.ts +53 -0
- package/src/runtime/server/tsconfig.json +3 -0
- package/src/runtime/server/utils/auth-attempts.ts +71 -0
- package/src/runtime/server/utils/auth-rate-limit.ts +48 -0
- package/src/runtime/server/utils/client-address.ts +41 -0
- package/src/runtime/server/utils/collections.ts +381 -0
- package/src/runtime/server/utils/db.ts +36 -0
- package/src/runtime/server/utils/dictionaries.ts +397 -0
- package/src/runtime/server/utils/media-list.ts +131 -0
- package/src/runtime/server/utils/media.ts +94 -0
- package/src/runtime/server/utils/oembed-fetch.ts +157 -0
- package/src/runtime/server/utils/options.ts +86 -0
- package/src/runtime/server/utils/permissions.ts +44 -0
- package/src/runtime/server/utils/public-fields-query.ts +14 -0
- package/src/runtime/server/utils/public-term.ts +98 -0
- package/src/runtime/server/utils/regenerate.ts +56 -0
- package/src/runtime/server/utils/relation.ts +96 -0
- package/src/runtime/server/utils/request-address.ts +16 -0
- package/src/runtime/server/utils/revisions.ts +256 -0
- package/src/runtime/server/utils/session.ts +112 -0
- package/src/runtime/server/utils/upload-headers.ts +35 -0
- package/src/runtime/server/utils/users.ts +67 -0
- package/src/runtime/utils/admin-users.ts +43 -0
- package/src/runtime/utils/auth-error.ts +22 -0
- package/src/runtime/utils/cms-paths.ts +17 -0
- package/src/runtime/utils/collections.ts +228 -0
- package/src/runtime/utils/dictionaries.ts +89 -0
- package/src/runtime/utils/field-errors.ts +12 -0
- package/src/runtime/utils/field-values.ts +101 -0
- package/src/runtime/utils/helpers.ts +33 -0
- package/src/runtime/utils/media-library-query.ts +263 -0
- package/src/runtime/utils/options.ts +25 -0
- package/src/runtime/utils/preview.ts +56 -0
- package/src/runtime/utils/relation.ts +60 -0
- package/src/runtime/utils/slugify.ts +10 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { findCollectionById, listCollectionParentOptions, loadCollectionSlugPath } from "@katecms/core";
|
|
4
|
+
import { getDb } from "../../../../utils/db.js";
|
|
5
|
+
import { requireUser } from "../../../../utils/session.js";
|
|
6
|
+
import { requirePermission } from "../../../../utils/permissions.js";
|
|
7
|
+
import {
|
|
8
|
+
entryFlags,
|
|
9
|
+
fail,
|
|
10
|
+
readCollectionSlug,
|
|
11
|
+
readEntryId,
|
|
12
|
+
requireCollection,
|
|
13
|
+
toAdminEntry,
|
|
14
|
+
toCollectionMeta,
|
|
15
|
+
toParentOption
|
|
16
|
+
} from "../../../../utils/collections.js";
|
|
17
|
+
import {
|
|
18
|
+
loadCollectionDictionaryPickers,
|
|
19
|
+
selectedDictionaryIds
|
|
20
|
+
} from "../../../../utils/dictionaries.js";
|
|
21
|
+
export default defineEventHandler(async (event) => {
|
|
22
|
+
const actor = await requireUser(event);
|
|
23
|
+
const collectionSlug = readCollectionSlug(getRouterParam(event, "collection"));
|
|
24
|
+
const id = readEntryId(getRouterParam(event, "id"));
|
|
25
|
+
const def = requireCollection(collectionSlug);
|
|
26
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {};
|
|
27
|
+
requirePermission(actor, "collections", "read", roles, collectionSlug);
|
|
28
|
+
const db = getDb();
|
|
29
|
+
const row = await findCollectionById(db, id);
|
|
30
|
+
if (!row || row.type !== collectionSlug) {
|
|
31
|
+
fail(404, "Entry not found.");
|
|
32
|
+
}
|
|
33
|
+
const slugPath = await loadCollectionSlugPath(db, collectionSlug, id) || row.slug;
|
|
34
|
+
const flags = entryFlags(actor, row, roles);
|
|
35
|
+
const meta = toCollectionMeta(collectionSlug, def);
|
|
36
|
+
const pickers = await loadCollectionDictionaryPickers(db, collectionSlug);
|
|
37
|
+
const dictionaryIds = await selectedDictionaryIds(db, id, pickers);
|
|
38
|
+
const response = {
|
|
39
|
+
collection: meta,
|
|
40
|
+
entry: toAdminEntry(row, slugPath, { ...flags, dictionaryIds }),
|
|
41
|
+
canUpdate: flags.canUpdate,
|
|
42
|
+
canDelete: flags.canDelete,
|
|
43
|
+
dictionaries: pickers
|
|
44
|
+
};
|
|
45
|
+
if (meta.hierarchical) {
|
|
46
|
+
const parents = await listCollectionParentOptions(db, collectionSlug, id);
|
|
47
|
+
response.parents = parents.map(toParentOption);
|
|
48
|
+
}
|
|
49
|
+
return response;
|
|
50
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CollectionEntryResponse } from '../../../../../utils/collections.js';
|
|
2
|
+
/** Partial update of a collection entry (including restore / move to trash). */
|
|
3
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<CollectionEntryResponse>>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam, readBody } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { findCollectionById, listCollectionParentOptions, loadCollectionSlugPath, updateCollection } from "@katecms/core";
|
|
4
|
+
import { getDb } from "../../../../utils/db.js";
|
|
5
|
+
import { requireUser } from "../../../../utils/session.js";
|
|
6
|
+
import { requireEntryPermission, requirePermission } from "../../../../utils/permissions.js";
|
|
7
|
+
import {
|
|
8
|
+
entryFlags,
|
|
9
|
+
fail,
|
|
10
|
+
readCollectionSlug,
|
|
11
|
+
readEntryId,
|
|
12
|
+
readFields,
|
|
13
|
+
readMenuOrder,
|
|
14
|
+
readParentId,
|
|
15
|
+
readPublishedAt,
|
|
16
|
+
readSlug,
|
|
17
|
+
readStatus,
|
|
18
|
+
readTitle,
|
|
19
|
+
requireCollection,
|
|
20
|
+
requirePublishedFields,
|
|
21
|
+
resolveAuthorId,
|
|
22
|
+
rethrowCollectionWriteError,
|
|
23
|
+
toAdminEntry,
|
|
24
|
+
toCollectionMeta,
|
|
25
|
+
toParentOption,
|
|
26
|
+
collectionRevisionsEnabled
|
|
27
|
+
} from "../../../../utils/collections.js";
|
|
28
|
+
import {
|
|
29
|
+
applyDictionaryAssignments,
|
|
30
|
+
loadCollectionDictionaryPickers,
|
|
31
|
+
selectedDictionaryIds
|
|
32
|
+
} from "../../../../utils/dictionaries.js";
|
|
33
|
+
import { entryRevisionSnapshot, recordEntryRevision } from "../../../../utils/revisions.js";
|
|
34
|
+
export default defineEventHandler(async (event) => {
|
|
35
|
+
const actor = await requireUser(event);
|
|
36
|
+
const collectionSlug = readCollectionSlug(getRouterParam(event, "collection"));
|
|
37
|
+
const id = readEntryId(getRouterParam(event, "id"));
|
|
38
|
+
const def = requireCollection(collectionSlug);
|
|
39
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {};
|
|
40
|
+
requirePermission(actor, "collections", "update", roles, collectionSlug);
|
|
41
|
+
const db = getDb();
|
|
42
|
+
const existing = await findCollectionById(db, id);
|
|
43
|
+
if (!existing || existing.type !== collectionSlug) {
|
|
44
|
+
fail(404, "Entry not found.");
|
|
45
|
+
}
|
|
46
|
+
requireEntryPermission(
|
|
47
|
+
actor,
|
|
48
|
+
"collections",
|
|
49
|
+
"update",
|
|
50
|
+
{ authorId: existing.author_id },
|
|
51
|
+
roles,
|
|
52
|
+
collectionSlug
|
|
53
|
+
);
|
|
54
|
+
const body = await readBody(event);
|
|
55
|
+
const patch = {};
|
|
56
|
+
if (body?.title !== void 0) {
|
|
57
|
+
patch.title = readTitle(body.title);
|
|
58
|
+
}
|
|
59
|
+
if (body?.slug !== void 0) {
|
|
60
|
+
patch.slug = readSlug(body.slug);
|
|
61
|
+
}
|
|
62
|
+
if (body?.fields !== void 0) {
|
|
63
|
+
patch.fields = readFields(body.fields);
|
|
64
|
+
}
|
|
65
|
+
if (body?.menuOrder !== void 0) {
|
|
66
|
+
patch.menu_order = readMenuOrder(body.menuOrder);
|
|
67
|
+
}
|
|
68
|
+
if (def.hierarchical === true && body?.parentId !== void 0) {
|
|
69
|
+
patch.parent_id = readParentId(body.parentId);
|
|
70
|
+
}
|
|
71
|
+
if (body?.status !== void 0) {
|
|
72
|
+
patch.status = readStatus(body.status, existing.status);
|
|
73
|
+
}
|
|
74
|
+
if (body?.publishedAt !== void 0) {
|
|
75
|
+
const publishedAt = readPublishedAt(body.publishedAt);
|
|
76
|
+
const nextStatus2 = patch.status ?? existing.status;
|
|
77
|
+
if (nextStatus2 === "published" && publishedAt == null) {
|
|
78
|
+
} else {
|
|
79
|
+
patch.published_at = publishedAt;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (body?.authorId !== void 0) {
|
|
83
|
+
patch.author_id = await resolveAuthorId(
|
|
84
|
+
db,
|
|
85
|
+
actor,
|
|
86
|
+
roles,
|
|
87
|
+
body.authorId,
|
|
88
|
+
existing.author_id ?? actor.id
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const nextStatus = patch.status ?? existing.status;
|
|
92
|
+
if (nextStatus === "published") {
|
|
93
|
+
const nextFields = patch.fields ?? existing.fields ?? {};
|
|
94
|
+
requirePublishedFields(def, nextStatus, nextFields);
|
|
95
|
+
}
|
|
96
|
+
const trackRevisions = collectionRevisionsEnabled(def);
|
|
97
|
+
const pickersBefore = await loadCollectionDictionaryPickers(db, collectionSlug);
|
|
98
|
+
const previous = trackRevisions ? entryRevisionSnapshot(existing, await selectedDictionaryIds(db, id, pickersBefore)) : null;
|
|
99
|
+
try {
|
|
100
|
+
const row = await updateCollection(db, id, patch);
|
|
101
|
+
if (!row) {
|
|
102
|
+
fail(404, "Entry not found.");
|
|
103
|
+
}
|
|
104
|
+
if (body?.dictionaries !== void 0) {
|
|
105
|
+
await applyDictionaryAssignments(db, id, collectionSlug, body.dictionaries);
|
|
106
|
+
}
|
|
107
|
+
const slugPath = await loadCollectionSlugPath(db, collectionSlug, id) || row.slug;
|
|
108
|
+
const flags = entryFlags(actor, row, roles);
|
|
109
|
+
const meta = toCollectionMeta(collectionSlug, def);
|
|
110
|
+
const pickers = pickersBefore;
|
|
111
|
+
const dictionaryIds = await selectedDictionaryIds(db, id, pickers);
|
|
112
|
+
if (trackRevisions && previous) {
|
|
113
|
+
await recordEntryRevision(db, id, actor.id, previous, entryRevisionSnapshot(row, dictionaryIds));
|
|
114
|
+
}
|
|
115
|
+
const response = {
|
|
116
|
+
collection: meta,
|
|
117
|
+
entry: toAdminEntry(row, slugPath, { ...flags, dictionaryIds }),
|
|
118
|
+
canUpdate: flags.canUpdate,
|
|
119
|
+
canDelete: flags.canDelete,
|
|
120
|
+
dictionaries: pickers
|
|
121
|
+
};
|
|
122
|
+
if (meta.hierarchical) {
|
|
123
|
+
const parents = await listCollectionParentOptions(db, collectionSlug, id);
|
|
124
|
+
response.parents = parents.map(toParentOption);
|
|
125
|
+
}
|
|
126
|
+
return response;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
rethrowCollectionWriteError(error);
|
|
129
|
+
}
|
|
130
|
+
});
|
package/dist/runtime/server/api/_katecms/collections/[collection]/revisions/[revisionId].post.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CollectionEntryResponse } from '../../../../../../utils/collections.js';
|
|
2
|
+
/** Replace an entry with a saved revision. The current state stays in the revision list. */
|
|
3
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<CollectionEntryResponse>>;
|
|
4
|
+
export default _default;
|
package/dist/runtime/server/api/_katecms/collections/[collection]/revisions/[revisionId].post.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import {
|
|
4
|
+
findCollectionById,
|
|
5
|
+
findCollectionRevisionById,
|
|
6
|
+
listCollectionParentOptions,
|
|
7
|
+
loadCollectionSlugPath,
|
|
8
|
+
updateCollection
|
|
9
|
+
} from "@katecms/core";
|
|
10
|
+
import { getDb } from "../../../../../utils/db.js";
|
|
11
|
+
import { requireUser } from "../../../../../utils/session.js";
|
|
12
|
+
import { requireEntryPermission, requirePermission } from "../../../../../utils/permissions.js";
|
|
13
|
+
import {
|
|
14
|
+
entryFlags,
|
|
15
|
+
fail,
|
|
16
|
+
readCollectionSlug,
|
|
17
|
+
readEntryId,
|
|
18
|
+
readFields,
|
|
19
|
+
readMenuOrder,
|
|
20
|
+
readPublishedAt,
|
|
21
|
+
readSlug,
|
|
22
|
+
readStatus,
|
|
23
|
+
readTitle,
|
|
24
|
+
requireCollection,
|
|
25
|
+
requirePublishedFields,
|
|
26
|
+
rethrowCollectionWriteError,
|
|
27
|
+
toAdminEntry,
|
|
28
|
+
toCollectionMeta,
|
|
29
|
+
toParentOption,
|
|
30
|
+
collectionRevisionsEnabled
|
|
31
|
+
} from "../../../../../utils/collections.js";
|
|
32
|
+
import {
|
|
33
|
+
applyDictionaryAssignments,
|
|
34
|
+
loadCollectionDictionaryPickers,
|
|
35
|
+
selectedDictionaryIds
|
|
36
|
+
} from "../../../../../utils/dictionaries.js";
|
|
37
|
+
import {
|
|
38
|
+
entryRevisionSnapshot,
|
|
39
|
+
readEntryRevisionData,
|
|
40
|
+
recordEntryRevision,
|
|
41
|
+
revisionAuthorId
|
|
42
|
+
} from "../../../../../utils/revisions.js";
|
|
43
|
+
export default defineEventHandler(async (event) => {
|
|
44
|
+
const actor = await requireUser(event);
|
|
45
|
+
const collectionSlug = readCollectionSlug(getRouterParam(event, "collection"));
|
|
46
|
+
const id = readEntryId(getRouterParam(event, "id"));
|
|
47
|
+
const revisionId = readRevisionId(getRouterParam(event, "revisionId"));
|
|
48
|
+
const def = requireCollection(collectionSlug);
|
|
49
|
+
if (!collectionRevisionsEnabled(def)) {
|
|
50
|
+
fail(404, "Revisions are disabled for this collection.");
|
|
51
|
+
}
|
|
52
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {};
|
|
53
|
+
requirePermission(actor, "collections", "update", roles, collectionSlug);
|
|
54
|
+
const db = getDb();
|
|
55
|
+
const existing = await findCollectionById(db, id);
|
|
56
|
+
if (!existing || existing.type !== collectionSlug) {
|
|
57
|
+
fail(404, "Entry not found.");
|
|
58
|
+
}
|
|
59
|
+
requireEntryPermission(
|
|
60
|
+
actor,
|
|
61
|
+
"collections",
|
|
62
|
+
"update",
|
|
63
|
+
{ authorId: existing.author_id },
|
|
64
|
+
roles,
|
|
65
|
+
collectionSlug
|
|
66
|
+
);
|
|
67
|
+
const revision = await findCollectionRevisionById(db, revisionId);
|
|
68
|
+
if (!revision || revision.collection_id !== id) {
|
|
69
|
+
fail(404, "Revision not found.");
|
|
70
|
+
}
|
|
71
|
+
const snapshot = readEntryRevisionData(revision.data);
|
|
72
|
+
const title = readTitle(snapshot.title);
|
|
73
|
+
const slug = readSlug(snapshot.slug);
|
|
74
|
+
const status = readStatus(snapshot.status, existing.status);
|
|
75
|
+
const fields = readFields(snapshot.fields);
|
|
76
|
+
requirePublishedFields(def, status, fields);
|
|
77
|
+
const publishedAt = readPublishedAt(snapshot.publishedAt);
|
|
78
|
+
const authorId = await revisionAuthorId(db, snapshot.authorId);
|
|
79
|
+
const pickers = await loadCollectionDictionaryPickers(db, collectionSlug);
|
|
80
|
+
const previous = entryRevisionSnapshot(existing, await selectedDictionaryIds(db, id, pickers));
|
|
81
|
+
try {
|
|
82
|
+
const row = await updateCollection(db, id, {
|
|
83
|
+
title,
|
|
84
|
+
slug,
|
|
85
|
+
status,
|
|
86
|
+
fields,
|
|
87
|
+
menu_order: readMenuOrder(snapshot.menuOrder, existing.menu_order),
|
|
88
|
+
published_at: publishedAt,
|
|
89
|
+
author_id: authorId,
|
|
90
|
+
...def.hierarchical === true ? { parent_id: snapshot.parentId } : {}
|
|
91
|
+
});
|
|
92
|
+
if (!row) {
|
|
93
|
+
fail(404, "Entry not found.");
|
|
94
|
+
}
|
|
95
|
+
await applyDictionaryAssignments(db, id, collectionSlug, snapshot.dictionaryIds);
|
|
96
|
+
const dictionaryIds = await selectedDictionaryIds(db, id, pickers);
|
|
97
|
+
await recordEntryRevision(db, id, actor.id, previous, entryRevisionSnapshot(row, dictionaryIds));
|
|
98
|
+
const slugPath = await loadCollectionSlugPath(db, collectionSlug, id) || row.slug;
|
|
99
|
+
const flags = entryFlags(actor, row, roles);
|
|
100
|
+
const meta = toCollectionMeta(collectionSlug, def);
|
|
101
|
+
const response = {
|
|
102
|
+
collection: meta,
|
|
103
|
+
entry: toAdminEntry(row, slugPath, { ...flags, dictionaryIds }),
|
|
104
|
+
canUpdate: flags.canUpdate,
|
|
105
|
+
canDelete: flags.canDelete,
|
|
106
|
+
dictionaries: pickers
|
|
107
|
+
};
|
|
108
|
+
if (meta.hierarchical) {
|
|
109
|
+
const parents = await listCollectionParentOptions(db, collectionSlug, id);
|
|
110
|
+
response.parents = parents.map(toParentOption);
|
|
111
|
+
}
|
|
112
|
+
return response;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
rethrowCollectionWriteError(error);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
function readRevisionId(raw) {
|
|
118
|
+
const id = Number(raw);
|
|
119
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
120
|
+
fail(400, "Invalid revision.");
|
|
121
|
+
}
|
|
122
|
+
return id;
|
|
123
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EntryRevisionItem } from '../../../../../utils/collections.js';
|
|
2
|
+
/** Saved versions of one collection entry. */
|
|
3
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
4
|
+
revisions: EntryRevisionItem[];
|
|
5
|
+
}>>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { findCollectionById } from "@katecms/core";
|
|
4
|
+
import { getDb } from "../../../../utils/db.js";
|
|
5
|
+
import { requireUser } from "../../../../utils/session.js";
|
|
6
|
+
import { requirePermission } from "../../../../utils/permissions.js";
|
|
7
|
+
import {
|
|
8
|
+
fail,
|
|
9
|
+
readCollectionSlug,
|
|
10
|
+
readEntryId,
|
|
11
|
+
requireCollection,
|
|
12
|
+
collectionRevisionsEnabled
|
|
13
|
+
} from "../../../../utils/collections.js";
|
|
14
|
+
import { listEntryRevisions } from "../../../../utils/revisions.js";
|
|
15
|
+
export default defineEventHandler(async (event) => {
|
|
16
|
+
const actor = await requireUser(event);
|
|
17
|
+
const collectionSlug = readCollectionSlug(getRouterParam(event, "collection"));
|
|
18
|
+
const id = readEntryId(getRouterParam(event, "id"));
|
|
19
|
+
const def = requireCollection(collectionSlug);
|
|
20
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {};
|
|
21
|
+
requirePermission(actor, "collections", "read", roles, collectionSlug);
|
|
22
|
+
const db = getDb();
|
|
23
|
+
const existing = await findCollectionById(db, id);
|
|
24
|
+
if (!existing || existing.type !== collectionSlug) {
|
|
25
|
+
fail(404, "Entry not found.");
|
|
26
|
+
}
|
|
27
|
+
if (!collectionRevisionsEnabled(def)) {
|
|
28
|
+
return { revisions: [] };
|
|
29
|
+
}
|
|
30
|
+
return { revisions: await listEntryRevisions(db, id) };
|
|
31
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CollectionListResponse } from '../../../../utils/collections.js';
|
|
2
|
+
/**
|
|
3
|
+
* List collection entries. Query: `status` (all|published|draft|trash),
|
|
4
|
+
* `q`, `month` (`YYYY-MM`), `sort`, `tz` (UTC offset minutes), `page`, `perPage`.
|
|
5
|
+
* Default `status=all` excludes trash. Default sort is newest list date.
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<CollectionListResponse>>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, getRouterParam } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import {
|
|
4
|
+
buildSlugPathMap,
|
|
5
|
+
can,
|
|
6
|
+
collectionListPaging,
|
|
7
|
+
collectionPerPage,
|
|
8
|
+
countCollections,
|
|
9
|
+
countCollectionStatuses,
|
|
10
|
+
flattenCollectionTree,
|
|
11
|
+
COLLECTION_LIST_SORTS,
|
|
12
|
+
isUnlimitedPerPage,
|
|
13
|
+
listCollectionMonths,
|
|
14
|
+
listCollectionParentOptions,
|
|
15
|
+
listCollections
|
|
16
|
+
} from "@katecms/core";
|
|
17
|
+
import { getDb } from "../../../utils/db.js";
|
|
18
|
+
import { requireUser } from "../../../utils/session.js";
|
|
19
|
+
import { requirePermission } from "../../../utils/permissions.js";
|
|
20
|
+
import {
|
|
21
|
+
entryFlags,
|
|
22
|
+
readCollectionSlug,
|
|
23
|
+
readListStatus,
|
|
24
|
+
readPage,
|
|
25
|
+
readPerPage,
|
|
26
|
+
readSearch,
|
|
27
|
+
requireCollection,
|
|
28
|
+
toAdminEntry,
|
|
29
|
+
toCollectionMeta,
|
|
30
|
+
toParentOption
|
|
31
|
+
} from "../../../utils/collections.js";
|
|
32
|
+
import { loadCollectionDictionaryPickers } from "../../../utils/dictionaries.js";
|
|
33
|
+
function pageCollectionTree(tree, page, perPage) {
|
|
34
|
+
if (isUnlimitedPerPage(perPage)) {
|
|
35
|
+
return tree;
|
|
36
|
+
}
|
|
37
|
+
return tree.slice((page - 1) * perPage, page * perPage);
|
|
38
|
+
}
|
|
39
|
+
function readRaw(value) {
|
|
40
|
+
const raw = Array.isArray(value) ? value[0] : value;
|
|
41
|
+
return typeof raw === "string" ? raw.trim() : "";
|
|
42
|
+
}
|
|
43
|
+
function readMonth(value) {
|
|
44
|
+
const raw = readRaw(value);
|
|
45
|
+
return /^\d{4}-(0[1-9]|1[0-2])$/.test(raw) ? raw : "";
|
|
46
|
+
}
|
|
47
|
+
function readOffset(value) {
|
|
48
|
+
const raw = readRaw(value);
|
|
49
|
+
if (!raw) {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
const n = Number(raw);
|
|
53
|
+
if (!Number.isInteger(n)) {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
return Math.max(-14 * 60, Math.min(14 * 60, n));
|
|
57
|
+
}
|
|
58
|
+
function readSort(value) {
|
|
59
|
+
const raw = readRaw(value);
|
|
60
|
+
return COLLECTION_LIST_SORTS.includes(raw) ? raw : "date-desc";
|
|
61
|
+
}
|
|
62
|
+
export default defineEventHandler(async (event) => {
|
|
63
|
+
const actor = await requireUser(event);
|
|
64
|
+
const collectionSlug = readCollectionSlug(getRouterParam(event, "collection"));
|
|
65
|
+
const def = requireCollection(collectionSlug);
|
|
66
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {};
|
|
67
|
+
requirePermission(actor, "collections", "read", roles, collectionSlug);
|
|
68
|
+
const query = getQuery(event);
|
|
69
|
+
const listStatus = readListStatus(query.status);
|
|
70
|
+
const search = readSearch(query.q);
|
|
71
|
+
const month = readMonth(query.month);
|
|
72
|
+
const offsetMinutes = readOffset(query.tz);
|
|
73
|
+
const sort = readSort(query.sort);
|
|
74
|
+
const page = readPage(query.page);
|
|
75
|
+
const perPage = readPerPage(query.perPage, collectionPerPage(def));
|
|
76
|
+
const db = getDb();
|
|
77
|
+
const meta = toCollectionMeta(collectionSlug, def);
|
|
78
|
+
const paging = meta.hierarchical ? {} : collectionListPaging(page, perPage);
|
|
79
|
+
const listOptions = {
|
|
80
|
+
status: listStatus,
|
|
81
|
+
search,
|
|
82
|
+
month,
|
|
83
|
+
offsetMinutes,
|
|
84
|
+
sort
|
|
85
|
+
};
|
|
86
|
+
const [rows, total, counts, pathRows, months] = await Promise.all([
|
|
87
|
+
listCollections(db, collectionSlug, {
|
|
88
|
+
...listOptions,
|
|
89
|
+
...paging
|
|
90
|
+
}),
|
|
91
|
+
countCollections(db, collectionSlug, listOptions),
|
|
92
|
+
countCollectionStatuses(db, collectionSlug),
|
|
93
|
+
db.selectFrom("collections").select(["id", "slug", "parent_id"]).where("type", "=", collectionSlug).execute(),
|
|
94
|
+
listCollectionMonths(db, collectionSlug, {
|
|
95
|
+
status: listStatus,
|
|
96
|
+
search,
|
|
97
|
+
offsetMinutes
|
|
98
|
+
})
|
|
99
|
+
]);
|
|
100
|
+
const paths = buildSlugPathMap(pathRows);
|
|
101
|
+
const listed = meta.hierarchical ? pageCollectionTree(flattenCollectionTree(rows), page, perPage) : rows.map((row) => ({ row, depth: 0 }));
|
|
102
|
+
const authorIds = [...new Set(
|
|
103
|
+
listed.map(({ row }) => row.author_id).filter((id) => id != null)
|
|
104
|
+
)];
|
|
105
|
+
const authors = authorIds.length > 0 ? await db.selectFrom("users").select(["id", "name", "email"]).where("id", "in", authorIds).execute() : [];
|
|
106
|
+
const authorNameById = new Map(
|
|
107
|
+
authors.map((user) => [user.id, user.name?.trim() || user.email])
|
|
108
|
+
);
|
|
109
|
+
const response = {
|
|
110
|
+
collection: meta,
|
|
111
|
+
entries: listed.map(({ row, depth }) => toAdminEntry(
|
|
112
|
+
row,
|
|
113
|
+
paths.get(row.id) ?? row.slug,
|
|
114
|
+
{
|
|
115
|
+
...entryFlags(actor, row, roles),
|
|
116
|
+
authorName: row.author_id != null ? authorNameById.get(row.author_id) ?? null : null,
|
|
117
|
+
...meta.hierarchical ? { depth } : {}
|
|
118
|
+
}
|
|
119
|
+
)),
|
|
120
|
+
counts,
|
|
121
|
+
months,
|
|
122
|
+
page,
|
|
123
|
+
perPage,
|
|
124
|
+
total,
|
|
125
|
+
canCreate: can(actor, "collections", "create", { roles, scope: collectionSlug }),
|
|
126
|
+
canUpdate: can(actor, "collections", "update", { roles, scope: collectionSlug }),
|
|
127
|
+
canDelete: can(actor, "collections", "delete", { roles, scope: collectionSlug })
|
|
128
|
+
};
|
|
129
|
+
response.dictionaries = await loadCollectionDictionaryPickers(db, collectionSlug);
|
|
130
|
+
if (meta.hierarchical) {
|
|
131
|
+
const parents = await listCollectionParentOptions(db, collectionSlug);
|
|
132
|
+
response.parents = parents.map(toParentOption);
|
|
133
|
+
}
|
|
134
|
+
return response;
|
|
135
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CollectionEntryResponse } from '../../../../utils/collections.js';
|
|
2
|
+
/** Create an entry in the given collection. */
|
|
3
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<CollectionEntryResponse>>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam, readBody } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { createCollection, listCollectionParentOptions, loadCollectionSlugPath } from "@katecms/core";
|
|
4
|
+
import { getDb } from "../../../utils/db.js";
|
|
5
|
+
import { requireUser } from "../../../utils/session.js";
|
|
6
|
+
import { requirePermission } from "../../../utils/permissions.js";
|
|
7
|
+
import {
|
|
8
|
+
entryFlags,
|
|
9
|
+
fail,
|
|
10
|
+
readCollectionSlug,
|
|
11
|
+
readFields,
|
|
12
|
+
readMenuOrder,
|
|
13
|
+
readParentId,
|
|
14
|
+
readPublishedAt,
|
|
15
|
+
readSlug,
|
|
16
|
+
readStatus,
|
|
17
|
+
readTitle,
|
|
18
|
+
requireCollection,
|
|
19
|
+
requirePublishedFields,
|
|
20
|
+
resolveAuthorId,
|
|
21
|
+
rethrowCollectionWriteError,
|
|
22
|
+
toAdminEntry,
|
|
23
|
+
toCollectionMeta,
|
|
24
|
+
toParentOption,
|
|
25
|
+
collectionRevisionsEnabled
|
|
26
|
+
} from "../../../utils/collections.js";
|
|
27
|
+
import {
|
|
28
|
+
applyDictionaryAssignments,
|
|
29
|
+
loadCollectionDictionaryPickers,
|
|
30
|
+
selectedDictionaryIds
|
|
31
|
+
} from "../../../utils/dictionaries.js";
|
|
32
|
+
import { entryRevisionSnapshot, recordEntryRevision } from "../../../utils/revisions.js";
|
|
33
|
+
export default defineEventHandler(async (event) => {
|
|
34
|
+
const actor = await requireUser(event);
|
|
35
|
+
const collectionSlug = readCollectionSlug(getRouterParam(event, "collection"));
|
|
36
|
+
const def = requireCollection(collectionSlug);
|
|
37
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {};
|
|
38
|
+
requirePermission(actor, "collections", "create", roles, collectionSlug);
|
|
39
|
+
const body = await readBody(event);
|
|
40
|
+
const title = readTitle(body?.title);
|
|
41
|
+
const slug = readSlug(body?.slug);
|
|
42
|
+
const status = readStatus(body?.status, "published");
|
|
43
|
+
const fields = readFields(body?.fields);
|
|
44
|
+
const parentId = def.hierarchical === true ? readParentId(body?.parentId) : null;
|
|
45
|
+
const menuOrder = readMenuOrder(body?.menuOrder, 0);
|
|
46
|
+
const publishedAt = readPublishedAt(body?.publishedAt);
|
|
47
|
+
const db = getDb();
|
|
48
|
+
const authorId = await resolveAuthorId(db, actor, roles, body?.authorId, actor.id);
|
|
49
|
+
if (status === "trash") {
|
|
50
|
+
fail(422, "New entries cannot be created in the trash.");
|
|
51
|
+
}
|
|
52
|
+
requirePublishedFields(def, status, fields);
|
|
53
|
+
try {
|
|
54
|
+
const row = await createCollection(db, {
|
|
55
|
+
type: collectionSlug,
|
|
56
|
+
title,
|
|
57
|
+
slug,
|
|
58
|
+
status,
|
|
59
|
+
fields,
|
|
60
|
+
parent_id: parentId,
|
|
61
|
+
menu_order: menuOrder,
|
|
62
|
+
author_id: authorId,
|
|
63
|
+
...publishedAt !== void 0 ? { published_at: publishedAt } : {}
|
|
64
|
+
});
|
|
65
|
+
if (body?.dictionaries !== void 0) {
|
|
66
|
+
await applyDictionaryAssignments(db, row.id, collectionSlug, body.dictionaries);
|
|
67
|
+
}
|
|
68
|
+
const slugPath = await loadCollectionSlugPath(db, collectionSlug, row.id) || row.slug;
|
|
69
|
+
const flags = entryFlags(actor, row, roles);
|
|
70
|
+
const meta = toCollectionMeta(collectionSlug, def);
|
|
71
|
+
const pickers = await loadCollectionDictionaryPickers(db, collectionSlug);
|
|
72
|
+
const dictionaryIds = await selectedDictionaryIds(db, row.id, pickers);
|
|
73
|
+
if (collectionRevisionsEnabled(def)) {
|
|
74
|
+
await recordEntryRevision(db, row.id, actor.id, null, entryRevisionSnapshot(row, dictionaryIds));
|
|
75
|
+
}
|
|
76
|
+
const response = {
|
|
77
|
+
collection: meta,
|
|
78
|
+
entry: toAdminEntry(row, slugPath, { ...flags, dictionaryIds }),
|
|
79
|
+
canUpdate: flags.canUpdate,
|
|
80
|
+
canDelete: flags.canDelete,
|
|
81
|
+
dictionaries: pickers
|
|
82
|
+
};
|
|
83
|
+
if (meta.hierarchical) {
|
|
84
|
+
const parents = await listCollectionParentOptions(db, collectionSlug, row.id);
|
|
85
|
+
response.parents = parents.map(toParentOption);
|
|
86
|
+
}
|
|
87
|
+
return response;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
rethrowCollectionWriteError(error);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AdminDictionaryMeta } from '../../../../../utils/dictionaries.js';
|
|
2
|
+
/** Permanently delete a dictionary term. Child terms become top-level. */
|
|
3
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
4
|
+
dictionary: AdminDictionaryMeta;
|
|
5
|
+
ok: true;
|
|
6
|
+
}>>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineEventHandler, getRouterParam } from "h3";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { deleteDictionary, findDictionaryById } from "@katecms/core";
|
|
4
|
+
import { getDb } from "../../../../utils/db.js";
|
|
5
|
+
import { requireUser } from "../../../../utils/session.js";
|
|
6
|
+
import { requirePermission } from "../../../../utils/permissions.js";
|
|
7
|
+
import {
|
|
8
|
+
fail,
|
|
9
|
+
readDictionarySlug,
|
|
10
|
+
readEntryId,
|
|
11
|
+
requireDictionary,
|
|
12
|
+
toDictionaryMeta
|
|
13
|
+
} from "../../../../utils/dictionaries.js";
|
|
14
|
+
export default defineEventHandler(async (event) => {
|
|
15
|
+
const actor = await requireUser(event);
|
|
16
|
+
const dictionarySlug = readDictionarySlug(getRouterParam(event, "dictionary"));
|
|
17
|
+
const id = readEntryId(getRouterParam(event, "id"));
|
|
18
|
+
const def = requireDictionary(dictionarySlug);
|
|
19
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {};
|
|
20
|
+
requirePermission(actor, "dictionaries", "delete", roles, dictionarySlug);
|
|
21
|
+
const db = getDb();
|
|
22
|
+
const existing = await findDictionaryById(db, id);
|
|
23
|
+
if (!existing || existing.type !== dictionarySlug) {
|
|
24
|
+
fail(404, "Term not found.");
|
|
25
|
+
}
|
|
26
|
+
await deleteDictionary(db, id);
|
|
27
|
+
return {
|
|
28
|
+
dictionary: toDictionaryMeta(dictionarySlug, def),
|
|
29
|
+
ok: true
|
|
30
|
+
};
|
|
31
|
+
});
|