emdash 0.38.0 → 0.39.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 (1394) hide show
  1. package/dist/action-token-On1sot_c.mjs +26 -0
  2. package/dist/action-token-On1sot_c.mjs.map +1 -0
  3. package/dist/activation-CaMfdBt1.mjs +382 -0
  4. package/dist/activation-CaMfdBt1.mjs.map +1 -0
  5. package/dist/adapters-Cq10K4_c.d.mts +171 -0
  6. package/dist/adapters-Cq10K4_c.d.mts.map +1 -0
  7. package/dist/after-PcEvMY_6.mjs +96 -0
  8. package/dist/after-PcEvMY_6.mjs.map +1 -0
  9. package/dist/allowed-origins-1Sa-2wZK.mjs +116 -0
  10. package/dist/allowed-origins-1Sa-2wZK.mjs.map +1 -0
  11. package/dist/api/route-utils.d.mts +4 -3
  12. package/dist/api/route-utils.d.mts.map +1 -1
  13. package/dist/api/route-utils.mjs +45 -30
  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 -6
  17. package/dist/api-DmjKxPCY.mjs +4831 -0
  18. package/dist/api-DmjKxPCY.mjs.map +1 -0
  19. package/dist/api-tokens-BIXItFKV.mjs +163 -0
  20. package/dist/api-tokens-BIXItFKV.mjs.map +1 -0
  21. package/dist/apply-drpfmqrR.mjs +1005 -0
  22. package/dist/apply-drpfmqrR.mjs.map +1 -0
  23. package/dist/artifact-fetch-COiMhVgk.mjs +813 -0
  24. package/dist/artifact-fetch-COiMhVgk.mjs.map +1 -0
  25. package/dist/astro/index.d.mts +14 -12
  26. package/dist/astro/index.d.mts.map +1 -1
  27. package/dist/astro/index.mjs +99 -15
  28. package/dist/astro/index.mjs.map +1 -1
  29. package/dist/astro/middleware/auth.d.mts +12 -10
  30. package/dist/astro/middleware/auth.d.mts.map +1 -1
  31. package/dist/astro/middleware/auth.mjs +20 -11
  32. package/dist/astro/middleware/auth.mjs.map +1 -1
  33. package/dist/astro/middleware/media-usage-write-fence.mjs +5 -5
  34. package/dist/astro/middleware/redirect.mjs +11 -11
  35. package/dist/astro/middleware/request-context.d.mts +1 -1
  36. package/dist/astro/middleware/request-context.d.mts.map +1 -1
  37. package/dist/astro/middleware/request-context.mjs +154 -28
  38. package/dist/astro/middleware/request-context.mjs.map +1 -1
  39. package/dist/astro/middleware/setup.mjs +1 -1
  40. package/dist/astro/middleware.d.mts +13 -10
  41. package/dist/astro/middleware.d.mts.map +1 -1
  42. package/dist/astro/middleware.mjs +114 -3062
  43. package/dist/astro/middleware.mjs.map +1 -1
  44. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +10 -9
  45. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs.map +1 -1
  46. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +10 -9
  47. package/dist/astro/routes/api/admin/allowed-domains/index.mjs.map +1 -1
  48. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +5 -5
  49. package/dist/astro/routes/api/admin/api-tokens/index.mjs +6 -6
  50. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +6 -6
  51. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +13 -12
  52. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs.map +1 -1
  53. package/dist/astro/routes/api/admin/byline-fields/index.mjs +13 -12
  54. package/dist/astro/routes/api/admin/byline-fields/index.mjs.map +1 -1
  55. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +13 -12
  56. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs.map +1 -1
  57. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +22 -21
  58. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs.map +1 -1
  59. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +22 -21
  60. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs.map +1 -1
  61. package/dist/astro/routes/api/admin/bylines/index.mjs +22 -21
  62. package/dist/astro/routes/api/admin/bylines/index.mjs.map +1 -1
  63. package/dist/astro/routes/api/admin/comments/_id_/status.d.mts.map +1 -1
  64. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +21 -54
  65. package/dist/astro/routes/api/admin/comments/_id_/status.mjs.map +1 -1
  66. package/dist/astro/routes/api/admin/comments/_id_.mjs +8 -8
  67. package/dist/astro/routes/api/admin/comments/bulk.mjs +15 -14
  68. package/dist/astro/routes/api/admin/comments/bulk.mjs.map +1 -1
  69. package/dist/astro/routes/api/admin/comments/counts.mjs +8 -8
  70. package/dist/astro/routes/api/admin/comments/index.mjs +15 -14
  71. package/dist/astro/routes/api/admin/comments/index.mjs.map +1 -1
  72. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +6 -6
  73. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +5 -5
  74. package/dist/astro/routes/api/admin/media-usage/activation.mjs +17 -16
  75. package/dist/astro/routes/api/admin/media-usage/activation.mjs.map +1 -1
  76. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +19 -18
  77. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs.map +1 -1
  78. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +19 -18
  79. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs.map +1 -1
  80. package/dist/astro/routes/api/admin/media-usage/progress.mjs +17 -17
  81. package/dist/astro/routes/api/admin/media-usage/repair.mjs +21 -20
  82. package/dist/astro/routes/api/admin/media-usage/repair.mjs.map +1 -1
  83. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +19 -18
  84. package/dist/astro/routes/api/admin/media-usage/work/index.mjs.map +1 -1
  85. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +19 -18
  86. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs.map +1 -1
  87. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +5 -5
  88. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +5 -5
  89. package/dist/astro/routes/api/admin/plugins/_id_/disable.d.mts.map +1 -1
  90. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +9 -69
  91. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
  92. package/dist/astro/routes/api/admin/plugins/_id_/enable.d.mts.map +1 -1
  93. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +9 -72
  94. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
  95. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +66 -62
  96. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  97. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +6 -6
  98. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +65 -62
  99. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
  100. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +70 -64
  101. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  102. package/dist/astro/routes/api/admin/plugins/_id_/update.d.mts.map +1 -1
  103. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +87 -66
  104. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  105. package/dist/astro/routes/api/admin/plugins/index.mjs +66 -62
  106. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  107. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +4 -4
  108. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +65 -62
  109. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  110. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.d.mts.map +1 -1
  111. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +85 -66
  112. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  113. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +65 -62
  114. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  115. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +70 -64
  116. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  117. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.d.mts.map +1 -1
  118. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +90 -69
  119. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  120. package/dist/astro/routes/api/admin/plugins/registry/artifact.d.mts.map +1 -1
  121. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +9 -8
  122. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
  123. package/dist/astro/routes/api/admin/plugins/registry/install.d.mts.map +1 -1
  124. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +77 -66
  125. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  126. package/dist/astro/routes/api/admin/plugins/registry/verify.d.mts.map +1 -1
  127. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +67 -64
  128. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs.map +1 -1
  129. package/dist/astro/routes/api/admin/plugins/updates.d.mts.map +1 -1
  130. package/dist/astro/routes/api/admin/plugins/updates.mjs +66 -63
  131. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  132. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.d.mts +8 -0
  133. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.d.mts.map +1 -0
  134. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs +27 -0
  135. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs.map +1 -0
  136. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +65 -62
  137. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  138. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +4 -4
  139. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +65 -62
  140. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  141. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +4 -4
  142. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +3 -3
  143. package/dist/astro/routes/api/admin/users/_id_/index.mjs +11 -10
  144. package/dist/astro/routes/api/admin/users/_id_/index.mjs.map +1 -1
  145. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +5 -5
  146. package/dist/astro/routes/api/admin/users/index.mjs +10 -9
  147. package/dist/astro/routes/api/admin/users/index.mjs.map +1 -1
  148. package/dist/astro/routes/api/auth/dev-bypass.mjs +5 -5
  149. package/dist/astro/routes/api/auth/invite/accept.mjs +3 -3
  150. package/dist/astro/routes/api/auth/invite/complete.mjs +15 -14
  151. package/dist/astro/routes/api/auth/invite/complete.mjs.map +1 -1
  152. package/dist/astro/routes/api/auth/invite/index.mjs +12 -11
  153. package/dist/astro/routes/api/auth/invite/index.mjs.map +1 -1
  154. package/dist/astro/routes/api/auth/invite/register-options.mjs +14 -13
  155. package/dist/astro/routes/api/auth/invite/register-options.mjs.map +1 -1
  156. package/dist/astro/routes/api/auth/logout.mjs +4 -4
  157. package/dist/astro/routes/api/auth/magic-link/send.mjs +14 -13
  158. package/dist/astro/routes/api/auth/magic-link/send.mjs.map +1 -1
  159. package/dist/astro/routes/api/auth/magic-link/verify.mjs +4 -4
  160. package/dist/astro/routes/api/auth/me.mjs +11 -10
  161. package/dist/astro/routes/api/auth/me.mjs.map +1 -1
  162. package/dist/astro/routes/api/auth/mode.mjs +4 -4
  163. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +4 -4
  164. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  165. package/dist/astro/routes/api/auth/passkey/_id_.mjs +10 -9
  166. package/dist/astro/routes/api/auth/passkey/_id_.mjs.map +1 -1
  167. package/dist/astro/routes/api/auth/passkey/index.mjs +3 -3
  168. package/dist/astro/routes/api/auth/passkey/options.mjs +16 -15
  169. package/dist/astro/routes/api/auth/passkey/options.mjs.map +1 -1
  170. package/dist/astro/routes/api/auth/passkey/register/options.mjs +14 -13
  171. package/dist/astro/routes/api/auth/passkey/register/options.mjs.map +1 -1
  172. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +15 -14
  173. package/dist/astro/routes/api/auth/passkey/register/verify.mjs.map +1 -1
  174. package/dist/astro/routes/api/auth/passkey/verify.mjs +15 -14
  175. package/dist/astro/routes/api/auth/passkey/verify.mjs.map +1 -1
  176. package/dist/astro/routes/api/auth/signup/complete.mjs +15 -14
  177. package/dist/astro/routes/api/auth/signup/complete.mjs.map +1 -1
  178. package/dist/astro/routes/api/auth/signup/request.mjs +14 -13
  179. package/dist/astro/routes/api/auth/signup/request.mjs.map +1 -1
  180. package/dist/astro/routes/api/auth/signup/verify.mjs +3 -3
  181. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.d.mts.map +1 -1
  182. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +15 -211
  183. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs.map +1 -1
  184. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +18 -17
  185. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs.map +1 -1
  186. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +4 -4
  187. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +15 -14
  188. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs.map +1 -1
  189. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +5 -5
  190. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +15 -14
  191. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs.map +1 -1
  192. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +4 -4
  193. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.d.mts +8 -0
  194. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.d.mts.map +1 -0
  195. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs +35 -0
  196. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs.map +1 -0
  197. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +16 -15
  198. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs.map +1 -1
  199. package/dist/astro/routes/api/content/_collection_/_id_/publish.d.mts +9 -2
  200. package/dist/astro/routes/api/content/_collection_/_id_/publish.d.mts.map +1 -1
  201. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +25 -18
  202. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
  203. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +27 -25
  204. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
  205. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +27 -25
  206. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
  207. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +5 -5
  208. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +4 -4
  209. package/dist/astro/routes/api/content/_collection_/_id_/schedule.d.mts.map +1 -1
  210. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +23 -15
  211. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
  212. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +23 -21
  213. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  214. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +4 -4
  215. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +23 -15
  216. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs.map +1 -1
  217. package/dist/astro/routes/api/content/_collection_/_id_.mjs +15 -14
  218. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  219. package/dist/astro/routes/api/content/_collection_/authors.mjs +4 -4
  220. package/dist/astro/routes/api/content/_collection_/index.mjs +12 -11
  221. package/dist/astro/routes/api/content/_collection_/index.mjs.map +1 -1
  222. package/dist/astro/routes/api/content/_collection_/trash.mjs +11 -10
  223. package/dist/astro/routes/api/content/_collection_/trash.mjs.map +1 -1
  224. package/dist/astro/routes/api/dashboard.mjs +14 -12
  225. package/dist/astro/routes/api/dashboard.mjs.map +1 -1
  226. package/dist/astro/routes/api/dev/emails.mjs +4 -4
  227. package/dist/astro/routes/api/health.d.mts +8 -0
  228. package/dist/astro/routes/api/health.d.mts.map +1 -0
  229. package/dist/astro/routes/api/health.mjs +21 -0
  230. package/dist/astro/routes/api/health.mjs.map +1 -0
  231. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  232. package/dist/astro/routes/api/import/probe.mjs +25 -23
  233. package/dist/astro/routes/api/import/probe.mjs.map +1 -1
  234. package/dist/astro/routes/api/import/wordpress/analyze.mjs +5 -5
  235. package/dist/astro/routes/api/import/wordpress/execute.d.mts +13 -11
  236. package/dist/astro/routes/api/import/wordpress/execute.d.mts.map +1 -1
  237. package/dist/astro/routes/api/import/wordpress/execute.mjs +20 -20
  238. package/dist/astro/routes/api/import/wordpress/media.d.mts +12 -10
  239. package/dist/astro/routes/api/import/wordpress/media.d.mts.map +1 -1
  240. package/dist/astro/routes/api/import/wordpress/media.mjs +15 -14
  241. package/dist/astro/routes/api/import/wordpress/media.mjs.map +1 -1
  242. package/dist/astro/routes/api/import/wordpress/prepare.mjs +14 -13
  243. package/dist/astro/routes/api/import/wordpress/prepare.mjs.map +1 -1
  244. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +13 -11
  245. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts.map +1 -1
  246. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +18 -17
  247. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs.map +1 -1
  248. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  249. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +25 -23
  250. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs.map +1 -1
  251. package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
  252. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +13 -11
  253. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts.map +1 -1
  254. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +36 -34
  255. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  256. package/dist/astro/routes/api/manifest.mjs +17 -9
  257. package/dist/astro/routes/api/manifest.mjs.map +1 -1
  258. package/dist/astro/routes/api/mcp.d.mts.map +1 -1
  259. package/dist/astro/routes/api/mcp.mjs +167 -101
  260. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  261. package/dist/astro/routes/api/media/_id_/confirm.mjs +15 -14
  262. package/dist/astro/routes/api/media/_id_/confirm.mjs.map +1 -1
  263. package/dist/astro/routes/api/media/_id_/replace.mjs +12 -11
  264. package/dist/astro/routes/api/media/_id_/replace.mjs.map +1 -1
  265. package/dist/astro/routes/api/media/_id_/upload.mjs +8 -8
  266. package/dist/astro/routes/api/media/_id_/usage.mjs +23 -22
  267. package/dist/astro/routes/api/media/_id_/usage.mjs.map +1 -1
  268. package/dist/astro/routes/api/media/_id_.mjs +22 -21
  269. package/dist/astro/routes/api/media/_id_.mjs.map +1 -1
  270. package/dist/astro/routes/api/media/asset/_id_/_filename_.d.mts +8 -0
  271. package/dist/astro/routes/api/media/asset/_id_/_filename_.d.mts.map +1 -0
  272. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs +52 -0
  273. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs.map +1 -0
  274. package/dist/astro/routes/api/media/file/_...key_.mjs +3 -3
  275. package/dist/astro/routes/api/media/folders/_id_.mjs +12 -11
  276. package/dist/astro/routes/api/media/folders/_id_.mjs.map +1 -1
  277. package/dist/astro/routes/api/media/folders/index.mjs +12 -11
  278. package/dist/astro/routes/api/media/folders/index.mjs.map +1 -1
  279. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +4 -4
  280. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +4 -4
  281. package/dist/astro/routes/api/media/providers/index.mjs +4 -4
  282. package/dist/astro/routes/api/media/upload-url.mjs +14 -13
  283. package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
  284. package/dist/astro/routes/api/media.mjs +26 -25
  285. package/dist/astro/routes/api/media.mjs.map +1 -1
  286. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +15 -14
  287. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  288. package/dist/astro/routes/api/menus/_name_/items.mjs +15 -14
  289. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  290. package/dist/astro/routes/api/menus/_name_/reorder.mjs +15 -14
  291. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  292. package/dist/astro/routes/api/menus/_name_/translations.mjs +15 -14
  293. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  294. package/dist/astro/routes/api/menus/_name_.mjs +15 -14
  295. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  296. package/dist/astro/routes/api/menus/index.mjs +15 -14
  297. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  298. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  299. package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -7
  300. package/dist/astro/routes/api/oauth/device/code.mjs +10 -10
  301. package/dist/astro/routes/api/oauth/device/token.mjs +9 -9
  302. package/dist/astro/routes/api/oauth/register.mjs +4 -4
  303. package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -7
  304. package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -7
  305. package/dist/astro/routes/api/oauth/token.mjs +7 -7
  306. package/dist/astro/routes/api/openapi.json.mjs +28 -23
  307. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  308. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.d.mts +2 -1
  309. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.d.mts.map +1 -1
  310. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +22 -40
  311. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs.map +1 -1
  312. package/dist/astro/routes/api/redirects/404s/index.mjs +18 -15
  313. package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
  314. package/dist/astro/routes/api/redirects/404s/summary.mjs +18 -15
  315. package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
  316. package/dist/astro/routes/api/redirects/_id_.d.mts.map +1 -1
  317. package/dist/astro/routes/api/redirects/_id_.mjs +20 -23
  318. package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
  319. package/dist/astro/routes/api/redirects/index.d.mts.map +1 -1
  320. package/dist/astro/routes/api/redirects/index.mjs +19 -20
  321. package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
  322. package/dist/astro/routes/api/relations/_id_/index.mjs +27 -25
  323. package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
  324. package/dist/astro/routes/api/relations/_id_/translations.mjs +21 -20
  325. package/dist/astro/routes/api/relations/_id_/translations.mjs.map +1 -1
  326. package/dist/astro/routes/api/relations/index.mjs +27 -25
  327. package/dist/astro/routes/api/relations/index.mjs.map +1 -1
  328. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +4 -4
  329. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +5 -5
  330. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +65 -62
  331. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  332. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +65 -62
  333. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  334. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +65 -62
  335. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  336. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +65 -62
  337. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  338. package/dist/astro/routes/api/schema/collections/index.mjs +65 -62
  339. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  340. package/dist/astro/routes/api/schema/collections/reorder.mjs +65 -62
  341. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  342. package/dist/astro/routes/api/schema/index.mjs +16 -16
  343. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +65 -62
  344. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  345. package/dist/astro/routes/api/schema/orphans/index.mjs +65 -62
  346. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  347. package/dist/astro/routes/api/search/enable.mjs +16 -15
  348. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  349. package/dist/astro/routes/api/search/index.mjs +17 -15
  350. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  351. package/dist/astro/routes/api/search/rebuild.mjs +16 -15
  352. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  353. package/dist/astro/routes/api/search/stats.mjs +10 -10
  354. package/dist/astro/routes/api/search/suggest.mjs +15 -14
  355. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  356. package/dist/astro/routes/api/sections/_slug_.mjs +15 -14
  357. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  358. package/dist/astro/routes/api/sections/index.mjs +15 -14
  359. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  360. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +9 -9
  361. package/dist/astro/routes/api/settings/backups/archives/index.mjs +8 -8
  362. package/dist/astro/routes/api/settings/backups/export.mjs +9 -9
  363. package/dist/astro/routes/api/settings/backups/index.mjs +10 -10
  364. package/dist/astro/routes/api/settings/email.mjs +6 -6
  365. package/dist/astro/routes/api/settings.mjs +22 -20
  366. package/dist/astro/routes/api/settings.mjs.map +1 -1
  367. package/dist/astro/routes/api/setup/admin-verify.mjs +16 -15
  368. package/dist/astro/routes/api/setup/admin-verify.mjs.map +1 -1
  369. package/dist/astro/routes/api/setup/admin.mjs +15 -14
  370. package/dist/astro/routes/api/setup/admin.mjs.map +1 -1
  371. package/dist/astro/routes/api/setup/dev-bypass.mjs +42 -40
  372. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  373. package/dist/astro/routes/api/setup/dev-reset.mjs +4 -4
  374. package/dist/astro/routes/api/setup/index.mjs +43 -40
  375. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  376. package/dist/astro/routes/api/setup/status.mjs +5 -5
  377. package/dist/astro/routes/api/snapshot.mjs +11 -11
  378. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +23 -22
  379. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -1
  380. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +23 -22
  381. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
  382. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +23 -22
  383. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
  384. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +23 -22
  385. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
  386. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +22 -21
  387. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -1
  388. package/dist/astro/routes/api/taxonomies/_name_.mjs +23 -22
  389. package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -1
  390. package/dist/astro/routes/api/taxonomies/index.mjs +23 -22
  391. package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
  392. package/dist/astro/routes/api/themes/preview.mjs +8 -8
  393. package/dist/astro/routes/api/typegen.mjs +6 -6
  394. package/dist/astro/routes/api/visual-editing/action-token.d.mts +8 -0
  395. package/dist/astro/routes/api/visual-editing/action-token.d.mts.map +1 -0
  396. package/dist/astro/routes/api/visual-editing/action-token.mjs +25 -0
  397. package/dist/astro/routes/api/visual-editing/action-token.mjs.map +1 -0
  398. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.d.mts +8 -0
  399. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.d.mts.map +1 -0
  400. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs +37 -0
  401. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs.map +1 -0
  402. package/dist/astro/routes/api/visual-editing/toolbar-labels.d.mts +8 -0
  403. package/dist/astro/routes/api/visual-editing/toolbar-labels.d.mts.map +1 -0
  404. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs +20 -0
  405. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs.map +1 -0
  406. package/dist/astro/routes/api/well-known/auth.mjs +2 -2
  407. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  408. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  409. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +12 -11
  410. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
  411. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +16 -15
  412. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
  413. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +16 -15
  414. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
  415. package/dist/astro/routes/api/widget-areas/_name_.mjs +10 -10
  416. package/dist/astro/routes/api/widget-areas/index.mjs +16 -15
  417. package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
  418. package/dist/astro/routes/api/widget-components.mjs +4 -4
  419. package/dist/astro/routes/robots.txt.mjs +13 -12
  420. package/dist/astro/routes/robots.txt.mjs.map +1 -1
  421. package/dist/astro/routes/sitemap-_collection_.xml.d.mts.map +1 -1
  422. package/dist/astro/routes/sitemap-_collection_.xml.mjs +23 -19
  423. package/dist/astro/routes/sitemap-_collection_.xml.mjs.map +1 -1
  424. package/dist/astro/routes/sitemap.xml.mjs +14 -13
  425. package/dist/astro/routes/sitemap.xml.mjs.map +1 -1
  426. package/dist/astro/types.d.mts +61 -23
  427. package/dist/astro/types.d.mts.map +1 -1
  428. package/dist/auth/providers/github.d.mts +1 -1
  429. package/dist/auth/providers/google.d.mts +1 -1
  430. package/dist/authoritative-records-DbqshfKD.mjs +5172 -0
  431. package/dist/authoritative-records-DbqshfKD.mjs.map +1 -0
  432. package/dist/authorize-BXpfMpp0.mjs +40 -0
  433. package/dist/authorize-BXpfMpp0.mjs.map +1 -0
  434. package/dist/backup-BsPQdwnS.mjs +246 -0
  435. package/dist/backup-BsPQdwnS.mjs.map +1 -0
  436. package/dist/base64-DvnNgP7e.mjs +63 -0
  437. package/dist/base64-DvnNgP7e.mjs.map +1 -0
  438. package/dist/byline-Doh-wt99.mjs +906 -0
  439. package/dist/byline-Doh-wt99.mjs.map +1 -0
  440. package/dist/byline-fields-CsrdvaLV.mjs +123 -0
  441. package/dist/byline-fields-CsrdvaLV.mjs.map +1 -0
  442. package/dist/byline-registry-D6lWzXk6.mjs +406 -0
  443. package/dist/byline-registry-D6lWzXk6.mjs.map +1 -0
  444. package/dist/bylines-Cop0hkoy.mjs +214 -0
  445. package/dist/bylines-Cop0hkoy.mjs.map +1 -0
  446. package/dist/bylines-kpBzHPr8.mjs +232 -0
  447. package/dist/bylines-kpBzHPr8.mjs.map +1 -0
  448. package/dist/cache-B0pOlXdM.mjs +108 -0
  449. package/dist/cache-B0pOlXdM.mjs.map +1 -0
  450. package/dist/capture-triggers-gxQxnxrJ.mjs +362 -0
  451. package/dist/capture-triggers-gxQxnxrJ.mjs.map +1 -0
  452. package/dist/challenge-store-CkRdSdd8.mjs +51 -0
  453. package/dist/challenge-store-CkRdSdd8.mjs.map +1 -0
  454. package/dist/checksum-Bsi2D9M1.mjs +162 -0
  455. package/dist/checksum-Bsi2D9M1.mjs.map +1 -0
  456. package/dist/chrome-tags-D7LGB91U.mjs +24 -0
  457. package/dist/chrome-tags-D7LGB91U.mjs.map +1 -0
  458. package/dist/chunks-BmWyou79.mjs +25 -0
  459. package/dist/chunks-BmWyou79.mjs.map +1 -0
  460. package/dist/cli/index.mjs +889 -102
  461. package/dist/cli/index.mjs.map +1 -1
  462. package/dist/client/cf-access.d.mts +1 -1
  463. package/dist/client/index.d.mts +2 -2
  464. package/dist/client/index.mjs +2 -2
  465. package/dist/collection-deletion-C3Xixmkx.mjs +436 -0
  466. package/dist/collection-deletion-C3Xixmkx.mjs.map +1 -0
  467. package/dist/collection-slugs-cache-D9auiKmI.mjs +85 -0
  468. package/dist/collection-slugs-cache-D9auiKmI.mjs.map +1 -0
  469. package/dist/comment-DcT8qdPK.mjs +313 -0
  470. package/dist/comment-DcT8qdPK.mjs.map +1 -0
  471. package/dist/comment-reaction-DY5-y8Y5.mjs +85 -0
  472. package/dist/comment-reaction-DY5-y8Y5.mjs.map +1 -0
  473. package/dist/comments-B67VRNGw.mjs +204 -0
  474. package/dist/comments-B67VRNGw.mjs.map +1 -0
  475. package/dist/comments-BVzzt6x5.mjs +99 -0
  476. package/dist/comments-BVzzt6x5.mjs.map +1 -0
  477. package/dist/components-DIl9Qzh6.mjs +108 -0
  478. package/dist/components-DIl9Qzh6.mjs.map +1 -0
  479. package/dist/config-B2acLeC5.mjs +242 -0
  480. package/dist/config-B2acLeC5.mjs.map +1 -0
  481. package/dist/config-CGVeT8Hc.mjs +73 -0
  482. package/dist/config-CGVeT8Hc.mjs.map +1 -0
  483. package/dist/config-D3HhLON3.d.mts +39 -0
  484. package/dist/config-D3HhLON3.d.mts.map +1 -0
  485. package/dist/config-DS7e4EZ9.d.mts +6387 -0
  486. package/dist/config-DS7e4EZ9.d.mts.map +1 -0
  487. package/dist/content-DZ3B5qtA.mjs +2216 -0
  488. package/dist/content-DZ3B5qtA.mjs.map +1 -0
  489. package/dist/content-list-query-CbPdzsna.d.mts +26 -0
  490. package/dist/content-list-query-CbPdzsna.d.mts.map +1 -0
  491. package/dist/content-policy-CM4skrNi.mjs +46 -0
  492. package/dist/content-policy-CM4skrNi.mjs.map +1 -0
  493. package/dist/content-refresh-BHLHJgyt.mjs +3599 -0
  494. package/dist/content-refresh-BHLHJgyt.mjs.map +1 -0
  495. package/dist/content-repair-BVll5WNl.mjs +440 -0
  496. package/dist/content-repair-BVll5WNl.mjs.map +1 -0
  497. package/dist/context-B195kjqZ.mjs +1835 -0
  498. package/dist/context-B195kjqZ.mjs.map +1 -0
  499. package/dist/cron-BcR3RN4K.mjs +282 -0
  500. package/dist/cron-BcR3RN4K.mjs.map +1 -0
  501. package/dist/dashboard-CZD4G7k_.mjs +151 -0
  502. package/dist/dashboard-CZD4G7k_.mjs.map +1 -0
  503. package/dist/database/migration-lock.d.mts +37 -0
  504. package/dist/database/migration-lock.d.mts.map +1 -0
  505. package/dist/database/migration-lock.mjs +76 -0
  506. package/dist/database/migration-lock.mjs.map +1 -0
  507. package/dist/database/pg-migration-lock.d.mts +1 -1
  508. package/dist/database/pg-migration-lock.mjs +1 -1
  509. package/dist/database/pg-migration-lock.mjs.map +1 -1
  510. package/dist/datetime-normalization-PeiEdcRY.mjs +187 -0
  511. package/dist/datetime-normalization-PeiEdcRY.mjs.map +1 -0
  512. package/dist/db/index.d.mts +3 -3
  513. package/dist/db/index.mjs +4 -3
  514. package/dist/db/index.mjs.map +1 -1
  515. package/dist/db/libsql-migrations.d.mts +1 -1
  516. package/dist/db/libsql-migrations.mjs +7 -6
  517. package/dist/db/libsql-migrations.mjs.map +1 -1
  518. package/dist/db/libsql.d.mts +1 -1
  519. package/dist/db/postgres-migrations.d.mts +1 -1
  520. package/dist/db/postgres-migrations.mjs +7 -6
  521. package/dist/db/postgres-migrations.mjs.map +1 -1
  522. package/dist/db/postgres.d.mts +1 -1
  523. package/dist/db/sqlite-migrations.d.mts +1 -1
  524. package/dist/db/sqlite-migrations.mjs +7 -6
  525. package/dist/db/sqlite-migrations.mjs.map +1 -1
  526. package/dist/db/sqlite.d.mts +1 -1
  527. package/dist/db/sqlite.mjs +1 -1
  528. package/dist/db-errors-CBD5yMro.mjs +55 -0
  529. package/dist/db-errors-CBD5yMro.mjs.map +1 -0
  530. package/dist/default-BtlxWgh9.mjs +81 -0
  531. package/dist/default-BtlxWgh9.mjs.map +1 -0
  532. package/dist/deferred-tasks-Ba9fphlE.d.mts +9 -0
  533. package/dist/deferred-tasks-Ba9fphlE.d.mts.map +1 -0
  534. package/dist/dev-typegen-CZaPLl3V.mjs +29 -0
  535. package/dist/dev-typegen-CZaPLl3V.mjs.map +1 -0
  536. package/dist/device-flow-3E5l0fpH.mjs +466 -0
  537. package/dist/device-flow-3E5l0fpH.mjs.map +1 -0
  538. package/dist/dialect-helpers-CtYdsX4W.mjs +307 -0
  539. package/dist/dialect-helpers-CtYdsX4W.mjs.map +1 -0
  540. package/dist/direct-executor-ZI8E01Yt.mjs +104 -0
  541. package/dist/direct-executor-ZI8E01Yt.mjs.map +1 -0
  542. package/dist/dist-2hDLsLeq.mjs +810 -0
  543. package/dist/dist-2hDLsLeq.mjs.map +1 -0
  544. package/dist/email-console-gc-E3Eqj.mjs +50 -0
  545. package/dist/email-console-gc-E3Eqj.mjs.map +1 -0
  546. package/dist/emdash-runtime-DZGinqTL.mjs +4041 -0
  547. package/dist/emdash-runtime-DZGinqTL.mjs.map +1 -0
  548. package/dist/enrich-C2Mk0lwE.mjs +194 -0
  549. package/dist/enrich-C2Mk0lwE.mjs.map +1 -0
  550. package/dist/entry-lock-D3C99MXS.mjs +1520 -0
  551. package/dist/entry-lock-D3C99MXS.mjs.map +1 -0
  552. package/dist/entry-lock-D9rnj2Lu.mjs +163 -0
  553. package/dist/entry-lock-D9rnj2Lu.mjs.map +1 -0
  554. package/dist/entry-lock-DX7QkqEg.d.mts +3503 -0
  555. package/dist/entry-lock-DX7QkqEg.d.mts.map +1 -0
  556. package/dist/entry-locks-CO_KaoU5.mjs +167 -0
  557. package/dist/entry-locks-CO_KaoU5.mjs.map +1 -0
  558. package/dist/error-CCTCskie.mjs +90 -0
  559. package/dist/error-CCTCskie.mjs.map +1 -0
  560. package/dist/errors-W3PA8HqB.mjs +447 -0
  561. package/dist/errors-W3PA8HqB.mjs.map +1 -0
  562. package/dist/escape-DN4Qmjsl.mjs +9 -0
  563. package/dist/escape-DN4Qmjsl.mjs.map +1 -0
  564. package/dist/field-defs-cache-B337z8UJ.mjs +77 -0
  565. package/dist/field-defs-cache-B337z8UJ.mjs.map +1 -0
  566. package/dist/focal-point-Gr34o-4o.mjs +23 -0
  567. package/dist/focal-point-Gr34o-4o.mjs.map +1 -0
  568. package/dist/fts-manager-DMb0sbIQ.mjs +413 -0
  569. package/dist/fts-manager-DMb0sbIQ.mjs.map +1 -0
  570. package/dist/hash-CLVFzWvx.mjs +37 -0
  571. package/dist/hash-CLVFzWvx.mjs.map +1 -0
  572. package/dist/hook-result-KY1jq21o.d.mts +31 -0
  573. package/dist/hook-result-KY1jq21o.d.mts.map +1 -0
  574. package/dist/hreflang-BgS2FqhH.d.mts +50 -0
  575. package/dist/hreflang-BgS2FqhH.d.mts.map +1 -0
  576. package/dist/hreflang-CrJwqoeb.mjs +105 -0
  577. package/dist/hreflang-CrJwqoeb.mjs.map +1 -0
  578. package/dist/http-route-dispatch-DAKlanXb.mjs +339 -0
  579. package/dist/http-route-dispatch-DAKlanXb.mjs.map +1 -0
  580. package/dist/identity-DRGSHEEr.mjs +35 -0
  581. package/dist/identity-DRGSHEEr.mjs.map +1 -0
  582. package/dist/import-DFr5B_hC.mjs +2020 -0
  583. package/dist/import-DFr5B_hC.mjs.map +1 -0
  584. package/dist/index-CDwKDkTq.d.mts +623 -0
  585. package/dist/index-CDwKDkTq.d.mts.map +1 -0
  586. package/dist/index.d.mts +27 -22
  587. package/dist/index.mjs +101 -89
  588. package/dist/init-lock-4eRRB4Le.mjs +56 -0
  589. package/dist/init-lock-4eRRB4Le.mjs.map +1 -0
  590. package/dist/install-finalization-5Os-QZ-2.mjs +58 -0
  591. package/dist/install-finalization-5Os-QZ-2.mjs.map +1 -0
  592. package/dist/lifecycle-7e-Lt_kX.mjs +25 -0
  593. package/dist/lifecycle-7e-Lt_kX.mjs.map +1 -0
  594. package/dist/load-Cu5bvCZh.mjs +28 -0
  595. package/dist/load-Cu5bvCZh.mjs.map +1 -0
  596. package/dist/loader-t4TxaFiQ.mjs +1004 -0
  597. package/dist/loader-t4TxaFiQ.mjs.map +1 -0
  598. package/dist/manifest-builder-D31UoJCu.mjs +189 -0
  599. package/dist/manifest-builder-D31UoJCu.mjs.map +1 -0
  600. package/dist/manifest-schema-Bkh8SeHd.mjs +491 -0
  601. package/dist/manifest-schema-Bkh8SeHd.mjs.map +1 -0
  602. package/dist/media/image-endpoint.mjs +1 -1
  603. package/dist/media/index.d.mts +1 -1
  604. package/dist/media/index.mjs +4 -4
  605. package/dist/media/local-runtime.d.mts +14 -12
  606. package/dist/media/local-runtime.d.mts.map +1 -1
  607. package/dist/media/local-runtime.mjs +12 -11
  608. package/dist/media/local-runtime.mjs.map +1 -1
  609. package/dist/media-TBlKCwo7.mjs +334 -0
  610. package/dist/media-TBlKCwo7.mjs.map +1 -0
  611. package/dist/media-allowlist-s60eAIf6.mjs +44 -0
  612. package/dist/media-allowlist-s60eAIf6.mjs.map +1 -0
  613. package/dist/media-folders-ClIRLUQv.mjs +210 -0
  614. package/dist/media-folders-ClIRLUQv.mjs.map +1 -0
  615. package/dist/media-url-DY_ijO3B.mjs +43 -0
  616. package/dist/media-url-DY_ijO3B.mjs.map +1 -0
  617. package/dist/media-usage-C4NolTpQ.mjs +1833 -0
  618. package/dist/media-usage-C4NolTpQ.mjs.map +1 -0
  619. package/dist/media-usage-activation-CAhmb14O.mjs +78 -0
  620. package/dist/media-usage-activation-CAhmb14O.mjs.map +1 -0
  621. package/dist/media-usage-work-Cu5DqewW.mjs +586 -0
  622. package/dist/media-usage-work-Cu5DqewW.mjs.map +1 -0
  623. package/dist/media-usage-work-DJr3rOEN.mjs +152 -0
  624. package/dist/media-usage-work-DJr3rOEN.mjs.map +1 -0
  625. package/dist/media-usage-write-fence-DW5oHT7q.mjs +42 -0
  626. package/dist/media-usage-write-fence-DW5oHT7q.mjs.map +1 -0
  627. package/dist/menus-DbgU9z5Q.mjs +3732 -0
  628. package/dist/menus-DbgU9z5Q.mjs.map +1 -0
  629. package/dist/menus-Wy8m5NcH.mjs +753 -0
  630. package/dist/menus-Wy8m5NcH.mjs.map +1 -0
  631. package/dist/migrations/index.d.mts +2 -2
  632. package/dist/migrations/index.d.mts.map +1 -1
  633. package/dist/migrations/index.mjs +6 -5
  634. package/dist/mime-CCYRC4r1.mjs +36 -0
  635. package/dist/mime-CCYRC4r1.mjs.map +1 -0
  636. package/dist/mode-CkmOhFqj.mjs +23 -0
  637. package/dist/mode-CkmOhFqj.mjs.map +1 -0
  638. package/dist/node-sqlite-compat-vpVaILnb.mjs +46 -0
  639. package/dist/node-sqlite-compat-vpVaILnb.mjs.map +1 -0
  640. package/dist/normalize-dChXQjwS.mjs +191 -0
  641. package/dist/normalize-dChXQjwS.mjs.map +1 -0
  642. package/dist/oauth-authorization-DZ-R-hmx.mjs +274 -0
  643. package/dist/oauth-authorization-DZ-R-hmx.mjs.map +1 -0
  644. package/dist/oauth-clients-BMPA8vjl.mjs +266 -0
  645. package/dist/oauth-clients-BMPA8vjl.mjs.map +1 -0
  646. package/dist/oauth-state-store-0gIdb48-.mjs +50 -0
  647. package/dist/oauth-state-store-0gIdb48-.mjs.map +1 -0
  648. package/dist/oauth-user-lookup-ChVW4UWu.mjs +26 -0
  649. package/dist/oauth-user-lookup-ChVW4UWu.mjs.map +1 -0
  650. package/dist/object-cache/memory.d.mts +1 -1
  651. package/dist/object-cache-DlSVbn5Y.mjs +534 -0
  652. package/dist/object-cache-DlSVbn5Y.mjs.map +1 -0
  653. package/dist/options-D5WcorD5.mjs +200 -0
  654. package/dist/options-D5WcorD5.mjs.map +1 -0
  655. package/dist/options-DAknChnw.d.mts +77 -0
  656. package/dist/options-DAknChnw.d.mts.map +1 -0
  657. package/dist/page/index.d.mts +2 -2
  658. package/dist/page/index.mjs +12 -11
  659. package/dist/page/index.mjs.map +1 -1
  660. package/dist/parse-Cr379Av9.mjs +81 -0
  661. package/dist/parse-Cr379Av9.mjs.map +1 -0
  662. package/dist/parse-tj9XLNO_.d.mts +165 -0
  663. package/dist/parse-tj9XLNO_.d.mts.map +1 -0
  664. package/dist/passkey-config-BD-wMaCf.mjs +46 -0
  665. package/dist/passkey-config-BD-wMaCf.mjs.map +1 -0
  666. package/dist/patterns-Do3iqi7N.mjs +145 -0
  667. package/dist/patterns-Do3iqi7N.mjs.map +1 -0
  668. package/dist/placeholder-CubPFn_L.d.mts +306 -0
  669. package/dist/placeholder-CubPFn_L.d.mts.map +1 -0
  670. package/dist/plugin-test-runtime.d.mts +97 -0
  671. package/dist/plugin-test-runtime.d.mts.map +1 -0
  672. package/dist/plugin-test-runtime.mjs +105 -0
  673. package/dist/plugin-types.d.mts +53 -15
  674. package/dist/plugin-types.d.mts.map +1 -1
  675. package/dist/plugin-types.mjs +18 -1
  676. package/dist/plugin-types.mjs.map +1 -0
  677. package/dist/plugin-utils.d.mts +12 -10
  678. package/dist/plugin-utils.d.mts.map +1 -1
  679. package/dist/plugins/adapt-sandbox-entry.d.mts +12 -10
  680. package/dist/plugins/adapt-sandbox-entry.d.mts.map +1 -1
  681. package/dist/plugins/adapt-sandbox-entry.mjs +18 -13
  682. package/dist/plugins/adapt-sandbox-entry.mjs.map +1 -1
  683. package/dist/plugins/host.d.mts +7 -0
  684. package/dist/plugins/host.mjs +45 -0
  685. package/dist/plugins/http-wire.d.mts +25 -0
  686. package/dist/plugins/http-wire.d.mts.map +1 -0
  687. package/dist/plugins/http-wire.mjs +148 -0
  688. package/dist/plugins/http-wire.mjs.map +1 -0
  689. package/dist/plugins/secret-redactor.d.mts +9 -0
  690. package/dist/plugins/secret-redactor.d.mts.map +1 -0
  691. package/dist/plugins/secret-redactor.mjs +51 -0
  692. package/dist/plugins/secret-redactor.mjs.map +1 -0
  693. package/dist/plugins-DHurtdXQ.mjs +277 -0
  694. package/dist/plugins-DHurtdXQ.mjs.map +1 -0
  695. package/dist/policy-lyZnjpwz.mjs +45 -0
  696. package/dist/policy-lyZnjpwz.mjs.map +1 -0
  697. package/dist/portable-text-oAwodbPS.mjs +286 -0
  698. package/dist/portable-text-oAwodbPS.mjs.map +1 -0
  699. package/dist/preview-Cup2bj8c.mjs +107 -0
  700. package/dist/preview-Cup2bj8c.mjs.map +1 -0
  701. package/dist/protocol-C1CNiKX4.d.mts +61 -0
  702. package/dist/protocol-C1CNiKX4.d.mts.map +1 -0
  703. package/dist/public-submission-Cs-pFMQK.mjs +245 -0
  704. package/dist/public-submission-Cs-pFMQK.mjs.map +1 -0
  705. package/dist/public-url-BWVHsfQv.mjs +101 -0
  706. package/dist/public-url-BWVHsfQv.mjs.map +1 -0
  707. package/dist/query-D-lxiOgn.mjs +890 -0
  708. package/dist/query-D-lxiOgn.mjs.map +1 -0
  709. package/dist/query-D7kHKOws.mjs +41 -0
  710. package/dist/query-D7kHKOws.mjs.map +1 -0
  711. package/dist/rate-limit-CqJn-w4h.mjs +120 -0
  712. package/dist/rate-limit-CqJn-w4h.mjs.map +1 -0
  713. package/dist/redirect-BrChFPIu.mjs +17 -0
  714. package/dist/redirect-BrChFPIu.mjs.map +1 -0
  715. package/dist/redirect-D2Yo-b6S.mjs +415 -0
  716. package/dist/redirect-D2Yo-b6S.mjs.map +1 -0
  717. package/dist/redirects-BCiTaIQ-.mjs +146 -0
  718. package/dist/redirects-BCiTaIQ-.mjs.map +1 -0
  719. package/dist/redirects-ByItliuu.mjs +644 -0
  720. package/dist/redirects-ByItliuu.mjs.map +1 -0
  721. package/dist/registry/testing.d.mts +14 -0
  722. package/dist/registry/testing.d.mts.map +1 -0
  723. package/dist/registry/testing.mjs +255 -0
  724. package/dist/registry/testing.mjs.map +1 -0
  725. package/dist/registry-CkuPoZs7.mjs +1222 -0
  726. package/dist/registry-CkuPoZs7.mjs.map +1 -0
  727. package/dist/relation-XTAtOpJO.mjs +334 -0
  728. package/dist/relation-XTAtOpJO.mjs.map +1 -0
  729. package/dist/relations-B4w-G5U9.mjs +309 -0
  730. package/dist/relations-B4w-G5U9.mjs.map +1 -0
  731. package/dist/relations-O63JWBRj.mjs +403 -0
  732. package/dist/relations-O63JWBRj.mjs.map +1 -0
  733. package/dist/request-cache-DaMhSQdx.mjs +104 -0
  734. package/dist/request-cache-DaMhSQdx.mjs.map +1 -0
  735. package/dist/request-context.d.mts +1 -1
  736. package/dist/request-meta-C8yl_sIs.mjs +141 -0
  737. package/dist/request-meta-C8yl_sIs.mjs.map +1 -0
  738. package/dist/resolve-BJIS8wKr.mjs +199 -0
  739. package/dist/resolve-BJIS8wKr.mjs.map +1 -0
  740. package/dist/route-wire-D66L2oaZ.mjs +197 -0
  741. package/dist/route-wire-D66L2oaZ.mjs.map +1 -0
  742. package/dist/routes-DYsTe-oR.mjs +321 -0
  743. package/dist/routes-DYsTe-oR.mjs.map +1 -0
  744. package/dist/runner-3gfxRsJG.d.mts +68 -0
  745. package/dist/runner-3gfxRsJG.d.mts.map +1 -0
  746. package/dist/runner-ClrleR8A.mjs +5502 -0
  747. package/dist/runner-ClrleR8A.mjs.map +1 -0
  748. package/dist/runtime.d.mts +13 -11
  749. package/dist/runtime.d.mts.map +1 -1
  750. package/dist/runtime.mjs +6 -6
  751. package/dist/schema-CPhPM9Do.mjs +420 -0
  752. package/dist/schema-CPhPM9Do.mjs.map +1 -0
  753. package/dist/schema-DEERRrKS.mjs +9 -0
  754. package/dist/schema-DEERRrKS.mjs.map +1 -0
  755. package/dist/scopes-Bn8_rCSt.mjs +27 -0
  756. package/dist/scopes-Bn8_rCSt.mjs.map +1 -0
  757. package/dist/search-lami_Ota.mjs +448 -0
  758. package/dist/search-lami_Ota.mjs.map +1 -0
  759. package/dist/secrets-DNgVgz_e.mjs +341 -0
  760. package/dist/secrets-DNgVgz_e.mjs.map +1 -0
  761. package/dist/sections-BIpd4Cxf.mjs +346 -0
  762. package/dist/sections-BIpd4Cxf.mjs.map +1 -0
  763. package/dist/seed/index.d.mts +2 -2
  764. package/dist/seed/index.mjs +35 -33
  765. package/dist/seo/index.d.mts +3 -3
  766. package/dist/seo/index.mjs +26 -24
  767. package/dist/seo/index.mjs.map +1 -1
  768. package/dist/seo-BtU70b7l.mjs +114 -0
  769. package/dist/seo-BtU70b7l.mjs.map +1 -0
  770. package/dist/seo-_4qmazxz.mjs +133 -0
  771. package/dist/seo-_4qmazxz.mjs.map +1 -0
  772. package/dist/service-Bpy5iTX0.mjs +150 -0
  773. package/dist/service-Bpy5iTX0.mjs.map +1 -0
  774. package/dist/session-user-BQeS2Mrb.mjs +51 -0
  775. package/dist/session-user-BQeS2Mrb.mjs.map +1 -0
  776. package/dist/settings-DmroR53o.mjs +420 -0
  777. package/dist/settings-DmroR53o.mjs.map +1 -0
  778. package/dist/settings-g2F2a3Ub.mjs +51 -0
  779. package/dist/settings-g2F2a3Ub.mjs.map +1 -0
  780. package/dist/setup-complete-BrZaXpVV.mjs +26 -0
  781. package/dist/setup-complete-BrZaXpVV.mjs.map +1 -0
  782. package/dist/setup-nonce-Cb9-884O.mjs +25 -0
  783. package/dist/setup-nonce-Cb9-884O.mjs.map +1 -0
  784. package/dist/single-flight-cache-B5O2qhO1.mjs +104 -0
  785. package/dist/single-flight-cache-B5O2qhO1.mjs.map +1 -0
  786. package/dist/site-url-DjhYCaep.mjs +16 -0
  787. package/dist/site-url-DjhYCaep.mjs.map +1 -0
  788. package/dist/slugify-T5GHH42D.mjs +17 -0
  789. package/dist/slugify-T5GHH42D.mjs.map +1 -0
  790. package/dist/snapshot-C32Xuv3o.mjs +233 -0
  791. package/dist/snapshot-C32Xuv3o.mjs.map +1 -0
  792. package/dist/ssrf-Co1GGFZz.mjs +406 -0
  793. package/dist/ssrf-Co1GGFZz.mjs.map +1 -0
  794. package/dist/state-C7gCoiHr.mjs +153 -0
  795. package/dist/state-C7gCoiHr.mjs.map +1 -0
  796. package/dist/status-DLoBmcDz.mjs +30 -0
  797. package/dist/status-DLoBmcDz.mjs.map +1 -0
  798. package/dist/storage/local.d.mts +1 -1
  799. package/dist/storage/local.mjs +1 -1
  800. package/dist/storage/s3.d.mts +1 -1
  801. package/dist/storage/s3.mjs +1 -1
  802. package/dist/storage-query-CPctdMKX.d.mts +1519 -0
  803. package/dist/storage-query-CPctdMKX.d.mts.map +1 -0
  804. package/dist/target-CUKlGrXb.mjs +27 -0
  805. package/dist/target-CUKlGrXb.mjs.map +1 -0
  806. package/dist/taxonomies-BpqpXJUE.mjs +707 -0
  807. package/dist/taxonomies-BpqpXJUE.mjs.map +1 -0
  808. package/dist/taxonomies-ClCo4IGO.mjs +899 -0
  809. package/dist/taxonomies-ClCo4IGO.mjs.map +1 -0
  810. package/dist/taxonomy-Dj1vpw5E.mjs +508 -0
  811. package/dist/taxonomy-Dj1vpw5E.mjs.map +1 -0
  812. package/dist/tokens-Ns02GAma.mjs +171 -0
  813. package/dist/tokens-Ns02GAma.mjs.map +1 -0
  814. package/dist/transaction-BcJO4Tmc.mjs +29 -0
  815. package/dist/transaction-BcJO4Tmc.mjs.map +1 -0
  816. package/dist/transport-B8P1xsqk.mjs +136 -0
  817. package/dist/transport-B8P1xsqk.mjs.map +1 -0
  818. package/dist/transport-BLHZZcD_.d.mts +42 -0
  819. package/dist/transport-BLHZZcD_.d.mts.map +1 -0
  820. package/dist/trusted-proxy-Cg7SuD15.mjs +51 -0
  821. package/dist/trusted-proxy-Cg7SuD15.mjs.map +1 -0
  822. package/dist/turnstile-DWCSh_Qc.mjs +53 -0
  823. package/dist/turnstile-DWCSh_Qc.mjs.map +1 -0
  824. package/dist/types-B3RkqvDW.mjs +156 -0
  825. package/dist/types-B3RkqvDW.mjs.map +1 -0
  826. package/dist/types-BkUg2yHx.mjs +92 -0
  827. package/dist/types-BkUg2yHx.mjs.map +1 -0
  828. package/dist/types-BtuppOTV.mjs +16 -0
  829. package/dist/types-BtuppOTV.mjs.map +1 -0
  830. package/dist/types-CCR3ivXE.d.mts +363 -0
  831. package/dist/types-CCR3ivXE.d.mts.map +1 -0
  832. package/dist/types-CSHgU_-_.mjs +18 -0
  833. package/dist/types-CSHgU_-_.mjs.map +1 -0
  834. package/dist/types-CbwqGOXm.d.mts +766 -0
  835. package/dist/types-CbwqGOXm.d.mts.map +1 -0
  836. package/dist/types-D4RGIc2I.d.mts +198 -0
  837. package/dist/types-D4RGIc2I.d.mts.map +1 -0
  838. package/dist/types-DEHidMEk.d.mts +1637 -0
  839. package/dist/types-DEHidMEk.d.mts.map +1 -0
  840. package/dist/types-DQeU2SR7.d.mts +279 -0
  841. package/dist/types-DQeU2SR7.d.mts.map +1 -0
  842. package/dist/types-DxQWoQLA.d.mts +264 -0
  843. package/dist/types-DxQWoQLA.d.mts.map +1 -0
  844. package/dist/types-FBBnGZ2Y.d.mts +198 -0
  845. package/dist/types-FBBnGZ2Y.d.mts.map +1 -0
  846. package/dist/types-ZCnlropY.mjs +69 -0
  847. package/dist/types-ZCnlropY.mjs.map +1 -0
  848. package/dist/types-_Qtyawiy.d.mts +124 -0
  849. package/dist/types-_Qtyawiy.d.mts.map +1 -0
  850. package/dist/types-gC6FAoa_.d.mts +75 -0
  851. package/dist/types-gC6FAoa_.d.mts.map +1 -0
  852. package/dist/types-k--LneIF.mjs +22 -0
  853. package/dist/types-k--LneIF.mjs.map +1 -0
  854. package/dist/upload-attempts-2xdnoKGe.mjs +27 -0
  855. package/dist/upload-attempts-2xdnoKGe.mjs.map +1 -0
  856. package/dist/url-pattern-3m3reMzr.mjs +33 -0
  857. package/dist/url-pattern-3m3reMzr.mjs.map +1 -0
  858. package/dist/user-DroRntkx.mjs +171 -0
  859. package/dist/user-DroRntkx.mjs.map +1 -0
  860. package/dist/utils-CC2oNGV8.mjs +435 -0
  861. package/dist/utils-CC2oNGV8.mjs.map +1 -0
  862. package/dist/validate-BCP9HNDn.mjs +384 -0
  863. package/dist/validate-BCP9HNDn.mjs.map +1 -0
  864. package/dist/validate-CyQ7I3xF.d.mts +410 -0
  865. package/dist/validate-CyQ7I3xF.d.mts.map +1 -0
  866. package/dist/validate-DANX1-Qi.mjs +120 -0
  867. package/dist/validate-DANX1-Qi.mjs.map +1 -0
  868. package/dist/validation-DBy6WF94.mjs +216 -0
  869. package/dist/validation-DBy6WF94.mjs.map +1 -0
  870. package/dist/version-B57E4Uo7.mjs +7 -0
  871. package/dist/version-B57E4Uo7.mjs.map +1 -0
  872. package/dist/widgets-wQ7Xcgq8.mjs +126 -0
  873. package/dist/widgets-wQ7Xcgq8.mjs.map +1 -0
  874. package/dist/wxr-taxonomies-DIHfvEDt.mjs +406 -0
  875. package/dist/wxr-taxonomies-DIHfvEDt.mjs.map +1 -0
  876. package/dist/wxr-taxonomies-DU2ZSiGc.d.mts +34 -0
  877. package/dist/wxr-taxonomies-DU2ZSiGc.d.mts.map +1 -0
  878. package/dist/zod-generator-D_yHIWfs.mjs +329 -0
  879. package/dist/zod-generator-D_yHIWfs.mjs.map +1 -0
  880. package/package.json +36 -11
  881. package/src/api/errors.ts +16 -0
  882. package/src/api/handlers/backup.ts +11 -5
  883. package/src/api/handlers/content.ts +160 -6
  884. package/src/api/handlers/dashboard.ts +31 -1
  885. package/src/api/handlers/index.ts +3 -0
  886. package/src/api/handlers/manifest.ts +4 -6
  887. package/src/api/handlers/marketplace.ts +99 -15
  888. package/src/api/handlers/media-upload.ts +31 -4
  889. package/src/api/handlers/plugin-settings.ts +35 -3
  890. package/src/api/handlers/redirects.ts +221 -138
  891. package/src/api/handlers/registry.ts +62 -21
  892. package/src/api/handlers/revision.ts +14 -26
  893. package/src/api/handlers/snapshot.ts +4 -1
  894. package/src/api/handlers/taxonomies.ts +70 -5
  895. package/src/api/handlers/validation.ts +120 -19
  896. package/src/api/openapi/document.ts +34 -17
  897. package/src/api/schemas/content.ts +26 -14
  898. package/src/api/schemas/entry-lock.ts +9 -0
  899. package/src/api/schemas/search.ts +4 -0
  900. package/src/api/types.ts +2 -0
  901. package/src/astro/integration/index.ts +16 -3
  902. package/src/astro/integration/routes.ts +84 -0
  903. package/src/astro/integration/runtime.ts +31 -23
  904. package/src/astro/integration/virtual-modules.ts +4 -0
  905. package/src/astro/integration/vite-config.ts +1 -0
  906. package/src/astro/middleware/auth.ts +25 -4
  907. package/src/astro/middleware/request-context.ts +28 -10
  908. package/src/astro/middleware.ts +17 -1
  909. package/src/astro/prefetch.ts +2 -2
  910. package/src/astro/routes/api/admin/comments/[id]/status.ts +22 -58
  911. package/src/astro/routes/api/admin/plugins/[id]/disable.ts +2 -15
  912. package/src/astro/routes/api/admin/plugins/[id]/enable.ts +2 -25
  913. package/src/astro/routes/api/admin/plugins/[id]/uninstall.ts +1 -0
  914. package/src/astro/routes/api/admin/plugins/[id]/update.ts +23 -4
  915. package/src/astro/routes/api/admin/plugins/marketplace/[id]/install.ts +12 -2
  916. package/src/astro/routes/api/admin/plugins/registry/[id]/uninstall.ts +1 -0
  917. package/src/astro/routes/api/admin/plugins/registry/[id]/update.ts +29 -10
  918. package/src/astro/routes/api/admin/plugins/registry/artifact.ts +8 -2
  919. package/src/astro/routes/api/admin/plugins/registry/install.ts +15 -4
  920. package/src/astro/routes/api/admin/plugins/registry/verify.ts +2 -1
  921. package/src/astro/routes/api/admin/plugins/updates.ts +6 -1
  922. package/src/astro/routes/api/admin/scheduled-policy-rejections/[collection]/[id].ts +34 -0
  923. package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +4 -259
  924. package/src/astro/routes/api/content/[collection]/[id]/plugin-extensions/[pluginId]/[kind]/[extensionId].ts +29 -0
  925. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +10 -3
  926. package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +10 -1
  927. package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +5 -1
  928. package/src/astro/routes/api/health.ts +23 -0
  929. package/src/astro/routes/api/manifest.ts +14 -4
  930. package/src/astro/routes/api/mcp.ts +2 -1
  931. package/src/astro/routes/api/media/asset/[id]/[filename].ts +50 -0
  932. package/src/astro/routes/api/plugins/[pluginId]/[...path].ts +13 -81
  933. package/src/astro/routes/api/redirects/[id].ts +0 -3
  934. package/src/astro/routes/api/redirects/index.ts +0 -2
  935. package/src/astro/routes/api/search/index.ts +1 -0
  936. package/src/astro/routes/api/visual-editing/action-token.ts +36 -0
  937. package/src/astro/routes/api/visual-editing/content/[collection]/[id]/publish.ts +32 -0
  938. package/src/astro/routes/api/visual-editing/toolbar-labels.ts +16 -0
  939. package/src/astro/routes/sitemap-[collection].xml.ts +7 -4
  940. package/src/astro/types.ts +70 -9
  941. package/src/cli/commands/bundle-utils.ts +19 -19
  942. package/src/cli/commands/bundle.ts +9 -6
  943. package/src/cli/commands/content.ts +1 -1
  944. package/src/cli/commands/doctor.ts +25 -0
  945. package/src/cli/commands/export-seed.ts +193 -56
  946. package/src/cli/commands/migrate.ts +71 -23
  947. package/src/cli/commands/publish.ts +2 -2
  948. package/src/comments/public-submission.ts +246 -0
  949. package/src/comments/service.ts +59 -12
  950. package/src/components/EmDashHead.astro +1 -0
  951. package/src/components/widgets/Archives.astro +6 -5
  952. package/src/config/secrets.ts +25 -11
  953. package/src/content/known-fields.ts +44 -0
  954. package/src/database/connection.ts +5 -1
  955. package/src/database/content-datetime.ts +123 -0
  956. package/src/database/datetime-storage.ts +452 -0
  957. package/src/database/dialect-helpers.ts +36 -1
  958. package/src/database/migration-lock.ts +140 -0
  959. package/src/database/migrations/078_menu_item_translation_groups.ts +15 -0
  960. package/src/database/migrations/079_datetime_normalization.ts +13 -0
  961. package/src/database/migrations/080_content_translation_locale_unique.ts +88 -0
  962. package/src/database/migrations/081_redirect_write_guards.ts +257 -0
  963. package/src/database/migrations/082_taxonomy_translation_locale_unique.ts +49 -0
  964. package/src/database/migrations/runner.ts +57 -15
  965. package/src/database/pg-migration-lock.ts +2 -2
  966. package/src/database/repositories/byline.ts +9 -0
  967. package/src/database/repositories/comment.ts +86 -0
  968. package/src/database/repositories/content.ts +391 -69
  969. package/src/database/repositories/media.ts +35 -4
  970. package/src/database/repositories/menu.ts +1 -0
  971. package/src/database/repositories/options.ts +46 -4
  972. package/src/database/repositories/redirect.ts +259 -64
  973. package/src/database/repositories/revision.ts +116 -17
  974. package/src/database/repositories/taxonomy.ts +34 -0
  975. package/src/database/repositories/types.ts +2 -0
  976. package/src/database/types.ts +11 -0
  977. package/src/datetime-normalization.ts +311 -0
  978. package/src/db/node-sqlite-compat.ts +3 -2
  979. package/src/emdash-runtime.ts +1925 -422
  980. package/src/fields/image.ts +2 -0
  981. package/src/i18n/config.ts +6 -6
  982. package/src/i18n/resolve.ts +54 -11
  983. package/src/index.ts +87 -0
  984. package/src/loader.ts +14 -0
  985. package/src/mcp/server.ts +194 -64
  986. package/src/media/usage/extractor.ts +50 -15
  987. package/src/media/usage/types.ts +1 -1
  988. package/src/menus/index.ts +49 -16
  989. package/src/migrations/direct-executor.ts +40 -2
  990. package/src/migrations/index.ts +1 -0
  991. package/src/migrations/protocol.ts +11 -1
  992. package/src/plugin-test-runtime.ts +17 -0
  993. package/src/plugin-types.ts +119 -21
  994. package/src/plugins/adapt-sandbox-entry.ts +34 -27
  995. package/src/plugins/content-access.ts +170 -0
  996. package/src/plugins/content-policy.ts +74 -0
  997. package/src/plugins/context.ts +742 -150
  998. package/src/plugins/cron.ts +18 -10
  999. package/src/plugins/define-plugin.ts +55 -54
  1000. package/src/plugins/editor-draft.ts +257 -0
  1001. package/src/plugins/hooks.ts +129 -2
  1002. package/src/plugins/host.ts +29 -0
  1003. package/src/plugins/http-route-dispatch.ts +389 -0
  1004. package/src/plugins/http-wire.ts +180 -0
  1005. package/src/plugins/index.ts +88 -3
  1006. package/src/plugins/install-finalization.ts +77 -0
  1007. package/src/plugins/lifecycle.ts +47 -0
  1008. package/src/plugins/manifest-schema.ts +314 -58
  1009. package/src/plugins/media.ts +166 -0
  1010. package/src/plugins/request-meta.ts +12 -2
  1011. package/src/plugins/route-wire.ts +304 -0
  1012. package/src/plugins/routes.ts +38 -5
  1013. package/src/plugins/sandbox/index.ts +4 -0
  1014. package/src/plugins/sandbox/proxy.ts +129 -0
  1015. package/src/plugins/sandbox/types.ts +67 -5
  1016. package/src/plugins/secret-redactor.ts +65 -0
  1017. package/src/plugins/settings.ts +303 -0
  1018. package/src/plugins/state.ts +26 -0
  1019. package/src/plugins/types.ts +488 -15
  1020. package/src/query.ts +55 -1
  1021. package/src/registry/authoritative-records.ts +26 -0
  1022. package/src/registry/config.ts +70 -22
  1023. package/src/registry/testing.ts +100 -0
  1024. package/src/registry/types.ts +7 -64
  1025. package/src/scheduled-publish.ts +70 -3
  1026. package/src/schema/index.ts +1 -0
  1027. package/src/schema/registry.ts +45 -1
  1028. package/src/schema/types.ts +7 -0
  1029. package/src/schema/zod-generator.ts +5 -13
  1030. package/src/search/fts-manager.ts +3 -3
  1031. package/src/search/query.ts +32 -5
  1032. package/src/search/types.ts +8 -0
  1033. package/src/seed/apply.ts +37 -3
  1034. package/src/seed/types.ts +6 -1
  1035. package/src/seo/hreflang.ts +9 -6
  1036. package/src/settings/index.ts +53 -11
  1037. package/src/visual-editing/action-token.ts +31 -0
  1038. package/src/visual-editing/toolbar-bootstrap.ts +31 -6
  1039. package/src/visual-editing/toolbar.ts +103 -12
  1040. package/src/widgets/archives.ts +10 -9
  1041. package/src/widgets/index.ts +11 -1
  1042. package/dist/activation-DyNTe_Tl.mjs +0 -382
  1043. package/dist/activation-DyNTe_Tl.mjs.map +0 -1
  1044. package/dist/adapters-DCEgOBXi.d.mts +0 -171
  1045. package/dist/adapters-DCEgOBXi.d.mts.map +0 -1
  1046. package/dist/after-CBU2vkoO.mjs +0 -96
  1047. package/dist/after-CBU2vkoO.mjs.map +0 -1
  1048. package/dist/allowed-origins-GFUVavRj.mjs +0 -116
  1049. package/dist/allowed-origins-GFUVavRj.mjs.map +0 -1
  1050. package/dist/api-BvxJmnFY.mjs +0 -10094
  1051. package/dist/api-BvxJmnFY.mjs.map +0 -1
  1052. package/dist/api-tokens-xpGqMHrC.mjs +0 -163
  1053. package/dist/api-tokens-xpGqMHrC.mjs.map +0 -1
  1054. package/dist/apply-DLmM3R7f.mjs +0 -984
  1055. package/dist/apply-DLmM3R7f.mjs.map +0 -1
  1056. package/dist/artifact-fetch-P2JXVwOq.mjs +0 -972
  1057. package/dist/artifact-fetch-P2JXVwOq.mjs.map +0 -1
  1058. package/dist/authorize-C2QHlWSS.mjs +0 -40
  1059. package/dist/authorize-C2QHlWSS.mjs.map +0 -1
  1060. package/dist/backup-oS8ft5Cm.mjs +0 -241
  1061. package/dist/backup-oS8ft5Cm.mjs.map +0 -1
  1062. package/dist/base64-CvLhUKQv.mjs +0 -63
  1063. package/dist/base64-CvLhUKQv.mjs.map +0 -1
  1064. package/dist/bundle-CL0JjIPx.mjs +0 -663
  1065. package/dist/bundle-CL0JjIPx.mjs.map +0 -1
  1066. package/dist/byline-Vdi85CsZ.mjs +0 -902
  1067. package/dist/byline-Vdi85CsZ.mjs.map +0 -1
  1068. package/dist/byline-fields-DPVRFMz2.mjs +0 -123
  1069. package/dist/byline-fields-DPVRFMz2.mjs.map +0 -1
  1070. package/dist/byline-registry-BxDGIO0I.mjs +0 -406
  1071. package/dist/byline-registry-BxDGIO0I.mjs.map +0 -1
  1072. package/dist/bylines-BX8QhcTk.mjs +0 -232
  1073. package/dist/bylines-BX8QhcTk.mjs.map +0 -1
  1074. package/dist/bylines-w-E1IEQd.mjs +0 -214
  1075. package/dist/bylines-w-E1IEQd.mjs.map +0 -1
  1076. package/dist/cache--7HKu5Xm.mjs +0 -108
  1077. package/dist/cache--7HKu5Xm.mjs.map +0 -1
  1078. package/dist/capture-triggers-CeAsC76Z.mjs +0 -362
  1079. package/dist/capture-triggers-CeAsC76Z.mjs.map +0 -1
  1080. package/dist/challenge-store-BIOak-tp.mjs +0 -51
  1081. package/dist/challenge-store-BIOak-tp.mjs.map +0 -1
  1082. package/dist/chrome-tags-DzDQBCjX.mjs +0 -24
  1083. package/dist/chrome-tags-DzDQBCjX.mjs.map +0 -1
  1084. package/dist/chunks-VG_tyqnP.mjs +0 -25
  1085. package/dist/chunks-VG_tyqnP.mjs.map +0 -1
  1086. package/dist/collection-deletion-BCwaWTDw.mjs +0 -436
  1087. package/dist/collection-deletion-BCwaWTDw.mjs.map +0 -1
  1088. package/dist/collection-slugs-cache-7lTmNzeA.mjs +0 -85
  1089. package/dist/collection-slugs-cache-7lTmNzeA.mjs.map +0 -1
  1090. package/dist/comment-reaction-CDyvPQRj.mjs +0 -85
  1091. package/dist/comment-reaction-CDyvPQRj.mjs.map +0 -1
  1092. package/dist/comment-vxOzWbZN.mjs +0 -255
  1093. package/dist/comment-vxOzWbZN.mjs.map +0 -1
  1094. package/dist/comments-VzmVLyaC.mjs +0 -204
  1095. package/dist/comments-VzmVLyaC.mjs.map +0 -1
  1096. package/dist/components-CL6Wkdk-.mjs +0 -108
  1097. package/dist/components-CL6Wkdk-.mjs.map +0 -1
  1098. package/dist/config--eWjQJE5.mjs +0 -217
  1099. package/dist/config--eWjQJE5.mjs.map +0 -1
  1100. package/dist/config-C3EBstHi.mjs +0 -72
  1101. package/dist/config-C3EBstHi.mjs.map +0 -1
  1102. package/dist/config-CGAhyOjP.d.mts +0 -6653
  1103. package/dist/config-CGAhyOjP.d.mts.map +0 -1
  1104. package/dist/config-ChFzshGd.d.mts +0 -34
  1105. package/dist/config-ChFzshGd.d.mts.map +0 -1
  1106. package/dist/content-CNfMWuhY.mjs +0 -1841
  1107. package/dist/content-CNfMWuhY.mjs.map +0 -1
  1108. package/dist/content-list-query-B8d4UQp9.d.mts +0 -26
  1109. package/dist/content-list-query-B8d4UQp9.d.mts.map +0 -1
  1110. package/dist/content-refresh-GTMyi2Xy.mjs +0 -3588
  1111. package/dist/content-refresh-GTMyi2Xy.mjs.map +0 -1
  1112. package/dist/content-repair-CIMt5C0U.mjs +0 -440
  1113. package/dist/content-repair-CIMt5C0U.mjs.map +0 -1
  1114. package/dist/context-C9PB8vGd.mjs +0 -1308
  1115. package/dist/context-C9PB8vGd.mjs.map +0 -1
  1116. package/dist/cron-DHAy9oyq.mjs +0 -277
  1117. package/dist/cron-DHAy9oyq.mjs.map +0 -1
  1118. package/dist/dashboard-BNSvAN8A.mjs +0 -140
  1119. package/dist/dashboard-BNSvAN8A.mjs.map +0 -1
  1120. package/dist/db-errors-Cl-sKYTm.mjs +0 -55
  1121. package/dist/db-errors-Cl-sKYTm.mjs.map +0 -1
  1122. package/dist/default-ByZ0JqZo.mjs +0 -81
  1123. package/dist/default-ByZ0JqZo.mjs.map +0 -1
  1124. package/dist/deferred-tasks-Cu4NSJpa.d.mts +0 -9
  1125. package/dist/deferred-tasks-Cu4NSJpa.d.mts.map +0 -1
  1126. package/dist/dev-typegen-DHT7lcMU.mjs +0 -29
  1127. package/dist/dev-typegen-DHT7lcMU.mjs.map +0 -1
  1128. package/dist/device-flow-Cf6bhCCT.mjs +0 -466
  1129. package/dist/device-flow-Cf6bhCCT.mjs.map +0 -1
  1130. package/dist/dialect-helpers-BcQvkHgn.mjs +0 -283
  1131. package/dist/dialect-helpers-BcQvkHgn.mjs.map +0 -1
  1132. package/dist/direct-executor-yAyUGSqB.mjs +0 -85
  1133. package/dist/direct-executor-yAyUGSqB.mjs.map +0 -1
  1134. package/dist/dist-BAsh8dbf.mjs +0 -810
  1135. package/dist/dist-BAsh8dbf.mjs.map +0 -1
  1136. package/dist/email-console-DNup1Fku.mjs +0 -50
  1137. package/dist/email-console-DNup1Fku.mjs.map +0 -1
  1138. package/dist/enrich-t2Xvjdqa.mjs +0 -194
  1139. package/dist/enrich-t2Xvjdqa.mjs.map +0 -1
  1140. package/dist/entry-lock-BEr8gDkG.mjs +0 -163
  1141. package/dist/entry-lock-BEr8gDkG.mjs.map +0 -1
  1142. package/dist/entry-lock-CGAtrwAR.d.mts +0 -3409
  1143. package/dist/entry-lock-CGAtrwAR.d.mts.map +0 -1
  1144. package/dist/entry-lock-DIYHAaSw.mjs +0 -1281
  1145. package/dist/entry-lock-DIYHAaSw.mjs.map +0 -1
  1146. package/dist/entry-locks-BEcX7ET0.mjs +0 -167
  1147. package/dist/entry-locks-BEcX7ET0.mjs.map +0 -1
  1148. package/dist/error-BDcFyoRt.mjs +0 -90
  1149. package/dist/error-BDcFyoRt.mjs.map +0 -1
  1150. package/dist/errors-DvMdNrgf.mjs +0 -434
  1151. package/dist/errors-DvMdNrgf.mjs.map +0 -1
  1152. package/dist/escape-B3asJC6W.mjs +0 -9
  1153. package/dist/escape-B3asJC6W.mjs.map +0 -1
  1154. package/dist/field-defs-cache-Cf5FHK0M.mjs +0 -77
  1155. package/dist/field-defs-cache-Cf5FHK0M.mjs.map +0 -1
  1156. package/dist/focal-point-BeWFo6Xx.mjs +0 -23
  1157. package/dist/focal-point-BeWFo6Xx.mjs.map +0 -1
  1158. package/dist/fts-manager-iddym8cd.mjs +0 -413
  1159. package/dist/fts-manager-iddym8cd.mjs.map +0 -1
  1160. package/dist/hash-BRweX6jz.mjs +0 -37
  1161. package/dist/hash-BRweX6jz.mjs.map +0 -1
  1162. package/dist/hook-result-BrshYHLx.d.mts +0 -31
  1163. package/dist/hook-result-BrshYHLx.d.mts.map +0 -1
  1164. package/dist/hreflang-CQpu5bMy.d.mts +0 -48
  1165. package/dist/hreflang-CQpu5bMy.d.mts.map +0 -1
  1166. package/dist/hreflang-DshnweTC.mjs +0 -103
  1167. package/dist/hreflang-DshnweTC.mjs.map +0 -1
  1168. package/dist/identity-CjGKDq8J.mjs +0 -35
  1169. package/dist/identity-CjGKDq8J.mjs.map +0 -1
  1170. package/dist/import-D96g2otw.mjs +0 -2020
  1171. package/dist/import-D96g2otw.mjs.map +0 -1
  1172. package/dist/index-1ECYpfiF.d.mts +0 -278
  1173. package/dist/index-1ECYpfiF.d.mts.map +0 -1
  1174. package/dist/init-lock-CFNBe_iH.mjs +0 -56
  1175. package/dist/init-lock-CFNBe_iH.mjs.map +0 -1
  1176. package/dist/load-DPtY9cZo.mjs +0 -28
  1177. package/dist/load-DPtY9cZo.mjs.map +0 -1
  1178. package/dist/loader-WJi6GFRn.mjs +0 -1004
  1179. package/dist/loader-WJi6GFRn.mjs.map +0 -1
  1180. package/dist/manifest-builder-BfNlGQIA.mjs +0 -189
  1181. package/dist/manifest-builder-BfNlGQIA.mjs.map +0 -1
  1182. package/dist/manifest-schema-CILooI5J.mjs +0 -301
  1183. package/dist/manifest-schema-CILooI5J.mjs.map +0 -1
  1184. package/dist/media-BBm8Wg3f.mjs +0 -318
  1185. package/dist/media-BBm8Wg3f.mjs.map +0 -1
  1186. package/dist/media-C1EIZKh1.mjs +0 -464
  1187. package/dist/media-C1EIZKh1.mjs.map +0 -1
  1188. package/dist/media-allowlist-elXJgb_K.mjs +0 -44
  1189. package/dist/media-allowlist-elXJgb_K.mjs.map +0 -1
  1190. package/dist/media-folders-DASfX_DH.mjs +0 -210
  1191. package/dist/media-folders-DASfX_DH.mjs.map +0 -1
  1192. package/dist/media-upload-C7_AQJ5v.mjs +0 -147
  1193. package/dist/media-upload-C7_AQJ5v.mjs.map +0 -1
  1194. package/dist/media-url-8dVl1loq.mjs +0 -43
  1195. package/dist/media-url-8dVl1loq.mjs.map +0 -1
  1196. package/dist/media-usage-C1EswMTq.mjs +0 -1833
  1197. package/dist/media-usage-C1EswMTq.mjs.map +0 -1
  1198. package/dist/media-usage-activation-CrHNltlL.mjs +0 -78
  1199. package/dist/media-usage-activation-CrHNltlL.mjs.map +0 -1
  1200. package/dist/media-usage-work-C5B1zT1c.mjs +0 -586
  1201. package/dist/media-usage-work-C5B1zT1c.mjs.map +0 -1
  1202. package/dist/media-usage-work-IkQx_Yz6.mjs +0 -152
  1203. package/dist/media-usage-work-IkQx_Yz6.mjs.map +0 -1
  1204. package/dist/media-usage-write-fence-B9anjOSg.mjs +0 -42
  1205. package/dist/media-usage-write-fence-B9anjOSg.mjs.map +0 -1
  1206. package/dist/menus-D8mC4eaN.mjs +0 -3989
  1207. package/dist/menus-D8mC4eaN.mjs.map +0 -1
  1208. package/dist/menus-UdwjHZJC.mjs +0 -752
  1209. package/dist/menus-UdwjHZJC.mjs.map +0 -1
  1210. package/dist/mime-DYpsOAny.mjs +0 -36
  1211. package/dist/mime-DYpsOAny.mjs.map +0 -1
  1212. package/dist/mode-Dm4BHhRH.mjs +0 -23
  1213. package/dist/mode-Dm4BHhRH.mjs.map +0 -1
  1214. package/dist/node-sqlite-compat-2sezm-Zd.mjs +0 -46
  1215. package/dist/node-sqlite-compat-2sezm-Zd.mjs.map +0 -1
  1216. package/dist/normalize-4nkKGsuW.mjs +0 -191
  1217. package/dist/normalize-4nkKGsuW.mjs.map +0 -1
  1218. package/dist/oauth-authorization-BxE_lURD.mjs +0 -274
  1219. package/dist/oauth-authorization-BxE_lURD.mjs.map +0 -1
  1220. package/dist/oauth-clients-DJIdOdq0.mjs +0 -266
  1221. package/dist/oauth-clients-DJIdOdq0.mjs.map +0 -1
  1222. package/dist/oauth-state-store-CsdxP57n.mjs +0 -50
  1223. package/dist/oauth-state-store-CsdxP57n.mjs.map +0 -1
  1224. package/dist/oauth-user-lookup-HzzW-dkF.mjs +0 -26
  1225. package/dist/oauth-user-lookup-HzzW-dkF.mjs.map +0 -1
  1226. package/dist/object-cache-DVKnyOfy.mjs +0 -534
  1227. package/dist/object-cache-DVKnyOfy.mjs.map +0 -1
  1228. package/dist/options-D1FBiAv1.mjs +0 -172
  1229. package/dist/options-D1FBiAv1.mjs.map +0 -1
  1230. package/dist/options-D8Y0VHc7.d.mts +0 -227
  1231. package/dist/options-D8Y0VHc7.d.mts.map +0 -1
  1232. package/dist/parse-WRg5C3NX.mjs +0 -81
  1233. package/dist/parse-WRg5C3NX.mjs.map +0 -1
  1234. package/dist/passkey-config-qIdO-wF6.mjs +0 -46
  1235. package/dist/passkey-config-qIdO-wF6.mjs.map +0 -1
  1236. package/dist/patterns-DC8CLptu.mjs +0 -145
  1237. package/dist/patterns-DC8CLptu.mjs.map +0 -1
  1238. package/dist/placeholder-COrvARyD.d.mts +0 -306
  1239. package/dist/placeholder-COrvARyD.d.mts.map +0 -1
  1240. package/dist/policy-XCfb-IE9.mjs +0 -45
  1241. package/dist/policy-XCfb-IE9.mjs.map +0 -1
  1242. package/dist/portable-text-BS3d5n-0.mjs +0 -286
  1243. package/dist/portable-text-BS3d5n-0.mjs.map +0 -1
  1244. package/dist/preview-BxwsGgGp.mjs +0 -107
  1245. package/dist/preview-BxwsGgGp.mjs.map +0 -1
  1246. package/dist/protocol-CLn58-nw.d.mts +0 -52
  1247. package/dist/protocol-CLn58-nw.d.mts.map +0 -1
  1248. package/dist/public-url-FWWAvnre.mjs +0 -101
  1249. package/dist/public-url-FWWAvnre.mjs.map +0 -1
  1250. package/dist/query-DygOte9M.mjs +0 -890
  1251. package/dist/query-DygOte9M.mjs.map +0 -1
  1252. package/dist/query-gtXT03Wc.mjs +0 -41
  1253. package/dist/query-gtXT03Wc.mjs.map +0 -1
  1254. package/dist/rate-limit-CQUPm0dh.mjs +0 -120
  1255. package/dist/rate-limit-CQUPm0dh.mjs.map +0 -1
  1256. package/dist/redirect-D1cWafi6.mjs +0 -17
  1257. package/dist/redirect-D1cWafi6.mjs.map +0 -1
  1258. package/dist/redirect-DId44BS1.mjs +0 -326
  1259. package/dist/redirect-DId44BS1.mjs.map +0 -1
  1260. package/dist/redirects-DN-ZE33W.mjs +0 -579
  1261. package/dist/redirects-DN-ZE33W.mjs.map +0 -1
  1262. package/dist/registry-DTqaqxed.mjs +0 -1195
  1263. package/dist/registry-DTqaqxed.mjs.map +0 -1
  1264. package/dist/relation-DxgCHOBw.mjs +0 -334
  1265. package/dist/relation-DxgCHOBw.mjs.map +0 -1
  1266. package/dist/relations-KKDSLUwS.mjs +0 -403
  1267. package/dist/relations-KKDSLUwS.mjs.map +0 -1
  1268. package/dist/relations-rOmbndUJ.mjs +0 -309
  1269. package/dist/relations-rOmbndUJ.mjs.map +0 -1
  1270. package/dist/request-cache-DAZZmesc.mjs +0 -104
  1271. package/dist/request-cache-DAZZmesc.mjs.map +0 -1
  1272. package/dist/request-meta-BgjUQLQ-.mjs +0 -140
  1273. package/dist/request-meta-BgjUQLQ-.mjs.map +0 -1
  1274. package/dist/resolve-Cy0aWSRj.mjs +0 -176
  1275. package/dist/resolve-Cy0aWSRj.mjs.map +0 -1
  1276. package/dist/runner-CfwysRM0.d.mts +0 -67
  1277. package/dist/runner-CfwysRM0.d.mts.map +0 -1
  1278. package/dist/runner-nEzvnogG.mjs +0 -4800
  1279. package/dist/runner-nEzvnogG.mjs.map +0 -1
  1280. package/dist/schema-CRu38Pr5.mjs +0 -9
  1281. package/dist/schema-CRu38Pr5.mjs.map +0 -1
  1282. package/dist/schema-DifxndJx.mjs +0 -420
  1283. package/dist/schema-DifxndJx.mjs.map +0 -1
  1284. package/dist/scopes-D5A1OZbq.mjs +0 -27
  1285. package/dist/scopes-D5A1OZbq.mjs.map +0 -1
  1286. package/dist/search-DEPFSBFq.mjs +0 -439
  1287. package/dist/search-DEPFSBFq.mjs.map +0 -1
  1288. package/dist/secrets-CdfzLdoO.mjs +0 -330
  1289. package/dist/secrets-CdfzLdoO.mjs.map +0 -1
  1290. package/dist/sections-3X52kmIR.mjs +0 -346
  1291. package/dist/sections-3X52kmIR.mjs.map +0 -1
  1292. package/dist/seo-Bw68KxRc.mjs +0 -133
  1293. package/dist/seo-Bw68KxRc.mjs.map +0 -1
  1294. package/dist/seo-C4AmbsMU.mjs +0 -114
  1295. package/dist/seo-C4AmbsMU.mjs.map +0 -1
  1296. package/dist/service-J_-Vgo7R.mjs +0 -195
  1297. package/dist/service-J_-Vgo7R.mjs.map +0 -1
  1298. package/dist/session-user-CbnMMwk6.mjs +0 -51
  1299. package/dist/session-user-CbnMMwk6.mjs.map +0 -1
  1300. package/dist/settings-AnEFYICn.mjs +0 -51
  1301. package/dist/settings-AnEFYICn.mjs.map +0 -1
  1302. package/dist/settings-DcMjREe5.mjs +0 -258
  1303. package/dist/settings-DcMjREe5.mjs.map +0 -1
  1304. package/dist/setup-complete-BClXXTvr.mjs +0 -26
  1305. package/dist/setup-complete-BClXXTvr.mjs.map +0 -1
  1306. package/dist/setup-nonce-BheRa4RG.mjs +0 -25
  1307. package/dist/setup-nonce-BheRa4RG.mjs.map +0 -1
  1308. package/dist/single-flight-cache-jaswDzmQ.mjs +0 -104
  1309. package/dist/single-flight-cache-jaswDzmQ.mjs.map +0 -1
  1310. package/dist/site-url-Bqf-ea3N.mjs +0 -16
  1311. package/dist/site-url-Bqf-ea3N.mjs.map +0 -1
  1312. package/dist/slugify-B994zkXC.mjs +0 -17
  1313. package/dist/slugify-B994zkXC.mjs.map +0 -1
  1314. package/dist/snapshot-C4CtXntb.mjs +0 -232
  1315. package/dist/snapshot-C4CtXntb.mjs.map +0 -1
  1316. package/dist/ssrf-gl4gFNhw.mjs +0 -406
  1317. package/dist/ssrf-gl4gFNhw.mjs.map +0 -1
  1318. package/dist/state-1F6IOhdQ.mjs +0 -136
  1319. package/dist/state-1F6IOhdQ.mjs.map +0 -1
  1320. package/dist/status-Cenfk_r5.mjs +0 -30
  1321. package/dist/status-Cenfk_r5.mjs.map +0 -1
  1322. package/dist/target-CRzeTs8G.mjs +0 -27
  1323. package/dist/target-CRzeTs8G.mjs.map +0 -1
  1324. package/dist/taxonomies-BOdxuZpV.mjs +0 -844
  1325. package/dist/taxonomies-BOdxuZpV.mjs.map +0 -1
  1326. package/dist/taxonomies-NcFDq5Gg.mjs +0 -707
  1327. package/dist/taxonomies-NcFDq5Gg.mjs.map +0 -1
  1328. package/dist/taxonomy-DP1vny4K.mjs +0 -492
  1329. package/dist/taxonomy-DP1vny4K.mjs.map +0 -1
  1330. package/dist/tokens-CDk8ox9p.mjs +0 -171
  1331. package/dist/tokens-CDk8ox9p.mjs.map +0 -1
  1332. package/dist/transaction-0KOpOyMu.mjs +0 -29
  1333. package/dist/transaction-0KOpOyMu.mjs.map +0 -1
  1334. package/dist/transport-BVn4tVb9.d.mts +0 -42
  1335. package/dist/transport-BVn4tVb9.d.mts.map +0 -1
  1336. package/dist/transport-DP0JI-8i.mjs +0 -136
  1337. package/dist/transport-DP0JI-8i.mjs.map +0 -1
  1338. package/dist/trusted-proxy-BTM6UxqD.mjs +0 -51
  1339. package/dist/trusted-proxy-BTM6UxqD.mjs.map +0 -1
  1340. package/dist/types-2n848aVW.d.mts +0 -198
  1341. package/dist/types-2n848aVW.d.mts.map +0 -1
  1342. package/dist/types-A2cN6a4a.mjs +0 -3
  1343. package/dist/types-BMXnRIrX.mjs +0 -144
  1344. package/dist/types-BMXnRIrX.mjs.map +0 -1
  1345. package/dist/types-BouXpOsa.d.mts +0 -1446
  1346. package/dist/types-BouXpOsa.d.mts.map +0 -1
  1347. package/dist/types-ByG2coLw.mjs +0 -16
  1348. package/dist/types-ByG2coLw.mjs.map +0 -1
  1349. package/dist/types-CQPWhPxE.mjs +0 -92
  1350. package/dist/types-CQPWhPxE.mjs.map +0 -1
  1351. package/dist/types-DEfNJ__A.d.mts +0 -75
  1352. package/dist/types-DEfNJ__A.d.mts.map +0 -1
  1353. package/dist/types-DKcKSbtB.d.mts +0 -273
  1354. package/dist/types-DKcKSbtB.d.mts.map +0 -1
  1355. package/dist/types-DRYs7uTL.d.mts +0 -198
  1356. package/dist/types-DRYs7uTL.d.mts.map +0 -1
  1357. package/dist/types-DaEg7KX2.d.mts +0 -363
  1358. package/dist/types-DaEg7KX2.d.mts.map +0 -1
  1359. package/dist/types-LU8utpP_.d.mts +0 -262
  1360. package/dist/types-LU8utpP_.d.mts.map +0 -1
  1361. package/dist/types-VpYfPUxN.d.mts +0 -124
  1362. package/dist/types-VpYfPUxN.d.mts.map +0 -1
  1363. package/dist/types-c9GP7Dj5.mjs +0 -18
  1364. package/dist/types-c9GP7Dj5.mjs.map +0 -1
  1365. package/dist/types-tJWDK__M.d.mts +0 -756
  1366. package/dist/types-tJWDK__M.d.mts.map +0 -1
  1367. package/dist/upload-attempts-C6S2y-lp.mjs +0 -27
  1368. package/dist/upload-attempts-C6S2y-lp.mjs.map +0 -1
  1369. package/dist/url-pattern-UYtxVTuj.mjs +0 -33
  1370. package/dist/url-pattern-UYtxVTuj.mjs.map +0 -1
  1371. package/dist/user-DIsIXogT.mjs +0 -171
  1372. package/dist/user-DIsIXogT.mjs.map +0 -1
  1373. package/dist/utils-BicP5Qbg.mjs +0 -435
  1374. package/dist/utils-BicP5Qbg.mjs.map +0 -1
  1375. package/dist/validate-BpwoDOgt.mjs +0 -120
  1376. package/dist/validate-BpwoDOgt.mjs.map +0 -1
  1377. package/dist/validate-D8VPn4Hv.mjs +0 -384
  1378. package/dist/validate-D8VPn4Hv.mjs.map +0 -1
  1379. package/dist/validate-Df6Dvwbw.d.mts +0 -405
  1380. package/dist/validate-Df6Dvwbw.d.mts.map +0 -1
  1381. package/dist/validation-CzMJn9Ku.mjs +0 -155
  1382. package/dist/validation-CzMJn9Ku.mjs.map +0 -1
  1383. package/dist/version-CK67_SXX.mjs +0 -7
  1384. package/dist/version-CK67_SXX.mjs.map +0 -1
  1385. package/dist/widgets-RFVAxQl3.mjs +0 -122
  1386. package/dist/widgets-RFVAxQl3.mjs.map +0 -1
  1387. package/dist/wxr-taxonomies-BX4yQL9s.d.mts +0 -34
  1388. package/dist/wxr-taxonomies-BX4yQL9s.d.mts.map +0 -1
  1389. package/dist/wxr-taxonomies-Csdp7yde.mjs +0 -406
  1390. package/dist/wxr-taxonomies-Csdp7yde.mjs.map +0 -1
  1391. package/dist/zod-generator-CNRGdnBY.mjs +0 -331
  1392. package/dist/zod-generator-CNRGdnBY.mjs.map +0 -1
  1393. /package/dist/{api-tokens-B_lfpmH3.mjs → api-tokens-DS1VzN7_.mjs} +0 -0
  1394. /package/dist/{ssrf-TQhaljuI.mjs → ssrf-BRpTDMV6.mjs} +0 -0
@@ -7,16 +7,30 @@
7
7
  * Created once per worker lifetime, cached and reused across requests.
8
8
  */
9
9
 
10
+ import { getLocaleDir, resolveLocale } from "@emdash-cms/admin/locales";
10
11
  import { Permissions } from "@emdash-cms/auth";
11
12
  import type { Element } from "@emdash-cms/blocks";
13
+ import {
14
+ normalizePluginPagePath,
15
+ validateBlockResponse,
16
+ validateContentEditorActionResponse,
17
+ type BlockValidationPolicy,
18
+ type PluginUiContext,
19
+ } from "@emdash-cms/blocks/server";
20
+ import { isJsonPostRouteContract } from "@emdash-cms/plugin-types";
12
21
  import { Kysely, type Dialect } from "kysely";
13
22
  import virtualConfig from "virtual:emdash/config";
14
23
  import { z } from "zod";
15
24
 
16
25
  import { ErrorCode } from "./api/errors.js";
17
26
  import { buildManifestCollections } from "./api/handlers/manifest.js";
27
+ import {
28
+ handleMediaUpload as uploadMedia,
29
+ type MediaUploadInput,
30
+ } from "./api/handlers/media-upload.js";
18
31
  import { assertMediaUsageActivationWriteAllowed } from "./api/media-usage-write-fence.js";
19
32
  import { validateRev } from "./api/rev.js";
33
+ import { getSiteBaseUrl } from "./api/site-url.js";
20
34
  import type {
21
35
  EmDashConfig,
22
36
  PluginAdminPage,
@@ -25,7 +39,9 @@ import type {
25
39
  import type { EmDashManifest } from "./astro/types.js";
26
40
  import { getAuthMode } from "./auth/mode.js";
27
41
  import { getTrustedProxyHeaders } from "./auth/trusted-proxy.js";
42
+ import { lookupContentAuthor, sendCommentNotification } from "./comments/notifications.js";
28
43
  import type { ContentFieldFilters } from "./content-list-query.js";
44
+ import { keepKnownFields, staleStoredKeys } from "./content/known-fields.js";
29
45
  import { isSqlite } from "./database/dialect-helpers.js";
30
46
  import { kyselyLogOption } from "./database/instrumentation.js";
31
47
  import {
@@ -38,6 +54,8 @@ import {
38
54
  MIGRATION_RACE_WAIT_MS,
39
55
  } from "./database/migrations/runner.js";
40
56
  import { AuditRepository } from "./database/repositories/audit.js";
57
+ import { CommentRepository } from "./database/repositories/comment.js";
58
+ import type { CommentStatus } from "./database/repositories/comment.js";
41
59
  import { ContentRepository } from "./database/repositories/content.js";
42
60
  import { RevisionRepository } from "./database/repositories/revision.js";
43
61
  import { ContentMutationConflictError } from "./database/repositories/types.js";
@@ -46,7 +64,7 @@ import type {
46
64
  ContentDateField,
47
65
  } from "./database/repositories/types.js";
48
66
  import type { ImageValue } from "./fields/types.js";
49
- import { getI18nConfig } from "./i18n/config.js";
67
+ import { getI18nConfig, resolveContentCreateLocale } from "./i18n/config.js";
50
68
  import { repairLocaleCasing } from "./i18n/repair-locale-casing.js";
51
69
  import { warnAboutUnconfiguredTaxonomyLocales } from "./i18n/taxonomy-locale-diagnostic.js";
52
70
  import { normalizeMediaValue } from "./media/normalize.js";
@@ -59,7 +77,17 @@ import {
59
77
  refreshContentMediaUsageAfterWrite,
60
78
  } from "./media/usage/content-refresh.js";
61
79
  import { processMediaUsageWorkAfterWrite } from "./media/usage/work-processor.js";
62
- import { inspectSandboxHookResult } from "./plugins/sandbox/hook-result.js";
80
+ import {
81
+ scheduledPolicyRejectionKey,
82
+ type ScheduledPolicyRejection,
83
+ } from "./plugins/content-policy.js";
84
+ import { createCommentAccess, createTaxonomyAccessWithWrite } from "./plugins/context.js";
85
+ import type { ContentActionCallbacks } from "./plugins/context.js";
86
+ import type { PluginContentCacheInvalidator } from "./plugins/routes.js";
87
+ import {
88
+ createSandboxedPluginProxy,
89
+ getSandboxSaveRejectionDetails,
90
+ } from "./plugins/sandbox/proxy.js";
63
91
  import { createSandboxRunnerOptions } from "./plugins/sandbox/runner-options.js";
64
92
  import { getSandboxRouteErrorDetails } from "./plugins/sandbox/types.js";
65
93
  import type {
@@ -69,13 +97,17 @@ import type {
69
97
  } from "./plugins/sandbox/types.js";
70
98
  import type {
71
99
  ActorInfo,
72
- ContentHookEvent,
100
+ ContentActionOrigin,
101
+ ContentItem as PluginContentItem,
73
102
  ResolvedPlugin,
74
103
  MediaItem,
104
+ MediaMetadataPatch,
75
105
  PluginManifest,
76
106
  PluginCapability,
77
107
  PluginStorageConfig,
78
108
  PluginMcpManifestConfig,
109
+ PluginEditorAction,
110
+ PluginEditorPanel,
79
111
  PublicPageContext,
80
112
  PageMetadataContribution,
81
113
  PageFragmentContribution,
@@ -83,9 +115,18 @@ import type {
83
115
  FieldWidgetConfig,
84
116
  SettingField,
85
117
  UserInfo,
118
+ CollectionCommentSettings,
119
+ ModerationDecision,
120
+ PluginComment,
121
+ PluginCommentStatus,
122
+ ContentWriteInput,
123
+ PluginContentCreateCallback,
124
+ VersionedContentItem,
86
125
  } from "./plugins/types.js";
126
+ import { normalizePluginCapabilities } from "./plugins/types.js";
87
127
  import { recordSchedulerHeartbeatSafely } from "./scheduler-health.js";
88
128
  import { primeRegisteredCollections } from "./schema/collection-slugs-cache.js";
129
+ import type { CollectionWithFields } from "./schema/types.js";
89
130
  import { isMissingTableError } from "./utils/db-errors.js";
90
131
  import { hashString } from "./utils/hash.js";
91
132
  import { createInitLock, type InitLock, initWithLock } from "./utils/init-lock.js";
@@ -95,6 +136,19 @@ import { COMMIT, VERSION } from "./version.js";
95
136
  const LEADING_SLASH_PATTERN = /^\//;
96
137
  const LOCALE_CASING_REPAIR_OPTION = "emdash:repair_locale_casing";
97
138
 
139
+ const PLUGIN_COMMENT_STATUSES = new Set<string>(["approved", "pending", "spam"]);
140
+
141
+ function assertPluginCommentStatus(
142
+ value: string,
143
+ name: "status" | "expectedStatus",
144
+ ): asserts value is PluginCommentStatus {
145
+ if (!PLUGIN_COMMENT_STATUSES.has(value)) {
146
+ throw Object.assign(new Error(`${name} must be one of: approved, pending, spam`), {
147
+ code: "COMMENT_STATUS_INVALID",
148
+ });
149
+ }
150
+ }
151
+
98
152
  function getLocaleCasingRepairVersion(locales: readonly string[]): string | null {
99
153
  if (locales.length === 0) return null;
100
154
  return `1:${locales.toSorted().join(",")}`;
@@ -114,50 +168,20 @@ function parseStringArray(raw: string | null | undefined): string[] {
114
168
  return parsed.filter((v): v is string => typeof v === "string");
115
169
  }
116
170
 
171
+ function isModerationDecision(value: unknown): value is ModerationDecision {
172
+ if (typeof value !== "object" || value === null || !("status" in value)) return false;
173
+ if (value.status !== "pending" && value.status !== "approved" && value.status !== "spam") {
174
+ return false;
175
+ }
176
+ return !("reason" in value) || value.reason === undefined || typeof value.reason === "string";
177
+ }
178
+
117
179
  /** Combined result from a single-pass page contribution collection */
118
180
  interface PageContributions {
119
181
  metadata: PageMetadataContribution[];
120
182
  fragments: PageFragmentContribution[];
121
183
  }
122
184
 
123
- const VALID_METADATA_KINDS = new Set(["meta", "property", "link", "jsonld"]);
124
-
125
- /** Security-critical allowlist for link rel values from sandboxed plugins */
126
- const VALID_LINK_REL = new Set([
127
- "canonical",
128
- "alternate",
129
- "author",
130
- "license",
131
- "nlweb",
132
- "site.standard.document",
133
- ]);
134
-
135
- /**
136
- * Runtime validation for sandboxed plugin metadata contributions.
137
- * Sandboxed plugins return `unknown` across the RPC boundary — we must
138
- * verify the shape before passing to the metadata collector.
139
- */
140
- function isValidMetadataContribution(c: unknown): c is PageMetadataContribution {
141
- if (!c || typeof c !== "object" || !("kind" in c)) return false;
142
- const obj = c as Record<string, unknown>;
143
- if (typeof obj.kind !== "string" || !VALID_METADATA_KINDS.has(obj.kind)) return false;
144
-
145
- switch (obj.kind) {
146
- case "meta":
147
- return typeof obj.name === "string" && typeof obj.content === "string";
148
- case "property":
149
- return typeof obj.property === "string" && typeof obj.content === "string";
150
- case "link":
151
- return (
152
- typeof obj.href === "string" && typeof obj.rel === "string" && VALID_LINK_REL.has(obj.rel)
153
- );
154
- case "jsonld":
155
- return obj.graph != null && typeof obj.graph === "object";
156
- default:
157
- return false;
158
- }
159
- }
160
-
161
185
  import { after } from "./after.js";
162
186
  import { maybeRunScheduledBackup } from "./api/handlers/backup.js";
163
187
  import { loadBundleFromR2 } from "./api/handlers/marketplace.js";
@@ -166,6 +190,15 @@ import {
166
190
  DEFAULT_COMMENT_MODERATOR_PLUGIN_ID,
167
191
  defaultCommentModerate,
168
192
  } from "./comments/moderator.js";
193
+ import { submitPublicComment } from "./comments/public-submission.js";
194
+ import {
195
+ CommentStatusConflictError,
196
+ createComment,
197
+ moderateComment,
198
+ type CommentCreateInput,
199
+ type CommentCreateResult,
200
+ type CommentHookRunner,
201
+ } from "./comments/service.js";
169
202
  import { validateEncryptionKeyAtStartup } from "./config/secrets.js";
170
203
  import { OptionsRepository } from "./database/repositories/options.js";
171
204
  import {
@@ -185,6 +218,7 @@ import {
185
218
  handleContentUnpublish,
186
219
  handleContentSchedule,
187
220
  handleContentUnschedule,
221
+ handleScheduledPolicyRejection,
188
222
  handleContentCountScheduled,
189
223
  handleContentDiscardDraft,
190
224
  handleContentCompare,
@@ -210,11 +244,15 @@ import { DEV_CONSOLE_EMAIL_PLUGIN_ID, devConsoleEmailDeliver } from "./plugins/e
210
244
  import { EmailPipeline } from "./plugins/email.js";
211
245
  import {
212
246
  createHookPipeline,
247
+ getActiveContentSaveHookName,
213
248
  resolveExclusiveHooks as resolveExclusiveHooksShared,
214
249
  type HookPipeline,
215
250
  } from "./plugins/hooks.js";
216
- import { normalizeManifestRoute } from "./plugins/manifest-schema.js";
251
+ import { disableRuntimePlugin, enableRuntimePlugin } from "./plugins/lifecycle.js";
252
+ import { HOOK_NAMES, normalizeManifestRoute } from "./plugins/manifest-schema.js";
253
+ import { updatePluginMediaMetadata } from "./plugins/media.js";
217
254
  import { extractRequestMeta, sanitizeHeadersForSandbox } from "./plugins/request-meta.js";
255
+ import { PluginRouteRequestError } from "./plugins/route-wire.js";
218
256
  import {
219
257
  buildRouteMeta,
220
258
  parseRouteInput,
@@ -227,7 +265,11 @@ import { isContentSaveRejection } from "./plugins/save-rejection.js";
227
265
  import type { CronScheduler } from "./plugins/scheduler/types.js";
228
266
  import { PluginStateRepository } from "./plugins/state.js";
229
267
  import { syncDeclaredStorageIndexes } from "./plugins/storage-indexes.js";
230
- import { resolveManifestRegistryConfig } from "./registry/config.js";
268
+ import {
269
+ getRegistryConfigInput,
270
+ resolveManifestRegistryConfig,
271
+ resolveRegistryConfigForSandbox,
272
+ } from "./registry/config.js";
231
273
  import { requestCached } from "./request-cache.js";
232
274
  import { getRequestContext } from "./request-context.js";
233
275
  import { publishDueContent, type PublishedRef } from "./scheduled-publish.js";
@@ -236,6 +278,28 @@ import { invalidateSiteSettingsCache } from "./settings/index.js";
236
278
 
237
279
  const DRAFT_ONLY_UPDATE_KEYS = new Set(["data", "slug", "locale", "skipRevision", "actor"]);
238
280
  const MAX_DRAFT_STAGE_ATTEMPTS = 32;
281
+ const PLUGIN_INVOCATION_RELEASE_GRACE_MS = 60_000;
282
+
283
+ type ContentPolicyHookName =
284
+ | "content:beforePublish"
285
+ | "content:beforeSchedule"
286
+ | "content:beforeUnpublish";
287
+
288
+ interface ContentPolicyMutationOptions {
289
+ _rev?: string;
290
+ actor?: ActorInfo;
291
+ origin?: ContentActionOrigin;
292
+ pluginInvocationId?: string;
293
+ }
294
+
295
+ type ContentPolicyCheck =
296
+ | { allowed: true; revision: string }
297
+ | {
298
+ allowed: false;
299
+ revision: string;
300
+ error: { code: string; message: string };
301
+ cancellation?: { pluginId: string; reason: string };
302
+ };
239
303
 
240
304
  /**
241
305
  * Sandboxed plugin entry from virtual module
@@ -261,6 +325,10 @@ export interface SandboxedPluginEntry {
261
325
  adminPages?: Array<{ path: string; label?: string; icon?: string }>;
262
326
  /** Dashboard widgets */
263
327
  adminWidgets?: Array<{ id: string; title?: string; size?: string }>;
328
+ /** Saved-entry Block Kit panels. */
329
+ editorPanels?: PluginManifest["admin"]["editorPanels"];
330
+ /** Saved-entry host-rendered actions. */
331
+ editorActions?: PluginManifest["admin"]["editorActions"];
264
332
  /** Settings schema for the auto-generated admin settings form */
265
333
  settingsSchema?: Record<string, SettingField>;
266
334
  /** Portable Text block types contributed to the editor (declarative Block Kit) */
@@ -276,6 +344,26 @@ export interface SandboxedPluginEntry {
276
344
  preferred?: string[];
277
345
  }
278
346
 
347
+ export type ResolvedPluginEditorExtension =
348
+ | {
349
+ kind: "panel";
350
+ extension: PluginEditorPanel;
351
+ policy: BlockValidationPolicy;
352
+ capabilities: readonly PluginCapability[];
353
+ }
354
+ | {
355
+ kind: "action";
356
+ extension: PluginEditorAction;
357
+ policy: BlockValidationPolicy;
358
+ capabilities: readonly PluginCapability[];
359
+ };
360
+
361
+ export interface PluginEditorExtensionDispatch {
362
+ ui: PluginUiContext;
363
+ kind: "panel" | "action";
364
+ policy: BlockValidationPolicy;
365
+ }
366
+
279
367
  /**
280
368
  * Media provider entry from virtual module
281
369
  */
@@ -352,6 +440,15 @@ export interface RuntimeDependencies {
352
440
  sandboxedPluginEntries: SandboxedPluginEntry[];
353
441
  /** Factory function supplied by the active platform adapter. */
354
442
  createSandboxRunner: SandboxRunnerFactory | null;
443
+ /** Clock used by cron scheduling, task execution, and scheduled publishing. */
444
+ now?: () => Date;
445
+ /** Site values supplied by hosts that do not load Astro's virtual config. */
446
+ siteInfo?: {
447
+ name?: string;
448
+ url?: string;
449
+ locale?: string;
450
+ trailingSlash?: "always" | "never" | "ignore";
451
+ };
355
452
  }
356
453
 
357
454
  /**
@@ -387,7 +484,16 @@ export interface EmDashRuntimeParts {
387
484
  db: Kysely<Database>;
388
485
  getDb?: () => Kysely<Database>;
389
486
  beforeContentWrite?: () => Promise<void>;
487
+ contentCreate?: PluginContentCreateCallback;
488
+ contentActions?: ContentActionCallbacks;
489
+ now?: () => Date;
390
490
  storage?: Storage;
491
+ commentModerate?: (
492
+ pluginId: string,
493
+ id: string,
494
+ status: PluginCommentStatus,
495
+ expectedStatus: PluginCommentStatus,
496
+ ) => Promise<PluginComment>;
391
497
  siteInfo?: {
392
498
  siteName?: string;
393
499
  siteUrl?: string;
@@ -406,6 +512,17 @@ export interface EmDashRuntimeParts {
406
512
  */
407
513
  function beforeSaveFailure(error: unknown) {
408
514
  if (isContentSaveRejection(error)) {
515
+ const sandbox = getSandboxSaveRejectionDetails(error);
516
+ if (sandbox) {
517
+ return {
518
+ success: false as const,
519
+ error: {
520
+ code: ErrorCode.SAVE_REJECTED,
521
+ message: error.message,
522
+ details: sandbox,
523
+ },
524
+ };
525
+ }
409
526
  return {
410
527
  success: false as const,
411
528
  error: { code: ErrorCode.SAVE_REJECTED, message: error.message },
@@ -429,6 +546,27 @@ function contentItemToRecord(item: ContentItemInternal): Record<string, unknown>
429
546
  return { ...item };
430
547
  }
431
548
 
549
+ function toPluginContentItem(item: ContentItemInternal): PluginContentItem {
550
+ return {
551
+ id: item.id,
552
+ type: item.type,
553
+ slug: item.slug,
554
+ status: item.status,
555
+ locale: item.locale,
556
+ data: item.data,
557
+ createdAt: item.createdAt,
558
+ updatedAt: item.updatedAt,
559
+ publishedAt: item.publishedAt,
560
+ scheduledAt: item.scheduledAt,
561
+ authorId: item.authorId,
562
+ translationGroup: item.translationGroup,
563
+ liveRevisionId: item.liveRevisionId,
564
+ draftRevisionId: item.draftRevisionId,
565
+ version: item.version,
566
+ ...(item.seo === undefined ? {} : { seo: item.seo }),
567
+ };
568
+ }
569
+
432
570
  /**
433
571
  * Db init lock reclaim deadline. Derived from the migration race wait so
434
572
  * they can't drift apart: a healthy init can legitimately block for the
@@ -509,6 +647,7 @@ function getSeedHolder(): SeedHolder {
509
647
  }
510
648
  const storageCache = new Map<string, Storage>();
511
649
  const sandboxedPluginCache = new Map<string, SandboxedPluginInstance>();
650
+ const sandboxedManifestCache = new Map<string, PluginManifest>();
512
651
  /**
513
652
  * Per-tier sets of `${pluginId}:${version}` keys present in
514
653
  * `sandboxedPluginCache`. Used during sync to know which entries belong
@@ -531,15 +670,35 @@ const marketplaceManifestCache = new Map<
531
670
  pages?: PluginAdminPage[];
532
671
  widgets?: PluginDashboardWidget[];
533
672
  settingsSchema?: Record<string, SettingField>;
673
+ editorPanels?: PluginManifest["admin"]["editorPanels"];
674
+ editorActions?: PluginManifest["admin"]["editorActions"];
534
675
  };
535
676
  mcp?: PluginMcpManifestConfig;
536
677
  storage?: PluginManifest["storage"];
678
+ allowedHosts?: string[];
679
+ capabilities?: PluginCapability[];
537
680
  }
538
681
  >();
539
682
  /** Route metadata for sandboxed plugins: pluginId -> routeName -> RouteMeta */
540
683
  const sandboxedRouteMetaCache = new Map<string, Map<string, RouteMeta>>();
541
684
  let sandboxRunner: SandboxRunner | null = null;
542
685
 
686
+ function allowedBrowserImageHosts(
687
+ capabilities: readonly PluginCapability[],
688
+ allowedHosts: readonly string[],
689
+ ): readonly string[] {
690
+ if (
691
+ capabilities.includes("network:request:unrestricted") ||
692
+ capabilities.includes("network:fetch:any")
693
+ ) {
694
+ return ["*"];
695
+ }
696
+ if (capabilities.includes("network:request") || capabilities.includes("network:fetch")) {
697
+ return allowedHosts;
698
+ }
699
+ return [];
700
+ }
701
+
543
702
  /**
544
703
  * EmDashRuntime - singleton per worker
545
704
  */
@@ -578,6 +737,16 @@ export class EmDashRuntime {
578
737
  private cronScheduler: CronScheduler | null;
579
738
  private enabledPlugins: Set<string>;
580
739
  private pluginStates: Map<string, string>;
740
+ private readonly activePluginContentActions = new Map<string, number>();
741
+ private readonly pendingPluginAfterHooks = new Map<string, Array<() => Promise<void>>>();
742
+ private readonly activePluginInvocations = new Set<string>();
743
+ /** Timed-out sandbox invocations whose later actions must schedule hooks without another flush. */
744
+ private readonly releasedPluginInvocations = new Set<string>();
745
+ private readonly pluginInvocationCacheInvalidators = new Map<
746
+ string,
747
+ PluginContentCacheInvalidator
748
+ >();
749
+ private pluginContentCacheInvalidator?: PluginContentCacheInvalidator;
581
750
 
582
751
  /**
583
752
  * Isolate-lifetime guard so FTS indexes are verified at most once per
@@ -602,7 +771,16 @@ export class EmDashRuntime {
602
771
  db: Kysely<Database>;
603
772
  getDb?: () => Kysely<Database>;
604
773
  beforeContentWrite?: () => Promise<void>;
774
+ contentCreate?: PluginContentCreateCallback;
775
+ contentActions?: ContentActionCallbacks;
776
+ now?: () => Date;
605
777
  storage?: Storage;
778
+ commentModerate?: (
779
+ pluginId: string,
780
+ id: string,
781
+ status: PluginCommentStatus,
782
+ expectedStatus: PluginCommentStatus,
783
+ ) => Promise<PluginComment>;
606
784
  siteInfo?: {
607
785
  siteName?: string;
608
786
  siteUrl?: string;
@@ -614,6 +792,7 @@ export class EmDashRuntime {
614
792
  private runtimeDeps: RuntimeDependencies;
615
793
  /** Mutable ref for the cron invokeCronHook closure to read the current pipeline */
616
794
  private pipelineRef!: { current: HookPipeline };
795
+ private readonly commentModerationInProgress = new Set<string>();
617
796
 
618
797
  /**
619
798
  * Get the database instance for the current request.
@@ -631,6 +810,13 @@ export class EmDashRuntime {
631
810
  return this._db;
632
811
  }
633
812
 
813
+ /** Bind the platform cache provider used by plugin actions, including request-less cron hooks. */
814
+ setPluginContentCacheInvalidator(
815
+ invalidateContentCache: PluginContentCacheInvalidator | undefined,
816
+ ): void {
817
+ this.pluginContentCacheInvalidator = invalidateContentCache;
818
+ }
819
+
634
820
  constructor(parts: EmDashRuntimeParts) {
635
821
  this._db = parts.db;
636
822
  this.storage = parts.storage;
@@ -681,9 +867,15 @@ export class EmDashRuntime {
681
867
  onPublished?: (refs: PublishedRef[]) => Promise<void>,
682
868
  ): Promise<PublishedRef[]> {
683
869
  await assertMediaUsageActivationWriteAllowed(this.db);
870
+ const currentTime = this.runtimeDeps.now?.() ?? new Date();
684
871
  return publishDueContent(this.db, {
685
- publish: (collection, id, options) => this.handleContentPublish(collection, id, options),
872
+ publish: (collection, id, options) =>
873
+ this.handleContentPublish(collection, id, {
874
+ ...options,
875
+ origin: { source: "scheduler" },
876
+ }),
686
877
  onPublished,
878
+ currentTime,
687
879
  });
688
880
  }
689
881
 
@@ -704,11 +896,26 @@ export class EmDashRuntime {
704
896
  async runScheduledTasks(
705
897
  options: {
706
898
  onPublished?: (refs: PublishedRef[]) => Promise<void>;
899
+ invalidateContentCache?: PluginContentCacheInvalidator;
707
900
  } = {},
708
901
  ): Promise<{ published: PublishedRef[] }> {
902
+ const { published } = await this.runScheduledTasksWithStats(options);
903
+ return { published };
904
+ }
905
+
906
+ async runScheduledTasksWithStats(
907
+ options: {
908
+ onPublished?: (refs: PublishedRef[]) => Promise<void>;
909
+ invalidateContentCache?: PluginContentCacheInvalidator;
910
+ } = {},
911
+ ): Promise<{ processed: number; published: PublishedRef[] }> {
912
+ if (options.invalidateContentCache) {
913
+ this.pluginContentCacheInvalidator = options.invalidateContentCache;
914
+ }
915
+ let processed = 0;
709
916
  if (this.cronExecutor) {
710
917
  try {
711
- await this.cronExecutor.tick();
918
+ processed = await this.cronExecutor.tick();
712
919
  } catch (error) {
713
920
  console.error("[cron] Tick failed:", error);
714
921
  }
@@ -742,7 +949,7 @@ export class EmDashRuntime {
742
949
  await maybeRunScheduledBackup(this.db, this.storage ?? undefined);
743
950
  await recordSchedulerHeartbeatSafely(this.db);
744
951
 
745
- return { published };
952
+ return { processed, published };
746
953
  }
747
954
 
748
955
  /**
@@ -773,6 +980,20 @@ export class EmDashRuntime {
773
980
  }
774
981
  }
775
982
 
983
+ /** Stop background work and discard loaded sandbox isolates. */
984
+ async shutdown(): Promise<void> {
985
+ await this.stopCron();
986
+ sandboxRunner?.setCommentModerate?.(null);
987
+ await sandboxRunner?.terminateAll();
988
+ sandboxRunner = null;
989
+ sandboxedPluginCache.clear();
990
+ sandboxedManifestCache.clear();
991
+ sandboxedRouteMetaCache.clear();
992
+ marketplaceManifestCache.clear();
993
+ marketplacePluginKeys.clear();
994
+ registryPluginKeys.clear();
995
+ }
996
+
776
997
  /**
777
998
  * Update in-memory plugin status and rebuild the hook pipeline.
778
999
  *
@@ -794,6 +1015,43 @@ export class EmDashRuntime {
794
1015
  }
795
1016
  }
796
1017
 
1018
+ async handlePluginEnable(pluginId: string) {
1019
+ return enableRuntimePlugin(this, pluginId);
1020
+ }
1021
+
1022
+ async handlePluginDisable(pluginId: string) {
1023
+ return disableRuntimePlugin(this, pluginId);
1024
+ }
1025
+
1026
+ /** Dispatch teardown lifecycle while the runtime-installed isolate is still loaded. */
1027
+ async runPluginUninstallLifecycle(pluginId: string, deleteData: boolean): Promise<void> {
1028
+ const active = this.isPluginEnabled(pluginId);
1029
+ if (active) {
1030
+ try {
1031
+ await this._hooks.runPluginDeactivate(pluginId);
1032
+ } catch (error) {
1033
+ console.error(`EmDash: Plugin ${pluginId} deactivate hook failed during uninstall:`, error);
1034
+ }
1035
+ }
1036
+
1037
+ try {
1038
+ const results = await this._hooks.runPluginUninstall(pluginId, deleteData);
1039
+ if (results.length > 0) return;
1040
+ await this.findSandboxedPlugin(pluginId)?.invokeHook("plugin:uninstall", { deleteData });
1041
+ } catch (error) {
1042
+ console.error(`EmDash: Plugin ${pluginId} uninstall hook failed:`, error);
1043
+ }
1044
+ }
1045
+
1046
+ async runPluginInstallLifecycle(pluginId: string): Promise<void> {
1047
+ await this._hooks.runPluginInstall(pluginId);
1048
+ await this._hooks.runPluginActivate(pluginId);
1049
+ }
1050
+
1051
+ async runPluginActivateLifecycle(pluginId: string): Promise<void> {
1052
+ await this._hooks.runPluginActivate(pluginId);
1053
+ }
1054
+
797
1055
  /**
798
1056
  * Rebuild the hook pipeline from the current set of enabled plugins.
799
1057
  *
@@ -866,7 +1124,7 @@ export class EmDashRuntime {
866
1124
  * update, and uninstall handlers complete.
867
1125
  */
868
1126
  async syncRegistryPlugins(): Promise<void> {
869
- if (!this.config.experimental?.registry) return;
1127
+ if (!getRegistryConfigInput(this.config.registry, this.config.experimental?.registry)) return;
870
1128
  await this.syncSandboxedSourcePlugins("registry");
871
1129
  }
872
1130
 
@@ -884,6 +1142,7 @@ export class EmDashRuntime {
884
1142
  if (!sandboxRunner || !sandboxRunner.isAvailable()) return;
885
1143
 
886
1144
  const keySet = source === "marketplace" ? marketplacePluginKeys : registryPluginKeys;
1145
+ let pipelineChanged = false;
887
1146
 
888
1147
  try {
889
1148
  const stateRepo = new PluginStateRepository(this.db);
@@ -937,8 +1196,11 @@ export class EmDashRuntime {
937
1196
  }
938
1197
 
939
1198
  sandboxedPluginCache.delete(key);
1199
+ sandboxedManifestCache.delete(key);
940
1200
  this.sandboxedPlugins.delete(key);
1201
+ this.removePluginFromLists(pluginId);
941
1202
  keySet.delete(key);
1203
+ pipelineChanged = true;
942
1204
  if (pluginId) {
943
1205
  sandboxedRouteMetaCache.delete(pluginId);
944
1206
  marketplaceManifestCache.delete(pluginId);
@@ -961,8 +1223,11 @@ export class EmDashRuntime {
961
1223
 
962
1224
  const loaded = await sandboxRunner.load(bundle.manifest, bundle.backendCode);
963
1225
  sandboxedPluginCache.set(key, loaded);
1226
+ sandboxedManifestCache.set(key, bundle.manifest);
964
1227
  this.sandboxedPlugins.set(key, loaded);
1228
+ this.allPipelinePlugins.push(createSandboxedPluginProxy(bundle.manifest, loaded));
965
1229
  keySet.add(key);
1230
+ pipelineChanged = true;
966
1231
 
967
1232
  // Cache manifest admin config for getManifest()
968
1233
  marketplaceManifestCache.set(pluginId, {
@@ -971,6 +1236,8 @@ export class EmDashRuntime {
971
1236
  admin: bundle.manifest.admin,
972
1237
  mcp: bundle.manifest.mcp,
973
1238
  storage: bundle.manifest.storage,
1239
+ allowedHosts: bundle.manifest.allowedHosts,
1240
+ capabilities: bundle.manifest.capabilities,
974
1241
  });
975
1242
 
976
1243
  // Cache route metadata from manifest for auth decisions
@@ -985,6 +1252,10 @@ export class EmDashRuntime {
985
1252
  sandboxedRouteMetaCache.delete(pluginId);
986
1253
  }
987
1254
  }
1255
+
1256
+ if (pipelineChanged) {
1257
+ await this.rebuildHookPipeline();
1258
+ }
988
1259
  } catch (error) {
989
1260
  console.error(`EmDash: Failed to sync ${source} plugins:`, error);
990
1261
  }
@@ -1087,6 +1358,8 @@ export class EmDashRuntime {
1087
1358
  admin: bundle.manifest.admin,
1088
1359
  mcp: bundle.manifest.mcp,
1089
1360
  storage: bundle.manifest.storage,
1361
+ allowedHosts: bundle.manifest.allowedHosts,
1362
+ capabilities: bundle.manifest.capabilities,
1090
1363
  });
1091
1364
  if (bundle.manifest.routes.length > 0) {
1092
1365
  const routeMetaMap = new Map<string, RouteMeta>();
@@ -1137,6 +1410,8 @@ export class EmDashRuntime {
1137
1410
  w.size === "full" || w.size === "half" || w.size === "third" ? w.size : undefined,
1138
1411
  })),
1139
1412
  settingsSchema: bundle.manifest.admin?.settingsSchema,
1413
+ editorPanels: bundle.manifest.admin?.editorPanels,
1414
+ editorActions: bundle.manifest.admin?.editorActions,
1140
1415
  });
1141
1416
  newPlugins.push(adapted);
1142
1417
  this.allPipelinePlugins.push(adapted);
@@ -1203,10 +1478,9 @@ export class EmDashRuntime {
1203
1478
  };
1204
1479
 
1205
1480
  // Validate EMDASH_ENCRYPTION_KEY once here so a malformed value
1206
- // surfaces in startup logs instead of as request-time 500s. The key
1207
- // itself is not yet consumed (a follow-up PR adds plugin-secret
1208
- // encryption); validating early just guards against silent
1209
- // misconfiguration.
1481
+ // surfaces in startup logs. Plugin secret-setting operations re-read
1482
+ // the key and fail closed at their own boundary, so validation here
1483
+ // does not block unrelated request paths.
1210
1484
  await phase("rt.secrets", "Validate encryption key", () => validateEncryptionKeyAtStartup());
1211
1485
 
1212
1486
  // FTS verify/repair is deferred off the cold-start hot path.
@@ -1285,13 +1559,13 @@ export class EmDashRuntime {
1285
1559
  ]);
1286
1560
  storedLocaleCasingRepairVersion = siteOpts.get(LOCALE_CASING_REPAIR_OPTION);
1287
1561
  return {
1288
- siteName: siteOpts.get("emdash:site_title") ?? undefined,
1289
- siteUrl: siteOpts.get("emdash:site_url") ?? undefined,
1290
- locale: siteOpts.get("emdash:locale") ?? undefined,
1562
+ siteName: deps.siteInfo?.name ?? siteOpts.get("emdash:site_title") ?? undefined,
1563
+ siteUrl: deps.siteInfo?.url ?? siteOpts.get("emdash:site_url") ?? undefined,
1564
+ locale: deps.siteInfo?.locale ?? siteOpts.get("emdash:locale") ?? undefined,
1291
1565
  // trailingSlash is a build-time Astro routing decision, not a
1292
1566
  // user-editable setting, so it comes from the Astro config
1293
1567
  // (virtual:emdash/config), not the options table.
1294
- trailingSlash: virtualConfig?.trailingSlash,
1568
+ trailingSlash: deps.siteInfo?.trailingSlash ?? virtualConfig?.trailingSlash,
1295
1569
  };
1296
1570
  };
1297
1571
 
@@ -1535,26 +1809,8 @@ export class EmDashRuntime {
1535
1809
  }
1536
1810
  }
1537
1811
 
1538
- // Filter to currently enabled plugins for the initial pipeline
1539
- const enabledPluginList = allPipelinePlugins.filter((p) => enabledPlugins.has(p.id));
1540
-
1541
- // Create hook pipeline. getDb travels here (not just via the email
1542
- // setContextFactory call below) so it survives rebuildHookPipeline(),
1543
- // which reconstructs the factory from pipelineFactoryOptions. Without it,
1544
- // toggling a plugin on an email-less deployment would silently revert
1545
- // plugin contexts to the singleton db — re-breaking connection-backed
1546
- // adapters. See #1622.
1547
- const pipelineFactoryOptions = {
1548
- db,
1549
- getDb: resolveDb,
1550
- beforeContentWrite: () => assertMediaUsageActivationWriteAllowed(resolveDb()),
1551
- storage: storage ?? undefined,
1552
- siteInfo,
1553
- };
1554
- const pipeline = createHookPipeline(enabledPluginList, pipelineFactoryOptions);
1555
-
1556
1812
  // Load sandboxed plugins (build-time, sandbox runner path)
1557
- const sandboxedPlugins = await phase("rt.sandbox", "Sandboxed plugins", () =>
1813
+ const sandboxedPluginPool = await phase("rt.sandbox", "Sandboxed plugins", () =>
1558
1814
  EmDashRuntime.loadSandboxedPlugins(deps, db, storage, siteInfo),
1559
1815
  );
1560
1816
 
@@ -1572,7 +1828,7 @@ export class EmDashRuntime {
1572
1828
  db,
1573
1829
  storage,
1574
1830
  deps,
1575
- sandboxedPlugins,
1831
+ sandboxedPluginPool,
1576
1832
  siteInfo,
1577
1833
  ),
1578
1834
  ),
@@ -1580,7 +1836,10 @@ export class EmDashRuntime {
1580
1836
  }
1581
1837
 
1582
1838
  // Cold-start: load registry-installed plugins from site R2
1583
- if (deps.config.experimental?.registry && storage) {
1839
+ if (
1840
+ getRegistryConfigInput(deps.config.registry, deps.config.experimental?.registry) &&
1841
+ storage
1842
+ ) {
1584
1843
  installedTierPhases.push(
1585
1844
  phase("rt.registry", "Registry plugins", () =>
1586
1845
  EmDashRuntime.loadInstalledSandboxedPlugins(
@@ -1588,7 +1847,7 @@ export class EmDashRuntime {
1588
1847
  db,
1589
1848
  storage,
1590
1849
  deps,
1591
- sandboxedPlugins,
1850
+ sandboxedPluginPool,
1592
1851
  siteInfo,
1593
1852
  ),
1594
1853
  ),
@@ -1598,6 +1857,113 @@ export class EmDashRuntime {
1598
1857
  await Promise.all(installedTierPhases);
1599
1858
  }
1600
1859
 
1860
+ const configuredSandboxIds = new Set(deps.sandboxedPluginEntries.map((entry) => entry.id));
1861
+ const sandboxedPlugins = new Map(
1862
+ [...sandboxedPluginPool].filter(([pluginKey]) => {
1863
+ const pluginId = pluginKey.slice(0, pluginKey.lastIndexOf(":"));
1864
+ return configuredSandboxIds.has(pluginId) || pluginStates.get(pluginId) === "active";
1865
+ }),
1866
+ );
1867
+
1868
+ // Add isolate-backed proxies to the same host pipeline as trusted
1869
+ // plugins. The proxy carries only manifest metadata and RPC handlers;
1870
+ // plugin code remains inside the configured runner.
1871
+ for (const [pluginKey, instance] of sandboxedPlugins) {
1872
+ const manifest = sandboxedManifestCache.get(pluginKey);
1873
+ if (!manifest) continue;
1874
+ allPipelinePlugins.push(createSandboxedPluginProxy(manifest, instance));
1875
+ const status = pluginStates.get(manifest.id);
1876
+ if (status === undefined || status === "active") enabledPlugins.add(manifest.id);
1877
+ }
1878
+
1879
+ // Create hook pipeline. getDb travels here (not just via the email
1880
+ // setContextFactory call below) so it survives rebuildHookPipeline(),
1881
+ // which reconstructs the factory from pipelineFactoryOptions. Without it,
1882
+ // toggling a plugin on an email-less deployment would silently revert
1883
+ // plugin contexts to the singleton db — re-breaking connection-backed
1884
+ // adapters. See #1622.
1885
+ const runtimeRef: { current: EmDashRuntime | null } = { current: null };
1886
+ const requireRuntime = (): EmDashRuntime => {
1887
+ if (!runtimeRef.current) throw new Error("EmDash runtime is not ready");
1888
+ return runtimeRef.current;
1889
+ };
1890
+ const contentActions: ContentActionCallbacks = {
1891
+ begin: (pluginId, invocationId, invalidateContentCache) =>
1892
+ requireRuntime().beginPluginInvocation(pluginId, invocationId, invalidateContentCache),
1893
+ flush: (pluginId, invocationId, final) =>
1894
+ requireRuntime().flushPluginAfterHooks(pluginId, invocationId, final),
1895
+ getVersioned: (pluginId, collection, id) =>
1896
+ requireRuntime().pluginGetVersioned(pluginId, collection, id),
1897
+ publish: (pluginId, collection, id, options, invocationId, invalidateContentCache) =>
1898
+ requireRuntime().pluginPublish(
1899
+ pluginId,
1900
+ collection,
1901
+ id,
1902
+ options,
1903
+ invocationId,
1904
+ invalidateContentCache,
1905
+ ),
1906
+ unpublish: (pluginId, collection, id, options, invocationId, invalidateContentCache) =>
1907
+ requireRuntime().pluginUnpublish(
1908
+ pluginId,
1909
+ collection,
1910
+ id,
1911
+ options,
1912
+ invocationId,
1913
+ invalidateContentCache,
1914
+ ),
1915
+ schedule: (pluginId, collection, id, options, invocationId, invalidateContentCache) =>
1916
+ requireRuntime().pluginSchedule(
1917
+ pluginId,
1918
+ collection,
1919
+ id,
1920
+ options,
1921
+ invocationId,
1922
+ invalidateContentCache,
1923
+ ),
1924
+ unschedule: (pluginId, collection, id, options, invocationId, invalidateContentCache) =>
1925
+ requireRuntime().pluginUnschedule(
1926
+ pluginId,
1927
+ collection,
1928
+ id,
1929
+ options,
1930
+ invocationId,
1931
+ invalidateContentCache,
1932
+ ),
1933
+ getTrashedVersioned: (pluginId, collection, id) =>
1934
+ requireRuntime().pluginGetTrashedVersioned(pluginId, collection, id),
1935
+ restore: (pluginId, collection, id, options, invocationId, invalidateContentCache) =>
1936
+ requireRuntime().pluginRestore(
1937
+ pluginId,
1938
+ collection,
1939
+ id,
1940
+ options,
1941
+ invocationId,
1942
+ invalidateContentCache,
1943
+ ),
1944
+ };
1945
+ const pipelineFactoryOptions = {
1946
+ db,
1947
+ getDb: resolveDb,
1948
+ beforeContentWrite: () => assertMediaUsageActivationWriteAllowed(resolveDb()),
1949
+ contentActions,
1950
+ now: deps.now,
1951
+ storage: storage ?? undefined,
1952
+ siteInfo,
1953
+ commentModerate: (
1954
+ pluginId: string,
1955
+ id: string,
1956
+ status: PluginCommentStatus,
1957
+ expectedStatus: PluginCommentStatus,
1958
+ ) => {
1959
+ const current = runtimeRef.current;
1960
+ if (!current) throw new Error("Comment moderation is unavailable during runtime startup");
1961
+ return current.handlePluginCommentModerate(pluginId, id, status, expectedStatus);
1962
+ },
1963
+ };
1964
+ const enabledPluginList = allPipelinePlugins.filter((p) => enabledPlugins.has(p.id));
1965
+ const pipeline = createHookPipeline(enabledPluginList, pipelineFactoryOptions);
1966
+
1601
1967
  // Initialize media providers
1602
1968
  const mediaProviders = new Map<string, MediaProvider>();
1603
1969
  const mediaProviderEntries = deps.mediaProviderEntries ?? [];
@@ -1653,11 +2019,9 @@ export class EmDashRuntime {
1653
2019
  // so the timer scheduler's cleanup can route scheduled publishing through
1654
2020
  // the runtime wrapper (firing content:afterPublish hooks). The first tick
1655
2021
  // is ≥1s out, well after the synchronous assignment below.
1656
- const runtimeRef: { current: EmDashRuntime | null } = { current: null };
1657
-
1658
2022
  await phase("rt.cron", "Cron init (recovery deferred post-response)", async () => {
1659
2023
  try {
1660
- cronExecutor = new CronExecutor(resolveDb, invokeCronHook);
2024
+ cronExecutor = new CronExecutor(resolveDb, invokeCronHook, deps.now);
1661
2025
  // Plugin schedules are always database-backed. On long-lived runtimes this
1662
2026
  // callback also wakes the timer; on Cloudflare the external Cron Trigger
1663
2027
  // drives execution, so rescheduling is intentionally a no-op.
@@ -1736,6 +2100,7 @@ export class EmDashRuntime {
1736
2100
  // Non-fatal — CMS works without cron
1737
2101
  }
1738
2102
  });
2103
+ sandboxRunner?.setCronReschedule?.(() => cronScheduler?.reschedule());
1739
2104
 
1740
2105
  const runtime = new EmDashRuntime({
1741
2106
  db,
@@ -1760,9 +2125,46 @@ export class EmDashRuntime {
1760
2125
  runtimeDeps: deps,
1761
2126
  pipelineRef,
1762
2127
  });
2128
+ const contentCreate: PluginContentCreateCallback = async (
2129
+ _pluginId,
2130
+ collection,
2131
+ input,
2132
+ options,
2133
+ ) => {
2134
+ const { seo, ...data } = input;
2135
+ const result = await runtime.handleContentCreate(
2136
+ collection,
2137
+ {
2138
+ data,
2139
+ seo,
2140
+ locale: resolveContentCreateLocale(options?.locale),
2141
+ translationOf: options?.translationOf,
2142
+ },
2143
+ {
2144
+ skipSaveHooks: options?.sandboxOrigin
2145
+ ? options.originHook !== undefined
2146
+ : getActiveContentSaveHookName() != null,
2147
+ excludeAfterSavePluginId: _pluginId,
2148
+ },
2149
+ );
2150
+ if (!result.success) {
2151
+ throw Object.assign(new Error(result.error.message), {
2152
+ name: result.error.code,
2153
+ code: result.error.code,
2154
+ });
2155
+ }
2156
+ return result.data.item;
2157
+ };
2158
+ runtime.pipelineFactoryOptions.contentCreate = contentCreate;
2159
+ pipeline.setContextFactory({ contentCreate });
2160
+ sandboxRunner?.setContentCreate?.(contentCreate);
1763
2161
  // Hand the constructed instance to the scheduler-cleanup closure so the
1764
2162
  // timer-driven sweep can fire publish hooks (see runtimeRef above).
1765
2163
  runtimeRef.current = runtime;
2164
+ sandboxRunner?.setCommentModerate?.((pluginId, id, status, expectedStatus) =>
2165
+ runtime.handlePluginCommentModerate(pluginId, id, status, expectedStatus),
2166
+ );
2167
+ sandboxRunner?.setContentActions?.(contentActions);
1766
2168
  return runtime;
1767
2169
  }
1768
2170
 
@@ -1990,6 +2392,8 @@ export class EmDashRuntime {
1990
2392
  settingsSchema: entry.settingsSchema,
1991
2393
  portableTextBlocks: entry.portableTextBlocks,
1992
2394
  fieldWidgets: entry.fieldWidgets,
2395
+ editorPanels: entry.editorPanels,
2396
+ editorActions: entry.editorActions,
1993
2397
  });
1994
2398
  plugins.push(resolved);
1995
2399
  console.log(
@@ -2016,11 +2420,6 @@ export class EmDashRuntime {
2016
2420
  trailingSlash?: "always" | "never" | "ignore";
2017
2421
  },
2018
2422
  ): Promise<Map<string, SandboxedPluginInstance>> {
2019
- // Return cached plugins if already loaded
2020
- if (sandboxedPluginCache.size > 0) {
2021
- return sandboxedPluginCache;
2022
- }
2023
-
2024
2423
  // Check if sandboxing is enabled
2025
2424
  if (!deps.sandboxEnabled) {
2026
2425
  return sandboxedPluginCache;
@@ -2033,6 +2432,8 @@ export class EmDashRuntime {
2033
2432
  {
2034
2433
  db,
2035
2434
  beforeContentWrite: () => assertMediaUsageActivationWriteAllowed(db),
2435
+ taxonomyWrite: createTaxonomyAccessWithWrite(db),
2436
+ now: deps.now,
2036
2437
  mediaStorage: mediaStorage
2037
2438
  ? {
2038
2439
  upload: (opts) =>
@@ -2041,6 +2442,7 @@ export class EmDashRuntime {
2041
2442
  body: opts.body,
2042
2443
  contentType: opts.contentType,
2043
2444
  }),
2445
+ download: (key) => mediaStorage.download(key),
2044
2446
  delete: (key) => mediaStorage.delete(key),
2045
2447
  }
2046
2448
  : undefined,
@@ -2089,21 +2491,49 @@ export class EmDashRuntime {
2089
2491
  }
2090
2492
 
2091
2493
  try {
2494
+ const adminPages = entry.adminPages?.map((page) => ({
2495
+ path: page.path,
2496
+ label: page.label ?? page.path,
2497
+ icon: page.icon,
2498
+ }));
2499
+ const adminWidgets: PluginDashboardWidget[] | undefined = entry.adminWidgets?.map(
2500
+ (widget) => ({
2501
+ id: widget.id,
2502
+ title: widget.title,
2503
+ size:
2504
+ widget.size === "full" || widget.size === "half" || widget.size === "third"
2505
+ ? widget.size
2506
+ : undefined,
2507
+ }),
2508
+ );
2509
+ const capabilities = normalizePluginCapabilities(entry.capabilities ?? []);
2510
+
2092
2511
  // Build manifest from entry's declared config
2093
2512
  const manifest: PluginManifest = {
2094
2513
  id: entry.id,
2095
2514
  version: entry.version,
2096
- capabilities: entry.capabilities ?? [],
2515
+ capabilities,
2097
2516
  allowedHosts: entry.allowedHosts ?? [],
2098
2517
  storage: entry.storage ?? {},
2099
- hooks: entry.hooks ?? [],
2518
+ // Descriptors built before hook metadata was emitted must keep
2519
+ // working. Invoking an absent hook is a no-op in both runners.
2520
+ hooks: entry.hooks ?? [...HOOK_NAMES],
2100
2521
  routes: entry.routes ?? [],
2101
- admin: {},
2522
+ admin: {
2523
+ pages: adminPages,
2524
+ widgets: adminWidgets,
2525
+ settingsSchema: entry.settingsSchema,
2526
+ portableTextBlocks: entry.portableTextBlocks,
2527
+ fieldWidgets: entry.fieldWidgets,
2528
+ editorPanels: entry.editorPanels,
2529
+ editorActions: entry.editorActions,
2530
+ },
2102
2531
  mcp: entry.mcp,
2103
2532
  };
2104
2533
 
2105
2534
  const plugin = await sandboxRunner.load(manifest, entry.code);
2106
2535
  sandboxedPluginCache.set(pluginKey, plugin);
2536
+ sandboxedManifestCache.set(pluginKey, manifest);
2107
2537
  console.log(
2108
2538
  `EmDash: Loaded sandboxed plugin ${pluginKey} with capabilities: [${manifest.capabilities.join(", ")}]`,
2109
2539
  );
@@ -2161,6 +2591,8 @@ export class EmDashRuntime {
2161
2591
  {
2162
2592
  db,
2163
2593
  beforeContentWrite: () => assertMediaUsageActivationWriteAllowed(db),
2594
+ taxonomyWrite: createTaxonomyAccessWithWrite(db),
2595
+ now: deps.now,
2164
2596
  mediaStorage: {
2165
2597
  upload: (opts) =>
2166
2598
  storage.upload({
@@ -2168,6 +2600,7 @@ export class EmDashRuntime {
2168
2600
  body: opts.body,
2169
2601
  contentType: opts.contentType,
2170
2602
  }),
2603
+ download: (key) => storage.download(key),
2171
2604
  delete: (key) => storage.delete(key),
2172
2605
  },
2173
2606
  },
@@ -2213,6 +2646,7 @@ export class EmDashRuntime {
2213
2646
 
2214
2647
  const loaded = await sandboxRunner.load(bundle.manifest, bundle.backendCode);
2215
2648
  cache.set(pluginKey, loaded);
2649
+ sandboxedManifestCache.set(pluginKey, bundle.manifest);
2216
2650
  keySet.add(pluginKey);
2217
2651
 
2218
2652
  // Cache manifest admin config for getManifest()
@@ -2222,6 +2656,8 @@ export class EmDashRuntime {
2222
2656
  admin: bundle.manifest.admin,
2223
2657
  mcp: bundle.manifest.mcp,
2224
2658
  storage: bundle.manifest.storage,
2659
+ allowedHosts: bundle.manifest.allowedHosts,
2660
+ capabilities: bundle.manifest.capabilities,
2225
2661
  });
2226
2662
 
2227
2663
  // Cache route metadata from manifest for auth decisions
@@ -2295,6 +2731,8 @@ export class EmDashRuntime {
2295
2731
  admin: bundle.manifest.admin,
2296
2732
  mcp: bundle.manifest.mcp,
2297
2733
  storage: bundle.manifest.storage,
2734
+ allowedHosts: bundle.manifest.allowedHosts,
2735
+ capabilities: bundle.manifest.capabilities,
2298
2736
  });
2299
2737
  if (bundle.manifest.routes.length > 0) {
2300
2738
  const routeMeta = new Map<string, RouteMeta>();
@@ -2331,6 +2769,8 @@ export class EmDashRuntime {
2331
2769
  w.size === "full" || w.size === "half" || w.size === "third" ? w.size : undefined,
2332
2770
  })),
2333
2771
  settingsSchema: bundle.manifest.admin?.settingsSchema,
2772
+ editorPanels: bundle.manifest.admin?.editorPanels,
2773
+ editorActions: bundle.manifest.admin?.editorActions,
2334
2774
  });
2335
2775
  resolved.push(adapted);
2336
2776
  console.log(
@@ -2464,6 +2904,8 @@ export class EmDashRuntime {
2464
2904
  fieldTypes: string[];
2465
2905
  elements?: Element[];
2466
2906
  }>;
2907
+ editorPanels?: PluginManifest["admin"]["editorPanels"];
2908
+ editorActions?: PluginManifest["admin"]["editorActions"];
2467
2909
  }
2468
2910
  > = {};
2469
2911
 
@@ -2475,10 +2917,13 @@ export class EmDashRuntime {
2475
2917
  const hasAdminEntry = !!plugin.admin?.entry;
2476
2918
  const hasAdminPages = (plugin.admin?.pages?.length ?? 0) > 0;
2477
2919
  const hasWidgets = (plugin.admin?.widgets?.length ?? 0) > 0;
2920
+ const hasEditorExtensions =
2921
+ (plugin.admin?.editorPanels?.length ?? 0) > 0 ||
2922
+ (plugin.admin?.editorActions?.length ?? 0) > 0;
2478
2923
  let adminMode: "react" | "blocks" | "none" = "none";
2479
2924
  if (hasAdminEntry) {
2480
2925
  adminMode = "react";
2481
- } else if (hasAdminPages || hasWidgets) {
2926
+ } else if (hasAdminPages || hasWidgets || hasEditorExtensions) {
2482
2927
  adminMode = "blocks";
2483
2928
  }
2484
2929
 
@@ -2490,6 +2935,8 @@ export class EmDashRuntime {
2490
2935
  dashboardWidgets: plugin.admin?.widgets ?? [],
2491
2936
  portableTextBlocks: plugin.admin?.portableTextBlocks,
2492
2937
  fieldWidgets: plugin.admin?.fieldWidgets,
2938
+ editorPanels: plugin.admin?.editorPanels,
2939
+ editorActions: plugin.admin?.editorActions,
2493
2940
  };
2494
2941
  }
2495
2942
 
@@ -2500,6 +2947,8 @@ export class EmDashRuntime {
2500
2947
 
2501
2948
  const hasAdminPages = (entry.adminPages?.length ?? 0) > 0;
2502
2949
  const hasWidgets = (entry.adminWidgets?.length ?? 0) > 0;
2950
+ const hasEditorExtensions =
2951
+ (entry.editorPanels?.length ?? 0) > 0 || (entry.editorActions?.length ?? 0) > 0;
2503
2952
 
2504
2953
  manifestPlugins[entry.id] = {
2505
2954
  version: entry.version,
@@ -2509,11 +2958,13 @@ export class EmDashRuntime {
2509
2958
  // contribute portableTextBlocks/fieldWidgets with adminMode "none" —
2510
2959
  // the admin reads those from the manifest regardless, so don't gate
2511
2960
  // admin contributions on `adminMode`.
2512
- adminMode: hasAdminPages || hasWidgets ? "blocks" : "none",
2961
+ adminMode: hasAdminPages || hasWidgets || hasEditorExtensions ? "blocks" : "none",
2513
2962
  adminPages: entry.adminPages ?? [],
2514
2963
  dashboardWidgets: entry.adminWidgets ?? [],
2515
2964
  portableTextBlocks: entry.portableTextBlocks,
2516
2965
  fieldWidgets: entry.fieldWidgets,
2966
+ editorPanels: entry.editorPanels,
2967
+ editorActions: entry.editorActions,
2517
2968
  };
2518
2969
  }
2519
2970
 
@@ -2529,14 +2980,18 @@ export class EmDashRuntime {
2529
2980
  const widgets = meta.admin?.widgets;
2530
2981
  const hasAdminPages = (pages?.length ?? 0) > 0;
2531
2982
  const hasWidgets = (widgets?.length ?? 0) > 0;
2983
+ const hasEditorExtensions =
2984
+ (meta.admin?.editorPanels?.length ?? 0) > 0 || (meta.admin?.editorActions?.length ?? 0) > 0;
2532
2985
 
2533
2986
  manifestPlugins[pluginId] = {
2534
2987
  version: meta.version,
2535
2988
  enabled,
2536
2989
  sandboxed: true,
2537
- adminMode: hasAdminPages || hasWidgets ? "blocks" : "none",
2990
+ adminMode: hasAdminPages || hasWidgets || hasEditorExtensions ? "blocks" : "none",
2538
2991
  adminPages: pages ?? [],
2539
2992
  dashboardWidgets: widgets ?? [],
2993
+ editorPanels: meta.admin?.editorPanels,
2994
+ editorActions: meta.admin?.editorActions,
2540
2995
  };
2541
2996
  }
2542
2997
 
@@ -2606,8 +3061,13 @@ export class EmDashRuntime {
2606
3061
  }
2607
3062
  : undefined;
2608
3063
 
3064
+ const registryConfig = resolveRegistryConfigForSandbox({
3065
+ registry: this.config.registry,
3066
+ experimentalRegistry: this.config.experimental?.registry,
3067
+ });
2609
3068
  const { registry, error: registryConfigurationError } = resolveManifestRegistryConfig(
2610
- this.config.experimental?.registry,
3069
+ registryConfig.input,
3070
+ { fieldPrefix: registryConfig.fieldPrefix },
2611
3071
  );
2612
3072
  if (registryConfigurationError) {
2613
3073
  console.error(
@@ -2740,7 +3200,10 @@ export class EmDashRuntime {
2740
3200
  *
2741
3201
  * No-op when no draft exists or the response is an error.
2742
3202
  */
2743
- private async hydrateDraftData<T>(result: T): Promise<T> {
3203
+ private async hydrateDraftData<T>(
3204
+ result: T,
3205
+ options: { includeStagedSlug?: boolean; strict?: boolean } = {},
3206
+ ): Promise<T> {
2744
3207
  if (!result || typeof result !== "object") return result;
2745
3208
  // eslint-disable-next-line typescript/no-unsafe-type-assertion -- shape probed below
2746
3209
  const r = result as {
@@ -2753,7 +3216,10 @@ export class EmDashRuntime {
2753
3216
  if (!draftRevisionId) return result;
2754
3217
  try {
2755
3218
  const revision = await new RevisionRepository(this.db).findById(draftRevisionId);
2756
- if (!revision) return result;
3219
+ if (!revision) {
3220
+ if (options.strict) throw new Error(`Draft revision not found: ${draftRevisionId}`);
3221
+ return result;
3222
+ }
2757
3223
  const liveData =
2758
3224
  item.data && typeof item.data === "object"
2759
3225
  ? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed to object above
@@ -2780,10 +3246,18 @@ export class EmDashRuntime {
2780
3246
  // eslint-disable-next-line typescript/no-unsafe-type-assertion -- shape preserved; result has been narrowed to the {success,data:{item}} envelope
2781
3247
  data: {
2782
3248
  ...r.data,
2783
- item: { ...item, data: mergedData, liveData },
3249
+ item: {
3250
+ ...item,
3251
+ ...(options.includeStagedSlug && typeof revision.data._slug === "string"
3252
+ ? { slug: revision.data._slug }
3253
+ : {}),
3254
+ data: mergedData,
3255
+ liveData,
3256
+ },
2784
3257
  },
2785
3258
  };
2786
3259
  } catch (error) {
3260
+ if (options.strict) throw error;
2787
3261
  // Non-fatal — fall back to the unhydrated response. Log so the
2788
3262
  // failure isn't completely silent (the response will look stale
2789
3263
  // to the caller but no error is raised).
@@ -2796,6 +3270,7 @@ export class EmDashRuntime {
2796
3270
  collection: string,
2797
3271
  body: {
2798
3272
  data: Record<string, unknown>;
3273
+ seo?: ContentWriteInput["seo"];
2799
3274
  slug?: string | null;
2800
3275
  status?: string;
2801
3276
  authorId?: string;
@@ -2805,12 +3280,61 @@ export class EmDashRuntime {
2805
3280
  taxonomies?: Record<string, string[]>;
2806
3281
  actor?: ActorInfo;
2807
3282
  },
3283
+ options: { skipSaveHooks?: boolean; excludeAfterSavePluginId?: string } = {},
2808
3284
  ) {
2809
3285
  const actor = body.actor ? { ...body.actor } : undefined;
3286
+ let locale: string;
3287
+ try {
3288
+ locale = resolveContentCreateLocale(body.locale);
3289
+ } catch (error) {
3290
+ return {
3291
+ success: false as const,
3292
+ error: {
3293
+ code: "VALIDATION_ERROR",
3294
+ message: error instanceof Error ? error.message : "Invalid locale",
3295
+ },
3296
+ };
3297
+ }
3298
+
3299
+ let translationSource: ContentItemInternal | null = null;
3300
+ let sharedFieldSlugs: string[] = [];
3301
+ if (body.translationOf) {
3302
+ const repo = new ContentRepository(this.db);
3303
+ const source = await repo.findById(collection, body.translationOf);
3304
+ if (!source) {
3305
+ return {
3306
+ success: false as const,
3307
+ error: { code: "NOT_FOUND", message: "Translation source content not found" },
3308
+ };
3309
+ }
3310
+ translationSource = source;
3311
+ sharedFieldSlugs = (
3312
+ await this.db
3313
+ .selectFrom("_emdash_fields as field")
3314
+ .innerJoin("_emdash_collections as collection", "collection.id", "field.collection_id")
3315
+ .select("field.slug")
3316
+ .where("collection.slug", "=", collection)
3317
+ .where("field.translatable", "=", 0)
3318
+ .execute()
3319
+ ).map((field) => field.slug);
3320
+ const siblings = await repo.findTranslations(
3321
+ collection,
3322
+ source.translationGroup ?? source.id,
3323
+ );
3324
+ if (siblings.some((sibling) => sibling.locale?.toLowerCase() === locale.toLowerCase())) {
3325
+ return {
3326
+ success: false as const,
3327
+ error: {
3328
+ code: "CONFLICT",
3329
+ message: `Translation already exists in locale "${locale}" for this content item`,
3330
+ },
3331
+ };
3332
+ }
3333
+ }
2810
3334
 
2811
3335
  // Run beforeSave hooks (trusted plugins)
2812
3336
  let processedData = body.data;
2813
- if (this.hooks.hasHooks("content:beforeSave")) {
3337
+ if (!options.skipSaveHooks && this.hooks.hasHooks("content:beforeSave")) {
2814
3338
  try {
2815
3339
  const hookResult = await this.hooks.runContentBeforeSave(
2816
3340
  body.data,
@@ -2825,16 +3349,16 @@ export class EmDashRuntime {
2825
3349
  }
2826
3350
  }
2827
3351
 
2828
- // Run beforeSave hooks (sandboxed plugins)
2829
- const sandboxResult = await this.runSandboxedBeforeSave(
2830
- processedData,
2831
- collection,
2832
- true,
2833
- undefined,
2834
- actor,
2835
- );
2836
- if (!sandboxResult.success) return sandboxResult;
2837
- processedData = sandboxResult.data;
3352
+ if (translationSource) {
3353
+ processedData = { ...processedData };
3354
+ for (const slug of sharedFieldSlugs) {
3355
+ if (Object.hasOwn(translationSource.data, slug)) {
3356
+ processedData[slug] = translationSource.data[slug];
3357
+ } else {
3358
+ delete processedData[slug];
3359
+ }
3360
+ }
3361
+ }
2838
3362
 
2839
3363
  // Normalize media fields (fill dimensions, storageKey, etc.)
2840
3364
  processedData = await this.normalizeMediaFields(collection, processedData);
@@ -2857,6 +3381,7 @@ export class EmDashRuntime {
2857
3381
  const result = await handleContentCreate(this.db, collection, {
2858
3382
  ...body,
2859
3383
  data: processedData,
3384
+ locale,
2860
3385
  authorId: body.authorId,
2861
3386
  bylines: body.bylines,
2862
3387
  });
@@ -2865,8 +3390,14 @@ export class EmDashRuntime {
2865
3390
  }
2866
3391
 
2867
3392
  // Run afterSave hooks (fire-and-forget)
2868
- if (result.success && result.data) {
2869
- this.runAfterSaveHooks(contentItemToRecord(result.data.item), collection, true, actor);
3393
+ if (!options.skipSaveHooks && result.success && result.data) {
3394
+ this.runAfterSaveHooks(
3395
+ contentItemToRecord(result.data.item),
3396
+ collection,
3397
+ true,
3398
+ actor,
3399
+ options.excludeAfterSavePluginId,
3400
+ );
2870
3401
  }
2871
3402
 
2872
3403
  return result;
@@ -2928,6 +3459,13 @@ export class EmDashRuntime {
2928
3459
  }
2929
3460
  const { _rev: _discardedRev, actor: _discardedActor, ...bodyWithoutRev } = body;
2930
3461
 
3462
+ // Loaded once and threaded through normalization, the stale-key drop and the draft
3463
+ // merge below: each of those needs the field list and the registry does not cache.
3464
+ const collectionInfo = bodyWithoutRev.data
3465
+ ? await this.schemaRegistry.getCollectionWithFields(collection).catch(() => null)
3466
+ : null;
3467
+ const knownFieldSlugs = new Set((collectionInfo?.fields ?? []).map((f) => f.slug));
3468
+
2931
3469
  // Run beforeSave hooks if data is provided
2932
3470
  let processedData = bodyWithoutRev.data;
2933
3471
  if (bodyWithoutRev.data) {
@@ -2946,19 +3484,19 @@ export class EmDashRuntime {
2946
3484
  }
2947
3485
  }
2948
3486
 
2949
- // Run sandboxed beforeSave hooks
2950
- const sandboxResult = await this.runSandboxedBeforeSave(
2951
- processedData!,
2952
- collection,
2953
- false,
2954
- resolvedItem?.id,
2955
- actor,
2956
- );
2957
- if (!sandboxResult.success) return sandboxResult;
2958
- processedData = sandboxResult.data;
2959
-
2960
3487
  // Normalize media fields (fill dimensions, storageKey, etc.)
2961
- processedData = await this.normalizeMediaFields(collection, processedData);
3488
+ processedData = await this.normalizeMediaFields(collection, processedData!, collectionInfo);
3489
+
3490
+ // Drop unknown field keys the entry already stores (e.g. a deleted field
3491
+ // stranded in a draft revision) before validation, while still rejecting
3492
+ // unknown keys the entry has never stored.
3493
+ if (collectionInfo?.fields) {
3494
+ processedData = await this.dropUnknownKeysAlreadyStored(
3495
+ processedData,
3496
+ resolvedItem,
3497
+ knownFieldSlugs,
3498
+ );
3499
+ }
2962
3500
 
2963
3501
  // Validate field-level shape BEFORE the draft-revision write so
2964
3502
  // invalid updates can't silently land in revision history.
@@ -2980,7 +3518,6 @@ export class EmDashRuntime {
2980
3518
  let usesDraftRevisions = false;
2981
3519
  let draftStorageChanged = false;
2982
3520
  if (processedData) {
2983
- const collectionInfo = await this.schemaRegistry.getCollectionWithFields(collection);
2984
3521
  if (collectionInfo?.supports?.includes("revisions")) {
2985
3522
  usesDraftRevisions = true;
2986
3523
  const revisionRepo = new RevisionRepository(this.db);
@@ -2995,7 +3532,12 @@ export class EmDashRuntime {
2995
3532
  baseData = existing.data;
2996
3533
  }
2997
3534
 
2998
- const mergedData = { ...baseData, ...processedData };
3535
+ // Written without the keys the collection has no field for, so an entry
3536
+ // carrying a deleted field's value sheds it on its next save instead of
3537
+ // carrying it through every revision that follows.
3538
+ const mergedData = collectionInfo?.fields
3539
+ ? keepKnownFields({ ...baseData, ...processedData }, knownFieldSlugs)
3540
+ : { ...baseData, ...processedData };
2999
3541
  if (bodyWithoutRev.slug !== undefined) {
3000
3542
  mergedData._slug = bodyWithoutRev.slug;
3001
3543
  }
@@ -3149,21 +3691,12 @@ export class EmDashRuntime {
3149
3691
  }
3150
3692
  }
3151
3693
 
3152
- // Run sandboxed beforeDelete hooks
3153
- const sandboxAllowed = await this.runSandboxedBeforeDelete(id, collection);
3154
- if (!sandboxAllowed) {
3155
- return {
3156
- success: false,
3157
- error: {
3158
- code: "DELETE_BLOCKED",
3159
- message: "Delete blocked by sandboxed plugin hook",
3160
- },
3161
- };
3162
- }
3694
+ const policyRejectionRevision = await this.getScheduledPolicyRejectionRevision(collection, id);
3163
3695
 
3164
3696
  // Delete the content
3165
3697
  const result = await handleContentDelete(this.db, collection, id);
3166
3698
  if (result.success) {
3699
+ await this.clearScheduledPolicyRejection(collection, result.data.id, policyRejectionRevision);
3167
3700
  await this.refreshContentUsageAfterSuccessfulWrite(collection, [result.data.id]);
3168
3701
  }
3169
3702
 
@@ -3186,23 +3719,38 @@ export class EmDashRuntime {
3186
3719
  return handleContentListTrashed(this.db, collection, params);
3187
3720
  }
3188
3721
 
3189
- async handleContentRestore(collection: string, id: string) {
3190
- const result = await handleContentRestore(this.db, collection, id);
3722
+ async handleContentRestore(
3723
+ collection: string,
3724
+ id: string,
3725
+ options: {
3726
+ _rev?: string;
3727
+ origin?: ContentActionOrigin;
3728
+ pluginInvocationId?: string;
3729
+ } = {},
3730
+ ) {
3731
+ const result = await handleContentRestore(this.db, collection, id, { _rev: options._rev });
3191
3732
  if (result.success && result.data) {
3192
3733
  await this.refreshContentUsageAfterSuccessfulWrite(collection, [result.data.item.id]);
3193
3734
  }
3194
3735
 
3195
3736
  // Run afterRestore hooks (fire-and-forget)
3196
3737
  if (result.success) {
3197
- this.runAfterRestoreHooks(contentItemToRecord(result.data.item), collection);
3738
+ this.runAfterRestoreHooks(
3739
+ contentItemToRecord(result.data.item),
3740
+ collection,
3741
+ options.origin?.source === "plugin" ? options.origin.pluginId : undefined,
3742
+ options.pluginInvocationId,
3743
+ );
3198
3744
  }
3199
3745
 
3200
3746
  return result;
3201
3747
  }
3202
3748
 
3203
3749
  async handleContentPermanentDelete(collection: string, id: string) {
3750
+ const policyRejectionRevision = await this.getScheduledPolicyRejectionRevision(collection, id);
3204
3751
  const result = await handleContentPermanentDelete(this.db, collection, id);
3205
3752
  if (result.success) {
3753
+ await this.clearScheduledPolicyRejection(collection, result.data.id, policyRejectionRevision);
3206
3754
  await this.deleteContentUsageAfterSuccessfulPermanentDelete(collection, result.data.id);
3207
3755
  }
3208
3756
 
@@ -3230,76 +3778,565 @@ export class EmDashRuntime {
3230
3778
  // Publishing & Scheduling Handlers
3231
3779
  // =========================================================================
3232
3780
 
3233
- async handleContentPublish(
3234
- collection: string,
3235
- id: string,
3236
- options: {
3237
- publishedAt?: string;
3238
- requireScheduledDue?: boolean;
3239
- expectedScheduledAt?: string;
3240
- _rev?: string;
3241
- } = {},
3242
- ) {
3243
- const result = await handleContentPublish(this.db, collection, id, options);
3244
- if (result.success && result.data) {
3245
- const { item } = result.data;
3246
- await this.refreshContentUsageAfterSuccessfulWrite(collection, [
3247
- item.id,
3248
- ...(await this.findSyncedSiblingsForUsageRefresh(
3249
- collection,
3250
- item.id,
3251
- item.translationGroup,
3252
- item.data,
3253
- { absentAsCleared: true },
3254
- )),
3255
- ]);
3256
- }
3257
-
3258
- // Run afterPublish hooks (fire-and-forget)
3259
- if (result.success && result.data) {
3260
- this.runAfterPublishHooks(contentItemToRecord(result.data.item), collection);
3781
+ private pluginVersionedResult(
3782
+ result:
3783
+ | { success: true; data: { item: ContentItemInternal; _rev?: string } }
3784
+ | { success: false; error: { code: string; message: string } },
3785
+ ): VersionedContentItem {
3786
+ if (!result.success) {
3787
+ throw Object.assign(new Error(result.error.message), { code: result.error.code });
3261
3788
  }
3262
-
3263
- return result;
3789
+ if (!result.data._rev) throw new Error("Content action returned no revision");
3790
+ return { item: toPluginContentItem(result.data.item), _rev: result.data._rev };
3264
3791
  }
3265
3792
 
3266
- async handleContentUnpublish(collection: string, id: string, options: { _rev?: string } = {}) {
3267
- const result = await handleContentUnpublish(this.db, collection, id, options);
3268
- if (result.success && result.data) {
3269
- await this.refreshContentUsageAfterSuccessfulWrite(collection, [result.data.item.id]);
3270
- }
3271
-
3272
- // Run afterUnpublish hooks (deferred past the response via after())
3273
- if (result.success && result.data) {
3274
- this.runAfterUnpublishHooks(contentItemToRecord(result.data.item), collection);
3793
+ private async runPluginContentAction<T>(
3794
+ pluginId: string,
3795
+ action: string,
3796
+ collection: string,
3797
+ id: string,
3798
+ fn: (resolvedId: string) => Promise<T>,
3799
+ invocationId?: string,
3800
+ invalidateContentCache?: PluginContentCacheInvalidator,
3801
+ ): Promise<T> {
3802
+ let invocationInvalidator: PluginContentCacheInvalidator | undefined;
3803
+ if (invocationId) {
3804
+ const invocationKey = this.pluginInvocationKey(pluginId, invocationId);
3805
+ if (
3806
+ !this.activePluginInvocations.has(invocationKey) &&
3807
+ !this.releasedPluginInvocations.has(invocationKey)
3808
+ ) {
3809
+ throw Object.assign(new Error("Plugin content action invocation has expired"), {
3810
+ code: "CONTENT_ACTION_INVOCATION_EXPIRED",
3811
+ });
3812
+ }
3813
+ invocationInvalidator = this.pluginInvocationCacheInvalidators.get(invocationKey);
3275
3814
  }
3276
-
3815
+ await assertMediaUsageActivationWriteAllowed(this.db);
3816
+ const repo = new ContentRepository(this.db);
3817
+ const item =
3818
+ action === "restore"
3819
+ ? await repo.findByIdOrSlugIncludingTrashed(collection, id)
3820
+ : await repo.findByIdOrSlug(collection, id);
3821
+ const resolvedId = item?.id ?? id;
3822
+ const key = this.pluginContentActionKey(collection, resolvedId);
3823
+ if ((this.activePluginContentActions.get(key) ?? 0) > 0) {
3824
+ throw Object.assign(new Error("Plugin content action re-entered itself"), {
3825
+ code: "CONTENT_ACTION_REENTRANT",
3826
+ });
3827
+ }
3828
+ this.retainPluginContentAction(key);
3829
+ try {
3830
+ const result = await fn(resolvedId);
3831
+ const invalidator =
3832
+ invalidateContentCache ?? invocationInvalidator ?? this.pluginContentCacheInvalidator;
3833
+ if (invalidator) {
3834
+ try {
3835
+ await invalidator([collection, resolvedId]);
3836
+ } catch (error) {
3837
+ console.error(
3838
+ `[plugin-content-action] Cache invalidation failed for ${collection}/${resolvedId}:`,
3839
+ error,
3840
+ );
3841
+ }
3842
+ }
3843
+ return result;
3844
+ } finally {
3845
+ this.releasePluginContentAction(key);
3846
+ }
3847
+ }
3848
+
3849
+ private pluginContentActionKey(collection: string, id: string): string {
3850
+ return JSON.stringify([collection, id]);
3851
+ }
3852
+
3853
+ private retainPluginContentAction(key: string): void {
3854
+ this.activePluginContentActions.set(key, (this.activePluginContentActions.get(key) ?? 0) + 1);
3855
+ }
3856
+
3857
+ private releasePluginContentAction(key: string): void {
3858
+ const remaining = (this.activePluginContentActions.get(key) ?? 1) - 1;
3859
+ if (remaining > 0) this.activePluginContentActions.set(key, remaining);
3860
+ else this.activePluginContentActions.delete(key);
3861
+ }
3862
+
3863
+ private async pluginGetVersioned(
3864
+ _pluginId: string,
3865
+ collection: string,
3866
+ id: string,
3867
+ ): Promise<VersionedContentItem | null> {
3868
+ const result = await this.handleContentGet(collection, id);
3869
+ if (!result.success) {
3870
+ if (result.error.code === "NOT_FOUND") return null;
3871
+ throw Object.assign(new Error(result.error.message), { code: result.error.code });
3872
+ }
3873
+ if (!result.data._rev) throw new Error("Content read returned no revision");
3874
+ return { item: toPluginContentItem(result.data.item), _rev: result.data._rev };
3875
+ }
3876
+
3877
+ private async pluginGetTrashedVersioned(
3878
+ _pluginId: string,
3879
+ collection: string,
3880
+ id: string,
3881
+ ): Promise<VersionedContentItem | null> {
3882
+ const result = await this.handleContentGetIncludingTrashed(collection, id);
3883
+ if (!result.success) {
3884
+ if (result.error.code === "NOT_FOUND") return null;
3885
+ throw Object.assign(new Error(result.error.message), { code: result.error.code });
3886
+ }
3887
+ if (!(await new ContentRepository(this.db).isTrashed(collection, result.data.item.id))) {
3888
+ return null;
3889
+ }
3890
+ if (!result.data._rev) throw new Error("Trashed content read returned no revision");
3891
+ return { item: toPluginContentItem(result.data.item), _rev: result.data._rev };
3892
+ }
3893
+
3894
+ private pluginPublish(
3895
+ pluginId: string,
3896
+ collection: string,
3897
+ id: string,
3898
+ options: { _rev: string },
3899
+ invocationId?: string,
3900
+ invalidateContentCache?: PluginContentCacheInvalidator,
3901
+ ): Promise<VersionedContentItem> {
3902
+ return this.runPluginContentAction(
3903
+ pluginId,
3904
+ "publish",
3905
+ collection,
3906
+ id,
3907
+ async (resolvedId) =>
3908
+ this.pluginVersionedResult(
3909
+ await this.handleContentPublish(collection, resolvedId, {
3910
+ _rev: options._rev,
3911
+ origin: { source: "plugin", pluginId },
3912
+ pluginInvocationId: invocationId,
3913
+ }),
3914
+ ),
3915
+ invocationId,
3916
+ invalidateContentCache,
3917
+ );
3918
+ }
3919
+
3920
+ private pluginUnpublish(
3921
+ pluginId: string,
3922
+ collection: string,
3923
+ id: string,
3924
+ options: { _rev: string },
3925
+ invocationId?: string,
3926
+ invalidateContentCache?: PluginContentCacheInvalidator,
3927
+ ): Promise<VersionedContentItem> {
3928
+ return this.runPluginContentAction(
3929
+ pluginId,
3930
+ "unpublish",
3931
+ collection,
3932
+ id,
3933
+ async (resolvedId) =>
3934
+ this.pluginVersionedResult(
3935
+ await this.handleContentUnpublish(collection, resolvedId, {
3936
+ _rev: options._rev,
3937
+ origin: { source: "plugin", pluginId },
3938
+ pluginInvocationId: invocationId,
3939
+ }),
3940
+ ),
3941
+ invocationId,
3942
+ invalidateContentCache,
3943
+ );
3944
+ }
3945
+
3946
+ private pluginSchedule(
3947
+ pluginId: string,
3948
+ collection: string,
3949
+ id: string,
3950
+ options: { scheduledAt: string; _rev: string },
3951
+ invocationId?: string,
3952
+ invalidateContentCache?: PluginContentCacheInvalidator,
3953
+ ): Promise<VersionedContentItem> {
3954
+ return this.runPluginContentAction(
3955
+ pluginId,
3956
+ "schedule",
3957
+ collection,
3958
+ id,
3959
+ async (resolvedId) =>
3960
+ this.pluginVersionedResult(
3961
+ await this.handleContentSchedule(collection, resolvedId, options.scheduledAt, {
3962
+ _rev: options._rev,
3963
+ origin: { source: "plugin", pluginId },
3964
+ pluginInvocationId: invocationId,
3965
+ }),
3966
+ ),
3967
+ invocationId,
3968
+ invalidateContentCache,
3969
+ );
3970
+ }
3971
+
3972
+ private pluginUnschedule(
3973
+ pluginId: string,
3974
+ collection: string,
3975
+ id: string,
3976
+ options: { _rev: string },
3977
+ invocationId?: string,
3978
+ invalidateContentCache?: PluginContentCacheInvalidator,
3979
+ ): Promise<VersionedContentItem> {
3980
+ return this.runPluginContentAction(
3981
+ pluginId,
3982
+ "unschedule",
3983
+ collection,
3984
+ id,
3985
+ async (resolvedId) =>
3986
+ this.pluginVersionedResult(
3987
+ await this.handleContentUnschedule(collection, resolvedId, {
3988
+ ...options,
3989
+ origin: { source: "plugin", pluginId },
3990
+ pluginInvocationId: invocationId,
3991
+ }),
3992
+ ),
3993
+ invocationId,
3994
+ invalidateContentCache,
3995
+ );
3996
+ }
3997
+
3998
+ private pluginRestore(
3999
+ pluginId: string,
4000
+ collection: string,
4001
+ id: string,
4002
+ options: { _rev: string },
4003
+ invocationId?: string,
4004
+ invalidateContentCache?: PluginContentCacheInvalidator,
4005
+ ): Promise<VersionedContentItem> {
4006
+ return this.runPluginContentAction(
4007
+ pluginId,
4008
+ "restore",
4009
+ collection,
4010
+ id,
4011
+ async (resolvedId) =>
4012
+ this.pluginVersionedResult(
4013
+ await this.handleContentRestore(collection, resolvedId, {
4014
+ ...options,
4015
+ origin: { source: "plugin", pluginId },
4016
+ pluginInvocationId: invocationId,
4017
+ }),
4018
+ ),
4019
+ invocationId,
4020
+ invalidateContentCache,
4021
+ );
4022
+ }
4023
+
4024
+ private async checkContentPolicy(
4025
+ name: ContentPolicyHookName,
4026
+ collection: string,
4027
+ id: string,
4028
+ options: ContentPolicyMutationOptions,
4029
+ rejectionCode: "PUBLISH_REJECTED" | "SCHEDULE_REJECTED" | "UNPUBLISH_REJECTED",
4030
+ failureCode: "CONTENT_PUBLISH_ERROR" | "CONTENT_SCHEDULE_ERROR" | "CONTENT_UNPUBLISH_ERROR",
4031
+ scheduledAt?: string,
4032
+ ): Promise<ContentPolicyCheck> {
4033
+ let current = await handleContentGet(this.db, collection, id);
4034
+ if (!current.success) {
4035
+ return {
4036
+ allowed: false,
4037
+ revision: options._rev ?? "",
4038
+ error: current.error,
4039
+ };
4040
+ }
4041
+
4042
+ const revision = current.data._rev;
4043
+ if (!revision) {
4044
+ return {
4045
+ allowed: false,
4046
+ revision: options._rev ?? "",
4047
+ error: { code: failureCode, message: "Failed to read content revision" },
4048
+ };
4049
+ }
4050
+ if (options._rev !== undefined && options._rev !== revision) {
4051
+ return {
4052
+ allowed: false,
4053
+ revision,
4054
+ error: { code: "CONFLICT", message: "Revision precondition did not match" },
4055
+ };
4056
+ }
4057
+
4058
+ if (!this.hooks.hasHooks(name)) return { allowed: true, revision };
4059
+ if (name !== "content:beforeUnpublish") {
4060
+ try {
4061
+ current = await this.hydrateDraftData(current, {
4062
+ includeStagedSlug: true,
4063
+ strict: true,
4064
+ });
4065
+ } catch (error) {
4066
+ console.error(`[content-policy] ${name} draft hydration failed:`, error);
4067
+ return {
4068
+ allowed: false,
4069
+ revision,
4070
+ error: { code: failureCode, message: `Failed to read content for ${name} policy` },
4071
+ };
4072
+ }
4073
+ }
4074
+
4075
+ const origin = options.origin ?? { source: "system" };
4076
+ const actor =
4077
+ options.actor &&
4078
+ (origin.source === "api" || origin.source === "mcp" || origin.source === "visual-editor")
4079
+ ? { ...options.actor, source: origin.source }
4080
+ : undefined;
4081
+ try {
4082
+ const decision = await this.hooks.runContentPolicy(name, {
4083
+ content: contentItemToRecord(current.data.item),
4084
+ collection,
4085
+ origin,
4086
+ actor,
4087
+ ...(scheduledAt === undefined ? {} : { scheduledAt }),
4088
+ });
4089
+ if (decision.cancellation) {
4090
+ return {
4091
+ allowed: false,
4092
+ revision,
4093
+ error: { code: rejectionCode, message: decision.cancellation.reason },
4094
+ cancellation: decision.cancellation,
4095
+ };
4096
+ }
4097
+ return { allowed: true, revision };
4098
+ } catch (error) {
4099
+ console.error(`[content-policy] ${name} failed:`, error);
4100
+ return {
4101
+ allowed: false,
4102
+ revision,
4103
+ error: { code: failureCode, message: `Failed to run ${name} policy` },
4104
+ };
4105
+ }
4106
+ }
4107
+
4108
+ private async getScheduledPolicyRejectionRevision(
4109
+ collection: string,
4110
+ id: string,
4111
+ ): Promise<string | undefined> {
4112
+ try {
4113
+ return (
4114
+ await new OptionsRepository(this.db).getVersioned(
4115
+ scheduledPolicyRejectionKey(collection, id),
4116
+ )
4117
+ )?.revision;
4118
+ } catch (error) {
4119
+ console.error(
4120
+ `[content-policy] Failed to read scheduled rejection for ${collection}/${id}:`,
4121
+ error,
4122
+ );
4123
+ return undefined;
4124
+ }
4125
+ }
4126
+
4127
+ private async clearScheduledPolicyRejection(
4128
+ collection: string,
4129
+ id: string,
4130
+ expectedRevision: string | undefined,
4131
+ ): Promise<void> {
4132
+ if (expectedRevision === undefined) return;
4133
+ try {
4134
+ await new OptionsRepository(this.db).compareAndDelete(
4135
+ scheduledPolicyRejectionKey(collection, id),
4136
+ expectedRevision,
4137
+ );
4138
+ } catch (error) {
4139
+ console.error(
4140
+ `[content-policy] Failed to clear scheduled rejection for ${collection}/${id}:`,
4141
+ error,
4142
+ );
4143
+ }
4144
+ }
4145
+
4146
+ private createScheduledPolicyRejection(
4147
+ collection: string,
4148
+ id: string,
4149
+ cancellation: { pluginId: string; reason: string },
4150
+ ): ScheduledPolicyRejection {
4151
+ return {
4152
+ collection,
4153
+ id,
4154
+ pluginId: cancellation.pluginId,
4155
+ reason: cancellation.reason,
4156
+ rejectedAt: (this.runtimeDeps.now?.() ?? new Date()).toISOString(),
4157
+ };
4158
+ }
4159
+
4160
+ async handleContentPublish(
4161
+ collection: string,
4162
+ id: string,
4163
+ options: {
4164
+ publishedAt?: string;
4165
+ requireScheduledDue?: boolean;
4166
+ expectedScheduledAt?: string;
4167
+ _rev?: string;
4168
+ currentTime?: Date;
4169
+ actor?: ActorInfo;
4170
+ origin?: ContentActionOrigin;
4171
+ pluginInvocationId?: string;
4172
+ } = {},
4173
+ ) {
4174
+ const policy = await this.checkContentPolicy(
4175
+ "content:beforePublish",
4176
+ collection,
4177
+ id,
4178
+ options,
4179
+ "PUBLISH_REJECTED",
4180
+ "CONTENT_PUBLISH_ERROR",
4181
+ );
4182
+ if (!policy.allowed) {
4183
+ if (policy.cancellation && options.origin?.source === "scheduler") {
4184
+ const unscheduled = await handleScheduledPolicyRejection(this.db, collection, id, {
4185
+ _rev: policy.revision,
4186
+ rejection: this.createScheduledPolicyRejection(collection, id, policy.cancellation),
4187
+ });
4188
+ if (!unscheduled.success) return unscheduled;
4189
+ await this.refreshContentUsageAfterSuccessfulWrite(collection, [unscheduled.data.item.id]);
4190
+ this.runAfterUnscheduleHooks(contentItemToRecord(unscheduled.data.item), collection);
4191
+ }
4192
+ return { success: false as const, error: policy.error };
4193
+ }
4194
+ const policyRejectionRevision = await this.getScheduledPolicyRejectionRevision(collection, id);
4195
+ const {
4196
+ actor: _actor,
4197
+ origin: _origin,
4198
+ pluginInvocationId: _pluginInvocationId,
4199
+ ...handlerOptions
4200
+ } = options;
4201
+ const result = await handleContentPublish(this.db, collection, id, {
4202
+ ...handlerOptions,
4203
+ _rev: policy.revision,
4204
+ });
4205
+ if (result.success && result.data) {
4206
+ await this.clearScheduledPolicyRejection(
4207
+ collection,
4208
+ result.data.item.id,
4209
+ policyRejectionRevision,
4210
+ );
4211
+ const { item } = result.data;
4212
+ await this.refreshContentUsageAfterSuccessfulWrite(collection, [
4213
+ item.id,
4214
+ ...(await this.findSyncedSiblingsForUsageRefresh(
4215
+ collection,
4216
+ item.id,
4217
+ item.translationGroup,
4218
+ item.data,
4219
+ { absentAsCleared: true },
4220
+ )),
4221
+ ]);
4222
+ }
4223
+
4224
+ // Run afterPublish hooks (fire-and-forget)
4225
+ if (result.success && result.data) {
4226
+ this.runAfterPublishHooks(
4227
+ contentItemToRecord(result.data.item),
4228
+ collection,
4229
+ options.origin?.source === "plugin" ? options.origin.pluginId : undefined,
4230
+ options.pluginInvocationId,
4231
+ );
4232
+ }
4233
+
3277
4234
  return result;
3278
4235
  }
3279
4236
 
3280
- async handleContentSchedule(collection: string, id: string, scheduledAt: string) {
3281
- const result = await handleContentSchedule(this.db, collection, id, scheduledAt);
4237
+ async handleContentUnpublish(
4238
+ collection: string,
4239
+ id: string,
4240
+ options: ContentPolicyMutationOptions = {},
4241
+ ) {
4242
+ const policy = await this.checkContentPolicy(
4243
+ "content:beforeUnpublish",
4244
+ collection,
4245
+ id,
4246
+ options,
4247
+ "UNPUBLISH_REJECTED",
4248
+ "CONTENT_UNPUBLISH_ERROR",
4249
+ );
4250
+ if (!policy.allowed) return { success: false as const, error: policy.error };
4251
+ const result = await handleContentUnpublish(this.db, collection, id, {
4252
+ _rev: policy.revision,
4253
+ });
3282
4254
  if (result.success && result.data) {
3283
4255
  await this.refreshContentUsageAfterSuccessfulWrite(collection, [result.data.item.id]);
3284
4256
  }
3285
4257
 
4258
+ // Run afterUnpublish hooks (deferred past the response via after())
4259
+ if (result.success && result.data) {
4260
+ this.runAfterUnpublishHooks(
4261
+ contentItemToRecord(result.data.item),
4262
+ collection,
4263
+ options.origin?.source === "plugin" ? options.origin.pluginId : undefined,
4264
+ options.pluginInvocationId,
4265
+ );
4266
+ }
4267
+
4268
+ return result;
4269
+ }
4270
+
4271
+ async handleContentSchedule(
4272
+ collection: string,
4273
+ id: string,
4274
+ scheduledAt: string,
4275
+ options: ContentPolicyMutationOptions = {},
4276
+ ) {
4277
+ const policy = await this.checkContentPolicy(
4278
+ "content:beforeSchedule",
4279
+ collection,
4280
+ id,
4281
+ options,
4282
+ "SCHEDULE_REJECTED",
4283
+ "CONTENT_SCHEDULE_ERROR",
4284
+ scheduledAt,
4285
+ );
4286
+ if (!policy.allowed) return { success: false as const, error: policy.error };
4287
+ const policyRejectionRevision = await this.getScheduledPolicyRejectionRevision(collection, id);
4288
+ const result = await handleContentSchedule(
4289
+ this.db,
4290
+ collection,
4291
+ id,
4292
+ scheduledAt,
4293
+ this.runtimeDeps.now?.() ?? new Date(),
4294
+ policy.revision,
4295
+ );
4296
+ if (result.success && result.data) {
4297
+ await this.clearScheduledPolicyRejection(
4298
+ collection,
4299
+ result.data.item.id,
4300
+ policyRejectionRevision,
4301
+ );
4302
+ await this.refreshContentUsageAfterSuccessfulWrite(collection, [result.data.item.id]);
4303
+ }
4304
+
3286
4305
  // Run afterSchedule hooks (fire-and-forget)
3287
4306
  if (result.success && result.data) {
3288
- this.runAfterScheduleHooks(contentItemToRecord(result.data.item), collection);
4307
+ this.runAfterScheduleHooks(
4308
+ contentItemToRecord(result.data.item),
4309
+ collection,
4310
+ options.origin?.source === "plugin" ? options.origin.pluginId : undefined,
4311
+ options.pluginInvocationId,
4312
+ );
3289
4313
  }
3290
4314
 
3291
4315
  return result;
3292
4316
  }
3293
4317
 
3294
- async handleContentUnschedule(collection: string, id: string) {
3295
- const result = await handleContentUnschedule(this.db, collection, id);
4318
+ async handleContentUnschedule(
4319
+ collection: string,
4320
+ id: string,
4321
+ options: {
4322
+ _rev?: string;
4323
+ origin?: ContentActionOrigin;
4324
+ pluginInvocationId?: string;
4325
+ } = {},
4326
+ ) {
4327
+ const result = await handleContentUnschedule(this.db, collection, id, { _rev: options._rev });
3296
4328
  if (result.success && result.data) {
3297
4329
  await this.refreshContentUsageAfterSuccessfulWrite(collection, [result.data.item.id]);
3298
4330
  }
3299
4331
 
3300
4332
  // Run afterUnschedule hooks (fire-and-forget)
3301
4333
  if (result.success && result.data) {
3302
- this.runAfterUnscheduleHooks(contentItemToRecord(result.data.item), collection);
4334
+ this.runAfterUnscheduleHooks(
4335
+ contentItemToRecord(result.data.item),
4336
+ collection,
4337
+ options.origin?.source === "plugin" ? options.origin.pluginId : undefined,
4338
+ options.pluginInvocationId,
4339
+ );
3303
4340
  }
3304
4341
 
3305
4342
  return result;
@@ -3344,6 +4381,33 @@ export class EmDashRuntime {
3344
4381
  return handleMediaGet(this.db, id);
3345
4382
  }
3346
4383
 
4384
+ async handleMediaUpload(input: MediaUploadInput) {
4385
+ if (!this.storage) {
4386
+ return {
4387
+ success: false as const,
4388
+ error: { code: "NO_STORAGE", message: "Storage not configured" },
4389
+ };
4390
+ }
4391
+ const result = await uploadMedia(this.db, this.storage, input, {
4392
+ beforeUpload: async (file) => {
4393
+ if (!this.hooks.hasHooks("media:beforeUpload")) return file;
4394
+ return (await this.hooks.runMediaBeforeUpload(file)).file;
4395
+ },
4396
+ });
4397
+ if (result.success && !result.data.deduplicated && this.hooks.hasHooks("media:afterUpload")) {
4398
+ const item = result.data.item;
4399
+ await this.hooks.runMediaAfterUpload({
4400
+ id: item.id,
4401
+ filename: item.filename,
4402
+ mimeType: item.mimeType,
4403
+ size: item.size,
4404
+ url: item.url,
4405
+ createdAt: item.createdAt,
4406
+ });
4407
+ }
4408
+ return result;
4409
+ }
4410
+
3347
4411
  async handleMediaCreate(input: {
3348
4412
  filename: string;
3349
4413
  mimeType: string;
@@ -3420,6 +4484,10 @@ export class EmDashRuntime {
3420
4484
  return result;
3421
4485
  }
3422
4486
 
4487
+ async handlePluginMediaMetadataUpdate(id: string, patch: MediaMetadataPatch) {
4488
+ return updatePluginMediaMetadata(this.db, id, patch);
4489
+ }
4490
+
3423
4491
  async handleMediaReplaceMetadata(
3424
4492
  id: string,
3425
4493
  expectedStorageKey: string,
@@ -3429,18 +4497,175 @@ export class EmDashRuntime {
3429
4497
  if (result.success) {
3430
4498
  invalidateSiteSettingsCache();
3431
4499
  }
3432
- return result;
4500
+ return result;
4501
+ }
4502
+
4503
+ async handleMediaDelete(id: string) {
4504
+ const result = await handleMediaDelete(this.db, id);
4505
+ // Same reasoning as `handleMediaUpdate`: if the deleted media row
4506
+ // was referenced by a setting, the cached resolved URL now points
4507
+ // at a 404. Invalidation is unconditional on success — cheaper than
4508
+ // querying which settings reference the id.
4509
+ if (result.success) {
4510
+ invalidateSiteSettingsCache();
4511
+ }
4512
+ return result;
4513
+ }
4514
+
4515
+ private commentHooks(): CommentHookRunner {
4516
+ return {
4517
+ runBeforeCreate: (event) => this.hooks.runCommentBeforeCreate(event),
4518
+ runModerate: async (event) => {
4519
+ const result = await this.hooks.invokeExclusiveHook("comment:moderate", event);
4520
+ if (!result) return { status: "pending", reason: "No moderator configured" };
4521
+ if (result.error) {
4522
+ console.error(`[comments] Moderation error (${result.pluginId}):`, result.error.message);
4523
+ return { status: "pending", reason: "Moderation error" };
4524
+ }
4525
+ if (!isModerationDecision(result.result)) {
4526
+ return { status: "pending", reason: "Invalid moderation result" };
4527
+ }
4528
+ return result.result;
4529
+ },
4530
+ fireAfterCreate: (event) => {
4531
+ void this.hooks
4532
+ .runCommentAfterCreate(event)
4533
+ .catch((error) =>
4534
+ console.error(
4535
+ "[comments] afterCreate error:",
4536
+ error instanceof Error ? error.message : error,
4537
+ ),
4538
+ );
4539
+ },
4540
+ fireAfterModerate: (event) => {
4541
+ return this.hooks
4542
+ .runCommentAfterModerate(event)
4543
+ .catch((error) =>
4544
+ console.error(
4545
+ "[comments] afterModerate error:",
4546
+ error instanceof Error ? error.message : error,
4547
+ ),
4548
+ );
4549
+ },
4550
+ };
4551
+ }
4552
+
4553
+ async handleCommentCreate(
4554
+ input: CommentCreateInput,
4555
+ settings: CollectionCommentSettings,
4556
+ contentInfo?: Parameters<typeof createComment>[4],
4557
+ ): Promise<CommentCreateResult | null> {
4558
+ return createComment(this.db, input, settings, this.commentHooks(), contentInfo);
4559
+ }
4560
+
4561
+ async handlePublicCommentSubmission(
4562
+ collection: string,
4563
+ contentId: string,
4564
+ request: Request,
4565
+ user?: UserInfo,
4566
+ ): Promise<Response> {
4567
+ return submitPublicComment(this, collection, contentId, request, user);
4568
+ }
4569
+
4570
+ private async sendCommentApproval(
4571
+ comment: Awaited<ReturnType<CommentRepository["findById"]>>,
4572
+ request?: Request,
4573
+ ) {
4574
+ if (!comment || !this.email) return;
4575
+ try {
4576
+ const adminBaseUrl = await getSiteBaseUrl(
4577
+ this.db,
4578
+ request ?? new Request("https://plugin.invalid/"),
4579
+ this.config,
4580
+ );
4581
+ const content = await lookupContentAuthor(this.db, comment.collection, comment.contentId);
4582
+ if (content?.author) {
4583
+ await sendCommentNotification({
4584
+ email: this.email,
4585
+ comment,
4586
+ contentAuthor: content.author,
4587
+ adminBaseUrl,
4588
+ });
4589
+ }
4590
+ } catch (error) {
4591
+ console.error(
4592
+ "[comments] notification error:",
4593
+ error instanceof Error ? error.message : error,
4594
+ );
4595
+ }
4596
+ }
4597
+
4598
+ private async moderateCommentWithOrigin(
4599
+ id: string,
4600
+ status: CommentStatus,
4601
+ expectedStatus: CommentStatus,
4602
+ origin:
4603
+ | { source: "admin"; userId: string; name: string | null }
4604
+ | { source: "plugin"; pluginId: string },
4605
+ request?: Request,
4606
+ ) {
4607
+ if (this.commentModerationInProgress.has(id)) {
4608
+ const current = await new CommentRepository(this.db).findById(id);
4609
+ if (current && current.status !== expectedStatus) {
4610
+ throw new CommentStatusConflictError(current.status);
4611
+ }
4612
+ throw Object.assign(new Error("Comment moderation is already in progress"), {
4613
+ code: "COMMENT_MODERATION_IN_PROGRESS",
4614
+ });
4615
+ }
4616
+ this.commentModerationInProgress.add(id);
4617
+ try {
4618
+ return await moderateComment(
4619
+ this.db,
4620
+ id,
4621
+ status,
4622
+ expectedStatus,
4623
+ origin,
4624
+ this.commentHooks(),
4625
+ (comment) => this.sendCommentApproval(comment, request),
4626
+ );
4627
+ } finally {
4628
+ this.commentModerationInProgress.delete(id);
4629
+ }
4630
+ }
4631
+
4632
+ async handleCommentModerate(
4633
+ id: string,
4634
+ status: CommentStatus,
4635
+ moderator: { id: string; name: string | null },
4636
+ expectedStatus?: CommentStatus,
4637
+ request?: Request,
4638
+ ) {
4639
+ let expected = expectedStatus;
4640
+ if (!expected) {
4641
+ const current = await new CommentRepository(this.db).findById(id);
4642
+ if (!current || current.status === "trash") return null;
4643
+ expected = current.status;
4644
+ }
4645
+ return this.moderateCommentWithOrigin(
4646
+ id,
4647
+ status,
4648
+ expected,
4649
+ { source: "admin", userId: moderator.id, name: moderator.name },
4650
+ request,
4651
+ );
3433
4652
  }
3434
4653
 
3435
- async handleMediaDelete(id: string) {
3436
- const result = await handleMediaDelete(this.db, id);
3437
- // Same reasoning as `handleMediaUpdate`: if the deleted media row
3438
- // was referenced by a setting, the cached resolved URL now points
3439
- // at a 404. Invalidation is unconditional on success — cheaper than
3440
- // querying which settings reference the id.
3441
- if (result.success) {
3442
- invalidateSiteSettingsCache();
3443
- }
4654
+ async handlePluginCommentModerate(
4655
+ pluginId: string,
4656
+ id: string,
4657
+ status: PluginCommentStatus,
4658
+ expectedStatus: PluginCommentStatus,
4659
+ ): Promise<PluginComment> {
4660
+ assertPluginCommentStatus(status, "status");
4661
+ assertPluginCommentStatus(expectedStatus, "expectedStatus");
4662
+ const updated = await this.moderateCommentWithOrigin(id, status, expectedStatus, {
4663
+ source: "plugin",
4664
+ pluginId,
4665
+ });
4666
+ if (!updated) throw new Error(`Comment not found: ${id}`);
4667
+ const result = await createCommentAccess(this.db).get(id);
4668
+ if (!result) throw new Error(`Comment not found: ${id}`);
3444
4669
  return result;
3445
4670
  }
3446
4671
 
@@ -3495,8 +4720,13 @@ export class EmDashRuntime {
3495
4720
  // live, matching the documented tool contract.
3496
4721
  try {
3497
4722
  const contentRepo = new ContentRepository(this.db);
3498
- const existing = await contentRepo.findById(revision.collection, revision.entryId);
3499
- if (!existing) {
4723
+ const newDraftId = await contentRepo.restoreDraftRevision(
4724
+ revision.collection,
4725
+ revision.entryId,
4726
+ revision.data,
4727
+ callerUserId,
4728
+ );
4729
+ if (!newDraftId) {
3500
4730
  return {
3501
4731
  success: false as const,
3502
4732
  error: {
@@ -3506,43 +4736,12 @@ export class EmDashRuntime {
3506
4736
  };
3507
4737
  }
3508
4738
 
3509
- const newDraft = await revisionRepo.create({
3510
- collection: revision.collection,
3511
- entryId: revision.entryId,
3512
- data: revision.data,
3513
- authorId: callerUserId,
3514
- });
3515
-
3516
- try {
3517
- const staged = await contentRepo.replaceDraftRevision(
3518
- revision.collection,
3519
- revision.entryId,
3520
- newDraft.id,
3521
- existing,
3522
- );
3523
- if (!staged) throw new ContentMutationConflictError();
3524
- } catch (error) {
3525
- try {
3526
- await revisionRepo.deleteIfUnreferenced(
3527
- revision.collection,
3528
- revision.entryId,
3529
- newDraft.id,
3530
- );
3531
- } catch (cleanupError) {
3532
- console.error(
3533
- `[emdash] Failed to clean up unrestored revision ${newDraft.id}:`,
3534
- cleanupError,
3535
- );
3536
- }
3537
- throw error;
3538
- }
3539
-
3540
4739
  after(async () => {
3541
4740
  try {
3542
4741
  await revisionRepo.pruneQueuedEntry(
3543
4742
  revision.collection,
3544
4743
  revision.entryId,
3545
- newDraft.id,
4744
+ newDraftId,
3546
4745
  50,
3547
4746
  );
3548
4747
  } catch (error) {
@@ -3659,6 +4858,211 @@ export class EmDashRuntime {
3659
4858
  // Plugin Routes
3660
4859
  // =========================================================================
3661
4860
 
4861
+ private getSandboxedAdminDefinition(pluginId: string): {
4862
+ pages: string[];
4863
+ widgets: string[];
4864
+ policy: BlockValidationPolicy;
4865
+ } | null {
4866
+ const entry = this.sandboxedPluginEntries.find((candidate) => candidate.id === pluginId);
4867
+ if (entry) {
4868
+ const pages = (entry.adminPages ?? []).map((page) => normalizePluginPagePath(page.path));
4869
+ const imageHosts = allowedBrowserImageHosts(entry.capabilities, entry.allowedHosts);
4870
+ return {
4871
+ pages,
4872
+ widgets: (entry.adminWidgets ?? []).map((widget) => widget.id),
4873
+ policy: { pluginPagePaths: pages, allowedImageHosts: imageHosts },
4874
+ };
4875
+ }
4876
+
4877
+ const manifest = marketplaceManifestCache.get(pluginId);
4878
+ if (!manifest) return null;
4879
+ const pages = (manifest.admin?.pages ?? []).map((page) => normalizePluginPagePath(page.path));
4880
+ const imageHosts = allowedBrowserImageHosts(
4881
+ manifest.capabilities ?? [],
4882
+ manifest.allowedHosts ?? [],
4883
+ );
4884
+ return {
4885
+ pages,
4886
+ widgets: (manifest.admin?.widgets ?? []).map((widget) => widget.id),
4887
+ policy: { pluginPagePaths: pages, allowedImageHosts: imageHosts },
4888
+ };
4889
+ }
4890
+
4891
+ private resolvePluginUiContext(
4892
+ definition: { pages: string[]; widgets: string[] },
4893
+ body: unknown,
4894
+ request: Request,
4895
+ ): { context?: PluginUiContext; error?: { code: string; message: string } } {
4896
+ if (typeof body !== "object" || body === null || !("page" in body)) return {};
4897
+ const page = body.page;
4898
+ if (typeof page !== "string") {
4899
+ return {
4900
+ error: { code: "INVALID_PLUGIN_UI_CONTEXT", message: "Plugin UI page must be a string" },
4901
+ };
4902
+ }
4903
+
4904
+ let surface: PluginUiContext["surface"];
4905
+ if (page.startsWith("widget:")) {
4906
+ if (!definition.widgets.includes(page.slice("widget:".length))) {
4907
+ return {
4908
+ error: {
4909
+ code: "INVALID_PLUGIN_UI_CONTEXT",
4910
+ message: "Plugin dashboard widget is not declared",
4911
+ },
4912
+ };
4913
+ }
4914
+ surface = "dashboard-widget";
4915
+ } else {
4916
+ if (!definition.pages.includes(normalizePluginPagePath(page))) {
4917
+ return {
4918
+ error: {
4919
+ code: "INVALID_PLUGIN_UI_CONTEXT",
4920
+ message: "Plugin admin page is not declared",
4921
+ },
4922
+ };
4923
+ }
4924
+ surface = "admin-page";
4925
+ }
4926
+
4927
+ const locale = resolveLocale(request);
4928
+ return { context: { surface, locale, direction: getLocaleDir(locale) } };
4929
+ }
4930
+
4931
+ private validateSandboxedAdminResponse(
4932
+ pluginId: string,
4933
+ definition: { policy: BlockValidationPolicy },
4934
+ result: {
4935
+ success: boolean;
4936
+ data?: unknown;
4937
+ error?: { code: string; message: string };
4938
+ status?: number;
4939
+ },
4940
+ ) {
4941
+ if (!result.success) return result;
4942
+ const validation = validateBlockResponse(result.data, definition.policy);
4943
+ if (validation.valid) return result;
4944
+
4945
+ console.error(
4946
+ `EmDash: Sandboxed plugin ${pluginId} returned invalid Block Kit content:`,
4947
+ validation.errors,
4948
+ );
4949
+ return {
4950
+ success: false,
4951
+ status: 502,
4952
+ error: {
4953
+ code: "INVALID_BLOCK_RESPONSE",
4954
+ message: "Plugin returned invalid Block Kit content",
4955
+ },
4956
+ };
4957
+ }
4958
+
4959
+ getPluginEditorExtension(
4960
+ pluginId: string,
4961
+ kind: "panel" | "action",
4962
+ extensionId: string,
4963
+ collection: string,
4964
+ ): ResolvedPluginEditorExtension | null {
4965
+ if (!this.isPluginEnabled(pluginId)) return null;
4966
+
4967
+ let panels: PluginEditorPanel[] | undefined;
4968
+ let actions: PluginEditorAction[] | undefined;
4969
+ let pages: string[] = [];
4970
+ let capabilities: readonly PluginCapability[] = [];
4971
+ let allowedHosts: readonly string[] = [];
4972
+
4973
+ const configured = this.configuredPlugins.find((plugin) => plugin.id === pluginId);
4974
+ if (configured) {
4975
+ if (configured.admin.entry) return null;
4976
+ panels = configured.admin.editorPanels;
4977
+ actions = configured.admin.editorActions;
4978
+ pages = (configured.admin.pages ?? []).map((page) => page.path);
4979
+ capabilities = configured.capabilities;
4980
+ allowedHosts = configured.allowedHosts;
4981
+ } else {
4982
+ const entry = this.sandboxedPluginEntries.find((candidate) => candidate.id === pluginId);
4983
+ if (entry) {
4984
+ panels = entry.editorPanels;
4985
+ actions = entry.editorActions;
4986
+ pages = (entry.adminPages ?? []).map((page) => page.path);
4987
+ capabilities = entry.capabilities;
4988
+ allowedHosts = entry.allowedHosts;
4989
+ } else {
4990
+ const manifest = marketplaceManifestCache.get(pluginId);
4991
+ if (!manifest) return null;
4992
+ panels = manifest.admin?.editorPanels;
4993
+ actions = manifest.admin?.editorActions;
4994
+ pages = (manifest.admin?.pages ?? []).map((page) => page.path);
4995
+ capabilities = manifest.capabilities ?? [];
4996
+ allowedHosts = manifest.allowedHosts ?? [];
4997
+ }
4998
+ }
4999
+
5000
+ const normalizedCapabilities = normalizePluginCapabilities(capabilities);
5001
+ const policy = {
5002
+ pluginPagePaths: pages,
5003
+ allowedImageHosts: allowedBrowserImageHosts(capabilities, allowedHosts),
5004
+ };
5005
+ if (kind === "panel") {
5006
+ const matches = panels?.filter((panel) => panel.id === extensionId) ?? [];
5007
+ const extension = matches[0];
5008
+ if (
5009
+ matches.length !== 1 ||
5010
+ !extension ||
5011
+ (extension.collections && !extension.collections.includes(collection))
5012
+ ) {
5013
+ return null;
5014
+ }
5015
+ return { kind, extension, policy, capabilities: normalizedCapabilities };
5016
+ }
5017
+ const matches = actions?.filter((action) => action.id === extensionId) ?? [];
5018
+ const extension = matches[0];
5019
+ if (
5020
+ matches.length !== 1 ||
5021
+ !extension ||
5022
+ (extension.collections && !extension.collections.includes(collection)) ||
5023
+ (extension.style === "danger" && !extension.confirm)
5024
+ ) {
5025
+ return null;
5026
+ }
5027
+ return { kind, extension, policy, capabilities: normalizedCapabilities };
5028
+ }
5029
+
5030
+ async getPluginEditorDraftSchema(collection: string) {
5031
+ return this.schemaRegistry.getCollectionWithFields(collection);
5032
+ }
5033
+
5034
+ private validatePluginEditorExtensionResponse(
5035
+ pluginId: string,
5036
+ dispatch: PluginEditorExtensionDispatch,
5037
+ result: {
5038
+ success: boolean;
5039
+ data?: unknown;
5040
+ error?: { code: string; message: string };
5041
+ status?: number;
5042
+ },
5043
+ ) {
5044
+ if (!result.success) return result;
5045
+ const validation =
5046
+ dispatch.kind === "panel"
5047
+ ? validateBlockResponse(result.data, dispatch.policy)
5048
+ : validateContentEditorActionResponse(result.data, dispatch.policy);
5049
+ if (validation.valid) return result;
5050
+
5051
+ console.error(
5052
+ `EmDash: Plugin ${pluginId} returned an invalid content editor ${dispatch.kind} response:`,
5053
+ validation.errors,
5054
+ );
5055
+ return {
5056
+ success: false,
5057
+ status: 502,
5058
+ error: {
5059
+ code:
5060
+ dispatch.kind === "panel" ? "INVALID_BLOCK_RESPONSE" : "INVALID_EDITOR_ACTION_RESPONSE",
5061
+ message: "Plugin returned an invalid editor extension response",
5062
+ },
5063
+ };
5064
+ }
5065
+
3662
5066
  /**
3663
5067
  * Get route metadata for a plugin route without invoking the handler.
3664
5068
  * Used by the catch-all route to decide auth before dispatch.
@@ -3722,10 +5126,12 @@ export class EmDashRuntime {
3722
5126
 
3723
5127
  async handlePluginApiRoute(
3724
5128
  pluginId: string,
3725
- _method: string,
5129
+ method: string,
3726
5130
  path: string,
3727
5131
  request: Request,
3728
5132
  user?: RouteCallerInput | null,
5133
+ invalidateContentCache?: PluginContentCacheInvalidator,
5134
+ editorDispatch?: PluginEditorExtensionDispatch,
3729
5135
  ) {
3730
5136
  if (!this.isPluginEnabled(pluginId)) {
3731
5137
  return {
@@ -3733,11 +5139,40 @@ export class EmDashRuntime {
3733
5139
  error: { code: "NOT_FOUND", message: `Plugin not enabled: ${pluginId}` },
3734
5140
  };
3735
5141
  }
5142
+ const normalizedMethod = method.toUpperCase();
5143
+ const routeMeta = this.getPluginRouteMeta(pluginId, path);
5144
+ if (routeMeta?.methods && !routeMeta.methods.some((allowed) => allowed === normalizedMethod)) {
5145
+ return {
5146
+ success: false,
5147
+ status: 405,
5148
+ error: { code: "METHOD_NOT_ALLOWED", message: "Method not allowed" },
5149
+ };
5150
+ }
3736
5151
 
3737
5152
  // Authenticated caller for `ctx.user`. Undefined for public routes
3738
5153
  // (the catch-all only forwards the caller after private-route auth)
3739
5154
  // and for machine tokens with no bound user.
3740
5155
  const caller = user ? toRouteCallerInfo(user) : undefined;
5156
+ let body: unknown;
5157
+ try {
5158
+ body = await parseRouteInput(request, routeMeta?.request);
5159
+ } catch (error) {
5160
+ if (error instanceof PluginRouteRequestError) {
5161
+ return {
5162
+ success: false,
5163
+ status: error.status,
5164
+ error: { code: "INVALID_PLUGIN_REQUEST", message: error.message },
5165
+ };
5166
+ }
5167
+ throw error;
5168
+ }
5169
+ const routeKey = path.replace(LEADING_SLASH_PATTERN, "");
5170
+ const adminDefinition =
5171
+ !editorDispatch && routeKey === "admin" ? this.getSandboxedAdminDefinition(pluginId) : null;
5172
+ const uiResult = adminDefinition
5173
+ ? this.resolvePluginUiContext(adminDefinition, body, request)
5174
+ : {};
5175
+ if (uiResult.error) return { success: false, status: 400, error: uiResult.error };
3741
5176
 
3742
5177
  // Check trusted (configured) plugins first — this must match the
3743
5178
  // resolution order in getPluginRouteMeta to avoid auth/execution mismatches.
@@ -3745,24 +5180,44 @@ export class EmDashRuntime {
3745
5180
  if (trustedPlugin && this.enabledPlugins.has(trustedPlugin.id)) {
3746
5181
  const routeRegistry = new PluginRouteRegistry({
3747
5182
  ...this.pipelineFactoryOptions,
5183
+ contentActions: this.contentActionsWithInvalidator(invalidateContentCache),
3748
5184
  emailPipeline: this.email ?? undefined,
3749
5185
  cronReschedule: () => this.cronScheduler?.reschedule(),
3750
5186
  trustedProxyHeaders: getTrustedProxyHeaders(this.config),
3751
5187
  });
3752
5188
  routeRegistry.register(trustedPlugin);
3753
5189
 
3754
- const routeKey = path.replace(LEADING_SLASH_PATTERN, "");
3755
-
3756
- // Body methods parse JSON; GET/HEAD/DELETE parse the query string (#2146).
3757
- const body = await parseRouteInput(request);
3758
-
3759
- return routeRegistry.invoke(pluginId, routeKey, { request, body, user: caller });
5190
+ const result = await routeRegistry.invoke(pluginId, routeKey, {
5191
+ request,
5192
+ body,
5193
+ user: caller,
5194
+ ui: editorDispatch?.ui ?? uiResult.context,
5195
+ });
5196
+ return editorDispatch
5197
+ ? this.validatePluginEditorExtensionResponse(pluginId, editorDispatch, result)
5198
+ : adminDefinition
5199
+ ? this.validateSandboxedAdminResponse(pluginId, adminDefinition, result)
5200
+ : result;
3760
5201
  }
3761
5202
 
3762
5203
  // Check sandboxed (marketplace) plugins second
3763
5204
  const sandboxedPlugin = this.findSandboxedPlugin(pluginId);
3764
5205
  if (sandboxedPlugin) {
3765
- return this.handleSandboxedRoute(sandboxedPlugin, path, request, caller);
5206
+ const result = await this.handleSandboxedRoute(
5207
+ sandboxedPlugin,
5208
+ path,
5209
+ request,
5210
+ body,
5211
+ routeMeta ?? { public: false },
5212
+ caller,
5213
+ editorDispatch?.ui ?? uiResult.context,
5214
+ invalidateContentCache,
5215
+ );
5216
+ return editorDispatch
5217
+ ? this.validatePluginEditorExtensionResponse(pluginId, editorDispatch, result)
5218
+ : adminDefinition
5219
+ ? this.validateSandboxedAdminResponse(pluginId, adminDefinition, result)
5220
+ : result;
3766
5221
  }
3767
5222
 
3768
5223
  return {
@@ -3771,6 +5226,28 @@ export class EmDashRuntime {
3771
5226
  };
3772
5227
  }
3773
5228
 
5229
+ private contentActionsWithInvalidator(
5230
+ invalidateContentCache?: PluginContentCacheInvalidator,
5231
+ ): ContentActionCallbacks | undefined {
5232
+ const actions = this.pipelineFactoryOptions.contentActions;
5233
+ if (!actions || !invalidateContentCache) return actions;
5234
+ return {
5235
+ ...actions,
5236
+ begin: (pluginId, invocationId, invocationInvalidator) =>
5237
+ actions.begin?.(pluginId, invocationId, invocationInvalidator ?? invalidateContentCache),
5238
+ publish: (pluginId, collection, id, options, invocationId) =>
5239
+ actions.publish(pluginId, collection, id, options, invocationId, invalidateContentCache),
5240
+ unpublish: (pluginId, collection, id, options, invocationId) =>
5241
+ actions.unpublish(pluginId, collection, id, options, invocationId, invalidateContentCache),
5242
+ schedule: (pluginId, collection, id, options, invocationId) =>
5243
+ actions.schedule(pluginId, collection, id, options, invocationId, invalidateContentCache),
5244
+ unschedule: (pluginId, collection, id, options, invocationId) =>
5245
+ actions.unschedule(pluginId, collection, id, options, invocationId, invalidateContentCache),
5246
+ restore: (pluginId, collection, id, options, invocationId) =>
5247
+ actions.restore(pluginId, collection, id, options, invocationId, invalidateContentCache),
5248
+ };
5249
+ }
5250
+
3774
5251
  async getPluginMcpTools(pluginId?: string) {
3775
5252
  const tools: Array<{
3776
5253
  pluginId: string;
@@ -3788,7 +5265,14 @@ export class EmDashRuntime {
3788
5265
  if (pluginId && plugin.id !== pluginId) continue;
3789
5266
  for (const [name, tool] of Object.entries(plugin.mcp?.tools ?? {})) {
3790
5267
  const route = plugin.routes[tool.route];
3791
- if (!route || route.public || !route.permission || !(route.permission in Permissions))
5268
+ if (
5269
+ !route ||
5270
+ route.public ||
5271
+ route.response === "raw" ||
5272
+ !isJsonPostRouteContract(route) ||
5273
+ !route.permission ||
5274
+ !Object.hasOwn(Permissions, route.permission)
5275
+ )
3792
5276
  continue;
3793
5277
  const key = `${plugin.id}__${name}`;
3794
5278
  if (seen.has(key)) continue;
@@ -3815,8 +5299,10 @@ export class EmDashRuntime {
3815
5299
  seen.has(key) ||
3816
5300
  !routeMeta ||
3817
5301
  routeMeta.public ||
5302
+ routeMeta.response === "raw" ||
5303
+ !isJsonPostRouteContract(routeMeta) ||
3818
5304
  routeMeta.permission !== tool.permission ||
3819
- !(tool.permission in Permissions)
5305
+ !Object.hasOwn(Permissions, tool.permission)
3820
5306
  ) {
3821
5307
  continue;
3822
5308
  }
@@ -3890,6 +5376,7 @@ export class EmDashRuntime {
3890
5376
  actorId: string,
3891
5377
  request: Request,
3892
5378
  caller?: RouteCallerInput | null,
5379
+ invalidateContentCache?: PluginContentCacheInvalidator,
3893
5380
  ) {
3894
5381
  const requestMeta = extractRequestMeta(request, getTrustedProxyHeaders(this.config));
3895
5382
  const audit = new AuditRepository(this.db);
@@ -3907,6 +5394,7 @@ export class EmDashRuntime {
3907
5394
  route,
3908
5395
  internalRequest,
3909
5396
  caller,
5397
+ invalidateContentCache,
3910
5398
  );
3911
5399
  await audit.log({
3912
5400
  actorId,
@@ -3953,6 +5441,37 @@ export class EmDashRuntime {
3953
5441
  return undefined;
3954
5442
  }
3955
5443
 
5444
+ /**
5445
+ * Drop incoming keys that have no matching collection field when the entry
5446
+ * already stores them in its live data or current draft revision.
5447
+ *
5448
+ * Draft revisions keep the full `data` JSON, so deleting a field can strand
5449
+ * the old value; this lets a read-then-write save succeed without allowing
5450
+ * genuinely unknown keys.
5451
+ */
5452
+ private async dropUnknownKeysAlreadyStored(
5453
+ data: Record<string, unknown>,
5454
+ existing: { data: Record<string, unknown>; draftRevisionId?: string | null } | null,
5455
+ knownFieldSlugs: ReadonlySet<string>,
5456
+ ): Promise<Record<string, unknown>> {
5457
+ if (!existing) return data;
5458
+
5459
+ let stored: Record<string, unknown> = existing.data ?? {};
5460
+ if (existing.draftRevisionId) {
5461
+ const draft = await new RevisionRepository(this.db)
5462
+ .findById(existing.draftRevisionId)
5463
+ .catch(() => null);
5464
+ if (draft?.data) stored = draft.data;
5465
+ }
5466
+
5467
+ const stale = staleStoredKeys(data, stored, knownFieldSlugs);
5468
+ if (stale.length === 0) return data;
5469
+
5470
+ const result = { ...data };
5471
+ for (const key of stale) delete result[key];
5472
+ return result;
5473
+ }
5474
+
3956
5475
  /**
3957
5476
  * Normalize image/file fields in content data.
3958
5477
  * Fills missing dimensions, storageKey, mimeType, and filename from providers.
@@ -3960,12 +5479,15 @@ export class EmDashRuntime {
3960
5479
  private async normalizeMediaFields(
3961
5480
  collection: string,
3962
5481
  data: Record<string, unknown>,
5482
+ preloaded?: CollectionWithFields | null,
3963
5483
  ): Promise<Record<string, unknown>> {
3964
- let collectionInfo;
3965
- try {
3966
- collectionInfo = await this.schemaRegistry.getCollectionWithFields(collection);
3967
- } catch {
3968
- return data;
5484
+ let collectionInfo = preloaded;
5485
+ if (collectionInfo === undefined) {
5486
+ try {
5487
+ collectionInfo = await this.schemaRegistry.getCollectionWithFields(collection);
5488
+ } catch {
5489
+ return data;
5490
+ }
3969
5491
  }
3970
5492
  if (!collectionInfo?.fields) return data;
3971
5493
 
@@ -4035,124 +5557,22 @@ export class EmDashRuntime {
4035
5557
  return result;
4036
5558
  }
4037
5559
 
4038
- private async runSandboxedBeforeSave(
4039
- content: Record<string, unknown>,
4040
- collection: string,
4041
- isNew: boolean,
4042
- contentId?: string,
4043
- actor?: ActorInfo,
4044
- ) {
4045
- let result = content;
4046
-
4047
- for (const [pluginKey, plugin] of this.sandboxedPlugins) {
4048
- const [id] = pluginKey.split(":");
4049
- if (!id || !this.isPluginEnabled(id)) continue;
4050
-
4051
- try {
4052
- const event: ContentHookEvent = { content: result, collection, isNew };
4053
- if (contentId !== undefined) event.id = contentId;
4054
- if (actor !== undefined) event.actor = { ...actor };
4055
- const hookResult = await plugin.invokeHook("content:beforeSave", event);
4056
- const inspection = inspectSandboxHookResult(hookResult);
4057
- if (inspection.kind === "error") {
4058
- return {
4059
- success: false as const,
4060
- error: {
4061
- code: ErrorCode.SAVE_REJECTED,
4062
- message: "Save rejected by a sandboxed plugin",
4063
- details: { pluginId: id, reason: inspection.error.reason },
4064
- },
4065
- };
4066
- }
4067
- if (inspection.kind === "malformed") {
4068
- console.error(`EmDash: Sandboxed plugin ${id} returned an invalid hook result`);
4069
- return {
4070
- success: false as const,
4071
- error: {
4072
- code: ErrorCode.CONTENT_HOOK_ERROR,
4073
- message: "A plugin hook failed while saving content",
4074
- },
4075
- };
4076
- }
4077
- if (hookResult && typeof hookResult === "object" && !Array.isArray(hookResult)) {
4078
- // Sandbox returns unknown; convert to record by iterating own properties
4079
- const record: Record<string, unknown> = {};
4080
- for (const [k, v] of Object.entries(hookResult)) {
4081
- record[k] = v;
4082
- }
4083
- result = record;
4084
- }
4085
- } catch (error) {
4086
- console.error(`EmDash: Sandboxed plugin ${id} beforeSave hook failed:`, error);
4087
- return {
4088
- success: false as const,
4089
- error: {
4090
- code: ErrorCode.CONTENT_HOOK_ERROR,
4091
- message: "A plugin hook failed while saving content",
4092
- },
4093
- };
4094
- }
4095
- }
4096
-
4097
- return { success: true as const, data: result };
4098
- }
4099
-
4100
- private async runSandboxedBeforeDelete(id: string, collection: string): Promise<boolean> {
4101
- for (const [pluginKey, plugin] of this.sandboxedPlugins) {
4102
- const [pluginId] = pluginKey.split(":");
4103
- if (!pluginId || !this.isPluginEnabled(pluginId)) continue;
4104
-
4105
- try {
4106
- const result = await plugin.invokeHook("content:beforeDelete", {
4107
- id,
4108
- collection,
4109
- });
4110
- if (result === false) {
4111
- return false;
4112
- }
4113
- } catch (error) {
4114
- console.error(`EmDash: Sandboxed plugin ${pluginId} beforeDelete hook error:`, error);
4115
- }
4116
- }
4117
-
4118
- return true;
4119
- }
4120
-
4121
5560
  private runAfterSaveHooks(
4122
5561
  content: Record<string, unknown>,
4123
5562
  collection: string,
4124
5563
  isNew: boolean,
4125
5564
  actor?: ActorInfo,
5565
+ excludePluginId?: string,
4126
5566
  ): void {
4127
5567
  after(async () => {
4128
5568
  // Trusted plugins
4129
5569
  if (this.hooks.hasHooks("content:afterSave")) {
4130
5570
  try {
4131
- await this.hooks.runContentAfterSave(content, collection, isNew, actor);
5571
+ await this.hooks.runContentAfterSave(content, collection, isNew, actor, excludePluginId);
4132
5572
  } catch (err) {
4133
5573
  console.error("EmDash afterSave hook error:", err);
4134
5574
  }
4135
5575
  }
4136
-
4137
- // Sandboxed plugins
4138
- const tasks: Promise<void>[] = [];
4139
- for (const [pluginKey, plugin] of this.sandboxedPlugins) {
4140
- const [id] = pluginKey.split(":");
4141
- if (!id || !this.isPluginEnabled(id)) continue;
4142
-
4143
- tasks.push(
4144
- (async () => {
4145
- try {
4146
- const event: ContentHookEvent = { content, collection, isNew };
4147
- if (actor !== undefined) event.actor = { ...actor };
4148
- await plugin.invokeHook("content:afterSave", event);
4149
- } catch (err) {
4150
- console.error(`EmDash: Sandboxed plugin ${id} afterSave error:`, err);
4151
- }
4152
- })(),
4153
- );
4154
- }
4155
- await Promise.allSettled(tasks);
4156
5576
  });
4157
5577
  }
4158
5578
 
@@ -4166,24 +5586,6 @@ export class EmDashRuntime {
4166
5586
  console.error("EmDash afterDelete hook error:", err);
4167
5587
  }
4168
5588
  }
4169
-
4170
- // Sandboxed plugins
4171
- const tasks: Promise<void>[] = [];
4172
- for (const [pluginKey, plugin] of this.sandboxedPlugins) {
4173
- const [pluginId] = pluginKey.split(":");
4174
- if (!pluginId || !this.isPluginEnabled(pluginId)) continue;
4175
-
4176
- tasks.push(
4177
- (async () => {
4178
- try {
4179
- await plugin.invokeHook("content:afterDelete", { id, collection, permanent });
4180
- } catch (err) {
4181
- console.error(`EmDash: Sandboxed plugin ${pluginId} afterDelete error:`, err);
4182
- }
4183
- })(),
4184
- );
4185
- }
4186
- await Promise.allSettled(tasks);
4187
5589
  });
4188
5590
  }
4189
5591
 
@@ -4196,10 +5598,12 @@ export class EmDashRuntime {
4196
5598
  | "content:afterUnschedule",
4197
5599
  content: Record<string, unknown>,
4198
5600
  collection: string,
5601
+ afterPluginId?: string,
5602
+ pluginInvocationId?: string,
4199
5603
  ): void {
4200
5604
  const label = name.slice("content:".length);
4201
5605
 
4202
- after(async () => {
5606
+ const invoke = async () => {
4203
5607
  // Trusted plugins
4204
5608
  if (this.hooks.hasHooks(name)) {
4205
5609
  try {
@@ -4224,52 +5628,160 @@ export class EmDashRuntime {
4224
5628
  console.error(`EmDash ${label} hook error:`, err);
4225
5629
  }
4226
5630
  }
5631
+ };
5632
+ const contentId = typeof content.id === "string" ? content.id : undefined;
5633
+ const guardKey =
5634
+ afterPluginId && contentId ? this.pluginContentActionKey(collection, contentId) : undefined;
5635
+ const invokeWithGuard = async () => {
5636
+ if (guardKey) this.retainPluginContentAction(guardKey);
5637
+ try {
5638
+ await invoke();
5639
+ } finally {
5640
+ if (guardKey) this.releasePluginContentAction(guardKey);
5641
+ }
5642
+ };
5643
+ if (afterPluginId && pluginInvocationId && this.findSandboxedPlugin(afterPluginId)) {
5644
+ const key = this.pluginInvocationKey(afterPluginId, pluginInvocationId);
5645
+ if (!this.activePluginInvocations.has(key) || this.releasedPluginInvocations.has(key)) {
5646
+ after(invokeWithGuard);
5647
+ return;
5648
+ }
5649
+ const pending = this.pendingPluginAfterHooks.get(key) ?? [];
5650
+ pending.push(invokeWithGuard);
5651
+ this.pendingPluginAfterHooks.set(key, pending);
5652
+ return;
5653
+ }
5654
+ after(invokeWithGuard);
5655
+ }
4227
5656
 
4228
- // Sandboxed plugins
4229
- const tasks: Promise<void>[] = [];
4230
- for (const [pluginKey, plugin] of this.sandboxedPlugins) {
4231
- const [pluginId] = pluginKey.split(":");
4232
- if (!pluginId || !this.isPluginEnabled(pluginId)) continue;
5657
+ private pluginInvocationKey(pluginId: string, invocationId: string): string {
5658
+ return JSON.stringify([pluginId, invocationId]);
5659
+ }
4233
5660
 
4234
- tasks.push(
4235
- (async () => {
4236
- try {
4237
- await plugin.invokeHook(name, { content, collection });
4238
- } catch (err) {
4239
- console.error(`EmDash: Sandboxed plugin ${pluginId} ${label} error:`, err);
4240
- }
4241
- })(),
4242
- );
4243
- }
4244
- await Promise.allSettled(tasks);
4245
- });
5661
+ private beginPluginInvocation(
5662
+ pluginId: string,
5663
+ invocationId: string,
5664
+ invalidateContentCache?: PluginContentCacheInvalidator,
5665
+ ): void {
5666
+ const key = this.pluginInvocationKey(pluginId, invocationId);
5667
+ this.pendingPluginAfterHooks.delete(key);
5668
+ this.releasedPluginInvocations.delete(key);
5669
+ if (invalidateContentCache)
5670
+ this.pluginInvocationCacheInvalidators.set(key, invalidateContentCache);
5671
+ else this.pluginInvocationCacheInvalidators.delete(key);
5672
+ this.activePluginInvocations.add(key);
4246
5673
  }
4247
5674
 
4248
- private runAfterPublishHooks(content: Record<string, unknown>, collection: string): void {
4249
- this.runDeferredContentHook("content:afterPublish", content, collection);
5675
+ private flushPluginAfterHooks(
5676
+ pluginId: string,
5677
+ invocationId?: string,
5678
+ final = true,
5679
+ ): Promise<void> {
5680
+ if (!invocationId) return Promise.resolve();
5681
+ const key = this.pluginInvocationKey(pluginId, invocationId);
5682
+ this.releasedPluginInvocations.add(key);
5683
+ const pending = this.pendingPluginAfterHooks.get(key) ?? [];
5684
+ this.pendingPluginAfterHooks.delete(key);
5685
+ for (const invoke of pending) after(invoke);
5686
+ if (final) {
5687
+ this.releasedPluginInvocations.delete(key);
5688
+ this.activePluginInvocations.delete(key);
5689
+ this.pluginInvocationCacheInvalidators.delete(key);
5690
+ } else {
5691
+ const timer = setTimeout(() => {
5692
+ this.releasedPluginInvocations.delete(key);
5693
+ this.activePluginInvocations.delete(key);
5694
+ this.pluginInvocationCacheInvalidators.delete(key);
5695
+ }, PLUGIN_INVOCATION_RELEASE_GRACE_MS);
5696
+ if (typeof timer === "object") timer.unref();
5697
+ }
5698
+ return Promise.resolve();
5699
+ }
5700
+
5701
+ private runAfterPublishHooks(
5702
+ content: Record<string, unknown>,
5703
+ collection: string,
5704
+ afterPluginId?: string,
5705
+ pluginInvocationId?: string,
5706
+ ): void {
5707
+ this.runDeferredContentHook(
5708
+ "content:afterPublish",
5709
+ content,
5710
+ collection,
5711
+ afterPluginId,
5712
+ pluginInvocationId,
5713
+ );
4250
5714
  }
4251
5715
 
4252
- private runAfterUnpublishHooks(content: Record<string, unknown>, collection: string): void {
4253
- this.runDeferredContentHook("content:afterUnpublish", content, collection);
5716
+ private runAfterUnpublishHooks(
5717
+ content: Record<string, unknown>,
5718
+ collection: string,
5719
+ afterPluginId?: string,
5720
+ pluginInvocationId?: string,
5721
+ ): void {
5722
+ this.runDeferredContentHook(
5723
+ "content:afterUnpublish",
5724
+ content,
5725
+ collection,
5726
+ afterPluginId,
5727
+ pluginInvocationId,
5728
+ );
4254
5729
  }
4255
5730
 
4256
- private runAfterRestoreHooks(content: Record<string, unknown>, collection: string): void {
4257
- this.runDeferredContentHook("content:afterRestore", content, collection);
5731
+ private runAfterRestoreHooks(
5732
+ content: Record<string, unknown>,
5733
+ collection: string,
5734
+ afterPluginId?: string,
5735
+ pluginInvocationId?: string,
5736
+ ): void {
5737
+ this.runDeferredContentHook(
5738
+ "content:afterRestore",
5739
+ content,
5740
+ collection,
5741
+ afterPluginId,
5742
+ pluginInvocationId,
5743
+ );
4258
5744
  }
4259
5745
 
4260
- private runAfterScheduleHooks(content: Record<string, unknown>, collection: string): void {
4261
- this.runDeferredContentHook("content:afterSchedule", content, collection);
5746
+ private runAfterScheduleHooks(
5747
+ content: Record<string, unknown>,
5748
+ collection: string,
5749
+ afterPluginId?: string,
5750
+ pluginInvocationId?: string,
5751
+ ): void {
5752
+ this.runDeferredContentHook(
5753
+ "content:afterSchedule",
5754
+ content,
5755
+ collection,
5756
+ afterPluginId,
5757
+ pluginInvocationId,
5758
+ );
4262
5759
  }
4263
5760
 
4264
- private runAfterUnscheduleHooks(content: Record<string, unknown>, collection: string): void {
4265
- this.runDeferredContentHook("content:afterUnschedule", content, collection);
5761
+ private runAfterUnscheduleHooks(
5762
+ content: Record<string, unknown>,
5763
+ collection: string,
5764
+ afterPluginId?: string,
5765
+ pluginInvocationId?: string,
5766
+ ): void {
5767
+ this.runDeferredContentHook(
5768
+ "content:afterUnschedule",
5769
+ content,
5770
+ collection,
5771
+ afterPluginId,
5772
+ pluginInvocationId,
5773
+ );
4266
5774
  }
4267
5775
 
4268
5776
  private async handleSandboxedRoute(
4269
5777
  plugin: SandboxedPluginInstance,
4270
5778
  path: string,
4271
5779
  request: Request,
5780
+ body: unknown,
5781
+ routeMeta: RouteMeta,
4272
5782
  user?: UserInfo,
5783
+ ui?: PluginUiContext,
5784
+ invalidateContentCache?: PluginContentCacheInvalidator,
4273
5785
  ): Promise<{
4274
5786
  success: boolean;
4275
5787
  data?: unknown;
@@ -4278,21 +5790,32 @@ export class EmDashRuntime {
4278
5790
  }> {
4279
5791
  const routeName = path.replace(LEADING_SLASH_PATTERN, "");
4280
5792
 
4281
- // Body methods parse JSON; GET/HEAD/DELETE parse the query string (#2146).
4282
- const body = await parseRouteInput(request);
4283
-
4284
5793
  try {
4285
- const headers = sanitizeHeadersForSandbox(request.headers);
5794
+ const declaredHeaders = routeMeta.request ? (routeMeta.request.headers ?? []) : undefined;
5795
+ const headers = sanitizeHeadersForSandbox(request.headers, declaredHeaders);
4286
5796
  const meta = extractRequestMeta(request, this.config);
4287
- const result = await plugin.invokeRoute(routeName, body, {
4288
- url: request.url,
4289
- method: request.method,
4290
- headers,
4291
- meta,
4292
- user,
4293
- });
5797
+ const result = await plugin.invokeRoute(
5798
+ routeName,
5799
+ body,
5800
+ {
5801
+ url: request.url,
5802
+ method: request.method,
5803
+ headers,
5804
+ meta,
5805
+ user,
5806
+ ui,
5807
+ },
5808
+ { invalidateContentCache },
5809
+ );
4294
5810
  return { success: true, data: result };
4295
5811
  } catch (error) {
5812
+ if (error instanceof PluginRouteRequestError) {
5813
+ return {
5814
+ success: false,
5815
+ status: error.status,
5816
+ error: { code: "INVALID_PLUGIN_REQUEST", message: error.message },
5817
+ };
5818
+ }
4296
5819
  console.error(`EmDash: Sandboxed plugin route error:`, error);
4297
5820
  const sandboxRouteError = getSandboxRouteErrorDetails(error);
4298
5821
  if (sandboxRouteError) {
@@ -4359,26 +5882,6 @@ export class EmDashRuntime {
4359
5882
  }
4360
5883
  }
4361
5884
 
4362
- // Sandboxed plugins — metadata only, never fragments
4363
- for (const [pluginKey, plugin] of this.sandboxedPlugins) {
4364
- const [id] = pluginKey.split(":");
4365
- if (!id || !this.isPluginEnabled(id)) continue;
4366
-
4367
- try {
4368
- const result = await plugin.invokeHook("page:metadata", { page });
4369
- if (result != null) {
4370
- const items = Array.isArray(result) ? result : [result];
4371
- for (const item of items) {
4372
- if (isValidMetadataContribution(item)) {
4373
- metadata.push(item);
4374
- }
4375
- }
4376
- }
4377
- } catch (error) {
4378
- console.error(`EmDash: Sandboxed plugin ${id} page:metadata error:`, error);
4379
- }
4380
- }
4381
-
4382
5885
  return { metadata, fragments };
4383
5886
  }
4384
5887