emdash 1.4.0 → 1.5.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 (1916) hide show
  1. package/dist/action-token-CKphU6ur.mjs +26 -0
  2. package/dist/action-token-CKphU6ur.mjs.map +1 -0
  3. package/dist/activation-X5iMalte.mjs +387 -0
  4. package/dist/activation-X5iMalte.mjs.map +1 -0
  5. package/dist/adapters-DFsc9XjW.d.mts +173 -0
  6. package/dist/adapters-DFsc9XjW.d.mts.map +1 -0
  7. package/dist/after-B3AvMfBQ.mjs +50 -0
  8. package/dist/after-B3AvMfBQ.mjs.map +1 -0
  9. package/dist/allowed-origins-BFDNF-05.mjs +116 -0
  10. package/dist/allowed-origins-BFDNF-05.mjs.map +1 -0
  11. package/dist/api/route-utils.d.mts +4 -4
  12. package/dist/api/route-utils.d.mts.map +1 -1
  13. package/dist/api/route-utils.mjs +7 -64
  14. package/dist/api/route-utils.mjs.map +1 -1
  15. package/dist/api/schemas/index.d.mts +2 -2
  16. package/dist/api/schemas/index.mjs +7 -12
  17. package/dist/api-tokens-B-p5eI6J.mjs +9 -0
  18. package/dist/api-tokens-B-p5eI6J.mjs.map +1 -0
  19. package/dist/api-tokens-D27OQ0oQ.mjs +173 -0
  20. package/dist/api-tokens-D27OQ0oQ.mjs.map +1 -0
  21. package/dist/apply-Culv7QJl.mjs +1774 -0
  22. package/dist/apply-Culv7QJl.mjs.map +1 -0
  23. package/dist/approvals-oLE5G5jw.mjs +460 -0
  24. package/dist/approvals-oLE5G5jw.mjs.map +1 -0
  25. package/dist/artifact-fetch-ByK_1pck.mjs +659 -0
  26. package/dist/artifact-fetch-ByK_1pck.mjs.map +1 -0
  27. package/dist/artifacts-BXKMIV2F.mjs +323 -0
  28. package/dist/artifacts-BXKMIV2F.mjs.map +1 -0
  29. package/dist/astro/index.d.mts +17 -15
  30. package/dist/astro/index.d.mts.map +1 -1
  31. package/dist/astro/index.mjs +217 -24
  32. package/dist/astro/index.mjs.map +1 -1
  33. package/dist/astro/middleware/auth.d.mts +15 -13
  34. package/dist/astro/middleware/auth.d.mts.map +1 -1
  35. package/dist/astro/middleware/auth.mjs +59 -24
  36. package/dist/astro/middleware/auth.mjs.map +1 -1
  37. package/dist/astro/middleware/media-usage-write-fence.d.mts.map +1 -1
  38. package/dist/astro/middleware/media-usage-write-fence.mjs +5 -7
  39. package/dist/astro/middleware/media-usage-write-fence.mjs.map +1 -1
  40. package/dist/astro/middleware/redirect.d.mts.map +1 -1
  41. package/dist/astro/middleware/redirect.mjs +18 -26
  42. package/dist/astro/middleware/redirect.mjs.map +1 -1
  43. package/dist/astro/middleware/request-context.d.mts.map +1 -1
  44. package/dist/astro/middleware/request-context.mjs +122 -79
  45. package/dist/astro/middleware/request-context.mjs.map +1 -1
  46. package/dist/astro/middleware/setup.mjs +1 -1
  47. package/dist/astro/middleware.d.mts +15 -13
  48. package/dist/astro/middleware.d.mts.map +1 -1
  49. package/dist/astro/middleware.mjs +62 -158
  50. package/dist/astro/middleware.mjs.map +1 -1
  51. package/dist/astro/routes/PluginRegistry.d.mts +1 -5
  52. package/dist/astro/routes/PluginRegistry.d.mts.map +1 -1
  53. package/dist/astro/routes/PluginRegistry.mjs +11 -10
  54. package/dist/astro/routes/PluginRegistry.mjs.map +1 -1
  55. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +3 -18
  56. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs.map +1 -1
  57. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +3 -18
  58. package/dist/astro/routes/api/admin/allowed-domains/index.mjs.map +1 -1
  59. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +2 -8
  60. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs.map +1 -1
  61. package/dist/astro/routes/api/admin/api-tokens/index.mjs +4 -9
  62. package/dist/astro/routes/api/admin/api-tokens/index.mjs.map +1 -1
  63. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +3 -8
  64. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs.map +1 -1
  65. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +5 -21
  66. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs.map +1 -1
  67. package/dist/astro/routes/api/admin/byline-fields/index.mjs +5 -21
  68. package/dist/astro/routes/api/admin/byline-fields/index.mjs.map +1 -1
  69. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +5 -21
  70. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs.map +1 -1
  71. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +8 -32
  72. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs.map +1 -1
  73. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +8 -32
  74. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs.map +1 -1
  75. package/dist/astro/routes/api/admin/bylines/index.mjs +8 -31
  76. package/dist/astro/routes/api/admin/bylines/index.mjs.map +1 -1
  77. package/dist/astro/routes/api/admin/comments/_id_/status.d.mts.map +1 -1
  78. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +9 -25
  79. package/dist/astro/routes/api/admin/comments/_id_/status.mjs.map +1 -1
  80. package/dist/astro/routes/api/admin/comments/_id_.d.mts.map +1 -1
  81. package/dist/astro/routes/api/admin/comments/_id_.mjs +12 -12
  82. package/dist/astro/routes/api/admin/comments/_id_.mjs.map +1 -1
  83. package/dist/astro/routes/api/admin/comments/bulk.d.mts.map +1 -1
  84. package/dist/astro/routes/api/admin/comments/bulk.mjs +16 -25
  85. package/dist/astro/routes/api/admin/comments/bulk.mjs.map +1 -1
  86. package/dist/astro/routes/api/admin/comments/counts.mjs +3 -10
  87. package/dist/astro/routes/api/admin/comments/counts.mjs.map +1 -1
  88. package/dist/astro/routes/api/admin/comments/index.mjs +5 -23
  89. package/dist/astro/routes/api/admin/comments/index.mjs.map +1 -1
  90. package/dist/astro/routes/api/admin/core-update.mjs +160 -10
  91. package/dist/astro/routes/api/admin/core-update.mjs.map +1 -1
  92. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +4 -8
  93. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs.map +1 -1
  94. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +2 -6
  95. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs.map +1 -1
  96. package/dist/astro/routes/api/admin/media-usage/activation.mjs +6 -25
  97. package/dist/astro/routes/api/admin/media-usage/activation.mjs.map +1 -1
  98. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +6 -26
  99. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs.map +1 -1
  100. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +6 -26
  101. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs.map +1 -1
  102. package/dist/astro/routes/api/admin/media-usage/progress.mjs +4 -29
  103. package/dist/astro/routes/api/admin/media-usage/progress.mjs.map +1 -1
  104. package/dist/astro/routes/api/admin/media-usage/repair.mjs +5 -36
  105. package/dist/astro/routes/api/admin/media-usage/repair.mjs.map +1 -1
  106. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +6 -26
  107. package/dist/astro/routes/api/admin/media-usage/work/index.mjs.map +1 -1
  108. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +6 -26
  109. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs.map +1 -1
  110. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +3 -7
  111. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs.map +1 -1
  112. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +3 -7
  113. package/dist/astro/routes/api/admin/oauth-clients/index.mjs.map +1 -1
  114. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +4 -10
  115. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
  116. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +4 -10
  117. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
  118. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +3 -86
  119. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  120. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +4 -8
  121. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs.map +1 -1
  122. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +4 -85
  123. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
  124. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +5 -85
  125. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  126. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +9 -96
  127. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  128. package/dist/astro/routes/api/admin/plugins/index.mjs +3 -86
  129. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  130. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +3 -8
  131. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs.map +1 -1
  132. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +3 -85
  133. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  134. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +9 -96
  135. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  136. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +3 -85
  137. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  138. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +7 -85
  139. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  140. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +14 -97
  141. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  142. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +6 -10
  143. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
  144. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +11 -88
  145. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  146. package/dist/astro/routes/api/admin/plugins/registry/publisher-handle.mjs +4 -8
  147. package/dist/astro/routes/api/admin/plugins/registry/publisher-handle.mjs.map +1 -1
  148. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +8 -86
  149. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs.map +1 -1
  150. package/dist/astro/routes/api/admin/plugins/updates.mjs +7 -85
  151. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  152. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs +4 -8
  153. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs.map +1 -1
  154. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +3 -85
  155. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  156. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +3 -8
  157. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs.map +1 -1
  158. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +3 -85
  159. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  160. package/dist/astro/routes/api/admin/transfer/_...path_.mjs +1 -5
  161. package/dist/astro/routes/api/admin/transfer/_...path_.mjs.map +1 -1
  162. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs +6 -49
  163. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs.map +1 -1
  164. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs +6 -49
  165. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs.map +1 -1
  166. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs +8 -51
  167. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs.map +1 -1
  168. package/dist/astro/routes/api/admin/transfer/capabilities.mjs +8 -50
  169. package/dist/astro/routes/api/admin/transfer/capabilities.mjs.map +1 -1
  170. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs +7 -51
  171. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs.map +1 -1
  172. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs +8 -52
  173. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs.map +1 -1
  174. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs +8 -52
  175. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs.map +1 -1
  176. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs +7 -51
  177. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs.map +1 -1
  178. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs +8 -52
  179. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs.map +1 -1
  180. package/dist/astro/routes/api/admin/transfer/exports/index.mjs +9 -53
  181. package/dist/astro/routes/api/admin/transfer/exports/index.mjs.map +1 -1
  182. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs +7 -51
  183. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs.map +1 -1
  184. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs +7 -51
  185. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs.map +1 -1
  186. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs +9 -52
  187. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs.map +1 -1
  188. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs +7 -51
  189. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs.map +1 -1
  190. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs +10 -53
  191. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs.map +1 -1
  192. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs +8 -51
  193. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs.map +1 -1
  194. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs +7 -51
  195. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs.map +1 -1
  196. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs +9 -53
  197. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs.map +1 -1
  198. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs +7 -51
  199. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs.map +1 -1
  200. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs +7 -51
  201. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs.map +1 -1
  202. package/dist/astro/routes/api/admin/transfer/imports/index.mjs +11 -53
  203. package/dist/astro/routes/api/admin/transfer/imports/index.mjs.map +1 -1
  204. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +2 -6
  205. package/dist/astro/routes/api/admin/users/_id_/disable.mjs.map +1 -1
  206. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -5
  207. package/dist/astro/routes/api/admin/users/_id_/enable.mjs.map +1 -1
  208. package/dist/astro/routes/api/admin/users/_id_/index.mjs +4 -19
  209. package/dist/astro/routes/api/admin/users/_id_/index.mjs.map +1 -1
  210. package/dist/astro/routes/api/admin/users/_id_/send-recovery.d.mts.map +1 -1
  211. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +11 -10
  212. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs.map +1 -1
  213. package/dist/astro/routes/api/admin/users/index.mjs +3 -18
  214. package/dist/astro/routes/api/admin/users/index.mjs.map +1 -1
  215. package/dist/astro/routes/api/auth/dev-bypass.d.mts.map +1 -1
  216. package/dist/astro/routes/api/auth/dev-bypass.mjs +10 -7
  217. package/dist/astro/routes/api/auth/dev-bypass.mjs.map +1 -1
  218. package/dist/astro/routes/api/auth/handover.mjs +3 -9
  219. package/dist/astro/routes/api/auth/handover.mjs.map +1 -1
  220. package/dist/astro/routes/api/auth/invite/accept.mjs +1 -5
  221. package/dist/astro/routes/api/auth/invite/accept.mjs.map +1 -1
  222. package/dist/astro/routes/api/auth/invite/complete.d.mts.map +1 -1
  223. package/dist/astro/routes/api/auth/invite/complete.mjs +11 -26
  224. package/dist/astro/routes/api/auth/invite/complete.mjs.map +1 -1
  225. package/dist/astro/routes/api/auth/invite/index.d.mts.map +1 -1
  226. package/dist/astro/routes/api/auth/invite/index.mjs +13 -23
  227. package/dist/astro/routes/api/auth/invite/index.mjs.map +1 -1
  228. package/dist/astro/routes/api/auth/invite/register-options.d.mts.map +1 -1
  229. package/dist/astro/routes/api/auth/invite/register-options.mjs +9 -23
  230. package/dist/astro/routes/api/auth/invite/register-options.mjs.map +1 -1
  231. package/dist/astro/routes/api/auth/logout.mjs +2 -6
  232. package/dist/astro/routes/api/auth/logout.mjs.map +1 -1
  233. package/dist/astro/routes/api/auth/magic-link/send.d.mts.map +1 -1
  234. package/dist/astro/routes/api/auth/magic-link/send.mjs +15 -26
  235. package/dist/astro/routes/api/auth/magic-link/send.mjs.map +1 -1
  236. package/dist/astro/routes/api/auth/magic-link/verify.mjs +5 -20
  237. package/dist/astro/routes/api/auth/magic-link/verify.mjs.map +1 -1
  238. package/dist/astro/routes/api/auth/me.d.mts +3 -1
  239. package/dist/astro/routes/api/auth/me.d.mts.map +1 -1
  240. package/dist/astro/routes/api/auth/me.mjs +30 -30
  241. package/dist/astro/routes/api/auth/me.mjs.map +1 -1
  242. package/dist/astro/routes/api/auth/mode.mjs +2 -6
  243. package/dist/astro/routes/api/auth/mode.mjs.map +1 -1
  244. package/dist/astro/routes/api/auth/oauth/_provider_/callback.d.mts.map +1 -1
  245. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +6 -14
  246. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs.map +1 -1
  247. package/dist/astro/routes/api/auth/oauth/_provider_.d.mts.map +1 -1
  248. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +3 -4
  249. package/dist/astro/routes/api/auth/oauth/_provider_.mjs.map +1 -1
  250. package/dist/astro/routes/api/auth/passkey/_id_.mjs +3 -18
  251. package/dist/astro/routes/api/auth/passkey/_id_.mjs.map +1 -1
  252. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -5
  253. package/dist/astro/routes/api/auth/passkey/index.mjs.map +1 -1
  254. package/dist/astro/routes/api/auth/passkey/options.d.mts.map +1 -1
  255. package/dist/astro/routes/api/auth/passkey/options.mjs +12 -26
  256. package/dist/astro/routes/api/auth/passkey/options.mjs.map +1 -1
  257. package/dist/astro/routes/api/auth/passkey/register/options.d.mts.map +1 -1
  258. package/dist/astro/routes/api/auth/passkey/register/options.mjs +9 -23
  259. package/dist/astro/routes/api/auth/passkey/register/options.mjs.map +1 -1
  260. package/dist/astro/routes/api/auth/passkey/register/verify.d.mts.map +1 -1
  261. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +10 -24
  262. package/dist/astro/routes/api/auth/passkey/register/verify.mjs.map +1 -1
  263. package/dist/astro/routes/api/auth/passkey/verify.d.mts.map +1 -1
  264. package/dist/astro/routes/api/auth/passkey/verify.mjs +11 -26
  265. package/dist/astro/routes/api/auth/passkey/verify.mjs.map +1 -1
  266. package/dist/astro/routes/api/auth/signup/complete.d.mts.map +1 -1
  267. package/dist/astro/routes/api/auth/signup/complete.mjs +11 -26
  268. package/dist/astro/routes/api/auth/signup/complete.mjs.map +1 -1
  269. package/dist/astro/routes/api/auth/signup/request.d.mts.map +1 -1
  270. package/dist/astro/routes/api/auth/signup/request.mjs +9 -24
  271. package/dist/astro/routes/api/auth/signup/request.mjs.map +1 -1
  272. package/dist/astro/routes/api/auth/signup/verify.mjs +1 -5
  273. package/dist/astro/routes/api/auth/signup/verify.mjs.map +1 -1
  274. package/dist/astro/routes/api/calendar.mjs +5 -19
  275. package/dist/astro/routes/api/calendar.mjs.map +1 -1
  276. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +5 -19
  277. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs.map +1 -1
  278. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +8 -26
  279. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs.map +1 -1
  280. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -6
  281. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs.map +1 -1
  282. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +14 -24
  283. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs.map +1 -1
  284. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +3 -6
  285. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs.map +1 -1
  286. package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts.map +1 -1
  287. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +9 -24
  288. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs.map +1 -1
  289. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +3 -7
  290. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs.map +1 -1
  291. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs +2 -13
  292. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs.map +1 -1
  293. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +13 -43
  294. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs.map +1 -1
  295. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +7 -23
  296. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
  297. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +5 -45
  298. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
  299. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +5 -45
  300. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
  301. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +4 -7
  302. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs.map +1 -1
  303. package/dist/astro/routes/api/content/_collection_/_id_/revisions/editors.d.mts +8 -0
  304. package/dist/astro/routes/api/content/_collection_/_id_/revisions/editors.d.mts.map +1 -0
  305. package/dist/astro/routes/api/content/_collection_/_id_/revisions/editors.mjs +16 -0
  306. package/dist/astro/routes/api/content/_collection_/_id_/revisions/editors.mjs.map +1 -0
  307. package/dist/astro/routes/api/content/_collection_/_id_/revisions.d.mts +2 -1
  308. package/dist/astro/routes/api/content/_collection_/_id_/revisions.d.mts.map +1 -1
  309. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +28 -7
  310. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs.map +1 -1
  311. package/dist/astro/routes/api/content/_collection_/_id_/room.d.mts +8 -0
  312. package/dist/astro/routes/api/content/_collection_/_id_/room.d.mts.map +1 -0
  313. package/dist/astro/routes/api/content/_collection_/_id_/room.mjs +29 -0
  314. package/dist/astro/routes/api/content/_collection_/_id_/room.mjs.map +1 -0
  315. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +11 -24
  316. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
  317. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.d.mts.map +1 -1
  318. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +32 -38
  319. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  320. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -6
  321. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs.map +1 -1
  322. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +7 -23
  323. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs.map +1 -1
  324. package/dist/astro/routes/api/content/_collection_/_id_.d.mts.map +1 -1
  325. package/dist/astro/routes/api/content/_collection_/_id_.mjs +28 -52
  326. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  327. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -6
  328. package/dist/astro/routes/api/content/_collection_/authors.mjs.map +1 -1
  329. package/dist/astro/routes/api/content/_collection_/index.mjs +5 -19
  330. package/dist/astro/routes/api/content/_collection_/index.mjs.map +1 -1
  331. package/dist/astro/routes/api/content/_collection_/trash.mjs +4 -19
  332. package/dist/astro/routes/api/content/_collection_/trash.mjs.map +1 -1
  333. package/dist/astro/routes/api/dashboard.mjs +141 -21
  334. package/dist/astro/routes/api/dashboard.mjs.map +1 -1
  335. package/dist/astro/routes/api/dev/emails.mjs +2 -6
  336. package/dist/astro/routes/api/dev/emails.mjs.map +1 -1
  337. package/dist/astro/routes/api/dev/scheduled-tasks.mjs +4 -125
  338. package/dist/astro/routes/api/dev/scheduled-tasks.mjs.map +1 -1
  339. package/dist/astro/routes/api/health.mjs +3 -7
  340. package/dist/astro/routes/api/health.mjs.map +1 -1
  341. package/dist/astro/routes/api/import/probe.d.mts +4 -4
  342. package/dist/astro/routes/api/import/probe.mjs +6 -37
  343. package/dist/astro/routes/api/import/probe.mjs.map +1 -1
  344. package/dist/astro/routes/api/import/wordpress/analyze.d.mts +5 -3
  345. package/dist/astro/routes/api/import/wordpress/analyze.d.mts.map +1 -1
  346. package/dist/astro/routes/api/import/wordpress/analyze.mjs +9 -9
  347. package/dist/astro/routes/api/import/wordpress/analyze.mjs.map +1 -1
  348. package/dist/astro/routes/api/import/wordpress/execute.d.mts +32 -15
  349. package/dist/astro/routes/api/import/wordpress/execute.d.mts.map +1 -1
  350. package/dist/astro/routes/api/import/wordpress/execute.mjs +146 -45
  351. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  352. package/dist/astro/routes/api/import/wordpress/media.d.mts +16 -14
  353. package/dist/astro/routes/api/import/wordpress/media.d.mts.map +1 -1
  354. package/dist/astro/routes/api/import/wordpress/media.mjs +11 -27
  355. package/dist/astro/routes/api/import/wordpress/media.mjs.map +1 -1
  356. package/dist/astro/routes/api/import/wordpress/prepare.mjs +8 -24
  357. package/dist/astro/routes/api/import/wordpress/prepare.mjs.map +1 -1
  358. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +16 -14
  359. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts.map +1 -1
  360. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +12 -39
  361. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs.map +1 -1
  362. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  363. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +6 -37
  364. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs.map +1 -1
  365. package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
  366. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +16 -14
  367. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts.map +1 -1
  368. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +187 -58
  369. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  370. package/dist/astro/routes/api/manifest.d.mts.map +1 -1
  371. package/dist/astro/routes/api/manifest.mjs +32 -13
  372. package/dist/astro/routes/api/manifest.mjs.map +1 -1
  373. package/dist/astro/routes/api/mcp.mjs +130 -125
  374. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  375. package/dist/astro/routes/api/media/_id_/confirm.d.mts.map +1 -1
  376. package/dist/astro/routes/api/media/_id_/confirm.mjs +50 -30
  377. package/dist/astro/routes/api/media/_id_/confirm.mjs.map +1 -1
  378. package/dist/astro/routes/api/media/_id_/replace.mjs +5 -20
  379. package/dist/astro/routes/api/media/_id_/replace.mjs.map +1 -1
  380. package/dist/astro/routes/api/media/_id_/upload.mjs +6 -10
  381. package/dist/astro/routes/api/media/_id_/upload.mjs.map +1 -1
  382. package/dist/astro/routes/api/media/_id_/usage.mjs +6 -38
  383. package/dist/astro/routes/api/media/_id_/usage.mjs.map +1 -1
  384. package/dist/astro/routes/api/media/_id_.mjs +5 -36
  385. package/dist/astro/routes/api/media/_id_.mjs.map +1 -1
  386. package/dist/astro/routes/api/media/asset/_id_/_filename_.d.mts.map +1 -1
  387. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs +4 -7
  388. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs.map +1 -1
  389. package/dist/astro/routes/api/media/file/_...key_.d.mts.map +1 -1
  390. package/dist/astro/routes/api/media/file/_...key_.mjs +5 -12
  391. package/dist/astro/routes/api/media/file/_...key_.mjs.map +1 -1
  392. package/dist/astro/routes/api/media/folders/_id_.mjs +5 -20
  393. package/dist/astro/routes/api/media/folders/_id_.mjs.map +1 -1
  394. package/dist/astro/routes/api/media/folders/index.mjs +5 -20
  395. package/dist/astro/routes/api/media/folders/index.mjs.map +1 -1
  396. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -6
  397. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs.map +1 -1
  398. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -6
  399. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs.map +1 -1
  400. package/dist/astro/routes/api/media/providers/index.mjs +2 -6
  401. package/dist/astro/routes/api/media/providers/index.mjs.map +1 -1
  402. package/dist/astro/routes/api/media/upload-url.mjs +8 -23
  403. package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
  404. package/dist/astro/routes/api/media.mjs +20 -43
  405. package/dist/astro/routes/api/media.mjs.map +1 -1
  406. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +8 -26
  407. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  408. package/dist/astro/routes/api/menus/_name_/items.mjs +8 -26
  409. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  410. package/dist/astro/routes/api/menus/_name_/reorder.mjs +8 -26
  411. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  412. package/dist/astro/routes/api/menus/_name_/translations.mjs +7 -26
  413. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  414. package/dist/astro/routes/api/menus/_name_.mjs +8 -26
  415. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  416. package/dist/astro/routes/api/menus/index.mjs +8 -26
  417. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  418. package/dist/astro/routes/api/oauth/authorize.mjs +5 -6
  419. package/dist/astro/routes/api/oauth/authorize.mjs.map +1 -1
  420. package/dist/astro/routes/api/oauth/device/authorize.d.mts.map +1 -1
  421. package/dist/astro/routes/api/oauth/device/authorize.mjs +3 -9
  422. package/dist/astro/routes/api/oauth/device/authorize.mjs.map +1 -1
  423. package/dist/astro/routes/api/oauth/device/code.mjs +6 -13
  424. package/dist/astro/routes/api/oauth/device/code.mjs.map +1 -1
  425. package/dist/astro/routes/api/oauth/device/token.mjs +5 -12
  426. package/dist/astro/routes/api/oauth/device/token.mjs.map +1 -1
  427. package/dist/astro/routes/api/oauth/register.mjs +4 -9
  428. package/dist/astro/routes/api/oauth/register.mjs.map +1 -1
  429. package/dist/astro/routes/api/oauth/token/refresh.mjs +3 -9
  430. package/dist/astro/routes/api/oauth/token/refresh.mjs.map +1 -1
  431. package/dist/astro/routes/api/oauth/token/revoke.mjs +3 -9
  432. package/dist/astro/routes/api/oauth/token/revoke.mjs.map +1 -1
  433. package/dist/astro/routes/api/oauth/token.mjs +4 -9
  434. package/dist/astro/routes/api/oauth/token.mjs.map +1 -1
  435. package/dist/astro/routes/api/openapi.json.mjs +15 -31
  436. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  437. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +2 -13
  438. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs.map +1 -1
  439. package/dist/astro/routes/api/redirects/404s/index.mjs +5 -28
  440. package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
  441. package/dist/astro/routes/api/redirects/404s/summary.mjs +5 -28
  442. package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
  443. package/dist/astro/routes/api/redirects/_id_.mjs +6 -29
  444. package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
  445. package/dist/astro/routes/api/redirects/index.mjs +6 -29
  446. package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
  447. package/dist/astro/routes/api/relations/_id_/index.mjs +5 -45
  448. package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
  449. package/dist/astro/routes/api/relations/index.mjs +5 -45
  450. package/dist/astro/routes/api/relations/index.mjs.map +1 -1
  451. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -6
  452. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs.map +1 -1
  453. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +7 -23
  454. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs.map +1 -1
  455. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs +5 -86
  456. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs.map +1 -1
  457. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs +5 -86
  458. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs.map +1 -1
  459. package/dist/astro/routes/api/schema/block-types/index.mjs +5 -86
  460. package/dist/astro/routes/api/schema/block-types/index.mjs.map +1 -1
  461. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +5 -86
  462. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  463. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +5 -86
  464. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  465. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +5 -86
  466. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  467. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +5 -86
  468. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  469. package/dist/astro/routes/api/schema/collections/index.mjs +5 -86
  470. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  471. package/dist/astro/routes/api/schema/collections/reorder.mjs +5 -86
  472. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  473. package/dist/astro/routes/api/schema/index.mjs +4 -22
  474. package/dist/astro/routes/api/schema/index.mjs.map +1 -1
  475. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +5 -86
  476. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  477. package/dist/astro/routes/api/schema/orphans/index.mjs +3 -85
  478. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  479. package/dist/astro/routes/api/search/enable.mjs +5 -27
  480. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  481. package/dist/astro/routes/api/search/index.mjs +4 -26
  482. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  483. package/dist/astro/routes/api/search/rebuild.mjs +5 -27
  484. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  485. package/dist/astro/routes/api/search/stats.mjs +3 -15
  486. package/dist/astro/routes/api/search/stats.mjs.map +1 -1
  487. package/dist/astro/routes/api/search/suggest.mjs +4 -26
  488. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  489. package/dist/astro/routes/api/sections/_slug_.mjs +5 -26
  490. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  491. package/dist/astro/routes/api/sections/index.mjs +5 -26
  492. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  493. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +4 -10
  494. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs.map +1 -1
  495. package/dist/astro/routes/api/settings/backups/archives/index.mjs +3 -10
  496. package/dist/astro/routes/api/settings/backups/archives/index.mjs.map +1 -1
  497. package/dist/astro/routes/api/settings/backups/export.mjs +4 -10
  498. package/dist/astro/routes/api/settings/backups/export.mjs.map +1 -1
  499. package/dist/astro/routes/api/settings/backups/index.mjs +5 -11
  500. package/dist/astro/routes/api/settings/backups/index.mjs.map +1 -1
  501. package/dist/astro/routes/api/settings/domain-notify.d.mts.map +1 -1
  502. package/dist/astro/routes/api/settings/domain-notify.mjs +14 -14
  503. package/dist/astro/routes/api/settings/domain-notify.mjs.map +1 -1
  504. package/dist/astro/routes/api/settings/domain.mjs +8 -27
  505. package/dist/astro/routes/api/settings/domain.mjs.map +1 -1
  506. package/dist/astro/routes/api/settings/email.d.mts +2 -1
  507. package/dist/astro/routes/api/settings/email.d.mts.map +1 -1
  508. package/dist/astro/routes/api/settings/email.mjs +124 -16
  509. package/dist/astro/routes/api/settings/email.mjs.map +1 -1
  510. package/dist/astro/routes/api/settings.mjs +7 -35
  511. package/dist/astro/routes/api/settings.mjs.map +1 -1
  512. package/dist/astro/routes/api/setup/admin-verify.d.mts.map +1 -1
  513. package/dist/astro/routes/api/setup/admin-verify.mjs +13 -29
  514. package/dist/astro/routes/api/setup/admin-verify.mjs.map +1 -1
  515. package/dist/astro/routes/api/setup/admin.d.mts.map +1 -1
  516. package/dist/astro/routes/api/setup/admin.mjs +10 -24
  517. package/dist/astro/routes/api/setup/admin.mjs.map +1 -1
  518. package/dist/astro/routes/api/setup/dev-bypass.d.mts.map +1 -1
  519. package/dist/astro/routes/api/setup/dev-bypass.mjs +13 -57
  520. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  521. package/dist/astro/routes/api/setup/dev-reset.mjs +2 -6
  522. package/dist/astro/routes/api/setup/dev-reset.mjs.map +1 -1
  523. package/dist/astro/routes/api/setup/index.mjs +14 -64
  524. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  525. package/dist/astro/routes/api/setup/status.mjs +3 -7
  526. package/dist/astro/routes/api/setup/status.mjs.map +1 -1
  527. package/dist/astro/routes/api/site/domain-proof.mjs +2 -21
  528. package/dist/astro/routes/api/site/domain-proof.mjs.map +1 -1
  529. package/dist/astro/routes/api/snapshot.mjs +6 -13
  530. package/dist/astro/routes/api/snapshot.mjs.map +1 -1
  531. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +7 -34
  532. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -1
  533. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +7 -34
  534. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
  535. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +8 -34
  536. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
  537. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +7 -34
  538. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
  539. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +5 -32
  540. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -1
  541. package/dist/astro/routes/api/taxonomies/_name_.mjs +8 -34
  542. package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -1
  543. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs +13 -46
  544. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs.map +1 -1
  545. package/dist/astro/routes/api/taxonomies/index.mjs +8 -34
  546. package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
  547. package/dist/astro/routes/api/themes/preview.mjs +4 -10
  548. package/dist/astro/routes/api/themes/preview.mjs.map +1 -1
  549. package/dist/astro/routes/api/typegen.mjs +3 -7
  550. package/dist/astro/routes/api/typegen.mjs.map +1 -1
  551. package/dist/astro/routes/api/visual-editing/action-token.mjs +3 -10
  552. package/dist/astro/routes/api/visual-editing/action-token.mjs.map +1 -1
  553. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs +3 -26
  554. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs.map +1 -1
  555. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs +1 -5
  556. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs.map +1 -1
  557. package/dist/astro/routes/api/well-known/auth.d.mts.map +1 -1
  558. package/dist/astro/routes/api/well-known/auth.mjs +4 -3
  559. package/dist/astro/routes/api/well-known/auth.mjs.map +1 -1
  560. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  561. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  562. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +8 -30
  563. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
  564. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +10 -31
  565. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
  566. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +9 -30
  567. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
  568. package/dist/astro/routes/api/widget-areas/_name_.mjs +7 -18
  569. package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
  570. package/dist/astro/routes/api/widget-areas/index.mjs +9 -30
  571. package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
  572. package/dist/astro/routes/api/widget-components.mjs +2 -6
  573. package/dist/astro/routes/api/widget-components.mjs.map +1 -1
  574. package/dist/astro/routes/robots.txt.d.mts.map +1 -1
  575. package/dist/astro/routes/robots.txt.mjs +6 -24
  576. package/dist/astro/routes/robots.txt.mjs.map +1 -1
  577. package/dist/astro/routes/sitemap-_collection_.xml.mjs +11 -25
  578. package/dist/astro/routes/sitemap-_collection_.xml.mjs.map +1 -1
  579. package/dist/astro/routes/sitemap.xml.d.mts.map +1 -1
  580. package/dist/astro/routes/sitemap.xml.mjs +5 -23
  581. package/dist/astro/routes/sitemap.xml.mjs.map +1 -1
  582. package/dist/astro/types.d.mts +45 -21
  583. package/dist/astro/types.d.mts.map +1 -1
  584. package/dist/audit-T3NRtoQ5.mjs +127 -0
  585. package/dist/audit-T3NRtoQ5.mjs.map +1 -0
  586. package/dist/auth/providers/github.d.mts +1 -1
  587. package/dist/auth/providers/google.d.mts +1 -1
  588. package/dist/auth/providers/microsoft.d.mts +1 -1
  589. package/dist/authoritative-records-Cd5BVXRs.mjs +5183 -0
  590. package/dist/authoritative-records-Cd5BVXRs.mjs.map +1 -0
  591. package/dist/authorize-B-4ogCQG.mjs +74 -0
  592. package/dist/authorize-B-4ogCQG.mjs.map +1 -0
  593. package/dist/backup-BQhg3MEK.mjs +246 -0
  594. package/dist/backup-BQhg3MEK.mjs.map +1 -0
  595. package/dist/base64-GXviT28w.mjs +63 -0
  596. package/dist/base64-GXviT28w.mjs.map +1 -0
  597. package/dist/block-types-BTzqdEZV.mjs +132 -0
  598. package/dist/block-types-BTzqdEZV.mjs.map +1 -0
  599. package/dist/block-values-DzZIh7WN.mjs +215 -0
  600. package/dist/block-values-DzZIh7WN.mjs.map +1 -0
  601. package/dist/byline--sweE_MZ.mjs +930 -0
  602. package/dist/byline--sweE_MZ.mjs.map +1 -0
  603. package/dist/byline-fields-Czdq4Yad.mjs +123 -0
  604. package/dist/byline-fields-Czdq4Yad.mjs.map +1 -0
  605. package/dist/byline-registry-Cr7kjrxM.mjs +406 -0
  606. package/dist/byline-registry-Cr7kjrxM.mjs.map +1 -0
  607. package/dist/bylines-DnuH3H8z.mjs +234 -0
  608. package/dist/bylines-DnuH3H8z.mjs.map +1 -0
  609. package/dist/bylines-txlwgzIK.mjs +150 -0
  610. package/dist/bylines-txlwgzIK.mjs.map +1 -0
  611. package/dist/cache-BjnpmIpb.mjs +151 -0
  612. package/dist/cache-BjnpmIpb.mjs.map +1 -0
  613. package/dist/canonical-Cb-rJGRU.mjs +174 -0
  614. package/dist/canonical-Cb-rJGRU.mjs.map +1 -0
  615. package/dist/capture-triggers-BZmIEdX2.mjs +362 -0
  616. package/dist/capture-triggers-BZmIEdX2.mjs.map +1 -0
  617. package/dist/challenge-store-B0PoBBqW.mjs +51 -0
  618. package/dist/challenge-store-B0PoBBqW.mjs.map +1 -0
  619. package/dist/checksum-CH9TyM-N.mjs +162 -0
  620. package/dist/checksum-CH9TyM-N.mjs.map +1 -0
  621. package/dist/chrome-tags-BocDVqqx.mjs +24 -0
  622. package/dist/chrome-tags-BocDVqqx.mjs.map +1 -0
  623. package/dist/chunks-DRnEstVb.mjs +25 -0
  624. package/dist/chunks-DRnEstVb.mjs.map +1 -0
  625. package/dist/cli/index.mjs +892 -93
  626. package/dist/cli/index.mjs.map +1 -1
  627. package/dist/client/cf-access.d.mts +1 -1
  628. package/dist/client/index.d.mts +70 -70
  629. package/dist/client/index.d.mts.map +1 -1
  630. package/dist/client/index.mjs +15 -6
  631. package/dist/client/index.mjs.map +1 -1
  632. package/dist/collection-slugs-cache-CYMrqHZ6.mjs +91 -0
  633. package/dist/collection-slugs-cache-CYMrqHZ6.mjs.map +1 -0
  634. package/dist/comment-BGeXmJ8F.mjs +335 -0
  635. package/dist/comment-BGeXmJ8F.mjs.map +1 -0
  636. package/dist/comment-reaction-ty-JEDYR.mjs +85 -0
  637. package/dist/comment-reaction-ty-JEDYR.mjs.map +1 -0
  638. package/dist/comments-ByrrLvZL.mjs +99 -0
  639. package/dist/comments-ByrrLvZL.mjs.map +1 -0
  640. package/dist/comments-DqhARoef.mjs +195 -0
  641. package/dist/comments-DqhARoef.mjs.map +1 -0
  642. package/dist/components-u2HE5Mu9.mjs +112 -0
  643. package/dist/components-u2HE5Mu9.mjs.map +1 -0
  644. package/dist/config-B4F2ttAZ.d.mts +7230 -0
  645. package/dist/config-B4F2ttAZ.d.mts.map +1 -0
  646. package/dist/config-BnrtMvHW.mjs +228 -0
  647. package/dist/config-BnrtMvHW.mjs.map +1 -0
  648. package/dist/config-DEse9gaE.d.mts +41 -0
  649. package/dist/config-DEse9gaE.d.mts.map +1 -0
  650. package/dist/connection-BaIVuaDX.mjs +36 -0
  651. package/dist/connection-BaIVuaDX.mjs.map +1 -0
  652. package/dist/content-Dxztag5t.mjs +2270 -0
  653. package/dist/content-Dxztag5t.mjs.map +1 -0
  654. package/dist/content-list-query-yYbBU-dB.d.mts +26 -0
  655. package/dist/content-list-query-yYbBU-dB.d.mts.map +1 -0
  656. package/dist/content-policy-Drm9sqdA.mjs +68 -0
  657. package/dist/content-policy-Drm9sqdA.mjs.map +1 -0
  658. package/dist/content-repair-2PdahlgZ.mjs +443 -0
  659. package/dist/content-repair-2PdahlgZ.mjs.map +1 -0
  660. package/dist/content-save-KMll0S7E.mjs +202 -0
  661. package/dist/content-save-KMll0S7E.mjs.map +1 -0
  662. package/dist/context-C3OZjexd.mjs +2225 -0
  663. package/dist/context-C3OZjexd.mjs.map +1 -0
  664. package/dist/credits-C8uXoWfN.mjs +110 -0
  665. package/dist/credits-C8uXoWfN.mjs.map +1 -0
  666. package/dist/cron-CrjBjDuy.mjs +310 -0
  667. package/dist/cron-CrjBjDuy.mjs.map +1 -0
  668. package/dist/db/index.d.mts +3 -3
  669. package/dist/db/index.mjs +1 -4
  670. package/dist/db/index.mjs.map +1 -1
  671. package/dist/db/libsql-migrations.d.mts +1 -1
  672. package/dist/db/libsql-migrations.mjs +2 -7
  673. package/dist/db/libsql-migrations.mjs.map +1 -1
  674. package/dist/db/libsql.d.mts +1 -1
  675. package/dist/db/postgres-migrations.d.mts +1 -1
  676. package/dist/db/postgres-migrations.mjs +2 -7
  677. package/dist/db/postgres-migrations.mjs.map +1 -1
  678. package/dist/db/postgres.d.mts +1 -1
  679. package/dist/db/sqlite-migrations.d.mts +1 -1
  680. package/dist/db/sqlite-migrations.mjs +2 -7
  681. package/dist/db/sqlite-migrations.mjs.map +1 -1
  682. package/dist/db/sqlite.d.mts +1 -1
  683. package/dist/db/sqlite.mjs +1 -1
  684. package/dist/default-DPoN3H5H.mjs +81 -0
  685. package/dist/default-DPoN3H5H.mjs.map +1 -0
  686. package/dist/deferred-tasks-uSx5qCFn.d.mts +10 -0
  687. package/dist/deferred-tasks-uSx5qCFn.d.mts.map +1 -0
  688. package/dist/deferred-tasks-yv85msJv.mjs +52 -0
  689. package/dist/deferred-tasks-yv85msJv.mjs.map +1 -0
  690. package/dist/destination-BNL1K7Mz.mjs +18 -0
  691. package/dist/destination-BNL1K7Mz.mjs.map +1 -0
  692. package/dist/dev-typegen-BVQAguf4.mjs +29 -0
  693. package/dist/dev-typegen-BVQAguf4.mjs.map +1 -0
  694. package/dist/device-flow-hT8lKWXq.mjs +519 -0
  695. package/dist/device-flow-hT8lKWXq.mjs.map +1 -0
  696. package/dist/dialect-helpers-DqUMP9fJ.mjs +350 -0
  697. package/dist/dialect-helpers-DqUMP9fJ.mjs.map +1 -0
  698. package/dist/digest-xYRiuW_E.mjs +194 -0
  699. package/dist/digest-xYRiuW_E.mjs.map +1 -0
  700. package/dist/direct-executor-CZ2SH1bq.mjs +117 -0
  701. package/dist/direct-executor-CZ2SH1bq.mjs.map +1 -0
  702. package/dist/dist-kxThYgdL.mjs +810 -0
  703. package/dist/dist-kxThYgdL.mjs.map +1 -0
  704. package/dist/email-console-CochjAlh.mjs +50 -0
  705. package/dist/email-console-CochjAlh.mjs.map +1 -0
  706. package/dist/email-locale-BoxaIPG8.mjs +25 -0
  707. package/dist/email-locale-BoxaIPG8.mjs.map +1 -0
  708. package/dist/email-smtp-BnHR_Ccx.mjs +643 -0
  709. package/dist/email-smtp-BnHR_Ccx.mjs.map +1 -0
  710. package/dist/emdash-runtime-CXsdCQnM.mjs +5262 -0
  711. package/dist/emdash-runtime-CXsdCQnM.mjs.map +1 -0
  712. package/dist/enrich-BReo_COC.mjs +203 -0
  713. package/dist/enrich-BReo_COC.mjs.map +1 -0
  714. package/dist/entry-lock-BfnhlRhC.mjs +207 -0
  715. package/dist/entry-lock-BfnhlRhC.mjs.map +1 -0
  716. package/dist/entry-lock-DsVhZcJN.mjs +1228 -0
  717. package/dist/entry-lock-DsVhZcJN.mjs.map +1 -0
  718. package/dist/entry-locks-D_kjygT1.mjs +173 -0
  719. package/dist/entry-locks-D_kjygT1.mjs.map +1 -0
  720. package/dist/env-types-CXI9uaMU.mjs +38 -0
  721. package/dist/env-types-CXI9uaMU.mjs.map +1 -0
  722. package/dist/error-DcDNU7hZ.mjs +92 -0
  723. package/dist/error-DcDNU7hZ.mjs.map +1 -0
  724. package/dist/errors-BYdjOimY.mjs +18 -0
  725. package/dist/errors-BYdjOimY.mjs.map +1 -0
  726. package/dist/errors-CJ6711al.mjs +120 -0
  727. package/dist/errors-CJ6711al.mjs.map +1 -0
  728. package/dist/errors-CwYHYcWF.mjs +502 -0
  729. package/dist/errors-CwYHYcWF.mjs.map +1 -0
  730. package/dist/escape-YSAGQRHa.mjs +9 -0
  731. package/dist/escape-YSAGQRHa.mjs.map +1 -0
  732. package/dist/fence-C3MLClBo.mjs +162 -0
  733. package/dist/fence-C3MLClBo.mjs.map +1 -0
  734. package/dist/field-defs-cache-Cpk0eFsQ.mjs +79 -0
  735. package/dist/field-defs-cache-Cpk0eFsQ.mjs.map +1 -0
  736. package/dist/field-map-6o9hPcRl.mjs +84 -0
  737. package/dist/field-map-6o9hPcRl.mjs.map +1 -0
  738. package/dist/focal-point-Cup37tLI.mjs +23 -0
  739. package/dist/focal-point-Cup37tLI.mjs.map +1 -0
  740. package/dist/fts-manager-B3iLXCGz.mjs +500 -0
  741. package/dist/fts-manager-B3iLXCGz.mjs.map +1 -0
  742. package/dist/gc-D24C-KP7.mjs +62 -0
  743. package/dist/gc-D24C-KP7.mjs.map +1 -0
  744. package/dist/hash-SY9Nq5FH.mjs +37 -0
  745. package/dist/hash-SY9Nq5FH.mjs.map +1 -0
  746. package/dist/hook-result-BU5rI-6M.d.mts +31 -0
  747. package/dist/hook-result-BU5rI-6M.d.mts.map +1 -0
  748. package/dist/hook-result-CO4E3zDv.mjs +3854 -0
  749. package/dist/hook-result-CO4E3zDv.mjs.map +1 -0
  750. package/dist/hreflang-Bzvlo9Ci.mjs +105 -0
  751. package/dist/hreflang-Bzvlo9Ci.mjs.map +1 -0
  752. package/dist/hreflang-Ds0WbBOu.d.mts +51 -0
  753. package/dist/hreflang-Ds0WbBOu.d.mts.map +1 -0
  754. package/dist/http-route-dispatch-BsjkWBZF.mjs +348 -0
  755. package/dist/http-route-dispatch-BsjkWBZF.mjs.map +1 -0
  756. package/dist/identity-CahxkBZC.mjs +35 -0
  757. package/dist/identity-CahxkBZC.mjs.map +1 -0
  758. package/dist/index-BauU0yTw.d.mts +261 -0
  759. package/dist/index-BauU0yTw.d.mts.map +1 -0
  760. package/dist/index.d.mts +26 -25
  761. package/dist/index.mjs +2111 -120
  762. package/dist/index.mjs.map +1 -0
  763. package/dist/init-lock-Dn7efXfy.mjs +56 -0
  764. package/dist/init-lock-Dn7efXfy.mjs.map +1 -0
  765. package/dist/install-finalization-CIl610wT.mjs +58 -0
  766. package/dist/install-finalization-CIl610wT.mjs.map +1 -0
  767. package/dist/json-recordset-CrS6ZqMk.mjs +12 -0
  768. package/dist/json-recordset-CrS6ZqMk.mjs.map +1 -0
  769. package/dist/json-schema-CBcJlGcY.mjs +15 -0
  770. package/dist/json-schema-CBcJlGcY.mjs.map +1 -0
  771. package/dist/keys-DJ62Wt5b.mjs +61 -0
  772. package/dist/keys-DJ62Wt5b.mjs.map +1 -0
  773. package/dist/kinds-D7_f3Qu3.mjs +974 -0
  774. package/dist/kinds-D7_f3Qu3.mjs.map +1 -0
  775. package/dist/lifecycle-DPCkpFHV.mjs +49 -0
  776. package/dist/lifecycle-DPCkpFHV.mjs.map +1 -0
  777. package/dist/limits-Bv6mXNM-.mjs +44 -0
  778. package/dist/limits-Bv6mXNM-.mjs.map +1 -0
  779. package/dist/load-r9P0fsRH.mjs +36 -0
  780. package/dist/load-r9P0fsRH.mjs.map +1 -0
  781. package/dist/loader-CSEfTKzr.mjs +1537 -0
  782. package/dist/loader-CSEfTKzr.mjs.map +1 -0
  783. package/dist/loops-BxzrcxPO.mjs +217 -0
  784. package/dist/loops-BxzrcxPO.mjs.map +1 -0
  785. package/dist/manifest-builder-BLWqITXR.mjs +196 -0
  786. package/dist/manifest-builder-BLWqITXR.mjs.map +1 -0
  787. package/dist/manifest-schema-BRpk5V7x.mjs +497 -0
  788. package/dist/manifest-schema-BRpk5V7x.mjs.map +1 -0
  789. package/dist/marketplace-5YFgYPVr.mjs +257 -0
  790. package/dist/marketplace-5YFgYPVr.mjs.map +1 -0
  791. package/dist/marketplace-zPVE4UY5.mjs +965 -0
  792. package/dist/marketplace-zPVE4UY5.mjs.map +1 -0
  793. package/dist/media/image-endpoint.d.mts.map +1 -1
  794. package/dist/media/image-endpoint.mjs +2 -1
  795. package/dist/media/image-endpoint.mjs.map +1 -1
  796. package/dist/media/index.d.mts +10 -5
  797. package/dist/media/index.d.mts.map +1 -1
  798. package/dist/media/index.mjs +4 -4
  799. package/dist/media/index.mjs.map +1 -1
  800. package/dist/media/local-runtime.d.mts +17 -15
  801. package/dist/media/local-runtime.d.mts.map +1 -1
  802. package/dist/media/local-runtime.mjs +3 -20
  803. package/dist/media/local-runtime.mjs.map +1 -1
  804. package/dist/media-C5fg1Xte.d.mts +203 -0
  805. package/dist/media-C5fg1Xte.d.mts.map +1 -0
  806. package/dist/media-CPETKjop.mjs +424 -0
  807. package/dist/media-CPETKjop.mjs.map +1 -0
  808. package/dist/media-Cid3xIHk.mjs +294 -0
  809. package/dist/media-Cid3xIHk.mjs.map +1 -0
  810. package/dist/media-DJaAAYI2.mjs +2805 -0
  811. package/dist/media-DJaAAYI2.mjs.map +1 -0
  812. package/dist/media-allowlist-B7JwNf-U.mjs +75 -0
  813. package/dist/media-allowlist-B7JwNf-U.mjs.map +1 -0
  814. package/dist/media-folders-BI7B7XUM.mjs +210 -0
  815. package/dist/media-folders-BI7B7XUM.mjs.map +1 -0
  816. package/dist/media-url-xWuPVfqO.mjs +43 -0
  817. package/dist/media-url-xWuPVfqO.mjs.map +1 -0
  818. package/dist/media-usage-SwtWPxy4.mjs +282 -0
  819. package/dist/media-usage-SwtWPxy4.mjs.map +1 -0
  820. package/dist/media-usage-activation-BTa1H4wE.mjs +78 -0
  821. package/dist/media-usage-activation-BTa1H4wE.mjs.map +1 -0
  822. package/dist/media-usage-work-BxHWfbKq.mjs +1036 -0
  823. package/dist/media-usage-work-BxHWfbKq.mjs.map +1 -0
  824. package/dist/media-usage-work-DYenZS8y.mjs +151 -0
  825. package/dist/media-usage-work-DYenZS8y.mjs.map +1 -0
  826. package/dist/menu-FtSf33fF.mjs +420 -0
  827. package/dist/menu-FtSf33fF.mjs.map +1 -0
  828. package/dist/menus--MSfZ5Eu.mjs +433 -0
  829. package/dist/menus--MSfZ5Eu.mjs.map +1 -0
  830. package/dist/menus-C8h6Jtpu.mjs +92 -0
  831. package/dist/menus-C8h6Jtpu.mjs.map +1 -0
  832. package/dist/menus-CpFAi_LK.mjs +434 -0
  833. package/dist/menus-CpFAi_LK.mjs.map +1 -0
  834. package/dist/migrations/index.d.mts +1 -1
  835. package/dist/migrations/index.mjs +2 -6
  836. package/dist/mime-Dx6aHTsR.mjs +82 -0
  837. package/dist/mime-Dx6aHTsR.mjs.map +1 -0
  838. package/dist/mode-D6Qg_-2J.mjs +23 -0
  839. package/dist/mode-D6Qg_-2J.mjs.map +1 -0
  840. package/dist/node-sqlite-compat-DvYkqx7Q.mjs +63 -0
  841. package/dist/node-sqlite-compat-DvYkqx7Q.mjs.map +1 -0
  842. package/dist/normalize-qcU0SKGf.mjs +220 -0
  843. package/dist/normalize-qcU0SKGf.mjs.map +1 -0
  844. package/dist/oauth-authorization-CBxtOboy.mjs +287 -0
  845. package/dist/oauth-authorization-CBxtOboy.mjs.map +1 -0
  846. package/dist/oauth-clients-HLGHmHqI.mjs +266 -0
  847. package/dist/oauth-clients-HLGHmHqI.mjs.map +1 -0
  848. package/dist/oauth-state-store-B4YAveSb.mjs +80 -0
  849. package/dist/oauth-state-store-B4YAveSb.mjs.map +1 -0
  850. package/dist/oauth-user-lookup-CTYMaKlq.mjs +26 -0
  851. package/dist/oauth-user-lookup-CTYMaKlq.mjs.map +1 -0
  852. package/dist/object-cache/memory.d.mts +1 -1
  853. package/dist/object-cache-DeATK4vw.mjs +805 -0
  854. package/dist/object-cache-DeATK4vw.mjs.map +1 -0
  855. package/dist/options-BJZMHnpx.d.mts +81 -0
  856. package/dist/options-BJZMHnpx.d.mts.map +1 -0
  857. package/dist/options-CMocxAku.mjs +208 -0
  858. package/dist/options-CMocxAku.mjs.map +1 -0
  859. package/dist/ownership-46c5NS0I.mjs +12 -0
  860. package/dist/ownership-46c5NS0I.mjs.map +1 -0
  861. package/dist/page/index.d.mts +2 -2
  862. package/dist/page/index.d.mts.map +1 -1
  863. package/dist/page/index.mjs +23 -27
  864. package/dist/page/index.mjs.map +1 -1
  865. package/dist/parse-B1E5cdyD.mjs +82 -0
  866. package/dist/parse-B1E5cdyD.mjs.map +1 -0
  867. package/dist/parse-Clt6wmpy.d.mts +178 -0
  868. package/dist/parse-Clt6wmpy.d.mts.map +1 -0
  869. package/dist/parts-CMwESQ6e.mjs +68 -0
  870. package/dist/parts-CMwESQ6e.mjs.map +1 -0
  871. package/dist/passkey-config-DiVZI-cx.mjs +46 -0
  872. package/dist/passkey-config-DiVZI-cx.mjs.map +1 -0
  873. package/dist/paths-NrYImb_h.mjs +77 -0
  874. package/dist/paths-NrYImb_h.mjs.map +1 -0
  875. package/dist/patterns-BxMSQThP.mjs +174 -0
  876. package/dist/patterns-BxMSQThP.mjs.map +1 -0
  877. package/dist/placeholder-B0vI-EQ9.d.mts +316 -0
  878. package/dist/placeholder-B0vI-EQ9.d.mts.map +1 -0
  879. package/dist/plan-CSb3BdFS.mjs +135 -0
  880. package/dist/plan-CSb3BdFS.mjs.map +1 -0
  881. package/dist/plugin-settings-HdYYRFi3.mjs +162 -0
  882. package/dist/plugin-settings-HdYYRFi3.mjs.map +1 -0
  883. package/dist/plugin-test-runtime.d.mts +23 -16
  884. package/dist/plugin-test-runtime.d.mts.map +1 -1
  885. package/dist/plugin-test-runtime.mjs +10 -125
  886. package/dist/plugin-tool-name-CCXxYq3K.mjs +27 -0
  887. package/dist/plugin-tool-name-CCXxYq3K.mjs.map +1 -0
  888. package/dist/plugin-types.d.mts +2 -2
  889. package/dist/plugin-utils.d.mts +15 -13
  890. package/dist/plugin-utils.d.mts.map +1 -1
  891. package/dist/plugins/adapt-sandbox-entry.d.mts +15 -13
  892. package/dist/plugins/adapt-sandbox-entry.d.mts.map +1 -1
  893. package/dist/plugins/adapt-sandbox-entry.mjs +6 -4
  894. package/dist/plugins/adapt-sandbox-entry.mjs.map +1 -1
  895. package/dist/plugins/host.d.mts +13 -6
  896. package/dist/plugins/host.d.mts.map +1 -0
  897. package/dist/plugins/host.mjs +10 -62
  898. package/dist/plugins-Bc70Xs37.mjs +261 -0
  899. package/dist/plugins-Bc70Xs37.mjs.map +1 -0
  900. package/dist/policy-C-ngDrxa.mjs +56 -0
  901. package/dist/policy-C-ngDrxa.mjs.map +1 -0
  902. package/dist/portable-text-T17rOqF7.mjs +454 -0
  903. package/dist/portable-text-T17rOqF7.mjs.map +1 -0
  904. package/dist/protocol-CmSX4cXv.d.mts +65 -0
  905. package/dist/protocol-CmSX4cXv.d.mts.map +1 -0
  906. package/dist/public-plugin-api-routes-_xsWTlwE.mjs +316 -0
  907. package/dist/public-plugin-api-routes-_xsWTlwE.mjs.map +1 -0
  908. package/dist/public-submission-ui3pFYtq.mjs +253 -0
  909. package/dist/public-submission-ui3pFYtq.mjs.map +1 -0
  910. package/dist/public-url-DMRZPAiW.mjs +123 -0
  911. package/dist/public-url-DMRZPAiW.mjs.map +1 -0
  912. package/dist/query-C1K9PzUc.mjs +41 -0
  913. package/dist/query-C1K9PzUc.mjs.map +1 -0
  914. package/dist/query-DdmHrvie.mjs +1201 -0
  915. package/dist/query-DdmHrvie.mjs.map +1 -0
  916. package/dist/query-EVjg8-Bq.mjs +37 -0
  917. package/dist/query-EVjg8-Bq.mjs.map +1 -0
  918. package/dist/range-BaF0521t.mjs +51 -0
  919. package/dist/range-BaF0521t.mjs.map +1 -0
  920. package/dist/rate-limit-6MngP0_m.mjs +127 -0
  921. package/dist/rate-limit-6MngP0_m.mjs.map +1 -0
  922. package/dist/receipt-BFm5eaN7.mjs +43 -0
  923. package/dist/receipt-BFm5eaN7.mjs.map +1 -0
  924. package/dist/redirect-ChcHI1KC.mjs +466 -0
  925. package/dist/redirect-ChcHI1KC.mjs.map +1 -0
  926. package/dist/redirect-EpidEf_5.mjs +19 -0
  927. package/dist/redirect-EpidEf_5.mjs.map +1 -0
  928. package/dist/redirect-paths-B9cXh9Wv.mjs +36 -0
  929. package/dist/redirect-paths-B9cXh9Wv.mjs.map +1 -0
  930. package/dist/redirects-D3zHoxhn.mjs +446 -0
  931. package/dist/redirects-D3zHoxhn.mjs.map +1 -0
  932. package/dist/redirects-dFPJ0HrD.mjs +148 -0
  933. package/dist/redirects-dFPJ0HrD.mjs.map +1 -0
  934. package/dist/registry/testing.mjs +2 -3
  935. package/dist/registry/testing.mjs.map +1 -1
  936. package/dist/registry-CDzYrAFY.mjs +6074 -0
  937. package/dist/registry-CDzYrAFY.mjs.map +1 -0
  938. package/dist/registry-Cf9vkVxW.mjs +1449 -0
  939. package/dist/registry-Cf9vkVxW.mjs.map +1 -0
  940. package/dist/registry-mZi_lxtT.mjs +755 -0
  941. package/dist/registry-mZi_lxtT.mjs.map +1 -0
  942. package/dist/relations-Eyop_U4o.mjs +798 -0
  943. package/dist/relations-Eyop_U4o.mjs.map +1 -0
  944. package/dist/request-cache-BYMs-BGX.mjs +104 -0
  945. package/dist/request-cache-BYMs-BGX.mjs.map +1 -0
  946. package/dist/request-context.d.mts +16 -3
  947. package/dist/request-context.d.mts.map +1 -1
  948. package/dist/request-context.mjs +22 -1
  949. package/dist/request-context.mjs.map +1 -1
  950. package/dist/request-meta-DsSkOdO0.mjs +141 -0
  951. package/dist/request-meta-DsSkOdO0.mjs.map +1 -0
  952. package/dist/resolve-Z5YK_6ew.mjs +199 -0
  953. package/dist/resolve-Z5YK_6ew.mjs.map +1 -0
  954. package/dist/resolve-s7ANHtFx.mjs +92 -0
  955. package/dist/resolve-s7ANHtFx.mjs.map +1 -0
  956. package/dist/rev-B6HS7337.mjs +50 -0
  957. package/dist/rev-B6HS7337.mjs.map +1 -0
  958. package/dist/revision-D7EedSdU.mjs +503 -0
  959. package/dist/revision-D7EedSdU.mjs.map +1 -0
  960. package/dist/rooms/index.d.mts +48 -0
  961. package/dist/rooms/index.d.mts.map +1 -0
  962. package/dist/rooms/index.mjs +6 -0
  963. package/dist/rooms/node/index.d.mts +25 -0
  964. package/dist/rooms/node/index.d.mts.map +1 -0
  965. package/dist/rooms/node/index.mjs +583 -0
  966. package/dist/rooms/node/index.mjs.map +1 -0
  967. package/dist/rooms/notifications.d.mts +47 -0
  968. package/dist/rooms/notifications.d.mts.map +1 -0
  969. package/dist/rooms/notifications.mjs +125 -0
  970. package/dist/rooms/notifications.mjs.map +1 -0
  971. package/dist/rooms/room.d.mts +76 -0
  972. package/dist/rooms/room.d.mts.map +1 -0
  973. package/dist/rooms/room.mjs +1257 -0
  974. package/dist/rooms/room.mjs.map +1 -0
  975. package/dist/rooms/site.d.mts +23 -0
  976. package/dist/rooms/site.d.mts.map +1 -0
  977. package/dist/rooms/site.mjs +146 -0
  978. package/dist/rooms/site.mjs.map +1 -0
  979. package/dist/rooms-CSNLTJsG.mjs +331 -0
  980. package/dist/rooms-CSNLTJsG.mjs.map +1 -0
  981. package/dist/rooms-CVsLla78.mjs +169 -0
  982. package/dist/rooms-CVsLla78.mjs.map +1 -0
  983. package/dist/rooms-CyXG83RZ.d.mts +4653 -0
  984. package/dist/rooms-CyXG83RZ.d.mts.map +1 -0
  985. package/dist/route-cache-CBpXPq-N.mjs +30 -0
  986. package/dist/route-cache-CBpXPq-N.mjs.map +1 -0
  987. package/dist/route-cache-DkhMwAIC.mjs +20 -0
  988. package/dist/route-cache-DkhMwAIC.mjs.map +1 -0
  989. package/dist/route-wire-DKSTaEz_.mjs +197 -0
  990. package/dist/route-wire-DKSTaEz_.mjs.map +1 -0
  991. package/dist/routes-QcHRiebw.mjs +272 -0
  992. package/dist/routes-QcHRiebw.mjs.map +1 -0
  993. package/dist/runner-4BfB04Rg.mjs +6950 -0
  994. package/dist/runner-4BfB04Rg.mjs.map +1 -0
  995. package/dist/runner-CAHS_KER.d.mts +79 -0
  996. package/dist/runner-CAHS_KER.d.mts.map +1 -0
  997. package/dist/runtime-holder-0g6pqbzx.mjs +36 -0
  998. package/dist/runtime-holder-0g6pqbzx.mjs.map +1 -0
  999. package/dist/runtime.d.mts +16 -14
  1000. package/dist/runtime.d.mts.map +1 -1
  1001. package/dist/runtime.mjs +1 -9
  1002. package/dist/runtime.mjs.map +1 -1
  1003. package/dist/scheduler-health-C5HEg2Yl.mjs +31 -0
  1004. package/dist/scheduler-health-C5HEg2Yl.mjs.map +1 -0
  1005. package/dist/schema/project-env-types.mjs +7 -54
  1006. package/dist/schema/project-env-types.mjs.map +1 -1
  1007. package/dist/schema-DS7ooMmp.mjs +13 -0
  1008. package/dist/schema-DS7ooMmp.mjs.map +1 -0
  1009. package/dist/schema-Mjtj7n1t.mjs +815 -0
  1010. package/dist/schema-Mjtj7n1t.mjs.map +1 -0
  1011. package/dist/scopes-BaR6WUyq.mjs +34 -0
  1012. package/dist/scopes-BaR6WUyq.mjs.map +1 -0
  1013. package/dist/search-B9RFgr0N.mjs +450 -0
  1014. package/dist/search-B9RFgr0N.mjs.map +1 -0
  1015. package/dist/secrets-C4UrjPiG.mjs +369 -0
  1016. package/dist/secrets-C4UrjPiG.mjs.map +1 -0
  1017. package/dist/sections-Bfa0oF8Q.mjs +129 -0
  1018. package/dist/sections-Bfa0oF8Q.mjs.map +1 -0
  1019. package/dist/sections-Bn2C6we7.mjs +222 -0
  1020. package/dist/sections-Bn2C6we7.mjs.map +1 -0
  1021. package/dist/seed/index.d.mts +3 -3
  1022. package/dist/seed/index.mjs +6 -53
  1023. package/dist/seo/index.d.mts +8 -6
  1024. package/dist/seo/index.d.mts.map +1 -1
  1025. package/dist/seo/index.mjs +10 -41
  1026. package/dist/seo/index.mjs.map +1 -1
  1027. package/dist/seo-DPW6k5_-.mjs +188 -0
  1028. package/dist/seo-DPW6k5_-.mjs.map +1 -0
  1029. package/dist/service-B4mHMku9.mjs +150 -0
  1030. package/dist/service-B4mHMku9.mjs.map +1 -0
  1031. package/dist/session-user-CF2jNfj7.mjs +61 -0
  1032. package/dist/session-user-CF2jNfj7.mjs.map +1 -0
  1033. package/dist/settings-4r88LLIM.mjs +66 -0
  1034. package/dist/settings-4r88LLIM.mjs.map +1 -0
  1035. package/dist/settings-BB2xxz3Y.mjs +74 -0
  1036. package/dist/settings-BB2xxz3Y.mjs.map +1 -0
  1037. package/dist/settings-BTkGl-bX.mjs +413 -0
  1038. package/dist/settings-BTkGl-bX.mjs.map +1 -0
  1039. package/dist/settings-y8Jx8b7g.mjs +157 -0
  1040. package/dist/settings-y8Jx8b7g.mjs.map +1 -0
  1041. package/dist/setup-complete-BGRiC59t.mjs +65 -0
  1042. package/dist/setup-complete-BGRiC59t.mjs.map +1 -0
  1043. package/dist/setup-nonce-D43FsOgZ.mjs +25 -0
  1044. package/dist/setup-nonce-D43FsOgZ.mjs.map +1 -0
  1045. package/dist/single-flight-cache-BCP1Tvcm.mjs +104 -0
  1046. package/dist/single-flight-cache-BCP1Tvcm.mjs.map +1 -0
  1047. package/dist/site-domain-CFX7g6ik.mjs +131 -0
  1048. package/dist/site-domain-CFX7g6ik.mjs.map +1 -0
  1049. package/dist/site-settings-C0D9fv7e.mjs +50 -0
  1050. package/dist/site-settings-C0D9fv7e.mjs.map +1 -0
  1051. package/dist/site-title-C0JVN6en.mjs +14 -0
  1052. package/dist/site-title-C0JVN6en.mjs.map +1 -0
  1053. package/dist/site-url-DzVnHJ8j.mjs +45 -0
  1054. package/dist/site-url-DzVnHJ8j.mjs.map +1 -0
  1055. package/dist/sitemap-name-Ja_Cvwx9.mjs +26 -0
  1056. package/dist/sitemap-name-Ja_Cvwx9.mjs.map +1 -0
  1057. package/dist/slug-CO2jtUda.mjs +16 -0
  1058. package/dist/slug-CO2jtUda.mjs.map +1 -0
  1059. package/dist/slugify-sxuydlHd.mjs +22 -0
  1060. package/dist/slugify-sxuydlHd.mjs.map +1 -0
  1061. package/dist/snapshot-C9OWUtFr.mjs +466 -0
  1062. package/dist/snapshot-C9OWUtFr.mjs.map +1 -0
  1063. package/dist/snapshot-CR5tan8p.mjs +184 -0
  1064. package/dist/snapshot-CR5tan8p.mjs.map +1 -0
  1065. package/dist/ssrf-Lj1KZxYt.mjs +406 -0
  1066. package/dist/ssrf-Lj1KZxYt.mjs.map +1 -0
  1067. package/dist/stage-ChbGIslu.mjs +662 -0
  1068. package/dist/stage-ChbGIslu.mjs.map +1 -0
  1069. package/dist/staged-BN8pRZwX.mjs +686 -0
  1070. package/dist/staged-BN8pRZwX.mjs.map +1 -0
  1071. package/dist/state-DtcE0eN3.mjs +178 -0
  1072. package/dist/state-DtcE0eN3.mjs.map +1 -0
  1073. package/dist/status-vvme29qV.mjs +30 -0
  1074. package/dist/status-vvme29qV.mjs.map +1 -0
  1075. package/dist/storage/local.d.mts +1 -1
  1076. package/dist/storage/local.mjs +2 -2
  1077. package/dist/storage/s3.d.mts +1 -1
  1078. package/dist/storage/s3.mjs +1 -1
  1079. package/dist/storage-query-BDUX3Cef.d.mts +1608 -0
  1080. package/dist/storage-query-BDUX3Cef.d.mts.map +1 -0
  1081. package/dist/tar-CAvEHFbE.mjs +449 -0
  1082. package/dist/tar-CAvEHFbE.mjs.map +1 -0
  1083. package/dist/target-BM_6fT9m.mjs +27 -0
  1084. package/dist/target-BM_6fT9m.mjs.map +1 -0
  1085. package/dist/taxonomies-BMuFLd53.mjs +722 -0
  1086. package/dist/taxonomies-BMuFLd53.mjs.map +1 -0
  1087. package/dist/taxonomies-ClkYcmcH.mjs +937 -0
  1088. package/dist/taxonomies-ClkYcmcH.mjs.map +1 -0
  1089. package/dist/taxonomy-s1GcBCRo.mjs +593 -0
  1090. package/dist/taxonomy-s1GcBCRo.mjs.map +1 -0
  1091. package/dist/tokens-Cpm6FIKJ.mjs +171 -0
  1092. package/dist/tokens-Cpm6FIKJ.mjs.map +1 -0
  1093. package/dist/transaction-SKrr6u84.mjs +44 -0
  1094. package/dist/transaction-SKrr6u84.mjs.map +1 -0
  1095. package/dist/transfer-B3CsI5MG.mjs +8963 -0
  1096. package/dist/transfer-B3CsI5MG.mjs.map +1 -0
  1097. package/dist/transfer-DqUiK3ca.mjs +166 -0
  1098. package/dist/transfer-DqUiK3ca.mjs.map +1 -0
  1099. package/dist/transfer-download-CWPfhL91.mjs +33 -0
  1100. package/dist/transfer-download-CWPfhL91.mjs.map +1 -0
  1101. package/dist/transformations-ClH4dJeM.mjs +196 -0
  1102. package/dist/transformations-ClH4dJeM.mjs.map +1 -0
  1103. package/dist/transport-C6Ps8ejN.mjs +144 -0
  1104. package/dist/transport-C6Ps8ejN.mjs.map +1 -0
  1105. package/dist/transport-D4hWYmO_.d.mts +42 -0
  1106. package/dist/transport-D4hWYmO_.d.mts.map +1 -0
  1107. package/dist/trusted-proxy-CWX1sqgb.mjs +51 -0
  1108. package/dist/trusted-proxy-CWX1sqgb.mjs.map +1 -0
  1109. package/dist/turnstile-B6zM50Mh.mjs +58 -0
  1110. package/dist/turnstile-B6zM50Mh.mjs.map +1 -0
  1111. package/dist/types-BBH-w_KS.mjs +133 -0
  1112. package/dist/types-BBH-w_KS.mjs.map +1 -0
  1113. package/dist/types-Ba3bWb9D.mjs +37 -0
  1114. package/dist/types-Ba3bWb9D.mjs.map +1 -0
  1115. package/dist/types-BmBK2cqf.mjs +201 -0
  1116. package/dist/types-BmBK2cqf.mjs.map +1 -0
  1117. package/dist/types-C0M6z2A4.mjs +16 -0
  1118. package/dist/types-C0M6z2A4.mjs.map +1 -0
  1119. package/dist/types-CG1dR_Cm.d.mts +934 -0
  1120. package/dist/types-CG1dR_Cm.d.mts.map +1 -0
  1121. package/dist/types-CImd8MBY.d.mts +1756 -0
  1122. package/dist/types-CImd8MBY.d.mts.map +1 -0
  1123. package/dist/types-CML-oGr6.d.mts +293 -0
  1124. package/dist/types-CML-oGr6.d.mts.map +1 -0
  1125. package/dist/types-CZO9f_vJ.d.mts +381 -0
  1126. package/dist/types-CZO9f_vJ.d.mts.map +1 -0
  1127. package/dist/types-CpFfDrGH.mjs +18 -0
  1128. package/dist/types-CpFfDrGH.mjs.map +1 -0
  1129. package/dist/types-D2zSjG0c.mjs +63 -0
  1130. package/dist/types-D2zSjG0c.mjs.map +1 -0
  1131. package/dist/types-DLKviL1s.d.mts +93 -0
  1132. package/dist/types-DLKviL1s.d.mts.map +1 -0
  1133. package/dist/types-Df0R58Wu.mjs +77 -0
  1134. package/dist/types-Df0R58Wu.mjs.map +1 -0
  1135. package/dist/types-DwNwhyWP.d.mts +227 -0
  1136. package/dist/types-DwNwhyWP.d.mts.map +1 -0
  1137. package/dist/types-DwZgl0Zn.d.mts +366 -0
  1138. package/dist/types-DwZgl0Zn.d.mts.map +1 -0
  1139. package/dist/types-Dyb_OuSw.d.mts +125 -0
  1140. package/dist/types-Dyb_OuSw.d.mts.map +1 -0
  1141. package/dist/types-iOnPkHRk.d.mts +209 -0
  1142. package/dist/types-iOnPkHRk.d.mts.map +1 -0
  1143. package/dist/ui-comments.d.mts +66 -0
  1144. package/dist/ui-search.d.mts +75 -0
  1145. package/dist/ui-webmcp-search.d.mts +29 -0
  1146. package/dist/ui.d.mts +576 -0
  1147. package/dist/upload-attempts-5Ot7-vsw.mjs +32 -0
  1148. package/dist/upload-attempts-5Ot7-vsw.mjs.map +1 -0
  1149. package/dist/url-BVdd-tah.mjs +104 -0
  1150. package/dist/url-BVdd-tah.mjs.map +1 -0
  1151. package/dist/url-ZCjpMO-q.mjs +74 -0
  1152. package/dist/url-ZCjpMO-q.mjs.map +1 -0
  1153. package/dist/url-pattern-BQT-sGmD.mjs +41 -0
  1154. package/dist/url-pattern-BQT-sGmD.mjs.map +1 -0
  1155. package/dist/urls-Cq_hUk4P.mjs +79 -0
  1156. package/dist/urls-Cq_hUk4P.mjs.map +1 -0
  1157. package/dist/user-C4km6fox.mjs +184 -0
  1158. package/dist/user-C4km6fox.mjs.map +1 -0
  1159. package/dist/utils-Cpo0_V09.d.mts +374 -0
  1160. package/dist/utils-Cpo0_V09.d.mts.map +1 -0
  1161. package/dist/utils-DMDmdhU3.mjs +450 -0
  1162. package/dist/utils-DMDmdhU3.mjs.map +1 -0
  1163. package/dist/validate-BNupiQtz.mjs +524 -0
  1164. package/dist/validate-BNupiQtz.mjs.map +1 -0
  1165. package/dist/validate-DBfkJa3O.d.mts +472 -0
  1166. package/dist/validate-DBfkJa3O.d.mts.map +1 -0
  1167. package/dist/validation-W_efZFgP.mjs +204 -0
  1168. package/dist/validation-W_efZFgP.mjs.map +1 -0
  1169. package/dist/version-C61rw8-y.mjs +9 -0
  1170. package/dist/version-C61rw8-y.mjs.map +1 -0
  1171. package/dist/version-DhGLeLRo.mjs +7 -0
  1172. package/dist/version-DhGLeLRo.mjs.map +1 -0
  1173. package/dist/version-eqLBDtcz.mjs +49 -0
  1174. package/dist/version-eqLBDtcz.mjs.map +1 -0
  1175. package/dist/video-My3h7vwE.mjs +18 -0
  1176. package/dist/video-My3h7vwE.mjs.map +1 -0
  1177. package/dist/virtual-modules-BZKqvjRC.mjs +568 -0
  1178. package/dist/virtual-modules-BZKqvjRC.mjs.map +1 -0
  1179. package/dist/widgets-DAdni19y.mjs +134 -0
  1180. package/dist/widgets-DAdni19y.mjs.map +1 -0
  1181. package/dist/wxr-DDPJOgkM.mjs +1054 -0
  1182. package/dist/wxr-DDPJOgkM.mjs.map +1 -0
  1183. package/dist/wxr-taxonomies-B0U2fJgs.mjs +735 -0
  1184. package/dist/wxr-taxonomies-B0U2fJgs.mjs.map +1 -0
  1185. package/dist/wxr-taxonomies-CyP2k4-Q.d.mts +34 -0
  1186. package/dist/wxr-taxonomies-CyP2k4-Q.d.mts.map +1 -0
  1187. package/dist/zod-generator-ChRSYUix.mjs +425 -0
  1188. package/dist/zod-generator-ChRSYUix.mjs.map +1 -0
  1189. package/package.json +81 -33
  1190. package/src/api/content-save.ts +281 -0
  1191. package/src/api/error.ts +6 -2
  1192. package/src/api/errors.ts +11 -0
  1193. package/src/api/handlers/content.ts +43 -8
  1194. package/src/api/handlers/entry-lock.ts +69 -14
  1195. package/src/api/handlers/marketplace.ts +8 -2
  1196. package/src/api/handlers/media-allowlist.ts +56 -0
  1197. package/src/api/handlers/media-upload.ts +9 -1
  1198. package/src/api/handlers/plugins.ts +4 -4
  1199. package/src/api/handlers/registry.ts +33 -21
  1200. package/src/api/handlers/relations.ts +20 -4
  1201. package/src/api/handlers/revision.ts +29 -0
  1202. package/src/api/handlers/rooms.ts +233 -0
  1203. package/src/api/handlers/site-domain.ts +1 -1
  1204. package/src/api/handlers/snapshot.ts +90 -30
  1205. package/src/api/handlers/staged-references.ts +14 -0
  1206. package/src/api/list-preconditions.ts +101 -0
  1207. package/src/api/openapi/document.ts +5 -5
  1208. package/src/api/parse.ts +3 -2
  1209. package/src/api/public-url.ts +21 -0
  1210. package/src/api/schemas/auth.ts +57 -1
  1211. package/src/api/schemas/content.ts +14 -0
  1212. package/src/api/schemas/entry-lock.ts +6 -1
  1213. package/src/api/schemas/import.ts +6 -0
  1214. package/src/api/schemas/index.ts +1 -0
  1215. package/src/api/schemas/media.ts +20 -0
  1216. package/src/api/schemas/rooms.ts +27 -0
  1217. package/src/api/schemas/schema.ts +9 -1
  1218. package/src/api/schemas/settings.ts +2 -0
  1219. package/src/api/site-title.ts +13 -0
  1220. package/src/api/types.ts +3 -0
  1221. package/src/astro/integration/index.ts +19 -5
  1222. package/src/astro/integration/routes.ts +15 -5
  1223. package/src/astro/integration/runtime.ts +32 -0
  1224. package/src/astro/integration/virtual-modules.ts +80 -17
  1225. package/src/astro/integration/vite-config.ts +136 -0
  1226. package/src/astro/middleware/auth.ts +44 -16
  1227. package/src/astro/middleware/media-usage-write-fence.ts +4 -0
  1228. package/src/astro/middleware/redirect.ts +11 -1
  1229. package/src/astro/middleware/request-context.ts +57 -27
  1230. package/src/astro/middleware.ts +44 -29
  1231. package/src/astro/routes/PluginRegistry.tsx +21 -17
  1232. package/src/astro/routes/api/admin/comments/[id]/status.ts +9 -1
  1233. package/src/astro/routes/api/admin/comments/[id].ts +10 -3
  1234. package/src/astro/routes/api/admin/comments/bulk.ts +18 -4
  1235. package/src/astro/routes/api/admin/plugins/marketplace/[id]/install.ts +1 -1
  1236. package/src/astro/routes/api/admin/plugins/registry/install.ts +1 -1
  1237. package/src/astro/routes/api/admin/users/[id]/send-recovery.ts +9 -2
  1238. package/src/astro/routes/api/auth/dev-bypass.ts +20 -1
  1239. package/src/astro/routes/api/auth/invite/complete.ts +2 -1
  1240. package/src/astro/routes/api/auth/invite/index.ts +9 -2
  1241. package/src/astro/routes/api/auth/invite/register-options.ts +2 -1
  1242. package/src/astro/routes/api/auth/magic-link/send.ts +9 -2
  1243. package/src/astro/routes/api/auth/me.ts +38 -17
  1244. package/src/astro/routes/api/auth/oauth/[provider]/callback.ts +6 -11
  1245. package/src/astro/routes/api/auth/oauth/[provider].ts +6 -11
  1246. package/src/astro/routes/api/auth/passkey/options.ts +2 -1
  1247. package/src/astro/routes/api/auth/passkey/register/options.ts +2 -1
  1248. package/src/astro/routes/api/auth/passkey/register/verify.ts +2 -1
  1249. package/src/astro/routes/api/auth/passkey/verify.ts +2 -1
  1250. package/src/astro/routes/api/auth/signup/complete.ts +2 -1
  1251. package/src/astro/routes/api/auth/signup/request.ts +2 -1
  1252. package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +2 -2
  1253. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +1 -0
  1254. package/src/astro/routes/api/content/[collection]/[id]/lock.ts +6 -3
  1255. package/src/astro/routes/api/content/[collection]/[id]/preview-url.ts +6 -2
  1256. package/src/astro/routes/api/content/[collection]/[id]/revisions/editors.ts +30 -0
  1257. package/src/astro/routes/api/content/[collection]/[id]/revisions.ts +37 -1
  1258. package/src/astro/routes/api/content/[collection]/[id]/room.ts +43 -0
  1259. package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +3 -1
  1260. package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +54 -2
  1261. package/src/astro/routes/api/content/[collection]/[id].ts +22 -73
  1262. package/src/astro/routes/api/import/wordpress/analyze.ts +11 -0
  1263. package/src/astro/routes/api/import/wordpress/execute.ts +193 -15
  1264. package/src/astro/routes/api/import/wordpress/media.ts +6 -1
  1265. package/src/astro/routes/api/import/wordpress/rewrite-urls.ts +9 -5
  1266. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +22 -16
  1267. package/src/astro/routes/api/manifest.ts +40 -5
  1268. package/src/astro/routes/api/media/[id]/confirm.ts +42 -14
  1269. package/src/astro/routes/api/media/asset/[id]/[filename].ts +1 -0
  1270. package/src/astro/routes/api/media/file/[...key].ts +1 -0
  1271. package/src/astro/routes/api/media/upload-url.ts +1 -1
  1272. package/src/astro/routes/api/media.ts +14 -4
  1273. package/src/astro/routes/api/oauth/device/authorize.ts +0 -2
  1274. package/src/astro/routes/api/revisions/[revisionId]/restore.ts +1 -1
  1275. package/src/astro/routes/api/settings/domain-notify.ts +9 -2
  1276. package/src/astro/routes/api/settings/email.ts +197 -8
  1277. package/src/astro/routes/api/setup/admin-verify.ts +2 -1
  1278. package/src/astro/routes/api/setup/admin.ts +2 -1
  1279. package/src/astro/routes/api/setup/dev-bypass.ts +3 -1
  1280. package/src/astro/routes/api/setup/index.ts +5 -2
  1281. package/src/astro/routes/api/well-known/auth.ts +2 -1
  1282. package/src/astro/routes/api/widget-areas/[name]/reorder.ts +1 -1
  1283. package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +2 -2
  1284. package/src/astro/routes/api/widget-areas/[name]/widgets.ts +1 -1
  1285. package/src/astro/routes/api/widget-areas/[name].ts +1 -1
  1286. package/src/astro/routes/api/widget-areas/index.ts +1 -1
  1287. package/src/astro/routes/robots.txt.ts +9 -10
  1288. package/src/astro/routes/sitemap-[collection].xml.ts +5 -6
  1289. package/src/astro/routes/sitemap.xml.ts +2 -6
  1290. package/src/astro/runtime-holder.ts +41 -0
  1291. package/src/astro/types.ts +42 -5
  1292. package/src/auth/oauth-env.ts +35 -0
  1293. package/src/bylines/field-defs-cache.ts +9 -4
  1294. package/src/cli/commands/export-seed.ts +4 -3
  1295. package/src/cli/commands/import/wordpress.ts +158 -56
  1296. package/src/cli/commands/import.ts +139 -0
  1297. package/src/cli/commands/login.ts +26 -1
  1298. package/src/cli/commands/schema.ts +2 -2
  1299. package/src/cli/commands/seed.ts +3 -3
  1300. package/src/cli/credentials.ts +58 -17
  1301. package/src/cli/index.ts +4 -1
  1302. package/src/cli/wxr/parser.ts +15 -13
  1303. package/src/client/index.ts +38 -24
  1304. package/src/client/portable-text.ts +390 -192
  1305. package/src/client/transport.ts +14 -4
  1306. package/src/comments/public-submission.ts +7 -0
  1307. package/src/comments/route-cache.ts +39 -0
  1308. package/src/components/Columns.astro +2 -4
  1309. package/src/components/CommentForm.astro +6 -0
  1310. package/src/components/Comments.astro +5 -1
  1311. package/src/components/Cover.astro +2 -4
  1312. package/src/components/EmDashHead.astro +9 -7
  1313. package/src/components/EmDashImage.astro +161 -34
  1314. package/src/components/EmDashMedia.astro +36 -31
  1315. package/src/components/Embed.astro +49 -17
  1316. package/src/components/Gallery.astro +6 -2
  1317. package/src/components/Image.astro +15 -3
  1318. package/src/components/InlinePortableTextEditor.tsx +1 -0
  1319. package/src/components/LiveSearch.astro +23 -1
  1320. package/src/components/PortableText.astro +5 -8
  1321. package/src/components/marks/Link.astro +7 -0
  1322. package/src/components/widgets/Archives.astro +6 -2
  1323. package/src/components/widgets/Categories.astro +7 -2
  1324. package/src/components/widgets/RecentPosts.astro +23 -13
  1325. package/src/components/widgets/Search.astro +3 -1
  1326. package/src/components/widgets/Tags.astro +7 -2
  1327. package/src/config/options-schema.ts +124 -0
  1328. package/src/content/converters/video.ts +6 -65
  1329. package/src/database/dialect-helpers.ts +57 -0
  1330. package/src/database/migrations/092_plugin_kv_options.ts +93 -0
  1331. package/src/database/migrations/093_menu_item_orphans.ts +21 -0
  1332. package/src/database/migrations/094_media_usage_file_url_reindex.ts +57 -0
  1333. package/src/database/migrations/095_plugin_storage_unique_scope.ts +134 -0
  1334. package/src/database/migrations/096_revision_kind_and_editors.ts +29 -0
  1335. package/src/database/migrations/097_room_storage.ts +43 -0
  1336. package/src/database/migrations/content-sized.ts +16 -0
  1337. package/src/database/migrations/policy.ts +6 -1
  1338. package/src/database/migrations/runner.ts +37 -8
  1339. package/src/database/plugin-storage-index-name.ts +29 -0
  1340. package/src/database/repositories/byline.ts +94 -89
  1341. package/src/database/repositories/content.ts +162 -13
  1342. package/src/database/repositories/entry-locks.ts +35 -29
  1343. package/src/database/repositories/media-usage.ts +1 -1
  1344. package/src/database/repositories/media.ts +23 -0
  1345. package/src/database/repositories/menu.ts +30 -3
  1346. package/src/database/repositories/redirect.ts +116 -46
  1347. package/src/database/repositories/revision.ts +216 -20
  1348. package/src/database/repositories/seo.ts +2 -0
  1349. package/src/database/repositories/taxonomy.ts +91 -27
  1350. package/src/database/repositories/user.ts +34 -0
  1351. package/src/database/transaction.ts +23 -2
  1352. package/src/database/types.ts +23 -1
  1353. package/src/emdash-runtime.ts +1048 -240
  1354. package/src/i18n/resolve.ts +10 -0
  1355. package/src/import/index.ts +0 -12
  1356. package/src/import/menus.ts +202 -151
  1357. package/src/import/registry.ts +30 -1
  1358. package/src/index.ts +10 -0
  1359. package/src/loader.ts +109 -26
  1360. package/src/mcp/server.ts +103 -29
  1361. package/src/media/enrich.ts +20 -4
  1362. package/src/media/image-endpoint.ts +1 -0
  1363. package/src/media/mime.ts +1 -0
  1364. package/src/media/placeholder.ts +4 -0
  1365. package/src/media/portable-text-file-refs.ts +98 -0
  1366. package/src/media/responsive.ts +29 -1
  1367. package/src/media/types.ts +2 -0
  1368. package/src/media/url.ts +15 -0
  1369. package/src/media/usage/content-snapshots.ts +111 -34
  1370. package/src/media/usage/extractor.ts +42 -8
  1371. package/src/media/usage/types.ts +5 -0
  1372. package/src/object-cache/index.ts +382 -19
  1373. package/src/page/jsonld.ts +26 -11
  1374. package/src/plugins/adapt-sandbox-entry.ts +2 -0
  1375. package/src/plugins/content-policy.ts +36 -2
  1376. package/src/plugins/context.ts +17 -7
  1377. package/src/plugins/cron.ts +6 -3
  1378. package/src/plugins/define-plugin.ts +5 -1
  1379. package/src/plugins/editor-draft.ts +9 -3
  1380. package/src/plugins/email-smtp.ts +936 -0
  1381. package/src/plugins/hooks.ts +34 -8
  1382. package/src/plugins/host.ts +2 -0
  1383. package/src/plugins/http-route-dispatch.ts +3 -1
  1384. package/src/plugins/lifecycle.ts +25 -1
  1385. package/src/plugins/manager.ts +3 -0
  1386. package/src/plugins/sandbox/types.ts +10 -1
  1387. package/src/plugins/storage-indexes.ts +64 -55
  1388. package/src/plugins/types.ts +16 -1
  1389. package/src/query.ts +72 -7
  1390. package/src/redirects/cache.ts +3 -2
  1391. package/src/redirects/loops.ts +20 -4
  1392. package/src/redirects/patterns.ts +16 -0
  1393. package/src/request-context.ts +29 -1
  1394. package/src/rooms/document.ts +99 -0
  1395. package/src/rooms/hash.ts +19 -0
  1396. package/src/rooms/index.ts +28 -0
  1397. package/src/rooms/kysely-store.ts +279 -0
  1398. package/src/rooms/limits.ts +41 -0
  1399. package/src/rooms/merge.ts +115 -0
  1400. package/src/rooms/node/index.ts +30 -0
  1401. package/src/rooms/node/registry.ts +232 -0
  1402. package/src/rooms/node/signals.ts +89 -0
  1403. package/src/rooms/node/upgrades.ts +210 -0
  1404. package/src/rooms/notifications.ts +157 -0
  1405. package/src/rooms/parts.ts +74 -0
  1406. package/src/rooms/room.ts +1559 -0
  1407. package/src/rooms/site.ts +185 -0
  1408. package/src/rooms/snapshot.ts +11 -0
  1409. package/src/rooms/types.ts +298 -0
  1410. package/src/scheduled-publish.ts +18 -5
  1411. package/src/schema/registry.ts +14 -3
  1412. package/src/schema/types.ts +10 -2
  1413. package/src/search/errors.ts +22 -0
  1414. package/src/search/fts-manager.ts +21 -6
  1415. package/src/search/index.ts +2 -0
  1416. package/src/seed/apply.ts +109 -48
  1417. package/src/seed/index.ts +1 -1
  1418. package/src/seed/load.ts +9 -0
  1419. package/src/seed/types.ts +20 -11
  1420. package/src/seo/hreflang.ts +5 -4
  1421. package/src/seo/index.ts +10 -4
  1422. package/src/seo/title-field.ts +19 -0
  1423. package/src/settings/index.ts +36 -3
  1424. package/src/settings/types.ts +7 -0
  1425. package/src/taxonomies/index.ts +55 -25
  1426. package/src/transfer/analyze/target.ts +5 -0
  1427. package/src/transfer/domain.ts +23 -0
  1428. package/src/transfer/export/readers.ts +6 -2
  1429. package/src/transfer/format/columns.ts +4 -0
  1430. package/src/transfer/format/settings.ts +1 -0
  1431. package/src/transfer/import/scaffold.ts +66 -8
  1432. package/src/ui.ts +18 -19
  1433. package/src/virtual-modules.d.ts +20 -3
  1434. package/src/visual-editing/toolbar.ts +73 -51
  1435. package/src/widgets/recent-posts.ts +13 -0
  1436. package/dist/action-token-SK8zyN7w.mjs +0 -26
  1437. package/dist/action-token-SK8zyN7w.mjs.map +0 -1
  1438. package/dist/activation-CGlyigmg.mjs +0 -387
  1439. package/dist/activation-CGlyigmg.mjs.map +0 -1
  1440. package/dist/adapters-D9a1PfqH.d.mts +0 -173
  1441. package/dist/adapters-D9a1PfqH.d.mts.map +0 -1
  1442. package/dist/after-32yNRvd2.mjs +0 -99
  1443. package/dist/after-32yNRvd2.mjs.map +0 -1
  1444. package/dist/allowed-origins-CEug-p0t.mjs +0 -116
  1445. package/dist/allowed-origins-CEug-p0t.mjs.map +0 -1
  1446. package/dist/api--PYoyeTo.mjs +0 -5098
  1447. package/dist/api--PYoyeTo.mjs.map +0 -1
  1448. package/dist/api-tokens-DqSlkDVI.mjs +0 -9
  1449. package/dist/api-tokens-DqSlkDVI.mjs.map +0 -1
  1450. package/dist/api-tokens-GNCsIegW.mjs +0 -173
  1451. package/dist/api-tokens-GNCsIegW.mjs.map +0 -1
  1452. package/dist/apply-DVnupNeS.mjs +0 -1760
  1453. package/dist/apply-DVnupNeS.mjs.map +0 -1
  1454. package/dist/approvals-DTtYSB27.mjs +0 -460
  1455. package/dist/approvals-DTtYSB27.mjs.map +0 -1
  1456. package/dist/artifact-fetch-DIh7iyOV.mjs +0 -659
  1457. package/dist/artifact-fetch-DIh7iyOV.mjs.map +0 -1
  1458. package/dist/artifacts-Dvdp2KK-.mjs +0 -323
  1459. package/dist/artifacts-Dvdp2KK-.mjs.map +0 -1
  1460. package/dist/audit-B8XE-0UV.mjs +0 -127
  1461. package/dist/audit-B8XE-0UV.mjs.map +0 -1
  1462. package/dist/authoritative-records-CQlB3JzE.mjs +0 -5183
  1463. package/dist/authoritative-records-CQlB3JzE.mjs.map +0 -1
  1464. package/dist/authorize-NJgp8kLI.mjs +0 -74
  1465. package/dist/authorize-NJgp8kLI.mjs.map +0 -1
  1466. package/dist/backup-8rPSJ28a.mjs +0 -246
  1467. package/dist/backup-8rPSJ28a.mjs.map +0 -1
  1468. package/dist/base64-BQBZwXCx.mjs +0 -63
  1469. package/dist/base64-BQBZwXCx.mjs.map +0 -1
  1470. package/dist/block-types-BbOrfnWs.mjs +0 -132
  1471. package/dist/block-types-BbOrfnWs.mjs.map +0 -1
  1472. package/dist/block-values-Dg0-8PPS.mjs +0 -215
  1473. package/dist/block-values-Dg0-8PPS.mjs.map +0 -1
  1474. package/dist/byline-DHJS-GGb.mjs +0 -994
  1475. package/dist/byline-DHJS-GGb.mjs.map +0 -1
  1476. package/dist/byline-fields-CiR8FvvF.mjs +0 -280
  1477. package/dist/byline-fields-CiR8FvvF.mjs.map +0 -1
  1478. package/dist/byline-fields-D6KYsEa7.mjs +0 -123
  1479. package/dist/byline-fields-D6KYsEa7.mjs.map +0 -1
  1480. package/dist/byline-registry-BhzpO41z.mjs +0 -406
  1481. package/dist/byline-registry-BhzpO41z.mjs.map +0 -1
  1482. package/dist/bylines-Bsg5cH4S.mjs +0 -234
  1483. package/dist/bylines-Bsg5cH4S.mjs.map +0 -1
  1484. package/dist/bylines-f_ZEc6Sn.mjs +0 -150
  1485. package/dist/bylines-f_ZEc6Sn.mjs.map +0 -1
  1486. package/dist/cache-5DHbpEWu.mjs +0 -151
  1487. package/dist/cache-5DHbpEWu.mjs.map +0 -1
  1488. package/dist/canonical-BudtH-Fx.mjs +0 -174
  1489. package/dist/canonical-BudtH-Fx.mjs.map +0 -1
  1490. package/dist/capture-triggers-BezAvWcB.mjs +0 -362
  1491. package/dist/capture-triggers-BezAvWcB.mjs.map +0 -1
  1492. package/dist/challenge-store-B1C0V4b3.mjs +0 -51
  1493. package/dist/challenge-store-B1C0V4b3.mjs.map +0 -1
  1494. package/dist/checksum-CEqvfxGX.mjs +0 -162
  1495. package/dist/checksum-CEqvfxGX.mjs.map +0 -1
  1496. package/dist/chrome-tags-BIKBMZYO.mjs +0 -24
  1497. package/dist/chrome-tags-BIKBMZYO.mjs.map +0 -1
  1498. package/dist/chunks-DiW8VMwz.mjs +0 -25
  1499. package/dist/chunks-DiW8VMwz.mjs.map +0 -1
  1500. package/dist/collection-slugs-cache-DIrLjqH-.mjs +0 -91
  1501. package/dist/collection-slugs-cache-DIrLjqH-.mjs.map +0 -1
  1502. package/dist/comment-DB74Zpa4.mjs +0 -335
  1503. package/dist/comment-DB74Zpa4.mjs.map +0 -1
  1504. package/dist/comment-reaction-BScxIWUn.mjs +0 -85
  1505. package/dist/comment-reaction-BScxIWUn.mjs.map +0 -1
  1506. package/dist/comments-Cor_zKml.mjs +0 -195
  1507. package/dist/comments-Cor_zKml.mjs.map +0 -1
  1508. package/dist/comments-yiRFx3w5.mjs +0 -99
  1509. package/dist/comments-yiRFx3w5.mjs.map +0 -1
  1510. package/dist/components-Brp__9xo.mjs +0 -112
  1511. package/dist/components-Brp__9xo.mjs.map +0 -1
  1512. package/dist/config-D44_8G9J.d.mts +0 -41
  1513. package/dist/config-D44_8G9J.d.mts.map +0 -1
  1514. package/dist/config-DBU6iUQB.mjs +0 -228
  1515. package/dist/config-DBU6iUQB.mjs.map +0 -1
  1516. package/dist/config-sDhZvkLR.d.mts +0 -6835
  1517. package/dist/config-sDhZvkLR.d.mts.map +0 -1
  1518. package/dist/connection-BtEN_lP9.mjs +0 -36
  1519. package/dist/connection-BtEN_lP9.mjs.map +0 -1
  1520. package/dist/content-BKHUVsE5.mjs +0 -2112
  1521. package/dist/content-BKHUVsE5.mjs.map +0 -1
  1522. package/dist/content-list-query-ByP4jRpZ.d.mts +0 -26
  1523. package/dist/content-list-query-ByP4jRpZ.d.mts.map +0 -1
  1524. package/dist/content-policy-BmE0MPZY.mjs +0 -46
  1525. package/dist/content-policy-BmE0MPZY.mjs.map +0 -1
  1526. package/dist/content-repair-Ukdxoq-R.mjs +0 -442
  1527. package/dist/content-repair-Ukdxoq-R.mjs.map +0 -1
  1528. package/dist/context-CzjejcsE.mjs +0 -2089
  1529. package/dist/context-CzjejcsE.mjs.map +0 -1
  1530. package/dist/credits-BKREepht.mjs +0 -110
  1531. package/dist/credits-BKREepht.mjs.map +0 -1
  1532. package/dist/cron-D7obTIfk.mjs +0 -306
  1533. package/dist/cron-D7obTIfk.mjs.map +0 -1
  1534. package/dist/dashboard-ynr1qJWM.mjs +0 -168
  1535. package/dist/dashboard-ynr1qJWM.mjs.map +0 -1
  1536. package/dist/default-C0W-PhAp.mjs +0 -81
  1537. package/dist/default-C0W-PhAp.mjs.map +0 -1
  1538. package/dist/deferred-tasks-wlMFJL95.d.mts +0 -10
  1539. package/dist/deferred-tasks-wlMFJL95.d.mts.map +0 -1
  1540. package/dist/destination-DR3IHjmy.mjs +0 -18
  1541. package/dist/destination-DR3IHjmy.mjs.map +0 -1
  1542. package/dist/dev-typegen-EBni_pOQ.mjs +0 -29
  1543. package/dist/dev-typegen-EBni_pOQ.mjs.map +0 -1
  1544. package/dist/device-flow-D1U392GC.mjs +0 -519
  1545. package/dist/device-flow-D1U392GC.mjs.map +0 -1
  1546. package/dist/dialect-helpers-B1XN2HGB.mjs +0 -314
  1547. package/dist/dialect-helpers-B1XN2HGB.mjs.map +0 -1
  1548. package/dist/digest-DJ1tHCgy.mjs +0 -194
  1549. package/dist/digest-DJ1tHCgy.mjs.map +0 -1
  1550. package/dist/direct-executor-Bs2g0ake.mjs +0 -117
  1551. package/dist/direct-executor-Bs2g0ake.mjs.map +0 -1
  1552. package/dist/dist-BUmWMTbN.mjs +0 -810
  1553. package/dist/dist-BUmWMTbN.mjs.map +0 -1
  1554. package/dist/email-console-FFVJWb9N.mjs +0 -50
  1555. package/dist/email-console-FFVJWb9N.mjs.map +0 -1
  1556. package/dist/email-locale-Bs3HFdnq.mjs +0 -25
  1557. package/dist/email-locale-Bs3HFdnq.mjs.map +0 -1
  1558. package/dist/emdash-runtime-C8T-pZpS.mjs +0 -4425
  1559. package/dist/emdash-runtime-C8T-pZpS.mjs.map +0 -1
  1560. package/dist/enrich-DFlfnd3u.mjs +0 -194
  1561. package/dist/enrich-DFlfnd3u.mjs.map +0 -1
  1562. package/dist/entry-lock-BulbgPBX.d.mts +0 -4568
  1563. package/dist/entry-lock-BulbgPBX.d.mts.map +0 -1
  1564. package/dist/entry-lock-CRVmruM0.mjs +0 -1211
  1565. package/dist/entry-lock-CRVmruM0.mjs.map +0 -1
  1566. package/dist/entry-lock-D-zJQ4q6.mjs +0 -163
  1567. package/dist/entry-lock-D-zJQ4q6.mjs.map +0 -1
  1568. package/dist/entry-locks-CJ9uhqg1.mjs +0 -167
  1569. package/dist/entry-locks-CJ9uhqg1.mjs.map +0 -1
  1570. package/dist/env-types-BE3bCvfP.mjs +0 -38
  1571. package/dist/env-types-BE3bCvfP.mjs.map +0 -1
  1572. package/dist/error-BCMgPxdn.mjs +0 -90
  1573. package/dist/error-BCMgPxdn.mjs.map +0 -1
  1574. package/dist/errors-8gJqv-XV.mjs +0 -492
  1575. package/dist/errors-8gJqv-XV.mjs.map +0 -1
  1576. package/dist/errors-B4f4It-2.mjs +0 -120
  1577. package/dist/errors-B4f4It-2.mjs.map +0 -1
  1578. package/dist/escape-lsNq38PP.mjs +0 -9
  1579. package/dist/escape-lsNq38PP.mjs.map +0 -1
  1580. package/dist/fence-Dagicj14.mjs +0 -162
  1581. package/dist/fence-Dagicj14.mjs.map +0 -1
  1582. package/dist/field-map-BSXdNGt5.mjs +0 -84
  1583. package/dist/field-map-BSXdNGt5.mjs.map +0 -1
  1584. package/dist/focal-point-CgCcr1Ca.mjs +0 -23
  1585. package/dist/focal-point-CgCcr1Ca.mjs.map +0 -1
  1586. package/dist/fts-manager-6861qcwk.mjs +0 -489
  1587. package/dist/fts-manager-6861qcwk.mjs.map +0 -1
  1588. package/dist/gc-CNkXB3mE.mjs +0 -75
  1589. package/dist/gc-CNkXB3mE.mjs.map +0 -1
  1590. package/dist/hash-BJaeek87.mjs +0 -37
  1591. package/dist/hash-BJaeek87.mjs.map +0 -1
  1592. package/dist/hook-result-f8t7hIuu.d.mts +0 -31
  1593. package/dist/hook-result-f8t7hIuu.d.mts.map +0 -1
  1594. package/dist/hreflang-8dUOJAPJ.d.mts +0 -50
  1595. package/dist/hreflang-8dUOJAPJ.d.mts.map +0 -1
  1596. package/dist/hreflang-BW5A4FLK.mjs +0 -105
  1597. package/dist/hreflang-BW5A4FLK.mjs.map +0 -1
  1598. package/dist/http-route-dispatch-rXKvTNm9.mjs +0 -342
  1599. package/dist/http-route-dispatch-rXKvTNm9.mjs.map +0 -1
  1600. package/dist/identity-CPRRSovU.mjs +0 -35
  1601. package/dist/identity-CPRRSovU.mjs.map +0 -1
  1602. package/dist/import-yVbfPyfd.mjs +0 -2126
  1603. package/dist/import-yVbfPyfd.mjs.map +0 -1
  1604. package/dist/index-VM7Fzxwe.d.mts +0 -260
  1605. package/dist/index-VM7Fzxwe.d.mts.map +0 -1
  1606. package/dist/init-lock-BGmew3r1.mjs +0 -56
  1607. package/dist/init-lock-BGmew3r1.mjs.map +0 -1
  1608. package/dist/install-finalization-RU6VrHOX.mjs +0 -58
  1609. package/dist/install-finalization-RU6VrHOX.mjs.map +0 -1
  1610. package/dist/json-recordset-D0WhN2UA.mjs +0 -12
  1611. package/dist/json-recordset-D0WhN2UA.mjs.map +0 -1
  1612. package/dist/json-schema-v_D_pPNG.mjs +0 -15
  1613. package/dist/json-schema-v_D_pPNG.mjs.map +0 -1
  1614. package/dist/keys-CifIkT0N.mjs +0 -61
  1615. package/dist/keys-CifIkT0N.mjs.map +0 -1
  1616. package/dist/kinds-B_Qcl5pz.mjs +0 -974
  1617. package/dist/kinds-B_Qcl5pz.mjs.map +0 -1
  1618. package/dist/lifecycle-B8d7Rdqx.mjs +0 -25
  1619. package/dist/lifecycle-B8d7Rdqx.mjs.map +0 -1
  1620. package/dist/load-D4xtzm6h.mjs +0 -28
  1621. package/dist/load-D4xtzm6h.mjs.map +0 -1
  1622. package/dist/loader-DhnedqY4.mjs +0 -1478
  1623. package/dist/loader-DhnedqY4.mjs.map +0 -1
  1624. package/dist/loops-B2YS-Zzr.mjs +0 -205
  1625. package/dist/loops-B2YS-Zzr.mjs.map +0 -1
  1626. package/dist/manifest-builder-g1FLviel.mjs +0 -196
  1627. package/dist/manifest-builder-g1FLviel.mjs.map +0 -1
  1628. package/dist/manifest-schema-DNb4XmTS.mjs +0 -497
  1629. package/dist/manifest-schema-DNb4XmTS.mjs.map +0 -1
  1630. package/dist/marketplace-CqbgeIa7.mjs +0 -257
  1631. package/dist/marketplace-CqbgeIa7.mjs.map +0 -1
  1632. package/dist/media-BR4_t-Wd.mjs +0 -416
  1633. package/dist/media-BR4_t-Wd.mjs.map +0 -1
  1634. package/dist/media-CikS-q6E.mjs +0 -294
  1635. package/dist/media-CikS-q6E.mjs.map +0 -1
  1636. package/dist/media-DepNLhPq.mjs +0 -383
  1637. package/dist/media-DepNLhPq.mjs.map +0 -1
  1638. package/dist/media-allowlist-BMBLqyWh.mjs +0 -45
  1639. package/dist/media-allowlist-BMBLqyWh.mjs.map +0 -1
  1640. package/dist/media-folders-CI0Wydfo.mjs +0 -210
  1641. package/dist/media-folders-CI0Wydfo.mjs.map +0 -1
  1642. package/dist/media-url-BQgKvpQ5.mjs +0 -43
  1643. package/dist/media-url-BQgKvpQ5.mjs.map +0 -1
  1644. package/dist/media-usage-X1_20MY-.mjs +0 -282
  1645. package/dist/media-usage-X1_20MY-.mjs.map +0 -1
  1646. package/dist/media-usage-activation-bWusy3M2.mjs +0 -78
  1647. package/dist/media-usage-activation-bWusy3M2.mjs.map +0 -1
  1648. package/dist/media-usage-work-B2RaoJIa.mjs +0 -151
  1649. package/dist/media-usage-work-B2RaoJIa.mjs.map +0 -1
  1650. package/dist/media-usage-work-BCK2J-v_.mjs +0 -1036
  1651. package/dist/media-usage-work-BCK2J-v_.mjs.map +0 -1
  1652. package/dist/menus-B0Qqv_cS.mjs +0 -837
  1653. package/dist/menus-B0Qqv_cS.mjs.map +0 -1
  1654. package/dist/menus-oypxT1pI.mjs +0 -3802
  1655. package/dist/menus-oypxT1pI.mjs.map +0 -1
  1656. package/dist/menus-uEAxWAm1.mjs +0 -92
  1657. package/dist/menus-uEAxWAm1.mjs.map +0 -1
  1658. package/dist/mime-D1We9jUx.mjs +0 -81
  1659. package/dist/mime-D1We9jUx.mjs.map +0 -1
  1660. package/dist/mode-C-D3qICy.mjs +0 -23
  1661. package/dist/mode-C-D3qICy.mjs.map +0 -1
  1662. package/dist/node-sqlite-compat-CrKzRr0J.mjs +0 -63
  1663. package/dist/node-sqlite-compat-CrKzRr0J.mjs.map +0 -1
  1664. package/dist/normalize-Cx-bNwhP.mjs +0 -220
  1665. package/dist/normalize-Cx-bNwhP.mjs.map +0 -1
  1666. package/dist/oauth-authorization-CPLgBrdo.mjs +0 -287
  1667. package/dist/oauth-authorization-CPLgBrdo.mjs.map +0 -1
  1668. package/dist/oauth-clients-BT0Pg-MO.mjs +0 -266
  1669. package/dist/oauth-clients-BT0Pg-MO.mjs.map +0 -1
  1670. package/dist/oauth-state-store-BndCfRum.mjs +0 -50
  1671. package/dist/oauth-state-store-BndCfRum.mjs.map +0 -1
  1672. package/dist/oauth-user-lookup-BDgF6IVG.mjs +0 -26
  1673. package/dist/oauth-user-lookup-BDgF6IVG.mjs.map +0 -1
  1674. package/dist/object-cache-DmKr09La.mjs +0 -603
  1675. package/dist/object-cache-DmKr09La.mjs.map +0 -1
  1676. package/dist/options-BUUgroHg.d.mts +0 -81
  1677. package/dist/options-BUUgroHg.d.mts.map +0 -1
  1678. package/dist/options-DhrI7eMv.mjs +0 -208
  1679. package/dist/options-DhrI7eMv.mjs.map +0 -1
  1680. package/dist/ownership-MiyA7qKO.mjs +0 -12
  1681. package/dist/ownership-MiyA7qKO.mjs.map +0 -1
  1682. package/dist/parse-B_b6gZxG.mjs +0 -81
  1683. package/dist/parse-B_b6gZxG.mjs.map +0 -1
  1684. package/dist/parse-Dndx1QmN.d.mts +0 -176
  1685. package/dist/parse-Dndx1QmN.d.mts.map +0 -1
  1686. package/dist/passkey-config-D2Lua5__.mjs +0 -46
  1687. package/dist/passkey-config-D2Lua5__.mjs.map +0 -1
  1688. package/dist/paths-biDzFTY2.mjs +0 -77
  1689. package/dist/paths-biDzFTY2.mjs.map +0 -1
  1690. package/dist/patterns-CryGz_EV.mjs +0 -159
  1691. package/dist/patterns-CryGz_EV.mjs.map +0 -1
  1692. package/dist/placeholder-CSKu5OkD.d.mts +0 -314
  1693. package/dist/placeholder-CSKu5OkD.d.mts.map +0 -1
  1694. package/dist/plan-CCoqxNoU.mjs +0 -135
  1695. package/dist/plan-CCoqxNoU.mjs.map +0 -1
  1696. package/dist/plugin-tool-name-DDUgN_0p.mjs +0 -27
  1697. package/dist/plugin-tool-name-DDUgN_0p.mjs.map +0 -1
  1698. package/dist/plugins-COJ2L49n.mjs +0 -261
  1699. package/dist/plugins-COJ2L49n.mjs.map +0 -1
  1700. package/dist/policy-BPugqmeV.mjs +0 -53
  1701. package/dist/policy-BPugqmeV.mjs.map +0 -1
  1702. package/dist/portable-text-BH4zgkSm.mjs +0 -311
  1703. package/dist/portable-text-BH4zgkSm.mjs.map +0 -1
  1704. package/dist/preview-DLexxwp3.mjs +0 -107
  1705. package/dist/preview-DLexxwp3.mjs.map +0 -1
  1706. package/dist/protocol-PoAfD_9W.d.mts +0 -65
  1707. package/dist/protocol-PoAfD_9W.d.mts.map +0 -1
  1708. package/dist/public-plugin-api-routes-CMljrTby.mjs +0 -316
  1709. package/dist/public-plugin-api-routes-CMljrTby.mjs.map +0 -1
  1710. package/dist/public-submission-ayqoyee4.mjs +0 -251
  1711. package/dist/public-submission-ayqoyee4.mjs.map +0 -1
  1712. package/dist/public-url-Bt98vysr.mjs +0 -101
  1713. package/dist/public-url-Bt98vysr.mjs.map +0 -1
  1714. package/dist/query-BFHjCzSh.mjs +0 -37
  1715. package/dist/query-BFHjCzSh.mjs.map +0 -1
  1716. package/dist/query-D62NntCZ.mjs +0 -1146
  1717. package/dist/query-D62NntCZ.mjs.map +0 -1
  1718. package/dist/query-LmPY2y0C.mjs +0 -41
  1719. package/dist/query-LmPY2y0C.mjs.map +0 -1
  1720. package/dist/range-CYfeXgGK.mjs +0 -51
  1721. package/dist/range-CYfeXgGK.mjs.map +0 -1
  1722. package/dist/rate-limit-C04Llsoc.mjs +0 -127
  1723. package/dist/rate-limit-C04Llsoc.mjs.map +0 -1
  1724. package/dist/receipt-BUsQCOeM.mjs +0 -43
  1725. package/dist/receipt-BUsQCOeM.mjs.map +0 -1
  1726. package/dist/redirect-CQAV7mCo.mjs +0 -19
  1727. package/dist/redirect-CQAV7mCo.mjs.map +0 -1
  1728. package/dist/redirect-DjLdw427.mjs +0 -423
  1729. package/dist/redirect-DjLdw427.mjs.map +0 -1
  1730. package/dist/redirect-paths-DOaVBp6E.mjs +0 -36
  1731. package/dist/redirect-paths-DOaVBp6E.mjs.map +0 -1
  1732. package/dist/redirects-Cpq1catN.mjs +0 -446
  1733. package/dist/redirects-Cpq1catN.mjs.map +0 -1
  1734. package/dist/redirects-CyvvZrCJ.mjs +0 -148
  1735. package/dist/redirects-CyvvZrCJ.mjs.map +0 -1
  1736. package/dist/registry-B0-O575m.mjs +0 -8374
  1737. package/dist/registry-B0-O575m.mjs.map +0 -1
  1738. package/dist/relations-WIOojTL4.mjs +0 -789
  1739. package/dist/relations-WIOojTL4.mjs.map +0 -1
  1740. package/dist/request-cache-5z2WzWmh.mjs +0 -104
  1741. package/dist/request-cache-5z2WzWmh.mjs.map +0 -1
  1742. package/dist/request-meta-bwZ_NsvU.mjs +0 -141
  1743. package/dist/request-meta-bwZ_NsvU.mjs.map +0 -1
  1744. package/dist/resolve-BNnm8EkB.mjs +0 -102
  1745. package/dist/resolve-BNnm8EkB.mjs.map +0 -1
  1746. package/dist/resolve-DdNXBJSr.mjs +0 -199
  1747. package/dist/resolve-DdNXBJSr.mjs.map +0 -1
  1748. package/dist/revision-Dx7Uth1X.mjs +0 -374
  1749. package/dist/revision-Dx7Uth1X.mjs.map +0 -1
  1750. package/dist/route-cache-QSOyDEw0.mjs +0 -20
  1751. package/dist/route-cache-QSOyDEw0.mjs.map +0 -1
  1752. package/dist/route-wire-Ca_HWCZ5.mjs +0 -197
  1753. package/dist/route-wire-Ca_HWCZ5.mjs.map +0 -1
  1754. package/dist/routes-avqgc-8r.mjs +0 -272
  1755. package/dist/routes-avqgc-8r.mjs.map +0 -1
  1756. package/dist/runner-Bkkfk4O8.mjs +0 -6669
  1757. package/dist/runner-Bkkfk4O8.mjs.map +0 -1
  1758. package/dist/runner-Dfgp6-S_.d.mts +0 -73
  1759. package/dist/runner-Dfgp6-S_.d.mts.map +0 -1
  1760. package/dist/schema-B-3rntlX.mjs +0 -815
  1761. package/dist/schema-B-3rntlX.mjs.map +0 -1
  1762. package/dist/schema-BqBlUZtb.mjs +0 -13
  1763. package/dist/schema-BqBlUZtb.mjs.map +0 -1
  1764. package/dist/scopes-DNaY7Ey0.mjs +0 -34
  1765. package/dist/scopes-DNaY7Ey0.mjs.map +0 -1
  1766. package/dist/search-BPWTnpnD.mjs +0 -450
  1767. package/dist/search-BPWTnpnD.mjs.map +0 -1
  1768. package/dist/secrets-Dswzrz3k.mjs +0 -369
  1769. package/dist/secrets-Dswzrz3k.mjs.map +0 -1
  1770. package/dist/sections-rSao6rBG.mjs +0 -346
  1771. package/dist/sections-rSao6rBG.mjs.map +0 -1
  1772. package/dist/seo-B_H_pqOd.mjs +0 -133
  1773. package/dist/seo-B_H_pqOd.mjs.map +0 -1
  1774. package/dist/seo-ClB-dw9w.mjs +0 -188
  1775. package/dist/seo-ClB-dw9w.mjs.map +0 -1
  1776. package/dist/service-DpiUQVpp.mjs +0 -150
  1777. package/dist/service-DpiUQVpp.mjs.map +0 -1
  1778. package/dist/session-user-DiE4JKPP.mjs +0 -61
  1779. package/dist/session-user-DiE4JKPP.mjs.map +0 -1
  1780. package/dist/settings--XlUdUaI.mjs +0 -66
  1781. package/dist/settings--XlUdUaI.mjs.map +0 -1
  1782. package/dist/settings-D932YP2-.mjs +0 -519
  1783. package/dist/settings-D932YP2-.mjs.map +0 -1
  1784. package/dist/settings-Dd1uivmQ.mjs +0 -73
  1785. package/dist/settings-Dd1uivmQ.mjs.map +0 -1
  1786. package/dist/setup-complete-qsJYWutC.mjs +0 -65
  1787. package/dist/setup-complete-qsJYWutC.mjs.map +0 -1
  1788. package/dist/setup-nonce-CBFgUFXw.mjs +0 -25
  1789. package/dist/setup-nonce-CBFgUFXw.mjs.map +0 -1
  1790. package/dist/single-flight-cache-D0EaGbN1.mjs +0 -104
  1791. package/dist/single-flight-cache-D0EaGbN1.mjs.map +0 -1
  1792. package/dist/site-domain-oRGS_JfA.mjs +0 -131
  1793. package/dist/site-domain-oRGS_JfA.mjs.map +0 -1
  1794. package/dist/site-settings-DRHfX7bq.mjs +0 -50
  1795. package/dist/site-settings-DRHfX7bq.mjs.map +0 -1
  1796. package/dist/site-url-MB685I5X.mjs +0 -45
  1797. package/dist/site-url-MB685I5X.mjs.map +0 -1
  1798. package/dist/sitemap-name-B8QP8wud.mjs +0 -26
  1799. package/dist/sitemap-name-B8QP8wud.mjs.map +0 -1
  1800. package/dist/slug-aVnUV4SL.mjs +0 -16
  1801. package/dist/slug-aVnUV4SL.mjs.map +0 -1
  1802. package/dist/slugify-BDEG9pLk.mjs +0 -22
  1803. package/dist/slugify-BDEG9pLk.mjs.map +0 -1
  1804. package/dist/snapshot-BjaXDZQ5.mjs +0 -414
  1805. package/dist/snapshot-BjaXDZQ5.mjs.map +0 -1
  1806. package/dist/ssrf-BcYjyM4M.mjs +0 -406
  1807. package/dist/ssrf-BcYjyM4M.mjs.map +0 -1
  1808. package/dist/ssrf-DM0E-D_8.mjs +0 -1
  1809. package/dist/stage-CZQnXM_G.mjs +0 -662
  1810. package/dist/stage-CZQnXM_G.mjs.map +0 -1
  1811. package/dist/staged-ByBmPFtX.mjs +0 -686
  1812. package/dist/staged-ByBmPFtX.mjs.map +0 -1
  1813. package/dist/state-CFbGZziM.mjs +0 -178
  1814. package/dist/state-CFbGZziM.mjs.map +0 -1
  1815. package/dist/status-BFNdxzKc.mjs +0 -30
  1816. package/dist/status-BFNdxzKc.mjs.map +0 -1
  1817. package/dist/storage-query-BFp06Y0s.d.mts +0 -1627
  1818. package/dist/storage-query-BFp06Y0s.d.mts.map +0 -1
  1819. package/dist/tar-DFjExb9X.mjs +0 -449
  1820. package/dist/tar-DFjExb9X.mjs.map +0 -1
  1821. package/dist/target-CWZs2-o6.mjs +0 -27
  1822. package/dist/target-CWZs2-o6.mjs.map +0 -1
  1823. package/dist/taxonomies-5SR76j11.mjs +0 -937
  1824. package/dist/taxonomies-5SR76j11.mjs.map +0 -1
  1825. package/dist/taxonomies-B__VmCKQ.mjs +0 -703
  1826. package/dist/taxonomies-B__VmCKQ.mjs.map +0 -1
  1827. package/dist/taxonomy-CMI5fczd.mjs +0 -563
  1828. package/dist/taxonomy-CMI5fczd.mjs.map +0 -1
  1829. package/dist/tokens-BnhSnGwJ.mjs +0 -171
  1830. package/dist/tokens-BnhSnGwJ.mjs.map +0 -1
  1831. package/dist/transaction-CkoQ5wqQ.mjs +0 -29
  1832. package/dist/transaction-CkoQ5wqQ.mjs.map +0 -1
  1833. package/dist/transfer-BbKfufJ4.mjs +0 -166
  1834. package/dist/transfer-BbKfufJ4.mjs.map +0 -1
  1835. package/dist/transfer-DTGblAj2.mjs +0 -8910
  1836. package/dist/transfer-DTGblAj2.mjs.map +0 -1
  1837. package/dist/transfer-download-D9LQEDX0.mjs +0 -33
  1838. package/dist/transfer-download-D9LQEDX0.mjs.map +0 -1
  1839. package/dist/transformations-Bx4lYY0Y.mjs +0 -196
  1840. package/dist/transformations-Bx4lYY0Y.mjs.map +0 -1
  1841. package/dist/transport-Dm5QzpT_.d.mts +0 -42
  1842. package/dist/transport-Dm5QzpT_.d.mts.map +0 -1
  1843. package/dist/transport-Dzpn5b3i.mjs +0 -137
  1844. package/dist/transport-Dzpn5b3i.mjs.map +0 -1
  1845. package/dist/trusted-proxy-BU3Nx9g1.mjs +0 -51
  1846. package/dist/trusted-proxy-BU3Nx9g1.mjs.map +0 -1
  1847. package/dist/turnstile-Cs2wfkJG.mjs +0 -58
  1848. package/dist/turnstile-Cs2wfkJG.mjs.map +0 -1
  1849. package/dist/types-BAsCk5KU.d.mts +0 -87
  1850. package/dist/types-BAsCk5KU.d.mts.map +0 -1
  1851. package/dist/types-BuvSwT9Y.d.mts +0 -375
  1852. package/dist/types-BuvSwT9Y.d.mts.map +0 -1
  1853. package/dist/types-C4KT3Md2.d.mts +0 -293
  1854. package/dist/types-C4KT3Md2.d.mts.map +0 -1
  1855. package/dist/types-CVXHwIBB.d.mts +0 -125
  1856. package/dist/types-CVXHwIBB.d.mts.map +0 -1
  1857. package/dist/types-C_asjp1J.mjs +0 -201
  1858. package/dist/types-C_asjp1J.mjs.map +0 -1
  1859. package/dist/types-CadaL_k8.d.mts +0 -366
  1860. package/dist/types-CadaL_k8.d.mts.map +0 -1
  1861. package/dist/types-CgfFGfO5.mjs +0 -16
  1862. package/dist/types-CgfFGfO5.mjs.map +0 -1
  1863. package/dist/types-Cj0_yZkn.mjs +0 -18
  1864. package/dist/types-Cj0_yZkn.mjs.map +0 -1
  1865. package/dist/types-CjftrmZR.d.mts +0 -1741
  1866. package/dist/types-CjftrmZR.d.mts.map +0 -1
  1867. package/dist/types-DKwRUA-x.d.mts +0 -916
  1868. package/dist/types-DKwRUA-x.d.mts.map +0 -1
  1869. package/dist/types-DwhEvIVb.mjs +0 -133
  1870. package/dist/types-DwhEvIVb.mjs.map +0 -1
  1871. package/dist/types-GwAyS5SH.d.mts +0 -227
  1872. package/dist/types-GwAyS5SH.d.mts.map +0 -1
  1873. package/dist/types-qHVygneX.mjs +0 -77
  1874. package/dist/types-qHVygneX.mjs.map +0 -1
  1875. package/dist/types-sUHaH7lC.mjs +0 -37
  1876. package/dist/types-sUHaH7lC.mjs.map +0 -1
  1877. package/dist/types-uU2YNYSt.d.mts +0 -209
  1878. package/dist/types-uU2YNYSt.d.mts.map +0 -1
  1879. package/dist/update-check-ABBJgg6M.mjs +0 -161
  1880. package/dist/update-check-ABBJgg6M.mjs.map +0 -1
  1881. package/dist/upload-attempts-DPFC4COv.mjs +0 -32
  1882. package/dist/upload-attempts-DPFC4COv.mjs.map +0 -1
  1883. package/dist/url-DTfGDJhI.mjs +0 -104
  1884. package/dist/url-DTfGDJhI.mjs.map +0 -1
  1885. package/dist/url-pattern-QATUE_rv.mjs +0 -41
  1886. package/dist/url-pattern-QATUE_rv.mjs.map +0 -1
  1887. package/dist/user-By8SzQxS.mjs +0 -171
  1888. package/dist/user-By8SzQxS.mjs.map +0 -1
  1889. package/dist/utils-D5uOi6WS.mjs +0 -450
  1890. package/dist/utils-D5uOi6WS.mjs.map +0 -1
  1891. package/dist/utils-Szp4iBQB.d.mts +0 -376
  1892. package/dist/utils-Szp4iBQB.d.mts.map +0 -1
  1893. package/dist/validate-DDvxy6qG.d.mts +0 -468
  1894. package/dist/validate-DDvxy6qG.d.mts.map +0 -1
  1895. package/dist/validate-Dz-TIOFB.mjs +0 -524
  1896. package/dist/validate-Dz-TIOFB.mjs.map +0 -1
  1897. package/dist/validation-Fc9ZSUS_.mjs +0 -221
  1898. package/dist/validation-Fc9ZSUS_.mjs.map +0 -1
  1899. package/dist/version-BZj18Q7G.mjs +0 -9
  1900. package/dist/version-BZj18Q7G.mjs.map +0 -1
  1901. package/dist/version-Bu6Nlbb5.mjs +0 -7
  1902. package/dist/version-Bu6Nlbb5.mjs.map +0 -1
  1903. package/dist/version-DqB7LIO7.mjs +0 -49
  1904. package/dist/version-DqB7LIO7.mjs.map +0 -1
  1905. package/dist/video-DytCnw3L.mjs +0 -54
  1906. package/dist/video-DytCnw3L.mjs.map +0 -1
  1907. package/dist/virtual-modules-DO954n7P.mjs +0 -515
  1908. package/dist/virtual-modules-DO954n7P.mjs.map +0 -1
  1909. package/dist/widgets-BUx_Mf2q.mjs +0 -134
  1910. package/dist/widgets-BUx_Mf2q.mjs.map +0 -1
  1911. package/dist/wxr-taxonomies-DbJtWrWM.mjs +0 -454
  1912. package/dist/wxr-taxonomies-DbJtWrWM.mjs.map +0 -1
  1913. package/dist/wxr-taxonomies-Dy2i2ON3.d.mts +0 -34
  1914. package/dist/wxr-taxonomies-Dy2i2ON3.d.mts.map +0 -1
  1915. package/dist/zod-generator--nlM0930.mjs +0 -425
  1916. package/dist/zod-generator--nlM0930.mjs.map +0 -1
@@ -0,0 +1,3854 @@
1
+ import { n as isMissingColumnError, r as isMissingTableError } from "./db-errors-unnO6yiZ.mjs";
2
+ import { t as validateIdentifier } from "./validate-DANX1-Qi.mjs";
3
+ import { d as isSqlite } from "./dialect-helpers-DqUMP9fJ.mjs";
4
+ import { l as resolveConfiguredLocale, r as getI18nConfig, s as isI18nEnabled } from "./config-Cs_AwWXI.mjs";
5
+ import { t as after } from "./after-B3AvMfBQ.mjs";
6
+ import { t as OptionsRepository } from "./options-CMocxAku.mjs";
7
+ import { i as isSystemOrderField, t as ContentRepository } from "./content-Dxztag5t.mjs";
8
+ import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-DRnEstVb.mjs";
9
+ import { m as isStoragelessFieldRow, p as isStoragelessField, s as MAX_COLLECTION_LIST_COLUMNS } from "./types-BmBK2cqf.mjs";
10
+ import { r as requestCached } from "./request-cache-BYMs-BGX.mjs";
11
+ import { a as InvalidCursorError, c as ScheduledNotDueError, i as EmDashValidationError, n as ContentMutationConflictError, r as ContentSlugConflictError, t as ContentCollectionNotFoundError } from "./types-BBH-w_KS.mjs";
12
+ import { t as RevisionRepository } from "./revision-D7EedSdU.mjs";
13
+ import { t as withTransaction } from "./transaction-SKrr6u84.mjs";
14
+ import { t as UserRepository } from "./user-C4km6fox.mjs";
15
+ import { t as TaxonomyRepository } from "./taxonomy-s1GcBCRo.mjs";
16
+ import { t as CommentRepository } from "./comment-BGeXmJ8F.mjs";
17
+ import { T as SeoRepository, t as PluginContextFactory, w as toBylineInfo } from "./context-C3OZjexd.mjs";
18
+ import { t as interpolateUrlPattern } from "./resolve-Z5YK_6ew.mjs";
19
+ import { r as redirectPathVariants, t as RedirectRepository } from "./redirect-ChcHI1KC.mjs";
20
+ import { t as BylineRepository } from "./byline--sweE_MZ.mjs";
21
+ import { c as readStagedReferenceBaselines, d as RelationRepository, i as STAGED_REFERENCES_KEY, l as readStagedReferences, r as STAGED_REFERENCES_BASELINE_KEY, s as pageStagedGroups } from "./staged-BN8pRZwX.mjs";
22
+ import { r as parseAllowedMimeTypes, t as matchesMimeAllowlist } from "./mime-Dx6aHTsR.mjs";
23
+ import { t as EntryLockRepository } from "./entry-locks-D_kjygT1.mjs";
24
+ import { i as scheduledPolicyRejectionKey, n as inspectContentPolicyDecision } from "./content-policy-Drm9sqdA.mjs";
25
+ import { n as invalidateRedirectCache } from "./cache-BjnpmIpb.mjs";
26
+ import { r as publishRedirectChanges } from "./artifacts-BXKMIV2F.mjs";
27
+ import { t as FTSManager } from "./fts-manager-B3iLXCGz.mjs";
28
+ import { d as invalidateTermCache } from "./taxonomies-BMuFLd53.mjs";
29
+ import { n as encodeRev, r as validateRev, t as decodeRev } from "./rev-B6HS7337.mjs";
30
+ import { R as BlockTypeRegistry, n as SchemaRegistry } from "./registry-CDzYrAFY.mjs";
31
+ import { r as hashString } from "./hash-SY9Nq5FH.mjs";
32
+ import { n as expandCollectionBlockFields } from "./block-values-DzZIh7WN.mjs";
33
+ import { _ as referenceFieldConstraints, d as resolveEntryGroups, f as resolveReferenceSelection, g as writeReferenceSelection, h as validateOppositeSideLimit, n as getReferenceTitleField, p as resolveReferenceSelectionTargets, u as resolveEntries, v as validateReferenceSelection, y as validateRequiredReferencesPresent } from "./relations-Eyop_U4o.mjs";
34
+ import { a as normalizePluginCapabilities, o as warnDeprecatedPluginCapabilities } from "./types-Ba3bWb9D.mjs";
35
+ import { sql } from "kysely";
36
+ import { AsyncLocalStorage } from "node:async_hooks";
37
+ import { PLUGIN_CAPABILITIES, isJsonPostRouteContract } from "@emdash-cms/plugin-types";
38
+
39
+ //#region src/api/handlers/staged-references.ts
40
+ /** One bound field's live selection as translation groups. */
41
+ async function liveFieldSelection(repo, field, entryGroup) {
42
+ return (field.relationSide === "child" ? await repo.getParents(field.relation, entryGroup) : await repo.getChildren(field.relation, entryGroup)).map((link) => field.relationSide === "child" ? link.parentGroup : link.childGroup);
43
+ }
44
+ /**
45
+ * Re-check what publication is about to make live against the relation's current
46
+ * cardinality.
47
+ *
48
+ * A draft can sit unpublished across a schema edit that makes its field required
49
+ * or narrows the relation's limits, and across another entry claiming what it
50
+ * selected. It is publication — not the save that staged it — that has to hold
51
+ * the line on both ends. So this walks the collection's bound fields rather than
52
+ * the staged keys: a field added as required after the entry was written appears
53
+ * in no existing draft, and iterating `staged` would never reach it. A field the
54
+ * draft does stage needs no link read.
55
+ */
56
+ async function validateStagedReferences(db, collection, staged, entryGroup, baselines) {
57
+ const repo = new RelationRepository(db);
58
+ for (const field of (await referenceFieldConstraints(db, collection)).values()) {
59
+ const isStaged = Object.hasOwn(staged, field.slug);
60
+ let groups = isStaged ? staged[field.slug] ?? [] : void 0;
61
+ const baseline = baselines?.[field.slug];
62
+ if (groups && baseline) {
63
+ const live = await liveFieldSelection(repo, field, entryGroup);
64
+ groups = applyReferenceDiff(baseline, groups, live);
65
+ }
66
+ groups ??= await liveFieldSelection(repo, field, entryGroup);
67
+ const valid = validateReferenceSelection(field, groups);
68
+ if (!valid.success) return valid;
69
+ if (!isStaged || field.relationId === null) continue;
70
+ const far = await validateOppositeSideLimit(db, {
71
+ relationId: field.relationId,
72
+ farLimit: field.maxOpposite,
73
+ side: field.relationSide,
74
+ entryGroup,
75
+ groups
76
+ });
77
+ if (!far.success) return far;
78
+ }
79
+ return {
80
+ success: true,
81
+ data: true
82
+ };
83
+ }
84
+ /**
85
+ * The live selection, in the same shape a draft stages: every bound reference
86
+ * field on the collection, by field slug, as translation groups.
87
+ *
88
+ * One link read per bound field. Used where both selections have to be
89
+ * comparable — the live and draft sides of a compare — never on a render path.
90
+ */
91
+ async function liveReferenceSelection(db, collection, entryGroup) {
92
+ const repo = new RelationRepository(db);
93
+ const selection = {};
94
+ for (const field of (await referenceFieldConstraints(db, collection)).values()) selection[field.slug] = await liveFieldSelection(repo, field, entryGroup);
95
+ return selection;
96
+ }
97
+ /**
98
+ * The live selection as revision data, so that restoring the revision brings these links back.
99
+ * Empty when the collection has no reference field.
100
+ */
101
+ async function liveReferenceData(db, collection, entryGroup) {
102
+ if (!entryGroup) return {};
103
+ const selection = await liveReferenceSelection(db, collection, entryGroup);
104
+ return Object.keys(selection).length > 0 ? { [STAGED_REFERENCES_KEY]: selection } : {};
105
+ }
106
+ /**
107
+ * Compute the selection that results from applying the staged-versus-baseline
108
+ * diff on top of the current live selection.
109
+ *
110
+ * Additions and removals made in the draft win. Items the draft left unchanged
111
+ * follow the current live selection, preserving additions and removals made
112
+ * from the relation's opposite end.
113
+ */
114
+ function applyReferenceDiff(baseline, staged, live) {
115
+ const baselineSet = new Set(baseline);
116
+ const stagedSet = new Set(staged);
117
+ const liveSet = new Set(live);
118
+ const additionSet = new Set(staged.filter((group) => !baselineSet.has(group)));
119
+ const removalSet = new Set(baseline.filter((group) => !stagedSet.has(group)));
120
+ const result = [];
121
+ const seen = /* @__PURE__ */ new Set();
122
+ for (const group of staged) {
123
+ if (!additionSet.has(group) && !liveSet.has(group) || seen.has(group)) continue;
124
+ result.push(group);
125
+ seen.add(group);
126
+ }
127
+ for (const group of live) {
128
+ if (removalSet.has(group) || seen.has(group)) continue;
129
+ result.push(group);
130
+ seen.add(group);
131
+ }
132
+ return result;
133
+ }
134
+ /**
135
+ * Record the complete live selection in the revision publication just made live.
136
+ *
137
+ * A draft stages only the fields its saves named, and a revision written from
138
+ * the columns stages none. Restoring either would otherwise leave whatever was
139
+ * published after it linked in the fields it does not carry.
140
+ */
141
+ async function recordPublishedReferences(db, collection, revisionId, entryGroup) {
142
+ const selection = await liveReferenceSelection(db, collection, entryGroup);
143
+ if (Object.keys(selection).length === 0) return;
144
+ await new RevisionRepository(db).mergeData(revisionId, { [STAGED_REFERENCES_KEY]: selection });
145
+ }
146
+ /**
147
+ * Promote a staged selection to live links.
148
+ *
149
+ * A field slug the collection no longer carries as a bound reference field is
150
+ * skipped: the revision outlived the field, and there is no relation left to
151
+ * write into.
152
+ *
153
+ * When `baselines` are provided, each staged field is promoted as a diff
154
+ * against its baseline rather than as a wholesale replacement. That prevents a
155
+ * draft saved before a concurrent opposite-end publish from undoing the links
156
+ * that publish added or removed.
157
+ */
158
+ async function applyStagedReferences(db, collection, entryGroup, staged, baselines) {
159
+ const constraints = await referenceFieldConstraints(db, collection);
160
+ const repo = new RelationRepository(db);
161
+ for (const [fieldSlug, groups] of Object.entries(staged)) {
162
+ const field = constraints.get(fieldSlug);
163
+ if (!field) continue;
164
+ const baseline = baselines?.[fieldSlug];
165
+ let selection;
166
+ if (baseline) selection = applyReferenceDiff(baseline, groups, await liveFieldSelection(repo, field, entryGroup));
167
+ else selection = groups;
168
+ await writeReferenceSelection(db, {
169
+ relation: field.relation,
170
+ side: field.relationSide,
171
+ entryGroup,
172
+ groups: selection
173
+ });
174
+ }
175
+ }
176
+
177
+ //#endregion
178
+ //#region src/api/handlers/validate-media-fields.ts
179
+ function asMediaRef(value) {
180
+ if (value === null || value === void 0) return null;
181
+ if (typeof value !== "object" || Array.isArray(value)) return null;
182
+ return value;
183
+ }
184
+ function fail(message) {
185
+ return {
186
+ success: false,
187
+ error: {
188
+ code: "INVALID_MIME_FOR_FIELD",
189
+ message
190
+ }
191
+ };
192
+ }
193
+ function addTarget(targets, path, value, allowedMimeTypes, includeDarkVariant) {
194
+ if (!allowedMimeTypes?.length || value == null) return;
195
+ targets.push({
196
+ path,
197
+ value,
198
+ allowedMimeTypes: [...allowedMimeTypes]
199
+ });
200
+ const ref = includeDarkVariant ? asMediaRef(value) : null;
201
+ if (ref && "darkVariant" in ref && ref.darkVariant != null) targets.push({
202
+ path: `${path}.darkVariant`,
203
+ value: ref.darkVariant,
204
+ allowedMimeTypes: [...allowedMimeTypes]
205
+ });
206
+ }
207
+ function collectBlockTargets(targets, field, value) {
208
+ if (!Array.isArray(value)) return {
209
+ success: true,
210
+ data: true
211
+ };
212
+ const types = new Map((field.blockTypes ?? []).map((type) => [type.slug, type]));
213
+ for (const [index, block] of value.entries()) {
214
+ if (!block || typeof block !== "object" || Array.isArray(block)) continue;
215
+ const typeSlug = "_type" in block && typeof block._type === "string" ? block._type : void 0;
216
+ const versionNumber = "_version" in block && typeof block._version === "number" ? block._version : void 0;
217
+ const key = "_key" in block && typeof block._key === "string" ? block._key : String(index);
218
+ const type = typeSlug ? types.get(typeSlug) : void 0;
219
+ const version = type?.versions.find((candidate) => candidate.version === versionNumber);
220
+ if (!type || !version || version.unsupportedTypes?.length) return {
221
+ success: false,
222
+ error: {
223
+ code: "UNSUPPORTED_FIELD_TYPE",
224
+ message: `Field '${field.slug}' block '${key}' has no retained definition`
225
+ }
226
+ };
227
+ for (const nestedField of version.fields) {
228
+ const nestedValue = nestedField.slug in block ? block[nestedField.slug] : void 0;
229
+ const nestedPath = `${field.slug}.${key}.${nestedField.slug}`;
230
+ if (nestedField.type !== "image" && nestedField.type !== "file") continue;
231
+ addTarget(targets, nestedPath, nestedValue, nestedField.validation?.allowedMimeTypes, nestedField.type === "image");
232
+ }
233
+ }
234
+ return {
235
+ success: true,
236
+ data: true
237
+ };
238
+ }
239
+ async function loadMediaFieldsForCollection(db, collectionSlug) {
240
+ const rows = await db.selectFrom("_emdash_fields").innerJoin("_emdash_collections", "_emdash_collections.id", "_emdash_fields.collection_id").select([
241
+ "_emdash_fields.slug",
242
+ "_emdash_fields.type",
243
+ "_emdash_fields.validation"
244
+ ]).where("_emdash_collections.slug", "=", collectionSlug).where("_emdash_fields.type", "in", [
245
+ "file",
246
+ "image",
247
+ "blocks"
248
+ ]).execute();
249
+ const out = [];
250
+ const allBlockTypes = rows.some((row) => row.type === "blocks") ? await new BlockTypeRegistry(db).listBlockTypes() : [];
251
+ const blockTypeBySlug = new Map(allBlockTypes.map((type) => [type.slug, type]));
252
+ for (const row of rows) {
253
+ if (row.type === "blocks") {
254
+ let validation;
255
+ try {
256
+ validation = row.validation ? JSON.parse(row.validation) : {};
257
+ } catch {
258
+ validation = {};
259
+ }
260
+ let configured = [];
261
+ if (validation && typeof validation === "object" && !Array.isArray(validation)) {
262
+ const allowed = "allowedTypes" in validation && Array.isArray(validation.allowedTypes) ? validation.allowedTypes : [];
263
+ const retired = "retiredTypes" in validation && Array.isArray(validation.retiredTypes) ? validation.retiredTypes : [];
264
+ configured = [...allowed, ...retired];
265
+ }
266
+ out.push({
267
+ slug: row.slug,
268
+ type: row.type,
269
+ allowedMimeTypes: [],
270
+ blockTypes: configured.flatMap((slug) => {
271
+ const type = typeof slug === "string" ? blockTypeBySlug.get(slug) : void 0;
272
+ return type ? [type] : [];
273
+ })
274
+ });
275
+ continue;
276
+ }
277
+ const list = parseAllowedMimeTypes(row.validation);
278
+ if (!list) continue;
279
+ out.push({
280
+ slug: row.slug,
281
+ type: row.type,
282
+ allowedMimeTypes: list
283
+ });
284
+ }
285
+ return out;
286
+ }
287
+ async function validateMediaFields(db, collectionSlug, data) {
288
+ const fields = await requestCached(`mediaFields:${collectionSlug}`, () => loadMediaFieldsForCollection(db, collectionSlug));
289
+ if (fields.length === 0) return {
290
+ success: true,
291
+ data: true
292
+ };
293
+ const targets = [];
294
+ for (const field of fields) {
295
+ const value = data[field.slug];
296
+ if (field.type === "blocks") {
297
+ const collected = collectBlockTargets(targets, field, value);
298
+ if (!collected.success) return collected;
299
+ } else addTarget(targets, field.slug, value, field.allowedMimeTypes, field.type === "image");
300
+ }
301
+ if (targets.length === 0) return {
302
+ success: true,
303
+ data: true
304
+ };
305
+ const localIds = /* @__PURE__ */ new Set();
306
+ for (const target of targets) {
307
+ const ref = asMediaRef(target.value);
308
+ if (!ref) continue;
309
+ if ((typeof ref.provider === "string" ? ref.provider : "local") === "local" && typeof ref.id === "string") localIds.add(ref.id);
310
+ }
311
+ const idList = [...localIds];
312
+ const mimeById = /* @__PURE__ */ new Map();
313
+ if (idList.length > 0) for (const batch of chunks(idList, SQL_BATCH_SIZE)) {
314
+ const rows = await db.selectFrom("media").select(["id", "mime_type"]).where("id", "in", batch).execute();
315
+ for (const r of rows) mimeById.set(r.id, r.mime_type);
316
+ }
317
+ for (const target of targets) {
318
+ const ref = asMediaRef(target.value);
319
+ if (!ref) continue;
320
+ const provider = typeof ref.provider === "string" ? ref.provider : "local";
321
+ let mime;
322
+ if (provider === "local") {
323
+ if (typeof ref.id !== "string") return fail(`Field '${target.path}' references media with an invalid id`);
324
+ mime = mimeById.get(ref.id);
325
+ if (!mime) return fail(`Field '${target.path}' references media with unknown MIME type`);
326
+ } else {
327
+ if (typeof ref.mimeType !== "string") return fail(`Field '${target.path}' requires a mimeType declaration for non-local media`);
328
+ mime = ref.mimeType;
329
+ }
330
+ if (!matchesMimeAllowlist(mime, target.allowedMimeTypes)) return fail(`Field '${target.path}' does not accept ${mime}`);
331
+ }
332
+ return {
333
+ success: true,
334
+ data: true
335
+ };
336
+ }
337
+
338
+ //#endregion
339
+ //#region src/api/handlers/content.ts
340
+ /**
341
+ * Narrow a caught error to one carrying a structured `apiError` discriminant.
342
+ * Used by transaction callbacks that want to surface a specific error code
343
+ * through the standard Error throwing path.
344
+ */
345
+ function hasApiError(error) {
346
+ if (!(error instanceof Error) || !("apiError" in error)) return false;
347
+ const { apiError } = error;
348
+ return typeof apiError === "object" && apiError !== null && "code" in apiError && typeof apiError.code === "string";
349
+ }
350
+ /**
351
+ * Abort the surrounding transaction when a relation's limit refused an edge.
352
+ *
353
+ * `farSide` names the end that filled up, which is the opposite of the end the
354
+ * refused group sits on: a child that cannot take another parent refuses with
355
+ * `"parent"`.
356
+ */
357
+ function throwIfReferenceLimitRefused(rejected, farSide) {
358
+ if (rejected.length === 0) return;
359
+ throw Object.assign(/* @__PURE__ */ new Error(`Entry '${rejected[0]}' already has the maximum number of ${farSide} entries on this relation.`), { apiError: { code: "VALIDATION_ERROR" } });
360
+ }
361
+ /** The slug a draft revision stages, when it stages one. */
362
+ function readStagedSlug(data) {
363
+ return typeof data?._slug === "string" ? data._slug : null;
364
+ }
365
+ /**
366
+ * Make every refusal `publish()` decides before it writes, ahead of it.
367
+ *
368
+ * `publish()` decides all of them again and stays authoritative; this does not
369
+ * replace it. It exists for the one caller that has irreversible work to do
370
+ * first — promoting a draft's staged reference selection, which nothing takes
371
+ * back where `withTransaction` degrades to plain statements. A refusal that
372
+ * landed after that promotion would leave a draft's links live on an entry that
373
+ * never published.
374
+ *
375
+ * The optimistic fence `publish()` ends on is not checked here, because it is
376
+ * the write itself: a publish lost to a concurrent edit still promotes.
377
+ */
378
+ async function assertPublishWillNotBeRefused(db, collection, id, existing, options) {
379
+ const { expectedRevision } = options;
380
+ if (expectedRevision && (existing.version !== expectedRevision.version || existing.updatedAt !== expectedRevision.updatedAt)) throw new ContentMutationConflictError();
381
+ if (options.requireDue && options.expectedScheduledAt !== void 0 && existing.scheduledAt !== options.expectedScheduledAt) throw new ScheduledNotDueError();
382
+ const intendedSlug = options.stagedSlug ?? existing.slug;
383
+ if (options.requireSlug && !intendedSlug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
384
+ if (options.stagedSlug !== null && options.stagedSlug !== existing.slug && existing.locale !== null) {
385
+ const conflict = await new ContentRepository(db).findBySlugIncludingTrashed(collection, options.stagedSlug, existing.locale);
386
+ if (conflict && conflict.id !== id) throw new EmDashValidationError(`Cannot publish: slug '${options.stagedSlug}' is already used by another entry in this collection (id: ${conflict.id}). Choose a different slug.`, { code: "SLUG_CONFLICT" });
387
+ }
388
+ }
389
+ function isTranslationLocaleConflict(error, collection) {
390
+ if (!(error instanceof Error)) return false;
391
+ const message = error.message.toLowerCase();
392
+ const storedIndexName = `uidx_ec_${collection}_active_tg_locale`.slice(0, 63).toLowerCase();
393
+ return message.includes(storedIndexName) || message.includes("unique constraint failed") && message.includes("translation_group") && message.includes("locale");
394
+ }
395
+ function decodeRevisionPrecondition(rev) {
396
+ if (rev === void 0) return void 0;
397
+ const decoded = decodeRev(rev);
398
+ if (!decoded) throw new ContentMutationConflictError("Revision precondition did not match");
399
+ return decoded;
400
+ }
401
+ /**
402
+ * Extract a slug source from content data: the collection's `titleField` when
403
+ * it sets one and the entry has a value for it, otherwise `title`, then `name`.
404
+ * Returns null if no suitable string field is found.
405
+ */
406
+ function getSlugSource(data, titleField) {
407
+ const configured = titleField ? data[titleField] : void 0;
408
+ if (typeof configured === "string" && configured.length > 0) return configured;
409
+ if (typeof data.title === "string" && data.title.length > 0) return data.title;
410
+ if (typeof data.name === "string" && data.name.length > 0) return data.name;
411
+ return null;
412
+ }
413
+ /** Default SEO values for content without an explicit SEO row */
414
+ const SEO_DEFAULTS = {
415
+ title: null,
416
+ description: null,
417
+ image: null,
418
+ canonical: null,
419
+ noIndex: false
420
+ };
421
+ /**
422
+ * Check if a collection has SEO enabled.
423
+ *
424
+ * Cached per request so bulk imports do not re-query `_emdash_collections`
425
+ * for every item they create.
426
+ */
427
+ async function collectionHasSeo(db, collection) {
428
+ return requestCached(`collectionHasSeo:${collection}`, async () => {
429
+ return (await db.selectFrom("_emdash_collections").select("has_seo").where("slug", "=", collection).executeTakeFirst())?.has_seo === 1;
430
+ });
431
+ }
432
+ /**
433
+ * Collection publication metadata, cached per request for bulk imports.
434
+ */
435
+ async function getCollectionPublishConfig(db, collection) {
436
+ return requestCached(`collectionPublishConfig:${collection}`, async () => {
437
+ const row = await db.selectFrom("_emdash_collections").select(["supports", "routable"]).where("slug", "=", collection).executeTakeFirst();
438
+ const supports = row?.supports ? JSON.parse(row.supports) : [];
439
+ return {
440
+ supportsRevisions: Array.isArray(supports) && supports.includes("revisions"),
441
+ supportsScheduling: !Array.isArray(supports) || !supports.includes("no-scheduling"),
442
+ routable: row?.routable !== 0
443
+ };
444
+ });
445
+ }
446
+ async function getCollectionTitleField(db, collection) {
447
+ return requestCached(`collectionTitleField:${collection}`, async () => {
448
+ return (await db.selectFrom("_emdash_collections").select("title_field").where("slug", "=", collection).executeTakeFirst())?.title_field ?? null;
449
+ });
450
+ }
451
+ function requireRoutablePublishSlug(routable, slug) {
452
+ if (routable && !slug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
453
+ }
454
+ /**
455
+ * Hydrate SEO data on a single content item if the collection has SEO enabled.
456
+ */
457
+ async function hydrateSeo(db, collection, item, hasSeo) {
458
+ if (!hasSeo) return;
459
+ item.seo = await new SeoRepository(db).get(collection, item.id);
460
+ }
461
+ /**
462
+ * Hydrate SEO data on multiple content items using a single batch query.
463
+ */
464
+ async function hydrateSeoMany(db, collection, items, hasSeo) {
465
+ if (!hasSeo || items.length === 0) return;
466
+ const seoMap = await new SeoRepository(db).getMany(collection, items.map((i) => i.id));
467
+ for (const item of items) item.seo = seoMap.get(item.id) ?? { ...SEO_DEFAULTS };
468
+ }
469
+ async function hydrateBylines(db, collection, item) {
470
+ const bylineRepo = new BylineRepository(db);
471
+ const localeOpt = item.locale ? { locale: item.locale } : void 0;
472
+ const bylines = await bylineRepo.getContentBylines(collection, item.id, localeOpt);
473
+ if (bylines.length > 0) {
474
+ item.bylines = bylines.map((c) => ({
475
+ ...c,
476
+ source: "explicit"
477
+ }));
478
+ item.byline = bylines[0]?.byline ?? null;
479
+ return;
480
+ }
481
+ if (item.primaryBylineId) {
482
+ item.bylines = [];
483
+ item.byline = null;
484
+ return;
485
+ }
486
+ if (item.authorId) {
487
+ const fallback = await bylineRepo.findByUserId(item.authorId, localeOpt);
488
+ if (fallback) {
489
+ item.bylines = [{
490
+ byline: fallback,
491
+ sortOrder: 0,
492
+ roleLabel: null,
493
+ source: "inferred"
494
+ }];
495
+ item.byline = fallback;
496
+ return;
497
+ }
498
+ }
499
+ item.bylines = [];
500
+ item.byline = null;
501
+ }
502
+ function isRecord$1(value) {
503
+ return typeof value === "object" && value !== null;
504
+ }
505
+ /**
506
+ * Hydrate the first page of each reference field's selection onto a single
507
+ * content item, keyed by field slug — the same key the create and update bodies
508
+ * take a selection under.
509
+ *
510
+ * Callers must have already decided `includeDrafts` — draft visibility is
511
+ * enforced by the caller, not this helper — because a resolved entry can carry
512
+ * a draft or scheduled entry's id and slug. The admin's REST GET route is the
513
+ * only caller, and it asks for every entry it serves, so a collection with no
514
+ * reference field still pays the two lookups below.
515
+ *
516
+ * For a caller that opted into drafts, a field whose selection is staged in the
517
+ * entry's draft revision is answered from that revision; every other field, and
518
+ * every field for a caller that did not opt in, is answered from the links,
519
+ * which hold the published selection. That is what keeps a picker change on a
520
+ * published entry invisible until it is published.
521
+ *
522
+ * Either selection arrives one page at a time, with the cursor to walk the rest
523
+ * through the edge routes — a draft's pending selection can be as long as a
524
+ * published one, and a caller that reads an entry should not have to take a
525
+ * field of a thousand entries to find out.
526
+ */
527
+ async function hydrateReferences(db, collection, item, includeDrafts) {
528
+ if (!item.translationGroup) return;
529
+ const collectionRow = await db.selectFrom("_emdash_collections").select("id").where("slug", "=", collection).executeTakeFirst();
530
+ if (!collectionRow) return;
531
+ const fields = await db.selectFrom("_emdash_fields").select(["slug", "validation"]).where("collection_id", "=", collectionRow.id).where("type", "=", "reference").execute();
532
+ const references = {};
533
+ if (fields.length === 0) {
534
+ item.references = references;
535
+ return;
536
+ }
537
+ const repo = new RelationRepository(db);
538
+ const content = new ContentRepository(db);
539
+ const staged = includeDrafts && item.draftRevisionId ? readStagedReferences((await new RevisionRepository(db).findById(item.draftRevisionId))?.data) : void 0;
540
+ for (const field of fields) {
541
+ let validation = {};
542
+ if (field.validation) {
543
+ let parsed;
544
+ try {
545
+ parsed = JSON.parse(field.validation);
546
+ } catch {
547
+ continue;
548
+ }
549
+ if (isRecord$1(parsed)) validation = parsed;
550
+ }
551
+ const relation = typeof validation.relation === "string" ? validation.relation : void 0;
552
+ const targetCollection = typeof validation.targetCollection === "string" ? validation.targetCollection : void 0;
553
+ if (!relation || !targetCollection) continue;
554
+ const stagedGroups = staged?.[field.slug];
555
+ if (stagedGroups) {
556
+ const page = pageStagedGroups(stagedGroups);
557
+ references[field.slug] = {
558
+ children: await resolveEntryGroups(content, targetCollection, page.groups, item.locale, includeDrafts, await getReferenceTitleField(db, targetCollection)),
559
+ ...page.nextCursor ? { nextCursor: page.nextCursor } : {}
560
+ };
561
+ continue;
562
+ }
563
+ const onChildSide = validation.relationSide === "child";
564
+ const edges = onChildSide ? await repo.getParentsPage(relation, item.translationGroup) : await repo.getChildrenPage(relation, item.translationGroup);
565
+ const children = await resolveEntries(content, targetCollection, edges.items, (e) => onChildSide ? e.parentGroup : e.childGroup, item.locale, includeDrafts, await getReferenceTitleField(db, targetCollection));
566
+ references[field.slug] = {
567
+ children,
568
+ ...edges.nextCursor ? { nextCursor: edges.nextCursor } : {}
569
+ };
570
+ }
571
+ item.references = references;
572
+ }
573
+ /**
574
+ * Batch-hydrate bylines for multiple items using two bulk queries instead of N+1.
575
+ *
576
+ * Items may live at different locales (e.g. a list endpoint returning the
577
+ * translations of an entry). Group by `item.locale` and call the strict
578
+ * per-locale repo method once per group so each item resolves against its
579
+ * own locale's byline rows.
580
+ */
581
+ async function hydrateBylinesMany(db, collection, items) {
582
+ if (items.length === 0) return;
583
+ const bylineRepo = new BylineRepository(db);
584
+ const localeBuckets = /* @__PURE__ */ new Map();
585
+ for (const item of items) {
586
+ const key = item.locale ?? null;
587
+ const bucket = localeBuckets.get(key);
588
+ if (bucket) bucket.push(item);
589
+ else localeBuckets.set(key, [item]);
590
+ }
591
+ const bylinesByItem = /* @__PURE__ */ new Map();
592
+ const itemsNeedingAuthorCheck = [];
593
+ for (const [locale, bucket] of localeBuckets) {
594
+ const localeOpt = locale ? { locale } : void 0;
595
+ const ids = bucket.map((i) => i.id);
596
+ const credits = await bylineRepo.getContentBylinesMany(collection, ids, localeOpt);
597
+ for (const [id, list] of credits) bylinesByItem.set(id, list);
598
+ for (const item of bucket) {
599
+ if (credits.has(item.id) && credits.get(item.id).length > 0) continue;
600
+ if (item.authorId) itemsNeedingAuthorCheck.push(item);
601
+ }
602
+ }
603
+ const fallbackByItem = /* @__PURE__ */ new Map();
604
+ if (itemsNeedingAuthorCheck.length > 0) {
605
+ const authorBuckets = /* @__PURE__ */ new Map();
606
+ for (const item of itemsNeedingAuthorCheck) {
607
+ if (item.primaryBylineId) continue;
608
+ const key = item.locale ?? null;
609
+ const bucket = authorBuckets.get(key);
610
+ if (bucket) bucket.push(item);
611
+ else authorBuckets.set(key, [item]);
612
+ }
613
+ for (const [locale, bucket] of authorBuckets) {
614
+ const localeOpt = locale ? { locale } : void 0;
615
+ const authorIds = bucket.map((i) => i.authorId).filter((id) => id !== null);
616
+ const uniqueAuthorIds = [...new Set(authorIds)];
617
+ if (uniqueAuthorIds.length === 0) continue;
618
+ const authorMap = await bylineRepo.findByUserIds(uniqueAuthorIds, localeOpt);
619
+ for (const item of bucket) {
620
+ if (!item.authorId) continue;
621
+ const f = authorMap.get(item.authorId);
622
+ if (f) fallbackByItem.set(item.id, f);
623
+ }
624
+ }
625
+ }
626
+ for (const item of items) {
627
+ const explicit = bylinesByItem.get(item.id);
628
+ if (explicit && explicit.length > 0) {
629
+ item.bylines = explicit.map((c) => ({
630
+ ...c,
631
+ source: "explicit"
632
+ }));
633
+ item.byline = explicit[0]?.byline ?? null;
634
+ continue;
635
+ }
636
+ const fallback = fallbackByItem.get(item.id);
637
+ if (fallback) {
638
+ item.bylines = [{
639
+ byline: fallback,
640
+ sortOrder: 0,
641
+ roleLabel: null,
642
+ source: "inferred"
643
+ }];
644
+ item.byline = fallback;
645
+ continue;
646
+ }
647
+ item.bylines = [];
648
+ item.byline = null;
649
+ }
650
+ }
651
+ /**
652
+ * Resolve an identifier (ID or slug) to a real content ID.
653
+ * Returns the ID if found, null if not found.
654
+ * When locale is provided, slug lookups are scoped to that locale.
655
+ */
656
+ async function resolveId(repo, collection, identifier, locale) {
657
+ return (await repo.findByIdOrSlug(collection, identifier, locale ? resolveConfiguredLocale(locale) : void 0))?.id ?? null;
658
+ }
659
+ /**
660
+ * Resolve an identifier (ID or slug) to a real content ID,
661
+ * including trashed (soft-deleted) items.
662
+ */
663
+ async function resolveIdIncludingTrashed(repo, collection, identifier, locale) {
664
+ return (await repo.findByIdOrSlugIncludingTrashed(collection, identifier, locale ? resolveConfiguredLocale(locale) : void 0))?.id ?? null;
665
+ }
666
+ /**
667
+ * Resolve the columns a content-list search should match against. Always
668
+ * includes `slug` (a standard column), adds the configured `titleField` plus
669
+ * the `title`/`name` display fields when the collection actually defines them,
670
+ * mirroring the admin's item-title resolution (titleField -> title -> name ->
671
+ * slug), and includes every field explicitly marked searchable. Returning only
672
+ * fields that have a column (a reference field bound to a relation has none)
673
+ * avoids "no such column" errors.
674
+ */
675
+ async function resolveSearchColumns(db, collection) {
676
+ const row = await db.selectFrom("_emdash_collections").select(["id", "title_field"]).where("slug", "=", collection).executeTakeFirst();
677
+ if (!row) return ["slug"];
678
+ const fields = (await db.selectFrom("_emdash_fields").select([
679
+ "slug",
680
+ "searchable",
681
+ "type",
682
+ "validation"
683
+ ]).where("collection_id", "=", row.id).orderBy("sort_order", "asc").execute()).filter((f) => !isStoragelessFieldRow(f));
684
+ const columns = new Set(["slug"]);
685
+ const fieldSlugs = new Set(fields.map((f) => f.slug));
686
+ if (row.title_field && fieldSlugs.has(row.title_field)) columns.add(row.title_field);
687
+ for (const candidate of ["title", "name"]) if (fieldSlugs.has(candidate)) columns.add(candidate);
688
+ for (const field of fields) if (field.searchable === 1) columns.add(field.slug);
689
+ return [...columns];
690
+ }
691
+ /**
692
+ * The keys of `data` that name a storage-less field — a reference field bound
693
+ * to a relation, whose selection lives in the edge table and reaches the API
694
+ * under the separate `references` key.
695
+ *
696
+ * A reference field with no relation still owns its column, so its value in
697
+ * `data` is exactly where it belongs and is not returned here.
698
+ */
699
+ async function storagelessDataKeys(db, collection, data) {
700
+ const collectionRow = await db.selectFrom("_emdash_collections").select("id").where("slug", "=", collection).executeTakeFirst();
701
+ if (!collectionRow) return [];
702
+ const fields = await db.selectFrom("_emdash_fields").select([
703
+ "slug",
704
+ "type",
705
+ "validation"
706
+ ]).where("collection_id", "=", collectionRow.id).execute();
707
+ const storageless = new Set(fields.filter(isStoragelessFieldRow).map((f) => f.slug));
708
+ if (storageless.size === 0) return [];
709
+ return Object.keys(data).filter((key) => storageless.has(key));
710
+ }
711
+ /**
712
+ * Refuse a `data` payload that tries to set a storage-less field.
713
+ *
714
+ * Such a key would otherwise reach the column writer and throw "no such
715
+ * column". Dropping it instead is worse than refusing it: a client that can
716
+ * only write `data` would be told its write succeeded while nothing was linked.
717
+ * On a collection that keeps drafts the key never reaches the column writer at
718
+ * all — it is merged into the draft revision's JSON — so the runtime applies
719
+ * this before staging rather than leaving it to the write below.
720
+ */
721
+ function storagelessDataKeyError(keys) {
722
+ return {
723
+ success: false,
724
+ error: {
725
+ code: "VALIDATION_ERROR",
726
+ message: `Reference fields bound to a relation are set through 'references', not 'data': ${keys.join(", ")}`
727
+ }
728
+ };
729
+ }
730
+ /**
731
+ * The storage-less keys in `data` that an update is actually trying to change.
732
+ *
733
+ * A field bound to a relation after its column existed keeps that column, and
734
+ * every read hands the value frozen in it back under the field's own slug. A
735
+ * read-then-write client — the admin editor among them — therefore echoes a key
736
+ * it never touched, and refusing that would make such an entry unsaveable. An
737
+ * echo asks for nothing; a different value is an attempt to set a selection
738
+ * through the one channel that cannot carry it.
739
+ *
740
+ * A key the entry does not store counts as changed, which is every key of a
741
+ * field that never had a column: there is nothing for such a payload to be
742
+ * echoing, and letting it through would reach the column writer.
743
+ */
744
+ function changedStoragelessDataKeys(storageless, data, stored) {
745
+ return Object.keys(data).filter((key) => storageless.has(key) && (!Object.hasOwn(stored, key) || JSON.stringify(data[key]) !== JSON.stringify(stored[key])));
746
+ }
747
+ /**
748
+ * Decide whether the content-list `q` filter can be served from the
749
+ * collection's FTS5 index instead of a full-scan substring LIKE (#1517).
750
+ *
751
+ * Requires SQLite (FTS5 is SQLite-only), search enabled on the collection,
752
+ * every non-slug display column present in the searchable-field set (or the
753
+ * index would miss matches the LIKE finds), and the index table actually
754
+ * existing.
755
+ */
756
+ async function canUseFtsForListFilter(db, collection, searchColumns) {
757
+ if (!isSqlite(db)) return false;
758
+ const ftsManager = new FTSManager(db);
759
+ if (!(await ftsManager.getSearchConfig(collection))?.enabled) return false;
760
+ const searchable = new Set(await ftsManager.getSearchableFields(collection));
761
+ if (!searchColumns.every((col) => col === "slug" || searchable.has(col))) return false;
762
+ return ftsManager.ftsTableExists(collection);
763
+ }
764
+ /**
765
+ * Create a 301 auto-redirect from an entry's old URL to its new one after a
766
+ * slug change, using the collection's URL pattern. Shared by
767
+ * handleContentUpdate (direct slug edits) and handleContentPublish (slug edits
768
+ * staged as `_slug` in a draft revision, which only land on publish).
769
+ */
770
+ async function createSlugChangeRedirect(db, collection, oldSlug, newSlug, contentId, oldPublishedAt, newPublishedAt) {
771
+ if (await slugStillTaken(db, collection, oldSlug, contentId)) return false;
772
+ const collectionRow = await db.selectFrom("_emdash_collections").select("url_pattern").where("slug", "=", collection).executeTakeFirst();
773
+ const redirect = await new RedirectRepository(db).createAutoRedirect(collection, oldSlug, newSlug, contentId, collectionRow?.url_pattern ?? null, oldPublishedAt, newPublishedAt);
774
+ invalidateRedirectCache();
775
+ return redirect !== null;
776
+ }
777
+ /**
778
+ * Remove any auto-redirect whose source is the URL a newly published entry
779
+ * now occupies. This prevents an earlier slug-change redirect from shadowing
780
+ * the new live page, because the redirect middleware runs before routing.
781
+ */
782
+ async function removeShadowingAutoRedirect(db, collection, slug, contentId, publishedAt) {
783
+ if (!slug) return false;
784
+ validateIdentifier(collection, "collection slug");
785
+ const url = interpolateUrlPattern({
786
+ pattern: (await db.selectFrom("_emdash_collections").select("url_pattern").where("slug", "=", collection).executeTakeFirst())?.url_pattern ?? null,
787
+ collection,
788
+ slug,
789
+ id: contentId,
790
+ date: publishedAt
791
+ });
792
+ const result = await db.deleteFrom("_emdash_redirects").where("source", "in", redirectPathVariants(url)).where("auto", "=", 1).executeTakeFirst();
793
+ const removed = BigInt(result.numDeletedRows ?? 0n) > 0n;
794
+ if (removed) invalidateRedirectCache();
795
+ return removed;
796
+ }
797
+ /** Whether a row other than `contentId` still holds `slug` in this collection. */
798
+ async function slugStillTaken(db, collection, slug, contentId) {
799
+ validateIdentifier(collection, "collection slug");
800
+ return (await sql`
801
+ SELECT id FROM ${sql.ref(`ec_${collection}`)}
802
+ WHERE slug = ${slug}
803
+ AND id != ${contentId}
804
+ AND deleted_at IS NULL
805
+ LIMIT 1
806
+ `.execute(db)).rows.length > 0;
807
+ }
808
+ /** Matches a date-only `YYYY-MM-DD` bound (no time component). */
809
+ const DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/;
810
+ /**
811
+ * Normalize a date-range bound to an ISO datetime for lexicographic comparison
812
+ * against stored ISO 8601 timestamps. A bare `YYYY-MM-DD` is widened to the
813
+ * appropriate UTC day boundary so the range stays inclusive: a `start` bound
814
+ * becomes the start of the day and an `end` bound the end of the day.
815
+ * Otherwise a date-only upper bound would exclude every same-day row (since
816
+ * `2024-06-01T12:00:00Z` sorts after `2024-06-01`). Full datetimes pass
817
+ * through unchanged.
818
+ */
819
+ function normalizeDateBound(value, edge) {
820
+ if (!value) return void 0;
821
+ if (!DATE_ONLY_RE.test(value)) return new Date(value).toISOString();
822
+ return edge === "start" ? `${value}T00:00:00.000Z` : `${value}T23:59:59.999Z`;
823
+ }
824
+ /**
825
+ * Build the repository's byline filter from the wire params.
826
+ *
827
+ * `locale` is the locale the list is scoped to, which is the locale an
828
+ * inferred credit has to resolve at — the admin list is always scoped to the
829
+ * locale picked in its switcher.
830
+ */
831
+ function resolveBylineFilter(params, locale) {
832
+ const includeInferred = params.includeInferredBylines === true;
833
+ if (params.bylinesNone) return {
834
+ mode: "none",
835
+ includeInferred,
836
+ locale
837
+ };
838
+ const bylineIds = params.bylines ?? [];
839
+ if (bylineIds.length === 0) return void 0;
840
+ return {
841
+ mode: "any",
842
+ bylineIds,
843
+ includeInferred,
844
+ locale
845
+ };
846
+ }
847
+ /**
848
+ * Rows to skip for a numbered page, or `null` when the page can't be served
849
+ * (combined with a cursor, or past the safe-integer range).
850
+ */
851
+ function pageOffset(params) {
852
+ const offset = (params.page - 1) * params.limit;
853
+ if (params.cursor !== void 0 || !Number.isSafeInteger(params.page) || params.page < 1 || !Number.isSafeInteger(offset)) return null;
854
+ return offset;
855
+ }
856
+ /**
857
+ * Create content list handler
858
+ */
859
+ async function handleContentList(db, collection, params) {
860
+ try {
861
+ const limit = Math.max(1, Math.min(params.limit || 50, 100));
862
+ const offset = params.page === void 0 ? void 0 : pageOffset({
863
+ page: params.page,
864
+ limit,
865
+ cursor: params.cursor
866
+ });
867
+ if (offset === null) return {
868
+ success: false,
869
+ error: {
870
+ code: "VALIDATION_ERROR",
871
+ message: "Invalid content page"
872
+ }
873
+ };
874
+ const repo = new ContentRepository(db);
875
+ const where = {};
876
+ if (params.status) where.status = params.status;
877
+ const locale = params.locale ? resolveConfiguredLocale(params.locale) : void 0;
878
+ if (locale) where.locale = locale;
879
+ if (params.authorId) where.authorId = params.authorId;
880
+ if (params.fieldFilters && Object.keys(params.fieldFilters).length > 0) where.fieldFilters = params.fieldFilters;
881
+ const bylineFilter = resolveBylineFilter(params, locale);
882
+ if (bylineFilter) where.bylineFilter = bylineFilter;
883
+ if (params.dateField && (params.dateFrom || params.dateTo)) where.dateFilter = {
884
+ field: params.dateField,
885
+ from: normalizeDateBound(params.dateFrom, "start"),
886
+ to: normalizeDateBound(params.dateTo, "end")
887
+ };
888
+ const q = params.q?.trim();
889
+ if (q) {
890
+ where.q = q;
891
+ where.searchColumns = await resolveSearchColumns(db, collection);
892
+ where.useFts = await canUseFtsForListFilter(db, collection, where.searchColumns);
893
+ }
894
+ let sortableExtras;
895
+ if (params.orderBy && !isSystemOrderField(params.orderBy)) {
896
+ const coll = await db.selectFrom("_emdash_collections").select(["title_field", "date_field"]).where("slug", "=", collection).executeTakeFirst();
897
+ sortableExtras = [coll?.title_field, coll?.date_field].filter((slug) => !!slug);
898
+ }
899
+ const result = await repo.findMany(collection, {
900
+ cursor: params.cursor,
901
+ offset,
902
+ limit,
903
+ where: Object.keys(where).length > 0 ? where : void 0,
904
+ orderBy: params.orderBy ? {
905
+ field: params.orderBy,
906
+ direction: params.order || "desc"
907
+ } : void 0,
908
+ sortableExtras
909
+ });
910
+ const unpublishedDrafts = result.items.filter((item) => item.status !== "published" && item.liveRevisionId === null && item.draftRevisionId);
911
+ const draftIds = unpublishedDrafts.flatMap((item) => item.draftRevisionId ? [item.draftRevisionId] : []);
912
+ if (draftIds.length > 0) {
913
+ const revisions = await new RevisionRepository(db).findByIds(collection, draftIds);
914
+ const byId = new Map(revisions.map((revision) => [revision.id, revision]));
915
+ for (const item of unpublishedDrafts) {
916
+ if (!item.draftRevisionId) continue;
917
+ const revision = byId.get(item.draftRevisionId);
918
+ if (!revision || revision.entryId !== item.id) continue;
919
+ const fields = Object.fromEntries(Object.entries(revision.data).filter(([key]) => !key.startsWith("_")));
920
+ item.data = {
921
+ ...item.data,
922
+ ...fields
923
+ };
924
+ }
925
+ }
926
+ const hasSeo = await collectionHasSeo(db, collection);
927
+ await hydrateSeoMany(db, collection, result.items, hasSeo);
928
+ await hydrateBylinesMany(db, collection, result.items);
929
+ return {
930
+ success: true,
931
+ data: {
932
+ items: result.items,
933
+ nextCursor: result.nextCursor,
934
+ total: result.total
935
+ }
936
+ };
937
+ } catch (error) {
938
+ if (error instanceof InvalidCursorError) return {
939
+ success: false,
940
+ error: {
941
+ code: "INVALID_CURSOR",
942
+ message: error.message
943
+ }
944
+ };
945
+ if (error instanceof ContentCollectionNotFoundError || isMissingTableError(error)) return {
946
+ success: false,
947
+ error: {
948
+ code: "COLLECTION_NOT_FOUND",
949
+ message: `Collection '${collection}' not found`
950
+ }
951
+ };
952
+ if (isMissingColumnError(error, "deleted_at")) return {
953
+ success: false,
954
+ error: {
955
+ code: "COLLECTION_SCHEMA_MISMATCH",
956
+ message: `Collection '${collection}' backing table is missing the 'deleted_at' column`
957
+ }
958
+ };
959
+ if (error instanceof EmDashValidationError) return {
960
+ success: false,
961
+ error: {
962
+ code: "VALIDATION_ERROR",
963
+ message: error.message
964
+ }
965
+ };
966
+ console.error("Content list error:", error);
967
+ return {
968
+ success: false,
969
+ error: {
970
+ code: "CONTENT_LIST_ERROR",
971
+ message: "Failed to list content"
972
+ }
973
+ };
974
+ }
975
+ }
976
+ /**
977
+ * List the distinct authors of a collection's live content.
978
+ *
979
+ * Backs the admin content-list author filter. Unlike `/admin/users` (ADMIN
980
+ * only), this is gated on `content:read`, so any editor can filter by author.
981
+ * Returns only users who have authored at least one non-trashed entry, sorted
982
+ * by display name then email for a stable dropdown order.
983
+ */
984
+ async function handleContentAuthors(db, collection) {
985
+ try {
986
+ const authorIds = await new ContentRepository(db).findDistinctAuthorIds(collection);
987
+ if (authorIds.length === 0) return {
988
+ success: true,
989
+ data: { items: [] }
990
+ };
991
+ return {
992
+ success: true,
993
+ data: { items: (await new UserRepository(db).findByIds(authorIds)).map((u) => ({
994
+ id: u.id,
995
+ name: u.name,
996
+ email: u.email,
997
+ avatarUrl: u.avatarUrl
998
+ })).toSorted((a, b) => (a.name ?? a.email).localeCompare(b.name ?? b.email)) }
999
+ };
1000
+ } catch (error) {
1001
+ if (isMissingTableError(error)) return {
1002
+ success: false,
1003
+ error: {
1004
+ code: "COLLECTION_NOT_FOUND",
1005
+ message: `Collection '${collection}' not found`
1006
+ }
1007
+ };
1008
+ console.error("Content authors error:", error);
1009
+ return {
1010
+ success: false,
1011
+ error: {
1012
+ code: "CONTENT_AUTHORS_ERROR",
1013
+ message: "Failed to list content authors"
1014
+ }
1015
+ };
1016
+ }
1017
+ }
1018
+ /**
1019
+ * Get single content item
1020
+ */
1021
+ async function handleContentGet(db, collection, id, locale, referenceOptions) {
1022
+ try {
1023
+ const item = await new ContentRepository(db).findByIdOrSlug(collection, id, locale ? resolveConfiguredLocale(locale) : void 0);
1024
+ if (!item) return {
1025
+ success: false,
1026
+ error: {
1027
+ code: "NOT_FOUND",
1028
+ message: `Content item not found: ${id}`
1029
+ }
1030
+ };
1031
+ await hydrateSeo(db, collection, item, await collectionHasSeo(db, collection));
1032
+ await hydrateBylines(db, collection, item);
1033
+ if (referenceOptions) await hydrateReferences(db, collection, item, referenceOptions.includeDrafts);
1034
+ return {
1035
+ success: true,
1036
+ data: {
1037
+ item,
1038
+ _rev: encodeRev(item)
1039
+ }
1040
+ };
1041
+ } catch (error) {
1042
+ console.error("Content get error:", error);
1043
+ return {
1044
+ success: false,
1045
+ error: {
1046
+ code: "CONTENT_GET_ERROR",
1047
+ message: "Failed to get content"
1048
+ }
1049
+ };
1050
+ }
1051
+ }
1052
+ /**
1053
+ * Get a content item by id, including trashed items.
1054
+ * Used by restore endpoint for ownership checks on soft-deleted items.
1055
+ */
1056
+ async function handleContentGetIncludingTrashed(db, collection, id, locale) {
1057
+ try {
1058
+ const item = await new ContentRepository(db).findByIdOrSlugIncludingTrashed(collection, id, locale ? resolveConfiguredLocale(locale) : void 0);
1059
+ if (!item) return {
1060
+ success: false,
1061
+ error: {
1062
+ code: "NOT_FOUND",
1063
+ message: `Content item not found: ${id}`
1064
+ }
1065
+ };
1066
+ await hydrateSeo(db, collection, item, await collectionHasSeo(db, collection));
1067
+ await hydrateBylines(db, collection, item);
1068
+ return {
1069
+ success: true,
1070
+ data: {
1071
+ item,
1072
+ _rev: encodeRev(item)
1073
+ }
1074
+ };
1075
+ } catch (error) {
1076
+ console.error("Content get error:", error);
1077
+ return {
1078
+ success: false,
1079
+ error: {
1080
+ code: "CONTENT_GET_ERROR",
1081
+ message: "Failed to get content"
1082
+ }
1083
+ };
1084
+ }
1085
+ }
1086
+ /**
1087
+ * Create content item.
1088
+ *
1089
+ * Content + SEO writes are wrapped in a transaction so either both succeed
1090
+ * or neither does. If `body.seo` is provided for a non-SEO collection, the
1091
+ * API returns a validation error rather than silently dropping it.
1092
+ */
1093
+ async function handleContentCreate(db, collection, body) {
1094
+ try {
1095
+ const hasSeo = await collectionHasSeo(db, collection);
1096
+ if (body.seo && !hasSeo) return {
1097
+ success: false,
1098
+ error: {
1099
+ code: "VALIDATION_ERROR",
1100
+ message: `Collection "${collection}" does not have SEO enabled. Remove the seo field or enable SEO on this collection.`
1101
+ }
1102
+ };
1103
+ const storagelessKeys = await storagelessDataKeys(db, collection, body.data);
1104
+ if (storagelessKeys.length > 0) return storagelessDataKeyError(storagelessKeys);
1105
+ const mimeCheck = await validateMediaFields(db, collection, body.data);
1106
+ if (!mimeCheck.success) return mimeCheck;
1107
+ const requiredReferences = await validateRequiredReferencesPresent(db, collection, body.references, body.translationOf);
1108
+ if (!requiredReferences.success) return requiredReferences;
1109
+ let redirectChanged = false;
1110
+ const item = await withTransaction(db, async (trx) => {
1111
+ const repo = new ContentRepository(trx);
1112
+ const bylineRepo = new BylineRepository(trx);
1113
+ const inheritedFields = body.translationOf ? (await trx.selectFrom("_emdash_fields as field").innerJoin("_emdash_collections as collection", "collection.id", "field.collection_id").select("field.slug").where("collection.slug", "=", collection).where("field.translatable", "=", 0).execute()).map((field) => field.slug) : [];
1114
+ const referenceWrites = [];
1115
+ if (body.references) {
1116
+ const entryGroup = body.translationOf ? (await repo.findById(collection, body.translationOf))?.translationGroup ?? null : null;
1117
+ for (const [fieldSlug, selectedIds] of Object.entries(body.references)) {
1118
+ const resolved = await resolveReferenceSelectionTargets(trx, collection, fieldSlug, selectedIds, entryGroup);
1119
+ if (!resolved.success) throw Object.assign(new Error(resolved.error.message), { apiError: { code: resolved.error.code } });
1120
+ referenceWrites.push(resolved.data);
1121
+ }
1122
+ }
1123
+ const effectiveLocale = body.locale ? resolveConfiguredLocale(body.locale) : getI18nConfig()?.defaultLocale;
1124
+ let slug = body.slug;
1125
+ if (!slug) {
1126
+ const slugSource = getSlugSource(body.data, await getCollectionTitleField(trx, collection));
1127
+ if (slugSource) slug = await repo.generateUniqueSlug(collection, slugSource, effectiveLocale);
1128
+ }
1129
+ if (body.status === "published") requireRoutablePublishSlug((await getCollectionPublishConfig(trx, collection)).routable, slug);
1130
+ const created = await repo.create({
1131
+ type: collection,
1132
+ slug,
1133
+ data: body.data,
1134
+ status: body.status || "draft",
1135
+ authorId: body.authorId,
1136
+ locale: effectiveLocale,
1137
+ translationOf: body.translationOf,
1138
+ inheritFields: inheritedFields,
1139
+ createdAt: body.createdAt,
1140
+ publishedAt: body.publishedAt
1141
+ });
1142
+ if (body.bylines !== void 0) created.primaryBylineId = (await bylineRepo.setContentBylines(collection, created.id, body.bylines))[0]?.byline.translationGroup ?? null;
1143
+ if (body.translationOf) {
1144
+ if (body.bylines === void 0) {
1145
+ await bylineRepo.copyContentBylines(collection, body.translationOf, created.id);
1146
+ const source = await repo.findById(collection, body.translationOf);
1147
+ if (source) created.primaryBylineId = source.primaryBylineId;
1148
+ }
1149
+ }
1150
+ await hydrateBylines(trx, collection, created);
1151
+ if (body.seo && hasSeo) created.seo = await new SeoRepository(trx).upsert(collection, created.id, body.seo);
1152
+ else if (hasSeo) created.seo = { ...SEO_DEFAULTS };
1153
+ if (body.taxonomies) await assignTaxonomies(trx, collection, created.id, effectiveLocale, body.taxonomies);
1154
+ if (created.translationGroup) for (const write of referenceWrites) await writeReferenceSelection(trx, {
1155
+ ...write,
1156
+ entryGroup: created.translationGroup
1157
+ });
1158
+ if (created.status === "published") redirectChanged = await removeShadowingAutoRedirect(trx, collection, created.slug, created.id, created.publishedAt);
1159
+ return created;
1160
+ });
1161
+ if (redirectChanged) after(() => publishRedirectChanges(db));
1162
+ return {
1163
+ success: true,
1164
+ data: {
1165
+ item,
1166
+ _rev: encodeRev(item)
1167
+ }
1168
+ };
1169
+ } catch (error) {
1170
+ if (hasApiError(error)) return {
1171
+ success: false,
1172
+ error: {
1173
+ code: error.apiError.code,
1174
+ message: error.message
1175
+ }
1176
+ };
1177
+ if (isMissingTableError(error)) return {
1178
+ success: false,
1179
+ error: {
1180
+ code: "COLLECTION_NOT_FOUND",
1181
+ message: `Collection '${collection}' not found`
1182
+ }
1183
+ };
1184
+ if (error instanceof ContentMutationConflictError) return {
1185
+ success: false,
1186
+ error: {
1187
+ code: "CONFLICT",
1188
+ message: error.message
1189
+ }
1190
+ };
1191
+ if (error instanceof ContentSlugConflictError) return {
1192
+ success: false,
1193
+ error: {
1194
+ code: "SLUG_CONFLICT",
1195
+ message: `Slug '${body.slug ?? "(auto-generated)"}' already exists in collection '${collection}'`
1196
+ }
1197
+ };
1198
+ if (error instanceof EmDashValidationError) {
1199
+ if (error.message === "Translation source content not found") return {
1200
+ success: false,
1201
+ error: {
1202
+ code: "NOT_FOUND",
1203
+ message: error.message
1204
+ }
1205
+ };
1206
+ return {
1207
+ success: false,
1208
+ error: {
1209
+ code: "VALIDATION_ERROR",
1210
+ message: error.message
1211
+ }
1212
+ };
1213
+ }
1214
+ const message = error instanceof Error ? error.message.toLowerCase() : "";
1215
+ if (message.includes("unique constraint failed") || message.includes("duplicate key")) {
1216
+ if (message.includes("active_tg_locale") || message.includes("translation_group") && message.includes("locale")) return {
1217
+ success: false,
1218
+ error: {
1219
+ code: "CONFLICT",
1220
+ message: `Translation already exists in locale "${body.locale ?? getI18nConfig()?.defaultLocale ?? "en"}" for this content item`
1221
+ }
1222
+ };
1223
+ if (message.includes("slug")) return {
1224
+ success: false,
1225
+ error: {
1226
+ code: "SLUG_CONFLICT",
1227
+ message: `Slug '${body.slug ?? "(auto-generated)"}' already exists in collection '${collection}'`
1228
+ }
1229
+ };
1230
+ return {
1231
+ success: false,
1232
+ error: {
1233
+ code: "CONFLICT",
1234
+ message: "Unique constraint violation"
1235
+ }
1236
+ };
1237
+ }
1238
+ console.error("Content create error:", error);
1239
+ return {
1240
+ success: false,
1241
+ error: {
1242
+ code: "CONTENT_CREATE_ERROR",
1243
+ message: "Failed to create content"
1244
+ }
1245
+ };
1246
+ }
1247
+ }
1248
+ /**
1249
+ * Update content item.
1250
+ * If `_rev` is provided, validates it against the current version before writing.
1251
+ * No `_rev` = blind write (backwards-compatible for admin UI).
1252
+ *
1253
+ * Content + SEO writes are wrapped in a transaction for atomicity.
1254
+ */
1255
+ async function handleContentUpdate(db, collection, id, body) {
1256
+ try {
1257
+ const hasSeo = await collectionHasSeo(db, collection);
1258
+ if (body.seo && !hasSeo) return {
1259
+ success: false,
1260
+ error: {
1261
+ code: "VALIDATION_ERROR",
1262
+ message: `Collection "${collection}" does not have SEO enabled. Remove the seo field or enable SEO on this collection.`
1263
+ }
1264
+ };
1265
+ if (body.data) {
1266
+ const mimeCheck = await validateMediaFields(db, collection, body.data);
1267
+ if (!mimeCheck.success) return mimeCheck;
1268
+ }
1269
+ const repo = new ContentRepository(db);
1270
+ const resolvedId = await resolveId(repo, collection, id, body.locale) ?? id;
1271
+ if (body.data) {
1272
+ const storagelessKeys = await storagelessDataKeys(db, collection, body.data);
1273
+ if (storagelessKeys.length > 0) {
1274
+ const stored = await repo.findById(collection, resolvedId);
1275
+ const changed = changedStoragelessDataKeys(new Set(storagelessKeys), body.data, stored?.data ?? {});
1276
+ if (changed.length > 0) return storagelessDataKeyError(changed);
1277
+ }
1278
+ }
1279
+ let redirectChanged = false;
1280
+ const item = await withTransaction(db, async (trx) => {
1281
+ const trxRepo = new ContentRepository(trx);
1282
+ const bylineRepo = new BylineRepository(trx);
1283
+ const existing = body._rev || body.slug !== void 0 || body.status === "published" ? await trxRepo.findById(collection, resolvedId) : null;
1284
+ if (body._rev) {
1285
+ if (!existing) throw Object.assign(/* @__PURE__ */ new Error(`Content item not found: ${id}`), { apiError: { code: "NOT_FOUND" } });
1286
+ const revCheck = validateRev(body._rev, existing);
1287
+ if (!revCheck.valid) throw Object.assign(new Error(revCheck.message), { apiError: { code: "CONFLICT" } });
1288
+ }
1289
+ let oldSlug;
1290
+ if (body.slug && existing?.slug && existing.slug !== body.slug) oldSlug = existing.slug;
1291
+ if ((body.status ?? existing?.status) === "published") {
1292
+ if (!existing) throw Object.assign(/* @__PURE__ */ new Error(`Content item not found: ${id}`), { apiError: { code: "NOT_FOUND" } });
1293
+ const publishConfig = await getCollectionPublishConfig(trx, collection);
1294
+ const intendedSlug = body.slug !== void 0 ? body.slug : existing.slug;
1295
+ requireRoutablePublishSlug(publishConfig.routable, intendedSlug);
1296
+ }
1297
+ const referenceWrites = [];
1298
+ if (body.references) for (const [fieldSlug, selectedIds] of Object.entries(body.references)) {
1299
+ const resolved = await resolveReferenceSelection(trx, collection, resolvedId, fieldSlug, selectedIds);
1300
+ if (!resolved.success) throw Object.assign(new Error(resolved.error.message), { apiError: { code: resolved.error.code } });
1301
+ referenceWrites.push(resolved.data);
1302
+ }
1303
+ const { supportsRevisions } = await getCollectionPublishConfig(trx, collection);
1304
+ const updated = await trxRepo.update(collection, resolvedId, {
1305
+ data: body.data,
1306
+ slug: body.slug,
1307
+ locale: existing?.locale ?? body.locale,
1308
+ status: body.status,
1309
+ authorId: body.authorId,
1310
+ publishedAt: body.publishedAt,
1311
+ ...supportsRevisions ? {} : { draftRevisionId: null }
1312
+ }, body._rev ? decodeRevisionPrecondition(body._rev) : void 0);
1313
+ if (body.bylines !== void 0) updated.primaryBylineId = (await bylineRepo.setContentBylines(collection, resolvedId, body.bylines))[0]?.byline.translationGroup ?? null;
1314
+ if (oldSlug && body.slug && existing?.status === "published") redirectChanged = await createSlugChangeRedirect(trx, collection, oldSlug, body.slug, resolvedId, existing?.publishedAt ?? null, updated.publishedAt ?? null);
1315
+ if (isI18nEnabled() && body.data && updated.translationGroup) await trxRepo.syncNonTranslatableFields(collection, updated.id, updated.translationGroup, body.data);
1316
+ if (body.seo && hasSeo) updated.seo = await new SeoRepository(trx).upsert(collection, resolvedId, body.seo);
1317
+ else if (hasSeo) updated.seo = await new SeoRepository(trx).get(collection, resolvedId);
1318
+ await hydrateBylines(trx, collection, updated);
1319
+ if (body.taxonomies) await assignTaxonomies(trx, collection, resolvedId, updated.locale ?? body.locale, body.taxonomies);
1320
+ for (const write of referenceWrites) await writeReferenceSelection(trx, write);
1321
+ if (updated.status === "published") redirectChanged = await removeShadowingAutoRedirect(trx, collection, updated.slug, updated.id, updated.publishedAt) || redirectChanged;
1322
+ return updated;
1323
+ });
1324
+ if (redirectChanged) after(() => publishRedirectChanges(db));
1325
+ return {
1326
+ success: true,
1327
+ data: {
1328
+ item,
1329
+ _rev: encodeRev(item)
1330
+ }
1331
+ };
1332
+ } catch (error) {
1333
+ if (hasApiError(error)) return {
1334
+ success: false,
1335
+ error: {
1336
+ code: error.apiError.code,
1337
+ message: error.message
1338
+ }
1339
+ };
1340
+ if (error instanceof ContentMutationConflictError) return {
1341
+ success: false,
1342
+ error: {
1343
+ code: "CONFLICT",
1344
+ message: error.message
1345
+ }
1346
+ };
1347
+ if (isMissingTableError(error)) return {
1348
+ success: false,
1349
+ error: {
1350
+ code: "COLLECTION_NOT_FOUND",
1351
+ message: `Collection '${collection}' not found`
1352
+ }
1353
+ };
1354
+ if (error instanceof EmDashValidationError) return {
1355
+ success: false,
1356
+ error: {
1357
+ code: "VALIDATION_ERROR",
1358
+ message: error.message
1359
+ }
1360
+ };
1361
+ if (error instanceof ContentSlugConflictError) return {
1362
+ success: false,
1363
+ error: {
1364
+ code: "SLUG_CONFLICT",
1365
+ message: `Slug '${body.slug ?? id}' already exists in collection '${collection}'`
1366
+ }
1367
+ };
1368
+ const message = error instanceof Error ? error.message.toLowerCase() : "";
1369
+ if (message.includes("unique constraint failed") || message.includes("duplicate key")) {
1370
+ if (message.includes("slug")) return {
1371
+ success: false,
1372
+ error: {
1373
+ code: "SLUG_CONFLICT",
1374
+ message: `Slug '${body.slug ?? id}' already exists in collection '${collection}'`
1375
+ }
1376
+ };
1377
+ return {
1378
+ success: false,
1379
+ error: {
1380
+ code: "CONFLICT",
1381
+ message: "Unique constraint violation"
1382
+ }
1383
+ };
1384
+ }
1385
+ console.error("Content update error:", error);
1386
+ return {
1387
+ success: false,
1388
+ error: {
1389
+ code: "CONTENT_UPDATE_ERROR",
1390
+ message: "Failed to update content"
1391
+ }
1392
+ };
1393
+ }
1394
+ }
1395
+ /**
1396
+ * Duplicate content item.
1397
+ *
1398
+ * Only copies SEO data if the collection has SEO enabled.
1399
+ * Always returns consistent `seo` shape for SEO-enabled collections.
1400
+ */
1401
+ async function handleContentDuplicate(db, collection, id, authorId) {
1402
+ try {
1403
+ const hasSeo = await collectionHasSeo(db, collection);
1404
+ return {
1405
+ success: true,
1406
+ data: { item: await withTransaction(db, async (trx) => {
1407
+ const repo = new ContentRepository(trx);
1408
+ const bylineRepo = new BylineRepository(trx);
1409
+ const resolvedId = await resolveId(repo, collection, id) ?? id;
1410
+ const original = await repo.findById(collection, resolvedId);
1411
+ const dup = await repo.duplicate(collection, resolvedId, authorId);
1412
+ if (original?.translationGroup && dup.translationGroup) {
1413
+ const relations = new RelationRepository(trx);
1414
+ throwIfReferenceLimitRefused(await relations.copyParentEdges(original.translationGroup, dup.translationGroup), "parent");
1415
+ for (const field of (await referenceFieldConstraints(trx, collection)).values()) {
1416
+ if (field.relationSide !== "child") continue;
1417
+ const parents = await relations.getParents(field.relation, original.translationGroup);
1418
+ if (parents.length === 0) continue;
1419
+ throwIfReferenceLimitRefused(await relations.setParents(field.relation, dup.translationGroup, parents.map((parent) => parent.parentGroup)), "child");
1420
+ }
1421
+ }
1422
+ const existingBylines = await bylineRepo.getContentBylines(collection, resolvedId);
1423
+ if (existingBylines.length > 0) await bylineRepo.setContentBylines(collection, dup.id, existingBylines.map((entry) => ({
1424
+ bylineId: entry.byline.id,
1425
+ roleLabel: entry.roleLabel
1426
+ })));
1427
+ if (hasSeo) {
1428
+ const seoRepo = new SeoRepository(trx);
1429
+ await seoRepo.copyForDuplicate(collection, resolvedId, dup.id);
1430
+ dup.seo = await seoRepo.get(collection, dup.id);
1431
+ }
1432
+ await hydrateBylines(trx, collection, dup);
1433
+ return dup;
1434
+ }) }
1435
+ };
1436
+ } catch (err) {
1437
+ if (err instanceof EmDashValidationError) return {
1438
+ success: false,
1439
+ error: {
1440
+ code: "NOT_FOUND",
1441
+ message: err.message
1442
+ }
1443
+ };
1444
+ if (hasApiError(err)) return {
1445
+ success: false,
1446
+ error: {
1447
+ code: err.apiError.code,
1448
+ message: err.message
1449
+ }
1450
+ };
1451
+ console.error("Content duplicate error:", err);
1452
+ return {
1453
+ success: false,
1454
+ error: {
1455
+ code: "CONTENT_DUPLICATE_ERROR",
1456
+ message: "Failed to duplicate content"
1457
+ }
1458
+ };
1459
+ }
1460
+ }
1461
+ /**
1462
+ * Delete content item (soft delete - moves to trash)
1463
+ */
1464
+ async function handleContentDelete(db, collection, id) {
1465
+ try {
1466
+ const result = await withTransaction(db, async (trx) => {
1467
+ const repo = new ContentRepository(trx);
1468
+ const resolvedId = await resolveId(repo, collection, id) ?? id;
1469
+ const deleted = await repo.delete(collection, resolvedId);
1470
+ if (deleted) await new EntryLockRepository(trx).releaseEntry(collection, resolvedId);
1471
+ return {
1472
+ id: resolvedId,
1473
+ deleted
1474
+ };
1475
+ });
1476
+ if (!result.deleted) return {
1477
+ success: false,
1478
+ error: {
1479
+ code: "NOT_FOUND",
1480
+ message: `Content item not found: ${id}`
1481
+ }
1482
+ };
1483
+ return {
1484
+ success: true,
1485
+ data: {
1486
+ deleted: true,
1487
+ id: result.id
1488
+ }
1489
+ };
1490
+ } catch (error) {
1491
+ console.error("Content delete error:", error);
1492
+ return {
1493
+ success: false,
1494
+ error: {
1495
+ code: "CONTENT_DELETE_ERROR",
1496
+ message: "Failed to delete content"
1497
+ }
1498
+ };
1499
+ }
1500
+ }
1501
+ /**
1502
+ * Restore content item from trash
1503
+ */
1504
+ async function handleContentRestore(db, collection, id, options = {}) {
1505
+ try {
1506
+ const expectedRevision = decodeRevisionPrecondition(options._rev);
1507
+ const item = await withTransaction(db, async (trx) => {
1508
+ const repo = new ContentRepository(trx);
1509
+ const resolvedId = await resolveIdIncludingTrashed(repo, collection, id) ?? id;
1510
+ return repo.restore(collection, resolvedId, expectedRevision);
1511
+ });
1512
+ if (!item) return {
1513
+ success: false,
1514
+ error: {
1515
+ code: "NOT_FOUND",
1516
+ message: `Trashed content item not found: ${id}`
1517
+ }
1518
+ };
1519
+ return {
1520
+ success: true,
1521
+ data: {
1522
+ restored: true,
1523
+ item,
1524
+ _rev: encodeRev(item)
1525
+ }
1526
+ };
1527
+ } catch (error) {
1528
+ if (error instanceof ContentMutationConflictError) return {
1529
+ success: false,
1530
+ error: {
1531
+ code: "CONFLICT",
1532
+ message: error.message
1533
+ }
1534
+ };
1535
+ if (isTranslationLocaleConflict(error, collection)) return {
1536
+ success: false,
1537
+ error: {
1538
+ code: "CONFLICT",
1539
+ message: "An active translation already exists in this locale"
1540
+ }
1541
+ };
1542
+ console.error("Content restore error:", error);
1543
+ return {
1544
+ success: false,
1545
+ error: {
1546
+ code: "CONTENT_RESTORE_ERROR",
1547
+ message: "Failed to restore content"
1548
+ }
1549
+ };
1550
+ }
1551
+ }
1552
+ /**
1553
+ * Permanently delete content item (cannot be undone).
1554
+ * Also cleans up associated SEO data.
1555
+ */
1556
+ async function handleContentPermanentDelete(db, collection, id) {
1557
+ try {
1558
+ const resolvedId = await resolveIdIncludingTrashed(new ContentRepository(db), collection, id) ?? id;
1559
+ if (!await withTransaction(db, async (trx) => {
1560
+ const trxRepo = new ContentRepository(trx);
1561
+ const item = await trxRepo.findByIdIncludingTrashed(collection, resolvedId);
1562
+ if (!item || item.deletedAt === null) return false;
1563
+ const lastOfGroup = item.translationGroup !== null ? !await trxRepo.hasTranslationsIncludingTrashed(collection, item.translationGroup, { excludeId: resolvedId }) : false;
1564
+ if (lastOfGroup && item.translationGroup) await new RelationRepository(trx).clearReferencesForGroup(item.translationGroup);
1565
+ const wasDeleted = await trxRepo.permanentDelete(collection, resolvedId);
1566
+ if (wasDeleted) {
1567
+ await new SeoRepository(trx).delete(collection, resolvedId);
1568
+ await new CommentRepository(trx).deleteByContent(collection, resolvedId);
1569
+ await new RevisionRepository(trx).deleteByEntry(collection, resolvedId);
1570
+ await new EntryLockRepository(trx).releaseEntry(collection, resolvedId);
1571
+ await new BylineRepository(trx).deleteContentBylines(collection, resolvedId);
1572
+ if (lastOfGroup && item.translationGroup) await new TaxonomyRepository(trx).clearEntryGroupTerms(collection, item.translationGroup);
1573
+ }
1574
+ return wasDeleted;
1575
+ })) return {
1576
+ success: false,
1577
+ error: {
1578
+ code: "NOT_FOUND",
1579
+ message: `Content item not found: ${id}`
1580
+ }
1581
+ };
1582
+ return {
1583
+ success: true,
1584
+ data: {
1585
+ deleted: true,
1586
+ id: resolvedId
1587
+ }
1588
+ };
1589
+ } catch (error) {
1590
+ console.error("Content permanent delete error:", error);
1591
+ return {
1592
+ success: false,
1593
+ error: {
1594
+ code: "CONTENT_DELETE_ERROR",
1595
+ message: "Failed to permanently delete content"
1596
+ }
1597
+ };
1598
+ }
1599
+ }
1600
+ /**
1601
+ * List trashed content items
1602
+ */
1603
+ async function handleContentListTrashed(db, collection, options = {}) {
1604
+ try {
1605
+ const limit = Math.max(1, Math.min(options.limit || 50, 100));
1606
+ const offset = options.page === void 0 ? void 0 : pageOffset({
1607
+ page: options.page,
1608
+ limit,
1609
+ cursor: options.cursor
1610
+ });
1611
+ if (offset === null) return {
1612
+ success: false,
1613
+ error: {
1614
+ code: "VALIDATION_ERROR",
1615
+ message: "Invalid content page"
1616
+ }
1617
+ };
1618
+ const repo = new ContentRepository(db);
1619
+ const where = { locale: options.locale };
1620
+ const [rowsResult, countResult] = await Promise.allSettled([repo.findTrashed(collection, {
1621
+ limit,
1622
+ cursor: options.cursor,
1623
+ offset,
1624
+ where
1625
+ }), offset === void 0 ? void 0 : repo.countTrashed(collection, where)]);
1626
+ if (rowsResult.status === "rejected") throw rowsResult.reason;
1627
+ if (countResult.status === "rejected") throw countResult.reason;
1628
+ const result = rowsResult.value;
1629
+ return {
1630
+ success: true,
1631
+ data: {
1632
+ items: result.items.map((item) => ({
1633
+ id: item.id,
1634
+ type: item.type,
1635
+ slug: item.slug,
1636
+ status: item.status,
1637
+ locale: item.locale,
1638
+ translationGroup: item.translationGroup,
1639
+ data: item.data,
1640
+ authorId: item.authorId,
1641
+ createdAt: item.createdAt,
1642
+ updatedAt: item.updatedAt,
1643
+ publishedAt: item.publishedAt,
1644
+ deletedAt: item.deletedAt
1645
+ })),
1646
+ nextCursor: result.nextCursor,
1647
+ total: countResult.value
1648
+ }
1649
+ };
1650
+ } catch (error) {
1651
+ if (error instanceof InvalidCursorError) return {
1652
+ success: false,
1653
+ error: {
1654
+ code: "INVALID_CURSOR",
1655
+ message: error.message
1656
+ }
1657
+ };
1658
+ console.error("Content list trashed error:", error);
1659
+ return {
1660
+ success: false,
1661
+ error: {
1662
+ code: "CONTENT_LIST_ERROR",
1663
+ message: "Failed to list trashed content"
1664
+ }
1665
+ };
1666
+ }
1667
+ }
1668
+ /**
1669
+ * Count trashed content items
1670
+ */
1671
+ async function handleContentCountTrashed(db, collection, options = {}) {
1672
+ try {
1673
+ return {
1674
+ success: true,
1675
+ data: { count: await new ContentRepository(db).countTrashed(collection, { locale: options.locale }) }
1676
+ };
1677
+ } catch (error) {
1678
+ console.error("Content count trashed error:", error);
1679
+ return {
1680
+ success: false,
1681
+ error: {
1682
+ code: "CONTENT_COUNT_ERROR",
1683
+ message: "Failed to count trashed content"
1684
+ }
1685
+ };
1686
+ }
1687
+ }
1688
+ /**
1689
+ * Schedule content for future publishing
1690
+ */
1691
+ async function handleContentSchedule(db, collection, id, scheduledAt, currentTime = /* @__PURE__ */ new Date(), _rev) {
1692
+ try {
1693
+ const expectedRevision = decodeRevisionPrecondition(_rev);
1694
+ const item = await withTransaction(db, async (trx) => {
1695
+ const repo = new ContentRepository(trx);
1696
+ const existing = await repo.findByIdOrSlug(collection, id);
1697
+ const resolvedId = existing?.id ?? id;
1698
+ if (existing) {
1699
+ const publishConfig = await getCollectionPublishConfig(trx, collection);
1700
+ if (!publishConfig.supportsScheduling) throw new EmDashValidationError("Scheduling is disabled for this collection");
1701
+ requireRoutablePublishSlug(publishConfig.routable, existing.slug);
1702
+ }
1703
+ return repo.schedule(collection, resolvedId, scheduledAt, currentTime, expectedRevision);
1704
+ });
1705
+ await hydrateSeo(db, collection, item, await collectionHasSeo(db, collection));
1706
+ return {
1707
+ success: true,
1708
+ data: {
1709
+ item,
1710
+ _rev: encodeRev(item)
1711
+ }
1712
+ };
1713
+ } catch (error) {
1714
+ if (error instanceof ContentMutationConflictError) return {
1715
+ success: false,
1716
+ error: {
1717
+ code: "CONFLICT",
1718
+ message: error.message
1719
+ }
1720
+ };
1721
+ if (error instanceof EmDashValidationError) return {
1722
+ success: false,
1723
+ error: {
1724
+ code: "VALIDATION_ERROR",
1725
+ message: error.message
1726
+ }
1727
+ };
1728
+ console.error("Content schedule error:", error);
1729
+ return {
1730
+ success: false,
1731
+ error: {
1732
+ code: "CONTENT_SCHEDULE_ERROR",
1733
+ message: "Failed to schedule content"
1734
+ }
1735
+ };
1736
+ }
1737
+ }
1738
+ /**
1739
+ * Unschedule content (revert to draft)
1740
+ */
1741
+ async function handleContentUnschedule(db, collection, id, options = {}) {
1742
+ try {
1743
+ const expectedRevision = decodeRevisionPrecondition(options._rev);
1744
+ const item = await withTransaction(db, async (trx) => {
1745
+ const repo = new ContentRepository(trx);
1746
+ const resolvedId = await resolveId(repo, collection, id) ?? id;
1747
+ return repo.unschedule(collection, resolvedId, expectedRevision);
1748
+ });
1749
+ await hydrateSeo(db, collection, item, await collectionHasSeo(db, collection));
1750
+ return {
1751
+ success: true,
1752
+ data: {
1753
+ item,
1754
+ _rev: encodeRev(item)
1755
+ }
1756
+ };
1757
+ } catch (error) {
1758
+ if (error instanceof ContentMutationConflictError) return {
1759
+ success: false,
1760
+ error: {
1761
+ code: "CONFLICT",
1762
+ message: error.message
1763
+ }
1764
+ };
1765
+ if (error instanceof EmDashValidationError) return {
1766
+ success: false,
1767
+ error: {
1768
+ code: "VALIDATION_ERROR",
1769
+ message: error.message
1770
+ }
1771
+ };
1772
+ console.error("Content unschedule error:", error);
1773
+ return {
1774
+ success: false,
1775
+ error: {
1776
+ code: "CONTENT_UNSCHEDULE_ERROR",
1777
+ message: "Failed to unschedule content"
1778
+ }
1779
+ };
1780
+ }
1781
+ }
1782
+ /**
1783
+ * Persist a permanent policy rejection and unschedule the publication.
1784
+ * Databases with transactions commit both writes together. D1 persists the
1785
+ * reason first so a failed option write cannot silently remove the entry from
1786
+ * future sweeps; if unscheduling then fails, the due entry and its dashboard
1787
+ * notice remain available for retry and operator action.
1788
+ */
1789
+ async function handleScheduledPolicyRejection(db, collection, id, options) {
1790
+ try {
1791
+ const expectedRevision = decodeRevisionPrecondition(options._rev);
1792
+ const item = await withTransaction(db, async (trx) => {
1793
+ const repo = new ContentRepository(trx);
1794
+ const resolvedId = await resolveId(repo, collection, id) ?? id;
1795
+ const optionsRepo = new OptionsRepository(trx);
1796
+ const rejectionKey = scheduledPolicyRejectionKey(collection, resolvedId);
1797
+ const rejectionRevision = await optionsRepo.setVersioned(rejectionKey, {
1798
+ ...options.rejection,
1799
+ id: resolvedId
1800
+ });
1801
+ try {
1802
+ return await repo.unschedule(collection, resolvedId, expectedRevision);
1803
+ } catch (error) {
1804
+ if (error instanceof ContentMutationConflictError) try {
1805
+ await optionsRepo.compareAndDelete(rejectionKey, rejectionRevision);
1806
+ } catch (cleanupError) {
1807
+ console.error("Failed to clear stale scheduled policy rejection:", cleanupError);
1808
+ }
1809
+ throw error;
1810
+ }
1811
+ });
1812
+ await hydrateSeo(db, collection, item, await collectionHasSeo(db, collection));
1813
+ return {
1814
+ success: true,
1815
+ data: {
1816
+ item,
1817
+ _rev: encodeRev(item)
1818
+ }
1819
+ };
1820
+ } catch (error) {
1821
+ if (error instanceof ContentMutationConflictError) return {
1822
+ success: false,
1823
+ error: {
1824
+ code: "CONFLICT",
1825
+ message: error.message
1826
+ }
1827
+ };
1828
+ if (error instanceof EmDashValidationError) return {
1829
+ success: false,
1830
+ error: {
1831
+ code: "VALIDATION_ERROR",
1832
+ message: error.message
1833
+ }
1834
+ };
1835
+ console.error("Scheduled policy rejection error:", error);
1836
+ return {
1837
+ success: false,
1838
+ error: {
1839
+ code: "CONTENT_UNSCHEDULE_ERROR",
1840
+ message: "Failed to record scheduled publication rejection"
1841
+ }
1842
+ };
1843
+ }
1844
+ }
1845
+ /**
1846
+ * Publish content immediately.
1847
+ *
1848
+ * Publication is one atomic content-row statement. On databases that support
1849
+ * transactions, the slug redirect and the locale sync stay grouped with it.
1850
+ */
1851
+ async function handleContentPublish(db, collection, id, options = {}) {
1852
+ try {
1853
+ const expectedRevision = decodeRevisionPrecondition(options._rev);
1854
+ let redirectChanged = false;
1855
+ const item = await withTransaction(db, async (trx) => {
1856
+ const repo = new ContentRepository(trx);
1857
+ const resolvedId = await resolveId(repo, collection, id) ?? id;
1858
+ const publishConfig = await getCollectionPublishConfig(trx, collection);
1859
+ const existing = await repo.findById(collection, resolvedId);
1860
+ const draftRevision = publishConfig.supportsRevisions && existing?.draftRevisionId ? await new RevisionRepository(trx).findById(existing.draftRevisionId) : void 0;
1861
+ const stagedReferences = draftRevision ? readStagedReferences(draftRevision.data) : void 0;
1862
+ const stagedReferenceBaselines = draftRevision ? readStagedReferenceBaselines(draftRevision.data) : void 0;
1863
+ if (existing?.translationGroup) {
1864
+ const valid = await validateStagedReferences(trx, collection, stagedReferences ?? {}, existing.translationGroup, stagedReferenceBaselines);
1865
+ if (!valid.success) throw Object.assign(new Error(valid.error.message), { apiError: { code: valid.error.code } });
1866
+ if (stagedReferences) {
1867
+ await assertPublishWillNotBeRefused(trx, collection, resolvedId, existing, {
1868
+ stagedSlug: readStagedSlug(draftRevision?.data),
1869
+ requireSlug: publishConfig.routable,
1870
+ requireDue: options.requireScheduledDue,
1871
+ expectedScheduledAt: options.expectedScheduledAt,
1872
+ expectedRevision
1873
+ });
1874
+ await applyStagedReferences(trx, collection, existing.translationGroup, stagedReferences, stagedReferenceBaselines);
1875
+ }
1876
+ }
1877
+ if (publishConfig.supportsRevisions && existing) {
1878
+ const entryGroup = existing.translationGroup;
1879
+ await repo.keepStartingRevision(new RevisionRepository(trx), collection, existing, () => liveReferenceData(trx, collection, entryGroup));
1880
+ }
1881
+ const published = await repo.publish(collection, resolvedId, options.publishedAt, options.requireScheduledDue, options.expectedScheduledAt, publishConfig.supportsRevisions, publishConfig.routable, expectedRevision, options.currentTime);
1882
+ if (publishConfig.supportsRevisions && published.liveRevisionId && published.translationGroup) await recordPublishedReferences(trx, collection, published.liveRevisionId, published.translationGroup);
1883
+ if (existing && isI18nEnabled() && publishConfig.supportsRevisions && published.translationGroup) await repo.syncNonTranslatableFields(collection, published.id, published.translationGroup, published.data, { previous: existing.data });
1884
+ if (existing?.status === "published" && existing.slug && published.slug && existing.slug !== published.slug) redirectChanged = await createSlugChangeRedirect(trx, collection, existing.slug, published.slug, resolvedId, existing.publishedAt ?? null, published.publishedAt ?? null);
1885
+ redirectChanged = await removeShadowingAutoRedirect(trx, collection, published.slug, published.id, published.publishedAt) || redirectChanged;
1886
+ return published;
1887
+ });
1888
+ if (redirectChanged) after(() => publishRedirectChanges(db));
1889
+ await hydrateSeo(db, collection, item, await collectionHasSeo(db, collection));
1890
+ return {
1891
+ success: true,
1892
+ data: {
1893
+ item,
1894
+ _rev: encodeRev(item)
1895
+ }
1896
+ };
1897
+ } catch (error) {
1898
+ if (hasApiError(error)) return {
1899
+ success: false,
1900
+ error: {
1901
+ code: error.apiError.code,
1902
+ message: error.message
1903
+ }
1904
+ };
1905
+ if (error instanceof ContentMutationConflictError) return {
1906
+ success: false,
1907
+ error: {
1908
+ code: "CONFLICT",
1909
+ message: error.message
1910
+ }
1911
+ };
1912
+ if (error instanceof ScheduledNotDueError) return {
1913
+ success: false,
1914
+ error: {
1915
+ code: "NOT_DUE",
1916
+ message: error.message
1917
+ }
1918
+ };
1919
+ if (error instanceof EmDashValidationError) {
1920
+ const details = error.details;
1921
+ return {
1922
+ success: false,
1923
+ error: {
1924
+ code: typeof details === "object" && details !== null && "code" in details && details.code === "SLUG_CONFLICT" ? "SLUG_CONFLICT" : "VALIDATION_ERROR",
1925
+ message: error.message
1926
+ }
1927
+ };
1928
+ }
1929
+ const message = error instanceof Error ? error.message.toLowerCase() : "";
1930
+ if ((message.includes("unique constraint failed") || message.includes("duplicate key")) && message.includes("slug")) return {
1931
+ success: false,
1932
+ error: {
1933
+ code: "SLUG_CONFLICT",
1934
+ message: `The staged slug is already used by another entry in collection '${collection}'`
1935
+ }
1936
+ };
1937
+ console.error("Content publish error:", error);
1938
+ return {
1939
+ success: false,
1940
+ error: {
1941
+ code: "CONTENT_PUBLISH_ERROR",
1942
+ message: "Failed to publish content"
1943
+ }
1944
+ };
1945
+ }
1946
+ }
1947
+ /**
1948
+ * Unpublish content (revert to draft).
1949
+ *
1950
+ * Wrapped in a transaction — unpublish may create a draft revision
1951
+ * from the live version then update the status, which is multi-step.
1952
+ */
1953
+ async function handleContentUnpublish(db, collection, id, options = {}) {
1954
+ try {
1955
+ const expectedRevision = decodeRevisionPrecondition(options._rev);
1956
+ const item = await withTransaction(db, async (trx) => {
1957
+ const repo = new ContentRepository(trx);
1958
+ const resolvedId = await resolveId(repo, collection, id) ?? id;
1959
+ const { supportsRevisions } = await getCollectionPublishConfig(trx, collection);
1960
+ return repo.unpublish(collection, resolvedId, expectedRevision, supportsRevisions);
1961
+ });
1962
+ await hydrateSeo(db, collection, item, await collectionHasSeo(db, collection));
1963
+ return {
1964
+ success: true,
1965
+ data: {
1966
+ item,
1967
+ _rev: encodeRev(item)
1968
+ }
1969
+ };
1970
+ } catch (error) {
1971
+ if (error instanceof ContentMutationConflictError) return {
1972
+ success: false,
1973
+ error: {
1974
+ code: "CONFLICT",
1975
+ message: error.message
1976
+ }
1977
+ };
1978
+ if (error instanceof EmDashValidationError) return {
1979
+ success: false,
1980
+ error: {
1981
+ code: "VALIDATION_ERROR",
1982
+ message: error.message
1983
+ }
1984
+ };
1985
+ console.error("Content unpublish error:", error);
1986
+ return {
1987
+ success: false,
1988
+ error: {
1989
+ code: "CONTENT_UNPUBLISH_ERROR",
1990
+ message: "Failed to unpublish content"
1991
+ }
1992
+ };
1993
+ }
1994
+ }
1995
+ /**
1996
+ * Count scheduled content items
1997
+ */
1998
+ async function handleContentCountScheduled(db, collection) {
1999
+ try {
2000
+ return {
2001
+ success: true,
2002
+ data: { count: await new ContentRepository(db).countScheduled(collection) }
2003
+ };
2004
+ } catch (error) {
2005
+ console.error("Content count scheduled error:", error);
2006
+ return {
2007
+ success: false,
2008
+ error: {
2009
+ code: "CONTENT_COUNT_ERROR",
2010
+ message: "Failed to count scheduled content"
2011
+ }
2012
+ };
2013
+ }
2014
+ }
2015
+ /**
2016
+ * Discard draft changes (revert to live version)
2017
+ */
2018
+ async function handleContentDiscardDraft(db, collection, id, options = {}) {
2019
+ try {
2020
+ const expectedRevision = decodeRevisionPrecondition(options._rev);
2021
+ const item = await withTransaction(db, async (trx) => {
2022
+ const repo = new ContentRepository(trx);
2023
+ const resolvedId = await resolveId(repo, collection, id) ?? id;
2024
+ return repo.discardDraft(collection, resolvedId, expectedRevision);
2025
+ });
2026
+ await hydrateSeo(db, collection, item, await collectionHasSeo(db, collection));
2027
+ return {
2028
+ success: true,
2029
+ data: {
2030
+ item,
2031
+ _rev: encodeRev(item)
2032
+ }
2033
+ };
2034
+ } catch (error) {
2035
+ if (error instanceof ContentMutationConflictError) return {
2036
+ success: false,
2037
+ error: {
2038
+ code: "CONFLICT",
2039
+ message: error.message
2040
+ }
2041
+ };
2042
+ if (error instanceof EmDashValidationError) return {
2043
+ success: false,
2044
+ error: {
2045
+ code: "NOT_FOUND",
2046
+ message: error.message
2047
+ }
2048
+ };
2049
+ console.error("Content discard draft error:", error);
2050
+ return {
2051
+ success: false,
2052
+ error: {
2053
+ code: "CONTENT_DISCARD_DRAFT_ERROR",
2054
+ message: "Failed to discard draft"
2055
+ }
2056
+ };
2057
+ }
2058
+ }
2059
+ /**
2060
+ * Compare live and draft revisions
2061
+ */
2062
+ async function handleContentCompare(db, collection, id) {
2063
+ try {
2064
+ const entry = await new ContentRepository(db).findByIdOrSlug(collection, id);
2065
+ if (!entry) return {
2066
+ success: false,
2067
+ error: {
2068
+ code: "NOT_FOUND",
2069
+ message: `Content item not found: ${id}`
2070
+ }
2071
+ };
2072
+ const revisionRepo = new RevisionRepository(db);
2073
+ const live = entry.liveRevisionId ? await revisionRepo.findById(entry.liveRevisionId) : null;
2074
+ const draft = entry.draftRevisionId ? await revisionRepo.findById(entry.draftRevisionId) : null;
2075
+ const liveReferences = entry.translationGroup ? await liveReferenceSelection(db, collection, entry.translationGroup) : {};
2076
+ const withReferences = (revisionData, staged) => {
2077
+ if (!revisionData) return void 0;
2078
+ const selection = {
2079
+ ...liveReferences,
2080
+ ...staged
2081
+ };
2082
+ if (Object.keys(selection).length === 0) return revisionData;
2083
+ return {
2084
+ ...revisionData,
2085
+ [STAGED_REFERENCES_KEY]: selection
2086
+ };
2087
+ };
2088
+ return {
2089
+ success: true,
2090
+ data: {
2091
+ hasChanges: entry.draftRevisionId !== null && entry.draftRevisionId !== entry.liveRevisionId,
2092
+ live: withReferences(live?.data, {}) ?? null,
2093
+ draft: withReferences(draft?.data, readStagedReferences(draft?.data) ?? {}) ?? null
2094
+ }
2095
+ };
2096
+ } catch (error) {
2097
+ console.error("Content compare error:", error);
2098
+ return {
2099
+ success: false,
2100
+ error: {
2101
+ code: "CONTENT_COMPARE_ERROR",
2102
+ message: "Failed to compare revisions"
2103
+ }
2104
+ };
2105
+ }
2106
+ }
2107
+ /**
2108
+ * Get all translations for a content item.
2109
+ * Returns the item's translation group members with locale and status info.
2110
+ */
2111
+ async function handleContentTranslations(db, collection, id) {
2112
+ try {
2113
+ const repo = new ContentRepository(db);
2114
+ const item = await repo.findByIdOrSlug(collection, id);
2115
+ if (!item) return {
2116
+ success: false,
2117
+ error: {
2118
+ code: "NOT_FOUND",
2119
+ message: `Content item not found: ${id}`
2120
+ }
2121
+ };
2122
+ if (!item.translationGroup) return {
2123
+ success: true,
2124
+ data: {
2125
+ translationGroup: item.id,
2126
+ translations: [{
2127
+ id: item.id,
2128
+ locale: item.locale,
2129
+ slug: item.slug,
2130
+ status: item.status,
2131
+ updatedAt: item.updatedAt
2132
+ }]
2133
+ }
2134
+ };
2135
+ const translations = await repo.findTranslations(collection, item.translationGroup);
2136
+ return {
2137
+ success: true,
2138
+ data: {
2139
+ translationGroup: item.translationGroup,
2140
+ translations: translations.map((t) => ({
2141
+ id: t.id,
2142
+ locale: t.locale,
2143
+ slug: t.slug,
2144
+ status: t.status,
2145
+ updatedAt: t.updatedAt
2146
+ }))
2147
+ }
2148
+ };
2149
+ } catch (error) {
2150
+ if (error instanceof Error) console.error("Content translations error:", error);
2151
+ return {
2152
+ success: false,
2153
+ error: {
2154
+ code: "CONTENT_TRANSLATIONS_ERROR",
2155
+ message: "Failed to get translations"
2156
+ }
2157
+ };
2158
+ }
2159
+ }
2160
+ /**
2161
+ * Resolve a `{ taxonomyName: [slug, ...] }` map to term IDs and replace the
2162
+ * entry's assignments for each named taxonomy.
2163
+ *
2164
+ * Shared by handleContentCreate and handleContentUpdate so both MCP entry
2165
+ * points behave identically. Slug resolution is scoped to `locale`; passing
2166
+ * `undefined` lets `findBySlug` fall back to its default (lowest locale code)
2167
+ * so callers on single-locale sites don't need to know the site's default.
2168
+ *
2169
+ * Throws EmDashValidationError on unknown slug or wrong shape; the calling
2170
+ * handler translates that into a VALIDATION_ERROR response.
2171
+ */
2172
+ async function assignTaxonomies(trx, collection, entryId, locale, taxonomies) {
2173
+ const taxRepo = new TaxonomyRepository(trx);
2174
+ let anyChange = false;
2175
+ for (const [taxonomyName, slugs] of Object.entries(taxonomies)) {
2176
+ if (!Array.isArray(slugs)) throw new EmDashValidationError(`taxonomies.${taxonomyName} must be an array of term slugs`);
2177
+ const termIds = [];
2178
+ for (const slug of slugs) {
2179
+ if (typeof slug !== "string" || slug.length === 0) throw new EmDashValidationError(`taxonomies.${taxonomyName} contains a non-string or empty slug`);
2180
+ const term = await taxRepo.findBySlug(taxonomyName, slug, locale);
2181
+ if (!term) throw new EmDashValidationError(`Unknown taxonomy term: ${taxonomyName}='${slug}'${locale ? ` (locale '${locale}')` : ""}`);
2182
+ termIds.push(term.id);
2183
+ }
2184
+ await taxRepo.setTermsForEntry(collection, entryId, taxonomyName, termIds);
2185
+ anyChange = true;
2186
+ }
2187
+ if (anyChange) invalidateTermCache();
2188
+ }
2189
+
2190
+ //#endregion
2191
+ //#region src/api/handlers/manifest.ts
2192
+ /** Pattern to add spaces before capital letters */
2193
+ const CAMEL_CASE_PATTERN = /([A-Z])/g;
2194
+ const FIRST_CHAR_PATTERN = /^./;
2195
+ /**
2196
+ * Map schema field types to editor field kinds.
2197
+ */
2198
+ /** Field types that can be surfaced as list columns in the admin. */
2199
+ const LIST_COLUMN_FIELD_TYPES = new Set([
2200
+ "string",
2201
+ "number",
2202
+ "integer",
2203
+ "boolean",
2204
+ "datetime",
2205
+ "select",
2206
+ "multiSelect"
2207
+ ]);
2208
+ const FIELD_TYPE_TO_KIND = {
2209
+ string: "string",
2210
+ slug: "string",
2211
+ url: "url",
2212
+ text: "richText",
2213
+ number: "number",
2214
+ integer: "number",
2215
+ boolean: "boolean",
2216
+ datetime: "datetime",
2217
+ select: "select",
2218
+ multiSelect: "multiSelect",
2219
+ portableText: "portableText",
2220
+ image: "image",
2221
+ file: "file",
2222
+ reference: "reference",
2223
+ json: "json",
2224
+ repeater: "repeater",
2225
+ blocks: "blocks"
2226
+ };
2227
+ /**
2228
+ * Generate admin manifest from collections
2229
+ */
2230
+ async function generateManifest(collections, plugins = {}, options = {}) {
2231
+ const manifestCollections = await buildManifestCollections(collections, options.db);
2232
+ return {
2233
+ version: "0.1.0",
2234
+ hash: await hashString(JSON.stringify(manifestCollections)),
2235
+ collections: manifestCollections,
2236
+ plugins
2237
+ };
2238
+ }
2239
+ /**
2240
+ * Build collection descriptors from build-time config plus live database rows.
2241
+ *
2242
+ * Config collections are added first and win on slug conflicts. Runtime/manual
2243
+ * collections have no Zod schema to inspect, so their field descriptors are
2244
+ * synthesized from `_emdash_fields`.
2245
+ */
2246
+ async function buildManifestCollections(collections, db) {
2247
+ const manifestCollections = {};
2248
+ for (const [name, definition] of Object.entries(collections)) {
2249
+ const fields = extractFieldDescriptors(definition.schema);
2250
+ manifestCollections[name] = {
2251
+ label: definition.admin.label,
2252
+ labelSingular: definition.admin.labelSingular || definition.admin.label,
2253
+ supports: definition.admin.supports || [],
2254
+ hasSeo: (definition.admin.supports || []).includes("seo"),
2255
+ routable: definition.admin.routable ?? true,
2256
+ fields
2257
+ };
2258
+ }
2259
+ if (!db) return manifestCollections;
2260
+ try {
2261
+ const storedCollections = await new SchemaRegistry(db).listCollectionsWithFields();
2262
+ const dbCollections = await Promise.all(storedCollections.map((collection) => expandCollectionBlockFields(db, collection)));
2263
+ const cardinality = await relationCardinality(db, dbCollections);
2264
+ for (const collection of dbCollections) {
2265
+ if (manifestCollections[collection.slug]) continue;
2266
+ const fields = {};
2267
+ for (const field of collection.fields) fields[field.slug] = dbFieldDescriptor(field, cardinality);
2268
+ const configuredListColumns = collection.admin?.listColumns ?? [];
2269
+ const fieldTypes = new Map(collection.fields.map((field) => [field.slug, field.type]));
2270
+ const listColumns = [];
2271
+ for (const slug of configuredListColumns) {
2272
+ if (listColumns.includes(slug)) continue;
2273
+ const fieldType = fieldTypes.get(slug);
2274
+ if (!fieldType || !LIST_COLUMN_FIELD_TYPES.has(fieldType)) {
2275
+ console.warn(`EmDash: Ignoring unsupported or unknown list column "${slug}" in collection "${collection.slug}".`);
2276
+ continue;
2277
+ }
2278
+ if (listColumns.length >= MAX_COLLECTION_LIST_COLUMNS) {
2279
+ console.warn(`EmDash: Collection "${collection.slug}" declares more than ${MAX_COLLECTION_LIST_COLUMNS} list columns; extra columns are ignored.`);
2280
+ break;
2281
+ }
2282
+ listColumns.push(slug);
2283
+ }
2284
+ manifestCollections[collection.slug] = {
2285
+ label: collection.label,
2286
+ labelSingular: collection.labelSingular || collection.label,
2287
+ supports: collection.supports || [],
2288
+ hasSeo: collection.hasSeo,
2289
+ urlPattern: collection.urlPattern,
2290
+ routable: collection.routable !== false,
2291
+ titleField: collection.titleField,
2292
+ dateField: collection.dateField,
2293
+ ...collection.hidden ? { hidden: true } : {},
2294
+ ...collection.icon ? { icon: collection.icon } : {},
2295
+ ...collection.group ? { group: collection.group } : {},
2296
+ ...collection.admin?.quickCreate === false ? { quickCreate: false } : {},
2297
+ listColumns: listColumns.length > 0 ? listColumns : void 0,
2298
+ fields
2299
+ };
2300
+ }
2301
+ } catch (error) {
2302
+ console.debug("EmDash: Could not load database collections for manifest:", error);
2303
+ }
2304
+ return manifestCollections;
2305
+ }
2306
+ /**
2307
+ * Extract field descriptors from Zod schema
2308
+ * Note: This is a simplified implementation that handles common types
2309
+ */
2310
+ function extractFieldDescriptors(schema) {
2311
+ const fields = {};
2312
+ const shape = typeof schema._def?.shape === "function" ? schema._def.shape() : schema.shape || {};
2313
+ for (const [name, fieldSchema] of Object.entries(shape)) fields[name] = extractFieldType(name, fieldSchema);
2314
+ return fields;
2315
+ }
2316
+ /**
2317
+ * Extract field type from Zod schema
2318
+ */
2319
+ /** Type guard: check if a value is a non-null object */
2320
+ function isObject(value) {
2321
+ return typeof value === "object" && value !== null;
2322
+ }
2323
+ function extractFieldType(name, schema) {
2324
+ if (!isObject(schema)) return {
2325
+ kind: "string",
2326
+ label: formatLabel(name)
2327
+ };
2328
+ if (schema.isPortableText) return {
2329
+ kind: "portableText",
2330
+ label: formatLabel(name)
2331
+ };
2332
+ if (schema.isImage) return {
2333
+ kind: "image",
2334
+ label: formatLabel(name)
2335
+ };
2336
+ if (schema.isReference) return {
2337
+ kind: "reference",
2338
+ label: formatLabel(name)
2339
+ };
2340
+ const def = isObject(schema._def) ? schema._def : void 0;
2341
+ switch (typeof def?.typeName === "string" ? def.typeName : void 0) {
2342
+ case "ZodString": return {
2343
+ kind: "string",
2344
+ label: formatLabel(name)
2345
+ };
2346
+ case "ZodNumber": return {
2347
+ kind: "number",
2348
+ label: formatLabel(name)
2349
+ };
2350
+ case "ZodBoolean": return {
2351
+ kind: "boolean",
2352
+ label: formatLabel(name)
2353
+ };
2354
+ case "ZodDate": return {
2355
+ kind: "datetime",
2356
+ label: formatLabel(name)
2357
+ };
2358
+ case "ZodEnum": {
2359
+ const values = Array.isArray(def?.values) ? def.values : [];
2360
+ return {
2361
+ kind: "select",
2362
+ label: formatLabel(name),
2363
+ options: values.filter((v) => typeof v === "string").map((v) => ({
2364
+ value: v,
2365
+ label: v.charAt(0).toUpperCase() + v.slice(1)
2366
+ }))
2367
+ };
2368
+ }
2369
+ case "ZodArray": return {
2370
+ kind: "array",
2371
+ label: formatLabel(name)
2372
+ };
2373
+ case "ZodObject": return {
2374
+ kind: "object",
2375
+ label: formatLabel(name)
2376
+ };
2377
+ case "ZodOptional":
2378
+ case "ZodDefault":
2379
+ if (def?.innerType) return extractFieldType(name, def.innerType);
2380
+ return {
2381
+ kind: "string",
2382
+ label: formatLabel(name)
2383
+ };
2384
+ default: return {
2385
+ kind: "string",
2386
+ label: formatLabel(name)
2387
+ };
2388
+ }
2389
+ }
2390
+ /**
2391
+ * The limits of every relation a bound reference field names, by relation slug.
2392
+ *
2393
+ * Empty when nothing is bound, so a site with no reference fields never issues
2394
+ * the query, and empty before migration 086 has created the table.
2395
+ */
2396
+ async function relationCardinality(db, collections) {
2397
+ if (!collections.some((collection) => collection.fields.some(isStoragelessField))) return /* @__PURE__ */ new Map();
2398
+ try {
2399
+ const rows = await db.selectFrom("_emdash_relations").select([
2400
+ "slug",
2401
+ "max_children_per_parent",
2402
+ "max_parents_per_child"
2403
+ ]).execute();
2404
+ return new Map(rows.map((row) => [row.slug, {
2405
+ maxChildrenPerParent: row.max_children_per_parent,
2406
+ maxParentsPerChild: row.max_parents_per_child
2407
+ }]));
2408
+ } catch (error) {
2409
+ if (isMissingTableError(error)) return /* @__PURE__ */ new Map();
2410
+ throw error;
2411
+ }
2412
+ }
2413
+ /**
2414
+ * Whether the editor may select more than one entry for a bound reference
2415
+ * field: the question the relation answers, from the end the field views.
2416
+ *
2417
+ * `validation.multiple` on the field row is a create-time input — it is what
2418
+ * set the relation's limit — and the relation is what the write path enforces.
2419
+ * Reading the field back would let the two disagree, which is what happens when
2420
+ * a later edit rewrites the row's validation without it.
2421
+ */
2422
+ function boundReferenceIsMultiple(validation, cardinality) {
2423
+ return (validation.relationSide === "child" ? cardinality.maxParentsPerChild : cardinality.maxChildrenPerParent) !== 1;
2424
+ }
2425
+ function dbFieldDescriptor(field, cardinality) {
2426
+ const entry = {
2427
+ kind: field.unsupportedType ? "unsupported" : FIELD_TYPE_TO_KIND[field.type],
2428
+ label: field.label,
2429
+ required: field.required,
2430
+ translatable: field.translatable,
2431
+ id: field.id
2432
+ };
2433
+ if (field.unsupportedType) entry.unsupportedType = field.unsupportedType;
2434
+ if (field.type === "integer") entry.integer = true;
2435
+ if (field.blockTypes) entry.blockTypes = field.blockTypes;
2436
+ if (field.blockTypeFingerprint) entry.blockTypeFingerprint = field.blockTypeFingerprint;
2437
+ if (field.widget) entry.widget = field.widget;
2438
+ if (field.options) entry.options = field.options;
2439
+ if (field.validation?.options) entry.options = field.validation.options.map((value) => ({
2440
+ value,
2441
+ label: value.charAt(0).toUpperCase() + value.slice(1)
2442
+ }));
2443
+ if (field.validation) {
2444
+ const validation = { ...field.validation };
2445
+ if (isStoragelessField(field) && field.validation.relation) {
2446
+ const limits = cardinality.get(field.validation.relation);
2447
+ if (limits) validation.multiple = boundReferenceIsMultiple(field.validation, limits);
2448
+ }
2449
+ entry.validation = validation;
2450
+ }
2451
+ if (field.defaultValue !== void 0 && !isStoragelessField(field)) entry.defaultValue = field.defaultValue;
2452
+ return entry;
2453
+ }
2454
+ /**
2455
+ * Format field name as label
2456
+ */
2457
+ function formatLabel(name) {
2458
+ return name.replace(CAMEL_CASE_PATTERN, " $1").replace(FIRST_CHAR_PATTERN, (str) => str.toUpperCase()).trim();
2459
+ }
2460
+
2461
+ //#endregion
2462
+ //#region src/api/handlers/revision.ts
2463
+ /**
2464
+ * List revisions for a content entry
2465
+ */
2466
+ async function handleRevisionList(db, collection, entryId, params = {}) {
2467
+ try {
2468
+ const repo = new RevisionRepository(db);
2469
+ const [items, total] = await Promise.all([repo.findByEntry(collection, entryId, { limit: Math.max(1, Math.min(params.limit || 50, 100)) }), repo.countByEntry(collection, entryId)]);
2470
+ return {
2471
+ success: true,
2472
+ data: {
2473
+ items,
2474
+ total
2475
+ }
2476
+ };
2477
+ } catch {
2478
+ return {
2479
+ success: false,
2480
+ error: {
2481
+ code: "REVISION_LIST_ERROR",
2482
+ message: "Failed to list revisions"
2483
+ }
2484
+ };
2485
+ }
2486
+ }
2487
+ /**
2488
+ * Everyone who edited a content entry in the revisions newer than `since`, newest first and once
2489
+ * each. With no `since`, everyone who edited it.
2490
+ */
2491
+ async function handleRevisionEditors(db, collection, entryId, since) {
2492
+ try {
2493
+ return {
2494
+ success: true,
2495
+ data: { items: await new RevisionRepository(db).findEditorsSince(collection, entryId, since) }
2496
+ };
2497
+ } catch {
2498
+ return {
2499
+ success: false,
2500
+ error: {
2501
+ code: "REVISION_EDITORS_ERROR",
2502
+ message: "Failed to list revision editors"
2503
+ }
2504
+ };
2505
+ }
2506
+ }
2507
+ /**
2508
+ * Get a specific revision
2509
+ */
2510
+ async function handleRevisionGet(db, revisionId) {
2511
+ try {
2512
+ const item = await new RevisionRepository(db).findById(revisionId);
2513
+ if (!item) return {
2514
+ success: false,
2515
+ error: {
2516
+ code: "NOT_FOUND",
2517
+ message: `Revision not found: ${revisionId}`
2518
+ }
2519
+ };
2520
+ return {
2521
+ success: true,
2522
+ data: { item }
2523
+ };
2524
+ } catch {
2525
+ return {
2526
+ success: false,
2527
+ error: {
2528
+ code: "REVISION_GET_ERROR",
2529
+ message: "Failed to get revision"
2530
+ }
2531
+ };
2532
+ }
2533
+ }
2534
+ /**
2535
+ * Restore a revision (updates content to this revision's data and creates new revision)
2536
+ */
2537
+ async function handleRevisionRestore(db, revisionId, callerUserId) {
2538
+ try {
2539
+ const revision = await new RevisionRepository(db).findById(revisionId);
2540
+ if (!revision) return {
2541
+ success: false,
2542
+ error: {
2543
+ code: "NOT_FOUND",
2544
+ message: `Revision not found: ${revisionId}`
2545
+ }
2546
+ };
2547
+ const stagedReferences = readStagedReferences(revision.data);
2548
+ if (stagedReferences) {
2549
+ const entry = await new ContentRepository(db).findById(revision.collection, revision.entryId);
2550
+ if (entry?.translationGroup) {
2551
+ const valid = await validateStagedReferences(db, revision.collection, stagedReferences, entry.translationGroup);
2552
+ if (!valid.success) return valid;
2553
+ }
2554
+ }
2555
+ const restoredData = { ...revision.data };
2556
+ delete restoredData[STAGED_REFERENCES_BASELINE_KEY];
2557
+ const { item, revisionId: queuedRevisionId } = await new ContentRepository(db).restoreRevision(revision.collection, revision.entryId, restoredData, callerUserId);
2558
+ if (stagedReferences && item.translationGroup) await applyStagedReferences(db, revision.collection, item.translationGroup, stagedReferences);
2559
+ const pruneRepo = new RevisionRepository(db);
2560
+ after(async () => {
2561
+ try {
2562
+ await pruneRepo.pruneQueuedEntry(revision.collection, revision.entryId, queuedRevisionId, 50);
2563
+ } catch (error) {
2564
+ console.error(`[revisions] Failed to prune revisions for ${revision.collection}/${revision.entryId}:`, error);
2565
+ }
2566
+ });
2567
+ return {
2568
+ success: true,
2569
+ data: {
2570
+ item,
2571
+ _rev: encodeRev(item)
2572
+ }
2573
+ };
2574
+ } catch (error) {
2575
+ if (error instanceof ContentMutationConflictError) return {
2576
+ success: false,
2577
+ error: {
2578
+ code: "CONFLICT",
2579
+ message: error.message
2580
+ }
2581
+ };
2582
+ return {
2583
+ success: false,
2584
+ error: {
2585
+ code: "REVISION_RESTORE_ERROR",
2586
+ message: "Failed to restore revision"
2587
+ }
2588
+ };
2589
+ }
2590
+ }
2591
+
2592
+ //#endregion
2593
+ //#region src/plugins/define-plugin.ts
2594
+ /**
2595
+ * definePlugin() Helper
2596
+ *
2597
+ * Native plugin authoring entry. Returns a fully-resolved
2598
+ * `ResolvedPlugin` ready for the host integration to mount.
2599
+ *
2600
+ * Sandboxed plugins do NOT use this function. They default-export
2601
+ * a bare `{ hooks?, routes? }` object with a `satisfies SandboxedPlugin`
2602
+ * annotation from `emdash/plugin`. See the `emdash` changeset for the
2603
+ * authoring shape.
2604
+ */
2605
+ const MCP_TOOL_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
2606
+ /**
2607
+ * Define a native EmDash plugin.
2608
+ *
2609
+ * Native plugins ship as regular npm modules, get installed via
2610
+ * `pnpm add` + an `astro.config.mjs` edit, and run in the host
2611
+ * process. They have full access to the runtime — capabilities are
2612
+ * still enforced by `PluginContextFactory`, but there is no isolation
2613
+ * boundary.
2614
+ *
2615
+ * @example
2616
+ * ```typescript
2617
+ * import { definePlugin } from "emdash";
2618
+ *
2619
+ * export default definePlugin({
2620
+ * id: "my-plugin",
2621
+ * version: "1.0.0",
2622
+ * capabilities: ["content:write"],
2623
+ * hooks: {
2624
+ * "content:beforeSave": async (event, ctx) => {
2625
+ * ctx.log.info("Saving content", { collection: event.collection });
2626
+ * return event.content;
2627
+ * }
2628
+ * },
2629
+ * routes: {
2630
+ * "sync": {
2631
+ * handler: async (ctx) => {
2632
+ * return { status: "ok" };
2633
+ * }
2634
+ * }
2635
+ * }
2636
+ * });
2637
+ * ```
2638
+ *
2639
+ * Sandboxed-format plugins do not use `definePlugin`. They
2640
+ * default-export a bare `{ hooks?, routes? }` object with a
2641
+ * `satisfies SandboxedPlugin` annotation from `emdash/plugin`. Calling
2642
+ * `definePlugin` with an object that has no `id` throws at runtime
2643
+ * (the type system already rejects it at compile time — this check is
2644
+ * for callers that bypass typechecking). Passing a plugin descriptor
2645
+ * (an object with an `entrypoint`) also throws.
2646
+ */
2647
+ function definePlugin(definition) {
2648
+ if (typeof definition.id !== "string" || definition.id.length === 0) throw new Error(`definePlugin() requires \`id\` (got ${typeof definition.id}). For native plugins, make sure your definition has both \`id\` and \`version\`. For sandboxed plugins, drop \`definePlugin()\` entirely and \`export default { hooks, routes } satisfies SandboxedPlugin\` from "emdash/plugin" — identity comes from \`emdash-plugin.jsonc\`.`);
2649
+ if ("entrypoint" in definition) throw new Error(`definePlugin() received a plugin descriptor for "${definition.id}" (it has an \`entrypoint\`). Pass the descriptor directly to the \`plugins\` array of the emdash() integration instead of wrapping it in definePlugin().`);
2650
+ return defineNativePlugin(definition);
2651
+ }
2652
+ function definePluginRoute(route) {
2653
+ return route;
2654
+ }
2655
+ /**
2656
+ * Internal: define a native-format plugin with full validation and normalization.
2657
+ */
2658
+ function defineNativePlugin(definition) {
2659
+ const SIMPLE_ID = /^[a-z0-9-]+$/;
2660
+ const SCOPED_ID = /^@[a-z0-9-]+\/[a-z0-9-]+$/;
2661
+ const SEMVER_PATTERN = /^\d+\.\d+\.\d+/;
2662
+ const { id, displayName, description, version, capabilities = [], allowedHosts = [], hooks = {}, routes = {}, mcp = { tools: {} }, admin = {} } = definition;
2663
+ const storage = definition.storage ?? {};
2664
+ if (!SIMPLE_ID.test(id) && !SCOPED_ID.test(id)) throw new Error(`Invalid plugin id "${id}". Must be lowercase alphanumeric with dashes (e.g., "my-plugin" or "@scope/my-plugin").`);
2665
+ if (!SEMVER_PATTERN.test(version)) throw new Error(`Invalid plugin version "${version}". Must be semver format (e.g., "1.0.0").`);
2666
+ for (const [name, tool] of Object.entries(mcp.tools)) {
2667
+ if (!MCP_TOOL_NAME_PATTERN.test(name)) throw new Error(`Invalid MCP tool name "${name}" in plugin "${id}".`);
2668
+ const route = routes[tool.route];
2669
+ if (!route) throw new Error(`MCP tool "${name}" references unknown route "${tool.route}".`);
2670
+ if (route.public) throw new Error(`MCP tool "${name}" cannot reference a public route.`);
2671
+ if (route.response === "raw") throw new Error(`MCP tool "${name}" cannot reference a raw response route.`);
2672
+ if (!isJsonPostRouteContract(route)) throw new Error(`MCP tool "${name}" must reference a POST-compatible JSON route.`);
2673
+ if (!route.permission) throw new Error(`MCP route "${tool.route}" must declare a permission.`);
2674
+ }
2675
+ for (const [kind, extensions] of [["editor panel", admin.editorPanels], ["editor action", admin.editorActions]]) for (const extension of extensions ?? []) {
2676
+ const route = routes[extension.route];
2677
+ if (!route) throw new Error(`Plugin ${kind} "${extension.id}" references unknown route "${extension.route}".`);
2678
+ if (route.public) throw new Error(`Plugin ${kind} "${extension.id}" must reference a private route.`);
2679
+ if (!isJsonPostRouteContract(route)) throw new Error(`Plugin ${kind} "${extension.id}" must reference a route that accepts POST JSON requests and returns JSON.`);
2680
+ }
2681
+ if ((admin.pages?.length ?? 0) > 0 || (admin.widgets?.length ?? 0) > 0) {
2682
+ const adminRoute = routes.admin;
2683
+ if (adminRoute && (adminRoute.public === true || !isJsonPostRouteContract(adminRoute))) throw new Error("Block Kit admin route must accept POST JSON requests and return JSON.");
2684
+ }
2685
+ const validCapabilities = new Set(PLUGIN_CAPABILITIES);
2686
+ for (const cap of capabilities) if (!validCapabilities.has(cap)) throw new Error(`Invalid capability "${cap}" in plugin "${id}".`);
2687
+ warnDeprecatedPluginCapabilities(id, capabilities);
2688
+ return {
2689
+ id,
2690
+ displayName,
2691
+ description,
2692
+ version,
2693
+ capabilities: normalizePluginCapabilities(capabilities),
2694
+ allowedHosts,
2695
+ storage,
2696
+ hooks: resolveHooks(hooks, id),
2697
+ routes,
2698
+ mcp,
2699
+ admin
2700
+ };
2701
+ }
2702
+ /**
2703
+ * Resolve hooks to normalized format with defaults.
2704
+ *
2705
+ * PluginHooks and ResolvedPluginHooks share the same keys — each input value is
2706
+ * `HookConfig<H> | H` and the output is `ResolvedHook<H>`. TS can't narrow
2707
+ * the handler type through a dynamic key, so we assert at the loop boundary.
2708
+ */
2709
+ function resolveHooks(hooks, pluginId) {
2710
+ const resolved = {};
2711
+ for (const key of Object.keys(hooks)) {
2712
+ const hook = hooks[key];
2713
+ if (hook) resolved[key] = resolveHook(hook, pluginId);
2714
+ }
2715
+ return resolved;
2716
+ }
2717
+ /**
2718
+ * Check if a hook value is a config object (has a `handler` property)
2719
+ */
2720
+ function isHookConfig(hook) {
2721
+ return typeof hook === "object" && hook !== null && "handler" in hook;
2722
+ }
2723
+ /**
2724
+ * Resolve a single hook to normalized format
2725
+ */
2726
+ function resolveHook(hook, pluginId) {
2727
+ if (isHookConfig(hook)) {
2728
+ if (hook.exclusive !== void 0 && typeof hook.exclusive !== "boolean") throw new Error(`Invalid "exclusive" value in hook config for plugin "${pluginId}". Must be boolean.`);
2729
+ return {
2730
+ priority: hook.priority ?? 100,
2731
+ timeout: hook.timeout ?? 5e3,
2732
+ dependencies: hook.dependencies ?? [],
2733
+ errorPolicy: hook.errorPolicy ?? "abort",
2734
+ exclusive: hook.exclusive ?? false,
2735
+ handler: hook.handler,
2736
+ pluginId
2737
+ };
2738
+ }
2739
+ return {
2740
+ priority: 100,
2741
+ timeout: 5e3,
2742
+ dependencies: [],
2743
+ errorPolicy: "abort",
2744
+ exclusive: false,
2745
+ handler: hook,
2746
+ pluginId
2747
+ };
2748
+ }
2749
+
2750
+ //#endregion
2751
+ //#region src/plugins/hooks.ts
2752
+ /**
2753
+ * Plugin Hooks System v2
2754
+ *
2755
+ * Uses the unified PluginContext for all hooks.
2756
+ * Manages lifecycle hooks with:
2757
+ * - Deterministic ordering via priority + dependencies
2758
+ * - Timeout enforcement
2759
+ * - Error isolation
2760
+ * - Observability
2761
+ *
2762
+ */
2763
+ /** A host-enforced hook deadline, distinct from an error thrown by plugin code. */
2764
+ var HookTimeoutError = class extends Error {
2765
+ constructor(timeout) {
2766
+ super(`Hook timeout after ${timeout}ms`);
2767
+ }
2768
+ };
2769
+ const CONTENT_SAVE_HOOK_CONTEXT_KEY = Symbol.for("emdash:content-save-hook-context");
2770
+ const contentSaveHookContext = globalThis[CONTENT_SAVE_HOOK_CONTEXT_KEY] ?? new AsyncLocalStorage();
2771
+ globalThis[CONTENT_SAVE_HOOK_CONTEXT_KEY] = contentSaveHookContext;
2772
+ function getActiveContentSaveHookName() {
2773
+ return contentSaveHookContext.getStore();
2774
+ }
2775
+ function assignSaveHookDetails(event, details) {
2776
+ if (details.locale !== void 0) event.locale = details.locale;
2777
+ if (details.translationOf !== void 0) event.translationOf = details.translationOf;
2778
+ if (details.editedBy !== void 0) event.editedBy = [...details.editedBy];
2779
+ }
2780
+ /**
2781
+ * Hook pipeline for executing hooks in order
2782
+ */
2783
+ var HookPipeline = class HookPipeline {
2784
+ hooks = /* @__PURE__ */ new Map();
2785
+ pluginMap = /* @__PURE__ */ new Map();
2786
+ contextFactory = null;
2787
+ /** Stored so setContextFactory can merge incrementally. */
2788
+ contextFactoryOptions = {};
2789
+ /** Hook names where at least one handler declared exclusive: true */
2790
+ exclusiveHookNames = /* @__PURE__ */ new Set();
2791
+ /**
2792
+ * Selected provider plugin ID for each exclusive hook.
2793
+ * Set by the PluginManager after resolution.
2794
+ */
2795
+ exclusiveSelections = /* @__PURE__ */ new Map();
2796
+ constructor(plugins, factoryOptions) {
2797
+ if (factoryOptions) {
2798
+ this.contextFactory = new PluginContextFactory(factoryOptions);
2799
+ this.contextFactoryOptions = { ...factoryOptions };
2800
+ }
2801
+ for (const plugin of plugins) this.pluginMap.set(plugin.id, plugin);
2802
+ this.registerPlugins(plugins);
2803
+ }
2804
+ /**
2805
+ * Set or update the context factory options.
2806
+ *
2807
+ * When called on a pipeline that already has a factory, the new options
2808
+ * are merged on top of the existing ones so that callers don't need to
2809
+ * repeat every field (e.g. adding `cronReschedule` without losing
2810
+ * `storage` / `getUploadUrl`).
2811
+ */
2812
+ setContextFactory(options) {
2813
+ const merged = {
2814
+ ...this.contextFactoryOptions,
2815
+ ...options
2816
+ };
2817
+ this.contextFactory = new PluginContextFactory(merged);
2818
+ this.contextFactoryOptions = merged;
2819
+ }
2820
+ /**
2821
+ * Get context for a plugin
2822
+ */
2823
+ getContext(pluginId) {
2824
+ const plugin = this.pluginMap.get(pluginId);
2825
+ if (!plugin) throw new Error(`Plugin "${pluginId}" not found`);
2826
+ if (!this.contextFactory) throw new Error("Context factory not initialized - call setContextFactory first");
2827
+ return this.contextFactory.createContext(plugin);
2828
+ }
2829
+ /**
2830
+ * Get typed hooks for a specific hook name.
2831
+ * The internal map stores ResolvedHook<unknown>, but we know each name
2832
+ * maps to a specific handler type via HookHandlerMap.
2833
+ *
2834
+ * Exclusive hooks that have a selected provider are filtered out — they
2835
+ * should only run via invokeExclusiveHook(), not in the regular pipeline.
2836
+ */
2837
+ getTypedHooks(name) {
2838
+ const all = this.hooks.get(name) ?? [];
2839
+ if (this.exclusiveSelections.has(name)) return all.filter((h) => !h.exclusive);
2840
+ return all;
2841
+ }
2842
+ /**
2843
+ * Register all hooks from plugins.
2844
+ *
2845
+ * Registers each hook name individually to preserve type safety. The
2846
+ * internal map stores ResolvedHook<unknown> since it's keyed by string,
2847
+ * but getTypedHooks() restores the correct handler type on retrieval.
2848
+ */
2849
+ registerPlugins(plugins) {
2850
+ for (const plugin of plugins) {
2851
+ this.registerPluginHook(plugin, "plugin:install");
2852
+ this.registerPluginHook(plugin, "plugin:activate");
2853
+ this.registerPluginHook(plugin, "plugin:deactivate");
2854
+ this.registerPluginHook(plugin, "plugin:uninstall");
2855
+ this.registerPluginHook(plugin, "content:beforeSave");
2856
+ this.registerPluginHook(plugin, "content:afterSave");
2857
+ this.registerPluginHook(plugin, "content:beforeDelete");
2858
+ this.registerPluginHook(plugin, "content:afterDelete");
2859
+ this.registerPluginHook(plugin, "content:beforePublish");
2860
+ this.registerPluginHook(plugin, "content:beforeSchedule");
2861
+ this.registerPluginHook(plugin, "content:beforeUnpublish");
2862
+ this.registerPluginHook(plugin, "content:afterPublish");
2863
+ this.registerPluginHook(plugin, "content:afterUnpublish");
2864
+ this.registerPluginHook(plugin, "content:afterRestore");
2865
+ this.registerPluginHook(plugin, "content:afterSchedule");
2866
+ this.registerPluginHook(plugin, "content:afterUnschedule");
2867
+ this.registerPluginHook(plugin, "media:beforeUpload");
2868
+ this.registerPluginHook(plugin, "media:afterUpload");
2869
+ this.registerPluginHook(plugin, "cron");
2870
+ this.registerPluginHook(plugin, "email:beforeSend");
2871
+ this.registerPluginHook(plugin, "email:deliver");
2872
+ this.registerPluginHook(plugin, "email:afterSend");
2873
+ this.registerPluginHook(plugin, "comment:beforeCreate");
2874
+ this.registerPluginHook(plugin, "comment:moderate");
2875
+ this.registerPluginHook(plugin, "comment:afterCreate");
2876
+ this.registerPluginHook(plugin, "comment:afterModerate");
2877
+ this.registerPluginHook(plugin, "byline:afterSave");
2878
+ this.registerPluginHook(plugin, "byline:afterDelete");
2879
+ this.registerPluginHook(plugin, "page:metadata");
2880
+ this.registerPluginHook(plugin, "page:fragments");
2881
+ }
2882
+ for (const [hookName, hooks] of this.hooks) this.hooks.set(hookName, this.sortHooks(hooks));
2883
+ }
2884
+ /**
2885
+ * Maps hook names to the capability required to register them.
2886
+ *
2887
+ * Hooks not listed here have no capability requirement (e.g. lifecycle
2888
+ * hooks, cron). Any plugin declaring a listed hook without the required
2889
+ * capability will have that hook silently skipped at registration time.
2890
+ */
2891
+ static HOOK_REQUIRED_CAPABILITY = new Map([
2892
+ ["email:beforeSend", "hooks.email-events:register"],
2893
+ ["email:afterSend", "hooks.email-events:register"],
2894
+ ["email:deliver", "hooks.email-transport:register"],
2895
+ ["content:beforeSave", "content:write"],
2896
+ ["content:afterSave", "content:read"],
2897
+ ["content:beforeDelete", "content:read"],
2898
+ ["content:afterDelete", "content:read"],
2899
+ ["content:beforePublish", "hooks.content-policy:register"],
2900
+ ["content:beforeSchedule", "hooks.content-policy:register"],
2901
+ ["content:beforeUnpublish", "hooks.content-policy:register"],
2902
+ ["content:afterPublish", "content:read"],
2903
+ ["content:afterUnpublish", "content:read"],
2904
+ ["content:afterRestore", "content:read"],
2905
+ ["content:afterSchedule", "content:read"],
2906
+ ["content:afterUnschedule", "content:read"],
2907
+ ["media:beforeUpload", "media:write"],
2908
+ ["media:afterUpload", "media:read"],
2909
+ ["comment:beforeCreate", "users:read"],
2910
+ ["comment:moderate", "users:read"],
2911
+ ["comment:afterCreate", "users:read"],
2912
+ ["comment:afterModerate", "users:read"],
2913
+ ["byline:afterSave", "bylines:read"],
2914
+ ["byline:afterDelete", "bylines:read"],
2915
+ ["page:fragments", "hooks.page-fragments:register"]
2916
+ ]);
2917
+ /**
2918
+ * Register a single plugin's hook by name
2919
+ */
2920
+ registerPluginHook(plugin, name) {
2921
+ const hook = plugin.hooks[name];
2922
+ if (!hook) return;
2923
+ const requiredCapability = HookPipeline.HOOK_REQUIRED_CAPABILITY.get(name);
2924
+ if (requiredCapability && !plugin.capabilities.includes(requiredCapability)) {
2925
+ console.warn(`[hooks] Plugin "${plugin.id}" declares ${name} hook without ${requiredCapability} capability — skipping`);
2926
+ return;
2927
+ }
2928
+ if (hook.exclusive) this.exclusiveHookNames.add(name);
2929
+ this.registerHook(name, hook);
2930
+ }
2931
+ /**
2932
+ * Register a single hook
2933
+ */
2934
+ registerHook(name, hook) {
2935
+ const existing = this.hooks.get(name) || [];
2936
+ existing.push(hook);
2937
+ this.hooks.set(name, existing);
2938
+ }
2939
+ /**
2940
+ * Sort hooks by priority and dependencies
2941
+ */
2942
+ sortHooks(hooks) {
2943
+ const sorted = [];
2944
+ const remaining = [...hooks];
2945
+ while (remaining.length > 0) {
2946
+ const ready = remaining.filter((hook) => hook.dependencies.every((dep) => sorted.some((s) => s.pluginId === dep)));
2947
+ if (ready.length === 0) {
2948
+ const pluginIds = remaining.map((h) => h.pluginId).join(", ");
2949
+ console.warn(`[hooks] Hook dependency cycle or missing dependency detected among plugins: ${pluginIds}. Falling back to priority order.`);
2950
+ remaining.sort((a, b) => a.priority - b.priority);
2951
+ sorted.push(...remaining);
2952
+ break;
2953
+ }
2954
+ ready.sort((a, b) => a.priority - b.priority);
2955
+ const next = ready[0];
2956
+ sorted.push(next);
2957
+ remaining.splice(remaining.indexOf(next), 1);
2958
+ }
2959
+ return sorted;
2960
+ }
2961
+ /**
2962
+ * Execute a hook with timeout
2963
+ */
2964
+ async executeWithTimeout(fn, timeout) {
2965
+ let timer;
2966
+ const timeoutPromise = new Promise((_, reject) => timer = setTimeout(() => reject(new HookTimeoutError(timeout)), timeout));
2967
+ try {
2968
+ return await Promise.race([fn(), timeoutPromise]);
2969
+ } finally {
2970
+ clearTimeout(timer);
2971
+ }
2972
+ }
2973
+ /**
2974
+ * Run plugin:install hooks
2975
+ */
2976
+ async runPluginInstall(pluginId) {
2977
+ return this.runLifecycleHook("plugin:install", pluginId);
2978
+ }
2979
+ /**
2980
+ * Run plugin:activate hooks
2981
+ */
2982
+ async runPluginActivate(pluginId) {
2983
+ return this.runLifecycleHook("plugin:activate", pluginId);
2984
+ }
2985
+ /**
2986
+ * Run plugin:deactivate hooks
2987
+ */
2988
+ async runPluginDeactivate(pluginId) {
2989
+ return this.runLifecycleHook("plugin:deactivate", pluginId);
2990
+ }
2991
+ /**
2992
+ * Run plugin:uninstall hooks
2993
+ */
2994
+ async runPluginUninstall(pluginId, deleteData) {
2995
+ const hooks = this.getTypedHooks("plugin:uninstall");
2996
+ const results = [];
2997
+ const hook = hooks.find((h) => h.pluginId === pluginId);
2998
+ if (!hook) return results;
2999
+ const { handler } = hook;
3000
+ const event = { deleteData };
3001
+ const ctx = this.getContext(pluginId);
3002
+ const start = Date.now();
3003
+ try {
3004
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3005
+ results.push({
3006
+ success: true,
3007
+ pluginId: hook.pluginId,
3008
+ duration: Date.now() - start
3009
+ });
3010
+ } catch (error) {
3011
+ results.push({
3012
+ success: false,
3013
+ error: error instanceof Error ? error : new Error(String(error)),
3014
+ pluginId: hook.pluginId,
3015
+ duration: Date.now() - start
3016
+ });
3017
+ }
3018
+ return results;
3019
+ }
3020
+ async runLifecycleHook(hookName, pluginId) {
3021
+ const hooks = this.getTypedHooks(hookName);
3022
+ const results = [];
3023
+ const hook = hooks.find((h) => h.pluginId === pluginId);
3024
+ if (!hook) return results;
3025
+ const { handler } = hook;
3026
+ const event = {};
3027
+ const ctx = this.getContext(pluginId);
3028
+ const start = Date.now();
3029
+ try {
3030
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3031
+ results.push({
3032
+ success: true,
3033
+ pluginId: hook.pluginId,
3034
+ duration: Date.now() - start
3035
+ });
3036
+ } catch (error) {
3037
+ results.push({
3038
+ success: false,
3039
+ error: error instanceof Error ? error : new Error(String(error)),
3040
+ pluginId: hook.pluginId,
3041
+ duration: Date.now() - start
3042
+ });
3043
+ }
3044
+ return results;
3045
+ }
3046
+ /**
3047
+ * Run content:beforeSave hooks
3048
+ * Returns modified content from the pipeline. `id` is the existing item's
3049
+ * ID when updating. `actor` is the authenticated user that triggered the
3050
+ * save, when one is available.
3051
+ */
3052
+ async runContentBeforeSave(content, collection, isNew, id, actor, details = {}) {
3053
+ const hooks = this.getTypedHooks("content:beforeSave");
3054
+ const results = [];
3055
+ let currentContent = content;
3056
+ for (const hook of hooks) {
3057
+ const { handler } = hook;
3058
+ const event = {
3059
+ content: currentContent,
3060
+ collection,
3061
+ isNew
3062
+ };
3063
+ if (id !== void 0) event.id = id;
3064
+ if (actor !== void 0) event.actor = { ...actor };
3065
+ assignSaveHookDetails(event, details);
3066
+ const ctx = this.getContext(hook.pluginId);
3067
+ const start = Date.now();
3068
+ try {
3069
+ const result = await contentSaveHookContext.run("content:beforeSave", () => this.executeWithTimeout(() => handler(event, ctx), hook.timeout));
3070
+ if (result !== void 0) currentContent = result;
3071
+ results.push({
3072
+ success: true,
3073
+ value: currentContent,
3074
+ pluginId: hook.pluginId,
3075
+ duration: Date.now() - start
3076
+ });
3077
+ } catch (error) {
3078
+ results.push({
3079
+ success: false,
3080
+ error: error instanceof Error ? error : new Error(String(error)),
3081
+ pluginId: hook.pluginId,
3082
+ duration: Date.now() - start
3083
+ });
3084
+ if (hook.errorPolicy === "abort") throw error;
3085
+ }
3086
+ }
3087
+ return {
3088
+ content: currentContent,
3089
+ results
3090
+ };
3091
+ }
3092
+ /**
3093
+ * Run content:afterSave hooks
3094
+ */
3095
+ async runContentAfterSave(content, collection, isNew, actor, excludePluginId, details = {}) {
3096
+ const hooks = this.getTypedHooks("content:afterSave");
3097
+ const results = [];
3098
+ for (const hook of hooks) {
3099
+ if (hook.pluginId === excludePluginId) continue;
3100
+ const { handler } = hook;
3101
+ const event = {
3102
+ content,
3103
+ collection,
3104
+ isNew
3105
+ };
3106
+ if (actor !== void 0) event.actor = { ...actor };
3107
+ assignSaveHookDetails(event, details);
3108
+ const ctx = this.getContext(hook.pluginId);
3109
+ const start = Date.now();
3110
+ try {
3111
+ await contentSaveHookContext.run("content:afterSave", () => this.executeWithTimeout(() => handler(event, ctx), hook.timeout));
3112
+ results.push({
3113
+ success: true,
3114
+ pluginId: hook.pluginId,
3115
+ duration: Date.now() - start
3116
+ });
3117
+ } catch (error) {
3118
+ results.push({
3119
+ success: false,
3120
+ error: error instanceof Error ? error : new Error(String(error)),
3121
+ pluginId: hook.pluginId,
3122
+ duration: Date.now() - start
3123
+ });
3124
+ if (hook.errorPolicy === "abort") throw error;
3125
+ }
3126
+ }
3127
+ return results;
3128
+ }
3129
+ /**
3130
+ * Run content:beforeDelete hooks
3131
+ * Returns whether deletion is allowed
3132
+ */
3133
+ async runContentBeforeDelete(id, collection) {
3134
+ const hooks = this.getTypedHooks("content:beforeDelete");
3135
+ const results = [];
3136
+ let allowed = true;
3137
+ for (const hook of hooks) {
3138
+ const { handler } = hook;
3139
+ const event = {
3140
+ id,
3141
+ collection,
3142
+ permanent: false
3143
+ };
3144
+ const ctx = this.getContext(hook.pluginId);
3145
+ const start = Date.now();
3146
+ try {
3147
+ const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3148
+ if (result === false) allowed = false;
3149
+ results.push({
3150
+ success: true,
3151
+ value: result !== false,
3152
+ pluginId: hook.pluginId,
3153
+ duration: Date.now() - start
3154
+ });
3155
+ } catch (error) {
3156
+ results.push({
3157
+ success: false,
3158
+ error: error instanceof Error ? error : new Error(String(error)),
3159
+ pluginId: hook.pluginId,
3160
+ duration: Date.now() - start
3161
+ });
3162
+ if (hook.errorPolicy === "abort") throw error;
3163
+ }
3164
+ }
3165
+ return {
3166
+ allowed,
3167
+ results
3168
+ };
3169
+ }
3170
+ /**
3171
+ * Run content:afterDelete hooks
3172
+ */
3173
+ async runContentAfterDelete(id, collection, permanent) {
3174
+ const hooks = this.getTypedHooks("content:afterDelete");
3175
+ const results = [];
3176
+ for (const hook of hooks) {
3177
+ const { handler } = hook;
3178
+ const event = {
3179
+ id,
3180
+ collection,
3181
+ permanent
3182
+ };
3183
+ const ctx = this.getContext(hook.pluginId);
3184
+ const start = Date.now();
3185
+ try {
3186
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3187
+ results.push({
3188
+ success: true,
3189
+ pluginId: hook.pluginId,
3190
+ duration: Date.now() - start
3191
+ });
3192
+ } catch (error) {
3193
+ results.push({
3194
+ success: false,
3195
+ error: error instanceof Error ? error : new Error(String(error)),
3196
+ pluginId: hook.pluginId,
3197
+ duration: Date.now() - start
3198
+ });
3199
+ if (hook.errorPolicy === "abort") throw error;
3200
+ }
3201
+ }
3202
+ return results;
3203
+ }
3204
+ async runContentPolicy(name, event) {
3205
+ if (name === "content:beforeSchedule") {
3206
+ if (!("scheduledAt" in event)) throw new Error("content:beforeSchedule requires scheduledAt");
3207
+ return this.runContentPolicyHooks(name, this.getTypedHooks(name), event);
3208
+ }
3209
+ return this.runContentPolicyHooks(name, this.getTypedHooks(name), event);
3210
+ }
3211
+ async runContentPolicyHooks(name, hooks, event) {
3212
+ const results = [];
3213
+ for (const hook of hooks) {
3214
+ const ctx = this.getContext(hook.pluginId);
3215
+ const start = Date.now();
3216
+ try {
3217
+ const decision = inspectContentPolicyDecision(await this.executeWithTimeout(() => hook.handler(event, ctx), hook.timeout));
3218
+ if (decision.kind === "invalid") throw new Error(`Plugin "${hook.pluginId}" returned an invalid ${name} decision`);
3219
+ results.push({
3220
+ success: true,
3221
+ pluginId: hook.pluginId,
3222
+ duration: Date.now() - start
3223
+ });
3224
+ if (decision.kind === "cancel") return {
3225
+ cancellation: {
3226
+ pluginId: hook.pluginId,
3227
+ reason: decision.reason
3228
+ },
3229
+ results
3230
+ };
3231
+ } catch (error) {
3232
+ results.push({
3233
+ success: false,
3234
+ error: error instanceof Error ? error : new Error(String(error)),
3235
+ pluginId: hook.pluginId,
3236
+ duration: Date.now() - start
3237
+ });
3238
+ if (hook.errorPolicy === "abort") throw error;
3239
+ console.error(`[content-policy] Plugin "${hook.pluginId}" failed ${name}; continuing by policy`);
3240
+ }
3241
+ }
3242
+ return { results };
3243
+ }
3244
+ /**
3245
+ * Run content state-change hooks that all share the same event shape.
3246
+ */
3247
+ async runContentStateChangeHook(name, content, collection) {
3248
+ const hooks = this.getTypedHooks(name);
3249
+ const results = [];
3250
+ for (const hook of hooks) {
3251
+ const { handler } = hook;
3252
+ const event = {
3253
+ content,
3254
+ collection
3255
+ };
3256
+ const ctx = this.getContext(hook.pluginId);
3257
+ const start = Date.now();
3258
+ try {
3259
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3260
+ results.push({
3261
+ success: true,
3262
+ pluginId: hook.pluginId,
3263
+ duration: Date.now() - start
3264
+ });
3265
+ } catch (error) {
3266
+ results.push({
3267
+ success: false,
3268
+ error: error instanceof Error ? error : new Error(String(error)),
3269
+ pluginId: hook.pluginId,
3270
+ duration: Date.now() - start
3271
+ });
3272
+ if (hook.errorPolicy === "abort") throw error;
3273
+ }
3274
+ }
3275
+ return results;
3276
+ }
3277
+ /**
3278
+ * Run content:afterPublish hooks (fire-and-forget).
3279
+ */
3280
+ async runContentAfterPublish(content, collection) {
3281
+ return this.runContentStateChangeHook("content:afterPublish", content, collection);
3282
+ }
3283
+ /**
3284
+ * Run content:afterUnpublish hooks (fire-and-forget).
3285
+ */
3286
+ async runContentAfterUnpublish(content, collection) {
3287
+ return this.runContentStateChangeHook("content:afterUnpublish", content, collection);
3288
+ }
3289
+ /**
3290
+ * Run content:afterRestore hooks (fire-and-forget).
3291
+ */
3292
+ async runContentAfterRestore(content, collection) {
3293
+ return this.runContentStateChangeHook("content:afterRestore", content, collection);
3294
+ }
3295
+ /**
3296
+ * Run content:afterSchedule hooks (fire-and-forget).
3297
+ */
3298
+ async runContentAfterSchedule(content, collection) {
3299
+ return this.runContentStateChangeHook("content:afterSchedule", content, collection);
3300
+ }
3301
+ /**
3302
+ * Run content:afterUnschedule hooks (fire-and-forget).
3303
+ */
3304
+ async runContentAfterUnschedule(content, collection) {
3305
+ return this.runContentStateChangeHook("content:afterUnschedule", content, collection);
3306
+ }
3307
+ /**
3308
+ * Run media:beforeUpload hooks
3309
+ */
3310
+ async runMediaBeforeUpload(file) {
3311
+ const hooks = this.getTypedHooks("media:beforeUpload");
3312
+ const results = [];
3313
+ let currentFile = file;
3314
+ for (const hook of hooks) {
3315
+ const { handler } = hook;
3316
+ const event = { file: currentFile };
3317
+ const ctx = this.getContext(hook.pluginId);
3318
+ const start = Date.now();
3319
+ try {
3320
+ const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3321
+ if (result !== void 0) currentFile = result;
3322
+ results.push({
3323
+ success: true,
3324
+ value: currentFile,
3325
+ pluginId: hook.pluginId,
3326
+ duration: Date.now() - start
3327
+ });
3328
+ } catch (error) {
3329
+ results.push({
3330
+ success: false,
3331
+ error: error instanceof Error ? error : new Error(String(error)),
3332
+ pluginId: hook.pluginId,
3333
+ duration: Date.now() - start
3334
+ });
3335
+ if (hook.errorPolicy === "abort") throw error;
3336
+ }
3337
+ }
3338
+ return {
3339
+ file: currentFile,
3340
+ results
3341
+ };
3342
+ }
3343
+ /**
3344
+ * Run media:afterUpload hooks
3345
+ */
3346
+ async runMediaAfterUpload(media) {
3347
+ const hooks = this.getTypedHooks("media:afterUpload");
3348
+ const results = [];
3349
+ for (const hook of hooks) {
3350
+ const { handler } = hook;
3351
+ const event = { media };
3352
+ const ctx = this.getContext(hook.pluginId);
3353
+ const start = Date.now();
3354
+ try {
3355
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3356
+ results.push({
3357
+ success: true,
3358
+ pluginId: hook.pluginId,
3359
+ duration: Date.now() - start
3360
+ });
3361
+ } catch (error) {
3362
+ results.push({
3363
+ success: false,
3364
+ error: error instanceof Error ? error : new Error(String(error)),
3365
+ pluginId: hook.pluginId,
3366
+ duration: Date.now() - start
3367
+ });
3368
+ if (hook.errorPolicy === "abort") throw error;
3369
+ }
3370
+ }
3371
+ return results;
3372
+ }
3373
+ /**
3374
+ * Invoke the cron hook for a specific plugin.
3375
+ *
3376
+ * Unlike other hooks which broadcast to all plugins, the cron hook is
3377
+ * dispatched only to the target plugin — the one that owns the task.
3378
+ */
3379
+ async invokeCronHook(pluginId, event) {
3380
+ const hook = this.getTypedHooks("cron").find((h) => h.pluginId === pluginId);
3381
+ if (!hook) return {
3382
+ success: false,
3383
+ error: /* @__PURE__ */ new Error(`Plugin "${pluginId}" has no cron hook registered`),
3384
+ pluginId,
3385
+ duration: 0
3386
+ };
3387
+ const { handler } = hook;
3388
+ const ctx = this.getContext(pluginId);
3389
+ const start = Date.now();
3390
+ try {
3391
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3392
+ return {
3393
+ success: true,
3394
+ pluginId,
3395
+ duration: Date.now() - start
3396
+ };
3397
+ } catch (error) {
3398
+ return {
3399
+ success: false,
3400
+ error: error instanceof Error ? error : new Error(String(error)),
3401
+ pluginId,
3402
+ duration: Date.now() - start
3403
+ };
3404
+ }
3405
+ }
3406
+ /**
3407
+ * Run email:beforeSend hooks (middleware pipeline).
3408
+ *
3409
+ * Each handler receives the message and returns a modified message or
3410
+ * `false` to cancel delivery. The pipeline chains message transformations —
3411
+ * each handler receives the output of the previous one.
3412
+ */
3413
+ async runEmailBeforeSend(message, source) {
3414
+ const hooks = this.getTypedHooks("email:beforeSend");
3415
+ const results = [];
3416
+ let currentMessage = message;
3417
+ for (const hook of hooks) {
3418
+ const { handler } = hook;
3419
+ const event = {
3420
+ message: { ...currentMessage },
3421
+ source
3422
+ };
3423
+ const ctx = this.getContext(hook.pluginId);
3424
+ const start = Date.now();
3425
+ try {
3426
+ const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3427
+ if (result === false) {
3428
+ results.push({
3429
+ success: true,
3430
+ value: false,
3431
+ pluginId: hook.pluginId,
3432
+ duration: Date.now() - start
3433
+ });
3434
+ return {
3435
+ message: false,
3436
+ results
3437
+ };
3438
+ }
3439
+ if (result && typeof result === "object") currentMessage = result;
3440
+ results.push({
3441
+ success: true,
3442
+ value: currentMessage,
3443
+ pluginId: hook.pluginId,
3444
+ duration: Date.now() - start
3445
+ });
3446
+ } catch (error) {
3447
+ results.push({
3448
+ success: false,
3449
+ error: error instanceof Error ? error : new Error(String(error)),
3450
+ pluginId: hook.pluginId,
3451
+ duration: Date.now() - start
3452
+ });
3453
+ if (hook.errorPolicy === "abort") throw error;
3454
+ }
3455
+ }
3456
+ return {
3457
+ message: currentMessage,
3458
+ results
3459
+ };
3460
+ }
3461
+ /**
3462
+ * Run email:afterSend hooks (fire-and-forget).
3463
+ *
3464
+ * Errors are logged but don't propagate — they don't affect the caller.
3465
+ */
3466
+ async runEmailAfterSend(message, source) {
3467
+ const hooks = this.getTypedHooks("email:afterSend");
3468
+ const results = [];
3469
+ for (const hook of hooks) {
3470
+ const { handler } = hook;
3471
+ const event = {
3472
+ message,
3473
+ source
3474
+ };
3475
+ const ctx = this.getContext(hook.pluginId);
3476
+ const start = Date.now();
3477
+ try {
3478
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3479
+ results.push({
3480
+ success: true,
3481
+ pluginId: hook.pluginId,
3482
+ duration: Date.now() - start
3483
+ });
3484
+ } catch (error) {
3485
+ console.error(`[email:afterSend] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
3486
+ results.push({
3487
+ success: false,
3488
+ error: error instanceof Error ? error : new Error(String(error)),
3489
+ pluginId: hook.pluginId,
3490
+ duration: Date.now() - start
3491
+ });
3492
+ }
3493
+ }
3494
+ return results;
3495
+ }
3496
+ /**
3497
+ * Run comment:beforeCreate hooks (middleware pipeline).
3498
+ *
3499
+ * Each handler receives the event and returns a modified event or
3500
+ * `false` to reject the comment. The pipeline chains transformations —
3501
+ * each handler receives the output of the previous one.
3502
+ */
3503
+ async runCommentBeforeCreate(event) {
3504
+ const hooks = this.getTypedHooks("comment:beforeCreate");
3505
+ let currentEvent = event;
3506
+ for (const hook of hooks) {
3507
+ const { handler } = hook;
3508
+ const ctx = this.getContext(hook.pluginId);
3509
+ const start = Date.now();
3510
+ try {
3511
+ const result = await this.executeWithTimeout(() => handler({ ...currentEvent }, ctx), hook.timeout);
3512
+ if (result === false) return false;
3513
+ if (result && typeof result === "object") currentEvent = result;
3514
+ } catch (error) {
3515
+ console.error(`[comment:beforeCreate] Plugin "${hook.pluginId}" error (${Date.now() - start}ms):`, error instanceof Error ? error.message : error);
3516
+ if (hook.errorPolicy === "abort") throw error;
3517
+ }
3518
+ }
3519
+ return currentEvent;
3520
+ }
3521
+ /**
3522
+ * Run comment:afterCreate hooks (fire-and-forget).
3523
+ *
3524
+ * Errors are logged but don't propagate — they don't affect the caller.
3525
+ */
3526
+ async runCommentAfterCreate(event) {
3527
+ const hooks = this.getTypedHooks("comment:afterCreate");
3528
+ for (const hook of hooks) {
3529
+ const { handler } = hook;
3530
+ const ctx = this.getContext(hook.pluginId);
3531
+ try {
3532
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3533
+ } catch (error) {
3534
+ console.error(`[comment:afterCreate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
3535
+ }
3536
+ }
3537
+ }
3538
+ /**
3539
+ * Run comment:afterModerate hooks (fire-and-forget).
3540
+ *
3541
+ * Errors are logged but don't propagate — they don't affect the caller.
3542
+ */
3543
+ async runCommentAfterModerate(event) {
3544
+ const hooks = this.getTypedHooks("comment:afterModerate");
3545
+ for (const hook of hooks) {
3546
+ const { handler } = hook;
3547
+ const ctx = this.getContext(hook.pluginId);
3548
+ try {
3549
+ await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
3550
+ } catch (error) {
3551
+ console.error(`[comment:afterModerate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
3552
+ }
3553
+ }
3554
+ }
3555
+ /** Run byline:afterSave hooks. Errors are logged and never propagate. */
3556
+ async runBylineAfterSave(byline, isNew) {
3557
+ const event = {
3558
+ byline: toBylineInfo(byline),
3559
+ isNew
3560
+ };
3561
+ for (const hook of this.getTypedHooks("byline:afterSave")) await this.runLoggedHook("byline:afterSave", hook, (ctx) => hook.handler(event, ctx));
3562
+ }
3563
+ /** Run byline:afterDelete hooks. Errors are logged and never propagate. */
3564
+ async runBylineAfterDelete(byline) {
3565
+ const event = { byline: toBylineInfo(byline) };
3566
+ for (const hook of this.getTypedHooks("byline:afterDelete")) await this.runLoggedHook("byline:afterDelete", hook, (ctx) => hook.handler(event, ctx));
3567
+ }
3568
+ async runLoggedHook(name, hook, run) {
3569
+ try {
3570
+ await this.executeWithTimeout(() => run(this.getContext(hook.pluginId)), hook.timeout);
3571
+ } catch (error) {
3572
+ console.error(`[${name}] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
3573
+ }
3574
+ }
3575
+ /**
3576
+ * Run page:metadata hooks. Each handler returns contributions that are
3577
+ * merged by the metadata collector. Errors are logged but don't propagate.
3578
+ */
3579
+ async runPageMetadata(event) {
3580
+ const hooks = this.getTypedHooks("page:metadata");
3581
+ const results = [];
3582
+ for (const hook of hooks) {
3583
+ const { handler } = hook;
3584
+ const ctx = this.getContext(hook.pluginId);
3585
+ try {
3586
+ const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
3587
+ if (result != null) {
3588
+ const contributions = Array.isArray(result) ? result : [result];
3589
+ results.push({
3590
+ pluginId: hook.pluginId,
3591
+ contributions
3592
+ });
3593
+ }
3594
+ } catch (error) {
3595
+ console.error(`[page:metadata] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
3596
+ }
3597
+ }
3598
+ return results;
3599
+ }
3600
+ /**
3601
+ * Run page:fragments hooks. Only trusted plugins should be registered
3602
+ * for this hook. Errors are logged but don't propagate.
3603
+ */
3604
+ async runPageFragments(event) {
3605
+ const hooks = this.getTypedHooks("page:fragments");
3606
+ const results = [];
3607
+ for (const hook of hooks) {
3608
+ const { handler } = hook;
3609
+ const ctx = this.getContext(hook.pluginId);
3610
+ try {
3611
+ const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
3612
+ if (result != null) {
3613
+ const contributions = Array.isArray(result) ? result : [result];
3614
+ results.push({
3615
+ pluginId: hook.pluginId,
3616
+ contributions
3617
+ });
3618
+ }
3619
+ } catch (error) {
3620
+ console.error(`[page:fragments] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
3621
+ }
3622
+ }
3623
+ return results;
3624
+ }
3625
+ /**
3626
+ * Check if any hooks are registered for a given name
3627
+ */
3628
+ hasHooks(name) {
3629
+ const hooks = this.hooks.get(name);
3630
+ return hooks !== void 0 && hooks.length > 0;
3631
+ }
3632
+ /**
3633
+ * Get hook count for debugging
3634
+ */
3635
+ getHookCount(name) {
3636
+ return this.hooks.get(name)?.length || 0;
3637
+ }
3638
+ /**
3639
+ * Get all registered hook names
3640
+ */
3641
+ getRegisteredHooks() {
3642
+ return [...this.hooks.keys()];
3643
+ }
3644
+ /**
3645
+ * Returns hook names where at least one handler declared exclusive: true
3646
+ */
3647
+ getRegisteredExclusiveHooks() {
3648
+ return [...this.exclusiveHookNames];
3649
+ }
3650
+ /**
3651
+ * Check if a hook is exclusive
3652
+ */
3653
+ isExclusiveHook(name) {
3654
+ return this.exclusiveHookNames.has(name);
3655
+ }
3656
+ /**
3657
+ * Set the selected provider for an exclusive hook.
3658
+ * Called by PluginManager after resolution.
3659
+ */
3660
+ setExclusiveSelection(hookName, pluginId) {
3661
+ this.exclusiveSelections.set(hookName, pluginId);
3662
+ }
3663
+ /**
3664
+ * Clear the selected provider for an exclusive hook.
3665
+ */
3666
+ clearExclusiveSelection(hookName) {
3667
+ this.exclusiveSelections.delete(hookName);
3668
+ }
3669
+ /**
3670
+ * Get the selected provider for an exclusive hook (if any).
3671
+ */
3672
+ getExclusiveSelection(hookName) {
3673
+ return this.exclusiveSelections.get(hookName);
3674
+ }
3675
+ /**
3676
+ * Get all plugins that registered a handler for a given exclusive hook.
3677
+ */
3678
+ getExclusiveHookProviders(hookName) {
3679
+ return (this.hooks.get(hookName) ?? []).filter((h) => h.exclusive).map((h) => ({ pluginId: h.pluginId }));
3680
+ }
3681
+ /**
3682
+ * Get all plugins that registered a non-exclusive handler for a given
3683
+ * hook (e.g. `email:beforeSend`, `email:afterSend`), preserving priority
3684
+ * order. Partitions with `getExclusiveHookProviders()`, which returns
3685
+ * plugins whose registration is marked `exclusive: true`.
3686
+ */
3687
+ getHookProviders(hookName) {
3688
+ return (this.hooks.get(hookName) ?? []).filter((h) => !h.exclusive).map((h) => ({ pluginId: h.pluginId }));
3689
+ }
3690
+ /**
3691
+ * Invoke an exclusive hook — dispatch only to the selected provider.
3692
+ * Returns null if no provider is selected or if the selected hook
3693
+ * is not found in the pipeline.
3694
+ *
3695
+ * This is a generic dispatch used by the email pipeline and other
3696
+ * exclusive hook consumers. The handler type is unknown — callers
3697
+ * must know the expected signature.
3698
+ *
3699
+ * Errors are isolated: a failing handler returns an error result
3700
+ * instead of propagating the exception to the caller.
3701
+ */
3702
+ async invokeExclusiveHook(hookName, event) {
3703
+ const selectedPluginId = this.exclusiveSelections.get(hookName);
3704
+ if (!selectedPluginId) return null;
3705
+ const hook = (this.hooks.get(hookName) ?? []).find((h) => h.pluginId === selectedPluginId && h.exclusive);
3706
+ if (!hook) return null;
3707
+ const start = Date.now();
3708
+ try {
3709
+ const ctx = this.getContext(selectedPluginId);
3710
+ const handler = hook.handler;
3711
+ return {
3712
+ result: await this.executeWithTimeout(() => handler(event, ctx), hook.timeout),
3713
+ pluginId: selectedPluginId,
3714
+ duration: Date.now() - start
3715
+ };
3716
+ } catch (error) {
3717
+ return {
3718
+ result: void 0,
3719
+ pluginId: selectedPluginId,
3720
+ error: error instanceof Error ? error : new Error(String(error)),
3721
+ duration: Date.now() - start
3722
+ };
3723
+ }
3724
+ }
3725
+ };
3726
+ /**
3727
+ * Create a hook pipeline from plugins
3728
+ */
3729
+ function createHookPipeline(plugins, factoryOptions) {
3730
+ return new HookPipeline(plugins, factoryOptions);
3731
+ }
3732
+ /** Options table key prefix for exclusive hook selections */
3733
+ const EXCLUSIVE_HOOK_KEY_PREFIX = "emdash:exclusive_hook:";
3734
+ /**
3735
+ * Resolve exclusive hook selections.
3736
+ *
3737
+ * Shared algorithm used by both PluginManager and EmDashRuntime:
3738
+ * 1. If a DB selection exists and that plugin is active → keep it.
3739
+ * 2. If DB selection is stale (plugin inactive/gone) → clear it.
3740
+ * 3. If no selection and only one active provider → auto-select it. Fallback
3741
+ * providers are not counted when another provider is active, so a single
3742
+ * plugin provider is selected over a built-in fallback. A fallback
3743
+ * selection is kept in memory only. Manual providers are never
3744
+ * auto-selected.
3745
+ * 4. If preferred hints match an active provider → first match wins.
3746
+ * 5. If multiple providers and no hint → leave unselected (admin must choose).
3747
+ */
3748
+ async function resolveExclusiveHooks(opts) {
3749
+ const { pipeline, isActive, getOption, getOptions, setOption, deleteOption, preferredHints, fallbackProviders, manualProviders } = opts;
3750
+ const exclusiveHookNames = pipeline.getRegisteredExclusiveHooks();
3751
+ if (exclusiveHookNames.length === 0) return;
3752
+ let batchedSelections;
3753
+ if (getOptions) try {
3754
+ batchedSelections = await getOptions(exclusiveHookNames.map((hookName) => `${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`));
3755
+ } catch {
3756
+ return;
3757
+ }
3758
+ for (const hookName of exclusiveHookNames) {
3759
+ const providers = pipeline.getExclusiveHookProviders(hookName);
3760
+ const activeProviderIds = new Set(providers.map((p) => p.pluginId).filter((id) => isActive(id)));
3761
+ const key = `${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`;
3762
+ let currentSelection = null;
3763
+ if (batchedSelections) currentSelection = batchedSelections.get(key) ?? null;
3764
+ else try {
3765
+ currentSelection = await getOption(key);
3766
+ } catch {
3767
+ continue;
3768
+ }
3769
+ if (currentSelection && activeProviderIds.has(currentSelection)) {
3770
+ pipeline.setExclusiveSelection(hookName, currentSelection);
3771
+ continue;
3772
+ }
3773
+ if (currentSelection) try {
3774
+ await deleteOption(key);
3775
+ } catch {}
3776
+ const autoSelectable = [...activeProviderIds].filter((id) => !manualProviders?.has(id));
3777
+ let candidates = autoSelectable.length > 1 && fallbackProviders ? autoSelectable.filter((id) => !fallbackProviders.has(id)) : autoSelectable;
3778
+ if (candidates.length === 0 && fallbackProviders) {
3779
+ const firstFallback = [...fallbackProviders].find((id) => autoSelectable.includes(id));
3780
+ if (firstFallback) candidates = [firstFallback];
3781
+ }
3782
+ if (candidates.length === 1) {
3783
+ const [onlyProvider] = candidates;
3784
+ if (!fallbackProviders?.has(onlyProvider)) try {
3785
+ await setOption(key, onlyProvider);
3786
+ } catch {}
3787
+ pipeline.setExclusiveSelection(hookName, onlyProvider);
3788
+ continue;
3789
+ }
3790
+ if (preferredHints) {
3791
+ let found = false;
3792
+ for (const [pluginId, hooks] of preferredHints) if (hooks.includes(hookName) && activeProviderIds.has(pluginId) && !manualProviders?.has(pluginId)) {
3793
+ try {
3794
+ await setOption(key, pluginId);
3795
+ } catch {}
3796
+ pipeline.setExclusiveSelection(hookName, pluginId);
3797
+ found = true;
3798
+ break;
3799
+ }
3800
+ if (found) continue;
3801
+ }
3802
+ pipeline.clearExclusiveSelection(hookName);
3803
+ }
3804
+ }
3805
+
3806
+ //#endregion
3807
+ //#region src/plugins/save-rejection.ts
3808
+ /**
3809
+ * Thrown by a `content:beforeSave` hook to reject a save with a message
3810
+ * that is safe to show to the editor. The runtime converts it into a
3811
+ * structured `SAVE_REJECTED` API error; any other exception thrown by the
3812
+ * hook cancels the save with a generic error that hides the exception
3813
+ * message.
3814
+ */
3815
+ var ContentSaveRejectedError = class extends Error {
3816
+ name = "ContentSaveRejectedError";
3817
+ };
3818
+ /**
3819
+ * Matches by name as well as by prototype: bundlers can duplicate this
3820
+ * module across SSR chunks, and an `instanceof` against the wrong copy of
3821
+ * the class would misreport a rejection as a plugin crash.
3822
+ */
3823
+ function isContentSaveRejection(error) {
3824
+ if (error instanceof ContentSaveRejectedError) return true;
3825
+ return error instanceof Error && error.name === "ContentSaveRejectedError";
3826
+ }
3827
+
3828
+ //#endregion
3829
+ //#region src/plugins/sandbox/hook-result.ts
3830
+ /** Current wire-format version for sandbox hook result envelopes. */
3831
+ const SANDBOX_HOOK_RESULT_VERSION = 1;
3832
+ /** Maximum editor-facing rejection reason accepted from a sandboxed plugin. */
3833
+ const MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH = 500;
3834
+ function isRecord(value) {
3835
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3836
+ }
3837
+ /** Validate and normalize an untrusted value returned across the sandbox boundary. */
3838
+ function inspectSandboxHookResult(value) {
3839
+ if (!isRecord(value) || !Object.hasOwn(value, "__emdashSandboxHookResult")) return { kind: "value" };
3840
+ if (value.__emdashSandboxHookResult !== true || value.version !== SANDBOX_HOOK_RESULT_VERSION || !isRecord(value.error) || value.error.code !== "SAVE_REJECTED" || typeof value.error.reason !== "string") return { kind: "malformed" };
3841
+ const reason = value.error.reason.trim();
3842
+ if (reason.length === 0 || reason.length > MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH) return { kind: "malformed" };
3843
+ return {
3844
+ kind: "error",
3845
+ error: {
3846
+ code: "SAVE_REJECTED",
3847
+ reason
3848
+ }
3849
+ };
3850
+ }
3851
+
3852
+ //#endregion
3853
+ export { handleContentGetIncludingTrashed as A, handleContentUpdate as B, handleContentCountScheduled as C, handleContentDiscardDraft as D, handleContentDelete as E, handleContentRestore as F, storagelessDataKeyError as H, handleContentSchedule as I, handleContentTranslations as L, handleContentListTrashed as M, handleContentPermanentDelete as N, handleContentDuplicate as O, handleContentPublish as P, handleContentUnpublish as R, handleContentCompare as S, handleContentCreate as T, liveReferenceData as U, handleScheduledPolicyRejection as V, liveReferenceSelection as W, handleRevisionRestore as _, isContentSaveRejection as a, changedStoragelessDataKeys as b, HookTimeoutError as c, resolveExclusiveHooks as d, definePlugin as f, handleRevisionList as g, handleRevisionGet as h, ContentSaveRejectedError as i, handleContentList as j, handleContentGet as k, createHookPipeline as l, handleRevisionEditors as m, SANDBOX_HOOK_RESULT_VERSION as n, EXCLUSIVE_HOOK_KEY_PREFIX as o, definePluginRoute as p, inspectSandboxHookResult as r, HookPipeline as s, MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH as t, getActiveContentSaveHookName as u, buildManifestCollections as v, handleContentCountTrashed as w, handleContentAuthors as x, generateManifest as y, handleContentUnschedule as z };
3854
+ //# sourceMappingURL=hook-result-CO4E3zDv.mjs.map