emdash 0.36.0 → 0.38.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 (991) hide show
  1. package/dist/{activation-K0kGBWuJ.mjs → activation-DyNTe_Tl.mjs} +3 -3
  2. package/dist/{activation-K0kGBWuJ.mjs.map → activation-DyNTe_Tl.mjs.map} +1 -1
  3. package/dist/{adapters-CzL3H752.d.mts → adapters-DCEgOBXi.d.mts} +4 -2
  4. package/dist/{adapters-CzL3H752.d.mts.map → adapters-DCEgOBXi.d.mts.map} +1 -1
  5. package/dist/{allowed-origins-maylGaHv.mjs → allowed-origins-GFUVavRj.mjs} +2 -2
  6. package/dist/{allowed-origins-maylGaHv.mjs.map → allowed-origins-GFUVavRj.mjs.map} +1 -1
  7. package/dist/api/route-utils.d.mts +3 -3
  8. package/dist/api/route-utils.mjs +25 -24
  9. package/dist/api/route-utils.mjs.map +1 -1
  10. package/dist/api/schemas/index.d.mts +2 -2
  11. package/dist/api/schemas/index.mjs +5 -5
  12. package/dist/api-BvxJmnFY.mjs +10094 -0
  13. package/dist/api-BvxJmnFY.mjs.map +1 -0
  14. package/dist/{api-tokens-9YrrCoE6.mjs → api-tokens-xpGqMHrC.mjs} +2 -2
  15. package/dist/{api-tokens-9YrrCoE6.mjs.map → api-tokens-xpGqMHrC.mjs.map} +1 -1
  16. package/dist/{apply-B_VMpJ2P.mjs → apply-DLmM3R7f.mjs} +26 -22
  17. package/dist/apply-DLmM3R7f.mjs.map +1 -0
  18. package/dist/artifact-fetch-P2JXVwOq.mjs +972 -0
  19. package/dist/artifact-fetch-P2JXVwOq.mjs.map +1 -0
  20. package/dist/astro/image-endpoint.mjs +2 -2
  21. package/dist/astro/image-endpoint.mjs.map +1 -1
  22. package/dist/astro/index.d.mts +12 -12
  23. package/dist/astro/index.d.mts.map +1 -1
  24. package/dist/astro/index.mjs +138 -39
  25. package/dist/astro/index.mjs.map +1 -1
  26. package/dist/astro/middleware/auth.d.mts +10 -10
  27. package/dist/astro/middleware/auth.mjs +6 -6
  28. package/dist/astro/middleware/media-usage-write-fence.mjs +3 -3
  29. package/dist/astro/middleware/redirect.mjs +7 -5
  30. package/dist/astro/middleware/redirect.mjs.map +1 -1
  31. package/dist/astro/middleware/request-context.mjs +3 -3
  32. package/dist/astro/middleware/setup.mjs +1 -1
  33. package/dist/astro/middleware.d.mts +10 -10
  34. package/dist/astro/middleware.d.mts.map +1 -1
  35. package/dist/astro/middleware.mjs +223 -232
  36. package/dist/astro/middleware.mjs.map +1 -1
  37. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +6 -6
  38. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +6 -6
  39. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +3 -3
  40. package/dist/astro/routes/api/admin/api-tokens/index.d.mts.map +1 -1
  41. package/dist/astro/routes/api/admin/api-tokens/index.mjs +5 -5
  42. package/dist/astro/routes/api/admin/api-tokens/index.mjs.map +1 -1
  43. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -4
  44. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +9 -9
  45. package/dist/astro/routes/api/admin/byline-fields/index.mjs +9 -9
  46. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +9 -9
  47. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +17 -17
  48. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +17 -17
  49. package/dist/astro/routes/api/admin/bylines/index.mjs +17 -17
  50. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +13 -13
  51. package/dist/astro/routes/api/admin/comments/_id_.mjs +5 -5
  52. package/dist/astro/routes/api/admin/comments/bulk.mjs +10 -10
  53. package/dist/astro/routes/api/admin/comments/counts.mjs +5 -5
  54. package/dist/astro/routes/api/admin/comments/index.mjs +10 -10
  55. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +4 -4
  56. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
  57. package/dist/astro/routes/api/admin/media-usage/activation.mjs +13 -13
  58. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +15 -15
  59. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +15 -15
  60. package/dist/astro/routes/api/admin/media-usage/progress.mjs +14 -14
  61. package/dist/astro/routes/api/admin/media-usage/repair.mjs +17 -17
  62. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +15 -15
  63. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +15 -15
  64. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +4 -4
  65. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs.map +1 -1
  66. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +4 -4
  67. package/dist/astro/routes/api/admin/oauth-clients/index.mjs.map +1 -1
  68. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +59 -56
  69. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
  70. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +59 -56
  71. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
  72. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +57 -54
  73. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  74. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +4 -4
  75. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +57 -54
  76. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
  77. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +58 -55
  78. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  79. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +58 -55
  80. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  81. package/dist/astro/routes/api/admin/plugins/index.mjs +57 -54
  82. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  83. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
  84. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +57 -54
  85. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  86. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +58 -55
  87. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  88. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +57 -54
  89. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  90. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +58 -55
  91. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  92. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.d.mts.map +1 -1
  93. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +64 -57
  94. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  95. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +18 -16
  96. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
  97. package/dist/astro/routes/api/admin/plugins/registry/install.d.mts.map +1 -1
  98. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +65 -58
  99. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  100. package/dist/astro/routes/api/admin/plugins/registry/verify.d.mts +8 -0
  101. package/dist/astro/routes/api/admin/plugins/registry/verify.d.mts.map +1 -0
  102. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +96 -0
  103. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs.map +1 -0
  104. package/dist/astro/routes/api/admin/plugins/updates.mjs +57 -54
  105. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  106. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +57 -54
  107. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  108. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
  109. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +57 -54
  110. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  111. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +1 -1
  112. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
  113. package/dist/astro/routes/api/admin/users/_id_/index.mjs +6 -6
  114. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +3 -3
  115. package/dist/astro/routes/api/admin/users/index.mjs +6 -6
  116. package/dist/astro/routes/api/auth/dev-bypass.mjs +3 -3
  117. package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
  118. package/dist/astro/routes/api/auth/invite/complete.mjs +11 -11
  119. package/dist/astro/routes/api/auth/invite/index.mjs +8 -8
  120. package/dist/astro/routes/api/auth/invite/register-options.mjs +10 -10
  121. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  122. package/dist/astro/routes/api/auth/magic-link/send.mjs +10 -10
  123. package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
  124. package/dist/astro/routes/api/auth/me.mjs +7 -7
  125. package/dist/astro/routes/api/auth/mode.mjs +2 -2
  126. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +4 -4
  127. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  128. package/dist/astro/routes/api/auth/passkey/_id_.mjs +6 -6
  129. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
  130. package/dist/astro/routes/api/auth/passkey/options.mjs +12 -12
  131. package/dist/astro/routes/api/auth/passkey/register/options.mjs +10 -10
  132. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +11 -11
  133. package/dist/astro/routes/api/auth/passkey/verify.mjs +11 -11
  134. package/dist/astro/routes/api/auth/signup/complete.mjs +11 -11
  135. package/dist/astro/routes/api/auth/signup/request.mjs +10 -10
  136. package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
  137. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +14 -14
  138. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +13 -13
  139. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  140. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.d.mts.map +1 -1
  141. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +19 -5
  142. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs.map +1 -1
  143. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +3 -3
  144. package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts +10 -0
  145. package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts.map +1 -0
  146. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +66 -0
  147. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs.map +1 -0
  148. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +2 -2
  149. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +11 -11
  150. package/dist/astro/routes/api/content/_collection_/_id_/publish.d.mts.map +1 -1
  151. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +18 -10
  152. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
  153. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +20 -18
  154. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
  155. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +20 -18
  156. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
  157. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +3 -3
  158. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
  159. package/dist/astro/routes/api/content/_collection_/_id_/schedule.d.mts.map +1 -1
  160. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +15 -8
  161. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
  162. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +16 -15
  163. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  164. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  165. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.d.mts.map +1 -1
  166. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +19 -5
  167. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs.map +1 -1
  168. package/dist/astro/routes/api/content/_collection_/_id_.d.mts.map +1 -1
  169. package/dist/astro/routes/api/content/_collection_/_id_.mjs +23 -11
  170. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  171. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  172. package/dist/astro/routes/api/content/_collection_/index.mjs +14 -9
  173. package/dist/astro/routes/api/content/_collection_/index.mjs.map +1 -1
  174. package/dist/astro/routes/api/content/_collection_/trash.mjs +7 -7
  175. package/dist/astro/routes/api/dashboard.mjs +8 -8
  176. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  177. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  178. package/dist/astro/routes/api/import/probe.mjs +18 -18
  179. package/dist/astro/routes/api/import/wordpress/analyze.mjs +3 -3
  180. package/dist/astro/routes/api/import/wordpress/execute.d.mts +11 -11
  181. package/dist/astro/routes/api/import/wordpress/execute.mjs +15 -14
  182. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  183. package/dist/astro/routes/api/import/wordpress/media.d.mts +10 -10
  184. package/dist/astro/routes/api/import/wordpress/media.mjs +11 -11
  185. package/dist/astro/routes/api/import/wordpress/prepare.mjs +10 -10
  186. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +11 -11
  187. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +13 -13
  188. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  189. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +18 -18
  190. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +11 -11
  191. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +29 -28
  192. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  193. package/dist/astro/routes/api/manifest.mjs +4 -4
  194. package/dist/astro/routes/api/manifest.mjs.map +1 -1
  195. package/dist/astro/routes/api/mcp.mjs +213 -74
  196. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  197. package/dist/astro/routes/api/media/_id_/confirm.mjs +11 -11
  198. package/dist/astro/routes/api/media/_id_/replace.d.mts +8 -0
  199. package/dist/astro/routes/api/media/_id_/replace.d.mts.map +1 -0
  200. package/dist/astro/routes/api/media/_id_/replace.mjs +91 -0
  201. package/dist/astro/routes/api/media/_id_/replace.mjs.map +1 -0
  202. package/dist/astro/routes/api/media/_id_/upload.mjs +6 -6
  203. package/dist/astro/routes/api/media/_id_/usage.mjs +19 -19
  204. package/dist/astro/routes/api/media/_id_.mjs +18 -18
  205. package/dist/astro/routes/api/media/file/_...key_.d.mts.map +1 -1
  206. package/dist/astro/routes/api/media/file/_...key_.mjs +3 -2
  207. package/dist/astro/routes/api/media/file/_...key_.mjs.map +1 -1
  208. package/dist/astro/routes/api/media/folders/_id_.mjs +8 -8
  209. package/dist/astro/routes/api/media/folders/index.mjs +8 -8
  210. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
  211. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  212. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  213. package/dist/astro/routes/api/media/upload-url.mjs +16 -14
  214. package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
  215. package/dist/astro/routes/api/media.d.mts.map +1 -1
  216. package/dist/astro/routes/api/media.mjs +53 -30
  217. package/dist/astro/routes/api/media.mjs.map +1 -1
  218. package/dist/astro/routes/api/menus/_name_/items/_id_.d.mts.map +1 -1
  219. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +20 -13
  220. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  221. package/dist/astro/routes/api/menus/_name_/items.d.mts.map +1 -1
  222. package/dist/astro/routes/api/menus/_name_/items.mjs +15 -11
  223. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  224. package/dist/astro/routes/api/menus/_name_/reorder.d.mts.map +1 -1
  225. package/dist/astro/routes/api/menus/_name_/reorder.mjs +15 -11
  226. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  227. package/dist/astro/routes/api/menus/_name_/translations.d.mts.map +1 -1
  228. package/dist/astro/routes/api/menus/_name_/translations.mjs +16 -12
  229. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  230. package/dist/astro/routes/api/menus/_name_.d.mts.map +1 -1
  231. package/dist/astro/routes/api/menus/_name_.mjs +21 -14
  232. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  233. package/dist/astro/routes/api/menus/index.d.mts.map +1 -1
  234. package/dist/astro/routes/api/menus/index.mjs +15 -11
  235. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  236. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  237. package/dist/astro/routes/api/oauth/device/authorize.mjs +5 -5
  238. package/dist/astro/routes/api/oauth/device/code.mjs +8 -8
  239. package/dist/astro/routes/api/oauth/device/token.mjs +7 -7
  240. package/dist/astro/routes/api/oauth/register.mjs +2 -2
  241. package/dist/astro/routes/api/oauth/token/refresh.mjs +5 -5
  242. package/dist/astro/routes/api/oauth/token/revoke.mjs +5 -5
  243. package/dist/astro/routes/api/oauth/token.mjs +5 -5
  244. package/dist/astro/routes/api/openapi.json.mjs +184 -52
  245. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  246. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +4 -4
  247. package/dist/astro/routes/api/redirects/404s/index.mjs +12 -11
  248. package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
  249. package/dist/astro/routes/api/redirects/404s/summary.mjs +12 -11
  250. package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
  251. package/dist/astro/routes/api/redirects/_id_.mjs +13 -12
  252. package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
  253. package/dist/astro/routes/api/redirects/index.mjs +13 -12
  254. package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
  255. package/dist/astro/routes/api/relations/_id_/index.mjs +20 -18
  256. package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
  257. package/dist/astro/routes/api/relations/_id_/translations.mjs +15 -13
  258. package/dist/astro/routes/api/relations/_id_/translations.mjs.map +1 -1
  259. package/dist/astro/routes/api/relations/index.mjs +20 -18
  260. package/dist/astro/routes/api/relations/index.mjs.map +1 -1
  261. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  262. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +3 -3
  263. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +57 -54
  264. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  265. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +57 -54
  266. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  267. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +57 -54
  268. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  269. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +57 -54
  270. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  271. package/dist/astro/routes/api/schema/collections/index.mjs +57 -54
  272. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  273. package/dist/astro/routes/api/schema/collections/reorder.mjs +57 -54
  274. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  275. package/dist/astro/routes/api/schema/index.mjs +13 -11
  276. package/dist/astro/routes/api/schema/index.mjs.map +1 -1
  277. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +57 -54
  278. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  279. package/dist/astro/routes/api/schema/orphans/index.mjs +57 -54
  280. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  281. package/dist/astro/routes/api/search/enable.mjs +12 -11
  282. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  283. package/dist/astro/routes/api/search/index.mjs +11 -10
  284. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  285. package/dist/astro/routes/api/search/rebuild.mjs +12 -11
  286. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  287. package/dist/astro/routes/api/search/stats.mjs +7 -6
  288. package/dist/astro/routes/api/search/stats.mjs.map +1 -1
  289. package/dist/astro/routes/api/search/suggest.mjs +11 -10
  290. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  291. package/dist/astro/routes/api/sections/_slug_.mjs +11 -10
  292. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  293. package/dist/astro/routes/api/sections/index.mjs +11 -10
  294. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  295. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +7 -6
  296. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs.map +1 -1
  297. package/dist/astro/routes/api/settings/backups/archives/index.mjs +6 -5
  298. package/dist/astro/routes/api/settings/backups/archives/index.mjs.map +1 -1
  299. package/dist/astro/routes/api/settings/backups/export.mjs +7 -6
  300. package/dist/astro/routes/api/settings/backups/export.mjs.map +1 -1
  301. package/dist/astro/routes/api/settings/backups/index.mjs +8 -7
  302. package/dist/astro/routes/api/settings/backups/index.mjs.map +1 -1
  303. package/dist/astro/routes/api/settings/email.mjs +5 -5
  304. package/dist/astro/routes/api/settings/email.mjs.map +1 -1
  305. package/dist/astro/routes/api/settings.d.mts.map +1 -1
  306. package/dist/astro/routes/api/settings.mjs +21 -17
  307. package/dist/astro/routes/api/settings.mjs.map +1 -1
  308. package/dist/astro/routes/api/setup/admin-verify.mjs +12 -12
  309. package/dist/astro/routes/api/setup/admin.mjs +11 -11
  310. package/dist/astro/routes/api/setup/dev-bypass.mjs +35 -33
  311. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  312. package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
  313. package/dist/astro/routes/api/setup/index.mjs +35 -33
  314. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  315. package/dist/astro/routes/api/setup/status.mjs +3 -3
  316. package/dist/astro/routes/api/snapshot.mjs +8 -7
  317. package/dist/astro/routes/api/snapshot.mjs.map +1 -1
  318. package/dist/astro/routes/api/taxonomies/_name_/reorder.d.mts.map +1 -1
  319. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +22 -17
  320. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -1
  321. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.d.mts.map +1 -1
  322. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +23 -18
  323. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
  324. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.d.mts.map +1 -1
  325. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +27 -19
  326. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
  327. package/dist/astro/routes/api/taxonomies/_name_/terms/index.d.mts.map +1 -1
  328. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +22 -17
  329. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
  330. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +16 -15
  331. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -1
  332. package/dist/astro/routes/api/taxonomies/_name_.d.mts.map +1 -1
  333. package/dist/astro/routes/api/taxonomies/_name_.mjs +28 -20
  334. package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -1
  335. package/dist/astro/routes/api/taxonomies/index.d.mts.map +1 -1
  336. package/dist/astro/routes/api/taxonomies/index.mjs +22 -17
  337. package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
  338. package/dist/astro/routes/api/themes/preview.mjs +5 -5
  339. package/dist/astro/routes/api/typegen.mjs +4 -4
  340. package/dist/astro/routes/api/well-known/auth.mjs +2 -2
  341. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  342. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  343. package/dist/astro/routes/api/widget-areas/_name_/reorder.d.mts.map +1 -1
  344. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +10 -8
  345. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
  346. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.d.mts.map +1 -1
  347. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +18 -14
  348. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
  349. package/dist/astro/routes/api/widget-areas/_name_/widgets.d.mts.map +1 -1
  350. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +16 -13
  351. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
  352. package/dist/astro/routes/api/widget-areas/_name_.d.mts.map +1 -1
  353. package/dist/astro/routes/api/widget-areas/_name_.mjs +9 -7
  354. package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
  355. package/dist/astro/routes/api/widget-areas/index.d.mts.map +1 -1
  356. package/dist/astro/routes/api/widget-areas/index.mjs +16 -13
  357. package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
  358. package/dist/astro/routes/api/widget-components.mjs +2 -2
  359. package/dist/astro/routes/robots.txt.mjs +8 -8
  360. package/dist/astro/routes/sitemap-_collection_.xml.mjs +13 -12
  361. package/dist/astro/routes/sitemap-_collection_.xml.mjs.map +1 -1
  362. package/dist/astro/routes/sitemap.xml.mjs +9 -9
  363. package/dist/astro/types.d.mts +50 -20
  364. package/dist/astro/types.d.mts.map +1 -1
  365. package/dist/auth/providers/github.d.mts +1 -1
  366. package/dist/auth/providers/google.d.mts +1 -1
  367. package/dist/{authorize-ByYs-Uxs.mjs → authorize-C2QHlWSS.mjs} +2 -2
  368. package/dist/{authorize-ByYs-Uxs.mjs.map → authorize-C2QHlWSS.mjs.map} +1 -1
  369. package/dist/{backup-ChyHfIoX.mjs → backup-oS8ft5Cm.mjs} +5 -5
  370. package/dist/{backup-ChyHfIoX.mjs.map → backup-oS8ft5Cm.mjs.map} +1 -1
  371. package/dist/{bundle-DZFhFurR.mjs → bundle-CL0JjIPx.mjs} +4 -4
  372. package/dist/{bundle-DZFhFurR.mjs.map → bundle-CL0JjIPx.mjs.map} +1 -1
  373. package/dist/{byline-Cpnwrje1.mjs → byline-Vdi85CsZ.mjs} +27 -14
  374. package/dist/byline-Vdi85CsZ.mjs.map +1 -0
  375. package/dist/{byline-fields-CAyA_Umd.mjs → byline-fields-DPVRFMz2.mjs} +2 -2
  376. package/dist/{byline-fields-CAyA_Umd.mjs.map → byline-fields-DPVRFMz2.mjs.map} +1 -1
  377. package/dist/{byline-registry-Bpu9-MVs.mjs → byline-registry-BxDGIO0I.mjs} +2 -2
  378. package/dist/{byline-registry-Bpu9-MVs.mjs.map → byline-registry-BxDGIO0I.mjs.map} +1 -1
  379. package/dist/{bylines-BSo9B9RX.mjs → bylines-BX8QhcTk.mjs} +7 -7
  380. package/dist/{bylines-BSo9B9RX.mjs.map → bylines-BX8QhcTk.mjs.map} +1 -1
  381. package/dist/{bylines-CHjvehVX.mjs → bylines-w-E1IEQd.mjs} +3 -3
  382. package/dist/{bylines-CHjvehVX.mjs.map → bylines-w-E1IEQd.mjs.map} +1 -1
  383. package/dist/{cache-5VirJ2Cn.mjs → cache--7HKu5Xm.mjs} +4 -4
  384. package/dist/{cache-5VirJ2Cn.mjs.map → cache--7HKu5Xm.mjs.map} +1 -1
  385. package/dist/{capture-triggers-CNW1q3HK.mjs → capture-triggers-CeAsC76Z.mjs} +2 -2
  386. package/dist/{capture-triggers-CNW1q3HK.mjs.map → capture-triggers-CeAsC76Z.mjs.map} +1 -1
  387. package/dist/{challenge-store-D5pSY2S1.mjs → challenge-store-BIOak-tp.mjs} +5 -3
  388. package/dist/challenge-store-BIOak-tp.mjs.map +1 -0
  389. package/dist/chrome-tags-DzDQBCjX.mjs +24 -0
  390. package/dist/chrome-tags-DzDQBCjX.mjs.map +1 -0
  391. package/dist/{chunks-bNiX6_DR.mjs → chunks-VG_tyqnP.mjs} +2 -2
  392. package/dist/{chunks-bNiX6_DR.mjs.map → chunks-VG_tyqnP.mjs.map} +1 -1
  393. package/dist/cli/index.mjs +68 -40
  394. package/dist/cli/index.mjs.map +1 -1
  395. package/dist/client/cf-access.d.mts +1 -1
  396. package/dist/client/index.d.mts +17 -7
  397. package/dist/client/index.d.mts.map +1 -1
  398. package/dist/client/index.mjs +17 -12
  399. package/dist/client/index.mjs.map +1 -1
  400. package/dist/{collection-deletion-m_oi2c0N.mjs → collection-deletion-BCwaWTDw.mjs} +4 -4
  401. package/dist/{collection-deletion-m_oi2c0N.mjs.map → collection-deletion-BCwaWTDw.mjs.map} +1 -1
  402. package/dist/collection-slugs-cache-7lTmNzeA.mjs +85 -0
  403. package/dist/collection-slugs-cache-7lTmNzeA.mjs.map +1 -0
  404. package/dist/{comment-reaction-CRuItEjt.mjs → comment-reaction-CDyvPQRj.mjs} +2 -2
  405. package/dist/{comment-reaction-CRuItEjt.mjs.map → comment-reaction-CDyvPQRj.mjs.map} +1 -1
  406. package/dist/{comment-DhvLEdhQ.mjs → comment-vxOzWbZN.mjs} +2 -2
  407. package/dist/{comment-DhvLEdhQ.mjs.map → comment-vxOzWbZN.mjs.map} +1 -1
  408. package/dist/{comments-CLj4bi8I.mjs → comments-VzmVLyaC.mjs} +2 -2
  409. package/dist/{comments-CLj4bi8I.mjs.map → comments-VzmVLyaC.mjs.map} +1 -1
  410. package/dist/{components-v4U4DT2y.mjs → components-CL6Wkdk-.mjs} +1 -1
  411. package/dist/{components-v4U4DT2y.mjs.map → components-CL6Wkdk-.mjs.map} +1 -1
  412. package/dist/config--eWjQJE5.mjs +217 -0
  413. package/dist/config--eWjQJE5.mjs.map +1 -0
  414. package/dist/{index-DWbJrsAg.d.mts → config-CGAhyOjP.d.mts} +276 -76
  415. package/dist/config-CGAhyOjP.d.mts.map +1 -0
  416. package/dist/{config-DrfghTPe.d.mts → config-ChFzshGd.d.mts} +1 -1
  417. package/dist/{config-DrfghTPe.d.mts.map → config-ChFzshGd.d.mts.map} +1 -1
  418. package/dist/{content-CP-SeXNa.mjs → content-CNfMWuhY.mjs} +202 -46
  419. package/dist/content-CNfMWuhY.mjs.map +1 -0
  420. package/dist/{content-list-query-BhejKVqb.d.mts → content-list-query-B8d4UQp9.d.mts} +1 -1
  421. package/dist/{content-list-query-BhejKVqb.d.mts.map → content-list-query-B8d4UQp9.d.mts.map} +1 -1
  422. package/dist/{content-refresh-DLOfIhYc.mjs → content-refresh-GTMyi2Xy.mjs} +53 -26
  423. package/dist/content-refresh-GTMyi2Xy.mjs.map +1 -0
  424. package/dist/{content-repair-BCxzy0r4.mjs → content-repair-CIMt5C0U.mjs} +4 -4
  425. package/dist/{content-repair-BCxzy0r4.mjs.map → content-repair-CIMt5C0U.mjs.map} +1 -1
  426. package/dist/{context-BR5hRWiK.mjs → context-C9PB8vGd.mjs} +308 -33
  427. package/dist/context-C9PB8vGd.mjs.map +1 -0
  428. package/dist/{cron-CWfWrWKG.mjs → cron-DHAy9oyq.mjs} +1 -1
  429. package/dist/{cron-CWfWrWKG.mjs.map → cron-DHAy9oyq.mjs.map} +1 -1
  430. package/dist/{dashboard-CkIV2rnQ.mjs → dashboard-BNSvAN8A.mjs} +5 -5
  431. package/dist/{dashboard-CkIV2rnQ.mjs.map → dashboard-BNSvAN8A.mjs.map} +1 -1
  432. package/dist/db/index.d.mts +3 -3
  433. package/dist/db/index.mjs +2 -2
  434. package/dist/db/index.mjs.map +1 -1
  435. package/dist/db/libsql-migrations.d.mts +1 -1
  436. package/dist/db/libsql-migrations.mjs +5 -5
  437. package/dist/db/libsql.d.mts +1 -1
  438. package/dist/db/postgres-migrations.d.mts +1 -1
  439. package/dist/db/postgres-migrations.mjs +5 -5
  440. package/dist/db/postgres.d.mts +1 -1
  441. package/dist/db/postgres.d.mts.map +1 -1
  442. package/dist/db/postgres.mjs +19 -3
  443. package/dist/db/postgres.mjs.map +1 -1
  444. package/dist/db/sqlite-migrations.d.mts +1 -1
  445. package/dist/db/sqlite-migrations.mjs +5 -5
  446. package/dist/db/sqlite.d.mts +1 -1
  447. package/dist/db/sqlite.mjs +1 -1
  448. package/dist/{default-YMEfcQUx.mjs → default-ByZ0JqZo.mjs} +1 -1
  449. package/dist/{default-YMEfcQUx.mjs.map → default-ByZ0JqZo.mjs.map} +1 -1
  450. package/dist/{deferred-tasks-DfqxH5Xf.d.mts → deferred-tasks-Cu4NSJpa.d.mts} +1 -1
  451. package/dist/{deferred-tasks-DfqxH5Xf.d.mts.map → deferred-tasks-Cu4NSJpa.d.mts.map} +1 -1
  452. package/dist/dev-typegen-DHT7lcMU.mjs +29 -0
  453. package/dist/dev-typegen-DHT7lcMU.mjs.map +1 -0
  454. package/dist/{device-flow-CojjSBwb.mjs → device-flow-Cf6bhCCT.mjs} +4 -4
  455. package/dist/{device-flow-CojjSBwb.mjs.map → device-flow-Cf6bhCCT.mjs.map} +1 -1
  456. package/dist/{dialect-helpers-BSbfaO3F.mjs → dialect-helpers-BcQvkHgn.mjs} +83 -2
  457. package/dist/dialect-helpers-BcQvkHgn.mjs.map +1 -0
  458. package/dist/{direct-executor-BWeWiRYB.mjs → direct-executor-yAyUGSqB.mjs} +3 -3
  459. package/dist/{direct-executor-BWeWiRYB.mjs.map → direct-executor-yAyUGSqB.mjs.map} +1 -1
  460. package/dist/{dist-89xCrGqi.mjs → dist-BAsh8dbf.mjs} +1 -1
  461. package/dist/{dist-89xCrGqi.mjs.map → dist-BAsh8dbf.mjs.map} +1 -1
  462. package/dist/{email-console-CEJgR_LB.mjs → email-console-DNup1Fku.mjs} +1 -1
  463. package/dist/{email-console-CEJgR_LB.mjs.map → email-console-DNup1Fku.mjs.map} +1 -1
  464. package/dist/{enrich-BX0IDp4z.mjs → enrich-t2Xvjdqa.mjs} +3 -3
  465. package/dist/{enrich-BX0IDp4z.mjs.map → enrich-t2Xvjdqa.mjs.map} +1 -1
  466. package/dist/entry-lock-BEr8gDkG.mjs +163 -0
  467. package/dist/entry-lock-BEr8gDkG.mjs.map +1 -0
  468. package/dist/{relations-C7B46bcU.d.mts → entry-lock-CGAtrwAR.d.mts} +265 -76
  469. package/dist/entry-lock-CGAtrwAR.d.mts.map +1 -0
  470. package/dist/{redirects-CRIM55KH.mjs → entry-lock-DIYHAaSw.mjs} +112 -34
  471. package/dist/entry-lock-DIYHAaSw.mjs.map +1 -0
  472. package/dist/entry-locks-BEcX7ET0.mjs +167 -0
  473. package/dist/entry-locks-BEcX7ET0.mjs.map +1 -0
  474. package/dist/{error-D9w94fjV.mjs → error-BDcFyoRt.mjs} +2 -2
  475. package/dist/{error-D9w94fjV.mjs.map → error-BDcFyoRt.mjs.map} +1 -1
  476. package/dist/{errors-n2j49uNf.mjs → errors-DvMdNrgf.mjs} +10 -1
  477. package/dist/errors-DvMdNrgf.mjs.map +1 -0
  478. package/dist/{escape-DN4Qmjsl.mjs → escape-B3asJC6W.mjs} +1 -1
  479. package/dist/{escape-DN4Qmjsl.mjs.map → escape-B3asJC6W.mjs.map} +1 -1
  480. package/dist/{field-defs-cache-Bh4q6oar.mjs → field-defs-cache-Cf5FHK0M.mjs} +5 -5
  481. package/dist/{field-defs-cache-Bh4q6oar.mjs.map → field-defs-cache-Cf5FHK0M.mjs.map} +1 -1
  482. package/dist/{fts-manager-BhOdW0bi.mjs → fts-manager-iddym8cd.mjs} +4 -4
  483. package/dist/{fts-manager-BhOdW0bi.mjs.map → fts-manager-iddym8cd.mjs.map} +1 -1
  484. package/dist/{hash-CTcngWvj.mjs → hash-BRweX6jz.mjs} +1 -1
  485. package/dist/{hash-CTcngWvj.mjs.map → hash-BRweX6jz.mjs.map} +1 -1
  486. package/dist/hook-result-BrshYHLx.d.mts +31 -0
  487. package/dist/hook-result-BrshYHLx.d.mts.map +1 -0
  488. package/dist/{hreflang-7pTHsLZJ.d.mts → hreflang-CQpu5bMy.d.mts} +2 -2
  489. package/dist/{hreflang-7pTHsLZJ.d.mts.map → hreflang-CQpu5bMy.d.mts.map} +1 -1
  490. package/dist/{hreflang-Huc6O5wa.mjs → hreflang-DshnweTC.mjs} +9 -8
  491. package/dist/{hreflang-Huc6O5wa.mjs.map → hreflang-DshnweTC.mjs.map} +1 -1
  492. package/dist/{identity-DXmb4aVp.mjs → identity-CjGKDq8J.mjs} +3 -3
  493. package/dist/{identity-DXmb4aVp.mjs.map → identity-CjGKDq8J.mjs.map} +1 -1
  494. package/dist/{import-C4_O3KXU.mjs → import-D96g2otw.mjs} +6 -6
  495. package/dist/{import-C4_O3KXU.mjs.map → import-D96g2otw.mjs.map} +1 -1
  496. package/dist/{index-6bRee8zb.d.mts → index-1ECYpfiF.d.mts} +3 -3
  497. package/dist/{index-6bRee8zb.d.mts.map → index-1ECYpfiF.d.mts.map} +1 -1
  498. package/dist/index.d.mts +22 -21
  499. package/dist/index.mjs +84 -81
  500. package/dist/{init-lock-DJkX6Hto.mjs → init-lock-CFNBe_iH.mjs} +1 -1
  501. package/dist/{init-lock-DJkX6Hto.mjs.map → init-lock-CFNBe_iH.mjs.map} +1 -1
  502. package/dist/{load-Bo7fZAbg.mjs → load-DPtY9cZo.mjs} +2 -2
  503. package/dist/{load-Bo7fZAbg.mjs.map → load-DPtY9cZo.mjs.map} +1 -1
  504. package/dist/{loader-ZsjE4paL.mjs → loader-WJi6GFRn.mjs} +90 -17
  505. package/dist/loader-WJi6GFRn.mjs.map +1 -0
  506. package/dist/{manifest-builder-QXuqvVMP.mjs → manifest-builder-BfNlGQIA.mjs} +2 -2
  507. package/dist/{manifest-builder-QXuqvVMP.mjs.map → manifest-builder-BfNlGQIA.mjs.map} +1 -1
  508. package/dist/{manifest-schema-CUYPfCEH.mjs → manifest-schema-CILooI5J.mjs} +5 -5
  509. package/dist/manifest-schema-CILooI5J.mjs.map +1 -0
  510. package/dist/media/image-endpoint.d.mts +4 -2
  511. package/dist/media/image-endpoint.d.mts.map +1 -1
  512. package/dist/media/image-endpoint.mjs +6 -4
  513. package/dist/media/image-endpoint.mjs.map +1 -1
  514. package/dist/media/index.d.mts +1 -1
  515. package/dist/media/index.mjs +3 -3
  516. package/dist/media/local-runtime.d.mts +12 -12
  517. package/dist/media/local-runtime.mjs +7 -7
  518. package/dist/{media-D6SeAfBl.mjs → media-BBm8Wg3f.mjs} +30 -2
  519. package/dist/media-BBm8Wg3f.mjs.map +1 -0
  520. package/dist/{media-BjwNuLEu.mjs → media-C1EIZKh1.mjs} +35 -5
  521. package/dist/media-C1EIZKh1.mjs.map +1 -0
  522. package/dist/{media-allowlist-D35v7bmL.mjs → media-allowlist-elXJgb_K.mjs} +2 -2
  523. package/dist/{media-allowlist-D35v7bmL.mjs.map → media-allowlist-elXJgb_K.mjs.map} +1 -1
  524. package/dist/{media-folders-D-0CmRZj.mjs → media-folders-DASfX_DH.mjs} +1 -1
  525. package/dist/{media-folders-D-0CmRZj.mjs.map → media-folders-DASfX_DH.mjs.map} +1 -1
  526. package/dist/{media-upload-C7bLXGcI.mjs → media-upload-C7_AQJ5v.mjs} +9 -9
  527. package/dist/{media-upload-C7bLXGcI.mjs.map → media-upload-C7_AQJ5v.mjs.map} +1 -1
  528. package/dist/{media-url-DH7giMx_.mjs → media-url-8dVl1loq.mjs} +19 -2
  529. package/dist/media-url-8dVl1loq.mjs.map +1 -0
  530. package/dist/{media-usage-BTRJvS6V.mjs → media-usage-C1EswMTq.mjs} +10 -10
  531. package/dist/{media-usage-BTRJvS6V.mjs.map → media-usage-C1EswMTq.mjs.map} +1 -1
  532. package/dist/{media-usage-activation-Dx0kPV6b.mjs → media-usage-activation-CrHNltlL.mjs} +3 -3
  533. package/dist/{media-usage-activation-Dx0kPV6b.mjs.map → media-usage-activation-CrHNltlL.mjs.map} +1 -1
  534. package/dist/{media-usage-work-C-fhM30c.mjs → media-usage-work-C5B1zT1c.mjs} +2 -2
  535. package/dist/{media-usage-work-C-fhM30c.mjs.map → media-usage-work-C5B1zT1c.mjs.map} +1 -1
  536. package/dist/{media-usage-work-DWb2XPMI.mjs → media-usage-work-IkQx_Yz6.mjs} +4 -4
  537. package/dist/{media-usage-work-DWb2XPMI.mjs.map → media-usage-work-IkQx_Yz6.mjs.map} +1 -1
  538. package/dist/{media-usage-write-fence-BwoJVRDC.mjs → media-usage-write-fence-B9anjOSg.mjs} +3 -3
  539. package/dist/{media-usage-write-fence-BwoJVRDC.mjs.map → media-usage-write-fence-B9anjOSg.mjs.map} +1 -1
  540. package/dist/{menus-CNg0QlDt.mjs → menus-D8mC4eaN.mjs} +406 -175
  541. package/dist/menus-D8mC4eaN.mjs.map +1 -0
  542. package/dist/{menus-CD7EFLwz.mjs → menus-UdwjHZJC.mjs} +12 -4
  543. package/dist/{menus-CD7EFLwz.mjs.map → menus-UdwjHZJC.mjs.map} +1 -1
  544. package/dist/migrations/index.d.mts +1 -1
  545. package/dist/migrations/index.mjs +4 -4
  546. package/dist/{mime-CUIG6x84.mjs → mime-DYpsOAny.mjs} +1 -1
  547. package/dist/{mime-CUIG6x84.mjs.map → mime-DYpsOAny.mjs.map} +1 -1
  548. package/dist/{mode-DaUM_MB2.mjs → mode-Dm4BHhRH.mjs} +1 -1
  549. package/dist/{mode-DaUM_MB2.mjs.map → mode-Dm4BHhRH.mjs.map} +1 -1
  550. package/dist/{node-sqlite-compat-Udb4Y-rs.mjs → node-sqlite-compat-2sezm-Zd.mjs} +1 -1
  551. package/dist/{node-sqlite-compat-Udb4Y-rs.mjs.map → node-sqlite-compat-2sezm-Zd.mjs.map} +1 -1
  552. package/dist/{normalize-CSxdKBVa.mjs → normalize-4nkKGsuW.mjs} +15 -5
  553. package/dist/normalize-4nkKGsuW.mjs.map +1 -0
  554. package/dist/{oauth-authorization-Dpsb-fMJ.mjs → oauth-authorization-BxE_lURD.mjs} +4 -4
  555. package/dist/{oauth-authorization-Dpsb-fMJ.mjs.map → oauth-authorization-BxE_lURD.mjs.map} +1 -1
  556. package/dist/{oauth-clients-Bxnoe_67.mjs → oauth-clients-DJIdOdq0.mjs} +1 -1
  557. package/dist/{oauth-clients-Bxnoe_67.mjs.map → oauth-clients-DJIdOdq0.mjs.map} +1 -1
  558. package/dist/{oauth-state-store-0C4s0K6w.mjs → oauth-state-store-CsdxP57n.mjs} +1 -1
  559. package/dist/{oauth-state-store-0C4s0K6w.mjs.map → oauth-state-store-CsdxP57n.mjs.map} +1 -1
  560. package/dist/{oauth-user-lookup-wlGYSeqX.mjs → oauth-user-lookup-HzzW-dkF.mjs} +1 -1
  561. package/dist/{oauth-user-lookup-wlGYSeqX.mjs.map → oauth-user-lookup-HzzW-dkF.mjs.map} +1 -1
  562. package/dist/object-cache/memory.d.mts +1 -1
  563. package/dist/{object-cache-71tPfV4A.mjs → object-cache-DVKnyOfy.mjs} +19 -3
  564. package/dist/object-cache-DVKnyOfy.mjs.map +1 -0
  565. package/dist/{options-BHPeIbBd.mjs → options-D1FBiAv1.mjs} +60 -5
  566. package/dist/options-D1FBiAv1.mjs.map +1 -0
  567. package/dist/{options-BhZIeFY1.d.mts → options-D8Y0VHc7.d.mts} +30 -11
  568. package/dist/options-D8Y0VHc7.d.mts.map +1 -0
  569. package/dist/page/index.d.mts +2 -2
  570. package/dist/page/index.d.mts.map +1 -1
  571. package/dist/page/index.mjs +12 -0
  572. package/dist/page/index.mjs.map +1 -1
  573. package/dist/{parse-BRJg1kz8.mjs → parse-WRg5C3NX.mjs} +2 -2
  574. package/dist/{parse-BRJg1kz8.mjs.map → parse-WRg5C3NX.mjs.map} +1 -1
  575. package/dist/{passkey-config-B3P0nHRR.mjs → passkey-config-qIdO-wF6.mjs} +1 -1
  576. package/dist/{passkey-config-B3P0nHRR.mjs.map → passkey-config-qIdO-wF6.mjs.map} +1 -1
  577. package/dist/{patterns-D9iDO3j8.mjs → patterns-DC8CLptu.mjs} +1 -1
  578. package/dist/{patterns-D9iDO3j8.mjs.map → patterns-DC8CLptu.mjs.map} +1 -1
  579. package/dist/{placeholder-BR4ZhVJl.d.mts → placeholder-COrvARyD.d.mts} +1 -1
  580. package/dist/{placeholder-BR4ZhVJl.d.mts.map → placeholder-COrvARyD.d.mts.map} +1 -1
  581. package/dist/plugin-types.d.mts +8 -3
  582. package/dist/plugin-types.d.mts.map +1 -1
  583. package/dist/plugin-utils.d.mts +10 -10
  584. package/dist/plugins/adapt-sandbox-entry.d.mts +10 -10
  585. package/dist/plugins/adapt-sandbox-entry.mjs +2 -2
  586. package/dist/{policy-BVRganJQ.mjs → policy-XCfb-IE9.mjs} +2 -2
  587. package/dist/{policy-BVRganJQ.mjs.map → policy-XCfb-IE9.mjs.map} +1 -1
  588. package/dist/{portable-text-C8Tvp4_g.mjs → portable-text-BS3d5n-0.mjs} +1 -1
  589. package/dist/{portable-text-C8Tvp4_g.mjs.map → portable-text-BS3d5n-0.mjs.map} +1 -1
  590. package/dist/{preview-dn2dUyM0.mjs → preview-BxwsGgGp.mjs} +2 -2
  591. package/dist/{preview-dn2dUyM0.mjs.map → preview-BxwsGgGp.mjs.map} +1 -1
  592. package/dist/{protocol-CuBEsqgE.d.mts → protocol-CLn58-nw.d.mts} +2 -2
  593. package/dist/{protocol-CuBEsqgE.d.mts.map → protocol-CLn58-nw.d.mts.map} +1 -1
  594. package/dist/{public-url-DRz_AinV.mjs → public-url-FWWAvnre.mjs} +1 -1
  595. package/dist/{public-url-DRz_AinV.mjs.map → public-url-FWWAvnre.mjs.map} +1 -1
  596. package/dist/{query-D18vTdha.mjs → query-DygOte9M.mjs} +26 -17
  597. package/dist/query-DygOte9M.mjs.map +1 -0
  598. package/dist/{query-tZDEdtCN.mjs → query-gtXT03Wc.mjs} +5 -5
  599. package/dist/{query-tZDEdtCN.mjs.map → query-gtXT03Wc.mjs.map} +1 -1
  600. package/dist/{rate-limit-on7KPo-v.mjs → rate-limit-CQUPm0dh.mjs} +2 -2
  601. package/dist/{rate-limit-on7KPo-v.mjs.map → rate-limit-CQUPm0dh.mjs.map} +1 -1
  602. package/dist/{redirect-DrbEmU9a.mjs → redirect-D1cWafi6.mjs} +1 -1
  603. package/dist/{redirect-DrbEmU9a.mjs.map → redirect-D1cWafi6.mjs.map} +1 -1
  604. package/dist/{redirect-CZkbozu9.mjs → redirect-DId44BS1.mjs} +19 -6
  605. package/dist/redirect-DId44BS1.mjs.map +1 -0
  606. package/dist/{redirects-BahWiu8Z.mjs → redirects-DN-ZE33W.mjs} +5 -5
  607. package/dist/{redirects-BahWiu8Z.mjs.map → redirects-DN-ZE33W.mjs.map} +1 -1
  608. package/dist/{registry-Cx-jEJOS.mjs → registry-DTqaqxed.mjs} +46 -12
  609. package/dist/registry-DTqaqxed.mjs.map +1 -0
  610. package/dist/{relation-A6wLF_DS.mjs → relation-DxgCHOBw.mjs} +2 -2
  611. package/dist/{relation-A6wLF_DS.mjs.map → relation-DxgCHOBw.mjs.map} +1 -1
  612. package/dist/{relations-Cj5hZ6Zg.mjs → relations-KKDSLUwS.mjs} +4 -4
  613. package/dist/{relations-Cj5hZ6Zg.mjs.map → relations-KKDSLUwS.mjs.map} +1 -1
  614. package/dist/{relations-BTPM2saV.mjs → relations-rOmbndUJ.mjs} +8 -8
  615. package/dist/relations-rOmbndUJ.mjs.map +1 -0
  616. package/dist/{request-cache-DH9zdCOD.mjs → request-cache-DAZZmesc.mjs} +1 -1
  617. package/dist/{request-cache-DH9zdCOD.mjs.map → request-cache-DAZZmesc.mjs.map} +1 -1
  618. package/dist/request-context.d.mts +1 -1
  619. package/dist/{request-meta-DRp5ENd_.mjs → request-meta-BgjUQLQ-.mjs} +2 -2
  620. package/dist/{request-meta-DRp5ENd_.mjs.map → request-meta-BgjUQLQ-.mjs.map} +1 -1
  621. package/dist/{resolve-DxUpTMmE.mjs → resolve-Cy0aWSRj.mjs} +37 -4
  622. package/dist/resolve-Cy0aWSRj.mjs.map +1 -0
  623. package/dist/{runner-zgqA_CqP.d.mts → runner-CfwysRM0.d.mts} +3 -2
  624. package/dist/runner-CfwysRM0.d.mts.map +1 -0
  625. package/dist/{runner-77GOZCnH.mjs → runner-nEzvnogG.mjs} +476 -295
  626. package/dist/runner-nEzvnogG.mjs.map +1 -0
  627. package/dist/runtime.d.mts +11 -11
  628. package/dist/runtime.mjs +3 -2
  629. package/dist/runtime.mjs.map +1 -1
  630. package/dist/{schema-BY-oVntF.mjs → schema-CRu38Pr5.mjs} +3 -3
  631. package/dist/{schema-BY-oVntF.mjs.map → schema-CRu38Pr5.mjs.map} +1 -1
  632. package/dist/{schema-Cw9kVK0I.mjs → schema-DifxndJx.mjs} +5 -5
  633. package/dist/{schema-Cw9kVK0I.mjs.map → schema-DifxndJx.mjs.map} +1 -1
  634. package/dist/{scopes-vMR1uIbt.mjs → scopes-D5A1OZbq.mjs} +3 -3
  635. package/dist/{scopes-vMR1uIbt.mjs.map → scopes-D5A1OZbq.mjs.map} +1 -1
  636. package/dist/{search-CfT3KxO5.mjs → search-DEPFSBFq.mjs} +4 -4
  637. package/dist/{search-CfT3KxO5.mjs.map → search-DEPFSBFq.mjs.map} +1 -1
  638. package/dist/{secrets-BH2Qow1-.mjs → secrets-CdfzLdoO.mjs} +3 -3
  639. package/dist/{secrets-BH2Qow1-.mjs.map → secrets-CdfzLdoO.mjs.map} +1 -1
  640. package/dist/{sections-DTfjyf1z.mjs → sections-3X52kmIR.mjs} +2 -2
  641. package/dist/{sections-DTfjyf1z.mjs.map → sections-3X52kmIR.mjs.map} +1 -1
  642. package/dist/seed/index.d.mts +2 -2
  643. package/dist/seed/index.mjs +28 -26
  644. package/dist/seo/index.d.mts +3 -3
  645. package/dist/seo/index.d.mts.map +1 -1
  646. package/dist/seo/index.mjs +20 -21
  647. package/dist/seo/index.mjs.map +1 -1
  648. package/dist/{seo-Cm-dtvgk.mjs → seo-Bw68KxRc.mjs} +3 -3
  649. package/dist/{seo-Cm-dtvgk.mjs.map → seo-Bw68KxRc.mjs.map} +1 -1
  650. package/dist/{seo-BSiTIXzd.mjs → seo-C4AmbsMU.mjs} +3 -2
  651. package/dist/seo-C4AmbsMU.mjs.map +1 -0
  652. package/dist/{service-DYsDHEKe.mjs → service-J_-Vgo7R.mjs} +3 -3
  653. package/dist/{service-DYsDHEKe.mjs.map → service-J_-Vgo7R.mjs.map} +1 -1
  654. package/dist/{session-user-CNAfvsdw.mjs → session-user-CbnMMwk6.mjs} +1 -1
  655. package/dist/{session-user-CNAfvsdw.mjs.map → session-user-CbnMMwk6.mjs.map} +1 -1
  656. package/dist/{settings-DjtkUo__.mjs → settings-AnEFYICn.mjs} +3 -3
  657. package/dist/{settings-DjtkUo__.mjs.map → settings-AnEFYICn.mjs.map} +1 -1
  658. package/dist/{settings-BgN-0DT-.mjs → settings-DcMjREe5.mjs} +21 -8
  659. package/dist/settings-DcMjREe5.mjs.map +1 -0
  660. package/dist/{setup-complete-CcpXaPU7.mjs → setup-complete-BClXXTvr.mjs} +2 -2
  661. package/dist/{setup-complete-CcpXaPU7.mjs.map → setup-complete-BClXXTvr.mjs.map} +1 -1
  662. package/dist/{setup-nonce-Reyw30jg.mjs → setup-nonce-BheRa4RG.mjs} +1 -1
  663. package/dist/{setup-nonce-Reyw30jg.mjs.map → setup-nonce-BheRa4RG.mjs.map} +1 -1
  664. package/dist/{single-flight-cache-BPuGPdcN.mjs → single-flight-cache-jaswDzmQ.mjs} +2 -2
  665. package/dist/{single-flight-cache-BPuGPdcN.mjs.map → single-flight-cache-jaswDzmQ.mjs.map} +1 -1
  666. package/dist/{site-url-Cs_V9n3V.mjs → site-url-Bqf-ea3N.mjs} +3 -3
  667. package/dist/{site-url-Cs_V9n3V.mjs.map → site-url-Bqf-ea3N.mjs.map} +1 -1
  668. package/dist/{snapshot-DSB8P7Lm.mjs → snapshot-C4CtXntb.mjs} +51 -35
  669. package/dist/snapshot-C4CtXntb.mjs.map +1 -0
  670. package/dist/{ssrf-DqebVE34.mjs → ssrf-gl4gFNhw.mjs} +151 -93
  671. package/dist/ssrf-gl4gFNhw.mjs.map +1 -0
  672. package/dist/{state-BJfU9Uzw.mjs → state-1F6IOhdQ.mjs} +1 -1
  673. package/dist/{state-BJfU9Uzw.mjs.map → state-1F6IOhdQ.mjs.map} +1 -1
  674. package/dist/{status-DDu8HIQl.mjs → status-Cenfk_r5.mjs} +1 -1
  675. package/dist/{status-DDu8HIQl.mjs.map → status-Cenfk_r5.mjs.map} +1 -1
  676. package/dist/storage/local.d.mts +2 -1
  677. package/dist/storage/local.d.mts.map +1 -1
  678. package/dist/storage/local.mjs +1 -1
  679. package/dist/storage/local.mjs.map +1 -1
  680. package/dist/storage/s3.d.mts +2 -1
  681. package/dist/storage/s3.d.mts.map +1 -1
  682. package/dist/storage/s3.mjs +3 -2
  683. package/dist/storage/s3.mjs.map +1 -1
  684. package/dist/{target-D0o26Azo.mjs → target-CRzeTs8G.mjs} +1 -1
  685. package/dist/{target-D0o26Azo.mjs.map → target-CRzeTs8G.mjs.map} +1 -1
  686. package/dist/{taxonomies-CPGxo-bn.mjs → taxonomies-BOdxuZpV.mjs} +23 -13
  687. package/dist/taxonomies-BOdxuZpV.mjs.map +1 -0
  688. package/dist/{taxonomies-kmyudNGP.mjs → taxonomies-NcFDq5Gg.mjs} +58 -23
  689. package/dist/taxonomies-NcFDq5Gg.mjs.map +1 -0
  690. package/dist/{taxonomy-8X09dLN5.mjs → taxonomy-DP1vny4K.mjs} +12 -4
  691. package/dist/{taxonomy-8X09dLN5.mjs.map → taxonomy-DP1vny4K.mjs.map} +1 -1
  692. package/dist/{tokens-gTS-IVUp.mjs → tokens-CDk8ox9p.mjs} +1 -1
  693. package/dist/{tokens-gTS-IVUp.mjs.map → tokens-CDk8ox9p.mjs.map} +1 -1
  694. package/dist/{transport-_6R1ub7t.d.mts → transport-BVn4tVb9.d.mts} +1 -1
  695. package/dist/{transport-_6R1ub7t.d.mts.map → transport-BVn4tVb9.d.mts.map} +1 -1
  696. package/dist/{transport-fX59xaJz.mjs → transport-DP0JI-8i.mjs} +1 -1
  697. package/dist/{transport-fX59xaJz.mjs.map → transport-DP0JI-8i.mjs.map} +1 -1
  698. package/dist/{trusted-proxy-fe6nEgR4.mjs → trusted-proxy-BTM6UxqD.mjs} +1 -1
  699. package/dist/{trusted-proxy-fe6nEgR4.mjs.map → trusted-proxy-BTM6UxqD.mjs.map} +1 -1
  700. package/dist/{types-D_DWe7k9.d.mts → types-2n848aVW.d.mts} +3 -2
  701. package/dist/types-2n848aVW.d.mts.map +1 -0
  702. package/dist/types-A2cN6a4a.mjs +3 -0
  703. package/dist/{types-75KIqzL9.mjs → types-BMXnRIrX.mjs} +4 -2
  704. package/dist/types-BMXnRIrX.mjs.map +1 -0
  705. package/dist/{types-Vg6f5i3s.d.mts → types-BouXpOsa.d.mts} +121 -4
  706. package/dist/types-BouXpOsa.d.mts.map +1 -0
  707. package/dist/{types-BXUmsINL.mjs → types-ByG2coLw.mjs} +1 -1
  708. package/dist/{types-BXUmsINL.mjs.map → types-ByG2coLw.mjs.map} +1 -1
  709. package/dist/types-CQPWhPxE.mjs.map +1 -1
  710. package/dist/{types-Blb-MRC3.d.mts → types-DEfNJ__A.d.mts} +1 -1
  711. package/dist/{types-Blb-MRC3.d.mts.map → types-DEfNJ__A.d.mts.map} +1 -1
  712. package/dist/{types-Br-ERaxh.d.mts → types-DKcKSbtB.d.mts} +23 -7
  713. package/dist/types-DKcKSbtB.d.mts.map +1 -0
  714. package/dist/{types-BzBd3PeX.d.mts → types-DRYs7uTL.d.mts} +1 -1
  715. package/dist/{types-BzBd3PeX.d.mts.map → types-DRYs7uTL.d.mts.map} +1 -1
  716. package/dist/{types-CLqvnd05.d.mts → types-DaEg7KX2.d.mts} +1 -1
  717. package/dist/{types-CLqvnd05.d.mts.map → types-DaEg7KX2.d.mts.map} +1 -1
  718. package/dist/{types-DJQxln7q.d.mts → types-LU8utpP_.d.mts} +14 -10
  719. package/dist/types-LU8utpP_.d.mts.map +1 -0
  720. package/dist/{types-D5VVLr7J.d.mts → types-VpYfPUxN.d.mts} +1 -1
  721. package/dist/{types-D5VVLr7J.d.mts.map → types-VpYfPUxN.d.mts.map} +1 -1
  722. package/dist/{types-DM3vioBY.mjs → types-c9GP7Dj5.mjs} +1 -1
  723. package/dist/{types-DM3vioBY.mjs.map → types-c9GP7Dj5.mjs.map} +1 -1
  724. package/dist/{types-DHxzBjbD.d.mts → types-tJWDK__M.d.mts} +14 -1
  725. package/dist/types-tJWDK__M.d.mts.map +1 -0
  726. package/dist/{upload-attempts-CNyGSepg.mjs → upload-attempts-C6S2y-lp.mjs} +1 -1
  727. package/dist/{upload-attempts-CNyGSepg.mjs.map → upload-attempts-C6S2y-lp.mjs.map} +1 -1
  728. package/dist/{url-pattern-K-KdXcSe.mjs → url-pattern-UYtxVTuj.mjs} +1 -1
  729. package/dist/{url-pattern-K-KdXcSe.mjs.map → url-pattern-UYtxVTuj.mjs.map} +1 -1
  730. package/dist/{user-CtYY0tp2.mjs → user-DIsIXogT.mjs} +2 -2
  731. package/dist/{user-CtYY0tp2.mjs.map → user-DIsIXogT.mjs.map} +1 -1
  732. package/dist/{utils-HztC73hq.mjs → utils-BicP5Qbg.mjs} +2 -2
  733. package/dist/{utils-HztC73hq.mjs.map → utils-BicP5Qbg.mjs.map} +1 -1
  734. package/dist/{validate-Dd-IUjnZ.mjs → validate-D8VPn4Hv.mjs} +8 -3
  735. package/dist/validate-D8VPn4Hv.mjs.map +1 -0
  736. package/dist/{validate-DlqdOZXB.d.mts → validate-Df6Dvwbw.d.mts} +12 -7
  737. package/dist/validate-Df6Dvwbw.d.mts.map +1 -0
  738. package/dist/{validation-D83n7Npi.mjs → validation-CzMJn9Ku.mjs} +13 -11
  739. package/dist/{validation-D83n7Npi.mjs.map → validation-CzMJn9Ku.mjs.map} +1 -1
  740. package/dist/version-CK67_SXX.mjs +7 -0
  741. package/dist/{version-ri-sCyAp.mjs.map → version-CK67_SXX.mjs.map} +1 -1
  742. package/dist/{widgets-CpmZd9Q-.mjs → widgets-RFVAxQl3.mjs} +18 -5
  743. package/dist/widgets-RFVAxQl3.mjs.map +1 -0
  744. package/dist/{wxr-taxonomies-BFd0y72_.d.mts → wxr-taxonomies-BX4yQL9s.d.mts} +1 -1
  745. package/dist/{wxr-taxonomies-BFd0y72_.d.mts.map → wxr-taxonomies-BX4yQL9s.d.mts.map} +1 -1
  746. package/dist/{wxr-taxonomies-Df4vxWcU.mjs → wxr-taxonomies-Csdp7yde.mjs} +4 -4
  747. package/dist/{wxr-taxonomies-Df4vxWcU.mjs.map → wxr-taxonomies-Csdp7yde.mjs.map} +1 -1
  748. package/dist/{zod-generator-DylzusHh.mjs → zod-generator-CNRGdnBY.mjs} +11 -7
  749. package/dist/zod-generator-CNRGdnBY.mjs.map +1 -0
  750. package/package.json +16 -11
  751. package/src/api/errors.ts +9 -0
  752. package/src/api/handlers/content.ts +115 -90
  753. package/src/api/handlers/entry-lock.ts +206 -0
  754. package/src/api/handlers/index.ts +1 -0
  755. package/src/api/handlers/manifest.ts +162 -12
  756. package/src/api/handlers/marketplace.ts +28 -20
  757. package/src/api/handlers/media.ts +30 -0
  758. package/src/api/handlers/menus.ts +9 -0
  759. package/src/api/handlers/registry.ts +406 -297
  760. package/src/api/handlers/revision.ts +2 -1
  761. package/src/api/handlers/seo.ts +10 -1
  762. package/src/api/handlers/snapshot.ts +84 -72
  763. package/src/api/handlers/taxonomies.ts +25 -9
  764. package/src/api/openapi/document.ts +196 -11
  765. package/src/api/parse.ts +1 -1
  766. package/src/api/schemas/auth.ts +4 -4
  767. package/src/api/schemas/bylines.ts +3 -3
  768. package/src/api/schemas/comments.ts +1 -1
  769. package/src/api/schemas/common.ts +3 -2
  770. package/src/api/schemas/content.ts +86 -22
  771. package/src/api/schemas/entry-lock.ts +48 -0
  772. package/src/api/schemas/index.ts +1 -0
  773. package/src/api/schemas/media.ts +52 -0
  774. package/src/api/schemas/redirects.ts +6 -1
  775. package/src/api/schemas/schema.ts +14 -1
  776. package/src/api/schemas/setup.ts +1 -1
  777. package/src/api/schemas/taxonomies.ts +2 -2
  778. package/src/api/schemas/users.ts +1 -1
  779. package/src/api/types.ts +25 -10
  780. package/src/astro/dev-typegen.ts +35 -0
  781. package/src/astro/image-endpoint.ts +2 -2
  782. package/src/astro/integration/dev-typegen.ts +91 -0
  783. package/src/astro/integration/index.ts +18 -50
  784. package/src/astro/integration/routes.ts +10 -0
  785. package/src/astro/integration/runtime.ts +13 -5
  786. package/src/astro/integration/vite-config.ts +51 -2
  787. package/src/astro/middleware.ts +21 -0
  788. package/src/astro/routes/api/admin/api-tokens/index.ts +4 -1
  789. package/src/astro/routes/api/admin/oauth-clients/[id].ts +1 -1
  790. package/src/astro/routes/api/admin/oauth-clients/index.ts +1 -1
  791. package/src/astro/routes/api/admin/plugins/registry/[id]/update.ts +4 -0
  792. package/src/astro/routes/api/admin/plugins/registry/artifact.ts +3 -7
  793. package/src/astro/routes/api/admin/plugins/registry/install.ts +4 -0
  794. package/src/astro/routes/api/admin/plugins/registry/verify.ts +60 -0
  795. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +18 -2
  796. package/src/astro/routes/api/content/[collection]/[id]/lock.ts +133 -0
  797. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +12 -1
  798. package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +20 -0
  799. package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +16 -2
  800. package/src/astro/routes/api/content/[collection]/[id].ts +27 -2
  801. package/src/astro/routes/api/content/[collection]/index.ts +3 -0
  802. package/src/astro/routes/api/manifest.ts +1 -1
  803. package/src/astro/routes/api/media/[id]/replace.ts +114 -0
  804. package/src/astro/routes/api/media/file/[...key].ts +4 -1
  805. package/src/astro/routes/api/media/upload-url.ts +8 -4
  806. package/src/astro/routes/api/media.ts +54 -8
  807. package/src/astro/routes/api/menus/[name]/items/[id].ts +7 -2
  808. package/src/astro/routes/api/menus/[name]/items.ts +4 -1
  809. package/src/astro/routes/api/menus/[name]/reorder.ts +4 -1
  810. package/src/astro/routes/api/menus/[name]/translations.ts +4 -1
  811. package/src/astro/routes/api/menus/[name].ts +7 -2
  812. package/src/astro/routes/api/menus/index.ts +4 -1
  813. package/src/astro/routes/api/settings/email.ts +1 -1
  814. package/src/astro/routes/api/settings.ts +4 -1
  815. package/src/astro/routes/api/taxonomies/[name]/reorder.ts +4 -1
  816. package/src/astro/routes/api/taxonomies/[name]/terms/[slug]/translations.ts +4 -1
  817. package/src/astro/routes/api/taxonomies/[name]/terms/[slug].ts +7 -2
  818. package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +4 -1
  819. package/src/astro/routes/api/taxonomies/[name].ts +7 -2
  820. package/src/astro/routes/api/taxonomies/index.ts +4 -1
  821. package/src/astro/routes/api/widget-areas/[name]/reorder.ts +3 -1
  822. package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +5 -2
  823. package/src/astro/routes/api/widget-areas/[name]/widgets.ts +3 -1
  824. package/src/astro/routes/api/widget-areas/[name].ts +3 -1
  825. package/src/astro/routes/api/widget-areas/index.ts +3 -1
  826. package/src/astro/routes/sitemap-[collection].xml.ts +4 -0
  827. package/src/astro/types.ts +36 -8
  828. package/src/auth/challenge-store.ts +3 -1
  829. package/src/aws-sdk.d.ts +1 -0
  830. package/src/cache/chrome-tags.ts +24 -0
  831. package/src/cli/commands/content.ts +31 -5
  832. package/src/cli/commands/export-seed.ts +2 -0
  833. package/src/client/index.ts +34 -7
  834. package/src/components/EmDashBodyEnd.astro +4 -1
  835. package/src/components/EmDashBodyStart.astro +4 -1
  836. package/src/components/EmDashHead.astro +35 -16
  837. package/src/components/EmDashImage.astro +2 -1
  838. package/src/components/EmDashMedia.astro +2 -1
  839. package/src/components/Gallery.astro +18 -4
  840. package/src/components/InlineEditor.astro +3 -1
  841. package/src/components/InlinePortableTextEditor.tsx +112 -12
  842. package/src/components/PortableText.astro +4 -0
  843. package/src/components/Table.astro +147 -62
  844. package/src/components/widgets/Archives.astro +2 -37
  845. package/src/config/errors.ts +13 -0
  846. package/src/content/converters/index.ts +2 -0
  847. package/src/content/converters/mark-safety.ts +1 -0
  848. package/src/content/converters/portable-text-identity.ts +139 -0
  849. package/src/content/converters/portable-text-to-prosemirror.ts +226 -69
  850. package/src/content/converters/prosemirror-to-portable-text.ts +128 -28
  851. package/src/content/converters/types.ts +11 -0
  852. package/src/database/dialect-helpers.ts +125 -0
  853. package/src/database/migrations/017_authorization_codes.ts +14 -4
  854. package/src/database/migrations/074_content_deleted_scheduled_index.ts +55 -0
  855. package/src/database/migrations/075_entry_edit_locks.ts +44 -0
  856. package/src/database/migrations/076_collection_nav_group.ts +22 -0
  857. package/src/database/migrations/077_plugin_storage_revisions.ts +89 -0
  858. package/src/database/migrations/runner.ts +9 -1
  859. package/src/database/repositories/byline.ts +32 -16
  860. package/src/database/repositories/content.ts +284 -48
  861. package/src/database/repositories/entry-locks.ts +257 -0
  862. package/src/database/repositories/media-usage.ts +66 -37
  863. package/src/database/repositories/media.ts +60 -1
  864. package/src/database/repositories/options.ts +69 -5
  865. package/src/database/repositories/plugin-storage.ts +233 -9
  866. package/src/database/repositories/redirect.ts +17 -6
  867. package/src/database/repositories/taxonomy.ts +8 -0
  868. package/src/database/repositories/types.ts +11 -7
  869. package/src/database/types.ts +15 -1
  870. package/src/db/adapters.ts +8 -1
  871. package/src/db/postgres.ts +23 -0
  872. package/src/emdash-runtime.ts +196 -199
  873. package/src/fields/boolean.ts +1 -1
  874. package/src/fields/datetime.ts +1 -1
  875. package/src/fields/file.ts +1 -1
  876. package/src/fields/integer.ts +1 -1
  877. package/src/fields/json.ts +1 -1
  878. package/src/fields/multiselect.ts +1 -1
  879. package/src/fields/number.ts +1 -1
  880. package/src/fields/portable-text.ts +1 -1
  881. package/src/fields/richtext.ts +1 -1
  882. package/src/fields/select.ts +1 -1
  883. package/src/fields/slug.ts +1 -1
  884. package/src/fields/text.ts +1 -1
  885. package/src/fields/textarea.ts +1 -1
  886. package/src/fields/types.ts +2 -2
  887. package/src/i18n/resolve.ts +44 -4
  888. package/src/index.ts +39 -3
  889. package/src/loader.ts +96 -12
  890. package/src/mcp/server.ts +251 -29
  891. package/src/media/image-endpoint.ts +5 -2
  892. package/src/media/normalize.ts +15 -4
  893. package/src/media/responsive.ts +23 -0
  894. package/src/media/usage/cleanup.ts +9 -8
  895. package/src/media/usage/content-refresh.ts +2 -1
  896. package/src/menus/index.ts +33 -21
  897. package/src/object-cache/index.ts +44 -2
  898. package/src/page/seo-contributions.ts +78 -1
  899. package/src/page/seo-panel.ts +47 -0
  900. package/src/plugin-types.ts +27 -1
  901. package/src/plugins/conditional-storage.ts +30 -0
  902. package/src/plugins/context.ts +49 -17
  903. package/src/plugins/hooks.ts +10 -1
  904. package/src/plugins/index.ts +15 -0
  905. package/src/plugins/manager.ts +6 -2
  906. package/src/plugins/manifest-schema.ts +1 -1
  907. package/src/plugins/routes.ts +3 -1
  908. package/src/plugins/sandbox/hook-result.ts +52 -0
  909. package/src/plugins/sandbox/index.ts +10 -0
  910. package/src/plugins/sandbox/types.ts +16 -2
  911. package/src/plugins/storage-query.ts +45 -0
  912. package/src/plugins/storage-update.ts +96 -0
  913. package/src/plugins/types.ts +120 -0
  914. package/src/query.ts +29 -3
  915. package/src/registry/artifact-checksum.ts +15 -0
  916. package/src/registry/artifact-verification.ts +85 -0
  917. package/src/registry/authoritative-records.ts +180 -0
  918. package/src/registry/config.ts +130 -27
  919. package/src/registry/record-labels.ts +28 -0
  920. package/src/registry/types.ts +5 -6
  921. package/src/schema/collection-slugs-cache.ts +157 -0
  922. package/src/schema/registry.ts +45 -3
  923. package/src/schema/types.ts +25 -6
  924. package/src/schema/zod-generator.ts +16 -13
  925. package/src/security/ssrf.ts +172 -143
  926. package/src/seed/apply.ts +4 -0
  927. package/src/seed/types.ts +7 -2
  928. package/src/seed/validate.ts +18 -1
  929. package/src/seo/hreflang.ts +1 -0
  930. package/src/seo/index.ts +5 -10
  931. package/src/seo/media-url.ts +26 -0
  932. package/src/settings/index.ts +16 -0
  933. package/src/storage/local.ts +1 -0
  934. package/src/storage/s3.ts +2 -0
  935. package/src/storage/types.ts +2 -0
  936. package/src/taxonomies/index.ts +40 -20
  937. package/src/taxonomies/term-counts.ts +22 -5
  938. package/src/widgets/archives.ts +67 -0
  939. package/src/widgets/index.ts +16 -0
  940. package/dist/api-B0w3uBiG.mjs +0 -2269
  941. package/dist/api-B0w3uBiG.mjs.map +0 -1
  942. package/dist/apply-B_VMpJ2P.mjs.map +0 -1
  943. package/dist/byline-Cpnwrje1.mjs.map +0 -1
  944. package/dist/challenge-store-D5pSY2S1.mjs.map +0 -1
  945. package/dist/content-CP-SeXNa.mjs.map +0 -1
  946. package/dist/content-refresh-DLOfIhYc.mjs.map +0 -1
  947. package/dist/context-BR5hRWiK.mjs.map +0 -1
  948. package/dist/dialect-helpers-BSbfaO3F.mjs.map +0 -1
  949. package/dist/errors-n2j49uNf.mjs.map +0 -1
  950. package/dist/index-DWbJrsAg.d.mts.map +0 -1
  951. package/dist/loader-ZsjE4paL.mjs.map +0 -1
  952. package/dist/manifest-schema-CUYPfCEH.mjs.map +0 -1
  953. package/dist/media-BjwNuLEu.mjs.map +0 -1
  954. package/dist/media-D6SeAfBl.mjs.map +0 -1
  955. package/dist/media-url-DH7giMx_.mjs.map +0 -1
  956. package/dist/menus-CNg0QlDt.mjs.map +0 -1
  957. package/dist/normalize-CSxdKBVa.mjs.map +0 -1
  958. package/dist/object-cache-71tPfV4A.mjs.map +0 -1
  959. package/dist/options-BHPeIbBd.mjs.map +0 -1
  960. package/dist/options-BhZIeFY1.d.mts.map +0 -1
  961. package/dist/query-D18vTdha.mjs.map +0 -1
  962. package/dist/redirect-CZkbozu9.mjs.map +0 -1
  963. package/dist/redirects-CRIM55KH.mjs.map +0 -1
  964. package/dist/registry-BiO5WwPq.mjs +0 -2716
  965. package/dist/registry-BiO5WwPq.mjs.map +0 -1
  966. package/dist/registry-Cx-jEJOS.mjs.map +0 -1
  967. package/dist/relations-BTPM2saV.mjs.map +0 -1
  968. package/dist/relations-C7B46bcU.d.mts.map +0 -1
  969. package/dist/resolve-DxUpTMmE.mjs.map +0 -1
  970. package/dist/runner-77GOZCnH.mjs.map +0 -1
  971. package/dist/runner-zgqA_CqP.d.mts.map +0 -1
  972. package/dist/seo-BSiTIXzd.mjs.map +0 -1
  973. package/dist/settings-BgN-0DT-.mjs.map +0 -1
  974. package/dist/snapshot-DSB8P7Lm.mjs.map +0 -1
  975. package/dist/ssrf-DqebVE34.mjs.map +0 -1
  976. package/dist/taxonomies-CPGxo-bn.mjs.map +0 -1
  977. package/dist/taxonomies-kmyudNGP.mjs.map +0 -1
  978. package/dist/types-75KIqzL9.mjs.map +0 -1
  979. package/dist/types-Br-ERaxh.d.mts.map +0 -1
  980. package/dist/types-D6OcIp2P.mjs +0 -3
  981. package/dist/types-DHxzBjbD.d.mts.map +0 -1
  982. package/dist/types-DJQxln7q.d.mts.map +0 -1
  983. package/dist/types-D_DWe7k9.d.mts.map +0 -1
  984. package/dist/types-Vg6f5i3s.d.mts.map +0 -1
  985. package/dist/validate-Dd-IUjnZ.mjs.map +0 -1
  986. package/dist/validate-DlqdOZXB.d.mts.map +0 -1
  987. package/dist/version-ri-sCyAp.mjs +0 -7
  988. package/dist/widgets-CpmZd9Q-.mjs.map +0 -1
  989. package/dist/zod-generator-DylzusHh.mjs.map +0 -1
  990. /package/dist/{api-tokens-B5NHLNUN.mjs → api-tokens-B_lfpmH3.mjs} +0 -0
  991. /package/dist/{ssrf-BPKzkm6O.mjs → ssrf-TQhaljuI.mjs} +0 -0
@@ -1,12 +1,12 @@
1
- import { c as __exportAll } from "./runner-77GOZCnH.mjs";
1
+ import { c as __exportAll } from "./runner-nEzvnogG.mjs";
2
2
  import { t as validateIdentifier } from "./validate-BpwoDOgt.mjs";
3
- import { u as listTablesLike } from "./dialect-helpers-BSbfaO3F.mjs";
4
- import { c as invalidateCollectionCache, s as invalidateBylineObjectCache } from "./object-cache-71tPfV4A.mjs";
5
- import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-bNiX6_DR.mjs";
3
+ import { d as listTablesLike } from "./dialect-helpers-BcQvkHgn.mjs";
4
+ import { c as invalidateCollectionCache, s as invalidateBylineObjectCache } from "./object-cache-DVKnyOfy.mjs";
5
+ import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-VG_tyqnP.mjs";
6
6
  import { o as decodeCursor, r as EmDashValidationError, s as encodeCursor } from "./types-CQPWhPxE.mjs";
7
7
  import { t as withTransaction } from "./transaction-0KOpOyMu.mjs";
8
- import { i as setRequestCacheEntry, n as peekRequestCache, t as clearRequestCacheEntry } from "./request-cache-DH9zdCOD.mjs";
9
- import { n as getBylineFieldDefs } from "./field-defs-cache-Bh4q6oar.mjs";
8
+ import { i as setRequestCacheEntry, n as peekRequestCache, t as clearRequestCacheEntry } from "./request-cache-DAZZmesc.mjs";
9
+ import { n as getBylineFieldDefs } from "./field-defs-cache-Cf5FHK0M.mjs";
10
10
  import { sql } from "kysely";
11
11
  import { ulid } from "ulidx";
12
12
 
@@ -318,8 +318,21 @@ var BylineRepository = class {
318
318
  }
319
319
  return result;
320
320
  }
321
+ /**
322
+ * Every byline column plus the avatar's media columns, folded in by the
323
+ * same `LEFT JOIN media` the credit-hydration queries use. Only the
324
+ * single-row finders select this; `findMany` stays a single-table scan.
325
+ */
326
+ selectBylineWithAvatar() {
327
+ return this.db.selectFrom("_emdash_bylines as b").leftJoin("media as m", "m.id", "b.avatar_media_id").selectAll("b").select([
328
+ "m.storage_key as avatar_storage_key",
329
+ "m.alt as avatar_alt",
330
+ "m.blurhash as avatar_blurhash",
331
+ "m.dominant_color as avatar_dominant_color"
332
+ ]);
333
+ }
321
334
  async findById(id) {
322
- const row = await this.db.selectFrom("_emdash_bylines").selectAll().where("id", "=", id).executeTakeFirst();
335
+ const row = await this.selectBylineWithAvatar().where("b.id", "=", id).executeTakeFirst();
323
336
  return this.withCustomFieldsOne(row);
324
337
  }
325
338
  /**
@@ -328,9 +341,9 @@ var BylineRepository = class {
328
341
  * calls). Mirrors `TaxonomyRepository.findBySlug`.
329
342
  */
330
343
  async findBySlug(slug, options) {
331
- let query = this.db.selectFrom("_emdash_bylines").selectAll().where("slug", "=", slug);
332
- if (options?.locale !== void 0) query = query.where("locale", "=", options.locale);
333
- const row = await query.orderBy("locale", "asc").executeTakeFirst();
344
+ let query = this.selectBylineWithAvatar().where("b.slug", "=", slug);
345
+ if (options?.locale !== void 0) query = query.where("b.locale", "=", options.locale);
346
+ const row = await query.orderBy("b.locale", "asc").executeTakeFirst();
334
347
  return this.withCustomFieldsOne(row);
335
348
  }
336
349
  /**
@@ -340,9 +353,9 @@ var BylineRepository = class {
340
353
  * the lowest-locale-code match.
341
354
  */
342
355
  async findByUserId(userId, options) {
343
- let query = this.db.selectFrom("_emdash_bylines").selectAll().where("user_id", "=", userId);
344
- if (options?.locale !== void 0) query = query.where("locale", "=", options.locale);
345
- const row = await query.orderBy("locale", "asc").executeTakeFirst();
356
+ let query = this.selectBylineWithAvatar().where("b.user_id", "=", userId);
357
+ if (options?.locale !== void 0) query = query.where("b.locale", "=", options.locale);
358
+ const row = await query.orderBy("b.locale", "asc").executeTakeFirst();
346
359
  return this.withCustomFieldsOne(row);
347
360
  }
348
361
  async findMany(options) {
@@ -886,4 +899,4 @@ var BylineRepository = class {
886
899
 
887
900
  //#endregion
888
901
  export { byline_exports as n, BylineRepository as t };
889
- //# sourceMappingURL=byline-Cpnwrje1.mjs.map
902
+ //# sourceMappingURL=byline-Vdi85CsZ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"byline-Vdi85CsZ.mjs","names":[],"sources":["../src/database/repositories/byline.ts"],"sourcesContent":["import { sql, type Kysely, type Selectable } from \"kysely\";\nimport { ulid } from \"ulidx\";\n\nimport { getBylineFieldDefs } from \"../../bylines/field-defs-cache.js\";\nimport {\n\tinvalidateBylineObjectCache,\n\tinvalidateCollectionCache,\n} from \"../../object-cache/index.js\";\nimport {\n\tclearRequestCacheEntry,\n\tpeekRequestCache,\n\tsetRequestCacheEntry,\n} from \"../../request-cache.js\";\nimport type { BylineFieldDefinition, CustomFieldValue } from \"../../schema/types.js\";\nimport { chunks, SQL_BATCH_SIZE } from \"../../utils/chunks.js\";\nimport { listTablesLike } from \"../dialect-helpers.js\";\nimport { withTransaction } from \"../transaction.js\";\nimport type { BylineTable, Database } from \"../types.js\";\nimport { validateIdentifier } from \"../validate.js\";\nimport {\n\tdecodeCursor,\n\tEmDashValidationError,\n\tencodeCursor,\n\ttype BylineSummary,\n\ttype ContentBylineCredit,\n\ttype FindManyResult,\n} from \"./types.js\";\n\ntype BylineRow = Selectable<BylineTable>;\n\n/**\n * A byline row optionally augmented with the avatar's media columns, folded in\n * by the `LEFT JOIN media` in the credit-hydration and single-row finder\n * queries. `findMany` selects without the join, so the keys are optional and\n * `rowToByline` defaults them to null.\n */\ntype BylineRowWithAvatar = BylineRow & {\n\tavatar_storage_key?: string | null;\n\tavatar_alt?: string | null;\n\tavatar_blurhash?: string | null;\n\tavatar_dominant_color?: string | null;\n};\n\nexport interface CreateBylineInput {\n\tslug: string;\n\tdisplayName: string;\n\tbio?: string | null;\n\tavatarMediaId?: string | null;\n\twebsiteUrl?: string | null;\n\tuserId?: string | null;\n\tisGuest?: boolean;\n\t/**\n\t * Locale this byline row belongs to. When omitted, the DB DEFAULT (the\n\t * configured `defaultLocale` after migration 040) is used. Keeps behaviour\n\t * consistent with `TaxonomyRepository.create`.\n\t */\n\tlocale?: string;\n\t/**\n\t * When set, the new row joins the source byline's translation_group rather\n\t * than minting a fresh one. The source must exist; otherwise the create\n\t * throws. Mirrors `TaxonomyRepository.create`.\n\t */\n\ttranslationOf?: string;\n\t/**\n\t * Byline custom-field values to seed on the new row (Phase 6 of\n\t * Discussion #1174). Same semantics as `UpdateBylineInput.customFields`:\n\t * keys must match registered slugs in `_emdash_byline_fields`, values\n\t * are validated against the field's type, and writes route to\n\t * `_emdash_byline_field_values` (translatable) or\n\t * `_emdash_byline_field_group_values` (group-shared). Validation runs\n\t * before the row insert so a bad value can't leave a bare byline behind.\n\t */\n\tcustomFields?: Record<string, unknown>;\n}\n\nexport interface UpdateBylineInput {\n\tslug?: string;\n\tdisplayName?: string;\n\tbio?: string | null;\n\tavatarMediaId?: string | null;\n\twebsiteUrl?: string | null;\n\tuserId?: string | null;\n\tisGuest?: boolean;\n\t/**\n\t * Byline custom-field values to write (Phase 3 of Discussion #1174).\n\t *\n\t * Each key must match a registered slug in `_emdash_byline_fields`;\n\t * unknown keys throw `EmDashValidationError`. Per-field writes route\n\t * to `_emdash_byline_field_values` (when the field's `translatable`\n\t * flag is true) or `_emdash_byline_field_group_values` (when false).\n\t * A value of `null` clears the row.\n\t *\n\t * Values are validated against the field's type:\n\t * - `string` / `text` / `url` accept a `string`\n\t * - `boolean` accepts a `boolean`\n\t * - `select` accepts a `string` that appears in `validation.options`\n\t *\n\t * Writes are idempotent (`INSERT … ON CONFLICT DO UPDATE`), so\n\t * retrying the same update produces the same DB state.\n\t */\n\tcustomFields?: Record<string, unknown>;\n}\n\nexport interface ContentBylineInput {\n\tbylineId: string;\n\troleLabel?: string | null;\n}\n\nfunction rowToByline(row: BylineRowWithAvatar): BylineSummary {\n\treturn {\n\t\tid: row.id,\n\t\tslug: row.slug,\n\t\tdisplayName: row.display_name,\n\t\tbio: row.bio,\n\t\tavatarMediaId: row.avatar_media_id,\n\t\tavatarStorageKey: row.avatar_storage_key ?? null,\n\t\tavatarAlt: row.avatar_alt ?? null,\n\t\tavatarBlurhash: row.avatar_blurhash ?? null,\n\t\tavatarDominantColor: row.avatar_dominant_color ?? null,\n\t\twebsiteUrl: row.website_url,\n\t\tuserId: row.user_id,\n\t\tisGuest: row.is_guest === 1,\n\t\tcreatedAt: row.created_at,\n\t\tupdatedAt: row.updated_at,\n\t\tlocale: row.locale,\n\t\ttranslationGroup: row.translation_group,\n\t};\n}\n\n/**\n * Merge a single decoded value into a `BylineSummary.customFields` map.\n * Centralised so the merge semantics (null storage, JSON.parse failure\n * handling) live in one place across both translatable and group-shared\n * paths.\n *\n * A stored row with `value = NULL` (representing an explicit null) is\n * surfaced as `null` in `customFields`. A row with a malformed JSON\n * payload is dropped silently with a `console.warn` — a corrupted\n * payload shouldn't break the entire byline hydration; the field-defs\n * cache will let admins replace the value, and the warning makes the\n * issue debuggable. (Storage path uses `JSON.stringify`, so the only\n * way to get malformed JSON is direct DB tampering or a future\n * migration bug.)\n */\nfunction assignCustomFieldValue(\n\tsummary: BylineSummary,\n\tfield: BylineFieldDefinition,\n\tstored: string | null,\n): void {\n\tconst target = summary.customFields ?? {};\n\tif (stored === null) {\n\t\ttarget[field.slug] = null;\n\t} else {\n\t\ttry {\n\t\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- coerceFieldValue ran at write time, see field-defs-cache.ts\n\t\t\ttarget[field.slug] = JSON.parse(stored) as CustomFieldValue;\n\t\t} catch {\n\t\t\tconsole.warn(\n\t\t\t\t`[BylineRepository] dropping malformed JSON for byline=${summary.id} ` +\n\t\t\t\t\t`field=${field.slug}: ${stored.slice(0, 60)}`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t}\n\tsummary.customFields = target;\n}\n\n/**\n * Coerce a raw write-path value to `CustomFieldValue`, throwing\n * `EmDashValidationError` on type mismatch. `null` clears the field\n * (DELETE in the write path).\n *\n * TODO: `field.required` is not enforced. The admin UI exposes the\n * toggle but the backend accepts missing values; design pass needed\n * on the enforcement model.\n */\nfunction coerceFieldValue(field: BylineFieldDefinition, raw: unknown): CustomFieldValue {\n\tif (raw === null) return null;\n\n\tswitch (field.type) {\n\t\tcase \"string\":\n\t\tcase \"text\": {\n\t\t\tif (typeof raw !== \"string\") {\n\t\t\t\tthrow new EmDashValidationError(\n\t\t\t\t\t`Byline field \"${field.slug}\" expects a string value (received ${typeof raw})`,\n\t\t\t\t\t{ slug: field.slug, type: field.type, received: typeof raw },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn raw;\n\t\t}\n\t\tcase \"url\": {\n\t\t\tif (typeof raw !== \"string\") {\n\t\t\t\tthrow new EmDashValidationError(\n\t\t\t\t\t`Byline field \"${field.slug}\" expects a string value (received ${typeof raw})`,\n\t\t\t\t\t{ slug: field.slug, type: field.type, received: typeof raw },\n\t\t\t\t);\n\t\t\t}\n\t\t\t// Empty string round-trips as a clear from the admin UI; any\n\t\t\t// non-empty value must be a valid http(s) URL. The scheme\n\t\t\t// allowlist mirrors `httpUrl` in `api/schemas/common.ts` —\n\t\t\t// `new URL` alone would accept `javascript:`/`data:` etc.\n\t\t\tif (raw === \"\") return raw;\n\t\t\tlet parsed: URL;\n\t\t\ttry {\n\t\t\t\tparsed = new URL(raw);\n\t\t\t} catch {\n\t\t\t\tthrow new EmDashValidationError(\n\t\t\t\t\t`Byline field \"${field.slug}\" expects a valid URL (received \"${raw}\")`,\n\t\t\t\t\t{ slug: field.slug, type: field.type, received: raw },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n\t\t\t\tthrow new EmDashValidationError(\n\t\t\t\t\t`Byline field \"${field.slug}\" must use http or https scheme (received \"${parsed.protocol}\")`,\n\t\t\t\t\t{ slug: field.slug, type: field.type, received: raw, protocol: parsed.protocol },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn raw;\n\t\t}\n\t\tcase \"boolean\": {\n\t\t\tif (typeof raw !== \"boolean\") {\n\t\t\t\tthrow new EmDashValidationError(\n\t\t\t\t\t`Byline field \"${field.slug}\" expects a boolean value (received ${typeof raw})`,\n\t\t\t\t\t{ slug: field.slug, type: field.type, received: typeof raw },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn raw;\n\t\t}\n\t\tcase \"select\": {\n\t\t\tif (typeof raw !== \"string\") {\n\t\t\t\tthrow new EmDashValidationError(\n\t\t\t\t\t`Byline field \"${field.slug}\" expects a string value (received ${typeof raw})`,\n\t\t\t\t\t{ slug: field.slug, type: field.type, received: typeof raw },\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst options = field.validation?.options ?? [];\n\t\t\tif (!options.includes(raw)) {\n\t\t\t\tthrow new EmDashValidationError(\n\t\t\t\t\t`Byline field \"${field.slug}\" value \"${raw}\" is not one of the registered choices`,\n\t\t\t\t\t{ slug: field.slug, value: raw, options },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn raw;\n\t\t}\n\t}\n}\n\n/**\n * Byline repository for content credits.\n *\n * Bylines are per-locale (migration 040). Translations of the same byline\n * share a `translation_group` ULID. `_emdash_content_bylines.byline_id` and\n * `ec_*.primary_byline_id` store the translation_group (not a row id) so a\n * single credit spans every locale variant of a byline.\n *\n * The repository does not resolve locale fallbacks on its own — callers\n * supply the locale they want. Hydration is strict per locale: a credit at\n * locale X renders iff a byline row exists at locale X within the credited\n * translation group. This mirrors `TaxonomyRepository.getTermsForEntry` and\n * the convention established by PR #916.\n *\n * Runtime helpers in `packages/core/src/bylines/index.ts` may layer fallback\n * resolution on top for the \"look up one byline by slug\" path, but the\n * relation-hydration methods on this class are always strict.\n */\nexport class BylineRepository {\n\tconstructor(private db: Kysely<Database>) {}\n\n\t// ============================================\n\t// Custom-field hydration (Phase 3 of #1174)\n\t// ============================================\n\n\t/**\n\t * Merge `customFields` onto each `BylineSummary` produced from the\n\t * given rows. Two batched queries total — one against\n\t * `_emdash_byline_field_values` (keyed by `byline_id`), one against\n\t * `_emdash_byline_field_group_values` (keyed by `translation_group`)\n\t * — both chunked at `SQL_BATCH_SIZE` for D1's bound-parameter cap.\n\t *\n\t * When zero fields are registered, every row gets `customFields = {}`\n\t * with no value-table reads (the field-defs cache returns `[]`).\n\t * Group-shared values are looked up via the row's `translation_group`,\n\t * so every locale sibling of the same byline identity sees the same\n\t * non-translatable value without re-reading per row.\n\t *\n\t * **Duplicate-row handling.** Callers (notably `getContentBylinesMany`\n\t * for list views with repeated authors) can pass the same byline row\n\t * multiple times. We assign values by *iterating both `rows` and\n\t * `summaries` in lockstep by index*, not by deduping into a Map keyed\n\t * on byline id. A Map approach silently drops earlier duplicates' merge\n\t * step (last writer wins, earlier instances keep their initial `{}`).\n\t * Iterating by index gives every duplicate its own merged copy.\n\t *\n\t * Hydration is *strict per row* — values are merged onto whichever\n\t * `BylineRow` produced them. Fallback semantics (e.g. \"if no value\n\t * for this locale, show the default-locale value\") are not the\n\t * repository's concern; consumers layer them on top if wanted, the\n\t * same way `BylineRepository` doesn't resolve locale fallback for\n\t * the base byline lookup.\n\t */\n\tprivate async withCustomFields(rows: BylineRowWithAvatar[]): Promise<BylineSummary[]> {\n\t\tconst summaries = rows.map(rowToByline);\n\t\t// Always populate `customFields = {}` (PR plan AC #6) — even when\n\t\t// no fields are registered, every BylineSummary carries the empty\n\t\t// object. A fresh object per summary so duplicate rows don't share\n\t\t// state.\n\t\tfor (const summary of summaries) {\n\t\t\tsummary.customFields = {};\n\t\t}\n\t\tawait this.applyCustomFieldsTo(summaries);\n\t\treturn summaries;\n\t}\n\n\tprivate async withCustomFieldsOne(\n\t\trow: BylineRowWithAvatar | undefined,\n\t): Promise<BylineSummary | null> {\n\t\tif (!row) return null;\n\t\tconst [result] = await this.withCustomFields([row]);\n\t\treturn result ?? null;\n\t}\n\n\t/**\n\t * Hydrate `customFields` on each `BylineSummary`, mutating in place.\n\t *\n\t * The public entry point for callers that fetch byline rows in\n\t * multiple passes (e.g. `getBylinesForEntries`, which buckets by\n\t * locale and calls `getContentBylinesMany` per bucket) and want a\n\t * single batched hydration over the union of bylines, not one per\n\t * pass. Use with the `skipHydration` option on the read methods to\n\t * defer customFields work to a single call here.\n\t *\n\t * Two batched queries total (translatable + group-shared) regardless\n\t * of how many bylines, locales, or translation_groups are in the\n\t * input — meets the Phase 3 query-count envelope for mixed-locale\n\t * list views even when sibling locales reference disjoint\n\t * translation_groups.\n\t *\n\t * Replaces any existing `customFields` on each summary with a freshly\n\t * fetched map. Callers that want to merge rather than replace should\n\t * not use this entry point.\n\t */\n\tasync hydrateBylineCustomFields(summaries: BylineSummary[]): Promise<void> {\n\t\tfor (const summary of summaries) {\n\t\t\tsummary.customFields = {};\n\t\t}\n\t\tawait this.applyCustomFieldsTo(summaries);\n\t}\n\n\t/**\n\t * Shared merge engine for `withCustomFields` and\n\t * `hydrateBylineCustomFields`. Reads field defs (cached), batches the\n\t * translatable + group-shared fetches, and walks `summaries` directly\n\t * to apply values.\n\t *\n\t * Iterates `summaries` (not a `summaryById` map) so duplicate\n\t * `BylineSummary` objects sharing the same `id` — e.g. the same\n\t * author credited to multiple entries — each get their own merged\n\t * values. The previous Map-based dedup silently dropped earlier\n\t * duplicates' merge step.\n\t */\n\tprivate async applyCustomFieldsTo(summaries: BylineSummary[]): Promise<void> {\n\t\tif (summaries.length === 0) return;\n\n\t\tconst defs = await getBylineFieldDefs(this.db);\n\t\tif (defs.length === 0) return;\n\n\t\tconst fieldById = new Map(defs.map((d) => [d.id, d]));\n\n\t\t// Translatable values, batched by byline_id (unique per locale, so\n\t\t// IDs across different locale buckets don't collide — one batched\n\t\t// query covers everything).\n\t\tconst translatableByByline = new Map<string, Map<string, string | null>>();\n\t\tconst bylineIds = [...new Set(summaries.map((s) => s.id))];\n\t\tfor (const chunk of chunks(bylineIds, SQL_BATCH_SIZE)) {\n\t\t\tconst trRows = await this.db\n\t\t\t\t.selectFrom(\"_emdash_byline_field_values\")\n\t\t\t\t.select([\"byline_id\", \"field_id\", \"value\"])\n\t\t\t\t.where(\"byline_id\", \"in\", chunk)\n\t\t\t\t.execute();\n\t\t\tfor (const trRow of trRows) {\n\t\t\t\tlet fieldMap = translatableByByline.get(trRow.byline_id);\n\t\t\t\tif (!fieldMap) {\n\t\t\t\t\tfieldMap = new Map();\n\t\t\t\t\ttranslatableByByline.set(trRow.byline_id, fieldMap);\n\t\t\t\t}\n\t\t\t\tfieldMap.set(trRow.field_id, trRow.value);\n\t\t\t}\n\t\t}\n\n\t\t// Group-shared values, batched over the union of translation_groups,\n\t\t// with per-group request-cache priming so subsequent calls within\n\t\t// the same request share the lookup. Together with the\n\t\t// `hydrateBylineCustomFields` + `skipHydration` flow in\n\t\t// `getBylinesForEntries`, this keeps mixed-locale list views to\n\t\t// **one** group-shared query per request, even for disjoint\n\t\t// translation_groups across locale buckets.\n\t\tconst groups = [\n\t\t\t...new Set(\n\t\t\t\tsummaries\n\t\t\t\t\t.map((s) => s.translationGroup)\n\t\t\t\t\t.filter((g): g is string => typeof g === \"string\" && g.length > 0),\n\t\t\t),\n\t\t];\n\t\tconst groupByGroup = await this.loadGroupValuesByIds(groups);\n\n\t\t// Each loop gates on `field.translatable` so a row in the wrong\n\t\t// owner table (e.g. left over from a translatable flip) can't\n\t\t// leak into hydration.\n\t\tfor (const summary of summaries) {\n\t\t\tconst trValues = translatableByByline.get(summary.id);\n\t\t\tif (trValues) {\n\t\t\t\tfor (const [fieldId, value] of trValues) {\n\t\t\t\t\tconst field = fieldById.get(fieldId);\n\t\t\t\t\tif (!field || !field.translatable) continue;\n\t\t\t\t\tassignCustomFieldValue(summary, field, value);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (summary.translationGroup) {\n\t\t\t\tconst grpValues = groupByGroup.get(summary.translationGroup);\n\t\t\t\tif (grpValues) {\n\t\t\t\t\tfor (const [fieldId, value] of grpValues) {\n\t\t\t\t\t\tconst field = fieldById.get(fieldId);\n\t\t\t\t\t\tif (!field || field.translatable) continue;\n\t\t\t\t\t\tassignCustomFieldValue(summary, field, value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Resolve the group-shared custom-field values for a set of\n\t * translation_groups, sharing work across hydration calls within the\n\t * same request via per-group `requestCached` entries.\n\t *\n\t * The non-translatable storage table (`_emdash_byline_field_group_values`)\n\t * is keyed by `translation_group`, which is locale-agnostic. Combining\n\t * this method with `skipHydration` on `getContentBylinesMany` and a\n\t * single `hydrateBylineCustomFields` call (see\n\t * `getBylinesForEntries`) keeps mixed-locale list hydration to **one**\n\t * batched group-shared SQL per request — even with disjoint\n\t * translation_groups across locale buckets. Solo callers (`findById`,\n\t * `findMany`, etc.) still get the same per-call batching they had\n\t * before; the cache simply means a second call in the same request\n\t * for an overlapping group is free.\n\t *\n\t * Cache key: `byline-field-group-values:${groupId}` — one entry per\n\t * group. Writes use `setRequestCacheEntry` (idempotent, doesn't\n\t * overwrite); `BylineRepository.update` calls `clearRequestCacheEntry`\n\t * after a group-shared write to keep the cache fresh within the same\n\t * request.\n\t */\n\tprivate async loadGroupValuesByIds(\n\t\tgroups: string[],\n\t): Promise<Map<string, Map<string, string | null>>> {\n\t\tconst result = new Map<string, Map<string, string | null>>();\n\t\tif (groups.length === 0) return result;\n\n\t\t// First pass: pull any already-cached groups from the request scope.\n\t\tconst missing: string[] = [];\n\t\tfor (const g of groups) {\n\t\t\tconst cached = peekRequestCache<Map<string, string | null>>(`byline-field-group-values:${g}`);\n\t\t\tif (cached) {\n\t\t\t\tresult.set(g, await cached);\n\t\t\t} else {\n\t\t\t\tmissing.push(g);\n\t\t\t}\n\t\t}\n\n\t\tif (missing.length === 0) return result;\n\n\t\t// Second pass: one batched SQL for the union of all missing groups\n\t\t// (chunked for D1's bound-parameter cap). Initialise empty maps for\n\t\t// missing groups so the primed cache covers \"this group has no\n\t\t// values\" — preventing a re-fetch on subsequent calls.\n\t\tconst fetched = new Map<string, Map<string, string | null>>();\n\t\tfor (const g of missing) fetched.set(g, new Map());\n\t\tfor (const chunk of chunks(missing, SQL_BATCH_SIZE)) {\n\t\t\tconst grpRows = await this.db\n\t\t\t\t.selectFrom(\"_emdash_byline_field_group_values\")\n\t\t\t\t.select([\"translation_group\", \"field_id\", \"value\"])\n\t\t\t\t.where(\"translation_group\", \"in\", chunk)\n\t\t\t\t.execute();\n\t\t\tfor (const grpRow of grpRows) {\n\t\t\t\tconst fieldMap = fetched.get(grpRow.translation_group);\n\t\t\t\tif (!fieldMap) continue;\n\t\t\t\tfieldMap.set(grpRow.field_id, grpRow.value);\n\t\t\t}\n\t\t}\n\n\t\tfor (const g of missing) {\n\t\t\tconst m = fetched.get(g);\n\t\t\tif (!m) continue;\n\t\t\tsetRequestCacheEntry(`byline-field-group-values:${g}`, m);\n\t\t\tresult.set(g, m);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// ============================================\n\t// Reads\n\t// ============================================\n\n\t/**\n\t * Every byline column plus the avatar's media columns, folded in by the\n\t * same `LEFT JOIN media` the credit-hydration queries use. Only the\n\t * single-row finders select this; `findMany` stays a single-table scan.\n\t */\n\tprivate selectBylineWithAvatar() {\n\t\treturn this.db\n\t\t\t.selectFrom(\"_emdash_bylines as b\")\n\t\t\t.leftJoin(\"media as m\", \"m.id\", \"b.avatar_media_id\")\n\t\t\t.selectAll(\"b\")\n\t\t\t.select([\n\t\t\t\t\"m.storage_key as avatar_storage_key\",\n\t\t\t\t\"m.alt as avatar_alt\",\n\t\t\t\t\"m.blurhash as avatar_blurhash\",\n\t\t\t\t\"m.dominant_color as avatar_dominant_color\",\n\t\t\t]);\n\t}\n\n\tasync findById(id: string): Promise<BylineSummary | null> {\n\t\tconst row = await this.selectBylineWithAvatar().where(\"b.id\", \"=\", id).executeTakeFirst();\n\t\treturn this.withCustomFieldsOne(row);\n\t}\n\n\t/**\n\t * Find a byline by slug. When `locale` is provided, filter by it strictly.\n\t * When omitted, returns the lowest-locale-code match (deterministic across\n\t * calls). Mirrors `TaxonomyRepository.findBySlug`.\n\t */\n\tasync findBySlug(slug: string, options?: { locale?: string }): Promise<BylineSummary | null> {\n\t\tlet query = this.selectBylineWithAvatar().where(\"b.slug\", \"=\", slug);\n\t\tif (options?.locale !== undefined) query = query.where(\"b.locale\", \"=\", options.locale);\n\t\tconst row = await query.orderBy(\"b.locale\", \"asc\").executeTakeFirst();\n\t\treturn this.withCustomFieldsOne(row);\n\t}\n\n\t/**\n\t * Find the byline linked to a CMS user. Post-migration 040 the partial\n\t * unique on user_id is `(user_id, locale)`, so `locale` is required to\n\t * disambiguate when multiple locale variants exist. When omitted, returns\n\t * the lowest-locale-code match.\n\t */\n\tasync findByUserId(userId: string, options?: { locale?: string }): Promise<BylineSummary | null> {\n\t\tlet query = this.selectBylineWithAvatar().where(\"b.user_id\", \"=\", userId);\n\t\tif (options?.locale !== undefined) query = query.where(\"b.locale\", \"=\", options.locale);\n\t\tconst row = await query.orderBy(\"b.locale\", \"asc\").executeTakeFirst();\n\t\treturn this.withCustomFieldsOne(row);\n\t}\n\n\tasync findMany(options?: {\n\t\tsearch?: string;\n\t\tisGuest?: boolean;\n\t\tuserId?: string;\n\t\tlocale?: string;\n\t\tcursor?: string;\n\t\tlimit?: number;\n\t}): Promise<FindManyResult<BylineSummary>> {\n\t\tconst limit = Math.min(Math.max(options?.limit ?? 50, 1), 100);\n\n\t\tlet query = this.db\n\t\t\t.selectFrom(\"_emdash_bylines\")\n\t\t\t.selectAll()\n\t\t\t.orderBy(\"created_at\", \"desc\")\n\t\t\t.orderBy(\"id\", \"desc\")\n\t\t\t.limit(limit + 1);\n\n\t\tif (options?.search) {\n\t\t\tconst escaped = options.search\n\t\t\t\t.replaceAll(\"\\\\\", \"\\\\\\\\\")\n\t\t\t\t.replaceAll(\"%\", \"\\\\%\")\n\t\t\t\t.replaceAll(\"_\", \"\\\\_\");\n\t\t\tconst term = `%${escaped}%`;\n\t\t\tquery = query.where((eb) =>\n\t\t\t\teb.or([eb(\"display_name\", \"like\", term), eb(\"slug\", \"like\", term)]),\n\t\t\t);\n\t\t}\n\n\t\tif (options?.isGuest !== undefined) {\n\t\t\tquery = query.where(\"is_guest\", \"=\", options.isGuest ? 1 : 0);\n\t\t}\n\n\t\tif (options?.userId !== undefined) {\n\t\t\tquery = query.where(\"user_id\", \"=\", options.userId);\n\t\t}\n\n\t\tif (options?.locale !== undefined) {\n\t\t\tquery = query.where(\"locale\", \"=\", options.locale);\n\t\t}\n\n\t\tif (options?.cursor) {\n\t\t\tconst decoded = decodeCursor(options.cursor);\n\t\t\tquery = query.where((eb) =>\n\t\t\t\teb.or([\n\t\t\t\t\teb(\"created_at\", \"<\", decoded.orderValue),\n\t\t\t\t\teb.and([eb(\"created_at\", \"=\", decoded.orderValue), eb(\"id\", \"<\", decoded.id)]),\n\t\t\t\t]),\n\t\t\t);\n\t\t}\n\n\t\tconst rows = await query.execute();\n\t\tconst pageRows = rows.slice(0, limit);\n\t\tconst items = await this.withCustomFields(pageRows);\n\t\tconst result: FindManyResult<BylineSummary> = { items };\n\n\t\tif (rows.length > limit) {\n\t\t\tconst last = items.at(-1);\n\t\t\tif (last) {\n\t\t\t\tresult.nextCursor = encodeCursor(last.createdAt, last.id);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * List every sibling row in `translation_group`. Used by the admin\n\t * `TranslationsPanel` to render one entry per configured locale.\n\t */\n\tasync listTranslations(id: string): Promise<BylineSummary[]> {\n\t\tconst anchor = await this.findById(id);\n\t\tif (!anchor) return [];\n\t\tconst group = anchor.translationGroup ?? anchor.id;\n\t\treturn this.findByTranslationGroup(group);\n\t}\n\n\t/**\n\t * Direct lookup by `translation_group`. Returns every locale variant of a\n\t * byline, ordered by locale code (deterministic).\n\t */\n\tasync findByTranslationGroup(translationGroup: string): Promise<BylineSummary[]> {\n\t\tconst rows = await this.db\n\t\t\t.selectFrom(\"_emdash_bylines\")\n\t\t\t.selectAll()\n\t\t\t.where(\"translation_group\", \"=\", translationGroup)\n\t\t\t.orderBy(\"locale\", \"asc\")\n\t\t\t.execute();\n\t\treturn this.withCustomFields(rows);\n\t}\n\n\t/**\n\t * Validate a `customFields` input map into a write list before any row\n\t * write — throws `EmDashValidationError` on unknown slugs, type\n\t * mismatches, or select-choice misses.\n\t */\n\tprivate async resolveCustomFieldWrites(\n\t\tcustomFields: Record<string, unknown> | undefined,\n\t): Promise<Array<{ field: BylineFieldDefinition; value: CustomFieldValue }>> {\n\t\tif (!customFields || Object.keys(customFields).length === 0) return [];\n\t\tconst defs = await getBylineFieldDefs(this.db);\n\t\tconst bySlug = new Map(defs.map((d) => [d.slug, d]));\n\t\tconst writes: Array<{ field: BylineFieldDefinition; value: CustomFieldValue }> = [];\n\t\tfor (const [slug, raw] of Object.entries(customFields)) {\n\t\t\tconst field = bySlug.get(slug);\n\t\t\tif (!field) {\n\t\t\t\tthrow new EmDashValidationError(`Unknown byline custom field \"${slug}\"`, {\n\t\t\t\t\tslug,\n\t\t\t\t\tregistered: defs.map((d) => d.slug),\n\t\t\t\t});\n\t\t\t}\n\t\t\twrites.push({ field, value: coerceFieldValue(field, raw) });\n\t\t}\n\t\treturn writes;\n\t}\n\n\t/**\n\t * Write a validated custom-field list against a byline row inside the\n\t * caller's transaction. Per-field writes route to\n\t * `_emdash_byline_field_values` (translatable) or\n\t * `_emdash_byline_field_group_values` (group-shared); `null` clears.\n\t * Returns `true` when any group-shared row was touched so the caller\n\t * can invalidate the per-request cache post-commit.\n\t */\n\tprivate async applyCustomFieldWritesInTrx(\n\t\ttrx: Kysely<Database>,\n\t\tbylineId: string,\n\t\ttranslationGroup: string,\n\t\twrites: Array<{ field: BylineFieldDefinition; value: CustomFieldValue }>,\n\t\tnow: string,\n\t): Promise<boolean> {\n\t\tif (writes.length === 0) return false;\n\t\tlet touchedGroupShared = false;\n\t\tfor (const { field, value } of writes) {\n\t\t\tif (!field.translatable) touchedGroupShared = true;\n\t\t\tif (field.translatable) {\n\t\t\t\tif (value === null) {\n\t\t\t\t\tawait trx\n\t\t\t\t\t\t.deleteFrom(\"_emdash_byline_field_values\")\n\t\t\t\t\t\t.where(\"byline_id\", \"=\", bylineId)\n\t\t\t\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t\t\t\t.execute();\n\t\t\t\t} else {\n\t\t\t\t\tconst encoded = JSON.stringify(value);\n\t\t\t\t\tawait trx\n\t\t\t\t\t\t.insertInto(\"_emdash_byline_field_values\")\n\t\t\t\t\t\t.values({\n\t\t\t\t\t\t\tbyline_id: bylineId,\n\t\t\t\t\t\t\tfield_id: field.id,\n\t\t\t\t\t\t\tvalue: encoded,\n\t\t\t\t\t\t\tcreated_at: now,\n\t\t\t\t\t\t\tupdated_at: now,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.onConflict((oc) =>\n\t\t\t\t\t\t\toc.columns([\"byline_id\", \"field_id\"]).doUpdateSet({\n\t\t\t\t\t\t\t\tvalue: encoded,\n\t\t\t\t\t\t\t\tupdated_at: now,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.execute();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (value === null) {\n\t\t\t\t\tawait trx\n\t\t\t\t\t\t.deleteFrom(\"_emdash_byline_field_group_values\")\n\t\t\t\t\t\t.where(\"translation_group\", \"=\", translationGroup)\n\t\t\t\t\t\t.where(\"field_id\", \"=\", field.id)\n\t\t\t\t\t\t.execute();\n\t\t\t\t} else {\n\t\t\t\t\tconst encoded = JSON.stringify(value);\n\t\t\t\t\tawait trx\n\t\t\t\t\t\t.insertInto(\"_emdash_byline_field_group_values\")\n\t\t\t\t\t\t.values({\n\t\t\t\t\t\t\ttranslation_group: translationGroup,\n\t\t\t\t\t\t\tfield_id: field.id,\n\t\t\t\t\t\t\tvalue: encoded,\n\t\t\t\t\t\t\tcreated_at: now,\n\t\t\t\t\t\t\tupdated_at: now,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.onConflict((oc) =>\n\t\t\t\t\t\t\toc.columns([\"translation_group\", \"field_id\"]).doUpdateSet({\n\t\t\t\t\t\t\t\tvalue: encoded,\n\t\t\t\t\t\t\t\tupdated_at: now,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.execute();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn touchedGroupShared;\n\t}\n\n\tasync create(input: CreateBylineInput): Promise<BylineSummary> {\n\t\tconst id = ulid();\n\t\tconst now = new Date().toISOString();\n\n\t\t// Validate customFields before opening the transaction so a bad\n\t\t// value surfaces as VALIDATION_ERROR without aborting an insert.\n\t\tconst customFieldWrites = await this.resolveCustomFieldWrites(input.customFields);\n\n\t\t// translationOf joins the source's group; otherwise mint a fresh\n\t\t// group = id (matches migration 040's backfill pattern).\n\t\tlet translationGroup: string = id;\n\t\tif (input.translationOf) {\n\t\t\tconst source = await this.findById(input.translationOf);\n\t\t\tif (!source) throw new Error(\"Source byline for translation not found\");\n\t\t\ttranslationGroup = source.translationGroup ?? source.id;\n\t\t}\n\n\t\t// Wrap insert + custom-field writes in one transaction so a\n\t\t// partial failure rolls both back on Node/PG. D1 still has its\n\t\t// own no-transactions limitation — recovery for that path lives\n\t\t// in `handleBylineCreate`.\n\t\tlet touchedGroupShared = false;\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tawait trx\n\t\t\t\t.insertInto(\"_emdash_bylines\")\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\tdisplay_name: input.displayName,\n\t\t\t\t\tbio: input.bio ?? null,\n\t\t\t\t\tavatar_media_id: input.avatarMediaId ?? null,\n\t\t\t\t\twebsite_url: input.websiteUrl ?? null,\n\t\t\t\t\tuser_id: input.userId ?? null,\n\t\t\t\t\tis_guest: input.isGuest ? 1 : 0,\n\t\t\t\t\tcreated_at: now,\n\t\t\t\t\tupdated_at: now,\n\t\t\t\t\t// Omit `locale` so the DB DEFAULT (configured defaultLocale)\n\t\t\t\t\t// applies — matches TaxonomyRepository.create.\n\t\t\t\t\t...(input.locale !== undefined ? { locale: input.locale } : {}),\n\t\t\t\t\ttranslation_group: translationGroup,\n\t\t\t\t})\n\t\t\t\t.execute();\n\n\t\t\ttouchedGroupShared = await this.applyCustomFieldWritesInTrx(\n\t\t\t\ttrx,\n\t\t\t\tid,\n\t\t\t\ttranslationGroup,\n\t\t\t\tcustomFieldWrites,\n\t\t\t\tnow,\n\t\t\t);\n\t\t});\n\n\t\tif (touchedGroupShared) {\n\t\t\tclearRequestCacheEntry(`byline-field-group-values:${translationGroup}`);\n\t\t}\n\t\tinvalidateBylineObjectCache();\n\n\t\tconst byline = await this.findById(id);\n\t\tif (!byline) {\n\t\t\tthrow new Error(\"Failed to create byline\");\n\t\t}\n\t\treturn byline;\n\t}\n\n\tasync update(id: string, input: UpdateBylineInput): Promise<BylineSummary | null> {\n\t\tconst existing = await this.findById(id);\n\t\tif (!existing) return null;\n\n\t\t// Validate customFields before opening the transaction so a bad\n\t\t// value surfaces as VALIDATION_ERROR without aborting an update.\n\t\tconst customFieldWrites = await this.resolveCustomFieldWrites(input.customFields);\n\n\t\tconst now = new Date().toISOString();\n\t\tconst updates: Record<string, unknown> = { updated_at: now };\n\n\t\tif (input.slug !== undefined) updates.slug = input.slug;\n\t\tif (input.displayName !== undefined) updates.display_name = input.displayName;\n\t\tif (input.bio !== undefined) updates.bio = input.bio;\n\t\tif (input.avatarMediaId !== undefined) updates.avatar_media_id = input.avatarMediaId;\n\t\tif (input.websiteUrl !== undefined) updates.website_url = input.websiteUrl;\n\t\tif (input.userId !== undefined) updates.user_id = input.userId;\n\t\tif (input.isGuest !== undefined) updates.is_guest = input.isGuest ? 1 : 0;\n\n\t\tconst group = existing.translationGroup ?? existing.id;\n\t\t// Wrap row update + custom-field writes in one transaction so a\n\t\t// partial failure rolls both back on Node/PG. The post-commit\n\t\t// invalidation below clears the per-request cache that the\n\t\t// top-of-method `findById` populated for this group.\n\t\tlet touchedGroupShared = false;\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\tawait trx.updateTable(\"_emdash_bylines\").set(updates).where(\"id\", \"=\", id).execute();\n\t\t\ttouchedGroupShared = await this.applyCustomFieldWritesInTrx(\n\t\t\t\ttrx,\n\t\t\t\tid,\n\t\t\t\tgroup,\n\t\t\t\tcustomFieldWrites,\n\t\t\t\tnow,\n\t\t\t);\n\t\t});\n\n\t\tif (touchedGroupShared) {\n\t\t\tclearRequestCacheEntry(`byline-field-group-values:${group}`);\n\t\t}\n\t\tinvalidateBylineObjectCache();\n\n\t\treturn await this.findById(id);\n\t}\n\n\t/**\n\t * Delete a byline row. When this row is the last sibling in its\n\t * translation group, also drops every junction row pointing at the group,\n\t * clears `primary_byline_id` references, and removes the byline's\n\t * non-translatable custom-field values. When other siblings remain in\n\t * the group, junctions, `primary_byline_id` pointers, and group-shared\n\t * custom-field values stay intact — the credit (and its shared metadata)\n\t * lives on at other locales.\n\t *\n\t * **Application-level cascade.** The byline domain has standardised on\n\t * app-level cascade rather than trusting FK ON DELETE CASCADE, partly\n\t * because migration 040 had to strip its own FK to support the\n\t * translation_group remap (#1021), and partly so cleanup doesn't\n\t * depend on `PRAGMA foreign_keys = ON` (set in production via\n\t * `connection.ts:60`, but easy to bypass in tests, scripts, and\n\t * one-off tools). Every byline-related deletion table is cleared\n\t * explicitly here:\n\t *\n\t * - `_emdash_byline_field_values` (per-byline translatable values) —\n\t * migration 041 declares FK ON DELETE CASCADE on `byline_id`; the\n\t * explicit DELETE removes the dependency on that pragma.\n\t * - `_emdash_content_bylines` — migration 040 dropped its FK.\n\t * - `ec_*.primary_byline_id` — never had an FK.\n\t * - `_emdash_byline_field_group_values` (translation-group-keyed) —\n\t * keyed by a text column with no FK to bylines, so app-level cleanup\n\t * is the only path.\n\t *\n\t * The FKs that remain (migration 041) serve as defense-in-depth.\n\t */\n\tasync delete(id: string): Promise<boolean> {\n\t\tconst existing = await this.findById(id);\n\t\tif (!existing) return false;\n\n\t\tconst group = existing.translationGroup ?? existing.id;\n\n\t\tawait withTransaction(this.db, async (trx) => {\n\t\t\t// Per-row translatable custom-field values. Done BEFORE the\n\t\t\t// byline row delete so the application-level cleanup is\n\t\t\t// observable in the transaction log even if FK enforcement is\n\t\t\t// off; migration 041's FK ON DELETE CASCADE would catch any\n\t\t\t// row we miss, but the explicit DELETE is what the rest of\n\t\t\t// the byline domain expects to see.\n\t\t\tawait trx.deleteFrom(\"_emdash_byline_field_values\").where(\"byline_id\", \"=\", id).execute();\n\n\t\t\tawait trx.deleteFrom(\"_emdash_bylines\").where(\"id\", \"=\", id).execute();\n\n\t\t\t// Count remaining siblings in the translation group. If none\n\t\t\t// remain, purge dependent rows; otherwise leave them intact so\n\t\t\t// the credit still resolves at other locales.\n\t\t\tconst remaining = await trx\n\t\t\t\t.selectFrom(\"_emdash_bylines\")\n\t\t\t\t.select(({ fn }) => [fn.count<number>(\"id\").as(\"count\")])\n\t\t\t\t.where(\"translation_group\", \"=\", group)\n\t\t\t\t.executeTakeFirst();\n\t\t\tconst remainingCount = Number(remaining?.count ?? 0);\n\t\t\tif (remainingCount > 0) return;\n\n\t\t\t// Last sibling gone: cascade in application code.\n\t\t\tawait trx.deleteFrom(\"_emdash_content_bylines\").where(\"byline_id\", \"=\", group).execute();\n\n\t\t\t// Group-shared custom-field values are keyed by translation_group\n\t\t\t// (no FK to bylines), so they don't cascade with the byline row.\n\t\t\t// Clean them up explicitly so deleting the last sibling of an\n\t\t\t// identity doesn't leave orphan group values pointing at a\n\t\t\t// vanished translation group. Per-row translatable values\n\t\t\t// (`_emdash_byline_field_values` keyed by byline_id) already\n\t\t\t// cascaded when each sibling row was deleted, so no extra\n\t\t\t// cleanup is needed for that table.\n\t\t\tawait trx\n\t\t\t\t.deleteFrom(\"_emdash_byline_field_group_values\")\n\t\t\t\t.where(\"translation_group\", \"=\", group)\n\t\t\t\t.execute();\n\n\t\t\tconst tableNames = await listTablesLike(trx, \"ec_%\");\n\t\t\tfor (const tableName of tableNames) {\n\t\t\t\tvalidateIdentifier(tableName, \"content table\");\n\t\t\t\tawait sql`\n\t\t\t\t\tUPDATE ${sql.ref(tableName)}\n\t\t\t\t\tSET primary_byline_id = NULL\n\t\t\t\t\tWHERE primary_byline_id = ${group}\n\t\t\t\t`.execute(trx);\n\t\t\t}\n\t\t});\n\n\t\tinvalidateBylineObjectCache();\n\t\treturn true;\n\t}\n\n\t/**\n\t * Strict per-locale credit hydration. Joins `_emdash_content_bylines` to\n\t * `_emdash_bylines` on `translation_group = byline_id`, then filters to\n\t * the requested locale. Credits whose translation group lacks a row at\n\t * the requested locale are omitted — callers wanting fallback behaviour\n\t * apply it themselves. Mirrors `TaxonomyRepository.getTermsForEntry`.\n\t */\n\tasync getContentBylines(\n\t\tcollectionSlug: string,\n\t\tcontentId: string,\n\t\toptions?: { locale?: string },\n\t): Promise<ContentBylineCredit[]> {\n\t\tlet query = this.db\n\t\t\t.selectFrom(\"_emdash_content_bylines as cb\")\n\t\t\t.innerJoin(\"_emdash_bylines as b\", \"b.translation_group\", \"cb.byline_id\")\n\t\t\t.leftJoin(\"media as m\", \"m.id\", \"b.avatar_media_id\")\n\t\t\t.select([\n\t\t\t\t\"cb.sort_order as sort_order\",\n\t\t\t\t\"cb.role_label as role_label\",\n\t\t\t\t\"b.id as id\",\n\t\t\t\t\"b.slug as slug\",\n\t\t\t\t\"b.display_name as display_name\",\n\t\t\t\t\"b.bio as bio\",\n\t\t\t\t\"b.avatar_media_id as avatar_media_id\",\n\t\t\t\t\"m.storage_key as avatar_storage_key\",\n\t\t\t\t\"m.alt as avatar_alt\",\n\t\t\t\t\"m.blurhash as avatar_blurhash\",\n\t\t\t\t\"m.dominant_color as avatar_dominant_color\",\n\t\t\t\t\"b.website_url as website_url\",\n\t\t\t\t\"b.user_id as user_id\",\n\t\t\t\t\"b.is_guest as is_guest\",\n\t\t\t\t\"b.created_at as created_at\",\n\t\t\t\t\"b.updated_at as updated_at\",\n\t\t\t\t\"b.locale as locale\",\n\t\t\t\t\"b.translation_group as translation_group\",\n\t\t\t])\n\t\t\t.where(\"cb.collection_slug\", \"=\", collectionSlug)\n\t\t\t.where(\"cb.content_id\", \"=\", contentId)\n\t\t\t.orderBy(\"cb.sort_order\", \"asc\");\n\t\tif (options?.locale !== undefined) query = query.where(\"b.locale\", \"=\", options.locale);\n\n\t\tconst rows = await query.execute();\n\t\t// Reconstruct byline rows to feed `withCustomFields`. The JOIN selects\n\t\t// the `BylineRow` columns under the `b.` alias plus the avatar media\n\t\t// columns from the `media` LEFT JOIN; carry both through so\n\t\t// `rowToByline` can populate `avatarStorageKey`/`avatarAlt` (otherwise\n\t\t// the join runs but its values are dropped here).\n\t\tconst bylineRows: BylineRowWithAvatar[] = rows.map((row) => ({\n\t\t\tid: row.id,\n\t\t\tslug: row.slug,\n\t\t\tdisplay_name: row.display_name,\n\t\t\tbio: row.bio,\n\t\t\tavatar_media_id: row.avatar_media_id,\n\t\t\tavatar_storage_key: row.avatar_storage_key,\n\t\t\tavatar_alt: row.avatar_alt,\n\t\t\tavatar_blurhash: row.avatar_blurhash,\n\t\t\tavatar_dominant_color: row.avatar_dominant_color,\n\t\t\twebsite_url: row.website_url,\n\t\t\tuser_id: row.user_id,\n\t\t\tis_guest: row.is_guest,\n\t\t\tcreated_at: row.created_at,\n\t\t\tupdated_at: row.updated_at,\n\t\t\tlocale: row.locale,\n\t\t\ttranslation_group: row.translation_group,\n\t\t}));\n\t\tconst hydrated = await this.withCustomFields(bylineRows);\n\t\treturn rows.map((row, i) => {\n\t\t\tconst byline = hydrated[i];\n\t\t\tif (!byline) {\n\t\t\t\t// Defensive: hydrated and rows are produced in lock-step;\n\t\t\t\t// this branch is unreachable unless `withCustomFields`\n\t\t\t\t// breaks its contract.\n\t\t\t\tthrow new Error(\"getContentBylines: hydration row count mismatch\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tbyline,\n\t\t\t\tsortOrder: row.sort_order,\n\t\t\t\troleLabel: row.role_label,\n\t\t\t};\n\t\t});\n\t}\n\n\t/**\n\t * Does this entry have any explicit byline credits — at any locale?\n\t *\n\t * Used to disambiguate \"no credits exist\" (fall back to author-linked\n\t * byline) from \"credits exist but don't resolve at the requested locale\"\n\t * (strict per-locale model: render no byline). Without this check the\n\t * locale-strict hydration would silently turn a missing translation into\n\t * an author-inferred byline, contradicting editorial intent.\n\t */\n\tasync hasContentBylines(collectionSlug: string, contentId: string): Promise<boolean> {\n\t\tconst row = await this.db\n\t\t\t.selectFrom(\"_emdash_content_bylines\")\n\t\t\t.select(\"id\")\n\t\t\t.where(\"collection_slug\", \"=\", collectionSlug)\n\t\t\t.where(\"content_id\", \"=\", contentId)\n\t\t\t.limit(1)\n\t\t\t.executeTakeFirst();\n\t\treturn row !== undefined;\n\t}\n\n\t/**\n\t * Batch variant of `hasContentBylines`. Returns the set of content IDs\n\t * that have at least one junction row (locale-agnostic).\n\t */\n\tasync hasContentBylinesMany(collectionSlug: string, contentIds: string[]): Promise<Set<string>> {\n\t\tconst result = new Set<string>();\n\t\tif (contentIds.length === 0) return result;\n\n\t\tconst uniqueContentIds = [...new Set(contentIds)];\n\t\tfor (const chunk of chunks(uniqueContentIds, SQL_BATCH_SIZE)) {\n\t\t\tconst rows = await this.db\n\t\t\t\t.selectFrom(\"_emdash_content_bylines\")\n\t\t\t\t.select(\"content_id\")\n\t\t\t\t.distinct()\n\t\t\t\t.where(\"collection_slug\", \"=\", collectionSlug)\n\t\t\t\t.where(\"content_id\", \"in\", chunk)\n\t\t\t\t.execute();\n\t\t\tfor (const row of rows) result.add(row.content_id);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Batch variant of `getContentBylines`. Same strict-per-locale semantics\n\t * applied to the requested locale (single value, not per-entry).\n\t *\n\t * When callers need per-entry-locale filtering (e.g. a list endpoint\n\t * returning entries at mixed locales), they should group the input ids by\n\t * the entry's locale and call this method once per group.\n\t *\n\t * When the caller will issue multiple `getContentBylinesMany` calls in\n\t * one request (e.g. per locale bucket) and wants a *single* batched\n\t * customFields hydration over the union of returned bylines, pass\n\t * `skipHydration: true` on each call and finish with\n\t * `hydrateBylineCustomFields(allBylines)`. The returned bylines carry\n\t * `customFields = {}` until that hydration call runs — matching the\n\t * \"always populated\" invariant from AC #6 — so callers that forget to\n\t * hydrate get an empty map rather than `undefined`.\n\t */\n\tasync getContentBylinesMany(\n\t\tcollectionSlug: string,\n\t\tcontentIds: string[],\n\t\toptions?: { locale?: string; skipHydration?: boolean },\n\t): Promise<Map<string, ContentBylineCredit[]>> {\n\t\tconst result = new Map<string, ContentBylineCredit[]>();\n\t\tif (contentIds.length === 0) return result;\n\n\t\tconst uniqueContentIds = [...new Set(contentIds)];\n\t\tfor (const chunk of chunks(uniqueContentIds, SQL_BATCH_SIZE)) {\n\t\t\tlet query = this.db\n\t\t\t\t.selectFrom(\"_emdash_content_bylines as cb\")\n\t\t\t\t.innerJoin(\"_emdash_bylines as b\", \"b.translation_group\", \"cb.byline_id\")\n\t\t\t\t.leftJoin(\"media as m\", \"m.id\", \"b.avatar_media_id\")\n\t\t\t\t.select([\n\t\t\t\t\t\"cb.content_id as content_id\",\n\t\t\t\t\t\"cb.sort_order as sort_order\",\n\t\t\t\t\t\"cb.role_label as role_label\",\n\t\t\t\t\t\"b.id as id\",\n\t\t\t\t\t\"b.slug as slug\",\n\t\t\t\t\t\"b.display_name as display_name\",\n\t\t\t\t\t\"b.bio as bio\",\n\t\t\t\t\t\"b.avatar_media_id as avatar_media_id\",\n\t\t\t\t\t\"m.storage_key as avatar_storage_key\",\n\t\t\t\t\t\"m.alt as avatar_alt\",\n\t\t\t\t\t\"m.blurhash as avatar_blurhash\",\n\t\t\t\t\t\"m.dominant_color as avatar_dominant_color\",\n\t\t\t\t\t\"b.website_url as website_url\",\n\t\t\t\t\t\"b.user_id as user_id\",\n\t\t\t\t\t\"b.is_guest as is_guest\",\n\t\t\t\t\t\"b.created_at as created_at\",\n\t\t\t\t\t\"b.updated_at as updated_at\",\n\t\t\t\t\t\"b.locale as locale\",\n\t\t\t\t\t\"b.translation_group as translation_group\",\n\t\t\t\t])\n\t\t\t\t.where(\"cb.collection_slug\", \"=\", collectionSlug)\n\t\t\t\t.where(\"cb.content_id\", \"in\", chunk)\n\t\t\t\t.orderBy(\"cb.sort_order\", \"asc\");\n\t\t\tif (options?.locale !== undefined) query = query.where(\"b.locale\", \"=\", options.locale);\n\n\t\t\tconst rows = await query.execute();\n\t\t\t// Carry the avatar media columns from the LEFT JOIN through the\n\t\t\t// reshape so `rowToByline` can populate avatarStorageKey/avatarAlt.\n\t\t\tconst bylineRows: BylineRowWithAvatar[] = rows.map((row) => ({\n\t\t\t\tid: row.id,\n\t\t\t\tslug: row.slug,\n\t\t\t\tdisplay_name: row.display_name,\n\t\t\t\tbio: row.bio,\n\t\t\t\tavatar_media_id: row.avatar_media_id,\n\t\t\t\tavatar_storage_key: row.avatar_storage_key,\n\t\t\t\tavatar_alt: row.avatar_alt,\n\t\t\t\tavatar_blurhash: row.avatar_blurhash,\n\t\t\t\tavatar_dominant_color: row.avatar_dominant_color,\n\t\t\t\twebsite_url: row.website_url,\n\t\t\t\tuser_id: row.user_id,\n\t\t\t\tis_guest: row.is_guest,\n\t\t\t\tcreated_at: row.created_at,\n\t\t\t\tupdated_at: row.updated_at,\n\t\t\t\tlocale: row.locale,\n\t\t\t\ttranslation_group: row.translation_group,\n\t\t\t}));\n\n\t\t\t// When `skipHydration` is set, return BylineSummary objects with\n\t\t\t// `customFields = {}`. The caller is responsible for batching\n\t\t\t// `hydrateBylineCustomFields` across multiple\n\t\t\t// `getContentBylinesMany` calls. Otherwise hydrate per-call —\n\t\t\t// the historical behaviour for solo callers.\n\t\t\tlet bylines: BylineSummary[];\n\t\t\tif (options?.skipHydration === true) {\n\t\t\t\tbylines = bylineRows.map(rowToByline);\n\t\t\t\tfor (const b of bylines) b.customFields = {};\n\t\t\t} else {\n\t\t\t\tbylines = await this.withCustomFields(bylineRows);\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < rows.length; i++) {\n\t\t\t\tconst row = rows[i];\n\t\t\t\tconst byline = bylines[i];\n\t\t\t\tif (!row || !byline) continue;\n\t\t\t\tconst contentId = row.content_id;\n\t\t\t\tconst credit: ContentBylineCredit = {\n\t\t\t\t\tbyline,\n\t\t\t\t\tsortOrder: row.sort_order,\n\t\t\t\t\troleLabel: row.role_label,\n\t\t\t\t};\n\t\t\t\tconst existing = result.get(contentId);\n\t\t\t\tif (existing) {\n\t\t\t\t\texisting.push(credit);\n\t\t\t\t} else {\n\t\t\t\t\tresult.set(contentId, [credit]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Batch-fetch byline profiles linked to user IDs in a single query.\n\t * Strict-locale variant of `findByUserId`.\n\t *\n\t * `skipHydration: true` returns bylines with `customFields = {}` so\n\t * callers issuing multiple `findByUserIds` calls in one request (e.g.\n\t * the per-locale-bucket author-fallback path in `getBylinesForEntries`)\n\t * can defer customFields hydration to a single batched\n\t * `hydrateBylineCustomFields` call across the union — keeping the\n\t * Phase 3 query-count envelope at \"+1 group-shared query per\n\t * hydration pass\" even when buckets fetch disjoint author bylines.\n\t */\n\tasync findByUserIds(\n\t\tuserIds: string[],\n\t\toptions?: { locale?: string; skipHydration?: boolean },\n\t): Promise<Map<string, BylineSummary>> {\n\t\tconst result = new Map<string, BylineSummary>();\n\t\tif (userIds.length === 0) return result;\n\n\t\tfor (const chunk of chunks(userIds, SQL_BATCH_SIZE)) {\n\t\t\t// LEFT JOIN media so author-inferred bylines (the fallback path in\n\t\t\t// `getBylinesForEntries`) carry the same render-ready avatar storage\n\t\t\t// key as explicitly-credited bylines do.\n\t\t\tlet query = this.db\n\t\t\t\t.selectFrom(\"_emdash_bylines as b\")\n\t\t\t\t.leftJoin(\"media as m\", \"m.id\", \"b.avatar_media_id\")\n\t\t\t\t.select([\n\t\t\t\t\t\"b.id as id\",\n\t\t\t\t\t\"b.slug as slug\",\n\t\t\t\t\t\"b.display_name as display_name\",\n\t\t\t\t\t\"b.bio as bio\",\n\t\t\t\t\t\"b.avatar_media_id as avatar_media_id\",\n\t\t\t\t\t\"m.storage_key as avatar_storage_key\",\n\t\t\t\t\t\"m.alt as avatar_alt\",\n\t\t\t\t\t\"m.blurhash as avatar_blurhash\",\n\t\t\t\t\t\"m.dominant_color as avatar_dominant_color\",\n\t\t\t\t\t\"b.website_url as website_url\",\n\t\t\t\t\t\"b.user_id as user_id\",\n\t\t\t\t\t\"b.is_guest as is_guest\",\n\t\t\t\t\t\"b.created_at as created_at\",\n\t\t\t\t\t\"b.updated_at as updated_at\",\n\t\t\t\t\t\"b.locale as locale\",\n\t\t\t\t\t\"b.translation_group as translation_group\",\n\t\t\t\t])\n\t\t\t\t.where(\"b.user_id\", \"in\", chunk);\n\t\t\tif (options?.locale !== undefined) query = query.where(\"b.locale\", \"=\", options.locale);\n\n\t\t\tconst rows = await query.execute();\n\t\t\tlet bylines: BylineSummary[];\n\t\t\tif (options?.skipHydration === true) {\n\t\t\t\tbylines = rows.map(rowToByline);\n\t\t\t\tfor (const b of bylines) b.customFields = {};\n\t\t\t} else {\n\t\t\t\tbylines = await this.withCustomFields(rows);\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < rows.length; i++) {\n\t\t\t\tconst row = rows[i];\n\t\t\t\tconst summary = bylines[i];\n\t\t\t\tif (!row || !summary || !row.user_id) continue;\n\t\t\t\tresult.set(row.user_id, summary);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Clone every junction row from `sourceContentId` to `targetContentId`,\n\t * preserving `sort_order` and `role_label`. Used by the content\n\t * translation flow: a newly created translation inherits the source's\n\t * byline credits at the storage level. Because the junction stores\n\t * `translation_group` (not a row id), the copy is locale-agnostic — the\n\t * credits resolve to whichever locale variants of each byline exist when\n\t * the translated entry is hydrated.\n\t *\n\t * No-op when the source has no credits. Skips when the target already\n\t * has credits (idempotent for re-runs).\n\t */\n\tasync copyContentBylines(\n\t\tcollection: string,\n\t\tsourceContentId: string,\n\t\ttargetContentId: string,\n\t): Promise<void> {\n\t\tvalidateIdentifier(collection, \"collection slug\");\n\t\tconst tableName = `ec_${collection}`;\n\t\tvalidateIdentifier(tableName, \"content table\");\n\n\t\t// Like `setContentBylines`, this method is expected to be called\n\t\t// within a transaction context (content handlers wrap in\n\t\t// withTransaction). All operations use `this.db` directly so an\n\t\t// outer transaction can serialise the copy alongside the create.\n\t\tconst existing = await this.db\n\t\t\t.selectFrom(\"_emdash_content_bylines\")\n\t\t\t.select(\"id\")\n\t\t\t.where(\"collection_slug\", \"=\", collection)\n\t\t\t.where(\"content_id\", \"=\", targetContentId)\n\t\t\t.executeTakeFirst();\n\t\tif (existing) return;\n\n\t\tconst sourceRows = await this.db\n\t\t\t.selectFrom(\"_emdash_content_bylines\")\n\t\t\t.select([\"byline_id\", \"sort_order\", \"role_label\"])\n\t\t\t.where(\"collection_slug\", \"=\", collection)\n\t\t\t.where(\"content_id\", \"=\", sourceContentId)\n\t\t\t.orderBy(\"sort_order\", \"asc\")\n\t\t\t.execute();\n\t\tif (sourceRows.length === 0) return;\n\n\t\tconst now = new Date().toISOString();\n\t\tawait this.db\n\t\t\t.insertInto(\"_emdash_content_bylines\")\n\t\t\t.values(\n\t\t\t\tsourceRows.map((row) => ({\n\t\t\t\t\tid: ulid(),\n\t\t\t\t\tcollection_slug: collection,\n\t\t\t\t\tcontent_id: targetContentId,\n\t\t\t\t\tbyline_id: row.byline_id,\n\t\t\t\t\tsort_order: row.sort_order,\n\t\t\t\t\trole_label: row.role_label,\n\t\t\t\t\tcreated_at: now,\n\t\t\t\t})),\n\t\t\t)\n\t\t\t.execute();\n\n\t\t// Mirror primary_byline_id from source so the cached pointer on the\n\t\t// target row matches the junction state we just wrote.\n\t\tconst firstByline = sourceRows[0]?.byline_id ?? null;\n\t\tawait sql`\n\t\t\tUPDATE ${sql.ref(tableName)}\n\t\t\tSET primary_byline_id = ${firstByline}\n\t\t\tWHERE id = ${targetContentId}\n\t\t`.execute(this.db);\n\n\t\t// Byline credits are folded into the target entry's cached payload.\n\t\tinvalidateCollectionCache(collection);\n\t}\n\n\t/**\n\t * Replace the set of byline credits on a content entry. Accepts row ids\n\t * at the wire (consistent with how the admin sends them), translates\n\t * each to its `translation_group` on write, and stores the group in\n\t * `_emdash_content_bylines.byline_id` and `ec_*.primary_byline_id`.\n\t *\n\t * The returned credits are hydrated with strict-locale matching at the\n\t * locale of the rows the caller supplied (i.e. the locale of the byline\n\t * each `bylineId` resolves to) — adequate for the autosave round-trip,\n\t * which then re-hydrates the entry against its own locale separately.\n\t */\n\tasync setContentBylines(\n\t\tcollectionSlug: string,\n\t\tcontentId: string,\n\t\tinputBylines: ContentBylineInput[],\n\t): Promise<ContentBylineCredit[]> {\n\t\tvalidateIdentifier(collectionSlug, \"collection slug\");\n\t\tconst tableName = `ec_${collectionSlug}`;\n\t\tvalidateIdentifier(tableName, \"content table\");\n\n\t\t// Resolve each wire row id to its translation_group up front so we\n\t\t// can (a) validate the rows exist and (b) dedupe by the value that\n\t\t// actually lands in the junction. Deduping by wire row id BEFORE\n\t\t// resolving would let two locale siblings of the same byline slip\n\t\t// through and trigger a UNIQUE(collection, content, byline_id)\n\t\t// failure at insert time. A single SELECT keeps this O(1) DB\n\t\t// calls regardless of how many credits are being set.\n\t\tconst idToGroup = new Map<string, string>();\n\t\tif (inputBylines.length > 0) {\n\t\t\tconst wireIds = [...new Set(inputBylines.map((item) => item.bylineId))];\n\t\t\tconst rows = await this.db\n\t\t\t\t.selectFrom(\"_emdash_bylines\")\n\t\t\t\t.select([\"id\", \"translation_group\"])\n\t\t\t\t.where(\"id\", \"in\", wireIds)\n\t\t\t\t.execute();\n\t\t\tif (rows.length !== wireIds.length) {\n\t\t\t\tthrow new Error(\"One or more byline IDs do not exist\");\n\t\t\t}\n\t\t\tfor (const row of rows) {\n\t\t\t\tidToGroup.set(row.id, row.translation_group ?? row.id);\n\t\t\t}\n\t\t}\n\n\t\t// Dedupe by translation_group. Preserves the order of first\n\t\t// occurrence so the editor's intent (which sibling appears first)\n\t\t// is honored. `roleLabel` follows the first occurrence too.\n\t\tconst seenGroups = new Set<string>();\n\t\tconst bylines: Array<ContentBylineInput & { group: string }> = [];\n\t\tfor (const item of inputBylines) {\n\t\t\tconst group = idToGroup.get(item.bylineId);\n\t\t\tif (!group) {\n\t\t\t\tthrow new Error(`Missing translation_group for byline ${item.bylineId}`);\n\t\t\t}\n\t\t\tif (seenGroups.has(group)) continue;\n\t\t\tseenGroups.add(group);\n\t\t\tbylines.push({ ...item, group });\n\t\t}\n\n\t\t// This method is expected to be called within a transaction context\n\t\t// (content handlers wrap in withTransaction, seed applies sequentially).\n\t\t// All operations use this.db directly -- callers are responsible for\n\t\t// wrapping in a transaction when atomicity is required.\n\t\tawait this.db\n\t\t\t.deleteFrom(\"_emdash_content_bylines\")\n\t\t\t.where(\"collection_slug\", \"=\", collectionSlug)\n\t\t\t.where(\"content_id\", \"=\", contentId)\n\t\t\t.execute();\n\n\t\tfor (let i = 0; i < bylines.length; i++) {\n\t\t\tconst item = bylines[i];\n\t\t\tif (!item) continue;\n\t\t\tawait this.db\n\t\t\t\t.insertInto(\"_emdash_content_bylines\")\n\t\t\t\t.values({\n\t\t\t\t\tid: ulid(),\n\t\t\t\t\tcollection_slug: collectionSlug,\n\t\t\t\t\tcontent_id: contentId,\n\t\t\t\t\tbyline_id: item.group,\n\t\t\t\t\tsort_order: i,\n\t\t\t\t\trole_label: item.roleLabel ?? null,\n\t\t\t\t\tcreated_at: new Date().toISOString(),\n\t\t\t\t})\n\t\t\t\t.execute();\n\t\t}\n\n\t\tconst primaryGroup = bylines[0]?.group ?? null;\n\t\tawait sql`\n\t\t\tUPDATE ${sql.ref(tableName)}\n\t\t\tSET primary_byline_id = ${primaryGroup}\n\t\t\tWHERE id = ${contentId}\n\t\t`.execute(this.db);\n\n\t\t// Byline credits are folded into this entry's cached payload.\n\t\tinvalidateCollectionCache(collectionSlug);\n\n\t\treturn await this.getContentBylines(collectionSlug, contentId);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA4GA,SAAS,YAAY,KAAyC;AAC7D,QAAO;EACN,IAAI,IAAI;EACR,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,KAAK,IAAI;EACT,eAAe,IAAI;EACnB,kBAAkB,IAAI,sBAAsB;EAC5C,WAAW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4BAA0B,eAAe;AAEzC,SAAO,MAAM,KAAK,kBAAkB,gBAAgB,UAAU"}
@@ -1,4 +1,4 @@
1
- import { n as BylineSchemaRegistry, r as mapBylineSchemaError, t as BylineSchemaError } from "./byline-registry-Bpu9-MVs.mjs";
1
+ import { n as BylineSchemaRegistry, r as mapBylineSchemaError, t as BylineSchemaError } from "./byline-registry-BxDGIO0I.mjs";
2
2
 
3
3
  //#region src/api/handlers/byline-fields.ts
4
4
  /**
@@ -120,4 +120,4 @@ async function handleBylineFieldReorder(db, slugs) {
120
120
 
121
121
  //#endregion
122
122
  export { handleBylineFieldReorder as a, handleBylineFieldList as i, handleBylineFieldDelete as n, handleBylineFieldUpdate as o, handleBylineFieldGet as r, handleBylineFieldUsage as s, handleBylineFieldCreate as t };
123
- //# sourceMappingURL=byline-fields-CAyA_Umd.mjs.map
123
+ //# sourceMappingURL=byline-fields-DPVRFMz2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"byline-fields-CAyA_Umd.mjs","names":[],"sources":["../src/api/handlers/byline-fields.ts"],"sourcesContent":["/**\n * Handler layer for the byline-fields admin API (Phase 4 of Discussion\n * #1174).\n *\n * Each handler:\n * - Takes the `Kysely<Database>` from the route, returns `ApiResult<T>`.\n * - Wraps the registry call in try/catch.\n * - Translates `BylineSchemaError` → shared `ErrorCode` via\n * `mapBylineSchemaError`. HTTP status comes from `mapErrorStatus` at\n * the route's `unwrapResult` site — handlers don't know about\n * statuses.\n * - Catches everything else, logs server-side, returns a 500-class\n * code without leaking `error.message`.\n *\n * Reserved-slug + identifier validation runs at the zod layer (see\n * `schemas/byline-fields.ts`); the registry repeats it for defence in\n * depth (non-HTTP callers). This module assumes inputs have already\n * passed through whichever zod schema the route used.\n */\n\nimport type { Kysely } from \"kysely\";\n\nimport type { Database } from \"../../database/types.js\";\nimport {\n\tBylineSchemaError,\n\tBylineSchemaRegistry,\n\tmapBylineSchemaError,\n} from \"../../schema/byline-registry.js\";\nimport type {\n\tBylineFieldDefinition,\n\tCreateBylineFieldInput,\n\tUpdateBylineFieldInput,\n} from \"../../schema/types.js\";\nimport type { ApiResult } from \"../types.js\";\n\n/**\n * Build a structured failure envelope from a `BylineSchemaError`.\n * Centralised so every handler emits the same shape.\n */\nfunction bylineSchemaErrorResult<T>(error: BylineSchemaError): ApiResult<T> {\n\tconst mapped = mapBylineSchemaError(error);\n\treturn {\n\t\tsuccess: false,\n\t\terror: { code: mapped.code, message: mapped.message, details: mapped.details },\n\t};\n}\n\n/**\n * Build a 500-class failure envelope. Logs the underlying error\n * server-side; the message returned to the client is the static\n * fallback to avoid leaking internals.\n */\nfunction internalErrorResult<T>(\n\terror: unknown,\n\tcode: string,\n\tfallbackMessage: string,\n): ApiResult<T> {\n\tconsole.error(`[${code}]`, error);\n\treturn {\n\t\tsuccess: false,\n\t\terror: { code, message: fallbackMessage },\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// List\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldList(\n\tdb: Kysely<Database>,\n): Promise<ApiResult<{ items: BylineFieldDefinition[] }>> {\n\ttry {\n\t\tconst items = await new BylineSchemaRegistry(db).listFields();\n\t\treturn { success: true, data: { items } };\n\t} catch (error) {\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_LIST_ERROR\", \"Failed to list byline fields\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Create\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldCreate(\n\tdb: Kysely<Database>,\n\tinput: CreateBylineFieldInput,\n): Promise<ApiResult<BylineFieldDefinition>> {\n\ttry {\n\t\tconst field = await new BylineSchemaRegistry(db).createField(input);\n\t\treturn { success: true, data: field };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_CREATE_ERROR\", \"Failed to create byline field\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Get one\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldGet(\n\tdb: Kysely<Database>,\n\tslug: string,\n): Promise<ApiResult<BylineFieldDefinition>> {\n\ttry {\n\t\tconst field = await new BylineSchemaRegistry(db).getField(slug);\n\t\tif (!field) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"NOT_FOUND\", message: \"Byline field not found\" },\n\t\t\t};\n\t\t}\n\t\treturn { success: true, data: field };\n\t} catch (error) {\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_GET_ERROR\", \"Failed to get byline field\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Update\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldUpdate(\n\tdb: Kysely<Database>,\n\tslug: string,\n\tinput: UpdateBylineFieldInput,\n): Promise<ApiResult<BylineFieldDefinition>> {\n\ttry {\n\t\tconst field = await new BylineSchemaRegistry(db).updateField(slug, input);\n\t\treturn { success: true, data: field };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_UPDATE_ERROR\", \"Failed to update byline field\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Delete\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldDelete(\n\tdb: Kysely<Database>,\n\tslug: string,\n): Promise<ApiResult<{ deleted: true }>> {\n\ttry {\n\t\tawait new BylineSchemaRegistry(db).deleteField(slug);\n\t\treturn { success: true, data: { deleted: true } };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_DELETE_ERROR\", \"Failed to delete byline field\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Usage\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldUsage(\n\tdb: Kysely<Database>,\n\tslug: string,\n): Promise<\n\tApiResult<{\n\t\ttranslatableValueCount: number;\n\t\tgroupValueCount: number;\n\t\ttotalAffectedRows: number;\n\t}>\n> {\n\ttry {\n\t\tconst usage = await new BylineSchemaRegistry(db).getFieldUsage(slug);\n\t\treturn { success: true, data: usage };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(\n\t\t\terror,\n\t\t\t\"SCHEMA_FIELD_GET_ERROR\",\n\t\t\t\"Failed to read byline field usage\",\n\t\t);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Reorder\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldReorder(\n\tdb: Kysely<Database>,\n\tslugs: string[],\n): Promise<ApiResult<{ items: BylineFieldDefinition[] }>> {\n\ttry {\n\t\tconst registry = new BylineSchemaRegistry(db);\n\t\tawait registry.reorderFields(slugs);\n\t\tconst items = await registry.listFields();\n\t\treturn { success: true, data: { items } };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(\n\t\t\terror,\n\t\t\t\"SCHEMA_FIELD_REORDER_ERROR\",\n\t\t\t\"Failed to reorder byline fields\",\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;AAuCA,SAAS,wBAA2B,OAAwC;CAC3E,MAAM,SAAS,qBAAqB,MAAM;AAC1C,QAAO;EACN,SAAS;EACT,OAAO;GAAE,MAAM,OAAO;GAAM,SAAS,OAAO;GAAS,SAAS,OAAO;GAAS;EAC9E;;;;;;;AAQF,SAAS,oBACR,OACA,MACA,iBACe;AACf,SAAQ,MAAM,IAAI,KAAK,IAAI,MAAM;AACjC,QAAO;EACN,SAAS;EACT,OAAO;GAAE;GAAM,SAAS;GAAiB;EACzC;;AAOF,eAAsB,sBACrB,IACyD;AACzD,KAAI;AAEH,SAAO;GAAE,SAAS;GAAM,MAAM,EAAE,OADlB,MAAM,IAA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AM,IAAI,qBAAqB,GAAG,CAAC,cAAc,KAAK;GAC/B;UAC7B,OAAO;AACf,MAAI,iBAAiB,kBACpB,QAAO,wBAAwB,MAAM;AAEtC,SAAO,oBACN,OACA,0BACA,oCACA;;;AAQH,eAAsB,yBACrB,IACA,OACyD;AACzD,KAAI;EACH,MAAM,WAAW,IAAI,qBAAqB,GAAG;AAC7C,QAAM,SAAS,cAAc,MAAM;AAEnC,SAAO;GAAE,SAAS;GAAM,MAAM,EAAE,OADlB,MAAM,SAAS,YAAY,EACF;GAAE;UACjC,OAAO;AACf,MAAI,iBAAiB,kBACpB,QAAO,wBAAwB,MAAM;AAEtC,SAAO,oBACN,OACA,8BACA,kCACA"}
1
+ {"version":3,"file":"byline-fields-DPVRFMz2.mjs","names":[],"sources":["../src/api/handlers/byline-fields.ts"],"sourcesContent":["/**\n * Handler layer for the byline-fields admin API (Phase 4 of Discussion\n * #1174).\n *\n * Each handler:\n * - Takes the `Kysely<Database>` from the route, returns `ApiResult<T>`.\n * - Wraps the registry call in try/catch.\n * - Translates `BylineSchemaError` → shared `ErrorCode` via\n * `mapBylineSchemaError`. HTTP status comes from `mapErrorStatus` at\n * the route's `unwrapResult` site — handlers don't know about\n * statuses.\n * - Catches everything else, logs server-side, returns a 500-class\n * code without leaking `error.message`.\n *\n * Reserved-slug + identifier validation runs at the zod layer (see\n * `schemas/byline-fields.ts`); the registry repeats it for defence in\n * depth (non-HTTP callers). This module assumes inputs have already\n * passed through whichever zod schema the route used.\n */\n\nimport type { Kysely } from \"kysely\";\n\nimport type { Database } from \"../../database/types.js\";\nimport {\n\tBylineSchemaError,\n\tBylineSchemaRegistry,\n\tmapBylineSchemaError,\n} from \"../../schema/byline-registry.js\";\nimport type {\n\tBylineFieldDefinition,\n\tCreateBylineFieldInput,\n\tUpdateBylineFieldInput,\n} from \"../../schema/types.js\";\nimport type { ApiResult } from \"../types.js\";\n\n/**\n * Build a structured failure envelope from a `BylineSchemaError`.\n * Centralised so every handler emits the same shape.\n */\nfunction bylineSchemaErrorResult<T>(error: BylineSchemaError): ApiResult<T> {\n\tconst mapped = mapBylineSchemaError(error);\n\treturn {\n\t\tsuccess: false,\n\t\terror: { code: mapped.code, message: mapped.message, details: mapped.details },\n\t};\n}\n\n/**\n * Build a 500-class failure envelope. Logs the underlying error\n * server-side; the message returned to the client is the static\n * fallback to avoid leaking internals.\n */\nfunction internalErrorResult<T>(\n\terror: unknown,\n\tcode: string,\n\tfallbackMessage: string,\n): ApiResult<T> {\n\tconsole.error(`[${code}]`, error);\n\treturn {\n\t\tsuccess: false,\n\t\terror: { code, message: fallbackMessage },\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// List\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldList(\n\tdb: Kysely<Database>,\n): Promise<ApiResult<{ items: BylineFieldDefinition[] }>> {\n\ttry {\n\t\tconst items = await new BylineSchemaRegistry(db).listFields();\n\t\treturn { success: true, data: { items } };\n\t} catch (error) {\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_LIST_ERROR\", \"Failed to list byline fields\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Create\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldCreate(\n\tdb: Kysely<Database>,\n\tinput: CreateBylineFieldInput,\n): Promise<ApiResult<BylineFieldDefinition>> {\n\ttry {\n\t\tconst field = await new BylineSchemaRegistry(db).createField(input);\n\t\treturn { success: true, data: field };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_CREATE_ERROR\", \"Failed to create byline field\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Get one\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldGet(\n\tdb: Kysely<Database>,\n\tslug: string,\n): Promise<ApiResult<BylineFieldDefinition>> {\n\ttry {\n\t\tconst field = await new BylineSchemaRegistry(db).getField(slug);\n\t\tif (!field) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: { code: \"NOT_FOUND\", message: \"Byline field not found\" },\n\t\t\t};\n\t\t}\n\t\treturn { success: true, data: field };\n\t} catch (error) {\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_GET_ERROR\", \"Failed to get byline field\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Update\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldUpdate(\n\tdb: Kysely<Database>,\n\tslug: string,\n\tinput: UpdateBylineFieldInput,\n): Promise<ApiResult<BylineFieldDefinition>> {\n\ttry {\n\t\tconst field = await new BylineSchemaRegistry(db).updateField(slug, input);\n\t\treturn { success: true, data: field };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_UPDATE_ERROR\", \"Failed to update byline field\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Delete\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldDelete(\n\tdb: Kysely<Database>,\n\tslug: string,\n): Promise<ApiResult<{ deleted: true }>> {\n\ttry {\n\t\tawait new BylineSchemaRegistry(db).deleteField(slug);\n\t\treturn { success: true, data: { deleted: true } };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(error, \"SCHEMA_FIELD_DELETE_ERROR\", \"Failed to delete byline field\");\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Usage\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldUsage(\n\tdb: Kysely<Database>,\n\tslug: string,\n): Promise<\n\tApiResult<{\n\t\ttranslatableValueCount: number;\n\t\tgroupValueCount: number;\n\t\ttotalAffectedRows: number;\n\t}>\n> {\n\ttry {\n\t\tconst usage = await new BylineSchemaRegistry(db).getFieldUsage(slug);\n\t\treturn { success: true, data: usage };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(\n\t\t\terror,\n\t\t\t\"SCHEMA_FIELD_GET_ERROR\",\n\t\t\t\"Failed to read byline field usage\",\n\t\t);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Reorder\n// ---------------------------------------------------------------------------\n\nexport async function handleBylineFieldReorder(\n\tdb: Kysely<Database>,\n\tslugs: string[],\n): Promise<ApiResult<{ items: BylineFieldDefinition[] }>> {\n\ttry {\n\t\tconst registry = new BylineSchemaRegistry(db);\n\t\tawait registry.reorderFields(slugs);\n\t\tconst items = await registry.listFields();\n\t\treturn { success: true, data: { items } };\n\t} catch (error) {\n\t\tif (error instanceof BylineSchemaError) {\n\t\t\treturn bylineSchemaErrorResult(error);\n\t\t}\n\t\treturn internalErrorResult(\n\t\t\terror,\n\t\t\t\"SCHEMA_FIELD_REORDER_ERROR\",\n\t\t\t\"Failed to reorder byline fields\",\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;AAuCA,SAAS,wBAA2B,OAAwC;CAC3E,MAAM,SAAS,qBAAqB,MAAM;AAC1C,QAAO;EACN,SAAS;EACT,OAAO;GAAE,MAAM,OAAO;GAAM,SAAS,OAAO;GAAS,SAAS,OAAO;GAAS;EAC9E;;;;;;;AAQF,SAAS,oBACR,OACA,MACA,iBACe;AACf,SAAQ,MAAM,IAAI,KAAK,IAAI,MAAM;AACjC,QAAO;EACN,SAAS;EACT,OAAO;GAAE;GAAM,SAAS;GAAiB;EACzC;;AAOF,eAAsB,sBACrB,IACyD;AACzD,KAAI;AAEH,SAAO;GAAE,SAAS;GAAM,MAAM,EAAE,OADlB,MAAM,IAAI,qBAAqB,GAAG,CAAC,YAAY,EACtB;GAAE;UACjC,OAAO;AACf,SAAO,oBAAoB,OAAO,2BAA2B,+BAA+B;;;AAQ9F,eAAsB,wBACrB,IACA,OAC4C;AAC5C,KAAI;A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;AAQH,eAAsB,yBACrB,IACA,OACyD;AACzD,KAAI;EACH,MAAM,WAAW,IAAI,qBAAqB,GAAG;AAC7C,QAAM,SAAS,cAAc,MAAM;AAEnC,SAAO;GAAE,SAAS;GAAM,MAAM,EAAE,OADlB,MAAM,SAAS,YAAY,EACF;GAAE;UACjC,OAAO;AACf,MAAI,iBAAiB,kBACpB,QAAO,wBAAwB,MAAM;AAEtC,SAAO,oBACN,OACA,8BACA,kCACA"}
@@ -1,5 +1,5 @@
1
1
  import { t as validateIdentifier } from "./validate-BpwoDOgt.mjs";
2
- import { a as RESERVED_BYLINE_FIELD_SLUGS, t as BYLINE_FIELD_TYPES } from "./types-75KIqzL9.mjs";
2
+ import { o as RESERVED_BYLINE_FIELD_SLUGS, t as BYLINE_FIELD_TYPES } from "./types-BMXnRIrX.mjs";
3
3
  import { t as withTransaction } from "./transaction-0KOpOyMu.mjs";
4
4
  import { sql } from "kysely";
5
5
  import { ulid } from "ulidx";
@@ -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-Bpu9-MVs.mjs.map
406
+ //# sourceMappingURL=byline-registry-BxDGIO0I.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"byline-registry-Bpu9-MVs.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;\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,MA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T,+CAA+C,mBAAmB,WAClE,sBACA,EAAE,OAAO,QAAQ,QAAQ,CACzB;GAEF,MAAM,uBAAO,IAAI,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,OAAO;;;AAIjD,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-BxDGIO0I.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;\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,S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,QAAQ,CACzB;GAEF,MAAM,uBAAO,IAAI,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,OAAO;;;AAIjD,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,10 +1,10 @@
1
- import { c as __exportAll } from "./runner-77GOZCnH.mjs";
1
+ import { c as __exportAll } from "./runner-nEzvnogG.mjs";
2
2
  import { t as validateIdentifier } from "./validate-BpwoDOgt.mjs";
3
3
  import { n as isMissingTableError } from "./db-errors-Cl-sKYTm.mjs";
4
- import { r as requestCached } from "./request-cache-DH9zdCOD.mjs";
5
- import { t as BylineRepository } from "./byline-Cpnwrje1.mjs";
6
- import { i as resolveLocaleChain } from "./resolve-DxUpTMmE.mjs";
7
- import { s as getDb } from "./loader-ZsjE4paL.mjs";
4
+ import { i as resolveLocaleChain } from "./resolve-Cy0aWSRj.mjs";
5
+ import { r as requestCached } from "./request-cache-DAZZmesc.mjs";
6
+ import { t as BylineRepository } from "./byline-Vdi85CsZ.mjs";
7
+ import { s as getDb } from "./loader-WJi6GFRn.mjs";
8
8
  import { sql } from "kysely";
9
9
 
10
10
  //#region src/bylines/index.ts
@@ -217,7 +217,7 @@ async function getBylinesForEntries(collection, entries) {
217
217
  * @param options - Optional locale, ordering, status, and limit
218
218
  */
219
219
  async function getEntriesByByline(collection, byline, options = {}) {
220
- const { getEmDashCollection } = await import("./query-D18vTdha.mjs").then((n) => n.o);
220
+ const { getEmDashCollection } = await import("./query-DygOte9M.mjs").then((n) => n.o);
221
221
  const queryOptions = { where: { byline } };
222
222
  if (options.locale !== void 0) queryOptions.locale = options.locale;
223
223
  if (options.orderBy !== void 0) queryOptions.orderBy = options.orderBy;
@@ -229,4 +229,4 @@ async function getEntriesByByline(collection, byline, options = {}) {
229
229
 
230
230
  //#endregion
231
231
  export { invalidateBylineCache as a, getEntriesByByline as i, getByline as n, getBylineBySlug as r, bylines_exports as t };
232
- //# sourceMappingURL=bylines-BSo9B9RX.mjs.map
232
+ //# sourceMappingURL=bylines-BX8QhcTk.mjs.map