emdash 0.20.0 → 0.21.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 (547) hide show
  1. package/dist/{adapters-BzIHV3sw.d.mts → adapters-BxSmgtbF.d.mts} +1 -1
  2. package/dist/{adapters-BzIHV3sw.d.mts.map → adapters-BxSmgtbF.d.mts.map} +1 -1
  3. package/dist/{allowed-origins-B1u7Qnvg.mjs → allowed-origins-BqC8cul8.mjs} +2 -2
  4. package/dist/{allowed-origins-B1u7Qnvg.mjs.map → allowed-origins-BqC8cul8.mjs.map} +1 -1
  5. package/dist/api/route-utils.d.mts +3 -3
  6. package/dist/api/route-utils.mjs +13 -12
  7. package/dist/api/route-utils.mjs.map +1 -1
  8. package/dist/api/schemas/index.d.mts +1 -1
  9. package/dist/api/schemas/index.mjs +3 -2
  10. package/dist/{api-DStv36ik.mjs → api-DxjIV2o8.mjs} +13 -13
  11. package/dist/{api-DStv36ik.mjs.map → api-DxjIV2o8.mjs.map} +1 -1
  12. package/dist/{api-tokens-DPfhPu5V.mjs → api-tokens-BFFkB0jB.mjs} +2 -2
  13. package/dist/{api-tokens-DPfhPu5V.mjs.map → api-tokens-BFFkB0jB.mjs.map} +1 -1
  14. package/dist/{apply-Dr7snAMT.mjs → apply-CLjxheyb.mjs} +12 -12
  15. package/dist/{apply-Dr7snAMT.mjs.map → apply-CLjxheyb.mjs.map} +1 -1
  16. package/dist/astro/index.d.mts +10 -10
  17. package/dist/astro/index.d.mts.map +1 -1
  18. package/dist/astro/index.mjs +50 -15
  19. package/dist/astro/index.mjs.map +1 -1
  20. package/dist/astro/middleware/auth.d.mts +9 -9
  21. package/dist/astro/middleware/auth.mjs +5 -5
  22. package/dist/astro/middleware/redirect.d.mts.map +1 -1
  23. package/dist/astro/middleware/redirect.mjs +11 -2
  24. package/dist/astro/middleware/redirect.mjs.map +1 -1
  25. package/dist/astro/middleware/request-context.mjs +3 -2
  26. package/dist/astro/middleware/request-context.mjs.map +1 -1
  27. package/dist/astro/middleware/setup.mjs +1 -1
  28. package/dist/astro/middleware.d.mts +1 -1
  29. package/dist/astro/middleware.mjs +63 -60
  30. package/dist/astro/middleware.mjs.map +1 -1
  31. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +5 -4
  32. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs.map +1 -1
  33. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +5 -4
  34. package/dist/astro/routes/api/admin/allowed-domains/index.mjs.map +1 -1
  35. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +3 -3
  36. package/dist/astro/routes/api/admin/api-tokens/index.mjs +4 -4
  37. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -4
  38. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +8 -7
  39. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs.map +1 -1
  40. package/dist/astro/routes/api/admin/byline-fields/index.mjs +8 -7
  41. package/dist/astro/routes/api/admin/byline-fields/index.mjs.map +1 -1
  42. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +8 -7
  43. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs.map +1 -1
  44. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +14 -12
  45. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs.map +1 -1
  46. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +14 -12
  47. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs.map +1 -1
  48. package/dist/astro/routes/api/admin/bylines/index.mjs +14 -12
  49. package/dist/astro/routes/api/admin/bylines/index.mjs.map +1 -1
  50. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +9 -8
  51. package/dist/astro/routes/api/admin/comments/_id_/status.mjs.map +1 -1
  52. package/dist/astro/routes/api/admin/comments/_id_.mjs +3 -3
  53. package/dist/astro/routes/api/admin/comments/bulk.mjs +7 -6
  54. package/dist/astro/routes/api/admin/comments/bulk.mjs.map +1 -1
  55. package/dist/astro/routes/api/admin/comments/counts.mjs +3 -3
  56. package/dist/astro/routes/api/admin/comments/index.mjs +7 -6
  57. package/dist/astro/routes/api/admin/comments/index.mjs.map +1 -1
  58. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +3 -3
  59. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +2 -2
  60. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +3 -3
  61. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +3 -3
  62. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +29 -27
  63. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
  64. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +29 -27
  65. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
  66. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +28 -26
  67. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  68. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +28 -26
  69. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  70. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +28 -26
  71. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  72. package/dist/astro/routes/api/admin/plugins/index.mjs +28 -26
  73. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  74. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
  75. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +28 -26
  76. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  77. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +28 -26
  78. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  79. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +28 -26
  80. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  81. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +28 -26
  82. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  83. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +29 -27
  84. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  85. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +28 -26
  86. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
  87. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +29 -27
  88. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  89. package/dist/astro/routes/api/admin/plugins/updates.mjs +28 -26
  90. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  91. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +28 -26
  92. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  93. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
  94. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +28 -26
  95. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  96. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +1 -1
  97. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
  98. package/dist/astro/routes/api/admin/users/_id_/index.mjs +5 -4
  99. package/dist/astro/routes/api/admin/users/_id_/index.mjs.map +1 -1
  100. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +2 -2
  101. package/dist/astro/routes/api/admin/users/index.mjs +5 -4
  102. package/dist/astro/routes/api/admin/users/index.mjs.map +1 -1
  103. package/dist/astro/routes/api/auth/dev-bypass.mjs +3 -3
  104. package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
  105. package/dist/astro/routes/api/auth/invite/complete.mjs +9 -8
  106. package/dist/astro/routes/api/auth/invite/complete.mjs.map +1 -1
  107. package/dist/astro/routes/api/auth/invite/index.mjs +6 -5
  108. package/dist/astro/routes/api/auth/invite/index.mjs.map +1 -1
  109. package/dist/astro/routes/api/auth/invite/register-options.mjs +8 -7
  110. package/dist/astro/routes/api/auth/invite/register-options.mjs.map +1 -1
  111. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  112. package/dist/astro/routes/api/auth/magic-link/send.mjs +8 -7
  113. package/dist/astro/routes/api/auth/magic-link/send.mjs.map +1 -1
  114. package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
  115. package/dist/astro/routes/api/auth/me.mjs +5 -4
  116. package/dist/astro/routes/api/auth/me.mjs.map +1 -1
  117. package/dist/astro/routes/api/auth/mode.mjs +1 -1
  118. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +3 -3
  119. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  120. package/dist/astro/routes/api/auth/passkey/_id_.mjs +5 -4
  121. package/dist/astro/routes/api/auth/passkey/_id_.mjs.map +1 -1
  122. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
  123. package/dist/astro/routes/api/auth/passkey/options.mjs +10 -9
  124. package/dist/astro/routes/api/auth/passkey/options.mjs.map +1 -1
  125. package/dist/astro/routes/api/auth/passkey/register/options.mjs +8 -7
  126. package/dist/astro/routes/api/auth/passkey/register/options.mjs.map +1 -1
  127. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +9 -8
  128. package/dist/astro/routes/api/auth/passkey/register/verify.mjs.map +1 -1
  129. package/dist/astro/routes/api/auth/passkey/verify.mjs +9 -8
  130. package/dist/astro/routes/api/auth/passkey/verify.mjs.map +1 -1
  131. package/dist/astro/routes/api/auth/signup/complete.mjs +9 -8
  132. package/dist/astro/routes/api/auth/signup/complete.mjs.map +1 -1
  133. package/dist/astro/routes/api/auth/signup/request.mjs +8 -7
  134. package/dist/astro/routes/api/auth/signup/request.mjs.map +1 -1
  135. package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
  136. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +11 -9
  137. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs.map +1 -1
  138. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  139. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +2 -2
  140. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +2 -2
  141. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +2 -2
  142. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +10 -8
  143. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs.map +1 -1
  144. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +6 -5
  145. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
  146. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +2 -2
  147. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
  148. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +6 -5
  149. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
  150. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +10 -9
  151. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  152. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  153. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +2 -2
  154. package/dist/astro/routes/api/content/_collection_/_id_.mjs +6 -5
  155. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  156. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  157. package/dist/astro/routes/api/content/_collection_/index.mjs +6 -5
  158. package/dist/astro/routes/api/content/_collection_/index.mjs.map +1 -1
  159. package/dist/astro/routes/api/content/_collection_/trash.mjs +6 -5
  160. package/dist/astro/routes/api/content/_collection_/trash.mjs.map +1 -1
  161. package/dist/astro/routes/api/dashboard.mjs +3 -3
  162. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  163. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  164. package/dist/astro/routes/api/import/probe.mjs +10 -9
  165. package/dist/astro/routes/api/import/probe.mjs.map +1 -1
  166. package/dist/astro/routes/api/import/wordpress/analyze.mjs +3 -3
  167. package/dist/astro/routes/api/import/wordpress/execute.d.mts +9 -9
  168. package/dist/astro/routes/api/import/wordpress/execute.mjs +10 -9
  169. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  170. package/dist/astro/routes/api/import/wordpress/media.mjs +8 -7
  171. package/dist/astro/routes/api/import/wordpress/media.mjs.map +1 -1
  172. package/dist/astro/routes/api/import/wordpress/prepare.mjs +9 -8
  173. package/dist/astro/routes/api/import/wordpress/prepare.mjs.map +1 -1
  174. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +8 -7
  175. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs.map +1 -1
  176. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  177. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +10 -9
  178. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs.map +1 -1
  179. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +1 -1
  180. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +14 -12
  181. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  182. package/dist/astro/routes/api/manifest.mjs +3 -3
  183. package/dist/astro/routes/api/mcp.mjs +20 -19
  184. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  185. package/dist/astro/routes/api/media/_id_/confirm.mjs +6 -5
  186. package/dist/astro/routes/api/media/_id_/confirm.mjs.map +1 -1
  187. package/dist/astro/routes/api/media/_id_.mjs +6 -5
  188. package/dist/astro/routes/api/media/_id_.mjs.map +1 -1
  189. package/dist/astro/routes/api/media/file/_...key_.mjs +1 -1
  190. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
  191. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  192. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  193. package/dist/astro/routes/api/media/upload-url.mjs +8 -7
  194. package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
  195. package/dist/astro/routes/api/media.mjs +10 -9
  196. package/dist/astro/routes/api/media.mjs.map +1 -1
  197. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +6 -5
  198. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  199. package/dist/astro/routes/api/menus/_name_/items.mjs +6 -5
  200. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  201. package/dist/astro/routes/api/menus/_name_/reorder.mjs +6 -5
  202. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  203. package/dist/astro/routes/api/menus/_name_/translations.mjs +6 -5
  204. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  205. package/dist/astro/routes/api/menus/_name_.mjs +6 -5
  206. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  207. package/dist/astro/routes/api/menus/index.mjs +6 -5
  208. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  209. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  210. package/dist/astro/routes/api/oauth/device/authorize.mjs +5 -5
  211. package/dist/astro/routes/api/oauth/device/code.mjs +8 -8
  212. package/dist/astro/routes/api/oauth/device/token.mjs +7 -7
  213. package/dist/astro/routes/api/oauth/register.mjs +2 -2
  214. package/dist/astro/routes/api/oauth/token/refresh.mjs +5 -5
  215. package/dist/astro/routes/api/oauth/token/revoke.mjs +5 -5
  216. package/dist/astro/routes/api/oauth/token.mjs +5 -5
  217. package/dist/astro/routes/api/openapi.json.mjs +3 -2
  218. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  219. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +3 -3
  220. package/dist/astro/routes/api/redirects/404s/index.mjs +7 -6
  221. package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
  222. package/dist/astro/routes/api/redirects/404s/summary.mjs +7 -6
  223. package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
  224. package/dist/astro/routes/api/redirects/_id_.mjs +8 -7
  225. package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
  226. package/dist/astro/routes/api/redirects/index.mjs +8 -7
  227. package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
  228. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  229. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +2 -2
  230. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +28 -26
  231. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  232. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +28 -26
  233. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  234. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +28 -26
  235. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  236. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +28 -26
  237. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  238. package/dist/astro/routes/api/schema/collections/index.mjs +28 -26
  239. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  240. package/dist/astro/routes/api/schema/index.mjs +5 -5
  241. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +28 -26
  242. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  243. package/dist/astro/routes/api/schema/orphans/index.mjs +28 -26
  244. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  245. package/dist/astro/routes/api/search/enable.mjs +9 -8
  246. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  247. package/dist/astro/routes/api/search/index.mjs +8 -7
  248. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  249. package/dist/astro/routes/api/search/rebuild.mjs +9 -8
  250. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  251. package/dist/astro/routes/api/search/stats.mjs +5 -5
  252. package/dist/astro/routes/api/search/suggest.mjs +8 -7
  253. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  254. package/dist/astro/routes/api/sections/_slug_.mjs +8 -7
  255. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  256. package/dist/astro/routes/api/sections/index.mjs +8 -7
  257. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  258. package/dist/astro/routes/api/settings/email.mjs +3 -3
  259. package/dist/astro/routes/api/settings.mjs +11 -9
  260. package/dist/astro/routes/api/settings.mjs.map +1 -1
  261. package/dist/astro/routes/api/setup/admin-verify.mjs +10 -9
  262. package/dist/astro/routes/api/setup/admin-verify.mjs.map +1 -1
  263. package/dist/astro/routes/api/setup/admin.mjs +9 -8
  264. package/dist/astro/routes/api/setup/admin.mjs.map +1 -1
  265. package/dist/astro/routes/api/setup/dev-bypass.mjs +19 -18
  266. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  267. package/dist/astro/routes/api/setup/dev-reset.mjs +1 -1
  268. package/dist/astro/routes/api/setup/index.mjs +20 -18
  269. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  270. package/dist/astro/routes/api/setup/status.mjs +3 -3
  271. package/dist/astro/routes/api/snapshot.mjs +5 -4
  272. package/dist/astro/routes/api/snapshot.mjs.map +1 -1
  273. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +11 -10
  274. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
  275. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +11 -10
  276. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
  277. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +11 -10
  278. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
  279. package/dist/astro/routes/api/taxonomies/index.mjs +11 -10
  280. package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
  281. package/dist/astro/routes/api/themes/preview.mjs +5 -4
  282. package/dist/astro/routes/api/themes/preview.mjs.map +1 -1
  283. package/dist/astro/routes/api/typegen.mjs +4 -4
  284. package/dist/astro/routes/api/well-known/auth.mjs +1 -1
  285. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  286. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  287. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +6 -5
  288. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
  289. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +9 -8
  290. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
  291. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +9 -8
  292. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
  293. package/dist/astro/routes/api/widget-areas/_name_.mjs +5 -5
  294. package/dist/astro/routes/api/widget-areas/index.mjs +9 -8
  295. package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
  296. package/dist/astro/routes/api/widget-components.mjs +2 -2
  297. package/dist/astro/routes/robots.txt.mjs +5 -4
  298. package/dist/astro/routes/robots.txt.mjs.map +1 -1
  299. package/dist/astro/routes/sitemap-_collection_.xml.mjs +8 -7
  300. package/dist/astro/routes/sitemap-_collection_.xml.mjs.map +1 -1
  301. package/dist/astro/routes/sitemap.xml.mjs +6 -5
  302. package/dist/astro/routes/sitemap.xml.mjs.map +1 -1
  303. package/dist/astro/types.d.mts +12 -12
  304. package/dist/auth/providers/github.d.mts +1 -1
  305. package/dist/auth/providers/google.d.mts +1 -1
  306. package/dist/{authorize-DsMSVSaY.mjs → authorize-D5gfBVU5.mjs} +2 -2
  307. package/dist/{authorize-DsMSVSaY.mjs.map → authorize-D5gfBVU5.mjs.map} +1 -1
  308. package/dist/{byline-DUx48sJp.mjs → byline-V_Qp1Ziw.mjs} +27 -14
  309. package/dist/byline-V_Qp1Ziw.mjs.map +1 -0
  310. package/dist/{byline-fields-8TMtkBnH.mjs → byline-fields-B0NO1yUB.mjs} +3 -3
  311. package/dist/{byline-fields-8TMtkBnH.mjs.map → byline-fields-B0NO1yUB.mjs.map} +1 -1
  312. package/dist/{byline-fields-DbibsvTl.d.mts → byline-fields-CQJRIQkn.d.mts} +32 -32
  313. package/dist/{byline-fields-DbibsvTl.d.mts.map → byline-fields-CQJRIQkn.d.mts.map} +1 -1
  314. package/dist/{byline-fields--WxSNS79.mjs → byline-fields-nBVqK_Ff.mjs} +2 -2
  315. package/dist/{byline-fields--WxSNS79.mjs.map → byline-fields-nBVqK_Ff.mjs.map} +1 -1
  316. package/dist/{byline-registry-CWP7I71B.mjs → byline-registry-DedidtqC.mjs} +2 -2
  317. package/dist/{byline-registry-CWP7I71B.mjs.map → byline-registry-DedidtqC.mjs.map} +1 -1
  318. package/dist/{bylines-BdxWCnPL.mjs → bylines-B2NWnIwS.mjs} +2 -2
  319. package/dist/{bylines-BdxWCnPL.mjs.map → bylines-B2NWnIwS.mjs.map} +1 -1
  320. package/dist/{bylines-s8c2DXbH.mjs → bylines-DfGDnred.mjs} +7 -7
  321. package/dist/{bylines-s8c2DXbH.mjs.map → bylines-DfGDnred.mjs.map} +1 -1
  322. package/dist/{cache-B_HzASVT.mjs → cache-DTTHWD8n.mjs} +1 -1
  323. package/dist/{cache-B_HzASVT.mjs.map → cache-DTTHWD8n.mjs.map} +1 -1
  324. package/dist/{challenge-store-DXX3rfdI.mjs → challenge-store-woE0bbCf.mjs} +1 -1
  325. package/dist/{challenge-store-DXX3rfdI.mjs.map → challenge-store-woE0bbCf.mjs.map} +1 -1
  326. package/dist/cli/index.mjs +19 -18
  327. package/dist/cli/index.mjs.map +1 -1
  328. package/dist/client/cf-access.d.mts +1 -1
  329. package/dist/client/index.d.mts +1 -1
  330. package/dist/client/index.mjs +1 -1
  331. package/dist/{comments-Vkivawyl.mjs → comments-D2hNuxNa.mjs} +1 -1
  332. package/dist/{comments-Vkivawyl.mjs.map → comments-D2hNuxNa.mjs.map} +1 -1
  333. package/dist/{components-CK0cuUoH.mjs → components-DYKp2gmo.mjs} +1 -1
  334. package/dist/{components-CK0cuUoH.mjs.map → components-DYKp2gmo.mjs.map} +1 -1
  335. package/dist/{context-Y7BRkWes.mjs → context-Cm4pt1Ws.mjs} +5 -5
  336. package/dist/{context-Y7BRkWes.mjs.map → context-Cm4pt1Ws.mjs.map} +1 -1
  337. package/dist/{cron-BJ2ClIlj.mjs → cron-DdEVrQ2Y.mjs} +1 -1
  338. package/dist/{cron-BJ2ClIlj.mjs.map → cron-DdEVrQ2Y.mjs.map} +1 -1
  339. package/dist/{dashboard-2JgAMWxK.mjs → dashboard-C-UYpps0.mjs} +1 -1
  340. package/dist/{dashboard-2JgAMWxK.mjs.map → dashboard-C-UYpps0.mjs.map} +1 -1
  341. package/dist/db/index.d.mts +3 -3
  342. package/dist/db/libsql.d.mts +1 -1
  343. package/dist/db/postgres.d.mts +1 -1
  344. package/dist/db/sqlite.d.mts +1 -1
  345. package/dist/{db-errors-CtzxKBxe.mjs → db-errors-BluWkwGI.mjs} +1 -1
  346. package/dist/{db-errors-CtzxKBxe.mjs.map → db-errors-BluWkwGI.mjs.map} +1 -1
  347. package/dist/{default-IlBaTFxM.mjs → default-NHGuJzQ3.mjs} +1 -1
  348. package/dist/{default-IlBaTFxM.mjs.map → default-NHGuJzQ3.mjs.map} +1 -1
  349. package/dist/{device-flow-R23SIbQ2.mjs → device-flow-BQApWgnW.mjs} +4 -4
  350. package/dist/{device-flow-R23SIbQ2.mjs.map → device-flow-BQApWgnW.mjs.map} +1 -1
  351. package/dist/{email-console-DHT2Fbpj.mjs → email-console-BbU3RbWv.mjs} +1 -1
  352. package/dist/{email-console-DHT2Fbpj.mjs.map → email-console-BbU3RbWv.mjs.map} +1 -1
  353. package/dist/{error-RwM4dD35.mjs → error-CNn_w7jf.mjs} +1 -1
  354. package/dist/{error-RwM4dD35.mjs.map → error-CNn_w7jf.mjs.map} +1 -1
  355. package/dist/{escape-Ds07EEyu.mjs → escape-DPgcxcpL.mjs} +1 -1
  356. package/dist/{escape-Ds07EEyu.mjs.map → escape-DPgcxcpL.mjs.map} +1 -1
  357. package/dist/{fts-manager-1RgHmopc.mjs → fts-manager-Cx5z8jdA.mjs} +1 -1
  358. package/dist/{fts-manager-1RgHmopc.mjs.map → fts-manager-Cx5z8jdA.mjs.map} +1 -1
  359. package/dist/{hash-9w3pd3-m.mjs → hash-DlvIFn0b.mjs} +1 -1
  360. package/dist/{hash-9w3pd3-m.mjs.map → hash-DlvIFn0b.mjs.map} +1 -1
  361. package/dist/{import-Dh8bWmyq.mjs → import-KyxT1Mbs.mjs} +3 -3
  362. package/dist/{import-Dh8bWmyq.mjs.map → import-KyxT1Mbs.mjs.map} +1 -1
  363. package/dist/{index-B1keaX5Y.d.mts → index-D2VAiumu.d.mts} +15 -15
  364. package/dist/{index-B1keaX5Y.d.mts.map → index-D2VAiumu.d.mts.map} +1 -1
  365. package/dist/{index-DR56od45.d.mts → index-uT2yR66F.d.mts} +3 -3
  366. package/dist/{index-DR56od45.d.mts.map → index-uT2yR66F.d.mts.map} +1 -1
  367. package/dist/index.d.mts +16 -16
  368. package/dist/index.mjs +48 -46
  369. package/dist/init-lock-DlBHjf9-.mjs +83 -0
  370. package/dist/init-lock-DlBHjf9-.mjs.map +1 -0
  371. package/dist/{load-BBetCvLC.mjs → load-Dq91b_DK.mjs} +1 -1
  372. package/dist/{load-BBetCvLC.mjs.map → load-Dq91b_DK.mjs.map} +1 -1
  373. package/dist/{loader-ZN1ll-d-.mjs → loader-BqWjcH3h.mjs} +2 -2
  374. package/dist/{loader-ZN1ll-d-.mjs.map → loader-BqWjcH3h.mjs.map} +1 -1
  375. package/dist/{manifest-schema-BtwbL_vj.mjs → manifest-schema-DFPeqMAn.mjs} +1 -1
  376. package/dist/{manifest-schema-BtwbL_vj.mjs.map → manifest-schema-DFPeqMAn.mjs.map} +1 -1
  377. package/dist/media/index.d.mts +1 -1
  378. package/dist/media/index.mjs +2 -2
  379. package/dist/media/local-runtime.d.mts +11 -11
  380. package/dist/media/local-runtime.mjs +4 -3
  381. package/dist/media/local-runtime.mjs.map +1 -1
  382. package/dist/{media-allowlist-Dknq-OFY.mjs → media-allowlist-_A0SuDn4.mjs} +2 -2
  383. package/dist/{media-allowlist-Dknq-OFY.mjs.map → media-allowlist-_A0SuDn4.mjs.map} +1 -1
  384. package/dist/{media-url-VClf8glU.mjs → media-url-CqLd69IO.mjs} +1 -1
  385. package/dist/{media-url-VClf8glU.mjs.map → media-url-CqLd69IO.mjs.map} +1 -1
  386. package/dist/{menus-DrQLusqj.mjs → menus-Ryk9L7fT.mjs} +9 -9
  387. package/dist/{menus-DrQLusqj.mjs.map → menus-Ryk9L7fT.mjs.map} +1 -1
  388. package/dist/{mime-CCEzze7W.mjs → mime-YbtlEtvS.mjs} +1 -1
  389. package/dist/{mime-CCEzze7W.mjs.map → mime-YbtlEtvS.mjs.map} +1 -1
  390. package/dist/{mode-CO2vQHfq.mjs → mode-CGXzIbD8.mjs} +1 -1
  391. package/dist/{mode-CO2vQHfq.mjs.map → mode-CGXzIbD8.mjs.map} +1 -1
  392. package/dist/{normalize-CK5o04zr.mjs → normalize-DKsg36ty.mjs} +1 -1
  393. package/dist/{normalize-CK5o04zr.mjs.map → normalize-DKsg36ty.mjs.map} +1 -1
  394. package/dist/{oauth-authorization-Bw4NdF_S.mjs → oauth-authorization-C2kVyjXI.mjs} +4 -4
  395. package/dist/{oauth-authorization-Bw4NdF_S.mjs.map → oauth-authorization-C2kVyjXI.mjs.map} +1 -1
  396. package/dist/{oauth-clients-BGGFp57s.mjs → oauth-clients-BC873NCV.mjs} +1 -1
  397. package/dist/{oauth-clients-BGGFp57s.mjs.map → oauth-clients-BC873NCV.mjs.map} +1 -1
  398. package/dist/{oauth-state-store-97x0xtN2.mjs → oauth-state-store-Cd--TUaq.mjs} +1 -1
  399. package/dist/{oauth-state-store-97x0xtN2.mjs.map → oauth-state-store-Cd--TUaq.mjs.map} +1 -1
  400. package/dist/{oauth-user-lookup-B_vnZHKO.mjs → oauth-user-lookup-e4wOvDud.mjs} +1 -1
  401. package/dist/{oauth-user-lookup-B_vnZHKO.mjs.map → oauth-user-lookup-e4wOvDud.mjs.map} +1 -1
  402. package/dist/{options-DyYIYpPd.d.mts → options-9kLgkE8m.d.mts} +3 -3
  403. package/dist/{options-DyYIYpPd.d.mts.map → options-9kLgkE8m.d.mts.map} +1 -1
  404. package/dist/page/index.d.mts +2 -2
  405. package/dist/{parse-CrGndy1A.mjs → parse-DzSrk1t8.mjs} +2 -2
  406. package/dist/{parse-CrGndy1A.mjs.map → parse-DzSrk1t8.mjs.map} +1 -1
  407. package/dist/{passkey-config-C3QgnQnU.mjs → passkey-config-BpjbE_Uv.mjs} +1 -1
  408. package/dist/{passkey-config-C3QgnQnU.mjs.map → passkey-config-BpjbE_Uv.mjs.map} +1 -1
  409. package/dist/{placeholder-BZxr8W1j.mjs → placeholder-2xumZh4g.mjs} +1 -1
  410. package/dist/{placeholder-BZxr8W1j.mjs.map → placeholder-2xumZh4g.mjs.map} +1 -1
  411. package/dist/{placeholder-CVBv5z8k.d.mts → placeholder-BevVKfay.d.mts} +1 -1
  412. package/dist/{placeholder-CVBv5z8k.d.mts.map → placeholder-BevVKfay.d.mts.map} +1 -1
  413. package/dist/plugin-types.d.mts +1 -1
  414. package/dist/plugin-utils.d.mts +9 -9
  415. package/dist/plugins/adapt-sandbox-entry.d.mts +9 -9
  416. package/dist/plugins/adapt-sandbox-entry.mjs +2 -2
  417. package/dist/{preview-BfuRkVKW.mjs → preview-Dqv2hwXr.mjs} +2 -2
  418. package/dist/{preview-BfuRkVKW.mjs.map → preview-Dqv2hwXr.mjs.map} +1 -1
  419. package/dist/{public-url-BFVC2OTJ.mjs → public-url-D_zARuvZ.mjs} +1 -1
  420. package/dist/{public-url-BFVC2OTJ.mjs.map → public-url-D_zARuvZ.mjs.map} +1 -1
  421. package/dist/{query-CbUcI4Xk.mjs → query-Crm038Mc.mjs} +9 -9
  422. package/dist/{query-CbUcI4Xk.mjs.map → query-Crm038Mc.mjs.map} +1 -1
  423. package/dist/{rate-limit-C7hjdkS5.mjs → rate-limit-hRTBqmw1.mjs} +2 -2
  424. package/dist/{rate-limit-C7hjdkS5.mjs.map → rate-limit-hRTBqmw1.mjs.map} +1 -1
  425. package/dist/{redirect-B_q19j4v.mjs → redirect-C-OOkyku.mjs} +1 -1
  426. package/dist/{redirect-B_q19j4v.mjs.map → redirect-C-OOkyku.mjs.map} +1 -1
  427. package/dist/{redirects-CCbCqCCd.mjs → redirects-6Zg2SoYo.mjs} +8 -9
  428. package/dist/{redirects-CCbCqCCd.mjs.map → redirects-6Zg2SoYo.mjs.map} +1 -1
  429. package/dist/{redirects-DxVoR7PI.mjs → redirects-CP3TnTLO.mjs} +20 -14
  430. package/dist/redirects-CP3TnTLO.mjs.map +1 -0
  431. package/dist/{registry-brYh-rAT.mjs → registry-diMzD1Wf.mjs} +3 -3
  432. package/dist/{registry-brYh-rAT.mjs.map → registry-diMzD1Wf.mjs.map} +1 -1
  433. package/dist/{request-cache-D32LpnmI.mjs → request-cache-UwmBAiUK.mjs} +1 -1
  434. package/dist/{request-cache-D32LpnmI.mjs.map → request-cache-UwmBAiUK.mjs.map} +1 -1
  435. package/dist/{request-meta-7ByVLxB-.mjs → request-meta-DPechd0W.mjs} +2 -2
  436. package/dist/{request-meta-7ByVLxB-.mjs.map → request-meta-DPechd0W.mjs.map} +1 -1
  437. package/dist/{resolve-BqYMVG0D.mjs → resolve-B3NUUtVY.mjs} +1 -1
  438. package/dist/{resolve-BqYMVG0D.mjs.map → resolve-B3NUUtVY.mjs.map} +1 -1
  439. package/dist/{runner-DTdhuI9i.d.mts → runner-C8vcbvCe.d.mts} +2 -2
  440. package/dist/{runner-DTdhuI9i.d.mts.map → runner-C8vcbvCe.d.mts.map} +1 -1
  441. package/dist/runtime.d.mts +10 -10
  442. package/dist/runtime.mjs +1 -1
  443. package/dist/{schema-C1E70ug_.mjs → schema-BDOkd3OU.mjs} +4 -4
  444. package/dist/{schema-C1E70ug_.mjs.map → schema-BDOkd3OU.mjs.map} +1 -1
  445. package/dist/{search-B3SGZw91.mjs → search-Bs_J_EW-.mjs} +3 -3
  446. package/dist/{search-B3SGZw91.mjs.map → search-Bs_J_EW-.mjs.map} +1 -1
  447. package/dist/{secrets-ChPTmy9x.mjs → secrets-C8xmE6mR.mjs} +21 -11
  448. package/dist/secrets-C8xmE6mR.mjs.map +1 -0
  449. package/dist/{sections-D_lVzwRZ.mjs → sections-P0zuBlyz.mjs} +2 -2
  450. package/dist/{sections-D_lVzwRZ.mjs.map → sections-P0zuBlyz.mjs.map} +1 -1
  451. package/dist/seed/index.d.mts +2 -2
  452. package/dist/seed/index.mjs +14 -13
  453. package/dist/seo/index.d.mts +1 -1
  454. package/dist/seo/index.mjs +1 -1
  455. package/dist/{seo-D_LPkOtu.mjs → seo-CLhm-Fmb.mjs} +1 -1
  456. package/dist/{seo-D_LPkOtu.mjs.map → seo-CLhm-Fmb.mjs.map} +1 -1
  457. package/dist/{seo-B5e6y9Wk.mjs → seo-DpNgGQjF.mjs} +1 -1
  458. package/dist/{seo-B5e6y9Wk.mjs.map → seo-DpNgGQjF.mjs.map} +1 -1
  459. package/dist/{service-ChDcsTBs.mjs → service-CDQQnT8W.mjs} +2 -2
  460. package/dist/{service-ChDcsTBs.mjs.map → service-CDQQnT8W.mjs.map} +1 -1
  461. package/dist/{settings-DfxiWY_s.mjs → settings-BjBsmVAo.mjs} +10 -184
  462. package/dist/settings-BjBsmVAo.mjs.map +1 -0
  463. package/dist/{settings-Cv47v9u8.mjs → settings-sO0Fif4p.mjs} +2 -2
  464. package/dist/{settings-Cv47v9u8.mjs.map → settings-sO0Fif4p.mjs.map} +1 -1
  465. package/dist/{setup-complete-yvPE4OsP.mjs → setup-complete-CMMr-oZU.mjs} +1 -1
  466. package/dist/{setup-complete-yvPE4OsP.mjs.map → setup-complete-CMMr-oZU.mjs.map} +1 -1
  467. package/dist/{setup-nonce-C9aFzb94.mjs → setup-nonce-169xl4fV.mjs} +1 -1
  468. package/dist/{setup-nonce-C9aFzb94.mjs.map → setup-nonce-169xl4fV.mjs.map} +1 -1
  469. package/dist/single-flight-cache-C0UV1Npg.mjs +104 -0
  470. package/dist/single-flight-cache-C0UV1Npg.mjs.map +1 -0
  471. package/dist/{site-url-CnHlmAs9.mjs → site-url-vtsuOvSD.mjs} +1 -1
  472. package/dist/{site-url-CnHlmAs9.mjs.map → site-url-vtsuOvSD.mjs.map} +1 -1
  473. package/dist/{ssrf-BsVGIE0Z.mjs → ssrf-XO05Voq6.mjs} +1 -1
  474. package/dist/{ssrf-BsVGIE0Z.mjs.map → ssrf-XO05Voq6.mjs.map} +1 -1
  475. package/dist/status-2gZklYuj.mjs +30 -0
  476. package/dist/status-2gZklYuj.mjs.map +1 -0
  477. package/dist/storage/local.d.mts +1 -1
  478. package/dist/storage/local.mjs +2 -2
  479. package/dist/storage/s3.d.mts +1 -1
  480. package/dist/storage/s3.mjs +1 -1
  481. package/dist/{taxonomies-BdAmbOwx.mjs → taxonomies-BBxYA38v.mjs} +6 -6
  482. package/dist/{taxonomies-BdAmbOwx.mjs.map → taxonomies-BBxYA38v.mjs.map} +1 -1
  483. package/dist/{taxonomies-BILwiyGk.mjs → taxonomies-DuESHWKI.mjs} +2 -2
  484. package/dist/{taxonomies-BILwiyGk.mjs.map → taxonomies-DuESHWKI.mjs.map} +1 -1
  485. package/dist/{tokens-Bx2afeT-.mjs → tokens-DMkVjxrx.mjs} +1 -1
  486. package/dist/{tokens-Bx2afeT-.mjs.map → tokens-DMkVjxrx.mjs.map} +1 -1
  487. package/dist/{transport-CmpLD7W3.mjs → transport-1cIrOb1Y.mjs} +1 -1
  488. package/dist/{transport-CmpLD7W3.mjs.map → transport-1cIrOb1Y.mjs.map} +1 -1
  489. package/dist/{transport-B7PPP2CC.d.mts → transport-jdvsZEIt.d.mts} +1 -1
  490. package/dist/{transport-B7PPP2CC.d.mts.map → transport-jdvsZEIt.d.mts.map} +1 -1
  491. package/dist/{trusted-proxy-B4AfnoAp.mjs → trusted-proxy-CHp41Fjj.mjs} +1 -1
  492. package/dist/{trusted-proxy-B4AfnoAp.mjs.map → trusted-proxy-CHp41Fjj.mjs.map} +1 -1
  493. package/dist/{types-BFgrqwSk.d.mts → types-BFgYtuKd.d.mts} +1 -1
  494. package/dist/{types-BFgrqwSk.d.mts.map → types-BFgYtuKd.d.mts.map} +1 -1
  495. package/dist/{types-DZk_y-MU.mjs → types-BIduXPJk.mjs} +1 -1
  496. package/dist/{types-DZk_y-MU.mjs.map → types-BIduXPJk.mjs.map} +1 -1
  497. package/dist/{types-DTniiNto.d.mts → types-BTnnBYVX.d.mts} +2 -2
  498. package/dist/{types-DTniiNto.d.mts.map → types-BTnnBYVX.d.mts.map} +1 -1
  499. package/dist/{types-BUUVn1zr.d.mts → types-Bzfk2yC8.d.mts} +1 -1
  500. package/dist/{types-BUUVn1zr.d.mts.map → types-Bzfk2yC8.d.mts.map} +1 -1
  501. package/dist/{types-BH8-30hc.d.mts → types-CkEuk-Zr.d.mts} +1 -1
  502. package/dist/{types-BH8-30hc.d.mts.map → types-CkEuk-Zr.d.mts.map} +1 -1
  503. package/dist/{types-CPAPl93j.d.mts → types-DO7whVYU.d.mts} +2 -2
  504. package/dist/{types-CPAPl93j.d.mts.map → types-DO7whVYU.d.mts.map} +1 -1
  505. package/dist/{types-S15DXXNi.d.mts → types-DdkL6fyv.d.mts} +1 -1
  506. package/dist/{types-S15DXXNi.d.mts.map → types-DdkL6fyv.d.mts.map} +1 -1
  507. package/dist/{types-DpFmlNyB.mjs → types-DejCHqWT.mjs} +1 -1
  508. package/dist/{types-DpFmlNyB.mjs.map → types-DejCHqWT.mjs.map} +1 -1
  509. package/dist/{types-BPzXTV9x.d.mts → types-Del0VMij.d.mts} +1 -1
  510. package/dist/{types-BPzXTV9x.d.mts.map → types-Del0VMij.d.mts.map} +1 -1
  511. package/dist/{types-D4kUqbHh.d.mts → types-u_XxjbS8.d.mts} +1 -1
  512. package/dist/{types-D4kUqbHh.d.mts.map → types-u_XxjbS8.d.mts.map} +1 -1
  513. package/dist/{utils-C4Ih4DML.mjs → utils-C4M981Br.mjs} +1 -1
  514. package/dist/{utils-C4Ih4DML.mjs.map → utils-C4M981Br.mjs.map} +1 -1
  515. package/dist/{validate-Bz4vqcX1.mjs → validate-DGhQPXzI.mjs} +2 -2
  516. package/dist/{validate-Bz4vqcX1.mjs.map → validate-DGhQPXzI.mjs.map} +1 -1
  517. package/dist/{validate-CNwkPWzz.d.mts → validate-cJOiOvT2.d.mts} +5 -5
  518. package/dist/{validate-CNwkPWzz.d.mts.map → validate-cJOiOvT2.d.mts.map} +1 -1
  519. package/dist/{validation-DgGTJm3u.mjs → validation-DVHjPM1M.mjs} +5 -5
  520. package/dist/{validation-DgGTJm3u.mjs.map → validation-DVHjPM1M.mjs.map} +1 -1
  521. package/dist/version-BOjj_cfz.mjs +7 -0
  522. package/dist/{version-D-5txk2m.mjs.map → version-BOjj_cfz.mjs.map} +1 -1
  523. package/dist/{widgets-DZfmAbE4.mjs → widgets-Ci6hLwfO.mjs} +4 -4
  524. package/dist/{widgets-DZfmAbE4.mjs.map → widgets-Ci6hLwfO.mjs.map} +1 -1
  525. package/dist/{zod-generator-Djo_VHCt.mjs → zod-generator-CarzgPAu.mjs} +2 -2
  526. package/dist/{zod-generator-Djo_VHCt.mjs.map → zod-generator-CarzgPAu.mjs.map} +1 -1
  527. package/package.json +5 -5
  528. package/src/api/handlers/redirects.ts +24 -13
  529. package/src/api/schemas/redirects.ts +11 -4
  530. package/src/astro/integration/index.ts +44 -8
  531. package/src/astro/integration/routes.ts +46 -9
  532. package/src/astro/middleware/redirect.ts +12 -0
  533. package/src/bylines/field-defs-cache.ts +70 -20
  534. package/src/cli/commands/doctor.ts +1 -1
  535. package/src/config/secrets.ts +28 -14
  536. package/src/emdash-runtime.ts +5 -5
  537. package/src/redirects/status.ts +27 -0
  538. package/src/settings/index.ts +13 -13
  539. package/src/utils/{isolate-cache.ts → single-flight-cache.ts} +26 -21
  540. package/dist/byline-DUx48sJp.mjs.map +0 -1
  541. package/dist/redirects-DxVoR7PI.mjs.map +0 -1
  542. package/dist/secrets-ChPTmy9x.mjs.map +0 -1
  543. package/dist/settings-DfxiWY_s.mjs.map +0 -1
  544. package/dist/version-D-5txk2m.mjs +0 -7
  545. /package/dist/{api-tokens-Oq39ba-Z.mjs → api-tokens-C7ywRx7l.mjs} +0 -0
  546. /package/dist/{ssrf-BvgVcfNQ.mjs → ssrf-CRZGzjdL.mjs} +0 -0
  547. /package/dist/{types-CZI4E3qG.mjs → types-BoRm8-pp.mjs} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"zod-generator-Djo_VHCt.mjs","names":[],"sources":["../src/schema/zod-generator.ts"],"sourcesContent":["import { z, type ZodTypeAny } from \"zod\";\n\nimport { hashString } from \"../utils/hash.js\";\nimport type { Field, FieldType, CollectionWithFields } from \"./types.js\";\n\n/** Pattern to split on underscores, hyphens, and spaces for PascalCase conversion */\nconst PASCAL_CASE_SPLIT_PATTERN = /[_\\-\\s]+/;\n\n/**\n * Generate a Zod schema from a collection's field definitions\n *\n * This allows runtime validation of content based on dynamically\n * defined schemas stored in D1.\n */\nexport function generateZodSchema(\n\tcollection: CollectionWithFields,\n): z.ZodObject<Record<string, ZodTypeAny>> {\n\tconst shape: Record<string, ZodTypeAny> = {};\n\n\tfor (const field of collection.fields) {\n\t\tshape[field.slug] = generateFieldSchema(field);\n\t}\n\n\treturn z.object(shape);\n}\n\n/**\n * Generate Zod schema for a single field\n */\nexport function generateFieldSchema(field: Field): ZodTypeAny {\n\tlet schema = getBaseSchema(field.type, field);\n\n\t// Apply validation rules\n\tif (field.validation) {\n\t\tschema = applyValidation(schema, field);\n\t}\n\n\t// Apply required/optional. Non-required fields use `.nullish()` rather\n\t// than `.optional()` because the underlying SQLite columns are nullable\n\t// (see `SchemaRegistry.addFieldColumn` -- non-required fields are added\n\t// without `NOT NULL`). The admin re-sends what it loaded from the\n\t// server on autosave, so any field that's actually `null` in the DB\n\t// must round-trip cleanly through the validator. `.optional()` only\n\t// accepts `undefined`; `.nullish()` accepts both `undefined` and\n\t// `null`. (#867 — autosave failures on seeded entries.)\n\tif (!field.required) {\n\t\tschema = schema.nullish();\n\t}\n\n\t// Apply default value\n\tif (field.defaultValue !== undefined) {\n\t\tschema = schema.default(field.defaultValue);\n\t}\n\n\treturn schema;\n}\n\n/**\n * Get base Zod schema for a field type\n */\nfunction getBaseSchema(type: FieldType, field: Field): ZodTypeAny {\n\tswitch (type) {\n\t\tcase \"url\":\n\t\t\treturn z.string().url();\n\n\t\tcase \"string\":\n\t\tcase \"text\":\n\t\tcase \"slug\":\n\t\t\treturn z.string();\n\n\t\tcase \"number\":\n\t\t\treturn z.number();\n\n\t\tcase \"integer\":\n\t\t\treturn z.number().int();\n\n\t\tcase \"boolean\":\n\t\t\t// Boolean fields map to `INTEGER` columns (`FIELD_TYPE_TO_COLUMN`\n\t\t\t// in `schema/types.ts`) and `serializeValue` in\n\t\t\t// `database/repositories/content.ts` writes booleans as 0/1.\n\t\t\t// `deserializeValue` never converts them back, so reads return\n\t\t\t// numbers. Coerce the stored 0/1 shape here so a GET → POST\n\t\t\t// round-trip on a boolean field passes validation. Other inputs\n\t\t\t// (strings, other numbers) fall through to `z.boolean()` and\n\t\t\t// produce its standard rejection.\n\t\t\treturn z.preprocess((v) => (v === 0 || v === 1 ? Boolean(v) : v), z.boolean());\n\n\t\tcase \"datetime\":\n\t\t\treturn z.string().datetime().or(z.string().date());\n\n\t\tcase \"select\": {\n\t\t\tconst options = field.validation?.options;\n\t\t\tif (options && options.length > 0) {\n\t\t\t\tconst [first, ...rest] = options;\n\t\t\t\treturn z.enum([first, ...rest]);\n\t\t\t}\n\t\t\treturn z.string();\n\t\t}\n\n\t\tcase \"multiSelect\": {\n\t\t\tconst multiOptions = field.validation?.options;\n\t\t\tif (multiOptions && multiOptions.length > 0) {\n\t\t\t\tconst [first, ...rest] = multiOptions;\n\t\t\t\treturn z.array(z.enum([first, ...rest]));\n\t\t\t}\n\t\t\treturn z.array(z.string());\n\t\t}\n\n\t\tcase \"portableText\":\n\t\t\t// Portable Text is an array of blocks. We require `_type` because\n\t\t\t// renderers dispatch on it, but `_key` is intentionally optional:\n\t\t\t// it's a UI-layer concern that the editor regenerates on every\n\t\t\t// change (see `PortableTextEditor`), and the rest of this schema\n\t\t\t// uses `.passthrough()` for everything below the top level. Making\n\t\t\t// `_key` strictly required here was an accidentally tight invariant\n\t\t\t// that rejected any seed/import data not authored against the\n\t\t\t// editor (#867 — autosave failures on seeded template content).\n\t\t\treturn z.array(\n\t\t\t\tz\n\t\t\t\t\t.object({\n\t\t\t\t\t\t_type: z.string(),\n\t\t\t\t\t\t_key: z.string().optional(),\n\t\t\t\t\t})\n\t\t\t\t\t.passthrough(),\n\t\t\t);\n\n\t\tcase \"image\":\n\t\t\treturn z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tsrc: z.string().optional(),\n\t\t\t\talt: z.string().optional(),\n\t\t\t\twidth: z.number().optional(),\n\t\t\t\theight: z.number().optional(),\n\t\t\t\t/** Provider ID (e.g. \"local\", \"cloudflare-images\") */\n\t\t\t\tprovider: z.string().optional(),\n\t\t\t\t/** Admin-side preview URL for external providers (not persisted by plugins) */\n\t\t\t\tpreviewUrl: z.string().optional(),\n\t\t\t\t/** Provider-specific metadata; for local media this carries storageKey */\n\t\t\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t\t\t});\n\n\t\tcase \"file\":\n\t\t\treturn z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tsrc: z.string().optional(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\tmimeType: z.string().optional(),\n\t\t\t\tsize: z.number().optional(),\n\t\t\t\t/** Provider ID (e.g. \"local\", \"s3\") */\n\t\t\t\tprovider: z.string().optional(),\n\t\t\t\t/** Provider-specific metadata; for local media this carries storageKey */\n\t\t\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t\t\t});\n\n\t\tcase \"reference\":\n\t\t\treturn z.string(); // Reference ID\n\n\t\tcase \"json\":\n\t\t\treturn z.unknown();\n\n\t\tdefault:\n\t\t\treturn z.unknown();\n\t}\n}\n\n/**\n * Apply validation rules to a schema\n */\nfunction applyValidation(schema: ZodTypeAny, field: Field): ZodTypeAny {\n\tconst validation = field.validation;\n\tif (!validation) return schema;\n\n\t// String validations\n\tif (schema instanceof z.ZodString) {\n\t\tlet strSchema = schema;\n\t\tif (validation.minLength !== undefined) {\n\t\t\tstrSchema = strSchema.min(validation.minLength);\n\t\t}\n\t\tif (validation.maxLength !== undefined) {\n\t\t\tstrSchema = strSchema.max(validation.maxLength);\n\t\t}\n\t\tif (validation.pattern) {\n\t\t\tstrSchema = strSchema.regex(new RegExp(validation.pattern));\n\t\t}\n\t\treturn strSchema;\n\t}\n\n\t// Number validations\n\tif (schema instanceof z.ZodNumber) {\n\t\tlet numSchema = schema;\n\t\tif (validation.min !== undefined) {\n\t\t\tnumSchema = numSchema.min(validation.min);\n\t\t}\n\t\tif (validation.max !== undefined) {\n\t\t\tnumSchema = numSchema.max(validation.max);\n\t\t}\n\t\treturn numSchema;\n\t}\n\n\treturn schema;\n}\n\n/**\n * Schema cache to avoid regenerating schemas on every request\n */\nconst schemaCache = new Map<string, { schema: z.ZodObject<any>; version: string }>();\n\n/**\n * Get or generate a cached schema for a collection\n */\nexport function getCachedSchema(\n\tcollection: CollectionWithFields,\n\tversion?: string,\n): z.ZodObject<any> {\n\tconst cacheKey = collection.slug;\n\tconst cached = schemaCache.get(cacheKey);\n\n\t// If version matches, return cached schema\n\tif (cached && (!version || cached.version === version)) {\n\t\treturn cached.schema;\n\t}\n\n\t// Generate new schema\n\tconst schema = generateZodSchema(collection);\n\n\t// Cache it\n\tschemaCache.set(cacheKey, {\n\t\tschema,\n\t\tversion: version || collection.updatedAt,\n\t});\n\n\treturn schema;\n}\n\n/**\n * Invalidate cached schema for a collection\n */\nexport function invalidateSchemaCache(slug: string): void {\n\tschemaCache.delete(slug);\n}\n\n/**\n * Clear all cached schemas\n */\nexport function clearSchemaCache(): void {\n\tschemaCache.clear();\n}\n\n/**\n * Validate data against a collection's schema\n */\nexport function validateContent(\n\tcollection: CollectionWithFields,\n\tdata: unknown,\n): { success: true; data: unknown } | { success: false; errors: z.ZodError } {\n\tconst schema = getCachedSchema(collection);\n\n\tconst result = schema.safeParse(data);\n\n\tif (result.success) {\n\t\treturn { success: true, data: result.data };\n\t}\n\n\treturn { success: false, errors: result.error };\n}\n\n/**\n * Generate TypeScript interface from field definitions\n * Used by CLI `emdash types` to generate types\n */\nexport function generateTypeScript(collection: CollectionWithFields): string {\n\tconst interfaceName = getInterfaceName(collection);\n\tconst lines: string[] = [];\n\n\tlines.push(`export interface ${interfaceName} {`);\n\tlines.push(` id: string;`);\n\tlines.push(` slug: string | null;`);\n\tlines.push(` status: string;`);\n\n\tfor (const field of collection.fields) {\n\t\tconst tsType = fieldTypeToTypeScript(field);\n\t\tconst optional = field.required ? \"\" : \"?\";\n\t\tlines.push(` ${field.slug}${optional}: ${tsType};`);\n\t}\n\n\tlines.push(` createdAt: Date;`);\n\tlines.push(` updatedAt: Date;`);\n\tlines.push(` publishedAt: Date | null;`);\n\t// Bylines are eagerly loaded by getEmDashCollection/getEmDashEntry\n\tlines.push(` bylines?: ContentBylineCredit[];`);\n\t// Taxonomy terms are eagerly loaded by getEmDashCollection/getEmDashEntry,\n\t// keyed by taxonomy name (e.g. data.terms?.tag)\n\tlines.push(` terms?: Record<string, TaxonomyTerm[]>;`);\n\tlines.push(`}`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generate a complete types file with module augmentation\n * This produces emdash-env.d.ts content that provides typed query functions\n */\nexport function generateTypesFile(collections: CollectionWithFields[]): string {\n\tconst lines: string[] = [];\n\n\t// Header\n\tlines.push(`// Generated by EmDash on dev server start`);\n\tlines.push(`// Do not edit manually`);\n\tlines.push(``);\n\tlines.push(`/// <reference types=\"emdash/locals\" />`);\n\tlines.push(``);\n\n\t// Check if we need PortableTextBlock import\n\tconst needsPortableText = collections.some((c) =>\n\t\tc.fields.some((f) => f.type === \"portableText\"),\n\t);\n\n\t// Build imports - ContentBylineCredit and TaxonomyTerm are always needed\n\t// for the hydrated bylines/terms fields\n\tconst imports = [\"ContentBylineCredit\", \"TaxonomyTerm\"];\n\tif (needsPortableText) {\n\t\timports.push(\"PortableTextBlock\");\n\t}\n\tlines.push(`import type { ${imports.join(\", \")} } from \"emdash\";`);\n\tlines.push(``);\n\n\t// Generate individual interfaces\n\tfor (const collection of collections) {\n\t\tlines.push(generateTypeScript(collection));\n\t\tlines.push(``);\n\t}\n\n\t// Generate the Collections interface for module augmentation\n\tlines.push(`declare module \"emdash\" {`);\n\tlines.push(` interface EmDashCollections {`);\n\tfor (const collection of collections) {\n\t\tconst interfaceName = getInterfaceName(collection);\n\t\tlines.push(` ${collection.slug}: ${interfaceName};`);\n\t}\n\tlines.push(` }`);\n\tlines.push(`}`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generate schema hash for cache invalidation\n */\nexport async function generateSchemaHash(collections: CollectionWithFields[]): Promise<string> {\n\tconst str = JSON.stringify(\n\t\tcollections.map((c) => ({\n\t\t\tslug: c.slug,\n\t\t\tfields: c.fields.map((f) => ({\n\t\t\t\tslug: f.slug,\n\t\t\t\ttype: f.type,\n\t\t\t\trequired: f.required,\n\t\t\t\tvalidation: f.validation,\n\t\t\t})),\n\t\t})),\n\t);\n\treturn hashString(str);\n}\n\n/**\n * Map field type to TypeScript type\n */\nfunction fieldTypeToTypeScript(field: Field): string {\n\tswitch (field.type) {\n\t\tcase \"string\":\n\t\tcase \"text\":\n\t\tcase \"slug\":\n\t\tcase \"url\":\n\t\tcase \"datetime\":\n\t\t\treturn \"string\";\n\n\t\tcase \"number\":\n\t\tcase \"integer\":\n\t\t\treturn \"number\";\n\n\t\tcase \"boolean\":\n\t\t\treturn \"boolean\";\n\n\t\tcase \"select\":\n\t\t\tconst options = field.validation?.options;\n\t\t\tif (options && options.length > 0) {\n\t\t\t\treturn options.map((o) => `\"${o}\"`).join(\" | \");\n\t\t\t}\n\t\t\treturn \"string\";\n\n\t\tcase \"multiSelect\":\n\t\t\tconst multiOptions = field.validation?.options;\n\t\t\tif (multiOptions && multiOptions.length > 0) {\n\t\t\t\treturn `(${multiOptions.map((o) => `\"${o}\"`).join(\" | \")})[]`;\n\t\t\t}\n\t\t\treturn \"string[]\";\n\n\t\tcase \"portableText\":\n\t\t\treturn \"PortableTextBlock[]\";\n\n\t\tcase \"image\":\n\t\t\treturn \"{ id: string; src?: string; alt?: string; width?: number; height?: number; provider?: string; previewUrl?: string; meta?: Record<string, unknown> }\";\n\n\t\tcase \"file\":\n\t\t\treturn \"{ id: string; src?: string; filename?: string; mimeType?: string; size?: number; provider?: string; meta?: Record<string, unknown> }\";\n\n\t\tcase \"reference\":\n\t\t\t// Could be enhanced to include the referenced collection type\n\t\t\treturn \"string\";\n\n\t\tcase \"json\":\n\t\t\treturn \"unknown\";\n\n\t\tdefault:\n\t\t\treturn \"unknown\";\n\t}\n}\n\n/**\n * Convert string to PascalCase (handles slugs, spaces, etc.)\n */\nfunction pascalCase(str: string): string {\n\treturn str\n\t\t.split(PASCAL_CASE_SPLIT_PATTERN)\n\t\t.filter(Boolean)\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\"\");\n}\n\n/**\n * Simple singularization - handles common cases\n */\nfunction singularize(str: string): string {\n\tif (str.endsWith(\"ies\")) {\n\t\treturn str.slice(0, -3) + \"y\";\n\t}\n\tif (\n\t\tstr.endsWith(\"es\") &&\n\t\t(str.endsWith(\"sses\") || str.endsWith(\"xes\") || str.endsWith(\"ches\") || str.endsWith(\"shes\"))\n\t) {\n\t\treturn str.slice(0, -2);\n\t}\n\tif (str.endsWith(\"s\") && !str.endsWith(\"ss\")) {\n\t\treturn str.slice(0, -1);\n\t}\n\treturn str;\n}\n\n/**\n * Get the interface name for a collection\n */\nfunction getInterfaceName(collection: CollectionWithFields): string {\n\treturn pascalCase(collection.labelSingular || singularize(collection.slug));\n}\n"],"mappings":";;;;;;;;;;;;;AAMA,MAAM,4BAA4B;;;;;;;AAQlC,SAAgB,kBACf,YAC0C;CAC1C,MAAM,QAAoC,EAAE;AAE5C,MAAK,MAAM,SAAS,WAAW,OAC9B,OAAM,MAAM,QAAQ,oBAAoB,MAAM;AAG/C,QAAO,EAAE,OAAO,MAAM;;;;;AAMvB,SAAgB,oBAAoB,OAA0B;CAC7D,IAAI,SAAS,cAAc,MAAM,MAAM,MAAM;AAG7C,KAAI,MAAM,WACT,UAAS,gBAAgB,QAAQ,MAAM;AAWxC,KAAI,CAAC,MAAM,SACV,UAAS,OAAO,SAAS;AAI1B,KAAI,MAAM,iBAAiB,OAC1B,UAAS,OAAO,QAAQ,MAAM,aAAa;AAG5C,QAAO;;;;;AAMR,SAAS,cAAc,MAAiB,OAA0B;AACjE,SAAQ,MAAR;EACC,KAAK,MACJ,QAAO,EAAE,QAAQ,CAAC,KAAK;EAExB,KAAK;EACL,KAAK;EACL,KAAK,OACJ,QAAO,EAAE,QAAQ;EAElB,KAAK,SACJ,QAAO,EAAE,QAAQ;EAElB,KAAK,UACJ,QAAO,EAAE,QAAQ,CAAC,KAAK;EAExB,KAAK,UASJ,QAAO,EAAE,YAAY,MAAO,MAAM,KAAK,MAAM,IAAI,QAAQ,EAAE,GAAG,GAAI,EAAE,SAAS,CAAC;EAE/E,KAAK,WACJ,QAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC;EAEnD,KAAK,UAAU;GACd,MAAM,UAAU,MAAM,YAAY;AAClC,OAAI,WAAW,QAAQ,SAAS,GA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AAU,MAAM,YAAY;AAClC,OAAI,WAAW,QAAQ,SAAS,EAC/B,QAAO,QAAQ,KAAK,MAAM,IAAI,EAAE,GAAG,CAAC,KAAK,MAAM;AAEhD,UAAO;EAER,KAAK;GACJ,MAAM,eAAe,MAAM,YAAY;AACvC,OAAI,gBAAgB,aAAa,SAAS,EACzC,QAAO,IAAI,aAAa,KAAK,MAAM,IAAI,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC;AAE1D,UAAO;EAER,KAAK,eACJ,QAAO;EAER,KAAK,QACJ,QAAO;EAER,KAAK,OACJ,QAAO;EAER,KAAK,YAEJ,QAAO;EAER,KAAK,OACJ,QAAO;EAER,QACC,QAAO;;;;;;AAOV,SAAS,WAAW,KAAqB;AACxC,QAAO,IACL,MAAM,0BAA0B,CAChC,OAAO,QAAQ,CACf,KAAK,SAAS,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE,CAAC,aAAa,CAAC,CACzE,KAAK,GAAG;;;;;AAMX,SAAS,YAAY,KAAqB;AACzC,KAAI,IAAI,SAAS,MAAM,CACtB,QAAO,IAAI,MAAM,GAAG,GAAG,GAAG;AAE3B,KACC,IAAI,SAAS,KAAK,KACjB,IAAI,SAAS,OAAO,IAAI,IAAI,SAAS,MAAM,IAAI,IAAI,SAAS,OAAO,IAAI,IAAI,SAAS,OAAO,EAE5F,QAAO,IAAI,MAAM,GAAG,GAAG;AAExB,KAAI,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,SAAS,KAAK,CAC3C,QAAO,IAAI,MAAM,GAAG,GAAG;AAExB,QAAO;;;;;AAMR,SAAS,iBAAiB,YAA0C;AACnE,QAAO,WAAW,WAAW,iBAAiB,YAAY,WAAW,KAAK,CAAC"}
1
+ {"version":3,"file":"zod-generator-CarzgPAu.mjs","names":[],"sources":["../src/schema/zod-generator.ts"],"sourcesContent":["import { z, type ZodTypeAny } from \"zod\";\n\nimport { hashString } from \"../utils/hash.js\";\nimport type { Field, FieldType, CollectionWithFields } from \"./types.js\";\n\n/** Pattern to split on underscores, hyphens, and spaces for PascalCase conversion */\nconst PASCAL_CASE_SPLIT_PATTERN = /[_\\-\\s]+/;\n\n/**\n * Generate a Zod schema from a collection's field definitions\n *\n * This allows runtime validation of content based on dynamically\n * defined schemas stored in D1.\n */\nexport function generateZodSchema(\n\tcollection: CollectionWithFields,\n): z.ZodObject<Record<string, ZodTypeAny>> {\n\tconst shape: Record<string, ZodTypeAny> = {};\n\n\tfor (const field of collection.fields) {\n\t\tshape[field.slug] = generateFieldSchema(field);\n\t}\n\n\treturn z.object(shape);\n}\n\n/**\n * Generate Zod schema for a single field\n */\nexport function generateFieldSchema(field: Field): ZodTypeAny {\n\tlet schema = getBaseSchema(field.type, field);\n\n\t// Apply validation rules\n\tif (field.validation) {\n\t\tschema = applyValidation(schema, field);\n\t}\n\n\t// Apply required/optional. Non-required fields use `.nullish()` rather\n\t// than `.optional()` because the underlying SQLite columns are nullable\n\t// (see `SchemaRegistry.addFieldColumn` -- non-required fields are added\n\t// without `NOT NULL`). The admin re-sends what it loaded from the\n\t// server on autosave, so any field that's actually `null` in the DB\n\t// must round-trip cleanly through the validator. `.optional()` only\n\t// accepts `undefined`; `.nullish()` accepts both `undefined` and\n\t// `null`. (#867 — autosave failures on seeded entries.)\n\tif (!field.required) {\n\t\tschema = schema.nullish();\n\t}\n\n\t// Apply default value\n\tif (field.defaultValue !== undefined) {\n\t\tschema = schema.default(field.defaultValue);\n\t}\n\n\treturn schema;\n}\n\n/**\n * Get base Zod schema for a field type\n */\nfunction getBaseSchema(type: FieldType, field: Field): ZodTypeAny {\n\tswitch (type) {\n\t\tcase \"url\":\n\t\t\treturn z.string().url();\n\n\t\tcase \"string\":\n\t\tcase \"text\":\n\t\tcase \"slug\":\n\t\t\treturn z.string();\n\n\t\tcase \"number\":\n\t\t\treturn z.number();\n\n\t\tcase \"integer\":\n\t\t\treturn z.number().int();\n\n\t\tcase \"boolean\":\n\t\t\t// Boolean fields map to `INTEGER` columns (`FIELD_TYPE_TO_COLUMN`\n\t\t\t// in `schema/types.ts`) and `serializeValue` in\n\t\t\t// `database/repositories/content.ts` writes booleans as 0/1.\n\t\t\t// `deserializeValue` never converts them back, so reads return\n\t\t\t// numbers. Coerce the stored 0/1 shape here so a GET → POST\n\t\t\t// round-trip on a boolean field passes validation. Other inputs\n\t\t\t// (strings, other numbers) fall through to `z.boolean()` and\n\t\t\t// produce its standard rejection.\n\t\t\treturn z.preprocess((v) => (v === 0 || v === 1 ? Boolean(v) : v), z.boolean());\n\n\t\tcase \"datetime\":\n\t\t\treturn z.string().datetime().or(z.string().date());\n\n\t\tcase \"select\": {\n\t\t\tconst options = field.validation?.options;\n\t\t\tif (options && options.length > 0) {\n\t\t\t\tconst [first, ...rest] = options;\n\t\t\t\treturn z.enum([first, ...rest]);\n\t\t\t}\n\t\t\treturn z.string();\n\t\t}\n\n\t\tcase \"multiSelect\": {\n\t\t\tconst multiOptions = field.validation?.options;\n\t\t\tif (multiOptions && multiOptions.length > 0) {\n\t\t\t\tconst [first, ...rest] = multiOptions;\n\t\t\t\treturn z.array(z.enum([first, ...rest]));\n\t\t\t}\n\t\t\treturn z.array(z.string());\n\t\t}\n\n\t\tcase \"portableText\":\n\t\t\t// Portable Text is an array of blocks. We require `_type` because\n\t\t\t// renderers dispatch on it, but `_key` is intentionally optional:\n\t\t\t// it's a UI-layer concern that the editor regenerates on every\n\t\t\t// change (see `PortableTextEditor`), and the rest of this schema\n\t\t\t// uses `.passthrough()` for everything below the top level. Making\n\t\t\t// `_key` strictly required here was an accidentally tight invariant\n\t\t\t// that rejected any seed/import data not authored against the\n\t\t\t// editor (#867 — autosave failures on seeded template content).\n\t\t\treturn z.array(\n\t\t\t\tz\n\t\t\t\t\t.object({\n\t\t\t\t\t\t_type: z.string(),\n\t\t\t\t\t\t_key: z.string().optional(),\n\t\t\t\t\t})\n\t\t\t\t\t.passthrough(),\n\t\t\t);\n\n\t\tcase \"image\":\n\t\t\treturn z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tsrc: z.string().optional(),\n\t\t\t\talt: z.string().optional(),\n\t\t\t\twidth: z.number().optional(),\n\t\t\t\theight: z.number().optional(),\n\t\t\t\t/** Provider ID (e.g. \"local\", \"cloudflare-images\") */\n\t\t\t\tprovider: z.string().optional(),\n\t\t\t\t/** Admin-side preview URL for external providers (not persisted by plugins) */\n\t\t\t\tpreviewUrl: z.string().optional(),\n\t\t\t\t/** Provider-specific metadata; for local media this carries storageKey */\n\t\t\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t\t\t});\n\n\t\tcase \"file\":\n\t\t\treturn z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tsrc: z.string().optional(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\tmimeType: z.string().optional(),\n\t\t\t\tsize: z.number().optional(),\n\t\t\t\t/** Provider ID (e.g. \"local\", \"s3\") */\n\t\t\t\tprovider: z.string().optional(),\n\t\t\t\t/** Provider-specific metadata; for local media this carries storageKey */\n\t\t\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t\t\t});\n\n\t\tcase \"reference\":\n\t\t\treturn z.string(); // Reference ID\n\n\t\tcase \"json\":\n\t\t\treturn z.unknown();\n\n\t\tdefault:\n\t\t\treturn z.unknown();\n\t}\n}\n\n/**\n * Apply validation rules to a schema\n */\nfunction applyValidation(schema: ZodTypeAny, field: Field): ZodTypeAny {\n\tconst validation = field.validation;\n\tif (!validation) return schema;\n\n\t// String validations\n\tif (schema instanceof z.ZodString) {\n\t\tlet strSchema = schema;\n\t\tif (validation.minLength !== undefined) {\n\t\t\tstrSchema = strSchema.min(validation.minLength);\n\t\t}\n\t\tif (validation.maxLength !== undefined) {\n\t\t\tstrSchema = strSchema.max(validation.maxLength);\n\t\t}\n\t\tif (validation.pattern) {\n\t\t\tstrSchema = strSchema.regex(new RegExp(validation.pattern));\n\t\t}\n\t\treturn strSchema;\n\t}\n\n\t// Number validations\n\tif (schema instanceof z.ZodNumber) {\n\t\tlet numSchema = schema;\n\t\tif (validation.min !== undefined) {\n\t\t\tnumSchema = numSchema.min(validation.min);\n\t\t}\n\t\tif (validation.max !== undefined) {\n\t\t\tnumSchema = numSchema.max(validation.max);\n\t\t}\n\t\treturn numSchema;\n\t}\n\n\treturn schema;\n}\n\n/**\n * Schema cache to avoid regenerating schemas on every request\n */\nconst schemaCache = new Map<string, { schema: z.ZodObject<any>; version: string }>();\n\n/**\n * Get or generate a cached schema for a collection\n */\nexport function getCachedSchema(\n\tcollection: CollectionWithFields,\n\tversion?: string,\n): z.ZodObject<any> {\n\tconst cacheKey = collection.slug;\n\tconst cached = schemaCache.get(cacheKey);\n\n\t// If version matches, return cached schema\n\tif (cached && (!version || cached.version === version)) {\n\t\treturn cached.schema;\n\t}\n\n\t// Generate new schema\n\tconst schema = generateZodSchema(collection);\n\n\t// Cache it\n\tschemaCache.set(cacheKey, {\n\t\tschema,\n\t\tversion: version || collection.updatedAt,\n\t});\n\n\treturn schema;\n}\n\n/**\n * Invalidate cached schema for a collection\n */\nexport function invalidateSchemaCache(slug: string): void {\n\tschemaCache.delete(slug);\n}\n\n/**\n * Clear all cached schemas\n */\nexport function clearSchemaCache(): void {\n\tschemaCache.clear();\n}\n\n/**\n * Validate data against a collection's schema\n */\nexport function validateContent(\n\tcollection: CollectionWithFields,\n\tdata: unknown,\n): { success: true; data: unknown } | { success: false; errors: z.ZodError } {\n\tconst schema = getCachedSchema(collection);\n\n\tconst result = schema.safeParse(data);\n\n\tif (result.success) {\n\t\treturn { success: true, data: result.data };\n\t}\n\n\treturn { success: false, errors: result.error };\n}\n\n/**\n * Generate TypeScript interface from field definitions\n * Used by CLI `emdash types` to generate types\n */\nexport function generateTypeScript(collection: CollectionWithFields): string {\n\tconst interfaceName = getInterfaceName(collection);\n\tconst lines: string[] = [];\n\n\tlines.push(`export interface ${interfaceName} {`);\n\tlines.push(` id: string;`);\n\tlines.push(` slug: string | null;`);\n\tlines.push(` status: string;`);\n\n\tfor (const field of collection.fields) {\n\t\tconst tsType = fieldTypeToTypeScript(field);\n\t\tconst optional = field.required ? \"\" : \"?\";\n\t\tlines.push(` ${field.slug}${optional}: ${tsType};`);\n\t}\n\n\tlines.push(` createdAt: Date;`);\n\tlines.push(` updatedAt: Date;`);\n\tlines.push(` publishedAt: Date | null;`);\n\t// Bylines are eagerly loaded by getEmDashCollection/getEmDashEntry\n\tlines.push(` bylines?: ContentBylineCredit[];`);\n\t// Taxonomy terms are eagerly loaded by getEmDashCollection/getEmDashEntry,\n\t// keyed by taxonomy name (e.g. data.terms?.tag)\n\tlines.push(` terms?: Record<string, TaxonomyTerm[]>;`);\n\tlines.push(`}`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generate a complete types file with module augmentation\n * This produces emdash-env.d.ts content that provides typed query functions\n */\nexport function generateTypesFile(collections: CollectionWithFields[]): string {\n\tconst lines: string[] = [];\n\n\t// Header\n\tlines.push(`// Generated by EmDash on dev server start`);\n\tlines.push(`// Do not edit manually`);\n\tlines.push(``);\n\tlines.push(`/// <reference types=\"emdash/locals\" />`);\n\tlines.push(``);\n\n\t// Check if we need PortableTextBlock import\n\tconst needsPortableText = collections.some((c) =>\n\t\tc.fields.some((f) => f.type === \"portableText\"),\n\t);\n\n\t// Build imports - ContentBylineCredit and TaxonomyTerm are always needed\n\t// for the hydrated bylines/terms fields\n\tconst imports = [\"ContentBylineCredit\", \"TaxonomyTerm\"];\n\tif (needsPortableText) {\n\t\timports.push(\"PortableTextBlock\");\n\t}\n\tlines.push(`import type { ${imports.join(\", \")} } from \"emdash\";`);\n\tlines.push(``);\n\n\t// Generate individual interfaces\n\tfor (const collection of collections) {\n\t\tlines.push(generateTypeScript(collection));\n\t\tlines.push(``);\n\t}\n\n\t// Generate the Collections interface for module augmentation\n\tlines.push(`declare module \"emdash\" {`);\n\tlines.push(` interface EmDashCollections {`);\n\tfor (const collection of collections) {\n\t\tconst interfaceName = getInterfaceName(collection);\n\t\tlines.push(` ${collection.slug}: ${interfaceName};`);\n\t}\n\tlines.push(` }`);\n\tlines.push(`}`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generate schema hash for cache invalidation\n */\nexport async function generateSchemaHash(collections: CollectionWithFields[]): Promise<string> {\n\tconst str = JSON.stringify(\n\t\tcollections.map((c) => ({\n\t\t\tslug: c.slug,\n\t\t\tfields: c.fields.map((f) => ({\n\t\t\t\tslug: f.slug,\n\t\t\t\ttype: f.type,\n\t\t\t\trequired: f.required,\n\t\t\t\tvalidation: f.validation,\n\t\t\t})),\n\t\t})),\n\t);\n\treturn hashString(str);\n}\n\n/**\n * Map field type to TypeScript type\n */\nfunction fieldTypeToTypeScript(field: Field): string {\n\tswitch (field.type) {\n\t\tcase \"string\":\n\t\tcase \"text\":\n\t\tcase \"slug\":\n\t\tcase \"url\":\n\t\tcase \"datetime\":\n\t\t\treturn \"string\";\n\n\t\tcase \"number\":\n\t\tcase \"integer\":\n\t\t\treturn \"number\";\n\n\t\tcase \"boolean\":\n\t\t\treturn \"boolean\";\n\n\t\tcase \"select\":\n\t\t\tconst options = field.validation?.options;\n\t\t\tif (options && options.length > 0) {\n\t\t\t\treturn options.map((o) => `\"${o}\"`).join(\" | \");\n\t\t\t}\n\t\t\treturn \"string\";\n\n\t\tcase \"multiSelect\":\n\t\t\tconst multiOptions = field.validation?.options;\n\t\t\tif (multiOptions && multiOptions.length > 0) {\n\t\t\t\treturn `(${multiOptions.map((o) => `\"${o}\"`).join(\" | \")})[]`;\n\t\t\t}\n\t\t\treturn \"string[]\";\n\n\t\tcase \"portableText\":\n\t\t\treturn \"PortableTextBlock[]\";\n\n\t\tcase \"image\":\n\t\t\treturn \"{ id: string; src?: string; alt?: string; width?: number; height?: number; provider?: string; previewUrl?: string; meta?: Record<string, unknown> }\";\n\n\t\tcase \"file\":\n\t\t\treturn \"{ id: string; src?: string; filename?: string; mimeType?: string; size?: number; provider?: string; meta?: Record<string, unknown> }\";\n\n\t\tcase \"reference\":\n\t\t\t// Could be enhanced to include the referenced collection type\n\t\t\treturn \"string\";\n\n\t\tcase \"json\":\n\t\t\treturn \"unknown\";\n\n\t\tdefault:\n\t\t\treturn \"unknown\";\n\t}\n}\n\n/**\n * Convert string to PascalCase (handles slugs, spaces, etc.)\n */\nfunction pascalCase(str: string): string {\n\treturn str\n\t\t.split(PASCAL_CASE_SPLIT_PATTERN)\n\t\t.filter(Boolean)\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\"\");\n}\n\n/**\n * Simple singularization - handles common cases\n */\nfunction singularize(str: string): string {\n\tif (str.endsWith(\"ies\")) {\n\t\treturn str.slice(0, -3) + \"y\";\n\t}\n\tif (\n\t\tstr.endsWith(\"es\") &&\n\t\t(str.endsWith(\"sses\") || str.endsWith(\"xes\") || str.endsWith(\"ches\") || str.endsWith(\"shes\"))\n\t) {\n\t\treturn str.slice(0, -2);\n\t}\n\tif (str.endsWith(\"s\") && !str.endsWith(\"ss\")) {\n\t\treturn str.slice(0, -1);\n\t}\n\treturn str;\n}\n\n/**\n * Get the interface name for a collection\n */\nfunction getInterfaceName(collection: CollectionWithFields): string {\n\treturn pascalCase(collection.labelSingular || singularize(collection.slug));\n}\n"],"mappings":";;;;;;;;;;;;;AAMA,MAAM,4BAA4B;;;;;;;AAQlC,SAAgB,kBACf,YAC0C;CAC1C,MAAM,QAAoC,EAAE;AAE5C,MAAK,MAAM,SAAS,WAAW,OAC9B,OAAM,MAAM,QAAQ,oBAAoB,MAAM;AAG/C,QAAO,EAAE,OAAO,MAAM;;;;;AAMvB,SAAgB,oBAAoB,OAA0B;CAC7D,IAAI,SAAS,cAAc,MAAM,MAAM,MAAM;AAG7C,KAAI,MAAM,WACT,UAAS,gBAAgB,QAAQ,MAAM;AAWxC,KAAI,CAAC,MAAM,SACV,UAAS,OAAO,SAAS;AAI1B,KAAI,MAAM,iBAAiB,OAC1B,UAAS,OAAO,QAAQ,MAAM,aAAa;AAG5C,QAAO;;;;;AAMR,SAAS,cAA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AAE3B,KACC,IAAI,SAAS,KAAK,KACjB,IAAI,SAAS,OAAO,IAAI,IAAI,SAAS,MAAM,IAAI,IAAI,SAAS,OAAO,IAAI,IAAI,SAAS,OAAO,EAE5F,QAAO,IAAI,MAAM,GAAG,GAAG;AAExB,KAAI,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,SAAS,KAAK,CAC3C,QAAO,IAAI,MAAM,GAAG,GAAG;AAExB,QAAO;;;;;AAMR,SAAS,iBAAiB,YAA0C;AACnE,QAAO,WAAW,WAAW,iBAAiB,YAAY,WAAW,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emdash",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Astro-native CMS with WordPress migration support",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -218,9 +218,9 @@
218
218
  "upng-js": "^2.1.0",
219
219
  "zod": "^4.4.1",
220
220
  "@atcute/client": "^5.0.0",
221
- "@emdash-cms/admin": "0.20.0",
222
- "@emdash-cms/auth": "0.20.0",
223
- "@emdash-cms/gutenberg-to-portable-text": "0.20.0",
221
+ "@emdash-cms/admin": "0.21.0",
222
+ "@emdash-cms/gutenberg-to-portable-text": "0.21.0",
223
+ "@emdash-cms/auth": "0.21.0",
224
224
  "@emdash-cms/plugin-types": "0.1.0",
225
225
  "@emdash-cms/registry-client": "0.3.2"
226
226
  },
@@ -255,7 +255,7 @@
255
255
  "vite": "^6.0.0",
256
256
  "vitest": "^4.1.5",
257
257
  "zod-openapi": "^5.4.6",
258
- "@emdash-cms/blocks": "0.20.0"
258
+ "@emdash-cms/blocks": "0.21.0"
259
259
  },
260
260
  "repository": {
261
261
  "type": "git",
@@ -16,6 +16,7 @@ import type { FindManyResult } from "../../database/repositories/types.js";
16
16
  import type { Database } from "../../database/types.js";
17
17
  import { wouldCreateLoop, detectLoops, type RedirectEdge } from "../../redirects/loops.js";
18
18
  import { validatePattern, validateDestinationParams, isPattern } from "../../redirects/patterns.js";
19
+ import { isTerminalStatus } from "../../redirects/status.js";
19
20
  import type { ApiResult } from "../types.js";
20
21
 
21
22
  // ---------------------------------------------------------------------------
@@ -70,7 +71,7 @@ export async function handleRedirectCreate(
70
71
  db: Kysely<Database>,
71
72
  input: {
72
73
  source: string;
73
- destination: string;
74
+ destination?: string;
74
75
  type?: number;
75
76
  enabled?: boolean;
76
77
  groupName?: string | null;
@@ -79,8 +80,14 @@ export async function handleRedirectCreate(
79
80
  try {
80
81
  const repo = new RedirectRepository(db);
81
82
 
83
+ const type = input.type ?? 301;
84
+ // Terminal statuses (410 Gone / 451) are served directly and have no
85
+ // destination — skip the destination/loop checks for them.
86
+ const terminal = isTerminalStatus(type);
87
+ const destination = terminal ? "" : (input.destination ?? "");
88
+
82
89
  // Source and destination must differ
83
- if (input.source === input.destination) {
90
+ if (!terminal && input.source === destination) {
84
91
  return {
85
92
  success: false,
86
93
  error: {
@@ -102,12 +109,15 @@ export async function handleRedirectCreate(
102
109
  }
103
110
 
104
111
  // Validate destination params reference valid source params
105
- const destError = validateDestinationParams(input.source, input.destination);
106
- if (destError) {
107
- return {
108
- success: false,
109
- error: { code: "VALIDATION_ERROR", message: destError },
110
- };
112
+ // (terminal rules have no destination to interpolate)
113
+ if (!terminal) {
114
+ const destError = validateDestinationParams(input.source, destination);
115
+ if (destError) {
116
+ return {
117
+ success: false,
118
+ error: { code: "VALIDATION_ERROR", message: destError },
119
+ };
120
+ }
111
121
  }
112
122
  }
113
123
 
@@ -123,17 +133,18 @@ export async function handleRedirectCreate(
123
133
  };
124
134
  }
125
135
 
126
- // Check for redirect loops (skip if creating as disabled)
127
- if (input.enabled !== false) {
136
+ // Check for redirect loops (skip if creating as disabled, or terminal —
137
+ // a Gone rule has no destination, so it can't form a loop)
138
+ if (!terminal && input.enabled !== false) {
128
139
  const edges = toEdges(await repo.findAllEnabled());
129
- const loopPath = wouldCreateLoop(input.source, input.destination, edges);
140
+ const loopPath = wouldCreateLoop(input.source, destination, edges);
130
141
  if (loopPath) return loopError(loopPath);
131
142
  }
132
143
 
133
144
  const redirect = await repo.create({
134
145
  source: input.source,
135
- destination: input.destination,
136
- type: input.type ?? 301,
146
+ destination,
147
+ type,
137
148
  isPattern: sourceIsPattern,
138
149
  enabled: input.enabled ?? true,
139
150
  groupName: input.groupName ?? null,
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
 
3
+ import { isTerminalStatus, REDIRECT_RULE_STATUSES } from "../../redirects/status.js";
3
4
  import { cursorPaginationQuery } from "./common.js";
4
5
 
5
6
  // ---------------------------------------------------------------------------
@@ -9,8 +10,8 @@ import { cursorPaginationQuery } from "./common.js";
9
10
  const redirectType = z.coerce
10
11
  .number()
11
12
  .int()
12
- .refine((n) => [301, 302, 307, 308].includes(n), {
13
- message: "Redirect type must be 301, 302, 307, or 308",
13
+ .refine((n) => REDIRECT_RULE_STATUSES.includes(n), {
14
+ message: "Redirect type must be 301, 302, 307, 308, 410, or 451",
14
15
  });
15
16
 
16
17
  /** Matches CR or LF characters */
@@ -40,17 +41,23 @@ const urlPath = z
40
41
  export const createRedirectBody = z
41
42
  .object({
42
43
  source: urlPath,
43
- destination: urlPath,
44
+ // Optional: terminal statuses (410/451) have no destination. Redirect
45
+ // statuses require one — enforced by the refine below.
46
+ destination: z.union([urlPath, z.literal("")]).optional(),
44
47
  type: redirectType.optional().default(301),
45
48
  enabled: z.boolean().optional().default(true),
46
49
  groupName: z.string().nullish(),
47
50
  })
51
+ .refine((o) => isTerminalStatus(o.type ?? 301) || !!o.destination, {
52
+ message: "destination is required for redirect types (301, 302, 307, 308)",
53
+ path: ["destination"],
54
+ })
48
55
  .meta({ id: "CreateRedirectBody" });
49
56
 
50
57
  export const updateRedirectBody = z
51
58
  .object({
52
59
  source: urlPath.optional(),
53
- destination: urlPath.optional(),
60
+ destination: z.union([urlPath, z.literal("")]).optional(),
54
61
  type: redirectType.optional(),
55
62
  enabled: z.boolean().optional(),
56
63
  groupName: z.string().nullish(),
@@ -17,6 +17,7 @@ import type { AstroIntegration, AstroIntegrationLogger } from "astro";
17
17
  import { validateAllowedOrigins, validateOriginShape } from "../../auth/allowed-origins.js";
18
18
  import { INTERNAL_MEDIA_PREFIX } from "../../media/normalize.js";
19
19
  import type { ResolvedPlugin } from "../../plugins/types.js";
20
+ import { VERSION } from "../../version.js";
20
21
  import { local } from "../storage/adapters.js";
21
22
  import { notoSans } from "./font-provider.js";
22
23
  import {
@@ -155,15 +156,24 @@ const cyan = (s: string) => `\x1b[36m${s}\x1b[39m`;
155
156
  function printBanner(_logger: AstroIntegrationLogger): void {
156
157
  const banner = `
157
158
 
158
- ${bold(cyan("— E M D A S H —"))}
159
+ ${bold(cyan("— E M D A S H —"))} ${dim(`v${VERSION}`)}
159
160
  `;
160
161
  console.log(banner);
161
162
  }
162
163
 
163
- /** Print route injection summary */
164
- function printRoutesSummary(_logger: AstroIntegrationLogger): void {
165
- console.log(`\n ${dim("›")} Admin UI ${cyan("/_emdash/admin")}`);
166
- console.log(` ${dim("›")} API ${cyan("/_emdash/api/*")}`);
164
+ /**
165
+ * Print dev-server route info with absolute (clickable) URLs, including the
166
+ * dev-bypass shortcut that skips passkey auth. Dev only -- the dev-bypass
167
+ * endpoint returns 403 in production.
168
+ */
169
+ function printDevServerInfo(baseUrl: string, mcpEnabled: boolean): void {
170
+ const devBypassUrl = `${baseUrl}/_emdash/api/setup/dev-bypass?redirect=/_emdash/admin`;
171
+ console.log(`\n ${dim("›")} Admin UI ${cyan(`${baseUrl}/_emdash/admin`)}`);
172
+ if (mcpEnabled) {
173
+ console.log(` ${dim("›")} MCP server ${cyan(`${baseUrl}/_emdash/api/mcp`)}`);
174
+ }
175
+ console.log(` ${dim("›")} Dev bypass ${cyan(devBypassUrl)}`);
176
+ console.log(` ${dim("Skips passkey setup/auth and signs you in as a dev admin")}`);
167
177
  console.log("");
168
178
  }
169
179
 
@@ -298,6 +308,10 @@ export function emdash(config: EmDashConfig = {}): AstroIntegration {
298
308
  // Check if auth is an AuthDescriptor (has entrypoint) indicating external auth
299
309
  const useExternalAuth = !!(resolvedConfig.auth && "entrypoint" in resolvedConfig.auth);
300
310
 
311
+ // Captured in astro:config:setup so the astro:server:setup hook can tell
312
+ // whether we're running `astro dev` (where the dev-bypass shortcut applies).
313
+ let astroCommand: "dev" | "build" | "preview" | "sync" | undefined;
314
+
301
315
  return {
302
316
  name: "emdash",
303
317
  hooks: {
@@ -309,6 +323,7 @@ export function emdash(config: EmDashConfig = {}): AstroIntegration {
309
323
  config: astroConfig,
310
324
  command,
311
325
  }) => {
326
+ astroCommand = command;
312
327
  printBanner(logger);
313
328
  // Capture the host's Astro version so the runtime can expose it
314
329
  // to the admin and the registry install gate for `env:astro`
@@ -345,7 +360,9 @@ export function emdash(config: EmDashConfig = {}): AstroIntegration {
345
360
  const securityConfig: Record<string, unknown> = {
346
361
  checkOrigin: false,
347
362
  ...(resolvedConfig.siteUrl
348
- ? { allowedDomains: [{ hostname: new URL(resolvedConfig.siteUrl).hostname }] }
363
+ ? {
364
+ allowedDomains: [{ hostname: new URL(resolvedConfig.siteUrl).hostname }],
365
+ }
349
366
  : {}),
350
367
  };
351
368
 
@@ -413,7 +430,7 @@ export function emdash(config: EmDashConfig = {}): AstroIntegration {
413
430
  });
414
431
 
415
432
  // Inject all core routes
416
- injectCoreRoutes(injectRoute);
433
+ injectCoreRoutes(injectRoute, { srcDir: astroConfig.srcDir });
417
434
 
418
435
  // Inject routes from pluggable auth providers (authProviders config)
419
436
  if (resolvedConfig.authProviders?.length) {
@@ -473,9 +490,28 @@ export function emdash(config: EmDashConfig = {}): AstroIntegration {
473
490
  order: "pre",
474
491
  });
475
492
 
476
- printRoutesSummary(logger);
493
+ // Route info is printed with absolute, clickable URLs once the
494
+ // dev server is listening (see astro:server:setup), since the
495
+ // port isn't known yet here. Nothing useful to print for build.
477
496
  },
478
497
  "astro:server:setup": ({ server, logger }) => {
498
+ // Print route info with absolute, clickable URLs once the server
499
+ // is listening. Only in `astro dev` -- the dev-bypass shortcut is
500
+ // dev-only and the port is unknown until now.
501
+ if (astroCommand === "dev") {
502
+ server.httpServer?.once("listening", () => {
503
+ const address = server.httpServer?.address();
504
+ if (!address || typeof address === "string") return;
505
+ let host = address.address;
506
+ if (host === "::1" || host === "::" || host === "0.0.0.0") {
507
+ host = "localhost";
508
+ } else if (address.family === "IPv6") {
509
+ host = `[${host}]`;
510
+ }
511
+ printDevServerInfo(`http://${host}:${address.port}`, resolvedConfig.mcp !== false);
512
+ });
513
+ }
514
+
479
515
  // Generate types once the server is listening.
480
516
  // The endpoint returns the types content; we write the file here
481
517
  // (in Node) because workerd has no real filesystem access.
@@ -4,6 +4,7 @@
4
4
  * Defines and injects all EmDash routes into the Astro application.
5
5
  */
6
6
 
7
+ import { existsSync } from "node:fs";
7
8
  import { createRequire } from "node:module";
8
9
  import { dirname, resolve } from "node:path";
9
10
  import { fileURLToPath } from "node:url";
@@ -41,10 +42,42 @@ function resolveRoute(route: string): string {
41
42
  /** Route injection function type */
42
43
  type InjectRoute = (route: { pattern: string; entrypoint: string }) => void;
43
44
 
45
+ interface InjectCoreRoutesOptions {
46
+ srcDir?: URL;
47
+ }
48
+
49
+ const ROUTE_OVERRIDE_EXTENSIONS = [
50
+ ".astro",
51
+ ".js",
52
+ ".ts",
53
+ ".jsx",
54
+ ".tsx",
55
+ ".mjs",
56
+ ".mts",
57
+ ".md",
58
+ ".mdx",
59
+ ".html",
60
+ ];
61
+
62
+ /**
63
+ * Detect whether the host site defines its own root-level public route file.
64
+ */
65
+ export function hasUserDefinedPublicRoute(srcDir: URL, basename: string): boolean {
66
+ const srcDirPath = fileURLToPath(srcDir);
67
+ return ROUTE_OVERRIDE_EXTENSIONS.some(
68
+ (extension) =>
69
+ existsSync(resolve(srcDirPath, "pages", `${basename}${extension}`)) ||
70
+ existsSync(resolve(srcDirPath, "pages", basename, `index${extension}`)),
71
+ );
72
+ }
73
+
44
74
  /**
45
75
  * Injects all core EmDash routes.
46
76
  */
47
- export function injectCoreRoutes(injectRoute: InjectRoute): void {
77
+ export function injectCoreRoutes(
78
+ injectRoute: InjectRoute,
79
+ options: InjectCoreRoutesOptions = {},
80
+ ): void {
48
81
  // Inject admin shell route
49
82
  injectRoute({
50
83
  pattern: "/_emdash/admin/[...path]",
@@ -752,20 +785,24 @@ export function injectCoreRoutes(injectRoute: InjectRoute): void {
752
785
  });
753
786
 
754
787
  // SEO routes (public, at site root)
755
- injectRoute({
756
- pattern: "/sitemap.xml",
757
- entrypoint: resolveRoute("sitemap.xml.ts"),
758
- });
788
+ if (!options.srcDir || !hasUserDefinedPublicRoute(options.srcDir, "sitemap.xml")) {
789
+ injectRoute({
790
+ pattern: "/sitemap.xml",
791
+ entrypoint: resolveRoute("sitemap.xml.ts"),
792
+ });
793
+ }
759
794
 
760
795
  injectRoute({
761
796
  pattern: "/sitemap-[collection].xml",
762
797
  entrypoint: resolveRoute("sitemap-[collection].xml.ts"),
763
798
  });
764
799
 
765
- injectRoute({
766
- pattern: "/robots.txt",
767
- entrypoint: resolveRoute("robots.txt.ts"),
768
- });
800
+ if (!options.srcDir || !hasUserDefinedPublicRoute(options.srcDir, "robots.txt")) {
801
+ injectRoute({
802
+ pattern: "/robots.txt",
803
+ entrypoint: resolveRoute("robots.txt.ts"),
804
+ });
805
+ }
769
806
 
770
807
  // Setup wizard API routes
771
808
  injectRoute({
@@ -23,6 +23,7 @@ import {
23
23
  matchCachedPatterns,
24
24
  setCachedRedirects,
25
25
  } from "../../redirects/cache.js";
26
+ import { isTerminalStatus } from "../../redirects/status.js";
26
27
 
27
28
  /** Paths that should never be intercepted by redirects */
28
29
  const SKIP_PREFIXES = ["/_emdash", "/_image"];
@@ -80,6 +81,12 @@ export const onRequest = defineMiddleware(async (context, next) => {
80
81
  exact = cached.exact.get(alt);
81
82
  }
82
83
  if (exact) {
84
+ // Terminal statuses (410 Gone / 451): serve the status directly,
85
+ // with no Location header.
86
+ if (isTerminalStatus(exact.type)) {
87
+ repo.recordHit(exact.id).catch(() => {});
88
+ return new Response(null, { status: exact.type });
89
+ }
83
90
  const dest = exact.destination;
84
91
  if (dest.startsWith("//") || dest.startsWith("/\\")) return next();
85
92
  repo.recordHit(exact.id).catch(() => {});
@@ -91,6 +98,11 @@ export const onRequest = defineMiddleware(async (context, next) => {
91
98
  const patternMatch = matchCachedPatterns(cached.patterns, pathname);
92
99
  if (patternMatch) {
93
100
  const { redirect, destination } = patternMatch;
101
+ // Terminal statuses (410 Gone / 451): serve the status directly.
102
+ if (isTerminalStatus(redirect.type)) {
103
+ repo.recordHit(redirect.id).catch(() => {});
104
+ return new Response(null, { status: redirect.type });
105
+ }
94
106
  if (destination.startsWith("//") || destination.startsWith("/\\")) return next();
95
107
  repo.recordHit(redirect.id).catch(() => {});
96
108
  const code = isRedirectCode(redirect.type) ? redirect.type : 301;
@@ -8,8 +8,12 @@
8
8
  * but are read on every byline hydration (admin pages, content rendering,
9
9
  * API responses). Caching at the isolate level drops the SELECT-from-
10
10
  * `_emdash_byline_fields` from once-per-hydration to once-per-isolate-
11
- * after-bump. The cache holds a Promise (not the resolved value) so
12
- * concurrent cold-isolate readers share the in-flight query.
11
+ * after-bump. The cache holds the resolved *value* behind a reclaimable
12
+ * single-flight lock (see `utils/single-flight-cache.ts`), never an
13
+ * in-flight promise: concurrent cold-isolate readers coalesce onto one
14
+ * query by polling the published value, so a reader whose request is
15
+ * cancelled mid-query can never strand later byline hydrations on the
16
+ * isolate (the workerd never-settling-promise hazard that produced 524s).
13
17
  *
14
18
  * Stored on globalThis under `Symbol.for("emdash:byline-field-defs")` so
15
19
  * Vite SSR chunk duplication can't produce two independent caches (same
@@ -50,17 +54,23 @@
50
54
 
51
55
  import type { Kysely } from "kysely";
52
56
 
57
+ import { after } from "../after.js";
53
58
  import type { Database } from "../database/types.js";
54
59
  import { requestCached } from "../request-cache.js";
55
60
  import { getRequestContext } from "../request-context.js";
56
61
  import { BylineSchemaRegistry } from "../schema/byline-registry.js";
57
62
  import type { BylineFieldDefinition } from "../schema/types.js";
63
+ import { createInitLock, type InitLock, initWithLock } from "../utils/init-lock.js";
58
64
 
59
65
  interface FieldDefsHolder {
60
- /** In-flight or resolved defs promise for the cached version. Null until first read. */
61
- cached: Promise<BylineFieldDefinition[]> | null;
62
- /** Persisted-version value that `cached` was fetched against. */
66
+ /** Last resolved defs, valid only when `hasValue` is true. */
67
+ value: BylineFieldDefinition[] | null;
68
+ /** Presence flag, separate from `value` so an empty-array result still caches. */
69
+ hasValue: boolean;
70
+ /** Persisted-version value that `value` was fetched against. */
63
71
  cachedVersion: number;
72
+ /** Reclaimable single-flight lock so a cancelled owner can't wedge readers. */
73
+ lock: InitLock;
64
74
  }
65
75
 
66
76
  const HOLDER_KEY = Symbol.for("emdash:byline-field-defs");
@@ -69,7 +79,12 @@ const holder: FieldDefsHolder =
69
79
  // eslint-disable-next-line typescript/no-unsafe-type-assertion -- globalThis singleton pattern (see request-cache.ts)
70
80
  (g[HOLDER_KEY] as FieldDefsHolder | undefined) ??
71
81
  (() => {
72
- const h: FieldDefsHolder = { cached: null, cachedVersion: -1 };
82
+ const h: FieldDefsHolder = {
83
+ value: null,
84
+ hasValue: false,
85
+ cachedVersion: -1,
86
+ lock: createInitLock(),
87
+ };
73
88
  g[HOLDER_KEY] = h;
74
89
  return h;
75
90
  })();
@@ -77,6 +92,16 @@ const holder: FieldDefsHolder =
77
92
  const REQUEST_CACHE_KEY_VERSION = "byline-fields-version";
78
93
  const REQUEST_CACHE_KEY_DEFS_PREFIX = "byline-field-defs:";
79
94
 
95
+ /**
96
+ * Reclaim window for the single-flight lock: if an owner holds it past
97
+ * this without publishing (e.g. its request was cancelled and the
98
+ * anchored fetch hasn't completed yet), the next reader reclaims and
99
+ * refetches. `listFields` is a single fast SELECT, so this only needs to
100
+ * cover a genuinely slow/stranded query. Mutable solely so tests can
101
+ * shorten it; production never changes it.
102
+ */
103
+ let reclaimDeadlineMs = 10_000;
104
+
80
105
  /**
81
106
  * Read the persisted `options.byline_fields_version` counter. Cached for
82
107
  * the duration of the current request via `requestCached`. Returns `0`
@@ -107,19 +132,29 @@ export async function getBylineFieldDefs(db: Kysely<Database>): Promise<BylineFi
107
132
  if (isolated || dirty) {
108
133
  return new BylineSchemaRegistry(db).listFields();
109
134
  }
110
- if (holder.cached !== null && holder.cachedVersion === version) {
111
- return holder.cached;
112
- }
113
- const defs = new BylineSchemaRegistry(db).listFields().catch((error) => {
114
- if (holder.cached === defs) {
115
- holder.cached = null;
116
- holder.cachedVersion = -1;
117
- }
118
- throw error;
119
- });
120
- holder.cached = defs;
121
- holder.cachedVersion = version;
122
- return defs;
135
+ // Per-isolate single-flight cache keyed on the persisted version.
136
+ // Coalesce concurrent cold readers via the lock and read the
137
+ // published value; never await another request's in-flight promise
138
+ // (a cancelled owner would otherwise strand every later byline
139
+ // hydration on the isolate). The fetch is anchored so a cancelled
140
+ // originator still drives it to completion and populates the cache.
141
+ return initWithLock<BylineFieldDefinition[]>(
142
+ holder.lock,
143
+ () => (holder.hasValue && holder.cachedVersion === version ? holder.value : null),
144
+ (isCurrentClaim) =>
145
+ (async () => {
146
+ const defs = await new BylineSchemaRegistry(db).listFields();
147
+ // Publish only while still the current claim, and never
148
+ // regress over a newer version a concurrent reader stored.
149
+ if (isCurrentClaim() && version >= holder.cachedVersion) {
150
+ holder.value = defs;
151
+ holder.hasValue = true;
152
+ holder.cachedVersion = version;
153
+ }
154
+ return defs;
155
+ })(),
156
+ { deadlineMs: reclaimDeadlineMs, anchor: (promise) => after(() => promise) },
157
+ );
123
158
  });
124
159
  }
125
160
 
@@ -133,6 +168,21 @@ export async function getBylineFieldDefs(db: Kysely<Database>): Promise<BylineFi
133
168
  * coordination that lets other isolates see the change.
134
169
  */
135
170
  export function resetBylineFieldDefsCacheForTests(): void {
136
- holder.cached = null;
171
+ holder.value = null;
172
+ holder.hasValue = false;
137
173
  holder.cachedVersion = -1;
174
+ holder.lock.ownerStartedAt = null;
175
+ holder.lock.generation = 0;
176
+ reclaimDeadlineMs = 10_000;
177
+ }
178
+
179
+ /**
180
+ * Test-only: shorten the single-flight reclaim window so a "stranded
181
+ * owner" scenario can be exercised without waiting out the production
182
+ * deadline. Reset by `resetBylineFieldDefsCacheForTests`.
183
+ *
184
+ * @internal
185
+ */
186
+ export function setBylineFieldDefsReclaimDeadlineForTests(ms: number): void {
187
+ reclaimDeadlineMs = ms;
138
188
  }
@@ -124,7 +124,7 @@ async function checkDatabase(dbPath: string): Promise<CheckResult[]> {
124
124
  try {
125
125
  const usersResult = await sql<{
126
126
  count: number;
127
- }>`SELECT COUNT(id) as count FROM _emdash_users`.execute(db);
127
+ }>`SELECT COUNT(id) as count FROM users`.execute(db);
128
128
  const count = usersResult.rows[0]?.count ?? 0;
129
129
  results.push({
130
130
  name: "users",