@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.
Files changed (325) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +609 -0
  3. package/dist/eponyme.d.mts +15 -0
  4. package/dist/eponyme.mjs +38 -0
  5. package/dist/module.d.mts +26 -0
  6. package/dist/module.json +9 -0
  7. package/dist/module.mjs +154 -0
  8. package/dist/runtime/assets/dashboard.css +1 -0
  9. package/dist/runtime/components/editor/EponymeCollectionPage.d.vue.ts +9 -0
  10. package/dist/runtime/components/editor/EponymeCollectionPage.vue +238 -0
  11. package/dist/runtime/components/editor/EponymeCollectionPage.vue.d.ts +9 -0
  12. package/dist/runtime/components/editor/EponymeCopy.d.vue.ts +7 -0
  13. package/dist/runtime/components/editor/EponymeCopy.vue +28 -0
  14. package/dist/runtime/components/editor/EponymeCopy.vue.d.ts +7 -0
  15. package/dist/runtime/components/editor/EponymeFolderNav.d.vue.ts +7 -0
  16. package/dist/runtime/components/editor/EponymeFolderNav.vue +146 -0
  17. package/dist/runtime/components/editor/EponymeFolderNav.vue.d.ts +7 -0
  18. package/dist/runtime/components/editor/EponymeFolderPage.d.vue.ts +7 -0
  19. package/dist/runtime/components/editor/EponymeFolderPage.vue +62 -0
  20. package/dist/runtime/components/editor/EponymeFolderPage.vue.d.ts +7 -0
  21. package/dist/runtime/components/editor/EponymeForm.d.vue.ts +9 -0
  22. package/dist/runtime/components/editor/EponymeForm.vue +309 -0
  23. package/dist/runtime/components/editor/EponymeForm.vue.d.ts +9 -0
  24. package/dist/runtime/components/editor/EponymeFormPage.d.vue.ts +8 -0
  25. package/dist/runtime/components/editor/EponymeFormPage.vue +288 -0
  26. package/dist/runtime/components/editor/EponymeFormPage.vue.d.ts +8 -0
  27. package/dist/runtime/components/editor/EponymeHistoryDialog.d.vue.ts +14 -0
  28. package/dist/runtime/components/editor/EponymeHistoryDialog.vue +97 -0
  29. package/dist/runtime/components/editor/EponymeHistoryDialog.vue.d.ts +14 -0
  30. package/dist/runtime/components/editor/EponymeNavigationLink.d.vue.ts +14 -0
  31. package/dist/runtime/components/editor/EponymeNavigationLink.vue +80 -0
  32. package/dist/runtime/components/editor/EponymeNavigationLink.vue.d.ts +14 -0
  33. package/dist/runtime/components/editor/EponymePageNavigation.d.vue.ts +8 -0
  34. package/dist/runtime/components/editor/EponymePageNavigation.vue +58 -0
  35. package/dist/runtime/components/editor/EponymePageNavigation.vue.d.ts +8 -0
  36. package/dist/runtime/components/editor/EponymePreviewPanel.d.vue.ts +16 -0
  37. package/dist/runtime/components/editor/EponymePreviewPanel.vue +100 -0
  38. package/dist/runtime/components/editor/EponymePreviewPanel.vue.d.ts +16 -0
  39. package/dist/runtime/components/editor/EponymeSidebar.d.vue.ts +6 -0
  40. package/dist/runtime/components/editor/EponymeSidebar.vue +244 -0
  41. package/dist/runtime/components/editor/EponymeSidebar.vue.d.ts +6 -0
  42. package/dist/runtime/components/editor/EponymeSidebarTree.d.vue.ts +18 -0
  43. package/dist/runtime/components/editor/EponymeSidebarTree.vue +84 -0
  44. package/dist/runtime/components/editor/EponymeSidebarTree.vue.d.ts +18 -0
  45. package/dist/runtime/components/fields/ArrayField.d.vue.ts +19 -0
  46. package/dist/runtime/components/fields/ArrayField.vue +198 -0
  47. package/dist/runtime/components/fields/ArrayField.vue.d.ts +19 -0
  48. package/dist/runtime/components/fields/BooleanField.d.vue.ts +16 -0
  49. package/dist/runtime/components/fields/BooleanField.vue +36 -0
  50. package/dist/runtime/components/fields/BooleanField.vue.d.ts +16 -0
  51. package/dist/runtime/components/fields/CheckboxGroupField.d.vue.ts +20 -0
  52. package/dist/runtime/components/fields/CheckboxGroupField.vue +52 -0
  53. package/dist/runtime/components/fields/CheckboxGroupField.vue.d.ts +20 -0
  54. package/dist/runtime/components/fields/ColorField.d.vue.ts +19 -0
  55. package/dist/runtime/components/fields/ColorField.vue +39 -0
  56. package/dist/runtime/components/fields/ColorField.vue.d.ts +19 -0
  57. package/dist/runtime/components/fields/DateField.d.vue.ts +18 -0
  58. package/dist/runtime/components/fields/DateField.vue +39 -0
  59. package/dist/runtime/components/fields/DateField.vue.d.ts +18 -0
  60. package/dist/runtime/components/fields/FieldRenderer.d.vue.ts +24 -0
  61. package/dist/runtime/components/fields/FieldRenderer.vue +135 -0
  62. package/dist/runtime/components/fields/FieldRenderer.vue.d.ts +24 -0
  63. package/dist/runtime/components/fields/NumberField.d.vue.ts +20 -0
  64. package/dist/runtime/components/fields/NumberField.vue +58 -0
  65. package/dist/runtime/components/fields/NumberField.vue.d.ts +20 -0
  66. package/dist/runtime/components/fields/RadioField.d.vue.ts +20 -0
  67. package/dist/runtime/components/fields/RadioField.vue +44 -0
  68. package/dist/runtime/components/fields/RadioField.vue.d.ts +20 -0
  69. package/dist/runtime/components/fields/RichTextField.d.vue.ts +20 -0
  70. package/dist/runtime/components/fields/RichTextField.vue +176 -0
  71. package/dist/runtime/components/fields/RichTextField.vue.d.ts +20 -0
  72. package/dist/runtime/components/fields/SectionField.d.vue.ts +20 -0
  73. package/dist/runtime/components/fields/SectionField.vue +127 -0
  74. package/dist/runtime/components/fields/SectionField.vue.d.ts +20 -0
  75. package/dist/runtime/components/fields/SelectField.d.vue.ts +21 -0
  76. package/dist/runtime/components/fields/SelectField.vue +42 -0
  77. package/dist/runtime/components/fields/SelectField.vue.d.ts +21 -0
  78. package/dist/runtime/components/fields/SlugField.d.vue.ts +20 -0
  79. package/dist/runtime/components/fields/SlugField.vue +35 -0
  80. package/dist/runtime/components/fields/SlugField.vue.d.ts +20 -0
  81. package/dist/runtime/components/fields/TabsField.d.vue.ts +19 -0
  82. package/dist/runtime/components/fields/TabsField.vue +109 -0
  83. package/dist/runtime/components/fields/TabsField.vue.d.ts +19 -0
  84. package/dist/runtime/components/fields/TextField.d.vue.ts +22 -0
  85. package/dist/runtime/components/fields/TextField.vue +56 -0
  86. package/dist/runtime/components/fields/TextField.vue.d.ts +22 -0
  87. package/dist/runtime/components/fields/TextareaField.d.vue.ts +20 -0
  88. package/dist/runtime/components/fields/TextareaField.vue +47 -0
  89. package/dist/runtime/components/fields/TextareaField.vue.d.ts +20 -0
  90. package/dist/runtime/components/fields/UrlField.d.vue.ts +17 -0
  91. package/dist/runtime/components/fields/UrlField.vue +35 -0
  92. package/dist/runtime/components/fields/UrlField.vue.d.ts +17 -0
  93. package/dist/runtime/components/ui/EPAccordion.d.vue.ts +26 -0
  94. package/dist/runtime/components/ui/EPAccordion.vue +64 -0
  95. package/dist/runtime/components/ui/EPAccordion.vue.d.ts +26 -0
  96. package/dist/runtime/components/ui/EPAvatar.d.vue.ts +9 -0
  97. package/dist/runtime/components/ui/EPAvatar.vue +25 -0
  98. package/dist/runtime/components/ui/EPAvatar.vue.d.ts +9 -0
  99. package/dist/runtime/components/ui/EPBadge.d.vue.ts +16 -0
  100. package/dist/runtime/components/ui/EPBadge.vue +17 -0
  101. package/dist/runtime/components/ui/EPBadge.vue.d.ts +16 -0
  102. package/dist/runtime/components/ui/EPButton.d.vue.ts +22 -0
  103. package/dist/runtime/components/ui/EPButton.vue +55 -0
  104. package/dist/runtime/components/ui/EPButton.vue.d.ts +22 -0
  105. package/dist/runtime/components/ui/EPCheckbox.d.vue.ts +11 -0
  106. package/dist/runtime/components/ui/EPCheckbox.vue +21 -0
  107. package/dist/runtime/components/ui/EPCheckbox.vue.d.ts +11 -0
  108. package/dist/runtime/components/ui/EPColorPicker.d.vue.ts +19 -0
  109. package/dist/runtime/components/ui/EPColorPicker.vue +63 -0
  110. package/dist/runtime/components/ui/EPColorPicker.vue.d.ts +19 -0
  111. package/dist/runtime/components/ui/EPDialog.d.vue.ts +24 -0
  112. package/dist/runtime/components/ui/EPDialog.vue +54 -0
  113. package/dist/runtime/components/ui/EPDialog.vue.d.ts +24 -0
  114. package/dist/runtime/components/ui/EPDropdownMenu.d.vue.ts +25 -0
  115. package/dist/runtime/components/ui/EPDropdownMenu.vue +40 -0
  116. package/dist/runtime/components/ui/EPDropdownMenu.vue.d.ts +25 -0
  117. package/dist/runtime/components/ui/EPFormField.d.vue.ts +24 -0
  118. package/dist/runtime/components/ui/EPFormField.vue +62 -0
  119. package/dist/runtime/components/ui/EPFormField.vue.d.ts +24 -0
  120. package/dist/runtime/components/ui/EPInputText.d.vue.ts +17 -0
  121. package/dist/runtime/components/ui/EPInputText.vue +33 -0
  122. package/dist/runtime/components/ui/EPInputText.vue.d.ts +17 -0
  123. package/dist/runtime/components/ui/EPLinkEditor.d.vue.ts +16 -0
  124. package/dist/runtime/components/ui/EPLinkEditor.vue +169 -0
  125. package/dist/runtime/components/ui/EPLinkEditor.vue.d.ts +16 -0
  126. package/dist/runtime/components/ui/EPRadioButton.d.vue.ts +16 -0
  127. package/dist/runtime/components/ui/EPRadioButton.vue +34 -0
  128. package/dist/runtime/components/ui/EPRadioButton.vue.d.ts +16 -0
  129. package/dist/runtime/components/ui/EPSelect.d.vue.ts +21 -0
  130. package/dist/runtime/components/ui/EPSelect.vue +73 -0
  131. package/dist/runtime/components/ui/EPSelect.vue.d.ts +21 -0
  132. package/dist/runtime/components/ui/EPSlider.d.vue.ts +16 -0
  133. package/dist/runtime/components/ui/EPSlider.vue +51 -0
  134. package/dist/runtime/components/ui/EPSlider.vue.d.ts +16 -0
  135. package/dist/runtime/components/ui/EPSwitch.d.vue.ts +11 -0
  136. package/dist/runtime/components/ui/EPSwitch.vue +23 -0
  137. package/dist/runtime/components/ui/EPSwitch.vue.d.ts +11 -0
  138. package/dist/runtime/components/ui/EPTextarea.d.vue.ts +12 -0
  139. package/dist/runtime/components/ui/EPTextarea.vue +18 -0
  140. package/dist/runtime/components/ui/EPTextarea.vue.d.ts +12 -0
  141. package/dist/runtime/components/ui/EPToast.d.vue.ts +13 -0
  142. package/dist/runtime/components/ui/EPToast.vue +60 -0
  143. package/dist/runtime/components/ui/EPToast.vue.d.ts +13 -0
  144. package/dist/runtime/components/ui/EPTooltip.d.vue.ts +17 -0
  145. package/dist/runtime/components/ui/EPTooltip.vue +34 -0
  146. package/dist/runtime/components/ui/EPTooltip.vue.d.ts +17 -0
  147. package/dist/runtime/components/ui/form-field-context.d.ts +12 -0
  148. package/dist/runtime/components/ui/form-field-context.js +1 -0
  149. package/dist/runtime/composables/useEponyme.d.ts +24 -0
  150. package/dist/runtime/composables/useEponyme.js +63 -0
  151. package/dist/runtime/composables/useEponymeAuth.d.ts +16 -0
  152. package/dist/runtime/composables/useEponymeAuth.js +81 -0
  153. package/dist/runtime/composables/useEponymeCollection.d.ts +27 -0
  154. package/dist/runtime/composables/useEponymeCollection.js +44 -0
  155. package/dist/runtime/composables/useEponymeColorPresets.d.ts +5 -0
  156. package/dist/runtime/composables/useEponymeColorPresets.js +16 -0
  157. package/dist/runtime/composables/useEponymeConfig.d.ts +1 -0
  158. package/dist/runtime/composables/useEponymeConfig.js +4 -0
  159. package/dist/runtime/composables/useEponymeForm.d.ts +35 -0
  160. package/dist/runtime/composables/useEponymeForm.js +75 -0
  161. package/dist/runtime/composables/useEponymeHistory.d.ts +26 -0
  162. package/dist/runtime/composables/useEponymeHistory.js +24 -0
  163. package/dist/runtime/composables/useEponymeValidation.d.ts +21 -0
  164. package/dist/runtime/composables/useEponymeValidation.js +34 -0
  165. package/dist/runtime/fields/array.d.ts +2 -0
  166. package/dist/runtime/fields/array.js +3 -0
  167. package/dist/runtime/fields/boolean.d.ts +2 -0
  168. package/dist/runtime/fields/boolean.js +3 -0
  169. package/dist/runtime/fields/checkbox-group.d.ts +2 -0
  170. package/dist/runtime/fields/checkbox-group.js +3 -0
  171. package/dist/runtime/fields/color.d.ts +2 -0
  172. package/dist/runtime/fields/color.js +3 -0
  173. package/dist/runtime/fields/date.d.ts +3 -0
  174. package/dist/runtime/fields/date.js +6 -0
  175. package/dist/runtime/fields/email.d.ts +2 -0
  176. package/dist/runtime/fields/email.js +3 -0
  177. package/dist/runtime/fields/image.d.ts +2 -0
  178. package/dist/runtime/fields/image.js +3 -0
  179. package/dist/runtime/fields/index.d.ts +37 -0
  180. package/dist/runtime/fields/index.js +19 -0
  181. package/dist/runtime/fields/number.d.ts +2 -0
  182. package/dist/runtime/fields/number.js +3 -0
  183. package/dist/runtime/fields/radio.d.ts +2 -0
  184. package/dist/runtime/fields/radio.js +3 -0
  185. package/dist/runtime/fields/rich-text.d.ts +2 -0
  186. package/dist/runtime/fields/rich-text.js +3 -0
  187. package/dist/runtime/fields/section.d.ts +2 -0
  188. package/dist/runtime/fields/section.js +3 -0
  189. package/dist/runtime/fields/select.d.ts +2 -0
  190. package/dist/runtime/fields/select.js +3 -0
  191. package/dist/runtime/fields/slug.d.ts +2 -0
  192. package/dist/runtime/fields/slug.js +3 -0
  193. package/dist/runtime/fields/string.d.ts +2 -0
  194. package/dist/runtime/fields/string.js +3 -0
  195. package/dist/runtime/fields/tab.d.ts +2 -0
  196. package/dist/runtime/fields/tab.js +3 -0
  197. package/dist/runtime/fields/textarea.d.ts +2 -0
  198. package/dist/runtime/fields/textarea.js +3 -0
  199. package/dist/runtime/fields/url.d.ts +2 -0
  200. package/dist/runtime/fields/url.js +3 -0
  201. package/dist/runtime/middleware/eponyme-auth.d.ts +2 -0
  202. package/dist/runtime/middleware/eponyme-auth.js +13 -0
  203. package/dist/runtime/middleware/eponyme-owner.d.ts +2 -0
  204. package/dist/runtime/middleware/eponyme-owner.js +7 -0
  205. package/dist/runtime/pages/EponymeChangePasswordPage.d.vue.ts +3 -0
  206. package/dist/runtime/pages/EponymeChangePasswordPage.vue +118 -0
  207. package/dist/runtime/pages/EponymeChangePasswordPage.vue.d.ts +3 -0
  208. package/dist/runtime/pages/EponymeDetailPage.d.vue.ts +3 -0
  209. package/dist/runtime/pages/EponymeDetailPage.vue +83 -0
  210. package/dist/runtime/pages/EponymeDetailPage.vue.d.ts +3 -0
  211. package/dist/runtime/pages/EponymeIndexPage.d.vue.ts +3 -0
  212. package/dist/runtime/pages/EponymeIndexPage.vue +51 -0
  213. package/dist/runtime/pages/EponymeIndexPage.vue.d.ts +3 -0
  214. package/dist/runtime/pages/EponymeLoginPage.d.vue.ts +3 -0
  215. package/dist/runtime/pages/EponymeLoginPage.vue +102 -0
  216. package/dist/runtime/pages/EponymeLoginPage.vue.d.ts +3 -0
  217. package/dist/runtime/pages/EponymeUsersPage.d.vue.ts +3 -0
  218. package/dist/runtime/pages/EponymeUsersPage.vue +261 -0
  219. package/dist/runtime/pages/EponymeUsersPage.vue.d.ts +3 -0
  220. package/dist/runtime/server/api/eponyme/[name].get.d.ts +4 -0
  221. package/dist/runtime/server/api/eponyme/[name].get.js +20 -0
  222. package/dist/runtime/server/api/eponyme/[name].patch.d.ts +11 -0
  223. package/dist/runtime/server/api/eponyme/[name].patch.js +20 -0
  224. package/dist/runtime/server/api/eponyme-auth/change-password.post.d.ts +4 -0
  225. package/dist/runtime/server/api/eponyme-auth/change-password.post.js +21 -0
  226. package/dist/runtime/server/api/eponyme-auth/login.post.d.ts +4 -0
  227. package/dist/runtime/server/api/eponyme-auth/login.post.js +12 -0
  228. package/dist/runtime/server/api/eponyme-auth/logout.post.d.ts +4 -0
  229. package/dist/runtime/server/api/eponyme-auth/logout.post.js +13 -0
  230. package/dist/runtime/server/api/eponyme-auth/session.get.d.ts +4 -0
  231. package/dist/runtime/server/api/eponyme-auth/session.get.js +5 -0
  232. package/dist/runtime/server/api/eponyme-collections/[path].delete.d.ts +4 -0
  233. package/dist/runtime/server/api/eponyme-collections/[path].delete.js +11 -0
  234. package/dist/runtime/server/api/eponyme-collections/[path].get.d.ts +4 -0
  235. package/dist/runtime/server/api/eponyme-collections/[path].get.js +11 -0
  236. package/dist/runtime/server/api/eponyme-collections/[path].post.d.ts +7 -0
  237. package/dist/runtime/server/api/eponyme-collections/[path].post.js +16 -0
  238. package/dist/runtime/server/api/eponyme-forms/[path].delete.d.ts +6 -0
  239. package/dist/runtime/server/api/eponyme-forms/[path].delete.js +19 -0
  240. package/dist/runtime/server/api/eponyme-forms/[path].get.d.ts +4 -0
  241. package/dist/runtime/server/api/eponyme-forms/[path].get.js +22 -0
  242. package/dist/runtime/server/api/eponyme-forms/[path].post.d.ts +19 -0
  243. package/dist/runtime/server/api/eponyme-forms/[path].post.js +36 -0
  244. package/dist/runtime/server/api/eponyme-history/[path].get.d.ts +4 -0
  245. package/dist/runtime/server/api/eponyme-history/[path].get.js +11 -0
  246. package/dist/runtime/server/api/eponyme-history/[path].patch.d.ts +2 -0
  247. package/dist/runtime/server/api/eponyme-history/[path].patch.js +18 -0
  248. package/dist/runtime/server/api/eponyme-sitemap.get.d.ts +4 -0
  249. package/dist/runtime/server/api/eponyme-sitemap.get.js +5 -0
  250. package/dist/runtime/server/api/eponyme-statuses.get.d.ts +4 -0
  251. package/dist/runtime/server/api/eponyme-statuses.get.js +7 -0
  252. package/dist/runtime/server/api/eponyme-users/[id]/reset-password.post.d.ts +5 -0
  253. package/dist/runtime/server/api/eponyme-users/[id]/reset-password.post.js +12 -0
  254. package/dist/runtime/server/api/eponyme-users/[id].patch.d.ts +4 -0
  255. package/dist/runtime/server/api/eponyme-users/[id].patch.js +14 -0
  256. package/dist/runtime/server/api/eponyme-users/index.get.d.ts +4 -0
  257. package/dist/runtime/server/api/eponyme-users/index.get.js +7 -0
  258. package/dist/runtime/server/api/eponyme-users/index.post.d.ts +5 -0
  259. package/dist/runtime/server/api/eponyme-users/index.post.js +13 -0
  260. package/dist/runtime/server/plugins/eponyme-sync.d.ts +2 -0
  261. package/dist/runtime/server/plugins/eponyme-sync.js +14 -0
  262. package/dist/runtime/server/services/eponyme-auth-service.d.ts +2 -0
  263. package/dist/runtime/server/services/eponyme-auth-service.js +15 -0
  264. package/dist/runtime/server/services/eponyme-auth-store.d.ts +119 -0
  265. package/dist/runtime/server/services/eponyme-auth-store.js +227 -0
  266. package/dist/runtime/server/services/eponyme-form-service.d.ts +3 -0
  267. package/dist/runtime/server/services/eponyme-form-service.js +8 -0
  268. package/dist/runtime/server/services/eponyme-form-store.d.ts +100 -0
  269. package/dist/runtime/server/services/eponyme-form-store.js +109 -0
  270. package/dist/runtime/server/services/eponyme-service.d.ts +3 -0
  271. package/dist/runtime/server/services/eponyme-service.js +8 -0
  272. package/dist/runtime/server/services/eponyme-store.d.ts +202 -0
  273. package/dist/runtime/server/services/eponyme-store.js +338 -0
  274. package/dist/runtime/server/utils/auth.d.ts +11 -0
  275. package/dist/runtime/server/utils/auth.js +41 -0
  276. package/dist/runtime/server/utils/eponyme-form.d.ts +14 -0
  277. package/dist/runtime/server/utils/eponyme-form.js +6 -0
  278. package/dist/runtime/server/utils/eponyme-sitemap.d.ts +7 -0
  279. package/dist/runtime/server/utils/eponyme-sitemap.js +7 -0
  280. package/dist/runtime/server/utils/form-route.d.ts +14 -0
  281. package/dist/runtime/server/utils/form-route.js +14 -0
  282. package/dist/runtime/server/utils/password.d.ts +4 -0
  283. package/dist/runtime/server/utils/password.js +30 -0
  284. package/dist/runtime/types/auth.d.ts +20 -0
  285. package/dist/runtime/types/auth.js +7 -0
  286. package/dist/runtime/types/eponyme-config.d.ts +11 -0
  287. package/dist/runtime/types/eponyme-navigation.d.ts +6 -0
  288. package/dist/runtime/types/eponyme-navigation.js +0 -0
  289. package/dist/runtime/types/eponyme.d.ts +87 -0
  290. package/dist/runtime/types/eponyme.js +0 -0
  291. package/dist/runtime/types/field.d.ts +203 -0
  292. package/dist/runtime/types/field.js +0 -0
  293. package/dist/runtime/types/index.d.ts +3 -0
  294. package/dist/runtime/types/index.js +3 -0
  295. package/dist/runtime/types/nuxt.d.ts +11 -0
  296. package/dist/runtime/utils/as-record.d.ts +1 -0
  297. package/dist/runtime/utils/as-record.js +3 -0
  298. package/dist/runtime/utils/build-eponyme-schema.d.ts +22 -0
  299. package/dist/runtime/utils/build-eponyme-schema.js +42 -0
  300. package/dist/runtime/utils/changed-paths.d.ts +6 -0
  301. package/dist/runtime/utils/changed-paths.js +25 -0
  302. package/dist/runtime/utils/create-default-eponyme-data.d.ts +5 -0
  303. package/dist/runtime/utils/create-default-eponyme-data.js +12 -0
  304. package/dist/runtime/utils/field-path.d.ts +14 -0
  305. package/dist/runtime/utils/field-path.js +23 -0
  306. package/dist/runtime/utils/get-eponyme-schemas.d.ts +7 -0
  307. package/dist/runtime/utils/get-eponyme-schemas.js +33 -0
  308. package/dist/runtime/utils/get-field-default-value.d.ts +4 -0
  309. package/dist/runtime/utils/get-field-default-value.js +56 -0
  310. package/dist/runtime/utils/humanize-label.d.ts +6 -0
  311. package/dist/runtime/utils/humanize-label.js +3 -0
  312. package/dist/runtime/utils/initials.d.ts +1 -0
  313. package/dist/runtime/utils/initials.js +3 -0
  314. package/dist/runtime/utils/is-field-visible.d.ts +2 -0
  315. package/dist/runtime/utils/is-field-visible.js +14 -0
  316. package/dist/runtime/utils/normalize-hex-color.d.ts +8 -0
  317. package/dist/runtime/utils/normalize-hex-color.js +11 -0
  318. package/dist/runtime/utils/normalize-slug.d.ts +1 -0
  319. package/dist/runtime/utils/normalize-slug.js +4 -0
  320. package/dist/runtime/utils/preview.d.ts +30 -0
  321. package/dist/runtime/utils/preview.js +30 -0
  322. package/dist/runtime/utils/validate-eponyme-data.d.ts +10 -0
  323. package/dist/runtime/utils/validate-eponyme-data.js +204 -0
  324. package/dist/types.d.mts +11 -0
  325. package/package.json +96 -0
@@ -0,0 +1,203 @@
1
+ export type EponymeFieldType = 'string' | 'slug' | 'email' | 'url' | 'textarea' | 'richText' | 'number' | 'boolean' | 'image' | 'select' | 'radio' | 'checkboxGroup' | 'date' | 'color' | 'array' | 'section' | 'tabs';
2
+ export type FieldVisibilityCondition = {
3
+ field: string;
4
+ equals: unknown;
5
+ notEquals?: never;
6
+ } | {
7
+ field: string;
8
+ notEquals: unknown;
9
+ equals?: never;
10
+ };
11
+ export type FieldValidationResult = true | string | string[] | null | undefined;
12
+ export type FieldValidator<T> = {
13
+ bivarianceHack(value: T, data: Readonly<Record<string, unknown>>): FieldValidationResult;
14
+ }['bivarianceHack'];
15
+ export interface DefaultFieldOptions<T> {
16
+ label?: string;
17
+ description?: string;
18
+ required?: boolean;
19
+ defaultValue?: T;
20
+ visibleWhen?: FieldVisibilityCondition | FieldVisibilityCondition[];
21
+ validate?: FieldValidator<T>;
22
+ }
23
+ export interface TextFieldOptions extends DefaultFieldOptions<string> {
24
+ minLength?: number;
25
+ maxLength?: number;
26
+ showCounter?: boolean;
27
+ placeholder?: string;
28
+ trim?: boolean;
29
+ regex?: RegExp;
30
+ email?: boolean;
31
+ url?: boolean;
32
+ }
33
+ export type StringFieldOptions = TextFieldOptions;
34
+ export type TextareaFieldOptions = TextFieldOptions;
35
+ export interface StringFieldDefinition {
36
+ type: 'string';
37
+ options: StringFieldOptions;
38
+ }
39
+ export interface SlugFieldOptions extends DefaultFieldOptions<string> {
40
+ minLength?: number;
41
+ maxLength?: number;
42
+ showCounter?: boolean;
43
+ placeholder?: string;
44
+ }
45
+ export interface SlugFieldDefinition {
46
+ type: 'slug';
47
+ options: SlugFieldOptions;
48
+ }
49
+ export interface TextareaFieldDefinition {
50
+ type: 'textarea';
51
+ options: TextareaFieldOptions;
52
+ }
53
+ export interface RichTextFieldOptions extends DefaultFieldOptions<string> {
54
+ minLength?: number;
55
+ maxLength?: number;
56
+ showCounter?: boolean;
57
+ placeholder?: string;
58
+ }
59
+ export interface RichTextFieldDefinition {
60
+ type: 'richText';
61
+ options: RichTextFieldOptions;
62
+ }
63
+ export type EmailFieldOptions = TextFieldOptions;
64
+ export interface EmailFieldDefinition {
65
+ type: 'email';
66
+ options: EmailFieldOptions;
67
+ }
68
+ export type UrlType = 'internal' | 'external';
69
+ export interface UrlValue {
70
+ href: string;
71
+ type: UrlType;
72
+ openInNewTab: boolean;
73
+ }
74
+ export interface UrlFieldOptions extends DefaultFieldOptions<UrlValue> {
75
+ placeholder?: string;
76
+ }
77
+ export interface UrlFieldDefinition {
78
+ type: 'url';
79
+ options: UrlFieldOptions;
80
+ }
81
+ export interface NumberFieldOptions extends DefaultFieldOptions<number> {
82
+ min?: number;
83
+ max?: number;
84
+ step?: number;
85
+ slider?: boolean;
86
+ }
87
+ export interface NumberFieldDefinition {
88
+ type: 'number';
89
+ options: NumberFieldOptions;
90
+ }
91
+ export type BooleanFieldOptions = DefaultFieldOptions<boolean>;
92
+ export interface BooleanFieldDefinition {
93
+ type: 'boolean';
94
+ options: BooleanFieldOptions;
95
+ }
96
+ export interface ImageFieldOptions extends DefaultFieldOptions<string> {
97
+ label?: string;
98
+ description?: string;
99
+ placeholder?: string;
100
+ }
101
+ export interface ImageFieldDefinition {
102
+ type: 'image';
103
+ options: ImageFieldOptions;
104
+ }
105
+ export interface SelectOption<T extends string = string> {
106
+ label: string;
107
+ value: T;
108
+ }
109
+ export interface SelectFieldOptions<T extends string = string> extends DefaultFieldOptions<T> {
110
+ options: ReadonlyArray<SelectOption<T>>;
111
+ placeholder?: string;
112
+ }
113
+ export interface SelectFieldDefinition<T extends string = string> {
114
+ type: 'select';
115
+ options: SelectFieldOptions<T>;
116
+ }
117
+ export interface RadioFieldOptions<T extends string = string> extends DefaultFieldOptions<T> {
118
+ options: ReadonlyArray<SelectOption<T>>;
119
+ }
120
+ export interface RadioFieldDefinition<T extends string = string> {
121
+ type: 'radio';
122
+ options: RadioFieldOptions<T>;
123
+ }
124
+ export interface CheckboxGroupFieldOptions<T extends string = string> extends DefaultFieldOptions<T[]> {
125
+ options: ReadonlyArray<SelectOption<T>>;
126
+ minItems?: number;
127
+ maxItems?: number;
128
+ }
129
+ export interface CheckboxGroupFieldDefinition<T extends string = string> {
130
+ type: 'checkboxGroup';
131
+ options: CheckboxGroupFieldOptions<T>;
132
+ }
133
+ export interface TodayDateDefault {
134
+ readonly __eponymeDefault: 'today';
135
+ }
136
+ export interface DateFieldOptions extends Omit<DefaultFieldOptions<string>, 'defaultValue'> {
137
+ defaultValue?: string | TodayDateDefault;
138
+ min?: string;
139
+ max?: string;
140
+ }
141
+ export interface DateFieldDefinition {
142
+ type: 'date';
143
+ options: DateFieldOptions;
144
+ }
145
+ export interface ColorPreset {
146
+ label: string;
147
+ value: string;
148
+ }
149
+ export interface ColorFieldOptions extends DefaultFieldOptions<string> {
150
+ /** Clickable palette for this field; falls back to the module-wide `colorPresets`. */
151
+ presets?: ReadonlyArray<string | ColorPreset>;
152
+ }
153
+ export interface ColorFieldDefinition {
154
+ type: 'color';
155
+ options: ColorFieldOptions;
156
+ }
157
+ export type ArrayItemFieldDefinition = StringFieldDefinition | SlugFieldDefinition | EmailFieldDefinition | UrlFieldDefinition | TextareaFieldDefinition | RichTextFieldDefinition | NumberFieldDefinition | BooleanFieldDefinition | ImageFieldDefinition | SelectFieldDefinition | RadioFieldDefinition | CheckboxGroupFieldDefinition | DateFieldDefinition | ColorFieldDefinition;
158
+ export type ArrayItemSchema = Record<string, ArrayItemFieldDefinition>;
159
+ export type ArrayItemDefinition = ArrayItemFieldDefinition | ArrayItemSchema;
160
+ export type ArrayItemValue<T extends ArrayItemDefinition> = T extends NumberFieldDefinition ? number : T extends BooleanFieldDefinition ? boolean : T extends UrlFieldDefinition ? UrlValue : T extends CheckboxGroupFieldDefinition<infer Value> ? Value[] : T extends ArrayItemFieldDefinition ? string : T extends ArrayItemSchema ? {
161
+ [K in keyof T]: ArrayItemValue<T[K]>;
162
+ } : never;
163
+ export interface ArrayFieldOptions<T extends ArrayItemDefinition> extends DefaultFieldOptions<Array<ArrayItemValue<T>>> {
164
+ of: T;
165
+ minItems?: number;
166
+ maxItems?: number;
167
+ addLabel?: string;
168
+ itemLabel?: string;
169
+ showCounter?: boolean;
170
+ }
171
+ export interface ArrayFieldDefinition<T extends ArrayItemDefinition = ArrayItemDefinition> {
172
+ type: 'array';
173
+ options: ArrayFieldOptions<T>;
174
+ }
175
+ export type SectionItemFieldDefinition = ArrayItemFieldDefinition | ArrayFieldDefinition;
176
+ export type SectionSchema = Record<string, SectionItemFieldDefinition>;
177
+ export type SectionItemValue<T extends SectionItemFieldDefinition> = T extends ArrayFieldDefinition<infer Item> ? Array<ArrayItemValue<Item>> : T extends ArrayItemFieldDefinition ? ArrayItemValue<T> : never;
178
+ export type SectionValue<T extends SectionSchema> = {
179
+ [K in keyof T]: SectionItemValue<T[K]>;
180
+ };
181
+ export interface SectionFieldOptions<T extends SectionSchema> extends DefaultFieldOptions<SectionValue<T>> {
182
+ fields: T;
183
+ }
184
+ export interface SectionFieldDefinition<T extends SectionSchema = SectionSchema> {
185
+ type: 'section';
186
+ options: SectionFieldOptions<T>;
187
+ }
188
+ export interface TabDefinition<T extends SectionSchema = SectionSchema> {
189
+ label?: string;
190
+ fields: T;
191
+ }
192
+ export type TabsSchema = Record<string, TabDefinition>;
193
+ export type TabsValue<T extends TabsSchema> = {
194
+ [K in keyof T]: SectionValue<T[K]['fields']>;
195
+ };
196
+ export interface TabFieldOptions<T extends TabsSchema> extends DefaultFieldOptions<TabsValue<T>> {
197
+ tabs: T;
198
+ }
199
+ export interface TabFieldDefinition<T extends TabsSchema = TabsSchema> {
200
+ type: 'tabs';
201
+ options: TabFieldOptions<T>;
202
+ }
203
+ export type FieldDefinition = SectionItemFieldDefinition | SectionFieldDefinition | TabFieldDefinition;
File without changes
@@ -0,0 +1,3 @@
1
+ export * from './auth.js';
2
+ export * from './eponyme.js';
3
+ export * from './field.js';
@@ -0,0 +1,3 @@
1
+ export * from "./auth.js";
2
+ export * from "./eponyme.js";
3
+ export * from "./field.js";
@@ -0,0 +1,11 @@
1
+ import type { ModuleOptions } from '../../module'
2
+
3
+ declare module '@nuxt/schema' {
4
+ interface NuxtConfig {
5
+ eponyme?: ModuleOptions
6
+ }
7
+
8
+ interface NuxtOptions {
9
+ eponyme: ModuleOptions
10
+ }
11
+ }
@@ -0,0 +1 @@
1
+ export declare function asRecord(value: unknown): Record<string, unknown>;
@@ -0,0 +1,3 @@
1
+ export function asRecord(value) {
2
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
3
+ }
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ import type { EponymeSchema } from '../types/index.js';
3
+ import { type ValidationErrors, type ValidationMode } from './validate-eponyme-data.js';
4
+ /**
5
+ * Exposes the Eponyme rules as a standard zod schema, so the same validation runs
6
+ * server-side on write and client-side on every keystroke.
7
+ *
8
+ * The rules themselves stay in `validate-eponyme-data.ts`: they carry mode-dependent
9
+ * semantics (`required` and lower bounds only apply when publishing) and cross-field
10
+ * context (`visibleWhen`, custom `validate`) that static zod checks cannot express.
11
+ * This wrapper turns the resulting path-keyed errors into zod issues, which is what
12
+ * gives consumers `issue.path` and a familiar `safeParse` API.
13
+ */
14
+ export type EponymeZodSchema = z.ZodType<Record<string, unknown>>;
15
+ /** Cached per (schema, mode) pair: the client rebuilds nothing while typing. */
16
+ export declare function buildEponymeSchema(schema: EponymeSchema, mode?: ValidationMode): EponymeZodSchema;
17
+ /** Same shape as a patch validation, for validating a partial payload. */
18
+ export declare function buildEponymePatchSchema(schema: EponymeSchema, mode?: ValidationMode): EponymeZodSchema;
19
+ /** Turns a zod error back into the `{ path: messages }` shape the API and the editor use. */
20
+ export declare function zodErrorToValidationErrors(error: z.ZodError): ValidationErrors;
21
+ /** Convenience wrapper: parse and get errors keyed by field path. */
22
+ export declare function validateWithSchema(schema: EponymeSchema, data: unknown, mode?: ValidationMode): ValidationErrors;
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { validateEponymeData, validateEponymePatch } from "./validate-eponyme-data.js";
3
+ const cache = /* @__PURE__ */ new WeakMap();
4
+ function toIssuePath(path) {
5
+ return path === "_form" ? [] : path.split(".").map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
6
+ }
7
+ function addErrorsToContext(errors, ctx) {
8
+ for (const [path, messages] of Object.entries(errors)) {
9
+ for (const message of messages)
10
+ ctx.addIssue({ code: "custom", message, path: toIssuePath(path) });
11
+ }
12
+ }
13
+ function createSchema(schema, mode) {
14
+ return z.custom((value) => Boolean(value) && typeof value === "object" && !Array.isArray(value), {
15
+ message: "Body must be an object."
16
+ }).superRefine((value, ctx) => addErrorsToContext(validateEponymeData(schema, value, mode), ctx));
17
+ }
18
+ export function buildEponymeSchema(schema, mode = "publish") {
19
+ const modes = cache.get(schema) ?? {};
20
+ if (!modes[mode]) {
21
+ modes[mode] = createSchema(schema, mode);
22
+ cache.set(schema, modes);
23
+ }
24
+ return modes[mode];
25
+ }
26
+ export function buildEponymePatchSchema(schema, mode = "publish") {
27
+ return z.custom((value) => Boolean(value) && typeof value === "object" && !Array.isArray(value), {
28
+ message: "Body must be an object."
29
+ }).superRefine((value, ctx) => addErrorsToContext(validateEponymePatch(schema, value, value, mode), ctx));
30
+ }
31
+ export function zodErrorToValidationErrors(error) {
32
+ const errors = /* @__PURE__ */ Object.create(null);
33
+ for (const issue of error.issues) {
34
+ const path = issue.path.length ? issue.path.join(".") : "_form";
35
+ (errors[path] ??= []).push(issue.message);
36
+ }
37
+ return errors;
38
+ }
39
+ export function validateWithSchema(schema, data, mode = "publish") {
40
+ const result = buildEponymeSchema(schema, mode).safeParse(data);
41
+ return result.success ? /* @__PURE__ */ Object.create(null) : zodErrorToValidationErrors(result.error);
42
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Dotted paths of every leaf that differs between two documents — `hero.title`,
3
+ * `items.0.title`. Used to tell which fields the user actually edited, so inline
4
+ * validation only flags those.
5
+ */
6
+ export declare function changedPaths(next: unknown, previous: unknown, prefix?: string): string[];
@@ -0,0 +1,25 @@
1
+ export function changedPaths(next, previous, prefix = "") {
2
+ if (next === previous) return [];
3
+ const nextRecord = isRecord(next) ? next : void 0;
4
+ const previousRecord = isRecord(previous) ? previous : void 0;
5
+ if (nextRecord && (previousRecord || previous === void 0) || previousRecord && next === void 0) {
6
+ const left = nextRecord ?? {};
7
+ const right = previousRecord ?? {};
8
+ return [.../* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)])].flatMap((key) => changedPaths(left[key], right[key], join(prefix, key)));
9
+ }
10
+ const nextArray = Array.isArray(next) ? next : void 0;
11
+ const previousArray = Array.isArray(previous) ? previous : void 0;
12
+ if (nextArray && (previousArray || previous === void 0) || previousArray && next === void 0) {
13
+ const left = nextArray ?? [];
14
+ const right = previousArray ?? [];
15
+ const length = Math.max(left.length, right.length);
16
+ return Array.from({ length }, (_, index) => index).flatMap((index) => changedPaths(left[index], right[index], join(prefix, String(index))));
17
+ }
18
+ return JSON.stringify(next) === JSON.stringify(previous) ? [] : [prefix];
19
+ }
20
+ function isRecord(value) {
21
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
22
+ }
23
+ function join(prefix, key) {
24
+ return prefix ? `${prefix}.${key}` : key;
25
+ }
@@ -0,0 +1,5 @@
1
+ import type { EponymeConfig, EponymeData, EponymeSchema } from '../types/index.js';
2
+ export declare function createDefaultEponymeData<T extends EponymeSchema>(schema: T): EponymeData<T>;
3
+ export declare function createDefaultEponymeDataByConfig<T extends EponymeConfig>(config: T): {
4
+ [k: string]: EponymeData<EponymeSchema>;
5
+ };
@@ -0,0 +1,12 @@
1
+ import { getFieldDefaultValue } from "./get-field-default-value.js";
2
+ import { getEponymeSchemas } from "./get-eponyme-schemas.js";
3
+ export function createDefaultEponymeData(schema) {
4
+ return Object.fromEntries(
5
+ Object.entries(schema).map(([name, definition]) => [name, getFieldDefaultValue(definition)])
6
+ );
7
+ }
8
+ export function createDefaultEponymeDataByConfig(config) {
9
+ return Object.fromEntries(
10
+ Object.entries(getEponymeSchemas(config)).map(([name, schema]) => [name, createDefaultEponymeData(schema)])
11
+ );
12
+ }
@@ -0,0 +1,14 @@
1
+ import type { ValidationErrors } from './validate-eponyme-data.js';
2
+ /** `hero` + `title` -> `hero.title`; array items use their index as a segment. */
3
+ export declare function joinFieldPath(prefix: string, segment: string | number): string;
4
+ /** Stable DOM id for a field path, usable in `for`/`aria-*` attributes. */
5
+ export declare function fieldPathId(path: string): string;
6
+ /** Messages recorded for this exact path. */
7
+ export declare function errorsAt(errors: ValidationErrors | undefined, path: string): string[];
8
+ /**
9
+ * Errors of everything nested under `path`, re-keyed relative to it, so a container can
10
+ * hand its children exactly what concerns them without knowing its own depth.
11
+ */
12
+ export declare function childErrors(errors: ValidationErrors | undefined, path: string): ValidationErrors;
13
+ /** True when this path, or anything under it, has at least one message. */
14
+ export declare function hasErrorsUnder(errors: ValidationErrors | undefined, path: string): boolean;
@@ -0,0 +1,23 @@
1
+ export function joinFieldPath(prefix, segment) {
2
+ return prefix ? `${prefix}.${segment}` : String(segment);
3
+ }
4
+ export function fieldPathId(path) {
5
+ return `field-${path.replace(/\./g, "-")}`;
6
+ }
7
+ export function errorsAt(errors, path) {
8
+ return errors?.[path] ?? [];
9
+ }
10
+ export function childErrors(errors, path) {
11
+ if (!errors) return {};
12
+ const prefix = `${path}.`;
13
+ const nested = {};
14
+ for (const [key, messages] of Object.entries(errors)) {
15
+ if (key.startsWith(prefix)) nested[key.slice(prefix.length)] = messages;
16
+ }
17
+ return nested;
18
+ }
19
+ export function hasErrorsUnder(errors, path) {
20
+ if (!errors) return false;
21
+ const prefix = `${path}.`;
22
+ return Object.keys(errors).some((key) => key === path || key.startsWith(prefix));
23
+ }
@@ -0,0 +1,7 @@
1
+ import type { EponymeCollectionDefinitionBase, EponymeConfig, EponymeFormDefinitionBase, EponymeSchema } from '../types/index.js';
2
+ export declare function isEponymeCollection(value: unknown): value is EponymeCollectionDefinitionBase;
3
+ export declare function isEponymeForm(value: unknown): value is EponymeFormDefinitionBase;
4
+ export declare function isEponymeSchema(value: EponymeSchema | EponymeCollectionDefinitionBase | EponymeFormDefinitionBase | EponymeConfig): value is EponymeSchema;
5
+ export declare function getEponymeSchemas(config: EponymeConfig, prefix?: string): Record<string, EponymeSchema>;
6
+ export declare function getEponymeCollections(config: EponymeConfig, prefix?: string): Record<string, EponymeCollectionDefinitionBase>;
7
+ export declare function getEponymeForms(config: EponymeConfig, prefix?: string): Record<string, EponymeFormDefinitionBase>;
@@ -0,0 +1,33 @@
1
+ export function isEponymeCollection(value) {
2
+ return Boolean(value && typeof value === "object" && !Array.isArray(value) && value.__eponymeCollection === true);
3
+ }
4
+ export function isEponymeForm(value) {
5
+ return Boolean(value && typeof value === "object" && !Array.isArray(value) && value.__eponymeForm === true);
6
+ }
7
+ export function isEponymeSchema(value) {
8
+ if (isEponymeCollection(value) || isEponymeForm(value)) return false;
9
+ return Object.values(value).every((field) => typeof field === "object" && field !== null && "type" in field && typeof field.type === "string");
10
+ }
11
+ export function getEponymeSchemas(config, prefix = "") {
12
+ return Object.fromEntries(Object.entries(config).flatMap(([name, value]) => {
13
+ const path = prefix ? `${prefix}/${name}` : name;
14
+ if (isEponymeCollection(value) || isEponymeForm(value)) return [];
15
+ return isEponymeSchema(value) ? [[path, value]] : Object.entries(getEponymeSchemas(value, path));
16
+ }));
17
+ }
18
+ export function getEponymeCollections(config, prefix = "") {
19
+ return Object.fromEntries(Object.entries(config).flatMap(([name, value]) => {
20
+ const path = prefix ? `${prefix}/${name}` : name;
21
+ if (isEponymeCollection(value)) return [[path, value]];
22
+ if (isEponymeForm(value)) return [];
23
+ return isEponymeSchema(value) ? [] : Object.entries(getEponymeCollections(value, path));
24
+ }));
25
+ }
26
+ export function getEponymeForms(config, prefix = "") {
27
+ return Object.fromEntries(Object.entries(config).flatMap(([name, value]) => {
28
+ const path = prefix ? `${prefix}/${name}` : name;
29
+ if (isEponymeForm(value)) return [[path, value]];
30
+ if (isEponymeCollection(value)) return [];
31
+ return isEponymeSchema(value) ? [] : Object.entries(getEponymeForms(value, path));
32
+ }));
33
+ }
@@ -0,0 +1,4 @@
1
+ import type { ArrayItemDefinition, ArrayItemFieldDefinition, FieldDefinition } from '../types/field.js';
2
+ export declare function isArrayItemFieldDefinition(definition: ArrayItemDefinition): definition is ArrayItemFieldDefinition;
3
+ export declare function getArrayItemDefaultValue(definition: ArrayItemDefinition): unknown;
4
+ export declare function getFieldDefaultValue(definition: FieldDefinition): unknown;
@@ -0,0 +1,56 @@
1
+ export function isArrayItemFieldDefinition(definition) {
2
+ return "type" in definition;
3
+ }
4
+ export function getArrayItemDefaultValue(definition) {
5
+ if (isArrayItemFieldDefinition(definition)) return getFieldDefaultValue(definition);
6
+ return Object.fromEntries(
7
+ Object.entries(definition).map(([name, field]) => [name, getFieldDefaultValue(field)])
8
+ );
9
+ }
10
+ export function getFieldDefaultValue(definition) {
11
+ if (definition.type === "date" && isTodayDateDefault(definition.options.defaultValue))
12
+ return getLocalToday();
13
+ if (definition.options.defaultValue !== void 0)
14
+ return cloneDefaultValue(definition.options.defaultValue);
15
+ switch (definition.type) {
16
+ case "array":
17
+ return [];
18
+ case "checkboxGroup":
19
+ return [];
20
+ case "section":
21
+ return Object.fromEntries(
22
+ Object.entries(definition.options.fields).map(([name, field]) => [name, getFieldDefaultValue(field)])
23
+ );
24
+ case "tabs":
25
+ return Object.fromEntries(
26
+ Object.entries(definition.options.tabs).map(([tabName, tab]) => [
27
+ tabName,
28
+ Object.fromEntries(Object.entries(tab.fields).map(([name, field]) => [name, getFieldDefaultValue(field)]))
29
+ ])
30
+ );
31
+ case "number":
32
+ return 0;
33
+ case "url":
34
+ return { href: "", type: "external", openInNewTab: false };
35
+ case "boolean":
36
+ return false;
37
+ default:
38
+ return "";
39
+ }
40
+ }
41
+ function isTodayDateDefault(value) {
42
+ return Boolean(value && typeof value === "object" && "__eponymeDefault" in value && value.__eponymeDefault === "today");
43
+ }
44
+ function getLocalToday() {
45
+ const date = /* @__PURE__ */ new Date();
46
+ const year = date.getFullYear();
47
+ const month = String(date.getMonth() + 1).padStart(2, "0");
48
+ const day = String(date.getDate()).padStart(2, "0");
49
+ return `${year}-${month}-${day}`;
50
+ }
51
+ function cloneDefaultValue(value) {
52
+ if (Array.isArray(value)) return value.map(cloneDefaultValue);
53
+ if (value && typeof value === "object")
54
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cloneDefaultValue(item)]));
55
+ return value;
56
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Turns a field name into a human label: `launch_date` -> `Launch Date`.
3
+ * Shared by every layer so what the editor shows and what error messages refer to
4
+ * can never drift apart.
5
+ */
6
+ export declare function humanizeLabel(name: string, configured?: string): string;
@@ -0,0 +1,3 @@
1
+ export function humanizeLabel(name, configured) {
2
+ return configured || name.replace(/[-_]/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
3
+ }
@@ -0,0 +1 @@
1
+ export declare function initials(value: string): string;
@@ -0,0 +1,3 @@
1
+ export function initials(value) {
2
+ return value.slice(0, 2).toUpperCase();
3
+ }
@@ -0,0 +1,2 @@
1
+ import type { DefaultFieldOptions } from '../types/index.js';
2
+ export declare function isFieldVisible(options: Pick<DefaultFieldOptions<unknown>, 'visibleWhen'>, data: Record<string, unknown>): boolean;
@@ -0,0 +1,14 @@
1
+ function getValue(data, path) {
2
+ return path.split(".").reduce((value, segment) => {
3
+ return value && typeof value === "object" && !Array.isArray(value) ? value[segment] : void 0;
4
+ }, data);
5
+ }
6
+ function matches(condition, data) {
7
+ const value = getValue(data, condition.field);
8
+ return "equals" in condition ? value === condition.equals : value !== condition.notEquals;
9
+ }
10
+ export function isFieldVisible(options, data) {
11
+ if (!options.visibleWhen) return true;
12
+ const conditions = Array.isArray(options.visibleWhen) ? options.visibleWhen : [options.visibleWhen];
13
+ return conditions.every((condition) => matches(condition, data));
14
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Canonical lowercase 6-digit form of a hex colour, or `undefined` when the value is not one.
3
+ * Comparing swatches needs it: a stored `#FFF` and a preset `#ffffff` are the same colour.
4
+ * Alpha (`#rrggbbaa`) is preserved, since the validator accepts it.
5
+ */
6
+ export declare function normalizeHexColor(value: unknown): string | undefined;
7
+ /** True when both values denote the same colour, whatever their notation. */
8
+ export declare function sameHexColor(left: unknown, right: unknown): boolean;
@@ -0,0 +1,11 @@
1
+ export function normalizeHexColor(value) {
2
+ if (typeof value !== "string") return void 0;
3
+ const hex = value.trim().toLowerCase();
4
+ if (/^#[\da-f]{3}$/.test(hex)) return `#${[...hex.slice(1)].map((char) => char + char).join("")}`;
5
+ if (/^#(?:[\da-f]{6}|[\da-f]{8})$/.test(hex)) return hex;
6
+ return void 0;
7
+ }
8
+ export function sameHexColor(left, right) {
9
+ const normalizedLeft = normalizeHexColor(left);
10
+ return normalizedLeft !== void 0 && normalizedLeft === normalizeHexColor(right);
11
+ }
@@ -0,0 +1 @@
1
+ export declare function normalizeSlug(value: string): string;
@@ -0,0 +1,4 @@
1
+ import slugify from "slugify";
2
+ export function normalizeSlug(value) {
3
+ return slugify(value, { lower: true, strict: true, trim: true });
4
+ }
@@ -0,0 +1,30 @@
1
+ /** Mirrors `EponymeVersionSelector`, redeclared so this stays free of server imports. */
2
+ type PreviewVersion = 'draft' | 'published' | number;
3
+ /**
4
+ * Single source of truth for `previewPaths` semantics, shared by the dashboard
5
+ * preview panel and the server-side sitemap builder so both resolve an entry to
6
+ * the exact same public URL.
7
+ */
8
+ /** The slug is URL-encoded. */
9
+ export declare function applyPreviewSlug(path: string, slug: string): string;
10
+ /**
11
+ * Splits `<collection>/<slug>` against the configured collection names.
12
+ * Collection entries are one level deep, so a slug containing `/` never matches.
13
+ */
14
+ export declare function splitCollectionEntry(collectionNames: string[], name: string): {
15
+ collection: string;
16
+ slug: string;
17
+ } | undefined;
18
+ /**
19
+ * An exact key (a singleton) returns its path unchanged; `<collection>/<slug>`
20
+ * returns `previewPaths[collection]` with `:slug` filled in.
21
+ */
22
+ export declare function resolvePreviewPath(previewPaths: Record<string, string>, collectionNames: string[], name: string): string | undefined;
23
+ /** Reads `?__eponyme_preview_version=` — `draft` by default, or a numeric history id. */
24
+ export declare function readPreviewVersion(raw: unknown): PreviewVersion;
25
+ /** Reads the preview query params, unwrapping the repeated-param array form. */
26
+ export declare function readPreviewQuery(query: Record<string, unknown>): {
27
+ entry: string | undefined;
28
+ version: unknown;
29
+ };
30
+ export {};
@@ -0,0 +1,30 @@
1
+ export function applyPreviewSlug(path, slug) {
2
+ return path.replace(/:slug\b/g, encodeURIComponent(slug));
3
+ }
4
+ export function splitCollectionEntry(collectionNames, name) {
5
+ for (const collection of collectionNames) {
6
+ const prefix = `${collection}/`;
7
+ if (!name.startsWith(prefix)) continue;
8
+ const slug = name.slice(prefix.length);
9
+ if (slug && !slug.includes("/")) return { collection, slug };
10
+ }
11
+ }
12
+ export function resolvePreviewPath(previewPaths, collectionNames, name) {
13
+ const exact = previewPaths[name];
14
+ if (exact) return exact;
15
+ const entry = splitCollectionEntry(collectionNames, name);
16
+ if (!entry) return void 0;
17
+ const pattern = previewPaths[entry.collection];
18
+ if (!pattern || !pattern.includes(":slug")) return void 0;
19
+ return applyPreviewSlug(pattern, entry.slug);
20
+ }
21
+ export function readPreviewVersion(raw) {
22
+ if (raw === "published") return "published";
23
+ const id = Number(raw);
24
+ return Number.isSafeInteger(id) && id > 0 ? id : "draft";
25
+ }
26
+ export function readPreviewQuery(query) {
27
+ const entry = Array.isArray(query.__eponyme_preview) ? query.__eponyme_preview[0] : query.__eponyme_preview;
28
+ const version = Array.isArray(query.__eponyme_preview_version) ? query.__eponyme_preview_version[0] : query.__eponyme_preview_version;
29
+ return { entry: entry === void 0 || entry === null ? void 0 : String(entry), version };
30
+ }
@@ -0,0 +1,10 @@
1
+ import type { EponymeSchema } from '../types/index.js';
2
+ /**
3
+ * Errors are keyed by the path of the field they belong to — `title`, `hero.title`,
4
+ * `items.0.title` — so the editor can show each message on the field that produced it.
5
+ * `_form` carries errors about the payload as a whole.
6
+ */
7
+ export type ValidationErrors = Record<string, string[]>;
8
+ export type ValidationMode = 'draft' | 'publish';
9
+ export declare function validateEponymePatch(schema: EponymeSchema, payload: unknown, data?: Record<string, unknown>, mode?: ValidationMode): ValidationErrors;
10
+ export declare function validateEponymeData(schema: EponymeSchema, data: Record<string, unknown>, mode?: ValidationMode): ValidationErrors;