emdash 0.17.2 → 0.19.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 (415) hide show
  1. package/dist/api/route-utils.d.mts +2 -2
  2. package/dist/api/route-utils.mjs +14 -14
  3. package/dist/api/schemas/index.d.mts +2 -2
  4. package/dist/api/schemas/index.mjs +3 -3
  5. package/dist/{api-B7GATEYo.mjs → api-BZ6bhjYs.mjs} +88 -16
  6. package/dist/api-BZ6bhjYs.mjs.map +1 -0
  7. package/dist/{apply-BrVqULFe.mjs → apply-hQkKKBCf.mjs} +23 -23
  8. package/dist/apply-hQkKKBCf.mjs.map +1 -0
  9. package/dist/astro/index.d.mts +8 -8
  10. package/dist/astro/index.d.mts.map +1 -1
  11. package/dist/astro/index.mjs +113 -23
  12. package/dist/astro/index.mjs.map +1 -1
  13. package/dist/astro/middleware/auth.d.mts +7 -7
  14. package/dist/astro/middleware/auth.mjs +2 -2
  15. package/dist/astro/middleware/redirect.mjs +4 -4
  16. package/dist/astro/middleware/request-context.mjs +2 -2
  17. package/dist/astro/middleware.d.mts +26 -4
  18. package/dist/astro/middleware.d.mts.map +1 -1
  19. package/dist/astro/middleware.mjs +414 -215
  20. package/dist/astro/middleware.mjs.map +1 -1
  21. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +5 -5
  22. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +5 -5
  23. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +2 -2
  24. package/dist/astro/routes/api/admin/api-tokens/index.mjs +3 -3
  25. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +5 -5
  26. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +8 -8
  27. package/dist/astro/routes/api/admin/byline-fields/index.mjs +8 -8
  28. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +8 -8
  29. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +12 -12
  30. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +12 -12
  31. package/dist/astro/routes/api/admin/bylines/index.mjs +12 -12
  32. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +11 -11
  33. package/dist/astro/routes/api/admin/comments/_id_.mjs +5 -5
  34. package/dist/astro/routes/api/admin/comments/bulk.mjs +8 -8
  35. package/dist/astro/routes/api/admin/comments/counts.mjs +5 -5
  36. package/dist/astro/routes/api/admin/comments/index.mjs +8 -8
  37. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +5 -5
  38. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +4 -4
  39. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +3 -3
  40. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +3 -3
  41. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +31 -31
  42. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +31 -31
  43. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +30 -30
  44. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +30 -30
  45. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +30 -30
  46. package/dist/astro/routes/api/admin/plugins/index.mjs +30 -30
  47. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +3 -3
  48. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +30 -30
  49. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +30 -30
  50. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +30 -30
  51. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +30 -30
  52. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +31 -31
  53. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +30 -30
  54. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +31 -31
  55. package/dist/astro/routes/api/admin/plugins/updates.mjs +30 -30
  56. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +30 -30
  57. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +3 -3
  58. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +30 -30
  59. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +3 -3
  60. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +2 -2
  61. package/dist/astro/routes/api/admin/users/_id_/index.mjs +6 -6
  62. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +4 -4
  63. package/dist/astro/routes/api/admin/users/index.mjs +5 -5
  64. package/dist/astro/routes/api/auth/dev-bypass.mjs +3 -3
  65. package/dist/astro/routes/api/auth/invite/accept.mjs +2 -2
  66. package/dist/astro/routes/api/auth/invite/complete.mjs +6 -6
  67. package/dist/astro/routes/api/auth/invite/index.mjs +7 -7
  68. package/dist/astro/routes/api/auth/invite/register-options.mjs +6 -6
  69. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  70. package/dist/astro/routes/api/auth/magic-link/send.mjs +8 -8
  71. package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
  72. package/dist/astro/routes/api/auth/me.mjs +6 -6
  73. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +2 -2
  74. package/dist/astro/routes/api/auth/passkey/_id_.mjs +5 -5
  75. package/dist/astro/routes/api/auth/passkey/index.mjs +2 -2
  76. package/dist/astro/routes/api/auth/passkey/options.mjs +7 -7
  77. package/dist/astro/routes/api/auth/passkey/register/options.mjs +6 -6
  78. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +6 -6
  79. package/dist/astro/routes/api/auth/passkey/verify.mjs +6 -6
  80. package/dist/astro/routes/api/auth/signup/complete.mjs +6 -6
  81. package/dist/astro/routes/api/auth/signup/request.mjs +8 -8
  82. package/dist/astro/routes/api/auth/signup/verify.mjs +2 -2
  83. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +11 -11
  84. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +3 -3
  85. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +6 -5
  86. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs.map +1 -1
  87. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +3 -3
  88. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +3 -3
  89. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +8 -8
  90. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +9 -8
  91. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
  92. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +3 -3
  93. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +3 -3
  94. package/dist/astro/routes/api/content/_collection_/_id_/schedule.d.mts.map +1 -1
  95. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +12 -10
  96. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
  97. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +11 -11
  98. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +3 -3
  99. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +6 -5
  100. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs.map +1 -1
  101. package/dist/astro/routes/api/content/_collection_/_id_.mjs +9 -8
  102. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  103. package/dist/astro/routes/api/content/_collection_/authors.d.mts +8 -0
  104. package/dist/astro/routes/api/content/_collection_/authors.d.mts.map +1 -0
  105. package/dist/astro/routes/api/content/_collection_/authors.mjs +19 -0
  106. package/dist/astro/routes/api/content/_collection_/authors.mjs.map +1 -0
  107. package/dist/astro/routes/api/content/_collection_/index.mjs +6 -6
  108. package/dist/astro/routes/api/content/_collection_/trash.mjs +6 -6
  109. package/dist/astro/routes/api/dashboard.mjs +7 -7
  110. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  111. package/dist/astro/routes/api/import/probe.d.mts +2 -2
  112. package/dist/astro/routes/api/import/probe.mjs +6 -6
  113. package/dist/astro/routes/api/import/wordpress/analyze.mjs +4 -4
  114. package/dist/astro/routes/api/import/wordpress/execute.d.mts +7 -7
  115. package/dist/astro/routes/api/import/wordpress/execute.mjs +9 -9
  116. package/dist/astro/routes/api/import/wordpress/media.mjs +6 -6
  117. package/dist/astro/routes/api/import/wordpress/prepare.mjs +9 -9
  118. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +8 -8
  119. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +6 -6
  120. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +9 -9
  121. package/dist/astro/routes/api/manifest.mjs +3 -3
  122. package/dist/astro/routes/api/mcp.mjs +28 -28
  123. package/dist/astro/routes/api/media/_id_/confirm.mjs +6 -6
  124. package/dist/astro/routes/api/media/_id_.mjs +6 -6
  125. package/dist/astro/routes/api/media/file/_...key_.mjs +2 -2
  126. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +3 -3
  127. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +3 -3
  128. package/dist/astro/routes/api/media/providers/index.mjs +3 -3
  129. package/dist/astro/routes/api/media/upload-url.mjs +6 -6
  130. package/dist/astro/routes/api/media.mjs +7 -7
  131. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +7 -7
  132. package/dist/astro/routes/api/menus/_name_/items.mjs +7 -7
  133. package/dist/astro/routes/api/menus/_name_/reorder.mjs +7 -7
  134. package/dist/astro/routes/api/menus/_name_/translations.mjs +7 -7
  135. package/dist/astro/routes/api/menus/_name_.mjs +7 -7
  136. package/dist/astro/routes/api/menus/index.mjs +7 -7
  137. package/dist/astro/routes/api/oauth/authorize.mjs +1 -1
  138. package/dist/astro/routes/api/oauth/device/authorize.mjs +4 -4
  139. package/dist/astro/routes/api/oauth/device/code.mjs +5 -5
  140. package/dist/astro/routes/api/oauth/device/token.mjs +5 -5
  141. package/dist/astro/routes/api/oauth/register.mjs +2 -2
  142. package/dist/astro/routes/api/oauth/token/refresh.mjs +4 -4
  143. package/dist/astro/routes/api/oauth/token/revoke.mjs +4 -4
  144. package/dist/astro/routes/api/oauth/token.mjs +4 -4
  145. package/dist/astro/routes/api/openapi.json.mjs +17 -3
  146. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  147. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +3 -3
  148. package/dist/astro/routes/api/redirects/404s/index.mjs +9 -9
  149. package/dist/astro/routes/api/redirects/404s/summary.mjs +9 -9
  150. package/dist/astro/routes/api/redirects/_id_.mjs +10 -10
  151. package/dist/astro/routes/api/redirects/index.mjs +10 -10
  152. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +3 -3
  153. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +3 -3
  154. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +30 -30
  155. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +30 -30
  156. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +30 -30
  157. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +30 -30
  158. package/dist/astro/routes/api/schema/collections/index.mjs +30 -30
  159. package/dist/astro/routes/api/schema/index.mjs +6 -6
  160. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +30 -30
  161. package/dist/astro/routes/api/schema/orphans/index.mjs +30 -30
  162. package/dist/astro/routes/api/search/enable.mjs +9 -9
  163. package/dist/astro/routes/api/search/index.mjs +8 -8
  164. package/dist/astro/routes/api/search/rebuild.mjs +9 -9
  165. package/dist/astro/routes/api/search/stats.mjs +6 -6
  166. package/dist/astro/routes/api/search/suggest.mjs +8 -8
  167. package/dist/astro/routes/api/sections/_slug_.mjs +8 -8
  168. package/dist/astro/routes/api/sections/index.mjs +8 -8
  169. package/dist/astro/routes/api/settings/email.mjs +5 -5
  170. package/dist/astro/routes/api/settings.mjs +12 -12
  171. package/dist/astro/routes/api/setup/admin-verify.mjs +6 -6
  172. package/dist/astro/routes/api/setup/admin.mjs +6 -6
  173. package/dist/astro/routes/api/setup/dev-bypass.mjs +18 -18
  174. package/dist/astro/routes/api/setup/dev-reset.mjs +3 -3
  175. package/dist/astro/routes/api/setup/index.mjs +21 -21
  176. package/dist/astro/routes/api/setup/status.mjs +3 -3
  177. package/dist/astro/routes/api/snapshot.mjs +5 -5
  178. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +11 -11
  179. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +11 -11
  180. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +11 -11
  181. package/dist/astro/routes/api/taxonomies/index.mjs +11 -11
  182. package/dist/astro/routes/api/themes/preview.mjs +5 -5
  183. package/dist/astro/routes/api/typegen.mjs +5 -5
  184. package/dist/astro/routes/api/well-known/auth.mjs +1 -1
  185. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +6 -6
  186. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +8 -8
  187. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +8 -8
  188. package/dist/astro/routes/api/widget-areas/_name_.mjs +5 -5
  189. package/dist/astro/routes/api/widget-areas/index.mjs +8 -8
  190. package/dist/astro/routes/api/widget-components.mjs +2 -2
  191. package/dist/astro/routes/robots.txt.mjs +6 -6
  192. package/dist/astro/routes/sitemap-_collection_.xml.mjs +6 -6
  193. package/dist/astro/routes/sitemap.xml.mjs +6 -6
  194. package/dist/astro/types.d.mts +15 -8
  195. package/dist/astro/types.d.mts.map +1 -1
  196. package/dist/{authorize-CLTmOUyx.mjs → authorize-C_8t2KGa.mjs} +2 -2
  197. package/dist/{authorize-CLTmOUyx.mjs.map → authorize-C_8t2KGa.mjs.map} +1 -1
  198. package/dist/{byline-CAhk4FrG.mjs → byline-DUx48sJp.mjs} +6 -6
  199. package/dist/{byline-CAhk4FrG.mjs.map → byline-DUx48sJp.mjs.map} +1 -1
  200. package/dist/{byline-fields-Dr-xcb6S.mjs → byline-fields-51kg6Vuv.mjs} +3 -3
  201. package/dist/{byline-fields-Dr-xcb6S.mjs.map → byline-fields-51kg6Vuv.mjs.map} +1 -1
  202. package/dist/{byline-fields-DC3Wkk-U.mjs → byline-fields-C_OsR-KF.mjs} +2 -2
  203. package/dist/{byline-fields-DC3Wkk-U.mjs.map → byline-fields-C_OsR-KF.mjs.map} +1 -1
  204. package/dist/{byline-fields-CR5hGLMw.d.mts → byline-fields-DYXKDuNX.d.mts} +53 -29
  205. package/dist/byline-fields-DYXKDuNX.d.mts.map +1 -0
  206. package/dist/{byline-registry-CxK5g559.mjs → byline-registry-CWP7I71B.mjs} +3 -3
  207. package/dist/{byline-registry-CxK5g559.mjs.map → byline-registry-CWP7I71B.mjs.map} +1 -1
  208. package/dist/{bylines-CbrD7STW.mjs → bylines-Cx5n-WqP.mjs} +3 -3
  209. package/dist/{bylines-CbrD7STW.mjs.map → bylines-Cx5n-WqP.mjs.map} +1 -1
  210. package/dist/{bylines-DCczH3AV.mjs → bylines-wurS258E.mjs} +50 -6
  211. package/dist/{bylines-DCczH3AV.mjs.map → bylines-wurS258E.mjs.map} +1 -1
  212. package/dist/{cache-DIHHyPkt.mjs → cache-B_HzASVT.mjs} +3 -3
  213. package/dist/{cache-DIHHyPkt.mjs.map → cache-B_HzASVT.mjs.map} +1 -1
  214. package/dist/{chunks-DnnHlRG3.mjs → chunks-BerYVuve.mjs} +2 -2
  215. package/dist/{chunks-DnnHlRG3.mjs.map → chunks-BerYVuve.mjs.map} +1 -1
  216. package/dist/cli/index.mjs +40 -27
  217. package/dist/cli/index.mjs.map +1 -1
  218. package/dist/client/cf-access.d.mts +1 -1
  219. package/dist/client/index.d.mts +1 -1
  220. package/dist/{comment-DkAfGX9E.mjs → comment-sqQxNpN3.mjs} +2 -2
  221. package/dist/{comment-DkAfGX9E.mjs.map → comment-sqQxNpN3.mjs.map} +1 -1
  222. package/dist/{comments-DLFnXs7J.mjs → comments-CJ0RZsYR.mjs} +3 -3
  223. package/dist/{comments-DLFnXs7J.mjs.map → comments-CJ0RZsYR.mjs.map} +1 -1
  224. package/dist/{content-C7aJ7keg.mjs → content-BIlVx-RX.mjs} +132 -43
  225. package/dist/content-BIlVx-RX.mjs.map +1 -0
  226. package/dist/{context-Ca0HkaIh.mjs → context-GG52SPgh.mjs} +10 -10
  227. package/dist/{context-Ca0HkaIh.mjs.map → context-GG52SPgh.mjs.map} +1 -1
  228. package/dist/{cron-DZovZUnC.mjs → cron-BJ2ClIlj.mjs} +4 -3
  229. package/dist/cron-BJ2ClIlj.mjs.map +1 -0
  230. package/dist/{dashboard-BrfLIsX1.mjs → dashboard-2JgAMWxK.mjs} +4 -4
  231. package/dist/{dashboard-BrfLIsX1.mjs.map → dashboard-2JgAMWxK.mjs.map} +1 -1
  232. package/dist/db/index.d.mts +2 -2
  233. package/dist/db/index.mjs +1 -1
  234. package/dist/{device-flow-ptLrVINd.mjs → device-flow-s6_q3T7A.mjs} +2 -2
  235. package/dist/{device-flow-ptLrVINd.mjs.map → device-flow-s6_q3T7A.mjs.map} +1 -1
  236. package/dist/{error-Bk9s3Ism.mjs → error-RwM4dD35.mjs} +2 -2
  237. package/dist/{error-Bk9s3Ism.mjs.map → error-RwM4dD35.mjs.map} +1 -1
  238. package/dist/{fts-manager-XpDfbIKo.mjs → fts-manager-1RgHmopc.mjs} +2 -2
  239. package/dist/{fts-manager-XpDfbIKo.mjs.map → fts-manager-1RgHmopc.mjs.map} +1 -1
  240. package/dist/{index-D60_SzHG.d.mts → index-BpYeJO1E.d.mts} +2 -2
  241. package/dist/{index-D60_SzHG.d.mts.map → index-BpYeJO1E.d.mts.map} +1 -1
  242. package/dist/{index-C8ciqSMJ.d.mts → index-FfiTQJq2.d.mts} +202 -20
  243. package/dist/index-FfiTQJq2.d.mts.map +1 -0
  244. package/dist/index.d.mts +9 -9
  245. package/dist/index.mjs +43 -43
  246. package/dist/{load-CF5oETkh.mjs → load-B84ohfBk.mjs} +2 -2
  247. package/dist/{load-CF5oETkh.mjs.map → load-B84ohfBk.mjs.map} +1 -1
  248. package/dist/{loader-BxyvbrZP.mjs → loader-CpZKpFz0.mjs} +32 -30
  249. package/dist/loader-CpZKpFz0.mjs.map +1 -0
  250. package/dist/media/index.mjs +1 -1
  251. package/dist/media/local-runtime.d.mts +7 -7
  252. package/dist/media/local-runtime.mjs +6 -6
  253. package/dist/{media-Cyz5BhSN.mjs → media-JOf3pNkw.mjs} +2 -2
  254. package/dist/{media-Cyz5BhSN.mjs.map → media-JOf3pNkw.mjs.map} +1 -1
  255. package/dist/{menus-PFp8FDuO.mjs → menus-DX4_E01q.mjs} +3 -3
  256. package/dist/{menus-PFp8FDuO.mjs.map → menus-DX4_E01q.mjs.map} +1 -1
  257. package/dist/{menus-CIdZ_Q6U.mjs → menus-Dp9xporj.mjs} +112 -16
  258. package/dist/menus-Dp9xporj.mjs.map +1 -0
  259. package/dist/{normalize-DVV8nbrL.mjs → normalize-CK5o04zr.mjs} +2 -2
  260. package/dist/{normalize-DVV8nbrL.mjs.map → normalize-CK5o04zr.mjs.map} +1 -1
  261. package/dist/{oauth-authorization-DvBAL75d.mjs → oauth-authorization-1aPAYjiC.mjs} +2 -2
  262. package/dist/{oauth-authorization-DvBAL75d.mjs.map → oauth-authorization-1aPAYjiC.mjs.map} +1 -1
  263. package/dist/{options-BL4X94qY.mjs → options-BPCVnesz.mjs} +1 -1
  264. package/dist/{options-BL4X94qY.mjs.map → options-BPCVnesz.mjs.map} +1 -1
  265. package/dist/{options-tb7DJROi.d.mts → options-D4MnavW_.d.mts} +3 -3
  266. package/dist/{options-tb7DJROi.d.mts.map → options-D4MnavW_.d.mts.map} +1 -1
  267. package/dist/{parse-B-K21lvm.mjs → parse-CrGndy1A.mjs} +2 -2
  268. package/dist/{parse-B-K21lvm.mjs.map → parse-CrGndy1A.mjs.map} +1 -1
  269. package/dist/{patterns-CqG5Ya3i.mjs → patterns-p-RBdTbM.mjs} +1 -1
  270. package/dist/{patterns-CqG5Ya3i.mjs.map → patterns-p-RBdTbM.mjs.map} +1 -1
  271. package/dist/plugin-utils.d.mts +7 -7
  272. package/dist/plugins/adapt-sandbox-entry.d.mts +7 -7
  273. package/dist/{query-Cc649nDl.mjs → query-BFQ029Ts.mjs} +21 -15
  274. package/dist/query-BFQ029Ts.mjs.map +1 -0
  275. package/dist/{rate-limit-BI1OdpQH.mjs → rate-limit-ClFFUga6.mjs} +2 -2
  276. package/dist/{rate-limit-BI1OdpQH.mjs.map → rate-limit-ClFFUga6.mjs.map} +1 -1
  277. package/dist/{redirect-C-FeA4j9.mjs → redirect-CRWIt8Zj.mjs} +3 -3
  278. package/dist/{redirect-C-FeA4j9.mjs.map → redirect-CRWIt8Zj.mjs.map} +1 -1
  279. package/dist/{redirects-C0L9JUk4.mjs → redirects-DEygMrRO.mjs} +25 -3
  280. package/dist/redirects-DEygMrRO.mjs.map +1 -0
  281. package/dist/{redirects-C1UgU9E0.mjs → redirects-OIu6vQ2i.mjs} +5 -5
  282. package/dist/{redirects-C1UgU9E0.mjs.map → redirects-OIu6vQ2i.mjs.map} +1 -1
  283. package/dist/{registry-C-T_PWgp.mjs → registry-brYh-rAT.mjs} +6 -6
  284. package/dist/{registry-C-T_PWgp.mjs.map → registry-brYh-rAT.mjs.map} +1 -1
  285. package/dist/{request-cache-BYMs-BGX.mjs → request-cache-D32LpnmI.mjs} +1 -1
  286. package/dist/{request-cache-BYMs-BGX.mjs.map → request-cache-D32LpnmI.mjs.map} +1 -1
  287. package/dist/{runner-BiuUfx-V.mjs → runner--4wMWwKM.mjs} +224 -168
  288. package/dist/runner--4wMWwKM.mjs.map +1 -0
  289. package/dist/{runner-DM1yR5qd.d.mts → runner-BcRuXq_h.d.mts} +2 -2
  290. package/dist/{runner-DM1yR5qd.d.mts.map → runner-BcRuXq_h.d.mts.map} +1 -1
  291. package/dist/runtime.d.mts +7 -7
  292. package/dist/runtime.mjs +2 -2
  293. package/dist/{schema-BpCJh2lU.mjs → schema-CS7Eg5gh.mjs} +5 -5
  294. package/dist/{schema-BpCJh2lU.mjs.map → schema-CS7Eg5gh.mjs.map} +1 -1
  295. package/dist/{search-BrF7k0Ho.mjs → search-o-aQzHI1.mjs} +4 -4
  296. package/dist/{search-BrF7k0Ho.mjs.map → search-o-aQzHI1.mjs.map} +1 -1
  297. package/dist/{secrets-YYbTgB1w.mjs → secrets-C_ZtRos3.mjs} +2 -2
  298. package/dist/{secrets-YYbTgB1w.mjs.map → secrets-C_ZtRos3.mjs.map} +1 -1
  299. package/dist/{sections-8DEa-dWt.mjs → sections-DhsZ0ns9.mjs} +3 -3
  300. package/dist/{sections-8DEa-dWt.mjs.map → sections-DhsZ0ns9.mjs.map} +1 -1
  301. package/dist/seed/index.d.mts +2 -2
  302. package/dist/seed/index.mjs +16 -16
  303. package/dist/seo/index.d.mts +1 -1
  304. package/dist/{seo-CKr7pLfA.mjs → seo-B5e6y9Wk.mjs} +2 -2
  305. package/dist/{seo-CKr7pLfA.mjs.map → seo-B5e6y9Wk.mjs.map} +1 -1
  306. package/dist/{service-9P2cdyR_.mjs → service-DAxg8RPR.mjs} +2 -2
  307. package/dist/{service-9P2cdyR_.mjs.map → service-DAxg8RPR.mjs.map} +1 -1
  308. package/dist/{settings-Jro4YcUb.mjs → settings-B1p-gPUK.mjs} +5 -5
  309. package/dist/{settings-Jro4YcUb.mjs.map → settings-B1p-gPUK.mjs.map} +1 -1
  310. package/dist/{settings-DYVzINdn.mjs → settings-DIsbHTRE.mjs} +3 -3
  311. package/dist/{settings-DYVzINdn.mjs.map → settings-DIsbHTRE.mjs.map} +1 -1
  312. package/dist/{setup-complete-VoEZfasi.mjs → setup-complete-Yuv78yua.mjs} +2 -2
  313. package/dist/{setup-complete-VoEZfasi.mjs.map → setup-complete-Yuv78yua.mjs.map} +1 -1
  314. package/dist/{site-url-Cm8-sJy7.mjs → site-url-mEVmwIFi.mjs} +2 -2
  315. package/dist/{site-url-Cm8-sJy7.mjs.map → site-url-mEVmwIFi.mjs.map} +1 -1
  316. package/dist/{taxonomies-CGD6y79Q.mjs → taxonomies-BEW7S5AI.mjs} +10 -8
  317. package/dist/taxonomies-BEW7S5AI.mjs.map +1 -0
  318. package/dist/{taxonomies-C0bVme_m.mjs → taxonomies-UusDXv3C.mjs} +4 -4
  319. package/dist/{taxonomies-C0bVme_m.mjs.map → taxonomies-UusDXv3C.mjs.map} +1 -1
  320. package/dist/{taxonomy-Db5xwphL.mjs → taxonomy-CdllE4oq.mjs} +3 -3
  321. package/dist/{taxonomy-Db5xwphL.mjs.map → taxonomy-CdllE4oq.mjs.map} +1 -1
  322. package/dist/{transaction-NQj4VJ7Z.mjs → transaction-x2tJQ-A1.mjs} +1 -1
  323. package/dist/{transaction-NQj4VJ7Z.mjs.map → transaction-x2tJQ-A1.mjs.map} +1 -1
  324. package/dist/{transport-OnMNbsIA.d.mts → transport-BwQeeY2p.d.mts} +1 -1
  325. package/dist/{transport-OnMNbsIA.d.mts.map → transport-BwQeeY2p.d.mts.map} +1 -1
  326. package/dist/{types-CfyYQ7eY.mjs → types-BXSUSAjt.mjs} +16 -3
  327. package/dist/{types-CfyYQ7eY.mjs.map → types-BXSUSAjt.mjs.map} +1 -1
  328. package/dist/{types-D8bhH891.mjs → types-DZk_y-MU.mjs} +1 -1
  329. package/dist/{types-D8bhH891.mjs.map → types-DZk_y-MU.mjs.map} +1 -1
  330. package/dist/{types-DawhLFwy.d.mts → types-OT_Es5mp.d.mts} +26 -1
  331. package/dist/{types-DawhLFwy.d.mts.map → types-OT_Es5mp.d.mts.map} +1 -1
  332. package/dist/{types-i8_uzhMD.d.mts → types-WVmpZBJV.d.mts} +18 -3
  333. package/dist/types-WVmpZBJV.d.mts.map +1 -0
  334. package/dist/{user-tLdHUEXV.mjs → user-C0um7wrg.mjs} +18 -2
  335. package/dist/user-C0um7wrg.mjs.map +1 -0
  336. package/dist/{validate-Dy6nkNls.d.mts → validate-BPAHUSge.d.mts} +10 -2
  337. package/dist/validate-BPAHUSge.d.mts.map +1 -0
  338. package/dist/{validate-DWmnRg6E.mjs → validate-ZP9Dvg0P.mjs} +6 -3
  339. package/dist/validate-ZP9Dvg0P.mjs.map +1 -0
  340. package/dist/{validation-BQ_TP-On.mjs → validation-CE5i4q0c.mjs} +5 -5
  341. package/dist/{validation-BQ_TP-On.mjs.map → validation-CE5i4q0c.mjs.map} +1 -1
  342. package/dist/version-Dw0JXu45.mjs +7 -0
  343. package/dist/{version-CgcnMvqS.mjs.map → version-Dw0JXu45.mjs.map} +1 -1
  344. package/dist/{widgets-DzlINGI6.mjs → widgets-ClEnYQCH.mjs} +2 -2
  345. package/dist/{widgets-DzlINGI6.mjs.map → widgets-ClEnYQCH.mjs.map} +1 -1
  346. package/dist/{zod-generator-MMm56Prt.mjs → zod-generator-Djo_VHCt.mjs} +4 -3
  347. package/dist/zod-generator-Djo_VHCt.mjs.map +1 -0
  348. package/package.json +7 -7
  349. package/src/api/handlers/content.ts +107 -8
  350. package/src/api/handlers/index.ts +2 -0
  351. package/src/api/openapi/document.ts +25 -0
  352. package/src/api/schemas/content.ts +33 -0
  353. package/src/astro/integration/index.ts +98 -0
  354. package/src/astro/integration/routes.ts +6 -0
  355. package/src/astro/integration/virtual-modules.ts +39 -0
  356. package/src/astro/integration/vite-config.ts +12 -0
  357. package/src/astro/middleware/stream-end-metrics.ts +96 -0
  358. package/src/astro/middleware.ts +107 -31
  359. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +4 -2
  360. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +4 -2
  361. package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +8 -4
  362. package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +4 -2
  363. package/src/astro/routes/api/content/[collection]/[id].ts +4 -2
  364. package/src/astro/routes/api/content/[collection]/authors.ts +34 -0
  365. package/src/astro/types.ts +8 -1
  366. package/src/bylines/index.ts +57 -0
  367. package/src/cli/commands/export-seed.ts +28 -12
  368. package/src/components/EmDashImage.astro +23 -4
  369. package/src/components/Image.astro +20 -3
  370. package/src/database/migrations/043_content_references.ts +121 -0
  371. package/src/database/migrations/runner.ts +9 -2
  372. package/src/database/repositories/content.ts +225 -67
  373. package/src/database/repositories/index.ts +7 -0
  374. package/src/database/repositories/relation.ts +467 -0
  375. package/src/database/repositories/types.ts +31 -0
  376. package/src/database/repositories/user.ts +18 -0
  377. package/src/database/types.ts +34 -0
  378. package/src/emdash-runtime.ts +318 -168
  379. package/src/index.ts +8 -1
  380. package/src/loader.ts +67 -34
  381. package/src/media/responsive.ts +125 -0
  382. package/src/menus/index.ts +27 -9
  383. package/src/plugins/cron.ts +3 -2
  384. package/src/plugins/hooks.ts +35 -6
  385. package/src/plugins/index.ts +5 -0
  386. package/src/plugins/manager.ts +1 -0
  387. package/src/plugins/scheduler/node.ts +9 -2
  388. package/src/query.ts +32 -5
  389. package/src/scheduled-publish.ts +153 -0
  390. package/src/schema/zod-generator.ts +6 -2
  391. package/src/seed/apply.ts +16 -6
  392. package/src/seed/types.ts +9 -0
  393. package/src/seed/validate.ts +15 -0
  394. package/src/taxonomies/index.ts +13 -8
  395. package/src/utils/init-lock.ts +143 -0
  396. package/src/virtual-modules.d.ts +11 -0
  397. package/dist/api-B7GATEYo.mjs.map +0 -1
  398. package/dist/apply-BrVqULFe.mjs.map +0 -1
  399. package/dist/byline-fields-CR5hGLMw.d.mts.map +0 -1
  400. package/dist/content-C7aJ7keg.mjs.map +0 -1
  401. package/dist/cron-DZovZUnC.mjs.map +0 -1
  402. package/dist/index-C8ciqSMJ.d.mts.map +0 -1
  403. package/dist/loader-BxyvbrZP.mjs.map +0 -1
  404. package/dist/menus-CIdZ_Q6U.mjs.map +0 -1
  405. package/dist/query-Cc649nDl.mjs.map +0 -1
  406. package/dist/redirects-C0L9JUk4.mjs.map +0 -1
  407. package/dist/runner-BiuUfx-V.mjs.map +0 -1
  408. package/dist/taxonomies-CGD6y79Q.mjs.map +0 -1
  409. package/dist/types-i8_uzhMD.d.mts.map +0 -1
  410. package/dist/user-tLdHUEXV.mjs.map +0 -1
  411. package/dist/validate-DWmnRg6E.mjs.map +0 -1
  412. package/dist/validate-Dy6nkNls.d.mts.map +0 -1
  413. package/dist/version-CgcnMvqS.mjs +0 -7
  414. package/dist/zod-generator-MMm56Prt.mjs.map +0 -1
  415. package/src/plugins/scheduler/piggyback.ts +0 -71
@@ -65,6 +65,14 @@ declare const contentListQuery: z.ZodObject<{
65
65
  }>>;
66
66
  locale: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
67
67
  q: z.ZodOptional<z.ZodString>;
68
+ authorId: z.ZodOptional<z.ZodString>;
69
+ dateField: z.ZodOptional<z.ZodEnum<{
70
+ createdAt: "createdAt";
71
+ updatedAt: "updatedAt";
72
+ publishedAt: "publishedAt";
73
+ }>>;
74
+ dateFrom: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
75
+ dateTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
68
76
  }, z.core.$strip>;
69
77
  declare const contentCreateBody: z.ZodObject<{
70
78
  data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
@@ -346,6 +354,22 @@ declare const contentListResponseSchema: z.ZodObject<{
346
354
  nextCursor: z.ZodOptional<z.ZodString>;
347
355
  total: z.ZodOptional<z.ZodNumber>;
348
356
  }, z.core.$strip>;
357
+ /** A distinct content author for the admin author filter */
358
+ declare const contentAuthorSchema: z.ZodObject<{
359
+ id: z.ZodString;
360
+ name: z.ZodNullable<z.ZodString>;
361
+ email: z.ZodString;
362
+ avatarUrl: z.ZodNullable<z.ZodString>;
363
+ }, z.core.$strip>;
364
+ /** Response for the content authors endpoint */
365
+ declare const contentAuthorsResponseSchema: z.ZodObject<{
366
+ items: z.ZodArray<z.ZodObject<{
367
+ id: z.ZodString;
368
+ name: z.ZodNullable<z.ZodString>;
369
+ email: z.ZodString;
370
+ avatarUrl: z.ZodNullable<z.ZodString>;
371
+ }, z.core.$strip>>;
372
+ }, z.core.$strip>;
349
373
  /** Trashed content item */
350
374
  declare const trashedContentItemSchema: z.ZodObject<{
351
375
  id: z.ZodString;
@@ -590,14 +614,14 @@ declare const createFieldBody: z.ZodObject<{
590
614
  string: "string";
591
615
  number: "number";
592
616
  boolean: "boolean";
593
- file: "file";
617
+ slug: "slug";
618
+ text: "text";
594
619
  url: "url";
620
+ select: "select";
621
+ file: "file";
595
622
  image: "image";
596
- slug: "slug";
597
623
  datetime: "datetime";
598
- text: "text";
599
624
  integer: "integer";
600
- select: "select";
601
625
  multiSelect: "multiSelect";
602
626
  portableText: "portableText";
603
627
  reference: "reference";
@@ -621,10 +645,10 @@ declare const createFieldBody: z.ZodObject<{
621
645
  string: "string";
622
646
  number: "number";
623
647
  boolean: "boolean";
624
- datetime: "datetime";
625
648
  text: "text";
626
- integer: "integer";
627
649
  select: "select";
650
+ datetime: "datetime";
651
+ integer: "integer";
628
652
  }>;
629
653
  label: z.ZodString;
630
654
  required: z.ZodOptional<z.ZodBoolean>;
@@ -659,10 +683,10 @@ declare const updateFieldBody: z.ZodObject<{
659
683
  string: "string";
660
684
  number: "number";
661
685
  boolean: "boolean";
662
- datetime: "datetime";
663
686
  text: "text";
664
- integer: "integer";
665
687
  select: "select";
688
+ datetime: "datetime";
689
+ integer: "integer";
666
690
  }>;
667
691
  label: z.ZodString;
668
692
  required: z.ZodOptional<z.ZodBoolean>;
@@ -715,14 +739,14 @@ declare const fieldSchema: z.ZodObject<{
715
739
  string: "string";
716
740
  number: "number";
717
741
  boolean: "boolean";
718
- file: "file";
742
+ slug: "slug";
743
+ text: "text";
719
744
  url: "url";
745
+ select: "select";
746
+ file: "file";
720
747
  image: "image";
721
- slug: "slug";
722
748
  datetime: "datetime";
723
- text: "text";
724
749
  integer: "integer";
725
- select: "select";
726
750
  multiSelect: "multiSelect";
727
751
  portableText: "portableText";
728
752
  reference: "reference";
@@ -780,14 +804,14 @@ declare const collectionWithFieldsResponseSchema: z.ZodObject<{
780
804
  string: "string";
781
805
  number: "number";
782
806
  boolean: "boolean";
783
- file: "file";
807
+ slug: "slug";
808
+ text: "text";
784
809
  url: "url";
810
+ select: "select";
811
+ file: "file";
785
812
  image: "image";
786
- slug: "slug";
787
813
  datetime: "datetime";
788
- text: "text";
789
814
  integer: "integer";
790
- select: "select";
791
815
  multiSelect: "multiSelect";
792
816
  portableText: "portableText";
793
817
  reference: "reference";
@@ -834,14 +858,14 @@ declare const fieldResponseSchema: z.ZodObject<{
834
858
  string: "string";
835
859
  number: "number";
836
860
  boolean: "boolean";
837
- file: "file";
861
+ slug: "slug";
862
+ text: "text";
838
863
  url: "url";
864
+ select: "select";
865
+ file: "file";
839
866
  image: "image";
840
- slug: "slug";
841
867
  datetime: "datetime";
842
- text: "text";
843
868
  integer: "integer";
844
- select: "select";
845
869
  multiSelect: "multiSelect";
846
870
  portableText: "portableText";
847
871
  reference: "reference";
@@ -871,14 +895,14 @@ declare const fieldListResponseSchema: z.ZodObject<{
871
895
  string: "string";
872
896
  number: "number";
873
897
  boolean: "boolean";
874
- file: "file";
898
+ slug: "slug";
899
+ text: "text";
875
900
  url: "url";
901
+ select: "select";
902
+ file: "file";
876
903
  image: "image";
877
- slug: "slug";
878
904
  datetime: "datetime";
879
- text: "text";
880
905
  integer: "integer";
881
- select: "select";
882
906
  multiSelect: "multiSelect";
883
907
  portableText: "portableText";
884
908
  reference: "reference";
@@ -2053,8 +2077,8 @@ declare const bylineFieldCreateBody: z.ZodObject<{
2053
2077
  type: z.ZodEnum<{
2054
2078
  string: "string";
2055
2079
  boolean: "boolean";
2056
- url: "url";
2057
2080
  text: "text";
2081
+ url: "url";
2058
2082
  select: "select";
2059
2083
  }>;
2060
2084
  required: z.ZodOptional<z.ZodBoolean>;
@@ -2089,8 +2113,8 @@ declare const bylineFieldDefinitionSchema: z.ZodObject<{
2089
2113
  type: z.ZodEnum<{
2090
2114
  string: "string";
2091
2115
  boolean: "boolean";
2092
- url: "url";
2093
2116
  text: "text";
2117
+ url: "url";
2094
2118
  select: "select";
2095
2119
  }>;
2096
2120
  required: z.ZodBoolean;
@@ -2110,8 +2134,8 @@ declare const bylineFieldListResponseSchema: z.ZodObject<{
2110
2134
  type: z.ZodEnum<{
2111
2135
  string: "string";
2112
2136
  boolean: "boolean";
2113
- url: "url";
2114
2137
  text: "text";
2138
+ url: "url";
2115
2139
  select: "select";
2116
2140
  }>;
2117
2141
  required: z.ZodBoolean;
@@ -2140,5 +2164,5 @@ declare const bylineFieldUsageResponseSchema: z.ZodObject<{
2140
2164
  totalAffectedRows: z.ZodNumber;
2141
2165
  }, z.core.$strip>;
2142
2166
  //#endregion
2143
- export { wpRewriteUrlsBody as $, apiErrorSchema as $n, commentSchema as $t, reorderWidgetsBody as A, mediaResponseSchema as An, menuSchema as At, userSchema as B, contentPublishBody as Bn, magicLinkSendBody as Bt, notFoundSummarySchema as C, mediaConfirmBody as Cn, termWithCountSchema as Ct, updateRedirectBody as D, mediaListQuery as Dn, menuItemSchema as Dt, redirectsListQuery as E, mediaItemSchema as En, createMenuItemBody as Et, widgetSchema as F, contentCreateBody as Fn, updateMenuItemBody as Ft, setupAdminVerifyBody as G, contentTermsBody as Gn, passkeyVerifyBody as Gt, usersListQuery as H, contentScheduleBody as Hn, passkeyRegisterOptionsBody as Ht, allowedDomainCreateBody as I, contentItemSchema as In, authMeActionBody as It, importProbeBody as J, contentTrashQuery as Jn, adminCommentListResponseSchema as Jt, setupAtprotoAdminBody as K, contentTranslationSchema as Kn, signupCompleteBody as Kt, allowedDomainUpdateBody as L, contentListQuery as Ln, inviteCompleteBody as Lt, widgetAreaSchema as M, mediaUploadUrlBody as Mn, menuWithItemsSchema as Mt, widgetAreaWithWidgetsAndCountSchema as N, mediaUploadUrlResponseSchema as Nn, reorderMenuItemsBody as Nt, createWidgetAreaBody as O, mediaListResponseSchema as On, menuItemTypeEnum as Ot, widgetAreaWithWidgetsSchema as P, contentCompareResponseSchema as Pn, updateMenuBody as Pt, wpPrepareBody as Q, VALID_ROLE_LEVELS as Qn, commentListQuery as Qt, userDetailSchema as R, contentListResponseSchema as Rn, inviteCreateBody as Rt, notFoundSummaryResponseSchema as S, formatFileSize as Sn, termTranslationsSchema as St, redirectSchema as T, mediaExistingResponseSchema as Tn, createMenuBody as Tt, atprotoLoginBody as U, contentSeoInput as Un, passkeyRegisterVerifyBody as Ut, userUpdateBody as V, contentResponseSchema as Vn, passkeyOptionsBody as Vt, setupAdminBody as W, contentSeoSchema as Wn, passkeyRenameBody as Wt, wpPluginAnalyzeBody as X, trashedContentItemSchema as Xn, commentBulkResponseSchema as Xt, wpMediaImportBody as Y, contentUpdateBody as Yn, commentBulkBody as Yt, wpPluginExecuteBody as Z, trashedContentListResponseSchema as Zn, commentCountsResponseSchema as Zt, notFoundEntrySchema as _, orphanedTableSchema as _n, taxonomyListResponseSchema as _t, bylineFieldUpdateBody as a, collectionListResponseSchema as an, localeFilterQuery as ar, searchSuggestQuery as at, notFoundPruneBody as b, updateFieldBody as bn, termResponseSchema as bt, bylineCreditSchema as c, collectionWithFieldsResponseSchema as cn, slugPattern as cr, createSectionBody as ct, bylineTranslationCreateBody as d, fieldListResponseSchema as dn, sectionsListQuery as dt, commentStatusBody as en, countResponseSchema as er, searchEnableBody as et, bylineTranslationsResponseSchema as f, fieldReorderBody as fn, updateSectionBody as ft, createRedirectBody as g, orphanedTableListResponseSchema as gn, taxonomyDefTranslationsSchema as gt, contentBylineInputSchema as h, orphanRegisterBody as hn, taxonomyDefSchema as ht, bylineFieldReorderBody as i, collectionGetQuery as in, localeCode as ir, searchResultSchema as it, updateWidgetBody as j, mediaUpdateBody as jn, menuTranslationsSchema as jt, createWidgetBody as k, mediaProviderListQuery as kn, menuListItemSchema as kt, bylineListResponseSchema as l, createCollectionBody as ln, successEnvelope as lr, sectionListResponseSchema as lt, bylinesListQuery as m, fieldSchema as mn, createTermBody as mt, bylineFieldDefinitionSchema as n, publicCommentListResponseSchema as nn, deleteResponseSchema as nr, searchRebuildBody as nt, bylineFieldUsageResponseSchema as o, collectionResponseSchema as on, offsetPaginationQuery as or, settingsUpdateBody as ot, bylineUpdateBody as p, fieldResponseSchema as pn, createTaxonomyDefBody as pt, setupBody as q, contentTranslationsResponseSchema as qn, signupRequestBody as qt, bylineFieldListResponseSchema as r, publicCommentSchema as rn, httpUrl as rr, searchResponseSchema as rt, bylineCreateBody as s, collectionSchema as sn, roleLevel as sr, siteSettingsSchema as st, bylineFieldCreateBody as t, createCommentBody as tn, cursorPaginationQuery as tr, searchQuery as tt, bylineSummarySchema as u, createFieldBody as un, sectionSchema as ut, notFoundListQuery as v, schemaExportQuery as vn, termGetResponseSchema as vt, redirectListResponseSchema as w, mediaConfirmResponseSchema as wn, updateTermBody as wt, notFoundSummaryQuery as x, DEFAULT_MAX_UPLOAD_SIZE as xn, termSchema as xt, notFoundListResponseSchema as y, updateCollectionBody as yn, termListResponseSchema as yt, userListResponseSchema as z, contentPreviewUrlBody as zn, inviteRegisterOptionsBody as zt };
2144
- //# sourceMappingURL=byline-fields-CR5hGLMw.d.mts.map
2167
+ export { wpRewriteUrlsBody as $, trashedContentListResponseSchema as $n, commentSchema as $t, reorderWidgetsBody as A, mediaResponseSchema as An, menuSchema as At, userSchema as B, contentListResponseSchema as Bn, magicLinkSendBody as Bt, notFoundSummarySchema as C, mediaConfirmBody as Cn, termWithCountSchema as Ct, updateRedirectBody as D, mediaListQuery as Dn, menuItemSchema as Dt, redirectsListQuery as E, mediaItemSchema as En, createMenuItemBody as Et, widgetSchema as F, contentAuthorsResponseSchema as Fn, updateMenuItemBody as Ft, setupAdminVerifyBody as G, contentSeoInput as Gn, passkeyVerifyBody as Gt, usersListQuery as H, contentPublishBody as Hn, passkeyRegisterOptionsBody as Ht, allowedDomainCreateBody as I, contentCompareResponseSchema as In, authMeActionBody as It, importProbeBody as J, contentTranslationSchema as Jn, adminCommentListResponseSchema as Jt, setupAtprotoAdminBody as K, contentSeoSchema as Kn, signupCompleteBody as Kt, allowedDomainUpdateBody as L, contentCreateBody as Ln, inviteCompleteBody as Lt, widgetAreaSchema as M, mediaUploadUrlBody as Mn, menuWithItemsSchema as Mt, widgetAreaWithWidgetsAndCountSchema as N, mediaUploadUrlResponseSchema as Nn, reorderMenuItemsBody as Nt, createWidgetAreaBody as O, mediaListResponseSchema as On, menuItemTypeEnum as Ot, widgetAreaWithWidgetsSchema as P, contentAuthorSchema as Pn, updateMenuBody as Pt, wpPrepareBody as Q, trashedContentItemSchema as Qn, commentListQuery as Qt, userDetailSchema as R, contentItemSchema as Rn, inviteCreateBody as Rt, notFoundSummaryResponseSchema as S, formatFileSize as Sn, termTranslationsSchema as St, redirectSchema as T, mediaExistingResponseSchema as Tn, createMenuBody as Tt, atprotoLoginBody as U, contentResponseSchema as Un, passkeyRegisterVerifyBody as Ut, userUpdateBody as V, contentPreviewUrlBody as Vn, passkeyOptionsBody as Vt, setupAdminBody as W, contentScheduleBody as Wn, passkeyRenameBody as Wt, wpPluginAnalyzeBody as X, contentTrashQuery as Xn, commentBulkResponseSchema as Xt, wpMediaImportBody as Y, contentTranslationsResponseSchema as Yn, commentBulkBody as Yt, wpPluginExecuteBody as Z, contentUpdateBody as Zn, commentCountsResponseSchema as Zt, notFoundEntrySchema as _, orphanedTableSchema as _n, taxonomyListResponseSchema as _t, bylineFieldUpdateBody as a, collectionListResponseSchema as an, httpUrl as ar, searchSuggestQuery as at, notFoundPruneBody as b, updateFieldBody as bn, termResponseSchema as bt, bylineCreditSchema as c, collectionWithFieldsResponseSchema as cn, offsetPaginationQuery as cr, createSectionBody as ct, bylineTranslationCreateBody as d, fieldListResponseSchema as dn, successEnvelope as dr, sectionsListQuery as dt, commentStatusBody as en, VALID_ROLE_LEVELS as er, searchEnableBody as et, bylineTranslationsResponseSchema as f, fieldReorderBody as fn, updateSectionBody as ft, createRedirectBody as g, orphanedTableListResponseSchema as gn, taxonomyDefTranslationsSchema as gt, contentBylineInputSchema as h, orphanRegisterBody as hn, taxonomyDefSchema as ht, bylineFieldReorderBody as i, collectionGetQuery as in, deleteResponseSchema as ir, searchResultSchema as it, updateWidgetBody as j, mediaUpdateBody as jn, menuTranslationsSchema as jt, createWidgetBody as k, mediaProviderListQuery as kn, menuListItemSchema as kt, bylineListResponseSchema as l, createCollectionBody as ln, roleLevel as lr, sectionListResponseSchema as lt, bylinesListQuery as m, fieldSchema as mn, createTermBody as mt, bylineFieldDefinitionSchema as n, publicCommentListResponseSchema as nn, countResponseSchema as nr, searchRebuildBody as nt, bylineFieldUsageResponseSchema as o, collectionResponseSchema as on, localeCode as or, settingsUpdateBody as ot, bylineUpdateBody as p, fieldResponseSchema as pn, createTaxonomyDefBody as pt, setupBody as q, contentTermsBody as qn, signupRequestBody as qt, bylineFieldListResponseSchema as r, publicCommentSchema as rn, cursorPaginationQuery as rr, searchResponseSchema as rt, bylineCreateBody as s, collectionSchema as sn, localeFilterQuery as sr, siteSettingsSchema as st, bylineFieldCreateBody as t, createCommentBody as tn, apiErrorSchema as tr, searchQuery as tt, bylineSummarySchema as u, createFieldBody as un, slugPattern as ur, sectionSchema as ut, notFoundListQuery as v, schemaExportQuery as vn, termGetResponseSchema as vt, redirectListResponseSchema as w, mediaConfirmResponseSchema as wn, updateTermBody as wt, notFoundSummaryQuery as x, DEFAULT_MAX_UPLOAD_SIZE as xn, termSchema as xt, notFoundListResponseSchema as y, updateCollectionBody as yn, termListResponseSchema as yt, userListResponseSchema as z, contentListQuery as zn, inviteRegisterOptionsBody as zt };
2168
+ //# sourceMappingURL=byline-fields-DYXKDuNX.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"byline-fields-DYXKDuNX.d.mts","names":[],"sources":["../src/api/schemas/common.ts","../src/api/schemas/content.ts","../src/api/schemas/media.ts","../src/api/schemas/schema.ts","../src/api/schemas/comments.ts","../src/api/schemas/auth.ts","../src/api/schemas/menus.ts","../src/api/schemas/taxonomies.ts","../src/api/schemas/sections.ts","../src/api/schemas/settings.ts","../src/api/schemas/search.ts","../src/api/schemas/import.ts","../src/api/schemas/setup.ts","../src/api/schemas/users.ts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;;;;;;;;;;cAmB3B,6BAAA,EAA6B,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;AjBnH1C;;;;;AAMA;ciB6Ha,8BAAA,EAA8B,CAAA,CAAA,SAAA"}
@@ -1,6 +1,6 @@
1
1
  import { t as validateIdentifier } from "./validate-VPnKoIzW.mjs";
2
- import { t as withTransaction } from "./transaction-NQj4VJ7Z.mjs";
3
- import { i as RESERVED_BYLINE_FIELD_SLUGS, t as BYLINE_FIELD_TYPES } from "./types-D8bhH891.mjs";
2
+ import { t as withTransaction } from "./transaction-x2tJQ-A1.mjs";
3
+ import { i as RESERVED_BYLINE_FIELD_SLUGS, t as BYLINE_FIELD_TYPES } from "./types-DZk_y-MU.mjs";
4
4
  import { sql } from "kysely";
5
5
  import { ulid } from "ulidx";
6
6
 
@@ -403,4 +403,4 @@ function mapFieldRow(row) {
403
403
 
404
404
  //#endregion
405
405
  export { BylineSchemaRegistry as n, mapBylineSchemaError as r, BylineSchemaError as t };
406
- //# sourceMappingURL=byline-registry-CxK5g559.mjs.map
406
+ //# sourceMappingURL=byline-registry-CWP7I71B.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"byline-registry-CxK5g559.mjs","names":[],"sources":["../src/schema/byline-registry.ts"],"sourcesContent":["import type { Kysely } from \"kysely\";\nimport { sql } from \"kysely\";\nimport { ulid } from \"ulidx\";\n\nimport { withTransaction } from \"../database/transaction.js\";\nimport type { BylineFieldTable, Database } from \"../database/types.js\";\nimport { validateIdentifier } from \"../database/validate.js\";\nimport {\n\tBYLINE_FIELD_TYPES,\n\tRESERVED_BYLINE_FIELD_SLUGS,\n\ttype BylineFieldDefinition,\n\ttype BylineFieldType,\n\ttype BylineFieldValidation,\n\ttype CreateBylineFieldInput,\n\ttype UpdateBylineFieldInput,\n} from \"./types.js\";\n\nconst RESERVED_SET: ReadonlySet<string> = new Set(RESERVED_BYLINE_FIELD_SLUGS);\nconst TYPE_SET: ReadonlySet<string> = new Set(BYLINE_FIELD_TYPES);\n\nconst VERSION_KEY = \"byline_fields_version\";\n\n/** Hard cap on the choices array for a `select`-type field. */\nconst MAX_SELECT_OPTIONS = 200;\n/** Hard cap on a slug — mirrors `SchemaRegistry.validateSlug`. */\nconst MAX_SLUG_LENGTH = 63;\n/** Hard cap on a label. Bigger than slugs because labels are display strings. */\nconst MAX_LABEL_LENGTH = 200;\n\n/**\n * Error thrown for byline-schema validation failures. Mirrors\n * `SchemaError` in `registry.ts` so the admin API layer can map a small\n * set of codes to HTTP statuses without inspecting messages.\n *\n * Codes:\n * - `INVALID_SLUG` — slug fails identifier rules or length cap\n * - `RESERVED_SLUG` — slug collides with a fixed `_emdash_bylines` column\n * - `INVALID_TYPE` — type is not one of the five v1 field types\n * - `INVALID_LABEL` — label missing or exceeds length cap\n * - `INVALID_VALIDATION` — validation payload malformed (e.g. `select` with\n * no `options`, duplicates in `options`)\n * - `FIELD_EXISTS` — slug already registered\n * - `FIELD_NOT_FOUND` — slug not registered\n * - `TRANSLATABLE_LOCKED` — attempt to flip `translatable` while stored\n * values reference the field\n * - `REORDER_MISMATCH` — reorder input doesn't match the registered set\n */\nexport class BylineSchemaError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic code: string,\n\t\tpublic details?: Record<string, unknown>,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"BylineSchemaError\";\n\t}\n}\n\n/**\n * Translate a `BylineSchemaError` code to a shared `ErrorCode` for the\n * admin API. HTTP status is then derived by `mapErrorStatus` — this\n * function deliberately doesn't carry one, so the API/handler boundary\n * matches the rest of the codebase (handlers return `ApiResult<T>` with\n * a code, the route layer maps to status via `unwrapResult`).\n *\n * Every code on the right-hand side of `case ... return ...` is defined\n * in `ErrorCode` (`api/errors.ts`). `INVALID_LABEL` and\n * `INVALID_VALIDATION` are intentionally folded into the `default`\n * branch (→ `VALIDATION_ERROR`) so no ad-hoc codes leak out — the\n * registry's domain code names them but the HTTP surface should not.\n *\n * `RESERVED_SLUG` / `INVALID_SLUG` typically don't reach this layer for\n * HTTP callers — the zod schema rejects them first with a clean\n * `VALIDATION_ERROR`. They're still listed so non-HTTP callers (and the\n * test layer) get consistent mapping.\n *\n * `FIELD_NOT_FOUND` is normalised to the shared `NOT_FOUND` code so the\n * admin client can branch on one constant across resource types.\n */\nexport function mapBylineSchemaError(error: BylineSchemaError): {\n\tcode: string;\n\tmessage: string;\n\tdetails?: Record<string, unknown>;\n} {\n\tswitch (error.code) {\n\t\tcase \"FIELD_NOT_FOUND\":\n\t\t\treturn { code: \"NOT_FOUND\", message: error.message, details: error.details };\n\t\tcase \"FIELD_EXISTS\":\n\t\tcase \"TRANSLATABLE_LOCKED\":\n\t\tcase \"REORDER_MISMATCH\":\n\t\tcase \"INVALID_SLUG\":\n\t\tcase \"RESERVED_SLUG\":\n\t\tcase \"INVALID_TYPE\":\n\t\t\treturn { code: error.code, message: error.message, details: error.details };\n\t\tdefault:\n\t\t\t// Catches INVALID_LABEL, INVALID_VALIDATION, and any future\n\t\t\t// registry codes we forget to wire up explicitly.\n\t\t\treturn { code: \"VALIDATION_ERROR\", message: error.message, details: error.details };\n\t}\n}\n\n/**\n * Registry for byline custom fields (Discussion #1174).\n *\n * Owns CRUD over `_emdash_byline_fields` and the\n * `options.byline_fields_version` counter that drives cache\n * invalidation in `bylines/field-defs-cache.ts`.\n *\n * **Dirty-bit bookend.** Every mutation runs `markVersionDirty` before\n * the schema write and `markVersionClean` after, as standalone writes\n * (not inside `withTransaction`) so concurrent isolates observe the\n * dirty mark *before* the mutation lands. Parity carries meaning:\n * odd = mutation in flight or crashed mid-flight, even = stable.\n * The cache bypasses the global holder while odd.\n *\n * `markVersionDirty` is parity-aware (idempotent on odd) so a\n * crashed prior attempt doesn't invert the bit.\n * `markVersionClean` always advances to a new even value (+2 from\n * even, +1 from odd) so concurrent mutators can't collapse on the\n * same key and pin a stale cache snapshot. Idempotent-retry exits\n * (`FIELD_EXISTS` / `FIELD_NOT_FOUND` / no-op update) call\n * `markVersionClean` too — same code path doubles as crash recovery\n * and false-clean recovery.\n *\n * The residual race: a reader caching between two concurrent\n * `markVersionClean` calls sees a partial-set snapshot until the\n * second clean lands. Bounded by the inter-clean window (~ms).\n * Schema mutations are admin-only and rare; acceptable for now.\n * A CAS-on-bump or dialect-specific lock is tracked as follow-up.\n *\n * **`deleteField` cascade.** Migration 041 already declares\n * `ON DELETE CASCADE` on both value tables. The explicit deletes\n * here are defense-in-depth against FK-pragma misconfig and mirror\n * `BylineRepository.delete`'s app-level cascade for the bylines\n * domain.\n *\n * Reserved-slug rejection runs at the API layer (zod) *and* here so\n * non-HTTP callers (seeds, scripts) can't bypass the check.\n */\nexport class BylineSchemaRegistry {\n\tconstructor(private db: Kysely<Database>) {}\n\n\tasync listFields(): Promise<BylineFieldDefinition[]> {\n\t\tconst rows = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_fields\")\n\t\t\t.selectAll()\n\t\t\t.orderBy(\"sort_order\", \"asc\")\n\t\t\t.orderBy(\"created_at\", \"asc\")\n\t\t\t.execute();\n\t\treturn rows.map((row) => mapFieldRow(row));\n\t}\n\n\tasync getField(slug: string): Promise<BylineFieldDefinition | null> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_fields\")\n\t\t\t.selectAll()\n\t\t\t.where(\"slug\", \"=\", slug)\n\t\t\t.executeTakeFirst();\n\t\treturn row ? mapFieldRow(row) : null;\n\t}\n\n\tasync getFieldById(id: string): Promise<BylineFieldDefinition | null> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_fields\")\n\t\t\t.selectAll()\n\t\t\t.where(\"id\", \"=\", id)\n\t\t\t.executeTakeFirst();\n\t\treturn row ? mapFieldRow(row) : null;\n\t}\n\n\tasync createField(input: CreateBylineFieldInput): Promise<BylineFieldDefinition> {\n\t\tthis.validateSlug(input.slug);\n\t\tthis.validateLabel(input.label);\n\t\tthis.validateType(input.type);\n\t\tconst validation = this.normaliseValidation(input.type, input.validation ?? null);\n\n\t\tconst existing = await this.getField(input.slug);\n\t\tif (existing) {\n\t\t\t// Idempotent retry exit — see class JSDoc.\n\t\t\tawait this.markVersionClean();\n\t\t\tthrow new BylineSchemaError(`Byline field \"${input.slug}\" already exists`, \"FIELD_EXISTS\", {\n\t\t\t\tslug: input.slug,\n\t\t\t});\n\t\t}\n\n\t\tconst id = ulid();\n\t\tconst sortOrder = input.sortOrder ?? (await this.nextSortOrder());\n\n\t\tawait this.markVersionDirty();\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tawait trx\n\t\t\t\t.insertInto(\"_emdash_byline_fields\")\n\t\t\t\t.values({\n\t\t\t\t\tid,\n\t\t\t\t\tslug: input.slug,\n\t\t\t\t\tlabel: input.label,\n\t\t\t\t\ttype: input.type,\n\t\t\t\t\trequired: input.required ? 1 : 0,\n\t\t\t\t\ttranslatable: input.translatable === false ? 0 : 1,\n\t\t\t\t\tvalidation: validation ? JSON.stringify(validation) : null,\n\t\t\t\t\tsort_order: sortOrder,\n\t\t\t\t})\n\t\t\t\t.execute();\n\t\t});\n\t\tawait this.markVersionClean();\n\n\t\tconst created = await this.getFieldById(id);\n\t\tif (!created) {\n\t\t\t// Should be unreachable on a working DB — but a typed error\n\t\t\t// beats letting the route returning null on a successful path.\n\t\t\tthrow new BylineSchemaError(\"Failed to load created field\", \"FIELD_NOT_FOUND\", {\n\t\t\t\tid,\n\t\t\t});\n\t\t}\n\t\treturn created;\n\t}\n\n\tasync updateField(slug: string, input: UpdateBylineFieldInput): Promise<BylineFieldDefinition> {\n\t\tconst field = await this.getField(slug);\n\t\tif (!field) {\n\t\t\t// Idempotent retry exit — see class JSDoc.\n\t\t\tawait this.markVersionClean();\n\t\t\tthrow new BylineSchemaError(`Byline field \"${slug}\" not found`, \"FIELD_NOT_FOUND\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\n\t\tconst updates: Partial<{\n\t\t\tlabel: string;\n\t\t\trequired: number;\n\t\t\ttranslatable: number;\n\t\t\tvalidation: string | null;\n\t\t\tsort_order: number;\n\t\t\tupdated_at: string;\n\t\t}> = {};\n\n\t\tif (input.label !== undefined) {\n\t\t\tthis.validateLabel(input.label);\n\t\t\tupdates.label = input.label;\n\t\t}\n\n\t\tif (input.required !== undefined) {\n\t\t\tupdates.required = input.required ? 1 : 0;\n\t\t}\n\n\t\tif (input.validation !== undefined) {\n\t\t\t// Validation payload is normalised against the *current* field\n\t\t\t// type — `type` is not updatable, so it's safe to use `field.type`.\n\t\t\tconst validation = this.normaliseValidation(field.type, input.validation);\n\t\t\tupdates.validation = validation ? JSON.stringify(validation) : null;\n\t\t}\n\n\t\tif (input.translatable !== undefined && input.translatable !== field.translatable) {\n\t\t\t// Flipping `translatable` would orphan any values already stored\n\t\t\t// in the table matching the *current* flag. Reject when any\n\t\t\t// value rows reference this field — admins can delete the field\n\t\t\t// (cascading the values) and re-create it with the new flag if\n\t\t\t// they want a clean re-start. Migrating values across tables is\n\t\t\t// out of scope (Discussion #1174 doesn't authorise it).\n\t\t\tconst usage = await this.countFieldValues(field.id);\n\t\t\tif (usage > 0) {\n\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t`Cannot change \"translatable\" on field \"${slug}\" while ${usage} value row(s) exist. ` +\n\t\t\t\t\t\t`Delete the values (or the field) and re-create with the new setting.`,\n\t\t\t\t\t\"TRANSLATABLE_LOCKED\",\n\t\t\t\t\t{ slug, valueCount: usage },\n\t\t\t\t);\n\t\t\t}\n\t\t\tupdates.translatable = input.translatable ? 1 : 0;\n\t\t}\n\n\t\tif (input.sortOrder !== undefined) {\n\t\t\tupdates.sort_order = input.sortOrder;\n\t\t}\n\n\t\tif (Object.keys(updates).length === 0) {\n\t\t\t// No-op update — still advance the clean marker in case\n\t\t\t// we're recovering a crashed prior attempt.\n\t\t\tawait this.markVersionClean();\n\t\t\treturn field;\n\t\t}\n\n\t\tupdates.updated_at = new Date().toISOString();\n\n\t\tawait this.markVersionDirty();\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tawait trx\n\t\t\t\t.updateTable(\"_emdash_byline_fields\")\n\t\t\t\t.set(updates)\n\t\t\t\t.where(\"id\", \"=\", field.id)\n\t\t\t\t.execute();\n\t\t});\n\t\tawait this.markVersionClean();\n\n\t\tconst updated = await this.getFieldById(field.id);\n\t\tif (!updated) {\n\t\t\tthrow new BylineSchemaError(\"Failed to load updated field\", \"FIELD_NOT_FOUND\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\t\treturn updated;\n\t}\n\n\tasync deleteField(slug: string): Promise<void> {\n\t\tconst field = await this.getField(slug);\n\t\tif (!field) {\n\t\t\t// Idempotent retry exit — see class JSDoc.\n\t\t\tawait this.markVersionClean();\n\t\t\tthrow new BylineSchemaError(`Byline field \"${slug}\" not found`, \"FIELD_NOT_FOUND\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\n\t\t// Delete order matters on D1 (no tx): value rows first, definition\n\t\t// row last, so a crash leaves the definition recoverable on retry\n\t\t// rather than orphan values pointing at a vanished id.\n\t\tawait this.markVersionDirty();\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tawait trx\n\t\t\t\t.deleteFrom(\"_emdash_byline_field_values\")\n\t\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t\t.execute();\n\t\t\tawait trx\n\t\t\t\t.deleteFrom(\"_emdash_byline_field_group_values\")\n\t\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t\t.execute();\n\t\t\tawait trx.deleteFrom(\"_emdash_byline_fields\").where(\"id\", \"=\", field.id).execute();\n\t\t});\n\t\tawait this.markVersionClean();\n\t}\n\n\t/**\n\t * Reorder fields by slug. The input must be the *exact* set of\n\t * currently registered slugs — no adds, no drops, no duplicates. This\n\t * keeps the operation invertible (any reorder is followed by a reverse\n\t * reorder) and removes a class of \"did I forget a field?\" bugs at the\n\t * API layer.\n\t */\n\tasync reorderFields(slugs: string[]): Promise<void> {\n\t\tif (new Set(slugs).size !== slugs.length) {\n\t\t\tthrow new BylineSchemaError(\"Reorder input contains duplicate slugs\", \"REORDER_MISMATCH\", {\n\t\t\t\tslugs,\n\t\t\t});\n\t\t}\n\n\t\tconst registered = await this.listFields();\n\t\tconst registeredSlugs = registered.map((f) => f.slug).toSorted();\n\t\tconst inputSlugs = slugs.toSorted();\n\n\t\tif (registeredSlugs.length !== inputSlugs.length) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\t`Reorder input has ${inputSlugs.length} slug(s); ${registeredSlugs.length} registered`,\n\t\t\t\t\"REORDER_MISMATCH\",\n\t\t\t\t{ registered: registeredSlugs, input: inputSlugs },\n\t\t\t);\n\t\t}\n\t\tfor (let i = 0; i < registeredSlugs.length; i++) {\n\t\t\tif (registeredSlugs[i] !== inputSlugs[i]) {\n\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t\"Reorder input does not match the registered field set\",\n\t\t\t\t\t\"REORDER_MISMATCH\",\n\t\t\t\t\t{ registered: registeredSlugs, input: inputSlugs },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst now = new Date().toISOString();\n\t\tawait this.markVersionDirty();\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tfor (let i = 0; i < slugs.length; i++) {\n\t\t\t\tconst slug = slugs[i];\n\t\t\t\tif (slug === undefined) continue;\n\t\t\t\tawait trx\n\t\t\t\t\t.updateTable(\"_emdash_byline_fields\")\n\t\t\t\t\t.set({ sort_order: i, updated_at: now })\n\t\t\t\t\t.where(\"slug\", \"=\", slug)\n\t\t\t\t\t.execute();\n\t\t\t}\n\t\t});\n\t\tawait this.markVersionClean();\n\t}\n\n\t/**\n\t * Per-table usage counts for a field, plus the sum. Backs the\n\t * destructive-delete confirm dialog in the admin UI (Phase 5).\n\t *\n\t * Both counts are surfaced separately for diagnostic value: a\n\t * non-zero count on the table that doesn't match the field's current\n\t * `translatable` flag indicates historical drift (e.g. a flip from\n\t * an older code path). Today the registry rejects such flips with\n\t * `TRANSLATABLE_LOCKED`, so any drift originates pre-Phase-2.\n\t *\n\t * Throws `FIELD_NOT_FOUND` when the slug doesn't resolve — callers\n\t * shouldn't get back zero counts for a missing field.\n\t */\n\tasync getFieldUsage(slug: string): Promise<{\n\t\ttranslatableValueCount: number;\n\t\tgroupValueCount: number;\n\t\ttotalAffectedRows: number;\n\t}> {\n\t\tconst field = await this.getField(slug);\n\t\tif (!field) {\n\t\t\tthrow new BylineSchemaError(`Byline field \"${slug}\" not found`, \"FIELD_NOT_FOUND\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\t\tconst tr = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_field_values\")\n\t\t\t.select(({ fn }) => [fn.count<number>(\"field_id\").as(\"count\")])\n\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t.executeTakeFirst();\n\t\tconst grp = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_field_group_values\")\n\t\t\t.select(({ fn }) => [fn.count<number>(\"field_id\").as(\"count\")])\n\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t.executeTakeFirst();\n\t\tconst translatableValueCount = Number(tr?.count ?? 0);\n\t\tconst groupValueCount = Number(grp?.count ?? 0);\n\t\treturn {\n\t\t\ttranslatableValueCount,\n\t\t\tgroupValueCount,\n\t\t\ttotalAffectedRows: translatableValueCount + groupValueCount,\n\t\t};\n\t}\n\n\t/**\n\t * Read the persisted version counter. Used by the field-defs cache\n\t * (Phase 3) to detect invalidation. Returns `0` when the row is\n\t * missing — covers the \"tests that didn't run migration 041\" case\n\t * without throwing.\n\t */\n\tasync getVersion(): Promise<number> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"options\")\n\t\t\t.select(\"value\")\n\t\t\t.where(\"name\", \"=\", VERSION_KEY)\n\t\t\t.executeTakeFirst();\n\t\tif (!row) return 0;\n\t\tconst parsed = Number.parseInt(row.value, 10);\n\t\treturn Number.isFinite(parsed) ? parsed : 0;\n\t}\n\n\t// ============================================\n\t// Private helpers\n\t// ============================================\n\n\t/**\n\t * Force the version counter to an odd integer (\"dirty\"). Idempotent\n\t * on odd so a crashed prior attempt can't invert parity. Upsert (not\n\t * UPDATE) so a missing row still flips parity — `getVersion` returns\n\t * 0 on missing, which is even, so a bare UPDATE would leave the\n\t * cache pinned on a stale snapshot. See the class JSDoc.\n\t *\n\t * `options.value` qualified: PG's `ON CONFLICT DO UPDATE` puts both\n\t * the target and `EXCLUDED.value` in scope; bare `value` is ambiguous.\n\t */\n\tprivate async markVersionDirty(): Promise<void> {\n\t\tawait sql`\n\t\t\tINSERT INTO options (name, value)\n\t\t\tVALUES (${VERSION_KEY}, '1')\n\t\t\tON CONFLICT(name) DO UPDATE SET value = CASE\n\t\t\t\tWHEN CAST(options.value AS INTEGER) % 2 = 0\n\t\t\t\t\tTHEN CAST(CAST(options.value AS INTEGER) + 1 AS TEXT)\n\t\t\t\tELSE options.value\n\t\t\tEND\n\t\t`.execute(this.db);\n\t}\n\n\t/**\n\t * Force the version counter to a **new** even integer (+2 from even,\n\t * +1 from odd). Always-advance — never a no-op — so two concurrent\n\t * mutators can't collapse on the same even key and pin a stale cache\n\t * snapshot. See the class JSDoc for the concurrent-collapse rationale.\n\t *\n\t * `options.value` qualified — see `markVersionDirty`.\n\t */\n\tprivate async markVersionClean(): Promise<void> {\n\t\tawait sql`\n\t\t\tINSERT INTO options (name, value)\n\t\t\tVALUES (${VERSION_KEY}, '2')\n\t\t\tON CONFLICT(name) DO UPDATE SET value = CASE\n\t\t\t\tWHEN CAST(options.value AS INTEGER) % 2 = 0\n\t\t\t\t\tTHEN CAST(CAST(options.value AS INTEGER) + 2 AS TEXT)\n\t\t\t\tELSE CAST(CAST(options.value AS INTEGER) + 1 AS TEXT)\n\t\t\tEND\n\t\t`.execute(this.db);\n\t}\n\n\tprivate async nextSortOrder(): Promise<number> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_fields\")\n\t\t\t.select(({ fn }) => [fn.max<number | null>(\"sort_order\").as(\"max\")])\n\t\t\t.executeTakeFirst();\n\t\tconst max = row?.max ?? null;\n\t\treturn max === null ? 0 : max + 1;\n\t}\n\n\tprivate async countFieldValues(fieldId: string): Promise<number> {\n\t\t// Count both per-locale and group-shared values. A field can only\n\t\t// store in one table at a time (translatable picks), but historic\n\t\t// rows might exist in the other if a prior version of this code\n\t\t// allowed the flip — count both to be safe.\n\t\tconst tr = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_field_values\")\n\t\t\t.select(({ fn }) => [fn.count<number>(\"field_id\").as(\"count\")])\n\t\t\t.where(\"field_id\", \"=\", fieldId)\n\t\t\t.executeTakeFirst();\n\t\tconst grp = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_field_group_values\")\n\t\t\t.select(({ fn }) => [fn.count<number>(\"field_id\").as(\"count\")])\n\t\t\t.where(\"field_id\", \"=\", fieldId)\n\t\t\t.executeTakeFirst();\n\t\treturn Number(tr?.count ?? 0) + Number(grp?.count ?? 0);\n\t}\n\n\tprivate validateSlug(slug: string): void {\n\t\tif (!slug || typeof slug !== \"string\") {\n\t\t\tthrow new BylineSchemaError(\"Byline field slug is required\", \"INVALID_SLUG\", { slug });\n\t\t}\n\t\tif (slug.length > MAX_SLUG_LENGTH) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\t`Byline field slug must be ${MAX_SLUG_LENGTH} characters or less`,\n\t\t\t\t\"INVALID_SLUG\",\n\t\t\t\t{ slug },\n\t\t\t);\n\t\t}\n\t\t// `validateIdentifier` enforces /^[a-z][a-z0-9_]*$/ — rejects\n\t\t// camelCase, PascalCase, hyphens, leading digits, and identifiers\n\t\t// over 128 characters. We hit the 63-char cap above first, which\n\t\t// matches the content-collection slug cap.\n\t\ttry {\n\t\t\tvalidateIdentifier(slug, \"byline field slug\");\n\t\t} catch (error) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\terror instanceof Error ? error.message : \"Invalid byline field slug\",\n\t\t\t\t\"INVALID_SLUG\",\n\t\t\t\t{ slug },\n\t\t\t);\n\t\t}\n\t\tif (RESERVED_SET.has(slug)) {\n\t\t\tthrow new BylineSchemaError(`Byline field slug \"${slug}\" is reserved`, \"RESERVED_SLUG\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate validateLabel(label: string): void {\n\t\tif (!label || typeof label !== \"string\") {\n\t\t\tthrow new BylineSchemaError(\"Byline field label is required\", \"INVALID_LABEL\", {\n\t\t\t\tlabel,\n\t\t\t});\n\t\t}\n\t\tif (label.length > MAX_LABEL_LENGTH) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\t`Byline field label must be ${MAX_LABEL_LENGTH} characters or less`,\n\t\t\t\t\"INVALID_LABEL\",\n\t\t\t\t{ length: label.length },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate validateType(type: BylineFieldType): void {\n\t\tif (!TYPE_SET.has(type)) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\t`Byline field type \"${type}\" is not supported. Valid types: ${[...TYPE_SET].join(\", \")}`,\n\t\t\t\t\"INVALID_TYPE\",\n\t\t\t\t{ type },\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Normalise + validate a validation payload for a given field type.\n\t *\n\t * - `select`: `options` is required, must be a non-empty array of unique\n\t * non-empty strings, capped at `MAX_SELECT_OPTIONS`.\n\t * - any other type: `options` is silently dropped if present (a future\n\t * field type might use it, but v1 doesn't).\n\t *\n\t * Returns `null` when the resulting validation object is empty, so the\n\t * storage column stays NULL rather than carrying `'{}'`.\n\t */\n\tprivate normaliseValidation(\n\t\ttype: BylineFieldType,\n\t\tvalidation: BylineFieldValidation | null,\n\t): BylineFieldValidation | null {\n\t\tif (type === \"select\") {\n\t\t\tconst options = validation?.options;\n\t\t\tif (!Array.isArray(options) || options.length === 0) {\n\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t`Byline field of type \"select\" requires non-empty \"validation.options\"`,\n\t\t\t\t\t\"INVALID_VALIDATION\",\n\t\t\t\t\t{ type },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (options.length > MAX_SELECT_OPTIONS) {\n\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t`Byline field \"select\" cannot have more than ${MAX_SELECT_OPTIONS} options`,\n\t\t\t\t\t\"INVALID_VALIDATION\",\n\t\t\t\t\t{ count: options.length },\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst seen = new Set<string>();\n\t\t\tfor (const option of options) {\n\t\t\t\tif (typeof option !== \"string\" || option.length === 0) {\n\t\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t\t`Byline field \"select\" options must be non-empty strings`,\n\t\t\t\t\t\t\"INVALID_VALIDATION\",\n\t\t\t\t\t\t{ option },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (seen.has(option)) {\n\t\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t\t`Byline field \"select\" options must be unique`,\n\t\t\t\t\t\t\"INVALID_VALIDATION\",\n\t\t\t\t\t\t{ option },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tseen.add(option);\n\t\t\t}\n\t\t\treturn { options };\n\t\t}\n\n\t\tif (validation == null) return null;\n\t\t// Non-select: drop `options` if present. Strip nothing else — future\n\t\t// field types might extend the shape and we don't want to lose\n\t\t// payload silently. Today's `BylineFieldValidation` is `{ options? }`\n\t\t// only, so this branch is a pass-through; left explicit for clarity.\n\t\tconst { options: _drop, ...rest } = validation;\n\t\treturn Object.keys(rest).length === 0 ? null : (rest as BylineFieldValidation);\n\t}\n}\n\nfunction mapFieldRow(row: {\n\tid: string;\n\tslug: string;\n\tlabel: string;\n\ttype: string;\n\trequired: number;\n\ttranslatable: number;\n\tvalidation: string | null;\n\tsort_order: number;\n\tcreated_at: string;\n\tupdated_at: string;\n}): BylineFieldDefinition {\n\treturn {\n\t\tid: row.id,\n\t\tslug: row.slug,\n\t\tlabel: row.label,\n\t\t// `type` is stored as TEXT but `createField` rejects anything outside\n\t\t// `BYLINE_FIELD_TYPES` before inserting. The assertion narrows on\n\t\t// that write-time guarantee.\n\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- validated at write\n\t\ttype: row.type as BylineFieldType,\n\t\trequired: row.required === 1,\n\t\ttranslatable: row.translatable === 1,\n\t\t// `validation` is JSON-encoded `BylineFieldValidation | null`, written\n\t\t// only through `normaliseValidation`. The cast matches the\n\t\t// `JSON.parse(...) as T` pattern in `OptionsRepository`.\n\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- validated at write\n\t\tvalidation: row.validation ? (JSON.parse(row.validation) as BylineFieldValidation) : null,\n\t\tsortOrder: row.sort_order,\n\t\tcreatedAt: row.created_at,\n\t\tupdatedAt: row.updated_at,\n\t};\n}\n\n// Re-export the table type for callers that want to spell it explicitly.\n// Most callers should rely on the Database interface; this is convenience\n// for tests that hand-roll Kysely queries.\nexport type { BylineFieldTable };\n"],"mappings":";;;;;;;AAiBA,MAAM,eAAoC,IAAI,IAAI,4BAA4B;AAC9E,MAAM,WAAgC,IAAI,IAAI,mBAAmB;AAEjE,MAAM,cAAc;;AAGpB,MAAM,qBAAqB;;AAE3B,MAAM,kBAAkB;;AAExB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;AAoBzB,IAAa,oBAAb,cAAuC,MAAM;CAC5C,YACC,SACA,AAAO,MACP,AAAO,SACN;AACD,QAAM,QAAQ;EAHP;EACA;AAGP,OAAK,OAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyBd,SAAgB,qBAAqB,OAInC;AACD,SAAQ,MAAM,MAAd;EACC,KAAK,kBACJ,QAAO;GAAE,MAAM;GAAa,SAAS,MAAM;GAAS,SAAS,MAAM;GAAS;EAC7E,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,eACJ,QAAO;GAAE,MAAM,MAAM;GAAM,SAAS,MAAM;GAAS,SAAS,MAAM;GAAS;EAC5E,QAGC,QAAO;GAAE,MAAM;GAAoB,SAAS,MAAM;GAAS,SAAS,MAAM;GAAS;;;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I,KAAa;AAC9B,QAAK,MAAM,UAAU,SAAS;AAC7B,QAAI,OAAO,WAAW,YAAY,OAAO,WAAW,EACnD,OAAM,IAAI,kBACT,2DACA,sBACA,EAAE,QAAQ,CACV;AAEF,QAAI,KAAK,IAAI,OAAO,CACnB,OAAM,IAAI,kBACT,gDACA,sBACA,EAAE,QAAQ,CACV;AAEF,SAAK,IAAI,OAAO;;AAEjB,UAAO,EAAE,SAAS;;AAGnB,MAAI,cAAc,KAAM,QAAO;EAK/B,MAAM,EAAE,SAAS,OAAO,GAAG,SAAS;AACpC,SAAO,OAAO,KAAK,KAAK,CAAC,WAAW,IAAI,OAAQ;;;AAIlD,SAAS,YAAY,KAWK;AACzB,QAAO;EACN,IAAI,IAAI;EACR,MAAM,IAAI;EACV,OAAO,IAAI;EAKX,MAAM,IAAI;EACV,UAAU,IAAI,aAAa;EAC3B,cAAc,IAAI,iBAAiB;EAKnC,YAAY,IAAI,aAAc,KAAK,MAAM,IAAI,WAAW,GAA6B;EACrF,WAAW,IAAI;EACf,WAAW,IAAI;EACf,WAAW,IAAI;EACf"}
1
+ {"version":3,"file":"byline-registry-CWP7I71B.mjs","names":[],"sources":["../src/schema/byline-registry.ts"],"sourcesContent":["import type { Kysely } from \"kysely\";\nimport { sql } from \"kysely\";\nimport { ulid } from \"ulidx\";\n\nimport { withTransaction } from \"../database/transaction.js\";\nimport type { BylineFieldTable, Database } from \"../database/types.js\";\nimport { validateIdentifier } from \"../database/validate.js\";\nimport {\n\tBYLINE_FIELD_TYPES,\n\tRESERVED_BYLINE_FIELD_SLUGS,\n\ttype BylineFieldDefinition,\n\ttype BylineFieldType,\n\ttype BylineFieldValidation,\n\ttype CreateBylineFieldInput,\n\ttype UpdateBylineFieldInput,\n} from \"./types.js\";\n\nconst RESERVED_SET: ReadonlySet<string> = new Set(RESERVED_BYLINE_FIELD_SLUGS);\nconst TYPE_SET: ReadonlySet<string> = new Set(BYLINE_FIELD_TYPES);\n\nconst VERSION_KEY = \"byline_fields_version\";\n\n/** Hard cap on the choices array for a `select`-type field. */\nconst MAX_SELECT_OPTIONS = 200;\n/** Hard cap on a slug — mirrors `SchemaRegistry.validateSlug`. */\nconst MAX_SLUG_LENGTH = 63;\n/** Hard cap on a label. Bigger than slugs because labels are display strings. */\nconst MAX_LABEL_LENGTH = 200;\n\n/**\n * Error thrown for byline-schema validation failures. Mirrors\n * `SchemaError` in `registry.ts` so the admin API layer can map a small\n * set of codes to HTTP statuses without inspecting messages.\n *\n * Codes:\n * - `INVALID_SLUG` — slug fails identifier rules or length cap\n * - `RESERVED_SLUG` — slug collides with a fixed `_emdash_bylines` column\n * - `INVALID_TYPE` — type is not one of the five v1 field types\n * - `INVALID_LABEL` — label missing or exceeds length cap\n * - `INVALID_VALIDATION` — validation payload malformed (e.g. `select` with\n * no `options`, duplicates in `options`)\n * - `FIELD_EXISTS` — slug already registered\n * - `FIELD_NOT_FOUND` — slug not registered\n * - `TRANSLATABLE_LOCKED` — attempt to flip `translatable` while stored\n * values reference the field\n * - `REORDER_MISMATCH` — reorder input doesn't match the registered set\n */\nexport class BylineSchemaError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic code: string,\n\t\tpublic details?: Record<string, unknown>,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"BylineSchemaError\";\n\t}\n}\n\n/**\n * Translate a `BylineSchemaError` code to a shared `ErrorCode` for the\n * admin API. HTTP status is then derived by `mapErrorStatus` — this\n * function deliberately doesn't carry one, so the API/handler boundary\n * matches the rest of the codebase (handlers return `ApiResult<T>` with\n * a code, the route layer maps to status via `unwrapResult`).\n *\n * Every code on the right-hand side of `case ... return ...` is defined\n * in `ErrorCode` (`api/errors.ts`). `INVALID_LABEL` and\n * `INVALID_VALIDATION` are intentionally folded into the `default`\n * branch (→ `VALIDATION_ERROR`) so no ad-hoc codes leak out — the\n * registry's domain code names them but the HTTP surface should not.\n *\n * `RESERVED_SLUG` / `INVALID_SLUG` typically don't reach this layer for\n * HTTP callers — the zod schema rejects them first with a clean\n * `VALIDATION_ERROR`. They're still listed so non-HTTP callers (and the\n * test layer) get consistent mapping.\n *\n * `FIELD_NOT_FOUND` is normalised to the shared `NOT_FOUND` code so the\n * admin client can branch on one constant across resource types.\n */\nexport function mapBylineSchemaError(error: BylineSchemaError): {\n\tcode: string;\n\tmessage: string;\n\tdetails?: Record<string, unknown>;\n} {\n\tswitch (error.code) {\n\t\tcase \"FIELD_NOT_FOUND\":\n\t\t\treturn { code: \"NOT_FOUND\", message: error.message, details: error.details };\n\t\tcase \"FIELD_EXISTS\":\n\t\tcase \"TRANSLATABLE_LOCKED\":\n\t\tcase \"REORDER_MISMATCH\":\n\t\tcase \"INVALID_SLUG\":\n\t\tcase \"RESERVED_SLUG\":\n\t\tcase \"INVALID_TYPE\":\n\t\t\treturn { code: error.code, message: error.message, details: error.details };\n\t\tdefault:\n\t\t\t// Catches INVALID_LABEL, INVALID_VALIDATION, and any future\n\t\t\t// registry codes we forget to wire up explicitly.\n\t\t\treturn { code: \"VALIDATION_ERROR\", message: error.message, details: error.details };\n\t}\n}\n\n/**\n * Registry for byline custom fields (Discussion #1174).\n *\n * Owns CRUD over `_emdash_byline_fields` and the\n * `options.byline_fields_version` counter that drives cache\n * invalidation in `bylines/field-defs-cache.ts`.\n *\n * **Dirty-bit bookend.** Every mutation runs `markVersionDirty` before\n * the schema write and `markVersionClean` after, as standalone writes\n * (not inside `withTransaction`) so concurrent isolates observe the\n * dirty mark *before* the mutation lands. Parity carries meaning:\n * odd = mutation in flight or crashed mid-flight, even = stable.\n * The cache bypasses the global holder while odd.\n *\n * `markVersionDirty` is parity-aware (idempotent on odd) so a\n * crashed prior attempt doesn't invert the bit.\n * `markVersionClean` always advances to a new even value (+2 from\n * even, +1 from odd) so concurrent mutators can't collapse on the\n * same key and pin a stale cache snapshot. Idempotent-retry exits\n * (`FIELD_EXISTS` / `FIELD_NOT_FOUND` / no-op update) call\n * `markVersionClean` too — same code path doubles as crash recovery\n * and false-clean recovery.\n *\n * The residual race: a reader caching between two concurrent\n * `markVersionClean` calls sees a partial-set snapshot until the\n * second clean lands. Bounded by the inter-clean window (~ms).\n * Schema mutations are admin-only and rare; acceptable for now.\n * A CAS-on-bump or dialect-specific lock is tracked as follow-up.\n *\n * **`deleteField` cascade.** Migration 041 already declares\n * `ON DELETE CASCADE` on both value tables. The explicit deletes\n * here are defense-in-depth against FK-pragma misconfig and mirror\n * `BylineRepository.delete`'s app-level cascade for the bylines\n * domain.\n *\n * Reserved-slug rejection runs at the API layer (zod) *and* here so\n * non-HTTP callers (seeds, scripts) can't bypass the check.\n */\nexport class BylineSchemaRegistry {\n\tconstructor(private db: Kysely<Database>) {}\n\n\tasync listFields(): Promise<BylineFieldDefinition[]> {\n\t\tconst rows = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_fields\")\n\t\t\t.selectAll()\n\t\t\t.orderBy(\"sort_order\", \"asc\")\n\t\t\t.orderBy(\"created_at\", \"asc\")\n\t\t\t.execute();\n\t\treturn rows.map((row) => mapFieldRow(row));\n\t}\n\n\tasync getField(slug: string): Promise<BylineFieldDefinition | null> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_fields\")\n\t\t\t.selectAll()\n\t\t\t.where(\"slug\", \"=\", slug)\n\t\t\t.executeTakeFirst();\n\t\treturn row ? mapFieldRow(row) : null;\n\t}\n\n\tasync getFieldById(id: string): Promise<BylineFieldDefinition | null> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_fields\")\n\t\t\t.selectAll()\n\t\t\t.where(\"id\", \"=\", id)\n\t\t\t.executeTakeFirst();\n\t\treturn row ? mapFieldRow(row) : null;\n\t}\n\n\tasync createField(input: CreateBylineFieldInput): Promise<BylineFieldDefinition> {\n\t\tthis.validateSlug(input.slug);\n\t\tthis.validateLabel(input.label);\n\t\tthis.validateType(input.type);\n\t\tconst validation = this.normaliseValidation(input.type, input.validation ?? null);\n\n\t\tconst existing = await this.getField(input.slug);\n\t\tif (existing) {\n\t\t\t// Idempotent retry exit — see class JSDoc.\n\t\t\tawait this.markVersionClean();\n\t\t\tthrow new BylineSchemaError(`Byline field \"${input.slug}\" already exists`, \"FIELD_EXISTS\", {\n\t\t\t\tslug: input.slug,\n\t\t\t});\n\t\t}\n\n\t\tconst id = ulid();\n\t\tconst sortOrder = input.sortOrder ?? (await this.nextSortOrder());\n\n\t\tawait this.markVersionDirty();\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tawait trx\n\t\t\t\t.insertInto(\"_emdash_byline_fields\")\n\t\t\t\t.values({\n\t\t\t\t\tid,\n\t\t\t\t\tslug: input.slug,\n\t\t\t\t\tlabel: input.label,\n\t\t\t\t\ttype: input.type,\n\t\t\t\t\trequired: input.required ? 1 : 0,\n\t\t\t\t\ttranslatable: input.translatable === false ? 0 : 1,\n\t\t\t\t\tvalidation: validation ? JSON.stringify(validation) : null,\n\t\t\t\t\tsort_order: sortOrder,\n\t\t\t\t})\n\t\t\t\t.execute();\n\t\t});\n\t\tawait this.markVersionClean();\n\n\t\tconst created = await this.getFieldById(id);\n\t\tif (!created) {\n\t\t\t// Should be unreachable on a working DB — but a typed error\n\t\t\t// beats letting the route returning null on a successful path.\n\t\t\tthrow new BylineSchemaError(\"Failed to load created field\", \"FIELD_NOT_FOUND\", {\n\t\t\t\tid,\n\t\t\t});\n\t\t}\n\t\treturn created;\n\t}\n\n\tasync updateField(slug: string, input: UpdateBylineFieldInput): Promise<BylineFieldDefinition> {\n\t\tconst field = await this.getField(slug);\n\t\tif (!field) {\n\t\t\t// Idempotent retry exit — see class JSDoc.\n\t\t\tawait this.markVersionClean();\n\t\t\tthrow new BylineSchemaError(`Byline field \"${slug}\" not found`, \"FIELD_NOT_FOUND\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\n\t\tconst updates: Partial<{\n\t\t\tlabel: string;\n\t\t\trequired: number;\n\t\t\ttranslatable: number;\n\t\t\tvalidation: string | null;\n\t\t\tsort_order: number;\n\t\t\tupdated_at: string;\n\t\t}> = {};\n\n\t\tif (input.label !== undefined) {\n\t\t\tthis.validateLabel(input.label);\n\t\t\tupdates.label = input.label;\n\t\t}\n\n\t\tif (input.required !== undefined) {\n\t\t\tupdates.required = input.required ? 1 : 0;\n\t\t}\n\n\t\tif (input.validation !== undefined) {\n\t\t\t// Validation payload is normalised against the *current* field\n\t\t\t// type — `type` is not updatable, so it's safe to use `field.type`.\n\t\t\tconst validation = this.normaliseValidation(field.type, input.validation);\n\t\t\tupdates.validation = validation ? JSON.stringify(validation) : null;\n\t\t}\n\n\t\tif (input.translatable !== undefined && input.translatable !== field.translatable) {\n\t\t\t// Flipping `translatable` would orphan any values already stored\n\t\t\t// in the table matching the *current* flag. Reject when any\n\t\t\t// value rows reference this field — admins can delete the field\n\t\t\t// (cascading the values) and re-create it with the new flag if\n\t\t\t// they want a clean re-start. Migrating values across tables is\n\t\t\t// out of scope (Discussion #1174 doesn't authorise it).\n\t\t\tconst usage = await this.countFieldValues(field.id);\n\t\t\tif (usage > 0) {\n\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t`Cannot change \"translatable\" on field \"${slug}\" while ${usage} value row(s) exist. ` +\n\t\t\t\t\t\t`Delete the values (or the field) and re-create with the new setting.`,\n\t\t\t\t\t\"TRANSLATABLE_LOCKED\",\n\t\t\t\t\t{ slug, valueCount: usage },\n\t\t\t\t);\n\t\t\t}\n\t\t\tupdates.translatable = input.translatable ? 1 : 0;\n\t\t}\n\n\t\tif (input.sortOrder !== undefined) {\n\t\t\tupdates.sort_order = input.sortOrder;\n\t\t}\n\n\t\tif (Object.keys(updates).length === 0) {\n\t\t\t// No-op update — still advance the clean marker in case\n\t\t\t// we're recovering a crashed prior attempt.\n\t\t\tawait this.markVersionClean();\n\t\t\treturn field;\n\t\t}\n\n\t\tupdates.updated_at = new Date().toISOString();\n\n\t\tawait this.markVersionDirty();\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tawait trx\n\t\t\t\t.updateTable(\"_emdash_byline_fields\")\n\t\t\t\t.set(updates)\n\t\t\t\t.where(\"id\", \"=\", field.id)\n\t\t\t\t.execute();\n\t\t});\n\t\tawait this.markVersionClean();\n\n\t\tconst updated = await this.getFieldById(field.id);\n\t\tif (!updated) {\n\t\t\tthrow new BylineSchemaError(\"Failed to load updated field\", \"FIELD_NOT_FOUND\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\t\treturn updated;\n\t}\n\n\tasync deleteField(slug: string): Promise<void> {\n\t\tconst field = await this.getField(slug);\n\t\tif (!field) {\n\t\t\t// Idempotent retry exit — see class JSDoc.\n\t\t\tawait this.markVersionClean();\n\t\t\tthrow new BylineSchemaError(`Byline field \"${slug}\" not found`, \"FIELD_NOT_FOUND\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\n\t\t// Delete order matters on D1 (no tx): value rows first, definition\n\t\t// row last, so a crash leaves the definition recoverable on retry\n\t\t// rather than orphan values pointing at a vanished id.\n\t\tawait this.markVersionDirty();\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tawait trx\n\t\t\t\t.deleteFrom(\"_emdash_byline_field_values\")\n\t\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t\t.execute();\n\t\t\tawait trx\n\t\t\t\t.deleteFrom(\"_emdash_byline_field_group_values\")\n\t\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t\t.execute();\n\t\t\tawait trx.deleteFrom(\"_emdash_byline_fields\").where(\"id\", \"=\", field.id).execute();\n\t\t});\n\t\tawait this.markVersionClean();\n\t}\n\n\t/**\n\t * Reorder fields by slug. The input must be the *exact* set of\n\t * currently registered slugs — no adds, no drops, no duplicates. This\n\t * keeps the operation invertible (any reorder is followed by a reverse\n\t * reorder) and removes a class of \"did I forget a field?\" bugs at the\n\t * API layer.\n\t */\n\tasync reorderFields(slugs: string[]): Promise<void> {\n\t\tif (new Set(slugs).size !== slugs.length) {\n\t\t\tthrow new BylineSchemaError(\"Reorder input contains duplicate slugs\", \"REORDER_MISMATCH\", {\n\t\t\t\tslugs,\n\t\t\t});\n\t\t}\n\n\t\tconst registered = await this.listFields();\n\t\tconst registeredSlugs = registered.map((f) => f.slug).toSorted();\n\t\tconst inputSlugs = slugs.toSorted();\n\n\t\tif (registeredSlugs.length !== inputSlugs.length) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\t`Reorder input has ${inputSlugs.length} slug(s); ${registeredSlugs.length} registered`,\n\t\t\t\t\"REORDER_MISMATCH\",\n\t\t\t\t{ registered: registeredSlugs, input: inputSlugs },\n\t\t\t);\n\t\t}\n\t\tfor (let i = 0; i < registeredSlugs.length; i++) {\n\t\t\tif (registeredSlugs[i] !== inputSlugs[i]) {\n\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t\"Reorder input does not match the registered field set\",\n\t\t\t\t\t\"REORDER_MISMATCH\",\n\t\t\t\t\t{ registered: registeredSlugs, input: inputSlugs },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst now = new Date().toISOString();\n\t\tawait this.markVersionDirty();\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tfor (let i = 0; i < slugs.length; i++) {\n\t\t\t\tconst slug = slugs[i];\n\t\t\t\tif (slug === undefined) continue;\n\t\t\t\tawait trx\n\t\t\t\t\t.updateTable(\"_emdash_byline_fields\")\n\t\t\t\t\t.set({ sort_order: i, updated_at: now })\n\t\t\t\t\t.where(\"slug\", \"=\", slug)\n\t\t\t\t\t.execute();\n\t\t\t}\n\t\t});\n\t\tawait this.markVersionClean();\n\t}\n\n\t/**\n\t * Per-table usage counts for a field, plus the sum. Backs the\n\t * destructive-delete confirm dialog in the admin UI (Phase 5).\n\t *\n\t * Both counts are surfaced separately for diagnostic value: a\n\t * non-zero count on the table that doesn't match the field's current\n\t * `translatable` flag indicates historical drift (e.g. a flip from\n\t * an older code path). Today the registry rejects such flips with\n\t * `TRANSLATABLE_LOCKED`, so any drift originates pre-Phase-2.\n\t *\n\t * Throws `FIELD_NOT_FOUND` when the slug doesn't resolve — callers\n\t * shouldn't get back zero counts for a missing field.\n\t */\n\tasync getFieldUsage(slug: string): Promise<{\n\t\ttranslatableValueCount: number;\n\t\tgroupValueCount: number;\n\t\ttotalAffectedRows: number;\n\t}> {\n\t\tconst field = await this.getField(slug);\n\t\tif (!field) {\n\t\t\tthrow new BylineSchemaError(`Byline field \"${slug}\" not found`, \"FIELD_NOT_FOUND\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\t\tconst tr = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_field_values\")\n\t\t\t.select(({ fn }) => [fn.count<number>(\"field_id\").as(\"count\")])\n\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t.executeTakeFirst();\n\t\tconst grp = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_field_group_values\")\n\t\t\t.select(({ fn }) => [fn.count<number>(\"field_id\").as(\"count\")])\n\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t.executeTakeFirst();\n\t\tconst translatableValueCount = Number(tr?.count ?? 0);\n\t\tconst groupValueCount = Number(grp?.count ?? 0);\n\t\treturn {\n\t\t\ttranslatableValueCount,\n\t\t\tgroupValueCount,\n\t\t\ttotalAffectedRows: translatableValueCount + groupValueCount,\n\t\t};\n\t}\n\n\t/**\n\t * Read the persisted version counter. Used by the field-defs cache\n\t * (Phase 3) to detect invalidation. Returns `0` when the row is\n\t * missing — covers the \"tests that didn't run migration 041\" case\n\t * without throwing.\n\t */\n\tasync getVersion(): Promise<number> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"options\")\n\t\t\t.select(\"value\")\n\t\t\t.where(\"name\", \"=\", VERSION_KEY)\n\t\t\t.executeTakeFirst();\n\t\tif (!row) return 0;\n\t\tconst parsed = Number.parseInt(row.value, 10);\n\t\treturn Number.isFinite(parsed) ? parsed : 0;\n\t}\n\n\t// ============================================\n\t// Private helpers\n\t// ============================================\n\n\t/**\n\t * Force the version counter to an odd integer (\"dirty\"). Idempotent\n\t * on odd so a crashed prior attempt can't invert parity. Upsert (not\n\t * UPDATE) so a missing row still flips parity — `getVersion` returns\n\t * 0 on missing, which is even, so a bare UPDATE would leave the\n\t * cache pinned on a stale snapshot. See the class JSDoc.\n\t *\n\t * `options.value` qualified: PG's `ON CONFLICT DO UPDATE` puts both\n\t * the target and `EXCLUDED.value` in scope; bare `value` is ambiguous.\n\t */\n\tprivate async markVersionDirty(): Promise<void> {\n\t\tawait sql`\n\t\t\tINSERT INTO options (name, value)\n\t\t\tVALUES (${VERSION_KEY}, '1')\n\t\t\tON CONFLICT(name) DO UPDATE SET value = CASE\n\t\t\t\tWHEN CAST(options.value AS INTEGER) % 2 = 0\n\t\t\t\t\tTHEN CAST(CAST(options.value AS INTEGER) + 1 AS TEXT)\n\t\t\t\tELSE options.value\n\t\t\tEND\n\t\t`.execute(this.db);\n\t}\n\n\t/**\n\t * Force the version counter to a **new** even integer (+2 from even,\n\t * +1 from odd). Always-advance — never a no-op — so two concurrent\n\t * mutators can't collapse on the same even key and pin a stale cache\n\t * snapshot. See the class JSDoc for the concurrent-collapse rationale.\n\t *\n\t * `options.value` qualified — see `markVersionDirty`.\n\t */\n\tprivate async markVersionClean(): Promise<void> {\n\t\tawait sql`\n\t\t\tINSERT INTO options (name, value)\n\t\t\tVALUES (${VERSION_KEY}, '2')\n\t\t\tON CONFLICT(name) DO UPDATE SET value = CASE\n\t\t\t\tWHEN CAST(options.value AS INTEGER) % 2 = 0\n\t\t\t\t\tTHEN CAST(CAST(options.value AS INTEGER) + 2 AS TEXT)\n\t\t\t\tELSE CAST(CAST(options.value AS INTEGER) + 1 AS TEXT)\n\t\t\tEND\n\t\t`.execute(this.db);\n\t}\n\n\tprivate async nextSortOrder(): Promise<number> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_fields\")\n\t\t\t.select(({ fn }) => [fn.max<number | null>(\"sort_order\").as(\"max\")])\n\t\t\t.executeTakeFirst();\n\t\tconst max = row?.max ?? null;\n\t\treturn max === null ? 0 : max + 1;\n\t}\n\n\tprivate async countFieldValues(fieldId: string): Promise<number> {\n\t\t// Count both per-locale and group-shared values. A field can only\n\t\t// store in one table at a time (translatable picks), but historic\n\t\t// rows might exist in the other if a prior version of this code\n\t\t// allowed the flip — count both to be safe.\n\t\tconst tr = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_field_values\")\n\t\t\t.select(({ fn }) => [fn.count<number>(\"field_id\").as(\"count\")])\n\t\t\t.where(\"field_id\", \"=\", fieldId)\n\t\t\t.executeTakeFirst();\n\t\tconst grp = await this.db\n\t\t\t.selectFrom(\"_emdash_byline_field_group_values\")\n\t\t\t.select(({ fn }) => [fn.count<number>(\"field_id\").as(\"count\")])\n\t\t\t.where(\"field_id\", \"=\", fieldId)\n\t\t\t.executeTakeFirst();\n\t\treturn Number(tr?.count ?? 0) + Number(grp?.count ?? 0);\n\t}\n\n\tprivate validateSlug(slug: string): void {\n\t\tif (!slug || typeof slug !== \"string\") {\n\t\t\tthrow new BylineSchemaError(\"Byline field slug is required\", \"INVALID_SLUG\", { slug });\n\t\t}\n\t\tif (slug.length > MAX_SLUG_LENGTH) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\t`Byline field slug must be ${MAX_SLUG_LENGTH} characters or less`,\n\t\t\t\t\"INVALID_SLUG\",\n\t\t\t\t{ slug },\n\t\t\t);\n\t\t}\n\t\t// `validateIdentifier` enforces /^[a-z][a-z0-9_]*$/ — rejects\n\t\t// camelCase, PascalCase, hyphens, leading digits, and identifiers\n\t\t// over 128 characters. We hit the 63-char cap above first, which\n\t\t// matches the content-collection slug cap.\n\t\ttry {\n\t\t\tvalidateIdentifier(slug, \"byline field slug\");\n\t\t} catch (error) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\terror instanceof Error ? error.message : \"Invalid byline field slug\",\n\t\t\t\t\"INVALID_SLUG\",\n\t\t\t\t{ slug },\n\t\t\t);\n\t\t}\n\t\tif (RESERVED_SET.has(slug)) {\n\t\t\tthrow new BylineSchemaError(`Byline field slug \"${slug}\" is reserved`, \"RESERVED_SLUG\", {\n\t\t\t\tslug,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate validateLabel(label: string): void {\n\t\tif (!label || typeof label !== \"string\") {\n\t\t\tthrow new BylineSchemaError(\"Byline field label is required\", \"INVALID_LABEL\", {\n\t\t\t\tlabel,\n\t\t\t});\n\t\t}\n\t\tif (label.length > MAX_LABEL_LENGTH) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\t`Byline field label must be ${MAX_LABEL_LENGTH} characters or less`,\n\t\t\t\t\"INVALID_LABEL\",\n\t\t\t\t{ length: label.length },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate validateType(type: BylineFieldType): void {\n\t\tif (!TYPE_SET.has(type)) {\n\t\t\tthrow new BylineSchemaError(\n\t\t\t\t`Byline field type \"${type}\" is not supported. Valid types: ${[...TYPE_SET].join(\", \")}`,\n\t\t\t\t\"INVALID_TYPE\",\n\t\t\t\t{ type },\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Normalise + validate a validation payload for a given field type.\n\t *\n\t * - `select`: `options` is required, must be a non-empty array of unique\n\t * non-empty strings, capped at `MAX_SELECT_OPTIONS`.\n\t * - any other type: `options` is silently dropped if present (a future\n\t * field type might use it, but v1 doesn't).\n\t *\n\t * Returns `null` when the resulting validation object is empty, so the\n\t * storage column stays NULL rather than carrying `'{}'`.\n\t */\n\tprivate normaliseValidation(\n\t\ttype: BylineFieldType,\n\t\tvalidation: BylineFieldValidation | null,\n\t): BylineFieldValidation | null {\n\t\tif (type === \"select\") {\n\t\t\tconst options = validation?.options;\n\t\t\tif (!Array.isArray(options) || options.length === 0) {\n\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t`Byline field of type \"select\" requires non-empty \"validation.options\"`,\n\t\t\t\t\t\"INVALID_VALIDATION\",\n\t\t\t\t\t{ type },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (options.length > MAX_SELECT_OPTIONS) {\n\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t`Byline field \"select\" cannot have more than ${MAX_SELECT_OPTIONS} options`,\n\t\t\t\t\t\"INVALID_VALIDATION\",\n\t\t\t\t\t{ count: options.length },\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst seen = new Set<string>();\n\t\t\tfor (const option of options) {\n\t\t\t\tif (typeof option !== \"string\" || option.length === 0) {\n\t\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t\t`Byline field \"select\" options must be non-empty strings`,\n\t\t\t\t\t\t\"INVALID_VALIDATION\",\n\t\t\t\t\t\t{ option },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (seen.has(option)) {\n\t\t\t\t\tthrow new BylineSchemaError(\n\t\t\t\t\t\t`Byline field \"select\" options must be unique`,\n\t\t\t\t\t\t\"INVALID_VALIDATION\",\n\t\t\t\t\t\t{ option },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tseen.add(option);\n\t\t\t}\n\t\t\treturn { options };\n\t\t}\n\n\t\tif (validation == null) return null;\n\t\t// Non-select: drop `options` if present. Strip nothing else — future\n\t\t// field types might extend the shape and we don't want to lose\n\t\t// payload silently. Today's `BylineFieldValidation` is `{ options? }`\n\t\t// only, so this branch is a pass-through; left explicit for clarity.\n\t\tconst { options: _drop, ...rest } = validation;\n\t\treturn Object.keys(rest).length === 0 ? null : (rest as BylineFieldValidation);\n\t}\n}\n\nfunction mapFieldRow(row: {\n\tid: string;\n\tslug: string;\n\tlabel: string;\n\ttype: string;\n\trequired: number;\n\ttranslatable: number;\n\tvalidation: string | null;\n\tsort_order: number;\n\tcreated_at: string;\n\tupdated_at: string;\n}): BylineFieldDefinition {\n\treturn {\n\t\tid: row.id,\n\t\tslug: row.slug,\n\t\tlabel: row.label,\n\t\t// `type` is stored as TEXT but `createField` rejects anything outside\n\t\t// `BYLINE_FIELD_TYPES` before inserting. The assertion narrows on\n\t\t// that write-time guarantee.\n\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- validated at write\n\t\ttype: row.type as BylineFieldType,\n\t\trequired: row.required === 1,\n\t\ttranslatable: row.translatable === 1,\n\t\t// `validation` is JSON-encoded `BylineFieldValidation | null`, written\n\t\t// only through `normaliseValidation`. The cast matches the\n\t\t// `JSON.parse(...) as T` pattern in `OptionsRepository`.\n\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- validated at write\n\t\tvalidation: row.validation ? (JSON.parse(row.validation) as BylineFieldValidation) : null,\n\t\tsortOrder: row.sort_order,\n\t\tcreatedAt: row.created_at,\n\t\tupdatedAt: row.updated_at,\n\t};\n}\n\n// Re-export the table type for callers that want to spell it explicitly.\n// Most callers should rely on the Database interface; this is convenience\n// for tests that hand-roll Kysely queries.\nexport type { BylineFieldTable };\n"],"mappings":";;;;;;;AAiBA,MAAM,eAAoC,IAAI,IAAI,4BAA4B;AAC9E,MAAM,WAAgC,IAAI,IAAI,mBAAmB;AAEjE,MAAM,cAAc;;AAGpB,MAAM,qBAAqB;;AAE3B,MAAM,kBAAkB;;AAExB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;AAoBzB,IAAa,oBAAb,cAAuC,MAAM;CAC5C,YACC,SACA,AAAO,MACP,AAAO,SACN;AACD,QAAM,QAAQ;EAHP;EACA;AAGP,OAAK,OAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyBd,SAAgB,qBAAqB,OAInC;AACD,SAAQ,MAAM,MAAd;EACC,KAAK,kBACJ,QAAO;GAAE,MAAM;GAAa,SAAS,MAAM;GAAS,SAAS,MAAM;GAAS;EAC7E,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,eACJ,QAAO;GAAE,MAAM,MAAM;GAAM,SAAS,MAAM;GAAS,SAAS,MAAM;GAAS;EAC5E,QAGC,QAAO;GAAE,MAAM;GAAoB,SAAS,MAAM;GAAS,SAAS,MAAM;GAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AS;AAC7B,QAAI,OAAO,WAAW,YAAY,OAAO,WAAW,EACnD,OAAM,IAAI,kBACT,2DACA,sBACA,EAAE,QAAQ,CACV;AAEF,QAAI,KAAK,IAAI,OAAO,CACnB,OAAM,IAAI,kBACT,gDACA,sBACA,EAAE,QAAQ,CACV;AAEF,SAAK,IAAI,OAAO;;AAEjB,UAAO,EAAE,SAAS;;AAGnB,MAAI,cAAc,KAAM,QAAO;EAK/B,MAAM,EAAE,SAAS,OAAO,GAAG,SAAS;AACpC,SAAO,OAAO,KAAK,KAAK,CAAC,WAAW,IAAI,OAAQ;;;AAIlD,SAAS,YAAY,KAWK;AACzB,QAAO;EACN,IAAI,IAAI;EACR,MAAM,IAAI;EACV,OAAO,IAAI;EAKX,MAAM,IAAI;EACV,UAAU,IAAI,aAAa;EAC3B,cAAc,IAAI,iBAAiB;EAKnC,YAAY,IAAI,aAAc,KAAK,MAAM,IAAI,WAAW,GAA6B;EACrF,WAAW,IAAI;EACf,WAAW,IAAI;EACf,WAAW,IAAI;EACf"}
@@ -1,6 +1,6 @@
1
1
  import { n as getI18nConfig } from "./config-CVssduLe.mjs";
2
- import { t as EmDashValidationError } from "./types-CfyYQ7eY.mjs";
3
- import { t as BylineRepository } from "./byline-CAhk4FrG.mjs";
2
+ import { t as EmDashValidationError } from "./types-BXSUSAjt.mjs";
3
+ import { t as BylineRepository } from "./byline-DUx48sJp.mjs";
4
4
 
5
5
  //#region src/api/handlers/bylines.ts
6
6
  const norm = (v) => v ?? null;
@@ -201,4 +201,4 @@ async function handleBylineUpdate(db, id, input) {
201
201
 
202
202
  //#endregion
203
203
  export { handleBylineTranslations as n, handleBylineUpdate as r, handleBylineCreate as t };
204
- //# sourceMappingURL=bylines-CbrD7STW.mjs.map
204
+ //# sourceMappingURL=bylines-Cx5n-WqP.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bylines-CbrD7STW.mjs","names":[],"sources":["../src/api/handlers/bylines.ts"],"sourcesContent":["import type { Kysely } from \"kysely\";\n\nimport {\n\tBylineRepository,\n\ttype CreateBylineInput,\n\ttype UpdateBylineInput,\n} from \"../../database/repositories/byline.js\";\nimport { EmDashValidationError, type BylineSummary } from \"../../database/repositories/types.js\";\nimport type { Database } from \"../../database/types.js\";\nimport { getI18nConfig } from \"../../i18n/config.js\";\nimport type { ApiResult } from \"../types.js\";\n\n// `undefined → null` so a missing field in the create payload matches the\n// repo's stored `null` (BylineRepository normalises with `?? null` on write).\nconst norm = (v: string | null | undefined): string | null => v ?? null;\n\n/**\n * Whether the existing byline row's fixed columns match a fresh-create\n * payload after null/undefined normalisation. Used by the D1 create-retry\n * recovery branch.\n */\nfunction bylineFixedFieldsMatch(\n\texisting: BylineSummary,\n\tinput: CreateBylineInput,\n\teffectiveLocale: string,\n): boolean {\n\treturn (\n\t\texisting.displayName === input.displayName &&\n\t\tnorm(existing.bio) === norm(input.bio) &&\n\t\tnorm(existing.avatarMediaId) === norm(input.avatarMediaId) &&\n\t\tnorm(existing.websiteUrl) === norm(input.websiteUrl) &&\n\t\tnorm(existing.userId) === norm(input.userId) &&\n\t\texisting.isGuest === (input.isGuest ?? false) &&\n\t\texisting.locale === effectiveLocale\n\t);\n}\n\n/**\n * Whether every key in `existing` appears in `input` with the same value.\n * Allows `input` to contain additional keys (the partial-write recovery\n * case); rejects on a divergent value or a key the input omits.\n */\nfunction existingCustomFieldsAreSubsetOf(\n\texisting: Record<string, unknown>,\n\tinput: Record<string, unknown> | undefined,\n): boolean {\n\tif (!input) return Object.keys(existing).length === 0;\n\tfor (const [slug, value] of Object.entries(existing)) {\n\t\tif (!Object.hasOwn(input, slug)) return false;\n\t\tif (input[slug] !== value) return false;\n\t}\n\treturn true;\n}\n\n/**\n * Reject locales the site doesn't configure. Returns `null` when the locale\n * is fine (omitted, or matches `locales` in the i18n config, or i18n isn't\n * configured at all).\n */\nfunction rejectUnknownLocale(locale: string | undefined): ApiResult<never> | null {\n\tif (!locale) return null;\n\tconst config = getI18nConfig();\n\tif (!config) return null;\n\tif (config.locales.includes(locale)) return null;\n\treturn {\n\t\tsuccess: false,\n\t\terror: {\n\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\tmessage: `Locale \"${locale}\" is not configured for this site`,\n\t\t},\n\t};\n}\n\n/**\n * Business-logic helpers for the bylines admin API.\n *\n * Mirrors the shape of `packages/core/src/api/handlers/menus.ts`. Route files\n * stay thin: they parse input, call these handlers, and forward the result via\n * `unwrapResult`. The repository (`BylineRepository`) is strict per locale; the\n * handlers add validation and translation-flow guards on top.\n */\n\nexport interface BylineTranslationsResponse {\n\titems: BylineSummary[];\n}\n\n/**\n * List every translation of a byline (by row id). Returns NOT_FOUND when no\n * row with the given id exists.\n */\nexport async function handleBylineTranslations(\n\tdb: Kysely<Database>,\n\tid: string,\n): Promise<ApiResult<BylineTranslationsResponse>> {\n\ttry {\n\t\tconst repo = new BylineRepository(db);\n\t\tconst anchor = await repo.findById(id);\n\t\tif (!anchor) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"NOT_FOUND\", message: \"Byline not found\" },\n\t\t\t};\n\t\t}\n\t\tconst items = await repo.listTranslations(id);\n\t\treturn { success: true, data: { items } };\n\t} catch {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: \"BYLINE_TRANSLATIONS_ERROR\",\n\t\t\t\tmessage: \"Failed to list byline translations\",\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n * Create a new byline. When `translationOf` is supplied, the new row joins the\n * source byline's translation_group (a sibling in the same logical identity).\n *\n * Translating from a source row only makes sense when the caller names the\n * target locale, otherwise we'd silently clone into the configured default,\n * which is almost never what's intended (and will collide if the source is\n * already the default-locale row). Mirrors `handleMenuCreate`.\n */\nexport async function handleBylineCreate(\n\tdb: Kysely<Database>,\n\tinput: CreateBylineInput,\n): Promise<ApiResult<BylineSummary>> {\n\ttry {\n\t\tif (input.translationOf && !input.locale) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\t\t\tmessage: \"`locale` is required when `translationOf` is provided\",\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst localeErr = rejectUnknownLocale(input.locale);\n\t\tif (localeErr) return localeErr;\n\n\t\tconst repo = new BylineRepository(db);\n\n\t\t// Existence check up front so the repo's \"Source not found\" throw\n\t\t// becomes a clean NOT_FOUND on the API.\n\t\tlet sourceGroup: string | undefined;\n\t\tif (input.translationOf) {\n\t\t\tconst source = await repo.findById(input.translationOf);\n\t\t\tif (!source) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tcode: \"NOT_FOUND\",\n\t\t\t\t\t\tmessage: \"Source byline for translation not found\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\tsourceGroup = source.translationGroup ?? source.id;\n\t\t}\n\n\t\tconst effectiveLocale = input.locale ?? getI18nConfig()?.defaultLocale ?? \"en\";\n\n\t\t// Translation-group guard: the row-per-locale model (PR #916)\n\t\t// allows exactly one row per (translation_group, locale). Reject\n\t\t// here so callers get a clean 409 instead of a UNIQUE constraint\n\t\t// failure from the partial index. The DB constraint is the safety\n\t\t// net; this is the friendly error.\n\t\tif (sourceGroup) {\n\t\t\tconst siblings = await repo.findByTranslationGroup(sourceGroup);\n\t\t\tif (siblings.some((b) => b.locale === effectiveLocale)) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tcode: \"CONFLICT\",\n\t\t\t\t\t\tmessage: `Translation already exists in locale \"${effectiveLocale}\" for this byline`,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Duplicate guard: same (slug, locale) — matches the DB unique key\n\t\t// from migration 040.\n\t\tconst existing = await repo.findBySlug(input.slug, { locale: effectiveLocale });\n\t\tif (existing) {\n\t\t\t// D1 has no transactions, so a crash between the byline insert\n\t\t\t// and the per-field writes leaves a partial row that's\n\t\t\t// otherwise unrecoverable. Treat a same-identity retry that\n\t\t\t// provides customFields as completing the abandoned create.\n\t\t\t// Recovery requires fixed-column + translation-group +\n\t\t\t// subset-customFields match; anything else collapses to a\n\t\t\t// standard duplicate-slug conflict.\n\t\t\tconst expectedTranslationGroup = sourceGroup ?? existing.id;\n\t\t\tconst inputHasFields = !!input.customFields && Object.keys(input.customFields).length > 0;\n\t\t\tif (\n\t\t\t\tinputHasFields &&\n\t\t\t\tbylineFixedFieldsMatch(existing, input, effectiveLocale) &&\n\t\t\t\texisting.translationGroup === expectedTranslationGroup &&\n\t\t\t\texistingCustomFieldsAreSubsetOf(existing.customFields ?? {}, input.customFields)\n\t\t\t) {\n\t\t\t\tconst recovered = await repo.update(existing.id, {\n\t\t\t\t\tcustomFields: input.customFields,\n\t\t\t\t});\n\t\t\t\tif (recovered) return { success: true, data: recovered };\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: \"CONFLICT\",\n\t\t\t\t\tmessage: `Byline \"${input.slug}\" already exists${\n\t\t\t\t\t\tinput.locale ? ` in locale \"${input.locale}\"` : \"\"\n\t\t\t\t\t}`,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst byline = await repo.create(input);\n\t\treturn { success: true, data: byline };\n\t} catch (error) {\n\t\t// Mirror handleBylineUpdate: surface customFields validation\n\t\t// errors as 400 rather than swallowing them as a generic 500.\n\t\tif (error instanceof EmDashValidationError) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"VALIDATION_ERROR\", message: error.message },\n\t\t\t};\n\t\t}\n\t\tconsole.error(\"[BYLINE_CREATE_ERROR]\", error);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: { code: \"BYLINE_CREATE_ERROR\", message: \"Failed to create byline\" },\n\t\t};\n\t}\n}\n\n/**\n * Update an existing byline. Forwards every field on `UpdateBylineInput`\n * to `BylineRepository.update`, including the Phase 3 `customFields`\n * map; per-field type validation lives in the repo, which throws\n * `EmDashValidationError` on unknown slugs, type mismatches, or\n * `select`-choice misses. This handler translates that into a clean\n * `VALIDATION_ERROR` (400 via `mapErrorStatus`).\n *\n * Returns `NOT_FOUND` when the byline id doesn't resolve. Generic\n * failures surface as `BYLINE_UPDATE_ERROR` (500) without leaking the\n * underlying message.\n */\nexport async function handleBylineUpdate(\n\tdb: Kysely<Database>,\n\tid: string,\n\tinput: UpdateBylineInput,\n): Promise<ApiResult<BylineSummary>> {\n\ttry {\n\t\tconst repo = new BylineRepository(db);\n\t\tconst byline = await repo.update(id, input);\n\t\tif (!byline) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"NOT_FOUND\", message: \"Byline not found\" },\n\t\t\t};\n\t\t}\n\t\treturn { success: true, data: byline };\n\t} catch (error) {\n\t\t// Unknown-key + type-mismatch + select-choice writes throw\n\t\t// EmDashValidationError (Phase 3, see BylineRepository.update).\n\t\t// Map to a clean 400 — the error message names the offending\n\t\t// slug/type, which is safe to surface to the admin client.\n\t\tif (error instanceof EmDashValidationError) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"VALIDATION_ERROR\", message: error.message },\n\t\t\t};\n\t\t}\n\t\tconsole.error(\"[BYLINE_UPDATE_ERROR]\", error);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: { code: \"BYLINE_UPDATE_ERROR\", message: \"Failed to update byline\" },\n\t\t};\n\t}\n}\n"],"mappings":";;;;;AAcA,MAAM,QAAQ,MAAgD,KAAK;;;;;;AAOnE,SAAS,uBACR,UACA,OACA,iBACU;AACV,QACC,SAAS,gBAAgB,MAAM,eAC/B,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,IAAI,IACtC,KAAK,SAAS,cAAc,KAAK,KAAK,MAAM,cAAc,IAC1D,KAAK,SAAS,WAAW,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yBAAyB,MAAM;AAC7C,SAAO;GACN,SAAS;GACT,OAAO;IAAE,MAAM;IAAuB,SAAS;IAA2B;GAC1E;;;;;;;;;;;;;;;AAgBH,eAAsB,mBACrB,IACA,IACA,OACoC;AACpC,KAAI;EAEH,MAAM,SAAS,MADF,IAAI,iBAAiB,GAAG,CACX,OAAO,IAAI,MAAM;AAC3C,MAAI,CAAC,OACJ,QAAO;GACN,SAAS;GACT,OAAO;IAAE,MAAM;IAAa,SAAS;IAAoB;GACzD;AAEF,SAAO;GAAE,SAAS;GAAM,MAAM;GAAQ;UAC9B,OAAO;AAKf,MAAI,iBAAiB,sBACpB,QAAO;GACN,SAAS;GACT,OAAO;IAAE,MAAM;IAAoB,SAAS,MAAM;IAAS;GAC3D;AAEF,UAAQ,MAAM,yBAAyB,MAAM;AAC7C,SAAO;GACN,SAAS;GACT,OAAO;IAAE,MAAM;IAAuB,SAAS;IAA2B;GAC1E"}
1
+ {"version":3,"file":"bylines-Cx5n-WqP.mjs","names":[],"sources":["../src/api/handlers/bylines.ts"],"sourcesContent":["import type { Kysely } from \"kysely\";\n\nimport {\n\tBylineRepository,\n\ttype CreateBylineInput,\n\ttype UpdateBylineInput,\n} from \"../../database/repositories/byline.js\";\nimport { EmDashValidationError, type BylineSummary } from \"../../database/repositories/types.js\";\nimport type { Database } from \"../../database/types.js\";\nimport { getI18nConfig } from \"../../i18n/config.js\";\nimport type { ApiResult } from \"../types.js\";\n\n// `undefined → null` so a missing field in the create payload matches the\n// repo's stored `null` (BylineRepository normalises with `?? null` on write).\nconst norm = (v: string | null | undefined): string | null => v ?? null;\n\n/**\n * Whether the existing byline row's fixed columns match a fresh-create\n * payload after null/undefined normalisation. Used by the D1 create-retry\n * recovery branch.\n */\nfunction bylineFixedFieldsMatch(\n\texisting: BylineSummary,\n\tinput: CreateBylineInput,\n\teffectiveLocale: string,\n): boolean {\n\treturn (\n\t\texisting.displayName === input.displayName &&\n\t\tnorm(existing.bio) === norm(input.bio) &&\n\t\tnorm(existing.avatarMediaId) === norm(input.avatarMediaId) &&\n\t\tnorm(existing.websiteUrl) === norm(input.websiteUrl) &&\n\t\tnorm(existing.userId) === norm(input.userId) &&\n\t\texisting.isGuest === (input.isGuest ?? false) &&\n\t\texisting.locale === effectiveLocale\n\t);\n}\n\n/**\n * Whether every key in `existing` appears in `input` with the same value.\n * Allows `input` to contain additional keys (the partial-write recovery\n * case); rejects on a divergent value or a key the input omits.\n */\nfunction existingCustomFieldsAreSubsetOf(\n\texisting: Record<string, unknown>,\n\tinput: Record<string, unknown> | undefined,\n): boolean {\n\tif (!input) return Object.keys(existing).length === 0;\n\tfor (const [slug, value] of Object.entries(existing)) {\n\t\tif (!Object.hasOwn(input, slug)) return false;\n\t\tif (input[slug] !== value) return false;\n\t}\n\treturn true;\n}\n\n/**\n * Reject locales the site doesn't configure. Returns `null` when the locale\n * is fine (omitted, or matches `locales` in the i18n config, or i18n isn't\n * configured at all).\n */\nfunction rejectUnknownLocale(locale: string | undefined): ApiResult<never> | null {\n\tif (!locale) return null;\n\tconst config = getI18nConfig();\n\tif (!config) return null;\n\tif (config.locales.includes(locale)) return null;\n\treturn {\n\t\tsuccess: false,\n\t\terror: {\n\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\tmessage: `Locale \"${locale}\" is not configured for this site`,\n\t\t},\n\t};\n}\n\n/**\n * Business-logic helpers for the bylines admin API.\n *\n * Mirrors the shape of `packages/core/src/api/handlers/menus.ts`. Route files\n * stay thin: they parse input, call these handlers, and forward the result via\n * `unwrapResult`. The repository (`BylineRepository`) is strict per locale; the\n * handlers add validation and translation-flow guards on top.\n */\n\nexport interface BylineTranslationsResponse {\n\titems: BylineSummary[];\n}\n\n/**\n * List every translation of a byline (by row id). Returns NOT_FOUND when no\n * row with the given id exists.\n */\nexport async function handleBylineTranslations(\n\tdb: Kysely<Database>,\n\tid: string,\n): Promise<ApiResult<BylineTranslationsResponse>> {\n\ttry {\n\t\tconst repo = new BylineRepository(db);\n\t\tconst anchor = await repo.findById(id);\n\t\tif (!anchor) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"NOT_FOUND\", message: \"Byline not found\" },\n\t\t\t};\n\t\t}\n\t\tconst items = await repo.listTranslations(id);\n\t\treturn { success: true, data: { items } };\n\t} catch {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode: \"BYLINE_TRANSLATIONS_ERROR\",\n\t\t\t\tmessage: \"Failed to list byline translations\",\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n * Create a new byline. When `translationOf` is supplied, the new row joins the\n * source byline's translation_group (a sibling in the same logical identity).\n *\n * Translating from a source row only makes sense when the caller names the\n * target locale, otherwise we'd silently clone into the configured default,\n * which is almost never what's intended (and will collide if the source is\n * already the default-locale row). Mirrors `handleMenuCreate`.\n */\nexport async function handleBylineCreate(\n\tdb: Kysely<Database>,\n\tinput: CreateBylineInput,\n): Promise<ApiResult<BylineSummary>> {\n\ttry {\n\t\tif (input.translationOf && !input.locale) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\t\t\tmessage: \"`locale` is required when `translationOf` is provided\",\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst localeErr = rejectUnknownLocale(input.locale);\n\t\tif (localeErr) return localeErr;\n\n\t\tconst repo = new BylineRepository(db);\n\n\t\t// Existence check up front so the repo's \"Source not found\" throw\n\t\t// becomes a clean NOT_FOUND on the API.\n\t\tlet sourceGroup: string | undefined;\n\t\tif (input.translationOf) {\n\t\t\tconst source = await repo.findById(input.translationOf);\n\t\t\tif (!source) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tcode: \"NOT_FOUND\",\n\t\t\t\t\t\tmessage: \"Source byline for translation not found\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\tsourceGroup = source.translationGroup ?? source.id;\n\t\t}\n\n\t\tconst effectiveLocale = input.locale ?? getI18nConfig()?.defaultLocale ?? \"en\";\n\n\t\t// Translation-group guard: the row-per-locale model (PR #916)\n\t\t// allows exactly one row per (translation_group, locale). Reject\n\t\t// here so callers get a clean 409 instead of a UNIQUE constraint\n\t\t// failure from the partial index. The DB constraint is the safety\n\t\t// net; this is the friendly error.\n\t\tif (sourceGroup) {\n\t\t\tconst siblings = await repo.findByTranslationGroup(sourceGroup);\n\t\t\tif (siblings.some((b) => b.locale === effectiveLocale)) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tcode: \"CONFLICT\",\n\t\t\t\t\t\tmessage: `Translation already exists in locale \"${effectiveLocale}\" for this byline`,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// Duplicate guard: same (slug, locale) — matches the DB unique key\n\t\t// from migration 040.\n\t\tconst existing = await repo.findBySlug(input.slug, { locale: effectiveLocale });\n\t\tif (existing) {\n\t\t\t// D1 has no transactions, so a crash between the byline insert\n\t\t\t// and the per-field writes leaves a partial row that's\n\t\t\t// otherwise unrecoverable. Treat a same-identity retry that\n\t\t\t// provides customFields as completing the abandoned create.\n\t\t\t// Recovery requires fixed-column + translation-group +\n\t\t\t// subset-customFields match; anything else collapses to a\n\t\t\t// standard duplicate-slug conflict.\n\t\t\tconst expectedTranslationGroup = sourceGroup ?? existing.id;\n\t\t\tconst inputHasFields = !!input.customFields && Object.keys(input.customFields).length > 0;\n\t\t\tif (\n\t\t\t\tinputHasFields &&\n\t\t\t\tbylineFixedFieldsMatch(existing, input, effectiveLocale) &&\n\t\t\t\texisting.translationGroup === expectedTranslationGroup &&\n\t\t\t\texistingCustomFieldsAreSubsetOf(existing.customFields ?? {}, input.customFields)\n\t\t\t) {\n\t\t\t\tconst recovered = await repo.update(existing.id, {\n\t\t\t\t\tcustomFields: input.customFields,\n\t\t\t\t});\n\t\t\t\tif (recovered) return { success: true, data: recovered };\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: \"CONFLICT\",\n\t\t\t\t\tmessage: `Byline \"${input.slug}\" already exists${\n\t\t\t\t\t\tinput.locale ? ` in locale \"${input.locale}\"` : \"\"\n\t\t\t\t\t}`,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tconst byline = await repo.create(input);\n\t\treturn { success: true, data: byline };\n\t} catch (error) {\n\t\t// Mirror handleBylineUpdate: surface customFields validation\n\t\t// errors as 400 rather than swallowing them as a generic 500.\n\t\tif (error instanceof EmDashValidationError) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"VALIDATION_ERROR\", message: error.message },\n\t\t\t};\n\t\t}\n\t\tconsole.error(\"[BYLINE_CREATE_ERROR]\", error);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: { code: \"BYLINE_CREATE_ERROR\", message: \"Failed to create byline\" },\n\t\t};\n\t}\n}\n\n/**\n * Update an existing byline. Forwards every field on `UpdateBylineInput`\n * to `BylineRepository.update`, including the Phase 3 `customFields`\n * map; per-field type validation lives in the repo, which throws\n * `EmDashValidationError` on unknown slugs, type mismatches, or\n * `select`-choice misses. This handler translates that into a clean\n * `VALIDATION_ERROR` (400 via `mapErrorStatus`).\n *\n * Returns `NOT_FOUND` when the byline id doesn't resolve. Generic\n * failures surface as `BYLINE_UPDATE_ERROR` (500) without leaking the\n * underlying message.\n */\nexport async function handleBylineUpdate(\n\tdb: Kysely<Database>,\n\tid: string,\n\tinput: UpdateBylineInput,\n): Promise<ApiResult<BylineSummary>> {\n\ttry {\n\t\tconst repo = new BylineRepository(db);\n\t\tconst byline = await repo.update(id, input);\n\t\tif (!byline) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"NOT_FOUND\", message: \"Byline not found\" },\n\t\t\t};\n\t\t}\n\t\treturn { success: true, data: byline };\n\t} catch (error) {\n\t\t// Unknown-key + type-mismatch + select-choice writes throw\n\t\t// EmDashValidationError (Phase 3, see BylineRepository.update).\n\t\t// Map to a clean 400 — the error message names the offending\n\t\t// slug/type, which is safe to surface to the admin client.\n\t\tif (error instanceof EmDashValidationError) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"VALIDATION_ERROR\", message: error.message },\n\t\t\t};\n\t\t}\n\t\tconsole.error(\"[BYLINE_UPDATE_ERROR]\", error);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: { code: \"BYLINE_UPDATE_ERROR\", message: \"Failed to update byline\" },\n\t\t};\n\t}\n}\n"],"mappings":";;;;;AAcA,MAAM,QAAQ,MAAgD,KAAK;;;;;;AAOnE,SAAS,uBACR,UACA,OACA,iBACU;AACV,QACC,SAAS,gBAAgB,MAAM,eAC/B,KAAK,SAAS,IAAI,KAAK,KAAK,MAAM,IAAI,IACtC,KAAK,SAAS,cAAc,KAAK,KAAK,MAAM,cAAc,IAC1D,KAAK,SAAS,WAAW,KAAK,KAAK,MAAM,WAAW,IACpD,KAAK,SAAS,OAAO,KAAK,KAAK,MAAM,OAAO,IAC5C,SAAS,aAAa,MAAM,WAAW,UACvC,SAAS,WAAW;;;;;;;AAStB,SAAS,gCACR,UACA,OACU;AACV,KAAI,CAAC,MAAO,QAAO,OAAO,KAAK,SAAS,CAAC,WAAW;AACpD,MAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,EAAE;AACrD,MAAI,CAAC,OAAO,OAAO,OAAO,KAAK,CAAE,QAAO;AACxC,MAAI,MAAM,UAAU,MAAO,QAAO;;AAEnC,QAAO;;;;;;;AAQR,SAAS,oBAAoB,QAAqD;AACjF,KAAI,CAAC,OAAQ,QAAO;CACpB,MAAM,SAAS,eAAe;AAC9B,KAAI,CAAC,OAAQ,QAAO;AACpB,KAAI,OAAO,QAAQ,SAAS,OAAO,CAAE,QAAO;AAC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AAS;IAA2B;GAC1E"}
@@ -1,9 +1,9 @@
1
- import { i as __exportAll } from "./runner-BiuUfx-V.mjs";
1
+ import { a as __exportAll } from "./runner--4wMWwKM.mjs";
2
2
  import { t as validateIdentifier } from "./validate-VPnKoIzW.mjs";
3
- import { r as requestCached } from "./request-cache-BYMs-BGX.mjs";
4
- import { t as BylineRepository } from "./byline-CAhk4FrG.mjs";
3
+ import { r as requestCached } from "./request-cache-D32LpnmI.mjs";
4
+ import { t as BylineRepository } from "./byline-DUx48sJp.mjs";
5
5
  import { n as isMissingTableError } from "./db-errors-CtzxKBxe.mjs";
6
- import { r as getDb } from "./loader-BxyvbrZP.mjs";
6
+ import { r as getDb } from "./loader-CpZKpFz0.mjs";
7
7
  import { i as resolveLocaleChain } from "./resolve-BqYMVG0D.mjs";
8
8
  import { sql } from "kysely";
9
9
 
@@ -12,6 +12,7 @@ var bylines_exports = /* @__PURE__ */ __exportAll({
12
12
  getByline: () => getByline,
13
13
  getBylineBySlug: () => getBylineBySlug,
14
14
  getBylinesForEntries: () => getBylinesForEntries,
15
+ getEntriesByByline: () => getEntriesByByline,
15
16
  invalidateBylineCache: () => invalidateBylineCache
16
17
  });
17
18
  /**
@@ -182,7 +183,50 @@ async function getBylinesForEntries(collection, entries) {
182
183
  }
183
184
  return result;
184
185
  }
186
+ /**
187
+ * Get content entries credited to a byline, in any credit position.
188
+ *
189
+ * Unlike filtering on the content table's `primary_byline_id` column (which
190
+ * only finds entries where the byline is the first/primary credit), this
191
+ * matches every explicit credit recorded in `_emdash_content_bylines`, so
192
+ * co-authored entries where the byline is a secondary credit are included.
193
+ *
194
+ * `byline` is matched against the byline's `translation_group` (the value
195
+ * stored on credits since migration 040), so a single credit spans every
196
+ * locale variant of the byline. Pass `byline.translationGroup ?? byline.id`
197
+ * from `getByline` / `getBylineBySlug`. An array matches any of the given
198
+ * bylines (OR).
199
+ *
200
+ * The result respects the active locale, status, ordering, and eager
201
+ * hydration of `getEmDashCollection`.
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * import { getBylineBySlug, getEntriesByByline } from "emdash";
206
+ *
207
+ * const byline = await getBylineBySlug("jane-doe");
208
+ * if (byline) {
209
+ * const posts = await getEntriesByByline("posts", byline.translationGroup ?? byline.id, {
210
+ * orderBy: { published_at: "desc" },
211
+ * });
212
+ * }
213
+ * ```
214
+ *
215
+ * @param collection - The collection slug (e.g. "posts")
216
+ * @param byline - A byline translation group, or an array of them (OR)
217
+ * @param options - Optional locale, ordering, status, and limit
218
+ */
219
+ async function getEntriesByByline(collection, byline, options = {}) {
220
+ const { getEmDashCollection } = await import("./query-BFQ029Ts.mjs").then((n) => n.o);
221
+ const queryOptions = { where: { byline } };
222
+ if (options.locale !== void 0) queryOptions.locale = options.locale;
223
+ if (options.orderBy !== void 0) queryOptions.orderBy = options.orderBy;
224
+ if (options.status !== void 0) queryOptions.status = options.status;
225
+ if (options.limit !== void 0) queryOptions.limit = options.limit;
226
+ const { entries } = await getEmDashCollection(collection, queryOptions);
227
+ return entries;
228
+ }
185
229
 
186
230
  //#endregion
187
- export { invalidateBylineCache as i, getByline as n, getBylineBySlug as r, bylines_exports as t };
188
- //# sourceMappingURL=bylines-DCczH3AV.mjs.map
231
+ export { invalidateBylineCache as a, getEntriesByByline as i, getByline as n, getBylineBySlug as r, bylines_exports as t };
232
+ //# sourceMappingURL=bylines-wurS258E.mjs.map