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,53 @@
|
|
|
1
|
+
import { defineNitroPlugin } from 'nitropack/runtime'
|
|
2
|
+
import { useRuntimeConfig } from '#imports'
|
|
3
|
+
import {
|
|
4
|
+
createPostgresDb,
|
|
5
|
+
migratePostgres,
|
|
6
|
+
migrateSqlite,
|
|
7
|
+
resolveDatabaseTarget,
|
|
8
|
+
syncCollectionFieldIndexes,
|
|
9
|
+
} from '@katecms/core'
|
|
10
|
+
import type { Collections } from '@katecms/core'
|
|
11
|
+
|
|
12
|
+
function trimEnv(value: unknown): string {
|
|
13
|
+
return typeof value === 'string' ? value.trim() : ''
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default defineNitroPlugin(async () => {
|
|
17
|
+
const katecms = useRuntimeConfig().katecms
|
|
18
|
+
const database = katecms?.database
|
|
19
|
+
const driver = trimEnv(database?.driver)
|
|
20
|
+
const url = trimEnv(database?.url)
|
|
21
|
+
|| (driver === 'postgres' ? trimEnv(process.env.DATABASE_URL) : '')
|
|
22
|
+
|
|
23
|
+
const target = resolveDatabaseTarget({
|
|
24
|
+
driver,
|
|
25
|
+
url,
|
|
26
|
+
sqliteFilename: database?.sqliteFilename,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
if (target.driver === 'postgres') {
|
|
30
|
+
await migratePostgres(target.url)
|
|
31
|
+
const db = createPostgresDb(target.url)
|
|
32
|
+
try {
|
|
33
|
+
const result = await syncCollectionFieldIndexes(
|
|
34
|
+
db,
|
|
35
|
+
(katecms?.collections ?? {}) as Collections,
|
|
36
|
+
)
|
|
37
|
+
for (const warning of result.warnings) {
|
|
38
|
+
console.warn(`[KateCMS] ${warning}`)
|
|
39
|
+
}
|
|
40
|
+
if (result.created.length > 0 || result.dropped.length > 0) {
|
|
41
|
+
console.info(
|
|
42
|
+
`[KateCMS] Field indexes: created ${result.created.length}, dropped ${result.dropped.length}`,
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
await db.destroy()
|
|
48
|
+
}
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await migrateSqlite({ filename: target.filename })
|
|
53
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createAuthRateLimiter } from '@katecms/core'
|
|
2
|
+
import type { AuthRateLimitDecision } from '@katecms/core'
|
|
3
|
+
|
|
4
|
+
const limiter = createAuthRateLimiter()
|
|
5
|
+
|
|
6
|
+
export interface AuthAttemptKeys {
|
|
7
|
+
/** Action, address, and email. Cleared after a successful attempt. */
|
|
8
|
+
pair: string
|
|
9
|
+
/** Action and address. Stays after success so one login does not reopen the address. */
|
|
10
|
+
ip: string
|
|
11
|
+
/** Action and email. Cleared after a successful attempt. */
|
|
12
|
+
email: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Three buckets for one login or registration attempt.
|
|
17
|
+
* Empty addresses and emails share an `unknown` bucket.
|
|
18
|
+
*/
|
|
19
|
+
export function authAttemptKeys(
|
|
20
|
+
action: 'login' | 'register',
|
|
21
|
+
ip: string,
|
|
22
|
+
email: string,
|
|
23
|
+
): AuthAttemptKeys {
|
|
24
|
+
const address = ip.trim() || 'unknown'
|
|
25
|
+
const normalized = email.trim().toLowerCase() || 'unknown'
|
|
26
|
+
return {
|
|
27
|
+
pair: `${action}:pair:${address}:${normalized}`,
|
|
28
|
+
ip: `${action}:ip:${address}`,
|
|
29
|
+
email: `${action}:email:${normalized}`,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function asKeys(key: string | AuthAttemptKeys): string[] {
|
|
34
|
+
return typeof key === 'string' ? [key] : [key.pair, key.ip, key.email]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Longest cooldown among the given buckets, or 0 when every bucket allows the attempt. */
|
|
38
|
+
export function authAttemptRetryAfterMs(key: string | AuthAttemptKeys): number {
|
|
39
|
+
let retryAfterMs = 0
|
|
40
|
+
for (const item of asKeys(key)) {
|
|
41
|
+
const decision = limiter.check(item)
|
|
42
|
+
if (!decision.allowed) {
|
|
43
|
+
retryAfterMs = Math.max(retryAfterMs, decision.retryAfterMs)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return retryAfterMs
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function recordAuthAttemptFailure(key: string | AuthAttemptKeys): AuthRateLimitDecision {
|
|
50
|
+
let longest: AuthRateLimitDecision = { allowed: true, retryAfterMs: 0 }
|
|
51
|
+
for (const item of asKeys(key)) {
|
|
52
|
+
const decision = limiter.recordFailure(item)
|
|
53
|
+
if (decision.retryAfterMs > longest.retryAfterMs) {
|
|
54
|
+
longest = decision
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return longest
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Drop the email and pair buckets. An address bucket is left in place.
|
|
62
|
+
* A string key (password change) is cleared on its own.
|
|
63
|
+
*/
|
|
64
|
+
export function recordAuthAttemptSuccess(key: string | AuthAttemptKeys): void {
|
|
65
|
+
if (typeof key === 'string') {
|
|
66
|
+
limiter.recordSuccess(key)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
limiter.recordSuccess(key.pair)
|
|
70
|
+
limiter.recordSuccess(key.email)
|
|
71
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { H3Event } from 'h3'
|
|
2
|
+
import { createError, setHeader } from 'h3'
|
|
3
|
+
import {
|
|
4
|
+
authAttemptKeys,
|
|
5
|
+
authAttemptRetryAfterMs,
|
|
6
|
+
recordAuthAttemptFailure,
|
|
7
|
+
recordAuthAttemptSuccess,
|
|
8
|
+
} from './auth-attempts'
|
|
9
|
+
import type { AuthAttemptKeys } from './auth-attempts'
|
|
10
|
+
import { eventClientAddress } from './request-address'
|
|
11
|
+
|
|
12
|
+
export { authAttemptKeys, recordAuthAttemptFailure, recordAuthAttemptSuccess }
|
|
13
|
+
export type { AuthAttemptKeys }
|
|
14
|
+
|
|
15
|
+
export function getAuthAttemptKeys(
|
|
16
|
+
event: H3Event,
|
|
17
|
+
action: 'login' | 'register',
|
|
18
|
+
email: string,
|
|
19
|
+
): AuthAttemptKeys {
|
|
20
|
+
return authAttemptKeys(action, eventClientAddress(event), email)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function assertAuthAttemptAllowed(event: H3Event, key: string | AuthAttemptKeys): void {
|
|
24
|
+
const retryAfterMs = authAttemptRetryAfterMs(key)
|
|
25
|
+
if (retryAfterMs > 0) {
|
|
26
|
+
throwTooManyAttempts(event, retryAfterMs)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function throwTooManyAttempts(event: H3Event, retryAfterMs: number): never {
|
|
31
|
+
const retryAfterSec = Math.max(1, Math.ceil(retryAfterMs / 1000))
|
|
32
|
+
setHeader(event, 'Retry-After', retryAfterSec)
|
|
33
|
+
throw createError({
|
|
34
|
+
statusCode: 429,
|
|
35
|
+
statusMessage: 'Too Many Requests',
|
|
36
|
+
message: `Too many attempts. Try again in ${retryAfterSec} sec.`,
|
|
37
|
+
data: { retryAfterMs },
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function invalidCredentialsError(retryAfterMs = 0) {
|
|
42
|
+
return createError({
|
|
43
|
+
statusCode: 401,
|
|
44
|
+
statusMessage: 'Unauthorized',
|
|
45
|
+
message: 'Invalid email or password.',
|
|
46
|
+
data: { retryAfterMs },
|
|
47
|
+
})
|
|
48
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many reverse proxies may append to `X-Forwarded-For`.
|
|
3
|
+
* `MIRAICMS_TRUST_PROXY=1` trusts one proxy and uses the address it added.
|
|
4
|
+
* Unset means the header is ignored and the socket address is used.
|
|
5
|
+
*/
|
|
6
|
+
export function trustedProxyHops(raw = process.env.MIRAICMS_TRUST_PROXY): number {
|
|
7
|
+
const value = (raw ?? '').trim().toLowerCase()
|
|
8
|
+
if (!value || value === '0' || value === 'false' || value === 'off') {
|
|
9
|
+
return 0
|
|
10
|
+
}
|
|
11
|
+
if (value === 'true' || value === 'on') {
|
|
12
|
+
return 1
|
|
13
|
+
}
|
|
14
|
+
const hops = Number(value)
|
|
15
|
+
if (!Number.isInteger(hops) || hops < 1) {
|
|
16
|
+
return 0
|
|
17
|
+
}
|
|
18
|
+
return hops
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Client address for the auth limiter.
|
|
23
|
+
* With `hops` 0 the forwarded header is ignored, so a caller cannot pick a new
|
|
24
|
+
* bucket by sending another `X-Forwarded-For`.
|
|
25
|
+
*/
|
|
26
|
+
export function clientAddress(options: {
|
|
27
|
+
forwardedFor?: string | null
|
|
28
|
+
hops: number
|
|
29
|
+
socketAddress?: string | null
|
|
30
|
+
}): string {
|
|
31
|
+
const socket = options.socketAddress?.trim() || 'unknown'
|
|
32
|
+
if (options.hops < 1) {
|
|
33
|
+
return socket
|
|
34
|
+
}
|
|
35
|
+
const parts = (options.forwardedFor ?? '')
|
|
36
|
+
.split(',')
|
|
37
|
+
.map(part => part.trim())
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
const index = parts.length - options.hops
|
|
40
|
+
return index >= 0 && parts[index] ? parts[index] : socket
|
|
41
|
+
}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { createError } from 'h3'
|
|
2
|
+
import { useRuntimeConfig } from '#imports'
|
|
3
|
+
import {
|
|
4
|
+
can,
|
|
5
|
+
canOnEntry,
|
|
6
|
+
collectionPerPage,
|
|
7
|
+
DEFAULT_COLLECTION_PER_PAGE,
|
|
8
|
+
findUserById,
|
|
9
|
+
formatRequiredFieldsError,
|
|
10
|
+
isUniqueConstraintError,
|
|
11
|
+
parseDate,
|
|
12
|
+
UNLIMITED_COLLECTION_PER_PAGE,
|
|
13
|
+
validateRequiredFields,
|
|
14
|
+
} from '@katecms/core'
|
|
15
|
+
import type {
|
|
16
|
+
Collection,
|
|
17
|
+
CollectionDefinition,
|
|
18
|
+
CollectionListStatus,
|
|
19
|
+
CollectionParentOption,
|
|
20
|
+
CollectionStatus,
|
|
21
|
+
Collections,
|
|
22
|
+
Fields,
|
|
23
|
+
RoleMap,
|
|
24
|
+
SafeUser,
|
|
25
|
+
} from '@katecms/core'
|
|
26
|
+
import type {
|
|
27
|
+
AdminCollectionMeta,
|
|
28
|
+
AdminEntry,
|
|
29
|
+
ParentOption,
|
|
30
|
+
PublicDictionaryTerm,
|
|
31
|
+
} from '../../utils/collections'
|
|
32
|
+
|
|
33
|
+
const ENTRY_STATUSES: readonly CollectionStatus[] = ['published', 'draft', 'trash']
|
|
34
|
+
const LIST_STATUSES: readonly CollectionListStatus[] = ['published', 'draft', 'trash', 'active', 'all']
|
|
35
|
+
const SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/i
|
|
36
|
+
|
|
37
|
+
const STATUS_PHRASE: Record<number, string> = {
|
|
38
|
+
400: 'Bad Request',
|
|
39
|
+
403: 'Forbidden',
|
|
40
|
+
404: 'Not Found',
|
|
41
|
+
409: 'Conflict',
|
|
42
|
+
422: 'Unprocessable Entity',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function fail(statusCode: number, message: string): never {
|
|
46
|
+
throw createError({
|
|
47
|
+
statusCode,
|
|
48
|
+
statusMessage: STATUS_PHRASE[statusCode] ?? 'Error',
|
|
49
|
+
message,
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function getCollections(): Collections {
|
|
54
|
+
return useRuntimeConfig().katecms?.collections ?? {}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getCollectionDefinition(slug: string): CollectionDefinition | undefined {
|
|
58
|
+
return getCollections()[slug]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function requireCollection(slug: string): CollectionDefinition {
|
|
62
|
+
const collection = getCollectionDefinition(slug)
|
|
63
|
+
if (!collection) {
|
|
64
|
+
fail(404, 'Collection not found.')
|
|
65
|
+
}
|
|
66
|
+
return collection
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function toCollectionMeta(slug: string, def: CollectionDefinition): AdminCollectionMeta {
|
|
70
|
+
return {
|
|
71
|
+
slug,
|
|
72
|
+
labels: {
|
|
73
|
+
name: def.labels.name,
|
|
74
|
+
singularName: def.labels.singularName ?? def.labels.name,
|
|
75
|
+
},
|
|
76
|
+
hierarchical: def.hierarchical === true,
|
|
77
|
+
autosave: def.autosave === true,
|
|
78
|
+
revisions: def.revisions !== false,
|
|
79
|
+
public: def.public !== false,
|
|
80
|
+
has_archive: typeof def.has_archive === 'string' ? def.has_archive : def.has_archive === true,
|
|
81
|
+
perPage: collectionPerPage(def),
|
|
82
|
+
rewrite: def.rewrite,
|
|
83
|
+
fields: (def.fields ?? {}) as Fields,
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function collectionRevisionsEnabled(def: CollectionDefinition): boolean {
|
|
88
|
+
return def.revisions !== false
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function toIso(value: Date | string | null | undefined): string | null {
|
|
92
|
+
if (value == null) {
|
|
93
|
+
return null
|
|
94
|
+
}
|
|
95
|
+
if (value instanceof Date) {
|
|
96
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString()
|
|
97
|
+
}
|
|
98
|
+
const date = new Date(value)
|
|
99
|
+
return Number.isNaN(date.getTime()) ? null : date.toISOString()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function toAdminEntry(
|
|
103
|
+
row: Collection,
|
|
104
|
+
slugPath: string,
|
|
105
|
+
flags?: {
|
|
106
|
+
canUpdate?: boolean
|
|
107
|
+
canDelete?: boolean
|
|
108
|
+
depth?: number
|
|
109
|
+
authorName?: string | null
|
|
110
|
+
dictionaryIds?: Record<string, number[]>
|
|
111
|
+
dictionaries?: Record<string, PublicDictionaryTerm[]>
|
|
112
|
+
},
|
|
113
|
+
): AdminEntry {
|
|
114
|
+
return {
|
|
115
|
+
id: row.id,
|
|
116
|
+
type: row.type,
|
|
117
|
+
status: row.status,
|
|
118
|
+
slug: row.slug,
|
|
119
|
+
slugPath: slugPath || row.slug,
|
|
120
|
+
title: row.title,
|
|
121
|
+
fields: (row.fields ?? {}) as Record<string, unknown>,
|
|
122
|
+
parentId: row.parent_id,
|
|
123
|
+
menuOrder: row.menu_order,
|
|
124
|
+
authorId: row.author_id,
|
|
125
|
+
createdAt: toIso(row.created_at) ?? new Date(0).toISOString(),
|
|
126
|
+
updatedAt: toIso(row.updated_at) ?? new Date(0).toISOString(),
|
|
127
|
+
publishedAt: toIso(row.published_at),
|
|
128
|
+
...flags,
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function entryFlags(
|
|
133
|
+
actor: SafeUser,
|
|
134
|
+
row: Collection,
|
|
135
|
+
roles: RoleMap,
|
|
136
|
+
): { canUpdate: boolean, canDelete: boolean } {
|
|
137
|
+
const entry = { authorId: row.author_id }
|
|
138
|
+
return {
|
|
139
|
+
canUpdate: canOnEntry(actor, 'collections', 'update', entry, {
|
|
140
|
+
roles,
|
|
141
|
+
scope: row.type,
|
|
142
|
+
userId: actor.id,
|
|
143
|
+
}),
|
|
144
|
+
canDelete: canOnEntry(actor, 'collections', 'delete', entry, {
|
|
145
|
+
roles,
|
|
146
|
+
scope: row.type,
|
|
147
|
+
userId: actor.id,
|
|
148
|
+
}),
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function toParentOption(row: CollectionParentOption): ParentOption {
|
|
153
|
+
return {
|
|
154
|
+
id: row.id,
|
|
155
|
+
title: row.title,
|
|
156
|
+
slug: row.slug,
|
|
157
|
+
parentId: row.parentId,
|
|
158
|
+
slugPath: row.slugPath,
|
|
159
|
+
depth: row.depth,
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function readCollectionSlug(raw: string | undefined): string {
|
|
164
|
+
const slug = typeof raw === 'string' ? raw.trim() : ''
|
|
165
|
+
if (!slug) {
|
|
166
|
+
fail(400, 'Collection is required.')
|
|
167
|
+
}
|
|
168
|
+
return slug
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function readEntryId(raw: string | undefined): number {
|
|
172
|
+
const id = Number(raw)
|
|
173
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
174
|
+
fail(400, 'Invalid entry id.')
|
|
175
|
+
}
|
|
176
|
+
return id
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function readTitle(value: unknown): string {
|
|
180
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
181
|
+
fail(422, 'Title is required.')
|
|
182
|
+
}
|
|
183
|
+
return value.trim()
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function readSlug(value: unknown): string {
|
|
187
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
188
|
+
fail(422, 'Slug is required.')
|
|
189
|
+
}
|
|
190
|
+
const slug = value.trim()
|
|
191
|
+
if (!SLUG_PATTERN.test(slug)) {
|
|
192
|
+
fail(422, 'Slug may contain only letters, numbers, and hyphens.')
|
|
193
|
+
}
|
|
194
|
+
return slug
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function readStatus(value: unknown, fallback: CollectionStatus = 'draft'): CollectionStatus {
|
|
198
|
+
if (value === undefined || value === null || value === '') {
|
|
199
|
+
return fallback
|
|
200
|
+
}
|
|
201
|
+
if (typeof value !== 'string' || !ENTRY_STATUSES.includes(value as CollectionStatus)) {
|
|
202
|
+
fail(422, 'Invalid status.')
|
|
203
|
+
}
|
|
204
|
+
return value as CollectionStatus
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function readFields(value: unknown): Record<string, unknown> {
|
|
208
|
+
if (value === undefined || value === null) {
|
|
209
|
+
return {}
|
|
210
|
+
}
|
|
211
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
212
|
+
fail(422, 'Invalid field values.')
|
|
213
|
+
}
|
|
214
|
+
return value as Record<string, unknown>
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Reject published entries that are missing visible required fields. */
|
|
218
|
+
export function requirePublishedFields(
|
|
219
|
+
def: CollectionDefinition,
|
|
220
|
+
status: CollectionStatus,
|
|
221
|
+
fields: Record<string, unknown>,
|
|
222
|
+
): void {
|
|
223
|
+
if (status !== 'published') {
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
const issues = validateRequiredFields(def.fields ?? {}, fields)
|
|
227
|
+
if (issues.length > 0) {
|
|
228
|
+
fail(422, formatRequiredFieldsError(issues))
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function readParentId(value: unknown): number | null {
|
|
233
|
+
if (value === undefined || value === null || value === '') {
|
|
234
|
+
return null
|
|
235
|
+
}
|
|
236
|
+
const id = typeof value === 'number' ? value : Number(value)
|
|
237
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
238
|
+
fail(422, 'Invalid parent.')
|
|
239
|
+
}
|
|
240
|
+
return id
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function readAuthorId(value: unknown): number {
|
|
244
|
+
const id = typeof value === 'number' ? value : Number(value)
|
|
245
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
246
|
+
fail(422, 'Invalid author.')
|
|
247
|
+
}
|
|
248
|
+
return id
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Resolve `authorId` from the request. Assigning another user requires `users:read`. */
|
|
252
|
+
export async function resolveAuthorId(
|
|
253
|
+
db: Parameters<typeof findUserById>[0],
|
|
254
|
+
actor: SafeUser,
|
|
255
|
+
roles: RoleMap,
|
|
256
|
+
requested: unknown,
|
|
257
|
+
fallback: number,
|
|
258
|
+
): Promise<number> {
|
|
259
|
+
if (requested === undefined || requested === null || requested === '') {
|
|
260
|
+
return fallback
|
|
261
|
+
}
|
|
262
|
+
const id = readAuthorId(requested)
|
|
263
|
+
if (id === fallback) {
|
|
264
|
+
return id
|
|
265
|
+
}
|
|
266
|
+
if (id !== actor.id && !can(actor, 'users', 'read', { roles })) {
|
|
267
|
+
fail(403, 'Insufficient permissions.')
|
|
268
|
+
}
|
|
269
|
+
const user = await findUserById(db, id)
|
|
270
|
+
if (!user) {
|
|
271
|
+
fail(422, 'Author not found.')
|
|
272
|
+
}
|
|
273
|
+
return id
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export function readMenuOrder(value: unknown, fallback = 0): number {
|
|
277
|
+
if (value === undefined || value === null || value === '') {
|
|
278
|
+
return fallback
|
|
279
|
+
}
|
|
280
|
+
const n = typeof value === 'number' ? value : Number(value)
|
|
281
|
+
if (!Number.isInteger(n)) {
|
|
282
|
+
fail(422, 'Invalid menu order.')
|
|
283
|
+
}
|
|
284
|
+
return n
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** `undefined` = omit from patch; `null` = clear. */
|
|
288
|
+
export function readPublishedAt(value: unknown): Date | null | undefined {
|
|
289
|
+
if (value === undefined) {
|
|
290
|
+
return undefined
|
|
291
|
+
}
|
|
292
|
+
if (value === null || value === '') {
|
|
293
|
+
return null
|
|
294
|
+
}
|
|
295
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
296
|
+
const date = new Date(value)
|
|
297
|
+
if (!Number.isNaN(date.getTime())) {
|
|
298
|
+
return date
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (typeof value === 'string') {
|
|
302
|
+
const iso = new Date(value)
|
|
303
|
+
if (!Number.isNaN(iso.getTime())) {
|
|
304
|
+
return iso
|
|
305
|
+
}
|
|
306
|
+
const parsed = parseDate(value, 'YYYY-MM-DD HH:mm') ?? parseDate(value, 'YYYY-MM-DD')
|
|
307
|
+
if (parsed) {
|
|
308
|
+
return parsed
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
fail(422, 'Invalid publish date.')
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export function readListStatus(value: unknown): CollectionListStatus {
|
|
315
|
+
if (value === undefined || value === null || value === '') {
|
|
316
|
+
return 'active'
|
|
317
|
+
}
|
|
318
|
+
if (value === 'all') {
|
|
319
|
+
return 'active'
|
|
320
|
+
}
|
|
321
|
+
if (typeof value === 'string' && LIST_STATUSES.includes(value as CollectionListStatus)) {
|
|
322
|
+
return value as CollectionListStatus
|
|
323
|
+
}
|
|
324
|
+
fail(400, 'Invalid status filter.')
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export function readPage(value: unknown): number {
|
|
328
|
+
if (value === undefined || value === null || value === '') {
|
|
329
|
+
return 1
|
|
330
|
+
}
|
|
331
|
+
const n = Number(value)
|
|
332
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
333
|
+
fail(400, 'Invalid page.')
|
|
334
|
+
}
|
|
335
|
+
return n
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function readPerPage(
|
|
339
|
+
value: unknown,
|
|
340
|
+
fallback: number = DEFAULT_COLLECTION_PER_PAGE,
|
|
341
|
+
): number {
|
|
342
|
+
if (value === undefined || value === null || value === '') {
|
|
343
|
+
if (fallback === UNLIMITED_COLLECTION_PER_PAGE) {
|
|
344
|
+
return UNLIMITED_COLLECTION_PER_PAGE
|
|
345
|
+
}
|
|
346
|
+
if (!Number.isInteger(fallback) || fallback < 1) {
|
|
347
|
+
return DEFAULT_COLLECTION_PER_PAGE
|
|
348
|
+
}
|
|
349
|
+
return fallback
|
|
350
|
+
}
|
|
351
|
+
const n = Number(value)
|
|
352
|
+
if (n === UNLIMITED_COLLECTION_PER_PAGE) {
|
|
353
|
+
return UNLIMITED_COLLECTION_PER_PAGE
|
|
354
|
+
}
|
|
355
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
356
|
+
fail(400, 'Invalid page size.')
|
|
357
|
+
}
|
|
358
|
+
return n
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export function readSearch(value: unknown): string {
|
|
362
|
+
if (typeof value !== 'string') {
|
|
363
|
+
return ''
|
|
364
|
+
}
|
|
365
|
+
return value.trim().slice(0, 200)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export function rethrowCollectionWriteError(error: unknown): never {
|
|
369
|
+
if (isUniqueConstraintError(error)) {
|
|
370
|
+
fail(409, 'An entry with this slug already exists.')
|
|
371
|
+
}
|
|
372
|
+
const message = error instanceof Error ? error.message : ''
|
|
373
|
+
if (
|
|
374
|
+
/parent/i.test(message)
|
|
375
|
+
|| /descendant/i.test(message)
|
|
376
|
+
|| /hierarchy/i.test(message)
|
|
377
|
+
) {
|
|
378
|
+
fail(422, message.startsWith('collections:') ? 'Invalid parent entry.' : message)
|
|
379
|
+
}
|
|
380
|
+
throw error
|
|
381
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useRuntimeConfig } from '#imports'
|
|
2
|
+
import {
|
|
3
|
+
createPostgresDb,
|
|
4
|
+
createSqliteDb,
|
|
5
|
+
resolveDatabaseTarget,
|
|
6
|
+
} from '@katecms/core'
|
|
7
|
+
|
|
8
|
+
let db: ReturnType<typeof createSqliteDb> | undefined
|
|
9
|
+
|
|
10
|
+
function trimEnv(value: unknown): string {
|
|
11
|
+
return typeof value === 'string' ? value.trim() : ''
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Singleton Kysely client for Nitro handlers. */
|
|
15
|
+
export function getDb(): ReturnType<typeof createSqliteDb> {
|
|
16
|
+
if (db) {
|
|
17
|
+
return db
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const database = useRuntimeConfig().katecms?.database
|
|
21
|
+
const driver = trimEnv(database?.driver)
|
|
22
|
+
const url = trimEnv(database?.url)
|
|
23
|
+
|| (driver === 'postgres' ? trimEnv(process.env.DATABASE_URL) : '')
|
|
24
|
+
|
|
25
|
+
const target = resolveDatabaseTarget({
|
|
26
|
+
driver,
|
|
27
|
+
url,
|
|
28
|
+
sqliteFilename: database?.sqliteFilename,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
db = target.driver === 'postgres'
|
|
32
|
+
? createPostgresDb(target.url)
|
|
33
|
+
: createSqliteDb({ filename: target.filename })
|
|
34
|
+
|
|
35
|
+
return db
|
|
36
|
+
}
|