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,332 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from 'h3'
|
|
2
|
+
import { useRuntimeConfig } from '#imports'
|
|
3
|
+
import {
|
|
4
|
+
buildSlugPathMap,
|
|
5
|
+
can,
|
|
6
|
+
collectionListPaging,
|
|
7
|
+
collectionPerPage,
|
|
8
|
+
countQueryCollections,
|
|
9
|
+
DEFAULT_COLLECTION_PER_PAGE,
|
|
10
|
+
isCollectionQueryOrderBy,
|
|
11
|
+
parseDictionaryQuery,
|
|
12
|
+
parseFieldsQuery,
|
|
13
|
+
queryCollections,
|
|
14
|
+
} from '@katecms/core'
|
|
15
|
+
import type {
|
|
16
|
+
CollectionDefinition,
|
|
17
|
+
CollectionQueryOrderBy,
|
|
18
|
+
Collections,
|
|
19
|
+
DictionaryQuery,
|
|
20
|
+
FieldsQuery,
|
|
21
|
+
QueryCollectionsOptions,
|
|
22
|
+
} from '@katecms/core'
|
|
23
|
+
import { getDb } from '../../utils/db'
|
|
24
|
+
import { rejectPublicRegexp } from '../../utils/public-fields-query'
|
|
25
|
+
import { getCurrentUser } from '../../utils/session'
|
|
26
|
+
import {
|
|
27
|
+
fail,
|
|
28
|
+
getCollectionDefinition,
|
|
29
|
+
getCollections,
|
|
30
|
+
readPage,
|
|
31
|
+
readPerPage,
|
|
32
|
+
readSearch,
|
|
33
|
+
toAdminEntry,
|
|
34
|
+
toCollectionMeta,
|
|
35
|
+
} from '../../utils/collections'
|
|
36
|
+
import { loadAssignedEntryDictionaries } from '../../utils/dictionaries'
|
|
37
|
+
import {
|
|
38
|
+
isTruthyQueryParam,
|
|
39
|
+
parsePublicStatusParam,
|
|
40
|
+
resolvePublicStatuses,
|
|
41
|
+
} from '../../../utils/preview'
|
|
42
|
+
import type { QueryCollectionResponse } from '../../../utils/collections'
|
|
43
|
+
|
|
44
|
+
const ORDER_ALIASES: Record<string, CollectionQueryOrderBy> = {
|
|
45
|
+
date: 'published_at',
|
|
46
|
+
modified: 'updated_at',
|
|
47
|
+
name: 'slug',
|
|
48
|
+
ID: 'id',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function firstQueryValue(value: unknown): unknown {
|
|
52
|
+
return Array.isArray(value) ? value[0] : value
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function hasQueryParam(query: Record<string, unknown>, keys: string[]): boolean {
|
|
56
|
+
return keys.some(key => query[key] !== undefined)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function readStringList(value: unknown): string[] {
|
|
60
|
+
const parts = Array.isArray(value) ? value : typeof value === 'string' ? value.split(',') : []
|
|
61
|
+
return [...new Set(parts.map(item => String(item).trim()).filter(Boolean))]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function readIdList(value: unknown): number[] {
|
|
65
|
+
const parts = Array.isArray(value) ? value : typeof value === 'string' ? value.split(',') : value == null ? [] : [value]
|
|
66
|
+
const ids: number[] = []
|
|
67
|
+
const seen = new Set<number>()
|
|
68
|
+
for (const part of parts) {
|
|
69
|
+
const n = Number(part)
|
|
70
|
+
if (!Number.isInteger(n) || n < 1 || seen.has(n)) {
|
|
71
|
+
continue
|
|
72
|
+
}
|
|
73
|
+
seen.add(n)
|
|
74
|
+
ids.push(n)
|
|
75
|
+
}
|
|
76
|
+
return ids
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function readParentIdList(value: unknown): number[] {
|
|
80
|
+
const parts = Array.isArray(value) ? value : typeof value === 'string' ? value.split(',') : value == null ? [] : [value]
|
|
81
|
+
const ids: number[] = []
|
|
82
|
+
const seen = new Set<number>()
|
|
83
|
+
for (const part of parts) {
|
|
84
|
+
if (part === null || part === 'null') {
|
|
85
|
+
if (!seen.has(0)) {
|
|
86
|
+
seen.add(0)
|
|
87
|
+
ids.push(0)
|
|
88
|
+
}
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
if (part === '') {
|
|
92
|
+
continue
|
|
93
|
+
}
|
|
94
|
+
const n = Number(part)
|
|
95
|
+
if (!Number.isInteger(n) || n < 0 || seen.has(n)) {
|
|
96
|
+
continue
|
|
97
|
+
}
|
|
98
|
+
seen.add(n)
|
|
99
|
+
ids.push(n)
|
|
100
|
+
}
|
|
101
|
+
return ids
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function readOrderBy(value: unknown): CollectionQueryOrderBy | undefined {
|
|
105
|
+
const raw = firstQueryValue(value)
|
|
106
|
+
if (typeof raw !== 'string' || !raw.trim()) {
|
|
107
|
+
return undefined
|
|
108
|
+
}
|
|
109
|
+
const token = raw.trim()
|
|
110
|
+
if (token === 'includeIds') {
|
|
111
|
+
return 'includeIds'
|
|
112
|
+
}
|
|
113
|
+
const mapped = ORDER_ALIASES[token] ?? token
|
|
114
|
+
return isCollectionQueryOrderBy(mapped) ? mapped : undefined
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function readOrder(value: unknown): 'asc' | 'desc' | undefined {
|
|
118
|
+
const raw = firstQueryValue(value)
|
|
119
|
+
if (typeof raw !== 'string') {
|
|
120
|
+
return undefined
|
|
121
|
+
}
|
|
122
|
+
const token = raw.trim().toLowerCase()
|
|
123
|
+
if (token === 'asc' || token === 'desc') {
|
|
124
|
+
return token
|
|
125
|
+
}
|
|
126
|
+
return undefined
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function readDictionaryQuery(value: unknown): DictionaryQuery | undefined {
|
|
130
|
+
const raw = firstQueryValue(value)
|
|
131
|
+
if (raw == null || raw === '') {
|
|
132
|
+
return undefined
|
|
133
|
+
}
|
|
134
|
+
let parsed: unknown = raw
|
|
135
|
+
if (typeof raw === 'string') {
|
|
136
|
+
try {
|
|
137
|
+
parsed = JSON.parse(raw)
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
fail(400, 'Invalid dictionaryQuery.')
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (typeof parsed !== 'object' || parsed == null || Array.isArray(parsed)) {
|
|
144
|
+
fail(400, 'Invalid dictionaryQuery.')
|
|
145
|
+
}
|
|
146
|
+
return parseDictionaryQuery(parsed)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function readFieldsQuery(value: unknown): FieldsQuery | undefined {
|
|
150
|
+
const raw = firstQueryValue(value)
|
|
151
|
+
if (raw == null || raw === '') {
|
|
152
|
+
return undefined
|
|
153
|
+
}
|
|
154
|
+
let parsed: unknown = raw
|
|
155
|
+
if (typeof raw === 'string') {
|
|
156
|
+
try {
|
|
157
|
+
parsed = JSON.parse(raw)
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
fail(400, 'Invalid fieldsQuery.')
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (typeof parsed !== 'object' || parsed == null || Array.isArray(parsed)) {
|
|
164
|
+
fail(400, 'Invalid fieldsQuery.')
|
|
165
|
+
}
|
|
166
|
+
return rejectPublicRegexp(parseFieldsQuery(parsed))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function defaultPerPage(defs: CollectionDefinition[]): number {
|
|
170
|
+
if (defs.length === 1) {
|
|
171
|
+
return collectionPerPage(defs[0])
|
|
172
|
+
}
|
|
173
|
+
return DEFAULT_COLLECTION_PER_PAGE
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function publicCollectionSlugs(all: Collections): string[] {
|
|
177
|
+
return Object.keys(all).filter(slug => all[slug]?.public !== false)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function resolveQueryCollectionTypes(requested: string[], all: Collections): string[] {
|
|
181
|
+
if (requested.includes('any')) {
|
|
182
|
+
return publicCollectionSlugs(all)
|
|
183
|
+
}
|
|
184
|
+
return requested.filter((slug) => {
|
|
185
|
+
const def = all[slug]
|
|
186
|
+
return def != null && def.public !== false
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Public list query.
|
|
192
|
+
*
|
|
193
|
+
* Query:
|
|
194
|
+
* - `collection` (required) — comma-separated collection slugs, or `any`
|
|
195
|
+
* for every public collection
|
|
196
|
+
* - `preview` — `1`/`true`/`yes` to include drafts when the requester may
|
|
197
|
+
* `collections:read` every queried collection
|
|
198
|
+
* - `status` — `published`, `draft`, or comma-separated; `draft` is ignored
|
|
199
|
+
* unless preview is granted. Trash is never returned.
|
|
200
|
+
* - `page`, `perPage`
|
|
201
|
+
* - `search`, `title`, `includeIds`, `excludeIds`
|
|
202
|
+
* - `parentId` (`0` = top-level), `parentIds`, `excludeParentIds`
|
|
203
|
+
* - `authorIn`, `authorNotIn`, `slug`, `slugs`
|
|
204
|
+
* - `dictionaryQuery` — JSON object (`relation` + `queries`)
|
|
205
|
+
* - `fieldsQuery` — JSON object (`relation` + `queries`) against `fields`.
|
|
206
|
+
* `REGEXP` and `NOT REGEXP` are rejected.
|
|
207
|
+
* - `orderBy` (`date`, `modified`, `name`, `includeIds`, or a column), `order`
|
|
208
|
+
*
|
|
209
|
+
* Collections with `public: false` are skipped. Unknown types are skipped.
|
|
210
|
+
*/
|
|
211
|
+
export default defineEventHandler(async (event): Promise<QueryCollectionResponse> => {
|
|
212
|
+
const query = getQuery(event) as Record<string, unknown>
|
|
213
|
+
const requested = readStringList(query.collection)
|
|
214
|
+
if (requested.length === 0) {
|
|
215
|
+
fail(400, 'Missing collection.')
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const all = getCollections()
|
|
219
|
+
const types = resolveQueryCollectionTypes(requested, all)
|
|
220
|
+
const defs = types
|
|
221
|
+
.map(slug => getCollectionDefinition(slug))
|
|
222
|
+
.filter((def): def is CollectionDefinition => def != null)
|
|
223
|
+
|
|
224
|
+
if (types.length === 0) {
|
|
225
|
+
return {
|
|
226
|
+
entries: [],
|
|
227
|
+
collections: [],
|
|
228
|
+
preview: false,
|
|
229
|
+
page: readPage(query.page),
|
|
230
|
+
perPage: readPerPage(query.perPage, DEFAULT_COLLECTION_PER_PAGE),
|
|
231
|
+
total: 0,
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const previewRequested = isTruthyQueryParam(query.preview)
|
|
236
|
+
const actor = previewRequested ? await getCurrentUser(event) : null
|
|
237
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {}
|
|
238
|
+
const previewAllowed = actor != null
|
|
239
|
+
&& types.every(slug => can(actor, 'collections', 'read', { roles, scope: slug }))
|
|
240
|
+
|
|
241
|
+
const { statuses, preview } = resolvePublicStatuses({
|
|
242
|
+
previewRequested,
|
|
243
|
+
previewAllowed,
|
|
244
|
+
requested: parsePublicStatusParam(query.status),
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
const page = readPage(query.page)
|
|
248
|
+
const perPage = readPerPage(query.perPage, defaultPerPage(defs))
|
|
249
|
+
const filters: QueryCollectionsOptions = {
|
|
250
|
+
types,
|
|
251
|
+
statuses,
|
|
252
|
+
search: readSearch(query.search) || undefined,
|
|
253
|
+
...collectionListPaging(page, perPage),
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (hasQueryParam(query, ['title'])) {
|
|
257
|
+
filters.title = readStringList(query.title)
|
|
258
|
+
}
|
|
259
|
+
if (hasQueryParam(query, ['includeIds'])) {
|
|
260
|
+
filters.includeIds = readIdList(query.includeIds)
|
|
261
|
+
}
|
|
262
|
+
if (hasQueryParam(query, ['excludeIds'])) {
|
|
263
|
+
filters.excludeIds = readIdList(query.excludeIds)
|
|
264
|
+
}
|
|
265
|
+
if (hasQueryParam(query, ['parentId', 'parentIds'])) {
|
|
266
|
+
filters.parentIds = [
|
|
267
|
+
...readParentIdList(query.parentIds),
|
|
268
|
+
...readParentIdList(query.parentId),
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
if (hasQueryParam(query, ['excludeParentIds'])) {
|
|
272
|
+
filters.excludeParentIds = readParentIdList(query.excludeParentIds)
|
|
273
|
+
}
|
|
274
|
+
if (hasQueryParam(query, ['authorIn'])) {
|
|
275
|
+
filters.authorIn = readIdList(query.authorIn)
|
|
276
|
+
}
|
|
277
|
+
if (hasQueryParam(query, ['authorNotIn'])) {
|
|
278
|
+
filters.authorNotIn = readIdList(query.authorNotIn)
|
|
279
|
+
}
|
|
280
|
+
if (hasQueryParam(query, ['slug', 'slugs'])) {
|
|
281
|
+
filters.slugs = [
|
|
282
|
+
...readStringList(query.slugs),
|
|
283
|
+
...readStringList(query.slug),
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
if (hasQueryParam(query, ['dictionaryQuery'])) {
|
|
287
|
+
filters.dictionaryQuery = readDictionaryQuery(query.dictionaryQuery)
|
|
288
|
+
}
|
|
289
|
+
if (hasQueryParam(query, ['fieldsQuery'])) {
|
|
290
|
+
filters.fieldsQuery = readFieldsQuery(query.fieldsQuery)
|
|
291
|
+
}
|
|
292
|
+
filters.orderBy = readOrderBy(query.orderBy) ?? 'published_at'
|
|
293
|
+
const order = readOrder(query.order)
|
|
294
|
+
if (order) {
|
|
295
|
+
filters.order = order
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const db = getDb()
|
|
299
|
+
const [rows, total, pathRows] = await Promise.all([
|
|
300
|
+
queryCollections(db, filters),
|
|
301
|
+
countQueryCollections(db, filters),
|
|
302
|
+
db.selectFrom('collections')
|
|
303
|
+
.select(['id', 'slug', 'parent_id', 'type'])
|
|
304
|
+
.where('type', 'in', types)
|
|
305
|
+
.execute(),
|
|
306
|
+
])
|
|
307
|
+
|
|
308
|
+
const pathsByType = new Map<string, ReturnType<typeof buildSlugPathMap>>()
|
|
309
|
+
for (const type of types) {
|
|
310
|
+
pathsByType.set(
|
|
311
|
+
type,
|
|
312
|
+
buildSlugPathMap(pathRows.filter(row => row.type === type)),
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const entries = await Promise.all(rows.map(async (row) => {
|
|
317
|
+
const dictionaries = await loadAssignedEntryDictionaries(db, row.id, row.type)
|
|
318
|
+
return toAdminEntry(row, pathsByType.get(row.type)?.get(row.id) ?? row.slug, { dictionaries })
|
|
319
|
+
}))
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
entries,
|
|
323
|
+
collections: types.flatMap((slug) => {
|
|
324
|
+
const def = getCollectionDefinition(slug)
|
|
325
|
+
return def ? [toCollectionMeta(slug, def)] : []
|
|
326
|
+
}),
|
|
327
|
+
preview,
|
|
328
|
+
page,
|
|
329
|
+
perPage,
|
|
330
|
+
total,
|
|
331
|
+
}
|
|
332
|
+
})
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from 'h3'
|
|
2
|
+
import { useRuntimeConfig } from '#imports'
|
|
3
|
+
import {
|
|
4
|
+
can,
|
|
5
|
+
listCollections,
|
|
6
|
+
} from '@katecms/core'
|
|
7
|
+
import { getDb } from '../../../utils/db'
|
|
8
|
+
import { requireUser } from '../../../utils/session'
|
|
9
|
+
import { getCollections, fail } from '../../../utils/collections'
|
|
10
|
+
import {
|
|
11
|
+
RELATION_PICKER_LIMIT,
|
|
12
|
+
collectionArchiveOption,
|
|
13
|
+
pathMapForRows,
|
|
14
|
+
pickFeaturedImage,
|
|
15
|
+
readStringList,
|
|
16
|
+
toPickerEntry,
|
|
17
|
+
} from '../../../utils/relation'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Collection entries for `post_object`, `page_link`, and `relationship`.
|
|
21
|
+
* Query: `postType` (comma-separated slugs), `q`, `elements` (image field keys), `archives=1`.
|
|
22
|
+
* Lists published and draft entries (not trash).
|
|
23
|
+
*/
|
|
24
|
+
export default defineEventHandler(async (event) => {
|
|
25
|
+
const actor = await requireUser(event)
|
|
26
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {}
|
|
27
|
+
const collections = getCollections()
|
|
28
|
+
const query = getQuery(event)
|
|
29
|
+
const requested = readStringList(query.postType)
|
|
30
|
+
const wanted = requested.length > 0
|
|
31
|
+
? requested.filter(slug => slug in collections)
|
|
32
|
+
: Object.keys(collections)
|
|
33
|
+
if (requested.length > 0 && wanted.length === 0) {
|
|
34
|
+
fail(404, 'Collection not found.')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const readable = wanted.filter(slug => can(actor, 'collections', 'read', { roles, scope: slug }))
|
|
38
|
+
const search = typeof query.q === 'string' ? query.q.trim() : ''
|
|
39
|
+
const imageFields = readStringList(query.elements)
|
|
40
|
+
const db = getDb()
|
|
41
|
+
const entries = []
|
|
42
|
+
|
|
43
|
+
for (const slug of readable) {
|
|
44
|
+
const def = collections[slug]
|
|
45
|
+
if (!def) {
|
|
46
|
+
continue
|
|
47
|
+
}
|
|
48
|
+
const rows = await listCollections(db, slug, {
|
|
49
|
+
status: 'active',
|
|
50
|
+
search: search || undefined,
|
|
51
|
+
limit: RELATION_PICKER_LIMIT,
|
|
52
|
+
})
|
|
53
|
+
const dictionarySlugs = readStringList(query.dictionary)
|
|
54
|
+
let filtered = rows
|
|
55
|
+
const ids = rows.map(row => row.id)
|
|
56
|
+
const termIdsByEntry = new Map<number, number[]>()
|
|
57
|
+
if (ids.length > 0) {
|
|
58
|
+
const links = await db
|
|
59
|
+
.selectFrom('collection_dictionaries')
|
|
60
|
+
.select(['collection_id', 'dictionary_id'])
|
|
61
|
+
.where('collection_id', 'in', ids)
|
|
62
|
+
.execute()
|
|
63
|
+
for (const link of links) {
|
|
64
|
+
const current = termIdsByEntry.get(link.collection_id) ?? []
|
|
65
|
+
current.push(link.dictionary_id)
|
|
66
|
+
termIdsByEntry.set(link.collection_id, current)
|
|
67
|
+
}
|
|
68
|
+
if (dictionarySlugs.length > 0) {
|
|
69
|
+
const typed = await db
|
|
70
|
+
.selectFrom('collection_dictionaries')
|
|
71
|
+
.innerJoin('dictionaries', 'dictionaries.id', 'collection_dictionaries.dictionary_id')
|
|
72
|
+
.select('collection_dictionaries.collection_id as collection_id')
|
|
73
|
+
.where('collection_dictionaries.collection_id', 'in', ids)
|
|
74
|
+
.where('dictionaries.type', 'in', dictionarySlugs)
|
|
75
|
+
.execute()
|
|
76
|
+
const allowed = new Set(typed.map(link => link.collection_id))
|
|
77
|
+
filtered = rows.filter(row => allowed.has(row.id))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const paths = pathMapForRows(rows)
|
|
81
|
+
for (const row of filtered) {
|
|
82
|
+
entries.push(toPickerEntry(row, def, paths.get(row.id) ?? row.slug, {
|
|
83
|
+
featuredImage: imageFields.length ? pickFeaturedImage(row.fields, imageFields) : undefined,
|
|
84
|
+
termIds: termIdsByEntry.get(row.id) ?? [],
|
|
85
|
+
}))
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const archives = query.archives === '1' || query.archives === 'true'
|
|
90
|
+
? readable.flatMap((slug) => {
|
|
91
|
+
const def = collections[slug]
|
|
92
|
+
const option = def ? collectionArchiveOption(slug, def) : null
|
|
93
|
+
return option ? [option] : []
|
|
94
|
+
})
|
|
95
|
+
: []
|
|
96
|
+
|
|
97
|
+
return { entries, archives }
|
|
98
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from 'h3'
|
|
2
|
+
import { useRuntimeConfig } from '#imports'
|
|
3
|
+
import { can, listDictionaries, toRelationTermValue } from '@katecms/core'
|
|
4
|
+
import type { RelationTermValue } from '@katecms/core'
|
|
5
|
+
import { getDb } from '../../../utils/db'
|
|
6
|
+
import { requireUser } from '../../../utils/session'
|
|
7
|
+
import {
|
|
8
|
+
flattenDictionaryTerms,
|
|
9
|
+
readDictionarySlug,
|
|
10
|
+
requireDictionary,
|
|
11
|
+
} from '../../../utils/dictionaries'
|
|
12
|
+
import { fail } from '../../../utils/collections'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Dictionary terms for the `dictionary` field and relationship filters.
|
|
16
|
+
* Readable with `dictionaries:read` or `collections:read` on an attached collection.
|
|
17
|
+
*/
|
|
18
|
+
export default defineEventHandler(async (event) => {
|
|
19
|
+
const actor = await requireUser(event)
|
|
20
|
+
const query = getQuery(event)
|
|
21
|
+
const dictionarySlug = readDictionarySlug(
|
|
22
|
+
typeof query.dictionary === 'string' ? query.dictionary : undefined,
|
|
23
|
+
)
|
|
24
|
+
const def = requireDictionary(dictionarySlug)
|
|
25
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {}
|
|
26
|
+
const canReadDictionary = can(actor, 'dictionaries', 'read', { roles, scope: dictionarySlug })
|
|
27
|
+
const canReadCollection = def.collections.some(slug => (
|
|
28
|
+
can(actor, 'collections', 'read', { roles, scope: slug })
|
|
29
|
+
))
|
|
30
|
+
if (!canReadDictionary && !canReadCollection) {
|
|
31
|
+
fail(403, 'Insufficient permissions.')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const db = getDb()
|
|
35
|
+
const rows = await listDictionaries(db, dictionarySlug)
|
|
36
|
+
const listed = flattenDictionaryTerms(rows)
|
|
37
|
+
const terms: RelationTermValue[] = listed.map(({ row, depth, slugPath }) => toRelationTermValue({
|
|
38
|
+
id: row.id,
|
|
39
|
+
type: row.type,
|
|
40
|
+
title: row.title,
|
|
41
|
+
slug: row.slug,
|
|
42
|
+
slugPath,
|
|
43
|
+
fields: row.fields ?? {},
|
|
44
|
+
parentId: row.parent_id,
|
|
45
|
+
depth,
|
|
46
|
+
createdAt: row.created_at,
|
|
47
|
+
updatedAt: row.updated_at,
|
|
48
|
+
}))
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
dictionary: {
|
|
52
|
+
slug: dictionarySlug,
|
|
53
|
+
labels: {
|
|
54
|
+
name: def.labels.name,
|
|
55
|
+
singularName: def.labels.singularName ?? def.labels.name,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
terms,
|
|
59
|
+
canCreate: can(actor, 'dictionaries', 'create', { roles, scope: dictionarySlug }),
|
|
60
|
+
}
|
|
61
|
+
})
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery } from 'h3'
|
|
2
|
+
import { useRuntimeConfig } from '#imports'
|
|
3
|
+
import {
|
|
4
|
+
buildSlugPathMap,
|
|
5
|
+
can,
|
|
6
|
+
collectionListPaging,
|
|
7
|
+
collectionPerPage,
|
|
8
|
+
countCollections,
|
|
9
|
+
findCollectionBySlugPath,
|
|
10
|
+
listCollections,
|
|
11
|
+
matchPublicCollectionRoute,
|
|
12
|
+
} from '@katecms/core'
|
|
13
|
+
import type { CollectionListStatus, CollectionStatus } from '@katecms/core'
|
|
14
|
+
import { getDb } from '../../utils/db'
|
|
15
|
+
import { getCurrentUser } from '../../utils/session'
|
|
16
|
+
import {
|
|
17
|
+
fail,
|
|
18
|
+
getCollectionDefinition,
|
|
19
|
+
getCollections,
|
|
20
|
+
readPage,
|
|
21
|
+
readPerPage,
|
|
22
|
+
toAdminEntry,
|
|
23
|
+
toCollectionMeta,
|
|
24
|
+
} from '../../utils/collections'
|
|
25
|
+
import { loadAssignedEntryDictionaries } from '../../utils/dictionaries'
|
|
26
|
+
import { resolvePublicDictionaryTerm } from '../../utils/public-term'
|
|
27
|
+
import {
|
|
28
|
+
isTruthyQueryParam,
|
|
29
|
+
parsePublicStatusParam,
|
|
30
|
+
resolvePublicStatuses,
|
|
31
|
+
} from '../../../utils/preview'
|
|
32
|
+
import type { ResolveResponse } from '../../../utils/collections'
|
|
33
|
+
|
|
34
|
+
function listStatusFromPublic(statuses: CollectionStatus[]): CollectionListStatus {
|
|
35
|
+
const published = statuses.includes('published')
|
|
36
|
+
const draft = statuses.includes('draft')
|
|
37
|
+
if (published && draft) {
|
|
38
|
+
return 'active'
|
|
39
|
+
}
|
|
40
|
+
if (draft) {
|
|
41
|
+
return 'draft'
|
|
42
|
+
}
|
|
43
|
+
return 'published'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Public resolve: map a frontend path to a collection entry or archive.
|
|
48
|
+
*
|
|
49
|
+
* Query:
|
|
50
|
+
* - `path` (required) — public URL, e.g. `/inf/about` or archive `/inf`
|
|
51
|
+
* - `preview` — `1`/`true`/`yes` to include drafts when the requester may
|
|
52
|
+
* `collections:read` the matched collection
|
|
53
|
+
* - `status` — `published`, `draft`, or comma-separated; `draft` is ignored
|
|
54
|
+
* unless preview is granted. Trash is never returned.
|
|
55
|
+
* - `page` / `perPage` — archive listing only
|
|
56
|
+
*
|
|
57
|
+
* Unauthorized preview requests still resolve published entries only (404 if
|
|
58
|
+
* the path is a draft), so existence is not leaked.
|
|
59
|
+
*/
|
|
60
|
+
export default defineEventHandler(async (event): Promise<ResolveResponse> => {
|
|
61
|
+
const query = getQuery(event)
|
|
62
|
+
const path = typeof query.path === 'string' ? query.path : ''
|
|
63
|
+
if (!path.trim()) {
|
|
64
|
+
fail(400, 'Missing path.')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const collections = getCollections()
|
|
68
|
+
const matched = matchPublicCollectionRoute(collections, path)
|
|
69
|
+
if (!matched) {
|
|
70
|
+
const db = getDb()
|
|
71
|
+
const termPage = await resolvePublicDictionaryTerm(db, path)
|
|
72
|
+
if (termPage) {
|
|
73
|
+
return termPage
|
|
74
|
+
}
|
|
75
|
+
fail(404, 'Page not found.')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const def = getCollectionDefinition(matched.collectionSlug)
|
|
79
|
+
if (!def || def.public === false) {
|
|
80
|
+
fail(404, 'Page not found.')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const previewRequested = isTruthyQueryParam(query.preview)
|
|
84
|
+
const actor = previewRequested ? await getCurrentUser(event) : null
|
|
85
|
+
const roles = useRuntimeConfig().katecms?.roles ?? {}
|
|
86
|
+
const previewAllowed = actor != null
|
|
87
|
+
&& can(actor, 'collections', 'read', { roles, scope: matched.collectionSlug })
|
|
88
|
+
|
|
89
|
+
const { statuses, preview } = resolvePublicStatuses({
|
|
90
|
+
previewRequested,
|
|
91
|
+
previewAllowed,
|
|
92
|
+
requested: parsePublicStatusParam(query.status),
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const db = getDb()
|
|
96
|
+
const meta = toCollectionMeta(matched.collectionSlug, def)
|
|
97
|
+
|
|
98
|
+
if (matched.kind === 'archive') {
|
|
99
|
+
const page = readPage(query.page)
|
|
100
|
+
const perPage = readPerPage(query.perPage, collectionPerPage(def))
|
|
101
|
+
const listStatus = listStatusFromPublic(statuses)
|
|
102
|
+
const [rows, total, pathRows] = await Promise.all([
|
|
103
|
+
listCollections(db, matched.collectionSlug, {
|
|
104
|
+
status: listStatus,
|
|
105
|
+
...collectionListPaging(page, perPage),
|
|
106
|
+
}),
|
|
107
|
+
countCollections(db, matched.collectionSlug, { status: listStatus }),
|
|
108
|
+
db.selectFrom('collections')
|
|
109
|
+
.select(['id', 'slug', 'parent_id'])
|
|
110
|
+
.where('type', '=', matched.collectionSlug)
|
|
111
|
+
.execute(),
|
|
112
|
+
])
|
|
113
|
+
const paths = buildSlugPathMap(pathRows)
|
|
114
|
+
const entries = await Promise.all(rows.map(async (row) => {
|
|
115
|
+
const dictionaries = await loadAssignedEntryDictionaries(db, row.id, matched.collectionSlug)
|
|
116
|
+
return toAdminEntry(row, paths.get(row.id) ?? row.slug, { dictionaries })
|
|
117
|
+
}))
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
kind: 'archive',
|
|
121
|
+
collection: meta,
|
|
122
|
+
entries,
|
|
123
|
+
preview,
|
|
124
|
+
page,
|
|
125
|
+
perPage,
|
|
126
|
+
total,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const row = await findCollectionBySlugPath(
|
|
131
|
+
db,
|
|
132
|
+
matched.collectionSlug,
|
|
133
|
+
matched.segments,
|
|
134
|
+
statuses,
|
|
135
|
+
)
|
|
136
|
+
if (!row) {
|
|
137
|
+
fail(404, 'Page not found.')
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const dictionaries = await loadAssignedEntryDictionaries(db, row.id, matched.collectionSlug)
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
kind: 'entry',
|
|
144
|
+
collection: meta,
|
|
145
|
+
entry: toAdminEntry(row, matched.slugPath, { dictionaries }),
|
|
146
|
+
preview,
|
|
147
|
+
}
|
|
148
|
+
})
|