@karibsen/eponyme 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +609 -0
- package/dist/eponyme.d.mts +15 -0
- package/dist/eponyme.mjs +38 -0
- package/dist/module.d.mts +26 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +154 -0
- package/dist/runtime/assets/dashboard.css +1 -0
- package/dist/runtime/components/editor/EponymeCollectionPage.d.vue.ts +9 -0
- package/dist/runtime/components/editor/EponymeCollectionPage.vue +238 -0
- package/dist/runtime/components/editor/EponymeCollectionPage.vue.d.ts +9 -0
- package/dist/runtime/components/editor/EponymeCopy.d.vue.ts +7 -0
- package/dist/runtime/components/editor/EponymeCopy.vue +28 -0
- package/dist/runtime/components/editor/EponymeCopy.vue.d.ts +7 -0
- package/dist/runtime/components/editor/EponymeFolderNav.d.vue.ts +7 -0
- package/dist/runtime/components/editor/EponymeFolderNav.vue +146 -0
- package/dist/runtime/components/editor/EponymeFolderNav.vue.d.ts +7 -0
- package/dist/runtime/components/editor/EponymeFolderPage.d.vue.ts +7 -0
- package/dist/runtime/components/editor/EponymeFolderPage.vue +62 -0
- package/dist/runtime/components/editor/EponymeFolderPage.vue.d.ts +7 -0
- package/dist/runtime/components/editor/EponymeForm.d.vue.ts +9 -0
- package/dist/runtime/components/editor/EponymeForm.vue +309 -0
- package/dist/runtime/components/editor/EponymeForm.vue.d.ts +9 -0
- package/dist/runtime/components/editor/EponymeFormPage.d.vue.ts +8 -0
- package/dist/runtime/components/editor/EponymeFormPage.vue +288 -0
- package/dist/runtime/components/editor/EponymeFormPage.vue.d.ts +8 -0
- package/dist/runtime/components/editor/EponymeHistoryDialog.d.vue.ts +14 -0
- package/dist/runtime/components/editor/EponymeHistoryDialog.vue +97 -0
- package/dist/runtime/components/editor/EponymeHistoryDialog.vue.d.ts +14 -0
- package/dist/runtime/components/editor/EponymeNavigationLink.d.vue.ts +14 -0
- package/dist/runtime/components/editor/EponymeNavigationLink.vue +80 -0
- package/dist/runtime/components/editor/EponymeNavigationLink.vue.d.ts +14 -0
- package/dist/runtime/components/editor/EponymePageNavigation.d.vue.ts +8 -0
- package/dist/runtime/components/editor/EponymePageNavigation.vue +58 -0
- package/dist/runtime/components/editor/EponymePageNavigation.vue.d.ts +8 -0
- package/dist/runtime/components/editor/EponymePreviewPanel.d.vue.ts +16 -0
- package/dist/runtime/components/editor/EponymePreviewPanel.vue +100 -0
- package/dist/runtime/components/editor/EponymePreviewPanel.vue.d.ts +16 -0
- package/dist/runtime/components/editor/EponymeSidebar.d.vue.ts +6 -0
- package/dist/runtime/components/editor/EponymeSidebar.vue +244 -0
- package/dist/runtime/components/editor/EponymeSidebar.vue.d.ts +6 -0
- package/dist/runtime/components/editor/EponymeSidebarTree.d.vue.ts +18 -0
- package/dist/runtime/components/editor/EponymeSidebarTree.vue +84 -0
- package/dist/runtime/components/editor/EponymeSidebarTree.vue.d.ts +18 -0
- package/dist/runtime/components/fields/ArrayField.d.vue.ts +19 -0
- package/dist/runtime/components/fields/ArrayField.vue +198 -0
- package/dist/runtime/components/fields/ArrayField.vue.d.ts +19 -0
- package/dist/runtime/components/fields/BooleanField.d.vue.ts +16 -0
- package/dist/runtime/components/fields/BooleanField.vue +36 -0
- package/dist/runtime/components/fields/BooleanField.vue.d.ts +16 -0
- package/dist/runtime/components/fields/CheckboxGroupField.d.vue.ts +20 -0
- package/dist/runtime/components/fields/CheckboxGroupField.vue +52 -0
- package/dist/runtime/components/fields/CheckboxGroupField.vue.d.ts +20 -0
- package/dist/runtime/components/fields/ColorField.d.vue.ts +19 -0
- package/dist/runtime/components/fields/ColorField.vue +39 -0
- package/dist/runtime/components/fields/ColorField.vue.d.ts +19 -0
- package/dist/runtime/components/fields/DateField.d.vue.ts +18 -0
- package/dist/runtime/components/fields/DateField.vue +39 -0
- package/dist/runtime/components/fields/DateField.vue.d.ts +18 -0
- package/dist/runtime/components/fields/FieldRenderer.d.vue.ts +24 -0
- package/dist/runtime/components/fields/FieldRenderer.vue +135 -0
- package/dist/runtime/components/fields/FieldRenderer.vue.d.ts +24 -0
- package/dist/runtime/components/fields/NumberField.d.vue.ts +20 -0
- package/dist/runtime/components/fields/NumberField.vue +58 -0
- package/dist/runtime/components/fields/NumberField.vue.d.ts +20 -0
- package/dist/runtime/components/fields/RadioField.d.vue.ts +20 -0
- package/dist/runtime/components/fields/RadioField.vue +44 -0
- package/dist/runtime/components/fields/RadioField.vue.d.ts +20 -0
- package/dist/runtime/components/fields/RichTextField.d.vue.ts +20 -0
- package/dist/runtime/components/fields/RichTextField.vue +176 -0
- package/dist/runtime/components/fields/RichTextField.vue.d.ts +20 -0
- package/dist/runtime/components/fields/SectionField.d.vue.ts +20 -0
- package/dist/runtime/components/fields/SectionField.vue +127 -0
- package/dist/runtime/components/fields/SectionField.vue.d.ts +20 -0
- package/dist/runtime/components/fields/SelectField.d.vue.ts +21 -0
- package/dist/runtime/components/fields/SelectField.vue +42 -0
- package/dist/runtime/components/fields/SelectField.vue.d.ts +21 -0
- package/dist/runtime/components/fields/SlugField.d.vue.ts +20 -0
- package/dist/runtime/components/fields/SlugField.vue +35 -0
- package/dist/runtime/components/fields/SlugField.vue.d.ts +20 -0
- package/dist/runtime/components/fields/TabsField.d.vue.ts +19 -0
- package/dist/runtime/components/fields/TabsField.vue +109 -0
- package/dist/runtime/components/fields/TabsField.vue.d.ts +19 -0
- package/dist/runtime/components/fields/TextField.d.vue.ts +22 -0
- package/dist/runtime/components/fields/TextField.vue +56 -0
- package/dist/runtime/components/fields/TextField.vue.d.ts +22 -0
- package/dist/runtime/components/fields/TextareaField.d.vue.ts +20 -0
- package/dist/runtime/components/fields/TextareaField.vue +47 -0
- package/dist/runtime/components/fields/TextareaField.vue.d.ts +20 -0
- package/dist/runtime/components/fields/UrlField.d.vue.ts +17 -0
- package/dist/runtime/components/fields/UrlField.vue +35 -0
- package/dist/runtime/components/fields/UrlField.vue.d.ts +17 -0
- package/dist/runtime/components/ui/EPAccordion.d.vue.ts +26 -0
- package/dist/runtime/components/ui/EPAccordion.vue +64 -0
- package/dist/runtime/components/ui/EPAccordion.vue.d.ts +26 -0
- package/dist/runtime/components/ui/EPAvatar.d.vue.ts +9 -0
- package/dist/runtime/components/ui/EPAvatar.vue +25 -0
- package/dist/runtime/components/ui/EPAvatar.vue.d.ts +9 -0
- package/dist/runtime/components/ui/EPBadge.d.vue.ts +16 -0
- package/dist/runtime/components/ui/EPBadge.vue +17 -0
- package/dist/runtime/components/ui/EPBadge.vue.d.ts +16 -0
- package/dist/runtime/components/ui/EPButton.d.vue.ts +22 -0
- package/dist/runtime/components/ui/EPButton.vue +55 -0
- package/dist/runtime/components/ui/EPButton.vue.d.ts +22 -0
- package/dist/runtime/components/ui/EPCheckbox.d.vue.ts +11 -0
- package/dist/runtime/components/ui/EPCheckbox.vue +21 -0
- package/dist/runtime/components/ui/EPCheckbox.vue.d.ts +11 -0
- package/dist/runtime/components/ui/EPColorPicker.d.vue.ts +19 -0
- package/dist/runtime/components/ui/EPColorPicker.vue +63 -0
- package/dist/runtime/components/ui/EPColorPicker.vue.d.ts +19 -0
- package/dist/runtime/components/ui/EPDialog.d.vue.ts +24 -0
- package/dist/runtime/components/ui/EPDialog.vue +54 -0
- package/dist/runtime/components/ui/EPDialog.vue.d.ts +24 -0
- package/dist/runtime/components/ui/EPDropdownMenu.d.vue.ts +25 -0
- package/dist/runtime/components/ui/EPDropdownMenu.vue +40 -0
- package/dist/runtime/components/ui/EPDropdownMenu.vue.d.ts +25 -0
- package/dist/runtime/components/ui/EPFormField.d.vue.ts +24 -0
- package/dist/runtime/components/ui/EPFormField.vue +62 -0
- package/dist/runtime/components/ui/EPFormField.vue.d.ts +24 -0
- package/dist/runtime/components/ui/EPInputText.d.vue.ts +17 -0
- package/dist/runtime/components/ui/EPInputText.vue +33 -0
- package/dist/runtime/components/ui/EPInputText.vue.d.ts +17 -0
- package/dist/runtime/components/ui/EPLinkEditor.d.vue.ts +16 -0
- package/dist/runtime/components/ui/EPLinkEditor.vue +169 -0
- package/dist/runtime/components/ui/EPLinkEditor.vue.d.ts +16 -0
- package/dist/runtime/components/ui/EPRadioButton.d.vue.ts +16 -0
- package/dist/runtime/components/ui/EPRadioButton.vue +34 -0
- package/dist/runtime/components/ui/EPRadioButton.vue.d.ts +16 -0
- package/dist/runtime/components/ui/EPSelect.d.vue.ts +21 -0
- package/dist/runtime/components/ui/EPSelect.vue +73 -0
- package/dist/runtime/components/ui/EPSelect.vue.d.ts +21 -0
- package/dist/runtime/components/ui/EPSlider.d.vue.ts +16 -0
- package/dist/runtime/components/ui/EPSlider.vue +51 -0
- package/dist/runtime/components/ui/EPSlider.vue.d.ts +16 -0
- package/dist/runtime/components/ui/EPSwitch.d.vue.ts +11 -0
- package/dist/runtime/components/ui/EPSwitch.vue +23 -0
- package/dist/runtime/components/ui/EPSwitch.vue.d.ts +11 -0
- package/dist/runtime/components/ui/EPTextarea.d.vue.ts +12 -0
- package/dist/runtime/components/ui/EPTextarea.vue +18 -0
- package/dist/runtime/components/ui/EPTextarea.vue.d.ts +12 -0
- package/dist/runtime/components/ui/EPToast.d.vue.ts +13 -0
- package/dist/runtime/components/ui/EPToast.vue +60 -0
- package/dist/runtime/components/ui/EPToast.vue.d.ts +13 -0
- package/dist/runtime/components/ui/EPTooltip.d.vue.ts +17 -0
- package/dist/runtime/components/ui/EPTooltip.vue +34 -0
- package/dist/runtime/components/ui/EPTooltip.vue.d.ts +17 -0
- package/dist/runtime/components/ui/form-field-context.d.ts +12 -0
- package/dist/runtime/components/ui/form-field-context.js +1 -0
- package/dist/runtime/composables/useEponyme.d.ts +24 -0
- package/dist/runtime/composables/useEponyme.js +63 -0
- package/dist/runtime/composables/useEponymeAuth.d.ts +16 -0
- package/dist/runtime/composables/useEponymeAuth.js +81 -0
- package/dist/runtime/composables/useEponymeCollection.d.ts +27 -0
- package/dist/runtime/composables/useEponymeCollection.js +44 -0
- package/dist/runtime/composables/useEponymeColorPresets.d.ts +5 -0
- package/dist/runtime/composables/useEponymeColorPresets.js +16 -0
- package/dist/runtime/composables/useEponymeConfig.d.ts +1 -0
- package/dist/runtime/composables/useEponymeConfig.js +4 -0
- package/dist/runtime/composables/useEponymeForm.d.ts +35 -0
- package/dist/runtime/composables/useEponymeForm.js +75 -0
- package/dist/runtime/composables/useEponymeHistory.d.ts +26 -0
- package/dist/runtime/composables/useEponymeHistory.js +24 -0
- package/dist/runtime/composables/useEponymeValidation.d.ts +21 -0
- package/dist/runtime/composables/useEponymeValidation.js +34 -0
- package/dist/runtime/fields/array.d.ts +2 -0
- package/dist/runtime/fields/array.js +3 -0
- package/dist/runtime/fields/boolean.d.ts +2 -0
- package/dist/runtime/fields/boolean.js +3 -0
- package/dist/runtime/fields/checkbox-group.d.ts +2 -0
- package/dist/runtime/fields/checkbox-group.js +3 -0
- package/dist/runtime/fields/color.d.ts +2 -0
- package/dist/runtime/fields/color.js +3 -0
- package/dist/runtime/fields/date.d.ts +3 -0
- package/dist/runtime/fields/date.js +6 -0
- package/dist/runtime/fields/email.d.ts +2 -0
- package/dist/runtime/fields/email.js +3 -0
- package/dist/runtime/fields/image.d.ts +2 -0
- package/dist/runtime/fields/image.js +3 -0
- package/dist/runtime/fields/index.d.ts +37 -0
- package/dist/runtime/fields/index.js +19 -0
- package/dist/runtime/fields/number.d.ts +2 -0
- package/dist/runtime/fields/number.js +3 -0
- package/dist/runtime/fields/radio.d.ts +2 -0
- package/dist/runtime/fields/radio.js +3 -0
- package/dist/runtime/fields/rich-text.d.ts +2 -0
- package/dist/runtime/fields/rich-text.js +3 -0
- package/dist/runtime/fields/section.d.ts +2 -0
- package/dist/runtime/fields/section.js +3 -0
- package/dist/runtime/fields/select.d.ts +2 -0
- package/dist/runtime/fields/select.js +3 -0
- package/dist/runtime/fields/slug.d.ts +2 -0
- package/dist/runtime/fields/slug.js +3 -0
- package/dist/runtime/fields/string.d.ts +2 -0
- package/dist/runtime/fields/string.js +3 -0
- package/dist/runtime/fields/tab.d.ts +2 -0
- package/dist/runtime/fields/tab.js +3 -0
- package/dist/runtime/fields/textarea.d.ts +2 -0
- package/dist/runtime/fields/textarea.js +3 -0
- package/dist/runtime/fields/url.d.ts +2 -0
- package/dist/runtime/fields/url.js +3 -0
- package/dist/runtime/middleware/eponyme-auth.d.ts +2 -0
- package/dist/runtime/middleware/eponyme-auth.js +13 -0
- package/dist/runtime/middleware/eponyme-owner.d.ts +2 -0
- package/dist/runtime/middleware/eponyme-owner.js +7 -0
- package/dist/runtime/pages/EponymeChangePasswordPage.d.vue.ts +3 -0
- package/dist/runtime/pages/EponymeChangePasswordPage.vue +118 -0
- package/dist/runtime/pages/EponymeChangePasswordPage.vue.d.ts +3 -0
- package/dist/runtime/pages/EponymeDetailPage.d.vue.ts +3 -0
- package/dist/runtime/pages/EponymeDetailPage.vue +83 -0
- package/dist/runtime/pages/EponymeDetailPage.vue.d.ts +3 -0
- package/dist/runtime/pages/EponymeIndexPage.d.vue.ts +3 -0
- package/dist/runtime/pages/EponymeIndexPage.vue +51 -0
- package/dist/runtime/pages/EponymeIndexPage.vue.d.ts +3 -0
- package/dist/runtime/pages/EponymeLoginPage.d.vue.ts +3 -0
- package/dist/runtime/pages/EponymeLoginPage.vue +102 -0
- package/dist/runtime/pages/EponymeLoginPage.vue.d.ts +3 -0
- package/dist/runtime/pages/EponymeUsersPage.d.vue.ts +3 -0
- package/dist/runtime/pages/EponymeUsersPage.vue +261 -0
- package/dist/runtime/pages/EponymeUsersPage.vue.d.ts +3 -0
- package/dist/runtime/server/api/eponyme/[name].get.d.ts +4 -0
- package/dist/runtime/server/api/eponyme/[name].get.js +20 -0
- package/dist/runtime/server/api/eponyme/[name].patch.d.ts +11 -0
- package/dist/runtime/server/api/eponyme/[name].patch.js +20 -0
- package/dist/runtime/server/api/eponyme-auth/change-password.post.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-auth/change-password.post.js +21 -0
- package/dist/runtime/server/api/eponyme-auth/login.post.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-auth/login.post.js +12 -0
- package/dist/runtime/server/api/eponyme-auth/logout.post.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-auth/logout.post.js +13 -0
- package/dist/runtime/server/api/eponyme-auth/session.get.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-auth/session.get.js +5 -0
- package/dist/runtime/server/api/eponyme-collections/[path].delete.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-collections/[path].delete.js +11 -0
- package/dist/runtime/server/api/eponyme-collections/[path].get.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-collections/[path].get.js +11 -0
- package/dist/runtime/server/api/eponyme-collections/[path].post.d.ts +7 -0
- package/dist/runtime/server/api/eponyme-collections/[path].post.js +16 -0
- package/dist/runtime/server/api/eponyme-forms/[path].delete.d.ts +6 -0
- package/dist/runtime/server/api/eponyme-forms/[path].delete.js +19 -0
- package/dist/runtime/server/api/eponyme-forms/[path].get.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-forms/[path].get.js +22 -0
- package/dist/runtime/server/api/eponyme-forms/[path].post.d.ts +19 -0
- package/dist/runtime/server/api/eponyme-forms/[path].post.js +36 -0
- package/dist/runtime/server/api/eponyme-history/[path].get.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-history/[path].get.js +11 -0
- package/dist/runtime/server/api/eponyme-history/[path].patch.d.ts +2 -0
- package/dist/runtime/server/api/eponyme-history/[path].patch.js +18 -0
- package/dist/runtime/server/api/eponyme-sitemap.get.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-sitemap.get.js +5 -0
- package/dist/runtime/server/api/eponyme-statuses.get.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-statuses.get.js +7 -0
- package/dist/runtime/server/api/eponyme-users/[id]/reset-password.post.d.ts +5 -0
- package/dist/runtime/server/api/eponyme-users/[id]/reset-password.post.js +12 -0
- package/dist/runtime/server/api/eponyme-users/[id].patch.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-users/[id].patch.js +14 -0
- package/dist/runtime/server/api/eponyme-users/index.get.d.ts +4 -0
- package/dist/runtime/server/api/eponyme-users/index.get.js +7 -0
- package/dist/runtime/server/api/eponyme-users/index.post.d.ts +5 -0
- package/dist/runtime/server/api/eponyme-users/index.post.js +13 -0
- package/dist/runtime/server/plugins/eponyme-sync.d.ts +2 -0
- package/dist/runtime/server/plugins/eponyme-sync.js +14 -0
- package/dist/runtime/server/services/eponyme-auth-service.d.ts +2 -0
- package/dist/runtime/server/services/eponyme-auth-service.js +15 -0
- package/dist/runtime/server/services/eponyme-auth-store.d.ts +119 -0
- package/dist/runtime/server/services/eponyme-auth-store.js +227 -0
- package/dist/runtime/server/services/eponyme-form-service.d.ts +3 -0
- package/dist/runtime/server/services/eponyme-form-service.js +8 -0
- package/dist/runtime/server/services/eponyme-form-store.d.ts +100 -0
- package/dist/runtime/server/services/eponyme-form-store.js +109 -0
- package/dist/runtime/server/services/eponyme-service.d.ts +3 -0
- package/dist/runtime/server/services/eponyme-service.js +8 -0
- package/dist/runtime/server/services/eponyme-store.d.ts +202 -0
- package/dist/runtime/server/services/eponyme-store.js +338 -0
- package/dist/runtime/server/utils/auth.d.ts +11 -0
- package/dist/runtime/server/utils/auth.js +41 -0
- package/dist/runtime/server/utils/eponyme-form.d.ts +14 -0
- package/dist/runtime/server/utils/eponyme-form.js +6 -0
- package/dist/runtime/server/utils/eponyme-sitemap.d.ts +7 -0
- package/dist/runtime/server/utils/eponyme-sitemap.js +7 -0
- package/dist/runtime/server/utils/form-route.d.ts +14 -0
- package/dist/runtime/server/utils/form-route.js +14 -0
- package/dist/runtime/server/utils/password.d.ts +4 -0
- package/dist/runtime/server/utils/password.js +30 -0
- package/dist/runtime/types/auth.d.ts +20 -0
- package/dist/runtime/types/auth.js +7 -0
- package/dist/runtime/types/eponyme-config.d.ts +11 -0
- package/dist/runtime/types/eponyme-navigation.d.ts +6 -0
- package/dist/runtime/types/eponyme-navigation.js +0 -0
- package/dist/runtime/types/eponyme.d.ts +87 -0
- package/dist/runtime/types/eponyme.js +0 -0
- package/dist/runtime/types/field.d.ts +203 -0
- package/dist/runtime/types/field.js +0 -0
- package/dist/runtime/types/index.d.ts +3 -0
- package/dist/runtime/types/index.js +3 -0
- package/dist/runtime/types/nuxt.d.ts +11 -0
- package/dist/runtime/utils/as-record.d.ts +1 -0
- package/dist/runtime/utils/as-record.js +3 -0
- package/dist/runtime/utils/build-eponyme-schema.d.ts +22 -0
- package/dist/runtime/utils/build-eponyme-schema.js +42 -0
- package/dist/runtime/utils/changed-paths.d.ts +6 -0
- package/dist/runtime/utils/changed-paths.js +25 -0
- package/dist/runtime/utils/create-default-eponyme-data.d.ts +5 -0
- package/dist/runtime/utils/create-default-eponyme-data.js +12 -0
- package/dist/runtime/utils/field-path.d.ts +14 -0
- package/dist/runtime/utils/field-path.js +23 -0
- package/dist/runtime/utils/get-eponyme-schemas.d.ts +7 -0
- package/dist/runtime/utils/get-eponyme-schemas.js +33 -0
- package/dist/runtime/utils/get-field-default-value.d.ts +4 -0
- package/dist/runtime/utils/get-field-default-value.js +56 -0
- package/dist/runtime/utils/humanize-label.d.ts +6 -0
- package/dist/runtime/utils/humanize-label.js +3 -0
- package/dist/runtime/utils/initials.d.ts +1 -0
- package/dist/runtime/utils/initials.js +3 -0
- package/dist/runtime/utils/is-field-visible.d.ts +2 -0
- package/dist/runtime/utils/is-field-visible.js +14 -0
- package/dist/runtime/utils/normalize-hex-color.d.ts +8 -0
- package/dist/runtime/utils/normalize-hex-color.js +11 -0
- package/dist/runtime/utils/normalize-slug.d.ts +1 -0
- package/dist/runtime/utils/normalize-slug.js +4 -0
- package/dist/runtime/utils/preview.d.ts +30 -0
- package/dist/runtime/utils/preview.js +30 -0
- package/dist/runtime/utils/validate-eponyme-data.d.ts +10 -0
- package/dist/runtime/utils/validate-eponyme-data.js +204 -0
- package/dist/types.d.mts +11 -0
- package/package.json +96 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { isArrayItemFieldDefinition } from "./get-field-default-value.js";
|
|
2
|
+
import { isFieldVisible } from "./is-field-visible.js";
|
|
3
|
+
const urlPattern = /^https?:\/\//i;
|
|
4
|
+
const datePattern = /^\d{4}-\d{2}-\d{2}$/;
|
|
5
|
+
const colorPattern = /^#(?:[\da-f]{3}|[\da-f]{6}|[\da-f]{8})$/i;
|
|
6
|
+
const slugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
7
|
+
function createErrors() {
|
|
8
|
+
return /* @__PURE__ */ Object.create(null);
|
|
9
|
+
}
|
|
10
|
+
function addError(errors, path, message) {
|
|
11
|
+
(errors[path] ??= []).push(message);
|
|
12
|
+
}
|
|
13
|
+
function countErrorsUnder(errors, path) {
|
|
14
|
+
const prefix = `${path}.`;
|
|
15
|
+
return Object.entries(errors).filter(([key]) => key === path || key.startsWith(prefix)).reduce((total, [, messages]) => total + messages.length, 0);
|
|
16
|
+
}
|
|
17
|
+
function validateField(path, definition, value, errors, mode, context) {
|
|
18
|
+
if (!isFieldVisible(definition.options, context)) return;
|
|
19
|
+
const errorsBefore = countErrorsUnder(errors, path);
|
|
20
|
+
validateFieldRules(path, definition, value, errors, mode, context);
|
|
21
|
+
if (countErrorsUnder(errors, path) !== errorsBefore || value === void 0 || value === null || !definition.options.validate) return;
|
|
22
|
+
try {
|
|
23
|
+
const result = definition.options.validate(value, context);
|
|
24
|
+
if (typeof result === "string") addError(errors, path, result);
|
|
25
|
+
else if (Array.isArray(result)) result.forEach((message) => addError(errors, path, message));
|
|
26
|
+
} catch {
|
|
27
|
+
addError(errors, path, "Custom validation failed.");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function validateFieldRules(name, definition, value, errors, mode, _context) {
|
|
31
|
+
const { options } = definition;
|
|
32
|
+
if (value === void 0 || value === null) {
|
|
33
|
+
if (mode === "publish" && options.required) addError(errors, name, "This field is required.");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (definition.type === "section") {
|
|
37
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
38
|
+
addError(errors, name, "Must be an object.");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const sectionData = value;
|
|
42
|
+
for (const sectionField of Object.keys(sectionData)) {
|
|
43
|
+
if (!definition.options.fields[sectionField]) addError(errors, `${name}.${sectionField}`, "Unknown field.");
|
|
44
|
+
}
|
|
45
|
+
for (const [sectionField, sectionDefinition] of Object.entries(definition.options.fields))
|
|
46
|
+
validateField(`${name}.${sectionField}`, sectionDefinition, sectionData[sectionField], errors, mode, sectionData);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (definition.type === "tabs") {
|
|
50
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
51
|
+
addError(errors, name, "Must be an object.");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const tabsData = value;
|
|
55
|
+
for (const tabName of Object.keys(tabsData)) {
|
|
56
|
+
if (!definition.options.tabs[tabName]) addError(errors, `${name}.${tabName}`, "Unknown tab.");
|
|
57
|
+
}
|
|
58
|
+
for (const [tabName, tabDefinition] of Object.entries(definition.options.tabs)) {
|
|
59
|
+
const tabValue = tabsData[tabName];
|
|
60
|
+
if (!tabValue || typeof tabValue !== "object" || Array.isArray(tabValue)) {
|
|
61
|
+
addError(errors, `${name}.${tabName}`, "Must be an object.");
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const tabData = tabValue;
|
|
65
|
+
for (const tabField of Object.keys(tabData)) {
|
|
66
|
+
if (!tabDefinition.fields[tabField]) addError(errors, `${name}.${tabName}.${tabField}`, "Unknown field.");
|
|
67
|
+
}
|
|
68
|
+
for (const [tabField, fieldDefinition] of Object.entries(tabDefinition.fields))
|
|
69
|
+
validateField(`${name}.${tabName}.${tabField}`, fieldDefinition, tabData[tabField], errors, mode, tabData);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (definition.type === "checkboxGroup") {
|
|
74
|
+
if (!Array.isArray(value)) {
|
|
75
|
+
addError(errors, name, "Must be an array.");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (mode === "publish" && definition.options.required && value.length === 0) addError(errors, name, "This field is required.");
|
|
79
|
+
if (mode === "publish" && definition.options.minItems !== void 0 && value.length < definition.options.minItems) addError(errors, name, `Must contain at least ${definition.options.minItems} items.`);
|
|
80
|
+
if (definition.options.maxItems !== void 0 && value.length > definition.options.maxItems) addError(errors, name, `Must contain at most ${definition.options.maxItems} items.`);
|
|
81
|
+
if (value.some((item) => typeof item !== "string" || !definition.options.options.some((option) => option.value === item)))
|
|
82
|
+
addError(errors, name, "Must contain only available options.");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (definition.type === "array") {
|
|
86
|
+
if (!Array.isArray(value)) {
|
|
87
|
+
addError(errors, name, "Must be an array.");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (mode === "publish" && options.required && value.length === 0) addError(errors, name, "This field is required.");
|
|
91
|
+
if (mode === "publish" && definition.options.minItems !== void 0 && value.length < definition.options.minItems) addError(errors, name, `Must contain at least ${definition.options.minItems} items.`);
|
|
92
|
+
if (definition.options.maxItems !== void 0 && value.length > definition.options.maxItems) addError(errors, name, `Must contain at most ${definition.options.maxItems} items.`);
|
|
93
|
+
value.forEach((item, index) => {
|
|
94
|
+
if (!isArrayItemFieldDefinition(definition.options.of)) {
|
|
95
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) {
|
|
96
|
+
addError(errors, `${name}.${index}`, "Must be an object.");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const itemData = item;
|
|
100
|
+
for (const itemField of Object.keys(itemData)) {
|
|
101
|
+
if (!definition.options.of[itemField]) addError(errors, `${name}.${index}.${itemField}`, "Unknown field.");
|
|
102
|
+
}
|
|
103
|
+
for (const [itemField, itemDefinition] of Object.entries(definition.options.of))
|
|
104
|
+
validateField(`${name}.${index}.${itemField}`, itemDefinition, itemData[itemField], errors, mode, itemData);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
validateField(`${name}.${index}`, definition.options.of, item, errors, mode, {});
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (definition.type === "number") {
|
|
112
|
+
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
113
|
+
addError(errors, name, "Must be a number.");
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (definition.options.min !== void 0 && value < definition.options.min) addError(errors, name, `Must be at least ${definition.options.min}.`);
|
|
117
|
+
if (definition.options.max !== void 0 && value > definition.options.max) addError(errors, name, `Must be at most ${definition.options.max}.`);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (definition.type === "boolean") {
|
|
121
|
+
if (typeof value !== "boolean") addError(errors, name, "Must be a boolean.");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (definition.type === "url") {
|
|
125
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
126
|
+
addError(errors, name, "Must be a link.");
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const link = value;
|
|
130
|
+
if (typeof link.href !== "string" || !["internal", "external"].includes(String(link.type)) || typeof link.openInNewTab !== "boolean") {
|
|
131
|
+
addError(errors, name, "Must be a valid link.");
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const href = link.href.trim();
|
|
135
|
+
if (mode === "publish" && options.required && !href) addError(errors, name, "This field is required.");
|
|
136
|
+
if (!href) return;
|
|
137
|
+
if (link.type === "external" && !urlPattern.test(href)) addError(errors, name, "External links must be HTTP(S) URLs.");
|
|
138
|
+
if (link.type === "internal" && !href.startsWith("/") && !href.startsWith("#")) addError(errors, name, "Internal links must start with / or #.");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (typeof value !== "string") {
|
|
142
|
+
addError(errors, name, "Must be a string.");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const normalized = value.trim();
|
|
146
|
+
const normalizedContent = definition.type === "richText" ? getRichTextContent(normalized) : normalized;
|
|
147
|
+
if (mode === "publish" && options.required && !normalizedContent) addError(errors, name, "This field is required.");
|
|
148
|
+
if (mode === "draft" && !normalizedContent) return;
|
|
149
|
+
if (definition.type === "image" && normalized && !urlPattern.test(normalized)) addError(errors, name, "Must be an HTTP(S) URL.");
|
|
150
|
+
if (definition.type === "image") return;
|
|
151
|
+
if (definition.type === "select" || definition.type === "radio") {
|
|
152
|
+
if (normalized && !definition.options.options.some((option) => option.value === value)) addError(errors, name, "Must be one of the available options.");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (definition.type === "date") {
|
|
156
|
+
const timestamp = Date.parse(`${normalized}T00:00:00Z`);
|
|
157
|
+
const isValid = datePattern.test(normalized) && !Number.isNaN(timestamp) && new Date(timestamp).toISOString().slice(0, 10) === normalized;
|
|
158
|
+
if (normalized && !isValid) addError(errors, name, "Must be a valid date.");
|
|
159
|
+
if (definition.options.min && normalized < definition.options.min) addError(errors, name, `Must be on or after ${definition.options.min}.`);
|
|
160
|
+
if (definition.options.max && normalized > definition.options.max) addError(errors, name, `Must be on or before ${definition.options.max}.`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (definition.type === "color") {
|
|
164
|
+
if (normalized && !colorPattern.test(normalized)) addError(errors, name, "Must be a valid hex color.");
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (definition.type === "slug") {
|
|
168
|
+
if (normalized && !slugPattern.test(normalized)) addError(errors, name, "Must contain only lowercase letters, numbers and single hyphens.");
|
|
169
|
+
if (mode === "publish" && definition.options.minLength !== void 0 && value.length < definition.options.minLength) addError(errors, name, `Must contain at least ${definition.options.minLength} characters.`);
|
|
170
|
+
if (definition.options.maxLength !== void 0 && value.length > definition.options.maxLength) addError(errors, name, `Must contain at most ${definition.options.maxLength} characters.`);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (definition.type === "richText") {
|
|
174
|
+
if (mode === "publish" && definition.options.minLength !== void 0 && normalizedContent.length < definition.options.minLength) addError(errors, name, `Must contain at least ${definition.options.minLength} characters.`);
|
|
175
|
+
if (definition.options.maxLength !== void 0 && normalizedContent.length > definition.options.maxLength) addError(errors, name, `Must contain at most ${definition.options.maxLength} characters.`);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (mode === "publish" && definition.options.minLength !== void 0 && value.length < definition.options.minLength) addError(errors, name, `Must contain at least ${definition.options.minLength} characters.`);
|
|
179
|
+
if (definition.options.maxLength !== void 0 && value.length > definition.options.maxLength) addError(errors, name, `Must contain at most ${definition.options.maxLength} characters.`);
|
|
180
|
+
if (definition.options.regex && !definition.options.regex.test(value)) addError(errors, name, "Has an invalid format.");
|
|
181
|
+
const [localPart, domain, ...extraParts] = normalized.split("@");
|
|
182
|
+
if ((definition.type === "email" || definition.options.email) && normalized && (!localPart || !domain?.includes(".") || extraParts.length)) addError(errors, name, "Must be a valid email address.");
|
|
183
|
+
if (definition.options.url && normalized && !urlPattern.test(normalized)) addError(errors, name, "Must be an HTTP(S) URL.");
|
|
184
|
+
}
|
|
185
|
+
function getRichTextContent(value) {
|
|
186
|
+
return value.replace(/<br\s*\/?>/gi, " ").replace(/<\/p>|<\/h[1-6]>|<\/li>|<\/blockquote>/gi, " ").replace(/<[^>]+>/g, "").replace(/ | /gi, " ").replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">").replace(/\s+/g, " ").trim();
|
|
187
|
+
}
|
|
188
|
+
export function validateEponymePatch(schema, payload, data, mode = "publish") {
|
|
189
|
+
const errors = createErrors();
|
|
190
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return { _form: ["Body must be an object."] };
|
|
191
|
+
const context = data ?? payload;
|
|
192
|
+
for (const [name, value] of Object.entries(payload)) {
|
|
193
|
+
const definition = schema[name];
|
|
194
|
+
if (!definition) addError(errors, name, "Unknown field.");
|
|
195
|
+
else validateField(name, definition, value, errors, mode, context);
|
|
196
|
+
}
|
|
197
|
+
return errors;
|
|
198
|
+
}
|
|
199
|
+
export function validateEponymeData(schema, data, mode = "publish") {
|
|
200
|
+
const errors = createErrors();
|
|
201
|
+
for (const [name, definition] of Object.entries(schema))
|
|
202
|
+
validateField(name, definition, data[name], errors, mode, data);
|
|
203
|
+
return errors;
|
|
204
|
+
}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { type collection, type defineEponymeConfig, type form } from './eponyme.mjs'
|
|
2
|
+
|
|
3
|
+
export { type field, type today } from '../dist/runtime/fields/index.js'
|
|
4
|
+
|
|
5
|
+
export { type EPONYME_ROLES, type canEditEponyme, type isEponymeRole } from '../dist/runtime/types/auth.js'
|
|
6
|
+
|
|
7
|
+
export { type ArrayFieldDefinition, type ArrayFieldOptions, type ArrayItemDefinition, type ArrayItemFieldDefinition, type ArrayItemSchema, type ArrayItemValue, type BooleanFieldDefinition, type BooleanFieldOptions, type CheckboxGroupFieldDefinition, type CheckboxGroupFieldOptions, type CollectionSlugField, type ColorFieldDefinition, type ColorFieldOptions, type DateFieldDefinition, type DateFieldOptions, type EmailFieldDefinition, type EmailFieldOptions, type EponymeAuthSession, type EponymeAuthUser, type EponymeCollectionDataByName, type EponymeCollectionDefinition, type EponymeCollectionDefinitionBase, type EponymeCollectionName, type EponymeCollectionOptions, type EponymeConfig, type EponymeData, type EponymeDataByName, type EponymeFormDataByName, type EponymeFormDefinition, type EponymeFormDefinitionBase, type EponymeFormFieldDefinition, type EponymeFormMode, type EponymeFormName, type EponymeFormOptions, type EponymeFormSchema, type EponymeManagedUserResult, type EponymeName, type EponymeRole, type EponymeSchema, type FieldDefinition, type FieldValidationResult, type FieldValidator, type FieldVisibilityCondition, type ImageFieldDefinition, type ImageFieldOptions, type NumberFieldDefinition, type NumberFieldOptions, type RadioFieldDefinition, type RadioFieldOptions, type RichTextFieldDefinition, type RichTextFieldOptions, type SectionFieldDefinition, type SectionFieldOptions, type SectionItemFieldDefinition, type SectionItemValue, type SectionSchema, type SectionValue, type SelectFieldDefinition, type SelectFieldOptions, type SelectOption, type SlugFieldDefinition, type SlugFieldOptions, type StringFieldDefinition, type StringFieldOptions, type TabDefinition, type TabFieldDefinition, type TabFieldOptions, type TabsSchema, type TabsValue, type TextareaFieldDefinition, type TextareaFieldOptions, type TodayDateDefault, type UrlFieldDefinition, type UrlFieldOptions, type UrlType, type UrlValue } from '../dist/runtime/types/index.js'
|
|
8
|
+
|
|
9
|
+
export { default } from './module.mjs'
|
|
10
|
+
|
|
11
|
+
export { type ModuleOptions } from './module.mjs'
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@karibsen/eponyme",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A lightweight, type-safe content manager for Nuxt.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"packageManager": "pnpm@10.33.4",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"nuxt",
|
|
10
|
+
"nuxt-module",
|
|
11
|
+
"cms",
|
|
12
|
+
"content",
|
|
13
|
+
"prisma",
|
|
14
|
+
"postgresql",
|
|
15
|
+
"typescript"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/karibsen-studio/eponyme.git"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/karibsen-studio/eponyme#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/karibsen-studio/eponyme/issues"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/types.d.mts",
|
|
31
|
+
"import": "./dist/module.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./config": {
|
|
34
|
+
"types": "./dist/eponyme.d.mts",
|
|
35
|
+
"import": "./dist/eponyme.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"main": "./dist/module.mjs",
|
|
40
|
+
"typesVersions": {
|
|
41
|
+
"*": {
|
|
42
|
+
".": [
|
|
43
|
+
"./dist/types.d.mts"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"dist"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"prepack": "nuxt-module-build build",
|
|
52
|
+
"dev": "npm run dev:prepare && nuxt dev --cwd playground",
|
|
53
|
+
"dev:build": "nuxt build --cwd playground",
|
|
54
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare --cwd playground",
|
|
55
|
+
"release": "npm run lint && npm run test && npm run test:types && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
56
|
+
"lint": "eslint .",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:watch": "vitest watch",
|
|
59
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@iconify-json/mingcute": "^1.2.7",
|
|
63
|
+
"@nuxt/icon": "^2.3.1",
|
|
64
|
+
"@nuxt/kit": "^4.4.8",
|
|
65
|
+
"@tailwindcss/vite": "^4.1.12",
|
|
66
|
+
"@tanstack/vue-table": "^8.21.3",
|
|
67
|
+
"@tiptap/extension-image": "^3.29.2",
|
|
68
|
+
"@tiptap/extension-placeholder": "^3.28.0",
|
|
69
|
+
"@tiptap/starter-kit": "^3.28.0",
|
|
70
|
+
"@tiptap/vue-3": "^3.28.0",
|
|
71
|
+
"@vueuse/core": "^14.3.0",
|
|
72
|
+
"@vueuse/integrations": "^14.3.0",
|
|
73
|
+
"picocolors": "^1.1.1",
|
|
74
|
+
"reka-ui": "^2.10.1",
|
|
75
|
+
"slugify": "^1.6.9",
|
|
76
|
+
"sortablejs": "^1.15.7",
|
|
77
|
+
"tailwindcss": "^4.1.12",
|
|
78
|
+
"zod": "^4.4.3"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@nuxt/devtools": "^3.2.4",
|
|
82
|
+
"@nuxt/eslint-config": "^1.15.2",
|
|
83
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
84
|
+
"@nuxt/schema": "^4.4.8",
|
|
85
|
+
"@nuxt/test-utils": "^4.0.3",
|
|
86
|
+
"@types/node": "latest",
|
|
87
|
+
"@types/sortablejs": "^1.15.9",
|
|
88
|
+
"changelogen": "^0.6.2",
|
|
89
|
+
"eslint": "^10.4.1",
|
|
90
|
+
"nuxt": "^4.4.8",
|
|
91
|
+
"typescript": "~6.0.3",
|
|
92
|
+
"unbuild": "^3.6.1",
|
|
93
|
+
"vitest": "^4.1.8",
|
|
94
|
+
"vue-tsc": "^3.3.3"
|
|
95
|
+
}
|
|
96
|
+
}
|