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
@@ -1,3989 +0,0 @@
1
- import { t as validateIdentifier } from "./validate-BpwoDOgt.mjs";
2
- import { n as cachedQuery, t as CacheNamespace } from "./object-cache-DVKnyOfy.mjs";
3
- import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-VG_tyqnP.mjs";
4
- import { o as decodeCursor, s as encodeCursor } from "./types-CQPWhPxE.mjs";
5
- import { t as CommentRepository } from "./comment-vxOzWbZN.mjs";
6
- import { t as OptionsRepository } from "./options-D1FBiAv1.mjs";
7
- import { t as PluginContextFactory } from "./context-C9PB8vGd.mjs";
8
- import { i as resolveLocaleChain, r as resolveLocale, t as interpolateUrlPattern } from "./resolve-Cy0aWSRj.mjs";
9
- import { r as requestCached } from "./request-cache-DAZZmesc.mjs";
10
- import { t as menuTag } from "./chrome-tags-DzDQBCjX.mjs";
11
- import { s as getDb } from "./loader-WJi6GFRn.mjs";
12
- import { i as normalizeCapabilities } from "./types-A2cN6a4a.mjs";
13
- import { xt as sanitizeHref } from "./entry-lock-DIYHAaSw.mjs";
14
- import { t as extractRequestMeta } from "./request-meta-BgjUQLQ-.mjs";
15
- import { r as setCronTasksEnabled } from "./cron-DHAy9oyq.mjs";
16
- import { t as MediaUsageActivationWriteBlockedError } from "./media-usage-write-fence-B9anjOSg.mjs";
17
- import { t as CommentReactionRepository } from "./comment-reaction-CDyvPQRj.mjs";
18
- import { sql } from "kysely";
19
- import { ulid } from "ulidx";
20
- import { AsyncLocalStorage } from "node:async_hooks";
21
- import { z } from "astro/zod";
22
- import { z as z$1 } from "zod";
23
- import { UnsafePortableTextTableError, portableTextTableToProseMirror, proseMirrorTableToPortableText } from "@emdash-cms/admin/portable-text-table";
24
- import { Extension, Mark, Node } from "@tiptap/core";
25
-
26
- //#region src/config/errors.ts
27
- /** A configuration failure whose message is safe to return from the API. */
28
- var EmDashConfigurationError = class extends Error {
29
- constructor(message, code, cause) {
30
- super(message);
31
- this.code = code;
32
- this.cause = cause;
33
- this.name = "EmDashConfigurationError";
34
- }
35
- };
36
-
37
- //#endregion
38
- //#region src/database/repositories/audit.ts
39
- /**
40
- * Audit repository for logging system events
41
- *
42
- * Tracks user actions for security, debugging, and compliance.
43
- * All mutations should create an audit log entry.
44
- */
45
- var AuditRepository = class {
46
- constructor(db) {
47
- this.db = db;
48
- }
49
- /**
50
- * Create an audit log entry
51
- */
52
- async log(input) {
53
- const id = ulid();
54
- const row = {
55
- id,
56
- actor_id: input.actorId ?? null,
57
- actor_ip: input.actorIp ?? null,
58
- action: input.action,
59
- resource_type: input.resourceType ?? null,
60
- resource_id: input.resourceId ?? null,
61
- details: input.details ? JSON.stringify(input.details) : null,
62
- status: input.status ?? null
63
- };
64
- await this.db.insertInto("audit_logs").values(row).execute();
65
- const log = await this.findById(id);
66
- if (!log) throw new Error("Failed to create audit log");
67
- return log;
68
- }
69
- /**
70
- * Find audit log by ID
71
- */
72
- async findById(id) {
73
- const row = await this.db.selectFrom("audit_logs").selectAll().where("id", "=", id).executeTakeFirst();
74
- return row ? this.rowToAuditLog(row) : null;
75
- }
76
- /**
77
- * Query audit logs with filters and cursor-based pagination
78
- */
79
- async findMany(query = {}) {
80
- const limit = Math.min(Math.max(1, query.limit || 50), 100);
81
- let q = this.db.selectFrom("audit_logs").selectAll().orderBy("timestamp", "desc").orderBy("id", "desc").limit(limit + 1);
82
- if (query.actorId) q = q.where("actor_id", "=", query.actorId);
83
- if (query.action) q = q.where("action", "=", query.action);
84
- if (query.resourceType) q = q.where("resource_type", "=", query.resourceType);
85
- if (query.resourceId) q = q.where("resource_id", "=", query.resourceId);
86
- if (query.status) q = q.where("status", "=", query.status);
87
- if (query.since) q = q.where("timestamp", ">=", query.since);
88
- if (query.until) q = q.where("timestamp", "<=", query.until);
89
- if (query.cursor) {
90
- const decoded = decodeCursor(query.cursor);
91
- q = q.where((eb) => eb.or([eb("timestamp", "<", decoded.orderValue), eb.and([eb("timestamp", "=", decoded.orderValue), eb("id", "<", decoded.id)])]));
92
- }
93
- const rows = await q.execute();
94
- const items = rows.slice(0, limit).map((row) => this.rowToAuditLog(row));
95
- const result = { items };
96
- if (rows.length > limit && items.length > 0) {
97
- const last = items.at(-1);
98
- result.nextCursor = encodeCursor(last.timestamp, last.id);
99
- }
100
- return result;
101
- }
102
- /**
103
- * Get all logs for a specific resource
104
- */
105
- async findByResource(resourceType, resourceId, options = {}) {
106
- let query = this.db.selectFrom("audit_logs").selectAll().where("resource_type", "=", resourceType).where("resource_id", "=", resourceId).orderBy("timestamp", "desc");
107
- if (options.limit) query = query.limit(options.limit);
108
- return (await query.execute()).map((row) => this.rowToAuditLog(row));
109
- }
110
- /**
111
- * Get all logs for a specific user
112
- */
113
- async findByActor(actorId, options = {}) {
114
- let query = this.db.selectFrom("audit_logs").selectAll().where("actor_id", "=", actorId).orderBy("timestamp", "desc");
115
- if (options.since) query = query.where("timestamp", ">=", options.since);
116
- if (options.limit) query = query.limit(options.limit);
117
- return (await query.execute()).map((row) => this.rowToAuditLog(row));
118
- }
119
- /**
120
- * Count logs matching a query
121
- */
122
- async count(query = {}) {
123
- let q = this.db.selectFrom("audit_logs").select((eb) => eb.fn.count("id").as("count"));
124
- if (query.actorId) q = q.where("actor_id", "=", query.actorId);
125
- if (query.action) q = q.where("action", "=", query.action);
126
- if (query.resourceType) q = q.where("resource_type", "=", query.resourceType);
127
- if (query.resourceId) q = q.where("resource_id", "=", query.resourceId);
128
- if (query.status) q = q.where("status", "=", query.status);
129
- if (query.since) q = q.where("timestamp", ">=", query.since);
130
- if (query.until) q = q.where("timestamp", "<=", query.until);
131
- const result = await q.executeTakeFirst();
132
- return Number(result?.count || 0);
133
- }
134
- /**
135
- * Delete old audit logs (for retention policy)
136
- */
137
- async deleteOlderThan(date) {
138
- const result = await this.db.deleteFrom("audit_logs").where("timestamp", "<", date).executeTakeFirst();
139
- return Number(result.numDeletedRows ?? 0);
140
- }
141
- /**
142
- * Convert database row to AuditLog object
143
- */
144
- rowToAuditLog(row) {
145
- return {
146
- id: row.id,
147
- timestamp: row.timestamp,
148
- actorId: row.actor_id,
149
- actorIp: row.actor_ip,
150
- action: row.action,
151
- resourceType: row.resource_type,
152
- resourceId: row.resource_id,
153
- details: row.details ? JSON.parse(row.details) : null,
154
- status: row.status
155
- };
156
- }
157
- };
158
-
159
- //#endregion
160
- //#region src/fields/image.ts
161
- const mediaSchema = z.object({
162
- id: z.string(),
163
- src: z.string().optional(),
164
- alt: z.string().optional(),
165
- width: z.number().optional(),
166
- height: z.number().optional(),
167
- filename: z.string().optional(),
168
- mimeType: z.string().optional(),
169
- blurhash: z.string().optional(),
170
- dominantColor: z.string().optional(),
171
- provider: z.string().optional(),
172
- previewUrl: z.string().optional(),
173
- meta: z.record(z.string(), z.unknown()).optional()
174
- });
175
- const imageSchema = mediaSchema.extend({ darkVariant: mediaSchema.optional() });
176
- function image(options = {}) {
177
- const validation = options.allowedTypes && options.allowedTypes.length > 0 ? { allowedMimeTypes: [...options.allowedTypes] } : void 0;
178
- return {
179
- type: "image",
180
- columnType: "TEXT",
181
- schema: options.required === false ? imageSchema.optional() : imageSchema,
182
- options,
183
- ui: { widget: "image" },
184
- validation
185
- };
186
- }
187
-
188
- //#endregion
189
- //#region src/fields/file.ts
190
- function file(options = {}) {
191
- const fileObjSchema = z.object({
192
- id: z.string(),
193
- url: z.string().optional(),
194
- src: z.string().optional(),
195
- filename: z.string().optional(),
196
- mimeType: z.string().optional(),
197
- size: z.number().optional(),
198
- provider: z.string().optional(),
199
- meta: z.record(z.string(), z.unknown()).optional()
200
- });
201
- return {
202
- type: "file",
203
- columnType: "TEXT",
204
- schema: options.required ? fileObjSchema : fileObjSchema.optional(),
205
- options,
206
- ui: {
207
- widget: "file",
208
- helpText: options.helpText,
209
- maxSize: options.maxSize
210
- },
211
- validation: options.allowedTypes && options.allowedTypes.length > 0 ? { allowedMimeTypes: [...options.allowedTypes] } : void 0
212
- };
213
- }
214
-
215
- //#endregion
216
- //#region src/fields/reference.ts
217
- /**
218
- * Reference field
219
- * References another content item by ID
220
- */
221
- function reference(collection, options) {
222
- const schema = z.string();
223
- return {
224
- type: "reference",
225
- columnType: "TEXT",
226
- schema: options?.required === false ? schema.optional() : schema,
227
- options: {
228
- ...options,
229
- collection
230
- },
231
- ui: { widget: "reference" }
232
- };
233
- }
234
-
235
- //#endregion
236
- //#region src/fields/portable-text.ts
237
- /**
238
- * Portable Text block schema
239
- */
240
- const portableTextBlockSchema = z.object({
241
- _type: z.string(),
242
- _key: z.string()
243
- }).loose();
244
- /**
245
- * Portable Text field
246
- * Stores structured content in Portable Text format
247
- */
248
- function portableText(options) {
249
- const schema = z.array(portableTextBlockSchema);
250
- return {
251
- type: "portableText",
252
- columnType: "JSON",
253
- schema: options?.required === false ? schema.optional() : schema,
254
- options,
255
- ui: { widget: "portableText" }
256
- };
257
- }
258
-
259
- //#endregion
260
- //#region src/content/converters/gallery.ts
261
- /**
262
- * Normalize an untrusted `images` value into well-formed gallery images.
263
- * Non-object entries and entries without an asset object are dropped.
264
- * Missing `_key`s are filled via `generateKey` when provided (PM → PT);
265
- * left empty otherwise (PT → PM keeps whatever the block carried).
266
- */
267
- function sanitizeGalleryImages(value, generateKey) {
268
- if (!Array.isArray(value)) return [];
269
- const images = [];
270
- for (const entry of value) {
271
- if (!isRecord$3(entry)) continue;
272
- const record = entry;
273
- const asset = record.asset;
274
- if (!isRecord$3(asset)) continue;
275
- const assetRecord = asset;
276
- const image = {
277
- _type: "image",
278
- _key: typeof record._key === "string" && record._key ? record._key : generateKey ? generateKey() : "",
279
- asset: {
280
- _type: "reference",
281
- _ref: typeof assetRecord._ref === "string" ? assetRecord._ref : "",
282
- ...typeof assetRecord.url === "string" && assetRecord.url ? { url: assetRecord.url } : {},
283
- ...typeof assetRecord.provider === "string" && assetRecord.provider ? { provider: assetRecord.provider } : {}
284
- }
285
- };
286
- if (typeof record.alt === "string" && record.alt) image.alt = record.alt;
287
- if (typeof record.caption === "string" && record.caption) image.caption = record.caption;
288
- if (typeof record.width === "number") image.width = record.width;
289
- if (typeof record.height === "number") image.height = record.height;
290
- if (typeof record.focalX === "number") image.focalX = record.focalX;
291
- if (typeof record.focalY === "number") image.focalY = record.focalY;
292
- if (typeof record.blurhash === "string" && record.blurhash) image.blurhash = record.blurhash;
293
- if (typeof record.dominantColor === "string" && record.dominantColor) image.dominantColor = record.dominantColor;
294
- images.push(image);
295
- }
296
- return images;
297
- }
298
- function isRecord$3(value) {
299
- return typeof value === "object" && value !== null && !Array.isArray(value);
300
- }
301
-
302
- //#endregion
303
- //#region src/content/converters/mark-safety.ts
304
- const SUPPORTED_PORTABLE_TEXT_DECORATORS = new Set([
305
- "strong",
306
- "em",
307
- "underline",
308
- "strike-through",
309
- "subscript",
310
- "superscript",
311
- "code"
312
- ]);
313
- const SUPPORTED_PROSEMIRROR_MARKS = new Set([
314
- "bold",
315
- "strong",
316
- "italic",
317
- "em",
318
- "underline",
319
- "strike",
320
- "strikethrough",
321
- "subscript",
322
- "superscript",
323
- "code",
324
- "link",
325
- "emdashPortableTextSpan"
326
- ]);
327
- function isRecord$2(value) {
328
- return typeof value === "object" && value !== null && !Array.isArray(value);
329
- }
330
- function collectPortableTextMarks(value, inheritedMarkDefs, unsupported) {
331
- if (Array.isArray(value)) {
332
- for (const item of value) collectPortableTextMarks(item, inheritedMarkDefs, unsupported);
333
- return;
334
- }
335
- if (!isRecord$2(value)) return;
336
- let markDefs = inheritedMarkDefs;
337
- if (Array.isArray(value.markDefs)) {
338
- const localMarkDefs = new Map(inheritedMarkDefs);
339
- for (const markDef of value.markDefs) if (isRecord$2(markDef) && typeof markDef._key === "string") localMarkDefs.set(markDef._key, markDef);
340
- markDefs = localMarkDefs;
341
- }
342
- if (value._type === "span" && Array.isArray(value.marks)) for (const mark of value.marks) {
343
- if (typeof mark !== "string" || SUPPORTED_PORTABLE_TEXT_DECORATORS.has(mark)) continue;
344
- const markDef = markDefs.get(mark);
345
- if (markDef?._type === "link") continue;
346
- unsupported.add(typeof markDef?._type === "string" ? markDef._type : mark);
347
- }
348
- for (const [key, child] of Object.entries(value)) if (key !== "markDefs") collectPortableTextMarks(child, markDefs, unsupported);
349
- }
350
- function collectProseMirrorMarks(node, unsupported) {
351
- for (const mark of node.marks ?? []) if (!SUPPORTED_PROSEMIRROR_MARKS.has(mark.type)) unsupported.add(mark.type);
352
- for (const child of node.content ?? []) collectProseMirrorMarks(child, unsupported);
353
- }
354
- var UnsupportedPortableTextMarksError = class extends Error {
355
- marks;
356
- constructor(marks) {
357
- const sortedMarks = [...new Set(marks)].toSorted();
358
- super(`Unsupported Portable Text marks: ${sortedMarks.join(", ")}`);
359
- this.name = "UnsupportedPortableTextMarksError";
360
- this.marks = sortedMarks;
361
- }
362
- };
363
- function findUnsupportedPortableTextMarks(blocks) {
364
- const unsupported = /* @__PURE__ */ new Set();
365
- for (const block of blocks) if (block._type === "block" || block._type === "table") collectPortableTextMarks(block, /* @__PURE__ */ new Map(), unsupported);
366
- return [...unsupported].toSorted();
367
- }
368
- function assertPortableTextMarksSupported(blocks) {
369
- const unsupported = findUnsupportedPortableTextMarks(blocks);
370
- if (unsupported.length > 0) throw new UnsupportedPortableTextMarksError(unsupported);
371
- }
372
- function assertProseMirrorMarksSupported(document) {
373
- const unsupported = /* @__PURE__ */ new Set();
374
- for (const node of document.content) collectProseMirrorMarks(node, unsupported);
375
- if (unsupported.size > 0) throw new UnsupportedPortableTextMarksError(unsupported);
376
- }
377
-
378
- //#endregion
379
- //#region src/content/converters/numbered-list.ts
380
- const MAX_ORDERED_LIST_START = 2147483647;
381
- function normalizeListId(value) {
382
- if (typeof value !== "string") return void 0;
383
- const normalized = value.trim();
384
- return normalized.length > 0 && normalized.length <= 128 ? normalized : void 0;
385
- }
386
- function normalizeListStart(value) {
387
- return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= MAX_ORDERED_LIST_START ? value : void 0;
388
- }
389
- function deriveLegacyListId(seed) {
390
- const readable = `legacy:${seed}`;
391
- if (readable.length <= 128) return readable;
392
- let hash = 2166136261;
393
- for (let i = 0; i < seed.length; i++) {
394
- hash ^= seed.charCodeAt(i);
395
- hash = Math.imul(hash, 16777619);
396
- }
397
- return `legacy:${seed.slice(0, 96)}:${(hash >>> 0).toString(36)}:${seed.length.toString(36)}`;
398
- }
399
- function readOrderedListMetadata(attrs, fallbackId) {
400
- return {
401
- listId: normalizeListId(attrs?.listId) ?? deriveLegacyListId(fallbackId),
402
- listStart: normalizeListStart(attrs?.listStart) ?? normalizeListStart(attrs?.start) ?? 1
403
- };
404
- }
405
- function collectProseMirrorOrderedLists(doc) {
406
- const lists = [];
407
- const visit = (node, path, depth, context) => {
408
- if (node.type === "orderedList") lists.push({
409
- node,
410
- path,
411
- depth,
412
- context
413
- });
414
- for (const [index, child] of (node.content ?? []).entries()) {
415
- const childPath = `${path}:${index}`;
416
- visit(child, childPath, depth + 1, child.type === "listItem" ? `listItem:${childPath}` : context);
417
- }
418
- };
419
- for (const [index, node] of doc.content.entries()) visit(node, `root:${index}`, 0, "root");
420
- return lists;
421
- }
422
- function cloneProseMirrorNode(node) {
423
- return {
424
- ...node,
425
- attrs: node.attrs ? { ...node.attrs } : void 0,
426
- content: node.content?.map(cloneProseMirrorNode),
427
- marks: node.marks?.map((mark) => ({
428
- ...mark,
429
- attrs: mark.attrs ? { ...mark.attrs } : void 0
430
- }))
431
- };
432
- }
433
- function createRepairId(sourceId, scope, attempt) {
434
- const base = deriveLegacyListId(`repair:${sourceId}:${scope}`);
435
- const suffix = `:${attempt.toString(36)}`;
436
- return `${base.slice(0, 128 - suffix.length)}${suffix}`;
437
- }
438
- function normalizeProseMirrorOrderedListJson(doc) {
439
- const normalized = {
440
- ...doc,
441
- content: doc.content.map(cloneProseMirrorNode)
442
- };
443
- const canonicalBySourceScope = /* @__PURE__ */ new Map();
444
- const assignedCanonicalIds = /* @__PURE__ */ new Set();
445
- const lists = collectProseMirrorOrderedLists(normalized).map((list) => {
446
- const sourceId = normalizeListId(list.node.attrs?.listId) ?? deriveLegacyListId(`pm-json:${list.path}:${list.depth}:${list.context}`);
447
- const scope = JSON.stringify([list.depth, list.context]);
448
- const sourceScope = JSON.stringify([sourceId, scope]);
449
- let listId = canonicalBySourceScope.get(sourceScope);
450
- if (!listId) {
451
- if (!assignedCanonicalIds.has(sourceId)) listId = sourceId;
452
- else {
453
- let attempt = 0;
454
- do
455
- listId = createRepairId(sourceId, scope, attempt++);
456
- while (assignedCanonicalIds.has(listId));
457
- }
458
- canonicalBySourceScope.set(sourceScope, listId);
459
- assignedCanonicalIds.add(listId);
460
- }
461
- return {
462
- ...list,
463
- listId,
464
- scopeKey: JSON.stringify([
465
- listId,
466
- list.depth,
467
- list.context
468
- ])
469
- };
470
- });
471
- const bases = /* @__PURE__ */ new Map();
472
- for (const list of lists) {
473
- const listStart = normalizeListStart(list.node.attrs?.listStart);
474
- if (listStart !== void 0 && !bases.has(list.scopeKey)) bases.set(list.scopeKey, listStart);
475
- }
476
- for (const list of lists) if (!bases.has(list.scopeKey)) bases.set(list.scopeKey, normalizeListStart(list.node.attrs?.start) ?? 1);
477
- const counts = /* @__PURE__ */ new Map();
478
- for (const list of lists) {
479
- const listStart = bases.get(list.scopeKey);
480
- const count = counts.get(list.scopeKey) ?? 0;
481
- const start = normalizeListStart(listStart + count) ?? 1;
482
- const directItemCount = list.node.content?.filter((node) => node.type === "listItem").length ?? 0;
483
- counts.set(list.scopeKey, count + directItemCount);
484
- list.node.attrs = {
485
- ...list.node.attrs,
486
- listId: list.listId,
487
- listStart,
488
- start
489
- };
490
- }
491
- return normalized;
492
- }
493
-
494
- //#endregion
495
- //#region src/content/converters/portable-text-identity.ts
496
- const PORTABLE_TEXT_BLOCK_NODE = "emdashPortableTextBlock";
497
- const PORTABLE_TEXT_BLOCK_ATTR = "emdashPortableTextBlock";
498
- const PORTABLE_TEXT_KEY_ATTR = "emdashPortableTextKey";
499
- const PORTABLE_TEXT_SPAN_MARK = "emdashPortableTextSpan";
500
- function isRecord$1(value) {
501
- return typeof value === "object" && value !== null && !Array.isArray(value);
502
- }
503
- function attrsWithPortableTextKey(attrs, key) {
504
- return {
505
- ...attrs,
506
- [PORTABLE_TEXT_KEY_ATTR]: key
507
- };
508
- }
509
- function portableTextKeyFromAttrs(attrs) {
510
- const key = attrs?.[PORTABLE_TEXT_KEY_ATTR];
511
- return typeof key === "string" && key ? key : void 0;
512
- }
513
- function portableTextSpanKeyFromMarks(marks) {
514
- for (const mark of marks ?? []) {
515
- if (!isRecord$1(mark) || mark.type !== PORTABLE_TEXT_SPAN_MARK || !isRecord$1(mark.attrs)) continue;
516
- const key = mark.attrs.key;
517
- if (typeof key === "string" && key) return key;
518
- }
519
- }
520
- function portableTextMarkDefsFromMarks(marks) {
521
- const identity = (marks ?? []).find((mark) => isRecord$1(mark) && mark.type === PORTABLE_TEXT_SPAN_MARK && isRecord$1(mark.attrs));
522
- if (!isRecord$1(identity) || !isRecord$1(identity.attrs) || !Array.isArray(identity.attrs.markDefs)) return [];
523
- return identity.attrs.markDefs.filter((markDef) => isRecord$1(markDef) && typeof markDef._type === "string" && typeof markDef._key === "string");
524
- }
525
- function portableTextBlockFromAttrs(attrs) {
526
- const block = attrs?.[PORTABLE_TEXT_BLOCK_ATTR];
527
- if (!isRecord$1(block) || typeof block._type !== "string" || typeof block._key !== "string") return;
528
- return {
529
- ...block,
530
- _type: block._type,
531
- _key: block._key
532
- };
533
- }
534
- const PortableTextIdentityExtension = Extension.create({
535
- name: "emdashPortableTextIdentity",
536
- addGlobalAttributes() {
537
- const hiddenAttribute = {
538
- default: null,
539
- rendered: false
540
- };
541
- return [{
542
- types: [
543
- "paragraph",
544
- "heading",
545
- "blockquote",
546
- "codeBlock",
547
- "htmlBlock",
548
- "image",
549
- "horizontalRule",
550
- "gallery",
551
- PORTABLE_TEXT_BLOCK_NODE
552
- ],
553
- attributes: { [PORTABLE_TEXT_KEY_ATTR]: hiddenAttribute }
554
- }];
555
- }
556
- });
557
- const PortableTextSpanIdentity = Mark.create({
558
- name: PORTABLE_TEXT_SPAN_MARK,
559
- inclusive: false,
560
- spanning: false,
561
- addAttributes() {
562
- return {
563
- key: {
564
- default: null,
565
- rendered: false
566
- },
567
- markDefs: {
568
- default: [],
569
- rendered: false
570
- }
571
- };
572
- },
573
- parseHTML() {
574
- return [];
575
- },
576
- renderHTML() {
577
- return ["span", 0];
578
- }
579
- });
580
- const PortableTextOpaqueBlock = Node.create({
581
- name: PORTABLE_TEXT_BLOCK_NODE,
582
- group: "block",
583
- atom: true,
584
- selectable: true,
585
- draggable: true,
586
- addAttributes() {
587
- return { [PORTABLE_TEXT_BLOCK_ATTR]: {
588
- default: null,
589
- rendered: false
590
- } };
591
- },
592
- parseHTML() {
593
- return [{ tag: "div[data-emdash-portable-text-block]" }];
594
- },
595
- renderHTML({ node }) {
596
- const blockType = portableTextBlockFromAttrs(node.attrs)?._type ?? "unknown";
597
- return [
598
- "div",
599
- {
600
- "data-emdash-portable-text-block": blockType,
601
- contenteditable: "false"
602
- },
603
- `[Unknown block type: ${blockType}]`
604
- ];
605
- }
606
- });
607
- const portableTextIdentityExtensions = [
608
- PortableTextIdentityExtension,
609
- PortableTextSpanIdentity,
610
- PortableTextOpaqueBlock
611
- ];
612
-
613
- //#endregion
614
- //#region src/content/converters/prosemirror-to-portable-text.ts
615
- /**
616
- * ProseMirror to Portable Text Converter
617
- *
618
- * Converts TipTap's ProseMirror JSON format to Portable Text for storage.
619
- */
620
- /**
621
- * Generate a unique key for Portable Text blocks
622
- */
623
- function generateKey$1() {
624
- return Math.random().toString(36).substring(2, 11);
625
- }
626
- /**
627
- * Convert ProseMirror document to Portable Text
628
- */
629
- function prosemirrorToPortableText(doc) {
630
- if (!doc || doc.type !== "doc" || !doc.content) return [];
631
- assertProseMirrorMarksSupported(doc);
632
- const blocks = [];
633
- const usedBlockKeys = /* @__PURE__ */ new Set();
634
- for (const [i, node] of doc.content.entries()) {
635
- if (i === doc.content.length - 1 && isUnkeyedEmptyParagraph(node)) continue;
636
- const converted = convertNode(node, `root:${i}`);
637
- for (const block of converted ? Array.isArray(converted) ? converted : [converted] : []) {
638
- let key = block._key;
639
- if (usedBlockKeys.has(key)) do
640
- key = generateKey$1();
641
- while (usedBlockKeys.has(key));
642
- usedBlockKeys.add(key);
643
- blocks.push(key === block._key ? block : {
644
- ...block,
645
- _key: key
646
- });
647
- }
648
- }
649
- return blocks;
650
- }
651
- function isUnkeyedEmptyParagraph(node) {
652
- return node.type === "paragraph" && (node.content?.length ?? 0) === 0 && portableTextKeyFromAttrs(node.attrs) === void 0;
653
- }
654
- /**
655
- * Convert a single ProseMirror node to Portable Text block(s)
656
- */
657
- function convertNode(node, path) {
658
- switch (node.type) {
659
- case PORTABLE_TEXT_BLOCK_NODE: return portableTextBlockFromAttrs(node.attrs) ?? null;
660
- case "paragraph": return convertParagraph(node);
661
- case "heading": return convertHeading(node);
662
- case "bulletList": return convertList$1(node, "bullet", path);
663
- case "orderedList": return convertList$1(node, "number", path);
664
- case "blockquote": return convertBlockquote(node);
665
- case "codeBlock": return convertCodeBlock$1(node);
666
- case "htmlBlock": return convertHtmlBlock(node);
667
- case "image": return convertImage$1(node);
668
- case "gallery": return convertGallery(node);
669
- case "table": {
670
- const result = proseMirrorTableToPortableText(node, {
671
- path,
672
- createKey: generateKey$1,
673
- inlineToSpans: (content) => {
674
- const { children, markDefs } = convertInlineContent(content, true);
675
- return {
676
- content: children,
677
- markDefs
678
- };
679
- }
680
- });
681
- if (!result.ok) throw new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);
682
- return result.table;
683
- }
684
- case "horizontalRule": return {
685
- _type: "break",
686
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
687
- style: "lineBreak"
688
- };
689
- default: return {
690
- _type: node.type,
691
- _key: generateKey$1(),
692
- ...node.attrs,
693
- _pmContent: node.content
694
- };
695
- }
696
- }
697
- /**
698
- * Convert paragraph to Portable Text block
699
- */
700
- function convertParagraph(node) {
701
- const { children, markDefs } = convertInlineContent(node.content || []);
702
- if (children.length === 0) return null;
703
- const ta = node.attrs?.textAlign;
704
- const textAlign = ta === "center" || ta === "right" || ta === "justify" ? ta : void 0;
705
- return {
706
- _type: "block",
707
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
708
- style: "normal",
709
- children,
710
- ...markDefs.length > 0 ? { markDefs } : {},
711
- ...textAlign ? { textAlign } : {}
712
- };
713
- }
714
- /** Map heading level number to Portable Text style */
715
- function headingLevelToStyle(level) {
716
- switch (level) {
717
- case 1: return "h1";
718
- case 2: return "h2";
719
- case 3: return "h3";
720
- case 4: return "h4";
721
- case 5: return "h5";
722
- case 6: return "h6";
723
- default: return "h1";
724
- }
725
- }
726
- /**
727
- * Convert heading to Portable Text block
728
- */
729
- function convertHeading(node) {
730
- const { children, markDefs } = convertInlineContent(node.content || []);
731
- const style = headingLevelToStyle(typeof node.attrs?.level === "number" ? node.attrs.level : 1);
732
- if (children.length === 0) return null;
733
- const ta = node.attrs?.textAlign;
734
- const textAlign = ta === "center" || ta === "right" || ta === "justify" ? ta : void 0;
735
- return {
736
- _type: "block",
737
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
738
- style,
739
- children,
740
- markDefs: markDefs.length > 0 ? markDefs : void 0,
741
- ...textAlign ? { textAlign } : {}
742
- };
743
- }
744
- /**
745
- * Convert list to Portable Text blocks
746
- */
747
- function convertList$1(node, listItem, path) {
748
- const blocks = [];
749
- const metadata = listItem === "number" ? readOrderedListMetadata(node.attrs, path) : void 0;
750
- for (const [i, item] of (node.content ?? []).entries()) if (item.type === "listItem") {
751
- const itemBlocks = convertListItem$1(item, listItem, 1, `${path}:${i}`, metadata);
752
- blocks.push(...itemBlocks);
753
- }
754
- return blocks;
755
- }
756
- /**
757
- * Convert list item to Portable Text blocks
758
- */
759
- function convertListItem$1(item, listItem, level, path, metadata) {
760
- const blocks = [];
761
- for (const [i, child] of (item.content ?? []).entries()) if (child.type === "paragraph") {
762
- const { children, markDefs } = convertInlineContent(child.content || []);
763
- if (children.length > 0) blocks.push({
764
- _type: "block",
765
- _key: portableTextKeyFromAttrs(child.attrs) ?? generateKey$1(),
766
- style: "normal",
767
- listItem,
768
- level,
769
- ...metadata,
770
- children,
771
- markDefs: markDefs.length > 0 ? markDefs : void 0
772
- });
773
- } else if (child.type === "bulletList") blocks.push(...convertListItemNested(child, "bullet", level + 1, `${path}:${i}`));
774
- else if (child.type === "orderedList") blocks.push(...convertListItemNested(child, "number", level + 1, `${path}:${i}`));
775
- return blocks;
776
- }
777
- /**
778
- * Convert nested list
779
- */
780
- function convertListItemNested(node, listItem, level, path) {
781
- const blocks = [];
782
- const metadata = listItem === "number" ? readOrderedListMetadata(node.attrs, path) : void 0;
783
- for (const [i, item] of (node.content ?? []).entries()) if (item.type === "listItem") blocks.push(...convertListItem$1(item, listItem, level, `${path}:${i}`, metadata));
784
- return blocks;
785
- }
786
- /**
787
- * Convert blockquote to Portable Text blocks
788
- */
789
- function convertBlockquote(node) {
790
- const blocks = [];
791
- for (const child of node.content || []) if (child.type === "paragraph") {
792
- const { children, markDefs } = convertInlineContent(child.content || []);
793
- if (children.length > 0) blocks.push({
794
- _type: "block",
795
- _key: portableTextKeyFromAttrs(child.attrs) ?? portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
796
- style: "blockquote",
797
- children,
798
- markDefs: markDefs.length > 0 ? markDefs : void 0
799
- });
800
- }
801
- return blocks.length === 1 ? blocks[0] : blocks.length > 0 ? blocks : null;
802
- }
803
- /**
804
- * Convert code block to Portable Text
805
- */
806
- function convertCodeBlock$1(node) {
807
- const code = node.content?.map((n) => n.text || "").join("") || "";
808
- const language = typeof node.attrs?.language === "string" ? node.attrs.language : void 0;
809
- return {
810
- _type: "code",
811
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
812
- code,
813
- language: language || void 0
814
- };
815
- }
816
- /**
817
- * Convert HTML block to Portable Text
818
- */
819
- function convertHtmlBlock(node) {
820
- const rawHtml = node.attrs?.html;
821
- return {
822
- _type: "htmlBlock",
823
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
824
- html: typeof rawHtml === "string" ? rawHtml : ""
825
- };
826
- }
827
- /**
828
- * Convert image to Portable Text
829
- */
830
- function convertImage$1(node) {
831
- const attrs = node.attrs;
832
- const provider = typeof attrs?.provider === "string" ? attrs.provider : void 0;
833
- const mediaId = typeof attrs?.mediaId === "string" ? attrs.mediaId : void 0;
834
- const src = typeof attrs?.src === "string" ? attrs.src : "";
835
- const alt = typeof attrs?.alt === "string" ? attrs.alt : void 0;
836
- const title = typeof attrs?.title === "string" ? attrs.title : void 0;
837
- const width = typeof attrs?.width === "number" ? attrs.width : void 0;
838
- const height = typeof attrs?.height === "number" ? attrs.height : void 0;
839
- const displayWidth = typeof attrs?.displayWidth === "number" ? attrs.displayWidth : void 0;
840
- const displayHeight = typeof attrs?.displayHeight === "number" ? attrs.displayHeight : void 0;
841
- const alignment = attrs?.alignment;
842
- return {
843
- _type: "image",
844
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
845
- asset: {
846
- _ref: mediaId || src || "",
847
- url: src || "",
848
- provider: provider && provider !== "local" ? provider : void 0
849
- },
850
- alt: alt || void 0,
851
- caption: title || void 0,
852
- width: width || void 0,
853
- height: height || void 0,
854
- displayWidth: displayWidth || void 0,
855
- displayHeight: displayHeight || void 0,
856
- alignment: alignment === "left" || alignment === "center" || alignment === "right" || alignment === "wide" || alignment === "full" ? alignment : void 0
857
- };
858
- }
859
- /**
860
- * Convert gallery node to Portable Text
861
- */
862
- function convertGallery(node) {
863
- const columns = node.attrs?.columns;
864
- return {
865
- _type: "gallery",
866
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
867
- images: sanitizeGalleryImages(node.attrs?.images, generateKey$1),
868
- ...typeof columns === "number" ? { columns } : {}
869
- };
870
- }
871
- /**
872
- * Convert inline content (text nodes with marks) to Portable Text spans
873
- */
874
- function convertInlineContent(nodes, preserveHardBreakBoundary = false) {
875
- const children = [];
876
- const markDefs = [];
877
- const markDefMap = /* @__PURE__ */ new Map();
878
- const usedSpanKeys = /* @__PURE__ */ new Set();
879
- const claimSpanKey = (preferred) => {
880
- if (preferred && !usedSpanKeys.has(preferred)) {
881
- usedSpanKeys.add(preferred);
882
- return preferred;
883
- }
884
- let key;
885
- do
886
- key = generateKey$1();
887
- while (usedSpanKeys.has(key));
888
- usedSpanKeys.add(key);
889
- return key;
890
- };
891
- for (const node of nodes) if (node.type === "text" && node.text) {
892
- const marks = [];
893
- const originalMarkDefs = portableTextMarkDefsFromMarks(node.marks);
894
- for (const mark of node.marks || []) {
895
- const markType = convertMark(mark, markDefs, markDefMap, originalMarkDefs);
896
- if (markType) marks.push(markType);
897
- }
898
- const preferredKey = portableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs);
899
- const normalizedMarks = marks.length > 0 ? marks : void 0;
900
- const previous = children.at(-1);
901
- if (preferredKey && previous?._key === preferredKey && JSON.stringify(previous.marks) === JSON.stringify(normalizedMarks)) {
902
- previous.text += node.text;
903
- continue;
904
- }
905
- children.push({
906
- _type: "span",
907
- _key: claimSpanKey(preferredKey),
908
- text: node.text,
909
- marks: normalizedMarks
910
- });
911
- } else if (node.type === "hardBreak") if (children.length > 0 && !preserveHardBreakBoundary) {
912
- const lastChild = children.at(-1);
913
- lastChild.text += "\n";
914
- } else children.push({
915
- _type: "span",
916
- _key: claimSpanKey(portableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs)),
917
- text: "\n"
918
- });
919
- if (children.length === 0) children.push({
920
- _type: "span",
921
- _key: claimSpanKey(),
922
- text: ""
923
- });
924
- return {
925
- children,
926
- markDefs
927
- };
928
- }
929
- /**
930
- * Convert a ProseMirror mark to Portable Text mark
931
- */
932
- function convertMark(mark, markDefs, markDefMap, originalMarkDefs) {
933
- switch (mark.type) {
934
- case "bold":
935
- case "strong": return "strong";
936
- case "italic":
937
- case "em": return "em";
938
- case "underline": return "underline";
939
- case "strike":
940
- case "strikethrough": return "strike-through";
941
- case "subscript": return "subscript";
942
- case "superscript": return "superscript";
943
- case "code": return "code";
944
- case PORTABLE_TEXT_SPAN_MARK: return null;
945
- case "link": {
946
- const href = (typeof mark.attrs?.href === "string" ? mark.attrs.href : "") || "";
947
- const blank = mark.attrs?.target === "_blank";
948
- const originalMarkDef = originalMarkDefs.find((markDef) => markDef._type === "link");
949
- const mapKey = originalMarkDef ? `key:${originalMarkDef._key}` : `value:${JSON.stringify([href, blank])}`;
950
- if (markDefMap.has(mapKey)) return markDefMap.get(mapKey);
951
- const key = originalMarkDef?._key || generateKey$1();
952
- markDefs.push({
953
- ...originalMarkDef,
954
- _type: "link",
955
- _key: key,
956
- href,
957
- ...originalMarkDef ? blank || Object.hasOwn(originalMarkDef, "blank") ? { blank } : {} : { blank }
958
- });
959
- markDefMap.set(mapKey, key);
960
- return key;
961
- }
962
- default: throw new UnsupportedPortableTextMarksError([mark.type]);
963
- }
964
- }
965
-
966
- //#endregion
967
- //#region src/content/converters/portable-text-to-prosemirror.ts
968
- /**
969
- * Portable Text to ProseMirror Converter
970
- *
971
- * Converts Portable Text to TipTap's ProseMirror JSON format for editing.
972
- */
973
- function generateKey() {
974
- return Math.random().toString(36).substring(2, 11);
975
- }
976
- /** Convert Portable Text to a ProseMirror document. */
977
- function portableTextToProsemirror(blocks, options = {}) {
978
- if (!blocks || blocks.length === 0) return {
979
- type: "doc",
980
- content: [{ type: "paragraph" }]
981
- };
982
- assertPortableTextMarksSupported(blocks);
983
- const preserveIdentity = options.preserveIdentity === true;
984
- const content = [];
985
- let i = 0;
986
- while (i < blocks.length) {
987
- const block = blocks[i];
988
- if (isTextBlock(block) && block.listItem) {
989
- const listBlocks = [];
990
- const listType = block.listItem;
991
- const runStart = i;
992
- const rootId = listType === "number" ? normalizeListId(block.listId) : void 0;
993
- while (i < blocks.length) {
994
- const current = blocks[i];
995
- if (!isTextBlock(current) || !current.listItem) break;
996
- const level = current.level || 1;
997
- const currentId = current.listItem === "number" ? normalizeListId(current.listId) : void 0;
998
- const sameRootIdentity = listType !== "number" || level > 1 || (rootId ? currentId === rootId : currentId === void 0);
999
- if (level > 1 || current.listItem === listType && sameRootIdentity) {
1000
- listBlocks.push(current);
1001
- i++;
1002
- } else break;
1003
- }
1004
- content.push(convertList(listBlocks, listType, `root:${runStart}`, preserveIdentity));
1005
- } else if (isTextBlock(block) && block.style === "blockquote") {
1006
- const quoteBlocks = [];
1007
- while (i < blocks.length) {
1008
- const current = blocks[i];
1009
- if (!isTextBlock(current) || current.style !== "blockquote" || current.listItem !== void 0) break;
1010
- quoteBlocks.push(current);
1011
- i++;
1012
- }
1013
- content.push({
1014
- type: "blockquote",
1015
- content: quoteBlocks.map((quoteBlock) => {
1016
- const paragraph = convertSpans(quoteBlock.children, quoteBlock.markDefs || [], preserveIdentity);
1017
- return {
1018
- type: "paragraph",
1019
- attrs: identityAttrs(void 0, quoteBlock._key, preserveIdentity),
1020
- content: paragraph.length > 0 ? paragraph : void 0
1021
- };
1022
- })
1023
- });
1024
- } else {
1025
- const converted = convertBlock(block, `root:${i}`, preserveIdentity);
1026
- if (converted) content.push(converted);
1027
- i++;
1028
- }
1029
- }
1030
- return normalizeProseMirrorOrderedListJson({
1031
- type: "doc",
1032
- content: content.length > 0 ? content : [{ type: "paragraph" }]
1033
- });
1034
- }
1035
- function identityAttrs(attrs, key, preserveIdentity) {
1036
- return preserveIdentity ? attrsWithPortableTextKey(attrs, key) : attrs;
1037
- }
1038
- function getListMetadata(item, fallbackSeed) {
1039
- const listId = normalizeListId(item.listId) ?? deriveLegacyListId(fallbackSeed);
1040
- const listStart = normalizeListStart(item.listStart);
1041
- return {
1042
- listId,
1043
- ...listStart === void 0 ? {} : { listStart }
1044
- };
1045
- }
1046
- function belongsToNestedGroup(item, minLevel, parentListType, anchorType, anchorId) {
1047
- if ((item.level || 2) > minLevel) return true;
1048
- if ((item.listItem || parentListType) !== anchorType) return false;
1049
- if (anchorType !== "number") return true;
1050
- const itemId = normalizeListId(item.listId);
1051
- return anchorId ? itemId === anchorId : itemId === void 0;
1052
- }
1053
- /**
1054
- * Type guard for text blocks
1055
- */
1056
- function isTextBlock(block) {
1057
- return block._type === "block";
1058
- }
1059
- /**
1060
- * Type guard for image blocks.
1061
- * Checks both `_type` and that `asset` is a valid object — image blocks
1062
- * without an `asset` wrapper (e.g. `{ _type: "image", url: "..." }`) are
1063
- * malformed and should not be cast to `PortableTextImageBlock`.
1064
- */
1065
- function isImageBlock(block) {
1066
- return block._type === "image" && "asset" in block && typeof block.asset === "object" && block.asset !== null;
1067
- }
1068
- /**
1069
- * Type guard for gallery blocks that carry a usable `images` array.
1070
- * Galleries without one are handled separately in `convertBlock`.
1071
- */
1072
- function isGalleryBlock(block) {
1073
- return block._type === "gallery" && "images" in block && Array.isArray(block.images);
1074
- }
1075
- /**
1076
- * Type guard for code blocks
1077
- */
1078
- function isCodeBlock(block) {
1079
- return block._type === "code";
1080
- }
1081
- /**
1082
- * Convert a single Portable Text block to ProseMirror node
1083
- */
1084
- function convertBlock(block, path, preserveIdentity) {
1085
- if (isTextBlock(block)) return convertTextBlock(block, preserveIdentity);
1086
- if (isImageBlock(block)) return convertImage(block, preserveIdentity);
1087
- if (block._type === "image") return convertMalformedImage(block, preserveIdentity);
1088
- if (isGalleryBlock(block)) return {
1089
- type: "gallery",
1090
- attrs: identityAttrs({
1091
- images: sanitizeGalleryImages(block.images),
1092
- columns: typeof block.columns === "number" ? block.columns : void 0
1093
- }, block._key, preserveIdentity)
1094
- };
1095
- if (isCodeBlock(block)) return convertCodeBlock(block, preserveIdentity);
1096
- if (block._type === "htmlBlock") return {
1097
- type: "htmlBlock",
1098
- attrs: identityAttrs({ html: block.html || "" }, block._key, preserveIdentity)
1099
- };
1100
- if (block._type === "break") return {
1101
- type: "horizontalRule",
1102
- attrs: identityAttrs(void 0, block._key, preserveIdentity)
1103
- };
1104
- if (block._type === "gallery") {
1105
- if (preserveIdentity) return {
1106
- type: PORTABLE_TEXT_BLOCK_NODE,
1107
- attrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block }
1108
- };
1109
- return {
1110
- type: "paragraph",
1111
- content: [{
1112
- type: "text",
1113
- text: `[Unknown block type: ${block._type}]`,
1114
- marks: [{ type: "code" }]
1115
- }]
1116
- };
1117
- }
1118
- if (preserveIdentity) return {
1119
- type: PORTABLE_TEXT_BLOCK_NODE,
1120
- attrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block }
1121
- };
1122
- if (block._type === "table") {
1123
- const result = portableTextTableToProseMirror(block, {
1124
- path,
1125
- createKey: generateKey,
1126
- spansToInline: (content, markDefs) => convertSpans(content, markDefs, preserveIdentity)
1127
- });
1128
- if (!result.ok) throw new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);
1129
- return result.node;
1130
- }
1131
- return {
1132
- type: "paragraph",
1133
- content: [{
1134
- type: "text",
1135
- text: `[Unknown block type: ${block._type}]`,
1136
- marks: [{ type: "code" }]
1137
- }]
1138
- };
1139
- }
1140
- /**
1141
- * Convert text block to ProseMirror paragraph or heading
1142
- */
1143
- function convertTextBlock(block, preserveIdentity) {
1144
- const { style = "normal", children, markDefs = [] } = block;
1145
- const content = convertSpans(children, markDefs, preserveIdentity);
1146
- switch (style) {
1147
- case "h1":
1148
- case "h2":
1149
- case "h3":
1150
- case "h4":
1151
- case "h5":
1152
- case "h6": return {
1153
- type: "heading",
1154
- attrs: identityAttrs({
1155
- level: parseInt(style.substring(1), 10),
1156
- ...block.textAlign ? { textAlign: block.textAlign } : {}
1157
- }, block._key, preserveIdentity),
1158
- content: content.length > 0 ? content : void 0
1159
- };
1160
- case "blockquote": return {
1161
- type: "blockquote",
1162
- attrs: identityAttrs(void 0, block._key, preserveIdentity),
1163
- content: [{
1164
- type: "paragraph",
1165
- content: content.length > 0 ? content : void 0
1166
- }]
1167
- };
1168
- default: return {
1169
- type: "paragraph",
1170
- attrs: identityAttrs(block.textAlign ? { textAlign: block.textAlign } : void 0, block._key, preserveIdentity),
1171
- content: content.length > 0 ? content : void 0
1172
- };
1173
- }
1174
- }
1175
- /**
1176
- * Convert list items to ProseMirror list
1177
- */
1178
- function convertList(items, listType, context, preserveIdentity) {
1179
- const rootItems = [];
1180
- let i = 0;
1181
- while (i < items.length) {
1182
- const item = items[i];
1183
- if ((item.level || 1) === 1) {
1184
- const nestedItems = [];
1185
- i++;
1186
- while (i < items.length && (items[i].level || 1) > 1) {
1187
- nestedItems.push(items[i]);
1188
- i++;
1189
- }
1190
- rootItems.push(convertListItem(item, nestedItems, listType, `${context}:${rootItems.length}`, preserveIdentity));
1191
- } else {
1192
- rootItems.push(convertListItem(item, [], listType, `${context}:${rootItems.length}`, preserveIdentity));
1193
- i++;
1194
- }
1195
- }
1196
- const metadata = listType === "number" ? getListMetadata(items[0], `${context}:${items[0]._key}`) : void 0;
1197
- return {
1198
- type: listType === "bullet" ? "bulletList" : "orderedList",
1199
- attrs: metadata ? {
1200
- ...metadata,
1201
- start: metadata.listStart ?? 1
1202
- } : void 0,
1203
- content: rootItems
1204
- };
1205
- }
1206
- /**
1207
- * Convert a single list item to ProseMirror
1208
- */
1209
- function convertListItem(item, nestedItems, parentListType, context, preserveIdentity) {
1210
- const content = [];
1211
- const spans = convertSpans(item.children, item.markDefs || [], preserveIdentity);
1212
- content.push({
1213
- type: "paragraph",
1214
- attrs: identityAttrs(void 0, item._key, preserveIdentity),
1215
- content: spans.length > 0 ? spans : void 0
1216
- });
1217
- if (nestedItems.length > 0) {
1218
- let minLevel = Infinity;
1219
- for (const ni of nestedItems) {
1220
- const level = ni.level || 2;
1221
- if (level < minLevel) minLevel = level;
1222
- }
1223
- let j = 0;
1224
- while (j < nestedItems.length) {
1225
- const anchorType = nestedItems[j].listItem || parentListType;
1226
- const anchorId = anchorType === "number" ? normalizeListId(nestedItems[j].listId) : void 0;
1227
- const nestedGroup = [];
1228
- do {
1229
- nestedGroup.push(nestedItems[j]);
1230
- j++;
1231
- } while (j < nestedItems.length && belongsToNestedGroup(nestedItems[j], minLevel, parentListType, anchorType, anchorId));
1232
- if (nestedGroup.length > 0) {
1233
- const adjustedGroup = nestedGroup.map((ni) => ({
1234
- ...ni,
1235
- level: (ni.level || 2) - 1
1236
- }));
1237
- content.push(convertList(adjustedGroup, anchorType, `${context}:nested:${j - nestedGroup.length}`, preserveIdentity));
1238
- }
1239
- }
1240
- }
1241
- return {
1242
- type: "listItem",
1243
- content
1244
- };
1245
- }
1246
- /**
1247
- * Convert Portable Text spans to ProseMirror text nodes
1248
- */
1249
- function convertSpans(spans, markDefs, preserveIdentity) {
1250
- const nodes = [];
1251
- const markDefsMap = new Map(markDefs.map((md) => [md._key, md]));
1252
- for (const span of spans) {
1253
- if (span._type !== "span") continue;
1254
- const referencedMarkDefs = markDefs.filter((markDef) => span.marks?.includes(markDef._key));
1255
- const parts = span.text.split("\n");
1256
- for (let i = 0; i < parts.length; i++) {
1257
- const text = parts[i];
1258
- if (text.length > 0) {
1259
- const marks = convertMarks(span.marks || [], markDefsMap);
1260
- if (preserveIdentity) marks.push({
1261
- type: PORTABLE_TEXT_SPAN_MARK,
1262
- attrs: {
1263
- key: span._key,
1264
- markDefs: referencedMarkDefs
1265
- }
1266
- });
1267
- const node = {
1268
- type: "text",
1269
- text
1270
- };
1271
- if (marks.length > 0) node.marks = marks;
1272
- nodes.push(node);
1273
- }
1274
- if (i < parts.length - 1) nodes.push(preserveIdentity ? {
1275
- type: "hardBreak",
1276
- marks: [{
1277
- type: PORTABLE_TEXT_SPAN_MARK,
1278
- attrs: {
1279
- key: span._key,
1280
- markDefs: referencedMarkDefs
1281
- }
1282
- }]
1283
- } : { type: "hardBreak" });
1284
- }
1285
- }
1286
- return nodes;
1287
- }
1288
- /**
1289
- * Convert Portable Text marks to ProseMirror marks
1290
- */
1291
- function convertMarks(marks, markDefs) {
1292
- const pmMarks = [];
1293
- for (const mark of marks) switch (mark) {
1294
- case "strong":
1295
- pmMarks.push({ type: "bold" });
1296
- break;
1297
- case "em":
1298
- pmMarks.push({ type: "italic" });
1299
- break;
1300
- case "underline":
1301
- pmMarks.push({ type: "underline" });
1302
- break;
1303
- case "strike-through":
1304
- pmMarks.push({ type: "strike" });
1305
- break;
1306
- case "subscript":
1307
- pmMarks.push({ type: "subscript" });
1308
- break;
1309
- case "superscript":
1310
- pmMarks.push({ type: "superscript" });
1311
- break;
1312
- case "code":
1313
- pmMarks.push({ type: "code" });
1314
- break;
1315
- default: {
1316
- const markDef = markDefs.get(mark);
1317
- if (markDef?._type === "link") pmMarks.push({
1318
- type: "link",
1319
- attrs: {
1320
- href: markDef.href,
1321
- target: markDef.blank ? "_blank" : null
1322
- }
1323
- });
1324
- else throw new UnsupportedPortableTextMarksError([typeof markDef?._type === "string" ? markDef._type : mark]);
1325
- break;
1326
- }
1327
- }
1328
- return pmMarks;
1329
- }
1330
- function imageAlignment(value) {
1331
- return value === "left" || value === "center" || value === "right" || value === "wide" || value === "full" ? value : void 0;
1332
- }
1333
- /**
1334
- * Convert image block to ProseMirror
1335
- */
1336
- function convertImage(block, preserveIdentity) {
1337
- return {
1338
- type: "image",
1339
- attrs: identityAttrs({
1340
- src: block.asset.url || block.asset._ref,
1341
- alt: block.alt || "",
1342
- title: block.caption || "",
1343
- mediaId: block.asset._ref,
1344
- provider: block.asset.provider,
1345
- width: block.width,
1346
- height: block.height,
1347
- displayWidth: block.displayWidth,
1348
- displayHeight: block.displayHeight,
1349
- alignment: imageAlignment(block.alignment)
1350
- }, block._key, preserveIdentity)
1351
- };
1352
- }
1353
- /**
1354
- * Convert a malformed image block (missing `asset` wrapper) to ProseMirror.
1355
- * Handles blocks like `{ _type: "image", url: "...", alt: "..." }` that may
1356
- * originate from migrations or third-party imports.
1357
- */
1358
- function convertMalformedImage(block, preserveIdentity) {
1359
- return {
1360
- type: "image",
1361
- attrs: identityAttrs({
1362
- src: "url" in block && typeof block.url === "string" ? block.url : "",
1363
- alt: "alt" in block && typeof block.alt === "string" ? block.alt : "",
1364
- title: "caption" in block && typeof block.caption === "string" ? block.caption : "",
1365
- mediaId: void 0,
1366
- provider: void 0,
1367
- width: "width" in block && typeof block.width === "number" ? block.width : void 0,
1368
- height: "height" in block && typeof block.height === "number" ? block.height : void 0,
1369
- displayWidth: "displayWidth" in block && typeof block.displayWidth === "number" ? block.displayWidth : void 0,
1370
- displayHeight: "displayHeight" in block && typeof block.displayHeight === "number" ? block.displayHeight : void 0,
1371
- alignment: imageAlignment("alignment" in block ? block.alignment : void 0)
1372
- }, block._key, preserveIdentity)
1373
- };
1374
- }
1375
- /**
1376
- * Convert code block to ProseMirror
1377
- */
1378
- function convertCodeBlock(block, preserveIdentity) {
1379
- return {
1380
- type: "codeBlock",
1381
- attrs: identityAttrs({ language: block.language || null }, block._key, preserveIdentity),
1382
- content: block.code ? [{
1383
- type: "text",
1384
- text: block.code
1385
- }] : void 0
1386
- };
1387
- }
1388
-
1389
- //#endregion
1390
- //#region src/plugins/define-plugin.ts
1391
- /**
1392
- * definePlugin() Helper
1393
- *
1394
- * Native plugin authoring entry. Returns a fully-resolved
1395
- * `ResolvedPlugin` ready for the host integration to mount.
1396
- *
1397
- * Sandboxed plugins do NOT use this function. They default-export
1398
- * a bare `{ hooks?, routes? }` object with a `satisfies SandboxedPlugin`
1399
- * annotation from `emdash/plugin`. See the `emdash` changeset for the
1400
- * authoring shape.
1401
- */
1402
- const MCP_TOOL_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
1403
- /**
1404
- * Define a native EmDash plugin.
1405
- *
1406
- * Native plugins ship as regular npm modules, get installed via
1407
- * `pnpm add` + an `astro.config.mjs` edit, and run in the host
1408
- * process. They have full access to the runtime — capabilities are
1409
- * still enforced by `PluginContextFactory`, but there is no isolation
1410
- * boundary.
1411
- *
1412
- * @example
1413
- * ```typescript
1414
- * import { definePlugin } from "emdash";
1415
- *
1416
- * export default definePlugin({
1417
- * id: "my-plugin",
1418
- * version: "1.0.0",
1419
- * capabilities: ["content:read"],
1420
- * hooks: {
1421
- * "content:beforeSave": async (event, ctx) => {
1422
- * ctx.log.info("Saving content", { collection: event.collection });
1423
- * return event.content;
1424
- * }
1425
- * },
1426
- * routes: {
1427
- * "sync": {
1428
- * handler: async (ctx) => {
1429
- * return { status: "ok" };
1430
- * }
1431
- * }
1432
- * }
1433
- * });
1434
- * ```
1435
- *
1436
- * Sandboxed-format plugins do not use `definePlugin`. They
1437
- * default-export a bare `{ hooks?, routes? }` object with a
1438
- * `satisfies SandboxedPlugin` annotation from `emdash/plugin`. Calling
1439
- * `definePlugin` with an object that has no `id` throws at runtime
1440
- * (the type system already rejects it at compile time — this check is
1441
- * for callers that bypass typechecking).
1442
- */
1443
- function definePlugin(definition) {
1444
- if (typeof definition.id !== "string" || definition.id.length === 0) throw new Error(`definePlugin() requires \`id\` (got ${typeof definition.id}). For native plugins, make sure your definition has both \`id\` and \`version\`. For sandboxed plugins, drop \`definePlugin()\` entirely and \`export default { hooks, routes } satisfies SandboxedPlugin\` from "emdash/plugin" — identity comes from \`emdash-plugin.jsonc\`.`);
1445
- return defineNativePlugin(definition);
1446
- }
1447
- /**
1448
- * Internal: define a native-format plugin with full validation and normalization.
1449
- */
1450
- function defineNativePlugin(definition) {
1451
- const SIMPLE_ID = /^[a-z0-9-]+$/;
1452
- const SCOPED_ID = /^@[a-z0-9-]+\/[a-z0-9-]+$/;
1453
- const SEMVER_PATTERN = /^\d+\.\d+\.\d+/;
1454
- const { id, version, capabilities = [], allowedHosts = [], hooks = {}, routes = {}, mcp = { tools: {} }, admin = {} } = definition;
1455
- const storage = definition.storage ?? {};
1456
- if (!SIMPLE_ID.test(id) && !SCOPED_ID.test(id)) throw new Error(`Invalid plugin id "${id}". Must be lowercase alphanumeric with dashes (e.g., "my-plugin" or "@scope/my-plugin").`);
1457
- if (!SEMVER_PATTERN.test(version)) throw new Error(`Invalid plugin version "${version}". Must be semver format (e.g., "1.0.0").`);
1458
- for (const [name, tool] of Object.entries(mcp.tools)) {
1459
- if (!MCP_TOOL_NAME_PATTERN.test(name)) throw new Error(`Invalid MCP tool name "${name}" in plugin "${id}".`);
1460
- const route = routes[tool.route];
1461
- if (!route) throw new Error(`MCP tool "${name}" references unknown route "${tool.route}".`);
1462
- if (route.public) throw new Error(`MCP tool "${name}" cannot reference a public route.`);
1463
- if (!route.permission) throw new Error(`MCP route "${tool.route}" must declare a permission.`);
1464
- }
1465
- const validCapabilities = new Set([
1466
- "network:request",
1467
- "network:request:unrestricted",
1468
- "content:read",
1469
- "content:write",
1470
- "taxonomies:read",
1471
- "media:read",
1472
- "media:write",
1473
- "users:read",
1474
- "email:send",
1475
- "hooks.email-transport:register",
1476
- "hooks.email-events:register",
1477
- "hooks.page-fragments:register",
1478
- "network:fetch",
1479
- "network:fetch:any",
1480
- "read:content",
1481
- "write:content",
1482
- "read:media",
1483
- "write:media",
1484
- "read:users",
1485
- "email:provide",
1486
- "email:intercept",
1487
- "page:inject"
1488
- ]);
1489
- for (const cap of capabilities) if (!validCapabilities.has(cap)) throw new Error(`Invalid capability "${cap}" in plugin "${id}".`);
1490
- const canonical = normalizeCapabilities(capabilities);
1491
- const normalizedCapabilities = [...canonical];
1492
- if (canonical.includes("content:write") && !canonical.includes("content:read")) normalizedCapabilities.push("content:read");
1493
- if (canonical.includes("media:write") && !canonical.includes("media:read")) normalizedCapabilities.push("media:read");
1494
- if (canonical.includes("network:request:unrestricted") && !canonical.includes("network:request")) normalizedCapabilities.push("network:request");
1495
- return {
1496
- id,
1497
- version,
1498
- capabilities: normalizedCapabilities,
1499
- allowedHosts,
1500
- storage,
1501
- hooks: resolveHooks(hooks, id),
1502
- routes,
1503
- mcp,
1504
- admin
1505
- };
1506
- }
1507
- /**
1508
- * Resolve hooks to normalized format with defaults.
1509
- *
1510
- * PluginHooks and ResolvedPluginHooks share the same keys — each input value is
1511
- * `HookConfig<H> | H` and the output is `ResolvedHook<H>`. TS can't narrow
1512
- * the handler type through a dynamic key, so we assert at the loop boundary.
1513
- */
1514
- function resolveHooks(hooks, pluginId) {
1515
- const resolved = {};
1516
- for (const key of Object.keys(hooks)) {
1517
- const hook = hooks[key];
1518
- if (hook) resolved[key] = resolveHook(hook, pluginId);
1519
- }
1520
- return resolved;
1521
- }
1522
- /**
1523
- * Check if a hook value is a config object (has a `handler` property)
1524
- */
1525
- function isHookConfig(hook) {
1526
- return typeof hook === "object" && hook !== null && "handler" in hook;
1527
- }
1528
- /**
1529
- * Resolve a single hook to normalized format
1530
- */
1531
- function resolveHook(hook, pluginId) {
1532
- if (isHookConfig(hook)) {
1533
- if (hook.exclusive !== void 0 && typeof hook.exclusive !== "boolean") throw new Error(`Invalid "exclusive" value in hook config for plugin "${pluginId}". Must be boolean.`);
1534
- return {
1535
- priority: hook.priority ?? 100,
1536
- timeout: hook.timeout ?? 5e3,
1537
- dependencies: hook.dependencies ?? [],
1538
- errorPolicy: hook.errorPolicy ?? "abort",
1539
- exclusive: hook.exclusive ?? false,
1540
- handler: hook.handler,
1541
- pluginId
1542
- };
1543
- }
1544
- return {
1545
- priority: 100,
1546
- timeout: 5e3,
1547
- dependencies: [],
1548
- errorPolicy: "abort",
1549
- exclusive: false,
1550
- handler: hook,
1551
- pluginId
1552
- };
1553
- }
1554
-
1555
- //#endregion
1556
- //#region src/plugins/hooks.ts
1557
- /**
1558
- * Plugin Hooks System v2
1559
- *
1560
- * Uses the unified PluginContext for all hooks.
1561
- * Manages lifecycle hooks with:
1562
- * - Deterministic ordering via priority + dependencies
1563
- * - Timeout enforcement
1564
- * - Error isolation
1565
- * - Observability
1566
- *
1567
- */
1568
- /**
1569
- * Hook pipeline for executing hooks in order
1570
- */
1571
- var HookPipeline = class HookPipeline {
1572
- hooks = /* @__PURE__ */ new Map();
1573
- pluginMap = /* @__PURE__ */ new Map();
1574
- contextFactory = null;
1575
- /** Stored so setContextFactory can merge incrementally. */
1576
- contextFactoryOptions = {};
1577
- /** Hook names where at least one handler declared exclusive: true */
1578
- exclusiveHookNames = /* @__PURE__ */ new Set();
1579
- /**
1580
- * Selected provider plugin ID for each exclusive hook.
1581
- * Set by the PluginManager after resolution.
1582
- */
1583
- exclusiveSelections = /* @__PURE__ */ new Map();
1584
- constructor(plugins, factoryOptions) {
1585
- if (factoryOptions) {
1586
- this.contextFactory = new PluginContextFactory(factoryOptions);
1587
- this.contextFactoryOptions = { ...factoryOptions };
1588
- }
1589
- for (const plugin of plugins) this.pluginMap.set(plugin.id, plugin);
1590
- this.registerPlugins(plugins);
1591
- }
1592
- /**
1593
- * Set or update the context factory options.
1594
- *
1595
- * When called on a pipeline that already has a factory, the new options
1596
- * are merged on top of the existing ones so that callers don't need to
1597
- * repeat every field (e.g. adding `cronReschedule` without losing
1598
- * `storage` / `getUploadUrl`).
1599
- */
1600
- setContextFactory(options) {
1601
- const merged = {
1602
- ...this.contextFactoryOptions,
1603
- ...options
1604
- };
1605
- this.contextFactory = new PluginContextFactory(merged);
1606
- this.contextFactoryOptions = merged;
1607
- }
1608
- /**
1609
- * Get context for a plugin
1610
- */
1611
- getContext(pluginId) {
1612
- const plugin = this.pluginMap.get(pluginId);
1613
- if (!plugin) throw new Error(`Plugin "${pluginId}" not found`);
1614
- if (!this.contextFactory) throw new Error("Context factory not initialized - call setContextFactory first");
1615
- return this.contextFactory.createContext(plugin);
1616
- }
1617
- /**
1618
- * Get typed hooks for a specific hook name.
1619
- * The internal map stores ResolvedHook<unknown>, but we know each name
1620
- * maps to a specific handler type via HookHandlerMap.
1621
- *
1622
- * Exclusive hooks that have a selected provider are filtered out — they
1623
- * should only run via invokeExclusiveHook(), not in the regular pipeline.
1624
- */
1625
- getTypedHooks(name) {
1626
- const all = this.hooks.get(name) ?? [];
1627
- if (this.exclusiveSelections.has(name)) return all.filter((h) => !h.exclusive);
1628
- return all;
1629
- }
1630
- /**
1631
- * Register all hooks from plugins.
1632
- *
1633
- * Registers each hook name individually to preserve type safety. The
1634
- * internal map stores ResolvedHook<unknown> since it's keyed by string,
1635
- * but getTypedHooks() restores the correct handler type on retrieval.
1636
- */
1637
- registerPlugins(plugins) {
1638
- for (const plugin of plugins) {
1639
- this.registerPluginHook(plugin, "plugin:install");
1640
- this.registerPluginHook(plugin, "plugin:activate");
1641
- this.registerPluginHook(plugin, "plugin:deactivate");
1642
- this.registerPluginHook(plugin, "plugin:uninstall");
1643
- this.registerPluginHook(plugin, "content:beforeSave");
1644
- this.registerPluginHook(plugin, "content:afterSave");
1645
- this.registerPluginHook(plugin, "content:beforeDelete");
1646
- this.registerPluginHook(plugin, "content:afterDelete");
1647
- this.registerPluginHook(plugin, "content:afterPublish");
1648
- this.registerPluginHook(plugin, "content:afterUnpublish");
1649
- this.registerPluginHook(plugin, "content:afterRestore");
1650
- this.registerPluginHook(plugin, "content:afterSchedule");
1651
- this.registerPluginHook(plugin, "content:afterUnschedule");
1652
- this.registerPluginHook(plugin, "media:beforeUpload");
1653
- this.registerPluginHook(plugin, "media:afterUpload");
1654
- this.registerPluginHook(plugin, "cron");
1655
- this.registerPluginHook(plugin, "email:beforeSend");
1656
- this.registerPluginHook(plugin, "email:deliver");
1657
- this.registerPluginHook(plugin, "email:afterSend");
1658
- this.registerPluginHook(plugin, "comment:beforeCreate");
1659
- this.registerPluginHook(plugin, "comment:moderate");
1660
- this.registerPluginHook(plugin, "comment:afterCreate");
1661
- this.registerPluginHook(plugin, "comment:afterModerate");
1662
- this.registerPluginHook(plugin, "page:metadata");
1663
- this.registerPluginHook(plugin, "page:fragments");
1664
- }
1665
- for (const [hookName, hooks] of this.hooks) this.hooks.set(hookName, this.sortHooks(hooks));
1666
- }
1667
- /**
1668
- * Maps hook names to the capability required to register them.
1669
- *
1670
- * Hooks not listed here have no capability requirement (e.g. lifecycle
1671
- * hooks, cron). Any plugin declaring a listed hook without the required
1672
- * capability will have that hook silently skipped at registration time.
1673
- */
1674
- static HOOK_REQUIRED_CAPABILITY = new Map([
1675
- ["email:beforeSend", "hooks.email-events:register"],
1676
- ["email:afterSend", "hooks.email-events:register"],
1677
- ["email:deliver", "hooks.email-transport:register"],
1678
- ["content:beforeSave", "content:write"],
1679
- ["content:afterSave", "content:read"],
1680
- ["content:beforeDelete", "content:read"],
1681
- ["content:afterDelete", "content:read"],
1682
- ["content:afterPublish", "content:read"],
1683
- ["content:afterUnpublish", "content:read"],
1684
- ["content:afterRestore", "content:read"],
1685
- ["content:afterSchedule", "content:read"],
1686
- ["content:afterUnschedule", "content:read"],
1687
- ["media:beforeUpload", "media:write"],
1688
- ["media:afterUpload", "media:read"],
1689
- ["comment:beforeCreate", "users:read"],
1690
- ["comment:moderate", "users:read"],
1691
- ["comment:afterCreate", "users:read"],
1692
- ["comment:afterModerate", "users:read"],
1693
- ["page:fragments", "hooks.page-fragments:register"]
1694
- ]);
1695
- /**
1696
- * Register a single plugin's hook by name
1697
- */
1698
- registerPluginHook(plugin, name) {
1699
- const hook = plugin.hooks[name];
1700
- if (!hook) return;
1701
- const requiredCapability = HookPipeline.HOOK_REQUIRED_CAPABILITY.get(name);
1702
- if (requiredCapability && !plugin.capabilities.includes(requiredCapability)) {
1703
- console.warn(`[hooks] Plugin "${plugin.id}" declares ${name} hook without ${requiredCapability} capability — skipping`);
1704
- return;
1705
- }
1706
- if (hook.exclusive) this.exclusiveHookNames.add(name);
1707
- this.registerHook(name, hook);
1708
- }
1709
- /**
1710
- * Register a single hook
1711
- */
1712
- registerHook(name, hook) {
1713
- const existing = this.hooks.get(name) || [];
1714
- existing.push(hook);
1715
- this.hooks.set(name, existing);
1716
- }
1717
- /**
1718
- * Sort hooks by priority and dependencies
1719
- */
1720
- sortHooks(hooks) {
1721
- const sorted = [];
1722
- const remaining = [...hooks];
1723
- while (remaining.length > 0) {
1724
- const ready = remaining.filter((hook) => hook.dependencies.every((dep) => sorted.some((s) => s.pluginId === dep)));
1725
- if (ready.length === 0) {
1726
- const pluginIds = remaining.map((h) => h.pluginId).join(", ");
1727
- console.warn(`[hooks] Hook dependency cycle or missing dependency detected among plugins: ${pluginIds}. Falling back to priority order.`);
1728
- remaining.sort((a, b) => a.priority - b.priority);
1729
- sorted.push(...remaining);
1730
- break;
1731
- }
1732
- ready.sort((a, b) => a.priority - b.priority);
1733
- const next = ready[0];
1734
- sorted.push(next);
1735
- remaining.splice(remaining.indexOf(next), 1);
1736
- }
1737
- return sorted;
1738
- }
1739
- /**
1740
- * Execute a hook with timeout
1741
- */
1742
- async executeWithTimeout(fn, timeout) {
1743
- let timer;
1744
- const timeoutPromise = new Promise((_, reject) => timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Hook timeout after ${timeout}ms`)), timeout));
1745
- try {
1746
- return await Promise.race([fn(), timeoutPromise]);
1747
- } finally {
1748
- clearTimeout(timer);
1749
- }
1750
- }
1751
- /**
1752
- * Run plugin:install hooks
1753
- */
1754
- async runPluginInstall(pluginId) {
1755
- return this.runLifecycleHook("plugin:install", pluginId);
1756
- }
1757
- /**
1758
- * Run plugin:activate hooks
1759
- */
1760
- async runPluginActivate(pluginId) {
1761
- return this.runLifecycleHook("plugin:activate", pluginId);
1762
- }
1763
- /**
1764
- * Run plugin:deactivate hooks
1765
- */
1766
- async runPluginDeactivate(pluginId) {
1767
- return this.runLifecycleHook("plugin:deactivate", pluginId);
1768
- }
1769
- /**
1770
- * Run plugin:uninstall hooks
1771
- */
1772
- async runPluginUninstall(pluginId, deleteData) {
1773
- const hooks = this.getTypedHooks("plugin:uninstall");
1774
- const results = [];
1775
- const hook = hooks.find((h) => h.pluginId === pluginId);
1776
- if (!hook) return results;
1777
- const { handler } = hook;
1778
- const event = { deleteData };
1779
- const ctx = this.getContext(pluginId);
1780
- const start = Date.now();
1781
- try {
1782
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1783
- results.push({
1784
- success: true,
1785
- pluginId: hook.pluginId,
1786
- duration: Date.now() - start
1787
- });
1788
- } catch (error) {
1789
- results.push({
1790
- success: false,
1791
- error: error instanceof Error ? error : new Error(String(error)),
1792
- pluginId: hook.pluginId,
1793
- duration: Date.now() - start
1794
- });
1795
- }
1796
- return results;
1797
- }
1798
- async runLifecycleHook(hookName, pluginId) {
1799
- const hooks = this.getTypedHooks(hookName);
1800
- const results = [];
1801
- const hook = hooks.find((h) => h.pluginId === pluginId);
1802
- if (!hook) return results;
1803
- const { handler } = hook;
1804
- const event = {};
1805
- const ctx = this.getContext(pluginId);
1806
- const start = Date.now();
1807
- try {
1808
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1809
- results.push({
1810
- success: true,
1811
- pluginId: hook.pluginId,
1812
- duration: Date.now() - start
1813
- });
1814
- } catch (error) {
1815
- results.push({
1816
- success: false,
1817
- error: error instanceof Error ? error : new Error(String(error)),
1818
- pluginId: hook.pluginId,
1819
- duration: Date.now() - start
1820
- });
1821
- }
1822
- return results;
1823
- }
1824
- /**
1825
- * Run content:beforeSave hooks
1826
- * Returns modified content from the pipeline. `id` is the existing item's
1827
- * ID when updating. `actor` is the authenticated user that triggered the
1828
- * save, when one is available.
1829
- */
1830
- async runContentBeforeSave(content, collection, isNew, id, actor) {
1831
- const hooks = this.getTypedHooks("content:beforeSave");
1832
- const results = [];
1833
- let currentContent = content;
1834
- for (const hook of hooks) {
1835
- const { handler } = hook;
1836
- const event = {
1837
- content: currentContent,
1838
- collection,
1839
- isNew
1840
- };
1841
- if (id !== void 0) event.id = id;
1842
- if (actor !== void 0) event.actor = { ...actor };
1843
- const ctx = this.getContext(hook.pluginId);
1844
- const start = Date.now();
1845
- try {
1846
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1847
- if (result !== void 0) currentContent = result;
1848
- results.push({
1849
- success: true,
1850
- value: currentContent,
1851
- pluginId: hook.pluginId,
1852
- duration: Date.now() - start
1853
- });
1854
- } catch (error) {
1855
- results.push({
1856
- success: false,
1857
- error: error instanceof Error ? error : new Error(String(error)),
1858
- pluginId: hook.pluginId,
1859
- duration: Date.now() - start
1860
- });
1861
- if (hook.errorPolicy === "abort") throw error;
1862
- }
1863
- }
1864
- return {
1865
- content: currentContent,
1866
- results
1867
- };
1868
- }
1869
- /**
1870
- * Run content:afterSave hooks
1871
- */
1872
- async runContentAfterSave(content, collection, isNew, actor) {
1873
- const hooks = this.getTypedHooks("content:afterSave");
1874
- const results = [];
1875
- for (const hook of hooks) {
1876
- const { handler } = hook;
1877
- const event = {
1878
- content,
1879
- collection,
1880
- isNew
1881
- };
1882
- if (actor !== void 0) event.actor = { ...actor };
1883
- const ctx = this.getContext(hook.pluginId);
1884
- const start = Date.now();
1885
- try {
1886
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1887
- results.push({
1888
- success: true,
1889
- pluginId: hook.pluginId,
1890
- duration: Date.now() - start
1891
- });
1892
- } catch (error) {
1893
- results.push({
1894
- success: false,
1895
- error: error instanceof Error ? error : new Error(String(error)),
1896
- pluginId: hook.pluginId,
1897
- duration: Date.now() - start
1898
- });
1899
- if (hook.errorPolicy === "abort") throw error;
1900
- }
1901
- }
1902
- return results;
1903
- }
1904
- /**
1905
- * Run content:beforeDelete hooks
1906
- * Returns whether deletion is allowed
1907
- */
1908
- async runContentBeforeDelete(id, collection) {
1909
- const hooks = this.getTypedHooks("content:beforeDelete");
1910
- const results = [];
1911
- let allowed = true;
1912
- for (const hook of hooks) {
1913
- const { handler } = hook;
1914
- const event = {
1915
- id,
1916
- collection,
1917
- permanent: false
1918
- };
1919
- const ctx = this.getContext(hook.pluginId);
1920
- const start = Date.now();
1921
- try {
1922
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1923
- if (result === false) allowed = false;
1924
- results.push({
1925
- success: true,
1926
- value: result !== false,
1927
- pluginId: hook.pluginId,
1928
- duration: Date.now() - start
1929
- });
1930
- } catch (error) {
1931
- results.push({
1932
- success: false,
1933
- error: error instanceof Error ? error : new Error(String(error)),
1934
- pluginId: hook.pluginId,
1935
- duration: Date.now() - start
1936
- });
1937
- if (hook.errorPolicy === "abort") throw error;
1938
- }
1939
- }
1940
- return {
1941
- allowed,
1942
- results
1943
- };
1944
- }
1945
- /**
1946
- * Run content:afterDelete hooks
1947
- */
1948
- async runContentAfterDelete(id, collection, permanent) {
1949
- const hooks = this.getTypedHooks("content:afterDelete");
1950
- const results = [];
1951
- for (const hook of hooks) {
1952
- const { handler } = hook;
1953
- const event = {
1954
- id,
1955
- collection,
1956
- permanent
1957
- };
1958
- const ctx = this.getContext(hook.pluginId);
1959
- const start = Date.now();
1960
- try {
1961
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1962
- results.push({
1963
- success: true,
1964
- pluginId: hook.pluginId,
1965
- duration: Date.now() - start
1966
- });
1967
- } catch (error) {
1968
- results.push({
1969
- success: false,
1970
- error: error instanceof Error ? error : new Error(String(error)),
1971
- pluginId: hook.pluginId,
1972
- duration: Date.now() - start
1973
- });
1974
- if (hook.errorPolicy === "abort") throw error;
1975
- }
1976
- }
1977
- return results;
1978
- }
1979
- /**
1980
- * Run content state-change hooks that all share the same event shape.
1981
- */
1982
- async runContentStateChangeHook(name, content, collection) {
1983
- const hooks = this.getTypedHooks(name);
1984
- const results = [];
1985
- for (const hook of hooks) {
1986
- const { handler } = hook;
1987
- const event = {
1988
- content,
1989
- collection
1990
- };
1991
- const ctx = this.getContext(hook.pluginId);
1992
- const start = Date.now();
1993
- try {
1994
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1995
- results.push({
1996
- success: true,
1997
- pluginId: hook.pluginId,
1998
- duration: Date.now() - start
1999
- });
2000
- } catch (error) {
2001
- results.push({
2002
- success: false,
2003
- error: error instanceof Error ? error : new Error(String(error)),
2004
- pluginId: hook.pluginId,
2005
- duration: Date.now() - start
2006
- });
2007
- if (hook.errorPolicy === "abort") throw error;
2008
- }
2009
- }
2010
- return results;
2011
- }
2012
- /**
2013
- * Run content:afterPublish hooks (fire-and-forget).
2014
- */
2015
- async runContentAfterPublish(content, collection) {
2016
- return this.runContentStateChangeHook("content:afterPublish", content, collection);
2017
- }
2018
- /**
2019
- * Run content:afterUnpublish hooks (fire-and-forget).
2020
- */
2021
- async runContentAfterUnpublish(content, collection) {
2022
- return this.runContentStateChangeHook("content:afterUnpublish", content, collection);
2023
- }
2024
- /**
2025
- * Run content:afterRestore hooks (fire-and-forget).
2026
- */
2027
- async runContentAfterRestore(content, collection) {
2028
- return this.runContentStateChangeHook("content:afterRestore", content, collection);
2029
- }
2030
- /**
2031
- * Run content:afterSchedule hooks (fire-and-forget).
2032
- */
2033
- async runContentAfterSchedule(content, collection) {
2034
- return this.runContentStateChangeHook("content:afterSchedule", content, collection);
2035
- }
2036
- /**
2037
- * Run content:afterUnschedule hooks (fire-and-forget).
2038
- */
2039
- async runContentAfterUnschedule(content, collection) {
2040
- return this.runContentStateChangeHook("content:afterUnschedule", content, collection);
2041
- }
2042
- /**
2043
- * Run media:beforeUpload hooks
2044
- */
2045
- async runMediaBeforeUpload(file) {
2046
- const hooks = this.getTypedHooks("media:beforeUpload");
2047
- const results = [];
2048
- let currentFile = file;
2049
- for (const hook of hooks) {
2050
- const { handler } = hook;
2051
- const event = { file: currentFile };
2052
- const ctx = this.getContext(hook.pluginId);
2053
- const start = Date.now();
2054
- try {
2055
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2056
- if (result !== void 0) currentFile = result;
2057
- results.push({
2058
- success: true,
2059
- value: currentFile,
2060
- pluginId: hook.pluginId,
2061
- duration: Date.now() - start
2062
- });
2063
- } catch (error) {
2064
- results.push({
2065
- success: false,
2066
- error: error instanceof Error ? error : new Error(String(error)),
2067
- pluginId: hook.pluginId,
2068
- duration: Date.now() - start
2069
- });
2070
- if (hook.errorPolicy === "abort") throw error;
2071
- }
2072
- }
2073
- return {
2074
- file: currentFile,
2075
- results
2076
- };
2077
- }
2078
- /**
2079
- * Run media:afterUpload hooks
2080
- */
2081
- async runMediaAfterUpload(media) {
2082
- const hooks = this.getTypedHooks("media:afterUpload");
2083
- const results = [];
2084
- for (const hook of hooks) {
2085
- const { handler } = hook;
2086
- const event = { media };
2087
- const ctx = this.getContext(hook.pluginId);
2088
- const start = Date.now();
2089
- try {
2090
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2091
- results.push({
2092
- success: true,
2093
- pluginId: hook.pluginId,
2094
- duration: Date.now() - start
2095
- });
2096
- } catch (error) {
2097
- results.push({
2098
- success: false,
2099
- error: error instanceof Error ? error : new Error(String(error)),
2100
- pluginId: hook.pluginId,
2101
- duration: Date.now() - start
2102
- });
2103
- if (hook.errorPolicy === "abort") throw error;
2104
- }
2105
- }
2106
- return results;
2107
- }
2108
- /**
2109
- * Invoke the cron hook for a specific plugin.
2110
- *
2111
- * Unlike other hooks which broadcast to all plugins, the cron hook is
2112
- * dispatched only to the target plugin — the one that owns the task.
2113
- */
2114
- async invokeCronHook(pluginId, event) {
2115
- const hook = this.getTypedHooks("cron").find((h) => h.pluginId === pluginId);
2116
- if (!hook) return {
2117
- success: false,
2118
- error: /* @__PURE__ */ new Error(`Plugin "${pluginId}" has no cron hook registered`),
2119
- pluginId,
2120
- duration: 0
2121
- };
2122
- const { handler } = hook;
2123
- const ctx = this.getContext(pluginId);
2124
- const start = Date.now();
2125
- try {
2126
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2127
- return {
2128
- success: true,
2129
- pluginId,
2130
- duration: Date.now() - start
2131
- };
2132
- } catch (error) {
2133
- return {
2134
- success: false,
2135
- error: error instanceof Error ? error : new Error(String(error)),
2136
- pluginId,
2137
- duration: Date.now() - start
2138
- };
2139
- }
2140
- }
2141
- /**
2142
- * Run email:beforeSend hooks (middleware pipeline).
2143
- *
2144
- * Each handler receives the message and returns a modified message or
2145
- * `false` to cancel delivery. The pipeline chains message transformations —
2146
- * each handler receives the output of the previous one.
2147
- */
2148
- async runEmailBeforeSend(message, source) {
2149
- const hooks = this.getTypedHooks("email:beforeSend");
2150
- const results = [];
2151
- let currentMessage = message;
2152
- for (const hook of hooks) {
2153
- const { handler } = hook;
2154
- const event = {
2155
- message: { ...currentMessage },
2156
- source
2157
- };
2158
- const ctx = this.getContext(hook.pluginId);
2159
- const start = Date.now();
2160
- try {
2161
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2162
- if (result === false) {
2163
- results.push({
2164
- success: true,
2165
- value: false,
2166
- pluginId: hook.pluginId,
2167
- duration: Date.now() - start
2168
- });
2169
- return {
2170
- message: false,
2171
- results
2172
- };
2173
- }
2174
- if (result && typeof result === "object") currentMessage = result;
2175
- results.push({
2176
- success: true,
2177
- value: currentMessage,
2178
- pluginId: hook.pluginId,
2179
- duration: Date.now() - start
2180
- });
2181
- } catch (error) {
2182
- results.push({
2183
- success: false,
2184
- error: error instanceof Error ? error : new Error(String(error)),
2185
- pluginId: hook.pluginId,
2186
- duration: Date.now() - start
2187
- });
2188
- if (hook.errorPolicy === "abort") throw error;
2189
- }
2190
- }
2191
- return {
2192
- message: currentMessage,
2193
- results
2194
- };
2195
- }
2196
- /**
2197
- * Run email:afterSend hooks (fire-and-forget).
2198
- *
2199
- * Errors are logged but don't propagate — they don't affect the caller.
2200
- */
2201
- async runEmailAfterSend(message, source) {
2202
- const hooks = this.getTypedHooks("email:afterSend");
2203
- const results = [];
2204
- for (const hook of hooks) {
2205
- const { handler } = hook;
2206
- const event = {
2207
- message,
2208
- source
2209
- };
2210
- const ctx = this.getContext(hook.pluginId);
2211
- const start = Date.now();
2212
- try {
2213
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2214
- results.push({
2215
- success: true,
2216
- pluginId: hook.pluginId,
2217
- duration: Date.now() - start
2218
- });
2219
- } catch (error) {
2220
- console.error(`[email:afterSend] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2221
- results.push({
2222
- success: false,
2223
- error: error instanceof Error ? error : new Error(String(error)),
2224
- pluginId: hook.pluginId,
2225
- duration: Date.now() - start
2226
- });
2227
- }
2228
- }
2229
- return results;
2230
- }
2231
- /**
2232
- * Run comment:beforeCreate hooks (middleware pipeline).
2233
- *
2234
- * Each handler receives the event and returns a modified event or
2235
- * `false` to reject the comment. The pipeline chains transformations —
2236
- * each handler receives the output of the previous one.
2237
- */
2238
- async runCommentBeforeCreate(event) {
2239
- const hooks = this.getTypedHooks("comment:beforeCreate");
2240
- let currentEvent = event;
2241
- for (const hook of hooks) {
2242
- const { handler } = hook;
2243
- const ctx = this.getContext(hook.pluginId);
2244
- const start = Date.now();
2245
- try {
2246
- const result = await this.executeWithTimeout(() => handler({ ...currentEvent }, ctx), hook.timeout);
2247
- if (result === false) return false;
2248
- if (result && typeof result === "object") currentEvent = result;
2249
- } catch (error) {
2250
- console.error(`[comment:beforeCreate] Plugin "${hook.pluginId}" error (${Date.now() - start}ms):`, error instanceof Error ? error.message : error);
2251
- if (hook.errorPolicy === "abort") throw error;
2252
- }
2253
- }
2254
- return currentEvent;
2255
- }
2256
- /**
2257
- * Run comment:afterCreate hooks (fire-and-forget).
2258
- *
2259
- * Errors are logged but don't propagate — they don't affect the caller.
2260
- */
2261
- async runCommentAfterCreate(event) {
2262
- const hooks = this.getTypedHooks("comment:afterCreate");
2263
- for (const hook of hooks) {
2264
- const { handler } = hook;
2265
- const ctx = this.getContext(hook.pluginId);
2266
- try {
2267
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2268
- } catch (error) {
2269
- console.error(`[comment:afterCreate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2270
- }
2271
- }
2272
- }
2273
- /**
2274
- * Run comment:afterModerate hooks (fire-and-forget).
2275
- *
2276
- * Errors are logged but don't propagate — they don't affect the caller.
2277
- */
2278
- async runCommentAfterModerate(event) {
2279
- const hooks = this.getTypedHooks("comment:afterModerate");
2280
- for (const hook of hooks) {
2281
- const { handler } = hook;
2282
- const ctx = this.getContext(hook.pluginId);
2283
- try {
2284
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2285
- } catch (error) {
2286
- console.error(`[comment:afterModerate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2287
- }
2288
- }
2289
- }
2290
- /**
2291
- * Run page:metadata hooks. Each handler returns contributions that are
2292
- * merged by the metadata collector. Errors are logged but don't propagate.
2293
- */
2294
- async runPageMetadata(event) {
2295
- const hooks = this.getTypedHooks("page:metadata");
2296
- const results = [];
2297
- for (const hook of hooks) {
2298
- const { handler } = hook;
2299
- const ctx = this.getContext(hook.pluginId);
2300
- try {
2301
- const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
2302
- if (result != null) {
2303
- const contributions = Array.isArray(result) ? result : [result];
2304
- results.push({
2305
- pluginId: hook.pluginId,
2306
- contributions
2307
- });
2308
- }
2309
- } catch (error) {
2310
- console.error(`[page:metadata] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2311
- }
2312
- }
2313
- return results;
2314
- }
2315
- /**
2316
- * Run page:fragments hooks. Only trusted plugins should be registered
2317
- * for this hook. Errors are logged but don't propagate.
2318
- */
2319
- async runPageFragments(event) {
2320
- const hooks = this.getTypedHooks("page:fragments");
2321
- const results = [];
2322
- for (const hook of hooks) {
2323
- const { handler } = hook;
2324
- const ctx = this.getContext(hook.pluginId);
2325
- try {
2326
- const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
2327
- if (result != null) {
2328
- const contributions = Array.isArray(result) ? result : [result];
2329
- results.push({
2330
- pluginId: hook.pluginId,
2331
- contributions
2332
- });
2333
- }
2334
- } catch (error) {
2335
- console.error(`[page:fragments] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2336
- }
2337
- }
2338
- return results;
2339
- }
2340
- /**
2341
- * Check if any hooks are registered for a given name
2342
- */
2343
- hasHooks(name) {
2344
- const hooks = this.hooks.get(name);
2345
- return hooks !== void 0 && hooks.length > 0;
2346
- }
2347
- /**
2348
- * Get hook count for debugging
2349
- */
2350
- getHookCount(name) {
2351
- return this.hooks.get(name)?.length || 0;
2352
- }
2353
- /**
2354
- * Get all registered hook names
2355
- */
2356
- getRegisteredHooks() {
2357
- return [...this.hooks.keys()];
2358
- }
2359
- /**
2360
- * Returns hook names where at least one handler declared exclusive: true
2361
- */
2362
- getRegisteredExclusiveHooks() {
2363
- return [...this.exclusiveHookNames];
2364
- }
2365
- /**
2366
- * Check if a hook is exclusive
2367
- */
2368
- isExclusiveHook(name) {
2369
- return this.exclusiveHookNames.has(name);
2370
- }
2371
- /**
2372
- * Set the selected provider for an exclusive hook.
2373
- * Called by PluginManager after resolution.
2374
- */
2375
- setExclusiveSelection(hookName, pluginId) {
2376
- this.exclusiveSelections.set(hookName, pluginId);
2377
- }
2378
- /**
2379
- * Clear the selected provider for an exclusive hook.
2380
- */
2381
- clearExclusiveSelection(hookName) {
2382
- this.exclusiveSelections.delete(hookName);
2383
- }
2384
- /**
2385
- * Get the selected provider for an exclusive hook (if any).
2386
- */
2387
- getExclusiveSelection(hookName) {
2388
- return this.exclusiveSelections.get(hookName);
2389
- }
2390
- /**
2391
- * Get all plugins that registered a handler for a given exclusive hook.
2392
- */
2393
- getExclusiveHookProviders(hookName) {
2394
- return (this.hooks.get(hookName) ?? []).filter((h) => h.exclusive).map((h) => ({ pluginId: h.pluginId }));
2395
- }
2396
- /**
2397
- * Get all plugins that registered a non-exclusive handler for a given
2398
- * hook (e.g. `email:beforeSend`, `email:afterSend`), preserving priority
2399
- * order. Partitions with `getExclusiveHookProviders()`, which returns
2400
- * plugins whose registration is marked `exclusive: true`.
2401
- */
2402
- getHookProviders(hookName) {
2403
- return (this.hooks.get(hookName) ?? []).filter((h) => !h.exclusive).map((h) => ({ pluginId: h.pluginId }));
2404
- }
2405
- /**
2406
- * Invoke an exclusive hook — dispatch only to the selected provider.
2407
- * Returns null if no provider is selected or if the selected hook
2408
- * is not found in the pipeline.
2409
- *
2410
- * This is a generic dispatch used by the email pipeline and other
2411
- * exclusive hook consumers. The handler type is unknown — callers
2412
- * must know the expected signature.
2413
- *
2414
- * Errors are isolated: a failing handler returns an error result
2415
- * instead of propagating the exception to the caller.
2416
- */
2417
- async invokeExclusiveHook(hookName, event) {
2418
- const selectedPluginId = this.exclusiveSelections.get(hookName);
2419
- if (!selectedPluginId) return null;
2420
- const hook = (this.hooks.get(hookName) ?? []).find((h) => h.pluginId === selectedPluginId && h.exclusive);
2421
- if (!hook) return null;
2422
- const start = Date.now();
2423
- try {
2424
- const ctx = this.getContext(selectedPluginId);
2425
- const handler = hook.handler;
2426
- return {
2427
- result: await this.executeWithTimeout(() => handler(event, ctx), hook.timeout),
2428
- pluginId: selectedPluginId,
2429
- duration: Date.now() - start
2430
- };
2431
- } catch (error) {
2432
- return {
2433
- result: void 0,
2434
- pluginId: selectedPluginId,
2435
- error: error instanceof Error ? error : new Error(String(error)),
2436
- duration: Date.now() - start
2437
- };
2438
- }
2439
- }
2440
- };
2441
- /**
2442
- * Create a hook pipeline from plugins
2443
- */
2444
- function createHookPipeline(plugins, factoryOptions) {
2445
- return new HookPipeline(plugins, factoryOptions);
2446
- }
2447
- /** Options table key prefix for exclusive hook selections */
2448
- const EXCLUSIVE_HOOK_KEY_PREFIX$1 = "emdash:exclusive_hook:";
2449
- /**
2450
- * Resolve exclusive hook selections.
2451
- *
2452
- * Shared algorithm used by both PluginManager and EmDashRuntime:
2453
- * 1. If a DB selection exists and that plugin is active → keep it.
2454
- * 2. If DB selection is stale (plugin inactive/gone) → clear it.
2455
- * 3. If no selection and only one active provider → auto-select it.
2456
- * 4. If preferred hints match an active provider → first match wins.
2457
- * 5. If multiple providers and no hint → leave unselected (admin must choose).
2458
- */
2459
- async function resolveExclusiveHooks(opts) {
2460
- const { pipeline, isActive, getOption, getOptions, setOption, deleteOption, preferredHints } = opts;
2461
- const exclusiveHookNames = pipeline.getRegisteredExclusiveHooks();
2462
- if (exclusiveHookNames.length === 0) return;
2463
- let batchedSelections;
2464
- if (getOptions) try {
2465
- batchedSelections = await getOptions(exclusiveHookNames.map((hookName) => `${EXCLUSIVE_HOOK_KEY_PREFIX$1}${hookName}`));
2466
- } catch {
2467
- return;
2468
- }
2469
- for (const hookName of exclusiveHookNames) {
2470
- const providers = pipeline.getExclusiveHookProviders(hookName);
2471
- const activeProviderIds = new Set(providers.map((p) => p.pluginId).filter((id) => isActive(id)));
2472
- const key = `${EXCLUSIVE_HOOK_KEY_PREFIX$1}${hookName}`;
2473
- let currentSelection = null;
2474
- if (batchedSelections) currentSelection = batchedSelections.get(key) ?? null;
2475
- else try {
2476
- currentSelection = await getOption(key);
2477
- } catch {
2478
- continue;
2479
- }
2480
- if (currentSelection && activeProviderIds.has(currentSelection)) {
2481
- pipeline.setExclusiveSelection(hookName, currentSelection);
2482
- continue;
2483
- }
2484
- if (currentSelection) try {
2485
- await deleteOption(key);
2486
- } catch {}
2487
- if (activeProviderIds.size === 1) {
2488
- const [onlyProvider] = activeProviderIds;
2489
- try {
2490
- await setOption(key, onlyProvider);
2491
- } catch {}
2492
- pipeline.setExclusiveSelection(hookName, onlyProvider);
2493
- continue;
2494
- }
2495
- if (preferredHints) {
2496
- let found = false;
2497
- for (const [pluginId, hooks] of preferredHints) if (hooks.includes(hookName) && activeProviderIds.has(pluginId)) {
2498
- try {
2499
- await setOption(key, pluginId);
2500
- } catch {}
2501
- pipeline.setExclusiveSelection(hookName, pluginId);
2502
- found = true;
2503
- break;
2504
- }
2505
- if (found) continue;
2506
- }
2507
- pipeline.clearExclusiveSelection(hookName);
2508
- }
2509
- }
2510
-
2511
- //#endregion
2512
- //#region src/plugins/save-rejection.ts
2513
- /**
2514
- * Thrown by a `content:beforeSave` hook to reject a save with a message
2515
- * that is safe to show to the editor. The runtime converts it into a
2516
- * structured `SAVE_REJECTED` API error; any other exception thrown by the
2517
- * hook cancels the save with a generic error that hides the exception
2518
- * message.
2519
- */
2520
- var ContentSaveRejectedError = class extends Error {
2521
- name = "ContentSaveRejectedError";
2522
- };
2523
- /**
2524
- * Matches by name as well as by prototype: bundlers can duplicate this
2525
- * module across SSR chunks, and an `instanceof` against the wrong copy of
2526
- * the class would misreport a rejection as a plugin crash.
2527
- */
2528
- function isContentSaveRejection(error) {
2529
- if (error instanceof ContentSaveRejectedError) return true;
2530
- return error instanceof Error && error.name === "ContentSaveRejectedError";
2531
- }
2532
-
2533
- //#endregion
2534
- //#region src/plugins/email.ts
2535
- /**
2536
- * Email Pipeline
2537
- *
2538
- * Orchestrates the three-stage email pipeline:
2539
- * 1. email:beforeSend hooks (middleware — transform, validate, cancel)
2540
- * 2. email:deliver hook (exclusive — exactly one provider delivers)
2541
- * 3. email:afterSend hooks (logging, analytics, fire-and-forget)
2542
- *
2543
- * Security features:
2544
- * - Recursion guard prevents re-entrant sends (e.g. plugin calling ctx.email.send from a hook)
2545
- * - System emails (source="system") bypass email:beforeSend and email:afterSend hooks entirely
2546
- * to protect auth tokens from exfiltration by plugin hooks
2547
- *
2548
- */
2549
- /** Hook name for the exclusive email delivery hook */
2550
- const EMAIL_DELIVER_HOOK = "email:deliver";
2551
- /** Source value used for auth emails (magic links, invites, password resets) */
2552
- const SYSTEM_SOURCE = "system";
2553
- /**
2554
- * Error thrown when ctx.email.send() is called but no provider is configured.
2555
- */
2556
- var EmailNotConfiguredError = class extends Error {
2557
- constructor() {
2558
- super("No email provider is configured. Install and activate an email provider plugin, then select it in Settings > Email.");
2559
- this.name = "EmailNotConfiguredError";
2560
- }
2561
- };
2562
- /**
2563
- * Error thrown when a recursive email send is detected.
2564
- */
2565
- var EmailRecursionError = class extends Error {
2566
- constructor() {
2567
- super("Recursive email send detected. A plugin hook attempted to send an email from within the email pipeline, which would cause infinite recursion.");
2568
- this.name = "EmailRecursionError";
2569
- }
2570
- };
2571
- /**
2572
- * Recursion guard using AsyncLocalStorage.
2573
- *
2574
- * EmailPipeline is a singleton (worker-lifetime cached via EmDashRuntime).
2575
- * Instance state like `sendDepth` would false-positive under concurrent
2576
- * requests because two unrelated sends would increment the same counter.
2577
- * ALS scopes the guard to the current async execution context, so concurrent
2578
- * requests each get their own independent recursion tracking.
2579
- */
2580
- const emailSendALS = new AsyncLocalStorage();
2581
- /**
2582
- * EmailPipeline orchestrates email delivery through the plugin hook system.
2583
- *
2584
- * The pipeline runs in three stages:
2585
- * 1. email:beforeSend — middleware hooks that can transform or cancel messages
2586
- * 2. email:deliver — exclusive hook dispatching to the selected provider
2587
- * 3. email:afterSend — fire-and-forget hooks for logging/analytics
2588
- */
2589
- var EmailPipeline = class {
2590
- pipeline;
2591
- constructor(pipeline) {
2592
- this.pipeline = pipeline;
2593
- }
2594
- /**
2595
- * Replace the underlying hook pipeline.
2596
- *
2597
- * Called by the runtime when rebuilding the hook pipeline after a
2598
- * plugin is enabled or disabled, so the email pipeline dispatches
2599
- * to the current set of active hooks.
2600
- */
2601
- setPipeline(pipeline) {
2602
- this.pipeline = pipeline;
2603
- }
2604
- /**
2605
- * Send an email through the full pipeline.
2606
- *
2607
- * @param message - The email to send
2608
- * @param source - Where the email originated ("system" for auth, plugin ID for plugins)
2609
- * @throws EmailNotConfiguredError if no provider is selected
2610
- * @throws EmailRecursionError if called re-entrantly from within a hook
2611
- * @throws Error if the provider handler throws
2612
- */
2613
- async send(message, source) {
2614
- const store = emailSendALS.getStore();
2615
- if (store && store.depth > 0) throw new EmailRecursionError();
2616
- const run = () => this.sendInner(message, source);
2617
- if (store) {
2618
- store.depth++;
2619
- try {
2620
- await run();
2621
- } finally {
2622
- store.depth--;
2623
- }
2624
- } else await emailSendALS.run({ depth: 1 }, run);
2625
- }
2626
- /**
2627
- * Inner send implementation, separated from the recursion guard.
2628
- */
2629
- async sendInner(message, source) {
2630
- if (!message || typeof message !== "object") throw new Error("Invalid email message: message must be an object");
2631
- if (!message.to || typeof message.to !== "string") throw new Error("Invalid email message: 'to' is required and must be a string");
2632
- if (!message.subject || typeof message.subject !== "string") throw new Error("Invalid email message: 'subject' is required and must be a string");
2633
- if (!message.text || typeof message.text !== "string") throw new Error("Invalid email message: 'text' is required and must be a string");
2634
- const isSystemEmail = source === SYSTEM_SOURCE;
2635
- let finalMessage;
2636
- if (isSystemEmail) finalMessage = message;
2637
- else {
2638
- const beforeResult = await this.pipeline.runEmailBeforeSend(message, source);
2639
- if (beforeResult.message === false) {
2640
- const cancelledBy = beforeResult.results.find((r) => r.value === false)?.pluginId ?? "unknown";
2641
- console.info(`[email] Email to "${message.to}" cancelled by plugin "${cancelledBy}"`);
2642
- return;
2643
- }
2644
- finalMessage = beforeResult.message;
2645
- }
2646
- const deliverEvent = {
2647
- message: finalMessage,
2648
- source
2649
- };
2650
- const deliverResult = await this.pipeline.invokeExclusiveHook(EMAIL_DELIVER_HOOK, deliverEvent);
2651
- if (!deliverResult) throw new EmailNotConfiguredError();
2652
- if (deliverResult.error) throw deliverResult.error;
2653
- if (!isSystemEmail) this.pipeline.runEmailAfterSend(finalMessage, source).catch((err) => console.error("[email] afterSend pipeline error:", err instanceof Error ? err.message : err));
2654
- }
2655
- /**
2656
- * Check if an email provider is configured and available.
2657
- *
2658
- * Returns true if an email:deliver provider is selected in the exclusive
2659
- * hook system. Plugins and auth code use this to decide whether to show
2660
- * "send invite" vs "copy invite link" UI.
2661
- */
2662
- isAvailable() {
2663
- return this.pipeline.getExclusiveSelection(EMAIL_DELIVER_HOOK) !== void 0;
2664
- }
2665
- };
2666
-
2667
- //#endregion
2668
- //#region src/plugins/routes.ts
2669
- /**
2670
- * Plugin Routes v2
2671
- *
2672
- * Handles plugin API route invocation with:
2673
- * - Input validation via Zod schemas
2674
- * - Route context creation
2675
- * - Error handling
2676
- *
2677
- */
2678
- /**
2679
- * Body-reading methods on `Request`. EmDash parses the request body once before
2680
- * the handler runs and exposes the result as `ctx.input`, leaving the underlying
2681
- * stream consumed. Calling any of these on `ctx.request` would re-read a spent
2682
- * stream and throw an opaque platform error ("Body is unusable: Body has already
2683
- * been read") with no hint about `ctx.input` — so the guard replaces them with an
2684
- * actionable message instead (#1293).
2685
- */
2686
- const CONSUMED_BODY_METHODS = new Set([
2687
- "json",
2688
- "text",
2689
- "arrayBuffer",
2690
- "blob",
2691
- "formData",
2692
- "bytes"
2693
- ]);
2694
- /**
2695
- * Wrap the request handed to a plugin route handler so an accidental
2696
- * `ctx.request.json()` (or `.text()`, `.formData()`, …) fails with a message
2697
- * pointing at `ctx.input` rather than the runtime's cryptic "body already read"
2698
- * error. Every non-body member passes through unchanged; function members are
2699
- * bound to the underlying request so methods like `clone()` don't throw an
2700
- * "Illegal invocation" when called on the proxy.
2701
- */
2702
- function guardConsumedRequestBody(request) {
2703
- return new Proxy(request, { get(target, prop) {
2704
- if (typeof prop === "string" && CONSUMED_BODY_METHODS.has(prop)) return () => {
2705
- throw new Error(`[emdash] ctx.request.${prop}() is not available inside a plugin route handler: EmDash has already parsed the request body and exposes it as ctx.input. Read ctx.input instead of ctx.request.${prop}().`);
2706
- };
2707
- const value = Reflect.get(target, prop, target);
2708
- return typeof value === "function" ? value.bind(target) : value;
2709
- } });
2710
- }
2711
- /**
2712
- * Build RouteMeta from a route's `public`/`cacheControl` flags. Single source
2713
- * of truth for the "cacheControl is only ever exposed on public routes"
2714
- * invariant — used for trusted routes and manifest-declared sandboxed routes.
2715
- */
2716
- function buildRouteMeta(route) {
2717
- const meta = { public: route.public === true };
2718
- if (route.permission !== void 0) meta.permission = route.permission;
2719
- if (meta.public && typeof route.cacheControl === "string" && route.cacheControl.length > 0) meta.cacheControl = route.cacheControl;
2720
- return meta;
2721
- }
2722
- /**
2723
- * HTTP methods that carry a request body. Everything else (GET, HEAD, DELETE)
2724
- * takes its route input from the URL query string.
2725
- */
2726
- const BODY_METHODS = new Set([
2727
- "POST",
2728
- "PUT",
2729
- "PATCH"
2730
- ]);
2731
- /**
2732
- * Parse a plugin route's input from the request, by method.
2733
- *
2734
- * Body methods (POST/PUT/PATCH) parse the JSON body as before. Bodyless
2735
- * methods (GET/HEAD/DELETE) have no body, so `request.json()` resolves to
2736
- * undefined and fails schema validation (#2146) — parse the query string into
2737
- * an object instead. Repeated keys (`?tag=a&tag=b`) become an array so array
2738
- * schemas work; a single key stays a scalar.
2739
- */
2740
- async function parseRouteInput(request) {
2741
- if (BODY_METHODS.has(request.method.toUpperCase())) try {
2742
- return await request.json();
2743
- } catch {
2744
- return;
2745
- }
2746
- const params = new URL(request.url).searchParams;
2747
- const input = {};
2748
- for (const key of new Set(params.keys())) {
2749
- const values = params.getAll(key);
2750
- input[key] = values.length > 1 ? values : values[0];
2751
- }
2752
- return input;
2753
- }
2754
- /**
2755
- * Convert the host's authenticated user into the read-only `UserInfo` shape
2756
- * exposed to plugins as `ctx.user`. Strips sensitive/irrelevant fields and
2757
- * keeps the value structured-clone-safe for sandboxed plugins.
2758
- */
2759
- function toRouteCallerInfo(user) {
2760
- return {
2761
- id: user.id,
2762
- email: user.email,
2763
- name: user.name,
2764
- role: user.role,
2765
- createdAt: typeof user.createdAt === "string" ? user.createdAt : user.createdAt.toISOString()
2766
- };
2767
- }
2768
- /**
2769
- * Route handler for a plugin
2770
- */
2771
- var PluginRouteHandler = class {
2772
- contextFactory;
2773
- plugin;
2774
- trustedProxyHeaders;
2775
- constructor(plugin, factoryOptions) {
2776
- this.plugin = plugin;
2777
- this.contextFactory = new PluginContextFactory(factoryOptions);
2778
- this.trustedProxyHeaders = factoryOptions.trustedProxyHeaders ?? [];
2779
- }
2780
- /**
2781
- * Invoke a route by name
2782
- */
2783
- async invoke(routeName, options) {
2784
- const route = this.plugin.routes[routeName];
2785
- if (!route) return {
2786
- success: false,
2787
- error: {
2788
- code: "ROUTE_NOT_FOUND",
2789
- message: `Route "${routeName}" not found in plugin "${this.plugin.id}"`
2790
- },
2791
- status: 404
2792
- };
2793
- let validatedInput;
2794
- if (route.input) {
2795
- const parseResult = route.input.safeParse(options.body);
2796
- if (!parseResult.success) return {
2797
- success: false,
2798
- error: {
2799
- code: "VALIDATION_ERROR",
2800
- message: "Invalid request body",
2801
- details: z$1.formatError(parseResult.error)
2802
- },
2803
- status: 400
2804
- };
2805
- validatedInput = parseResult.data;
2806
- } else validatedInput = options.body;
2807
- const routeContext = {
2808
- ...this.contextFactory.createContext(this.plugin),
2809
- input: validatedInput,
2810
- request: guardConsumedRequestBody(options.request),
2811
- requestMeta: extractRequestMeta(options.request, this.trustedProxyHeaders),
2812
- user: options.user
2813
- };
2814
- try {
2815
- return {
2816
- success: true,
2817
- data: await route.handler(routeContext),
2818
- status: 200
2819
- };
2820
- } catch (error) {
2821
- if (error instanceof MediaUsageActivationWriteBlockedError) return {
2822
- success: false,
2823
- error: {
2824
- code: error.code,
2825
- message: error.message
2826
- },
2827
- status: error.status
2828
- };
2829
- if (error instanceof PluginRouteError) return {
2830
- success: false,
2831
- error: {
2832
- code: error.code,
2833
- message: error.message,
2834
- details: error.details
2835
- },
2836
- status: error.status
2837
- };
2838
- console.error(`[plugin:${this.plugin.id}] Route handler failed:`, error);
2839
- return {
2840
- success: false,
2841
- error: {
2842
- code: "INTERNAL_ERROR",
2843
- message: "An internal error occurred"
2844
- },
2845
- status: 500
2846
- };
2847
- }
2848
- }
2849
- /**
2850
- * Get all route names
2851
- */
2852
- getRouteNames() {
2853
- return Object.keys(this.plugin.routes);
2854
- }
2855
- /**
2856
- * Check if a route exists
2857
- */
2858
- hasRoute(name) {
2859
- return name in this.plugin.routes;
2860
- }
2861
- /**
2862
- * Get route metadata without invoking the handler.
2863
- * Returns null if the route doesn't exist.
2864
- */
2865
- getRouteMeta(name) {
2866
- const route = this.plugin.routes[name];
2867
- if (!route) return null;
2868
- return buildRouteMeta(route);
2869
- }
2870
- };
2871
- /**
2872
- * Error class for plugin routes
2873
- * Allows plugins to return structured errors with specific HTTP status codes
2874
- */
2875
- var PluginRouteError = class PluginRouteError extends Error {
2876
- constructor(code, message, status = 400, details) {
2877
- super(message);
2878
- this.code = code;
2879
- this.status = status;
2880
- this.details = details;
2881
- this.name = "PluginRouteError";
2882
- }
2883
- /**
2884
- * Create a bad request error (400)
2885
- */
2886
- static badRequest(message, details) {
2887
- return new PluginRouteError("BAD_REQUEST", message, 400, details);
2888
- }
2889
- /**
2890
- * Create an unauthorized error (401)
2891
- */
2892
- static unauthorized(message = "Unauthorized") {
2893
- return new PluginRouteError("UNAUTHORIZED", message, 401);
2894
- }
2895
- /**
2896
- * Create a forbidden error (403)
2897
- */
2898
- static forbidden(message = "Forbidden") {
2899
- return new PluginRouteError("FORBIDDEN", message, 403);
2900
- }
2901
- /**
2902
- * Create a not found error (404)
2903
- */
2904
- static notFound(message = "Not found") {
2905
- return new PluginRouteError("NOT_FOUND", message, 404);
2906
- }
2907
- /**
2908
- * Create a conflict error (409)
2909
- */
2910
- static conflict(message, details) {
2911
- return new PluginRouteError("CONFLICT", message, 409, details);
2912
- }
2913
- /**
2914
- * Create an internal error (500)
2915
- */
2916
- static internal(message = "Internal error") {
2917
- return new PluginRouteError("INTERNAL_ERROR", message, 500);
2918
- }
2919
- };
2920
- /**
2921
- * Registry for all plugin route handlers
2922
- */
2923
- var PluginRouteRegistry = class {
2924
- handlers = /* @__PURE__ */ new Map();
2925
- constructor(factoryOptions) {
2926
- this.factoryOptions = factoryOptions;
2927
- }
2928
- /**
2929
- * Register a plugin's routes
2930
- */
2931
- register(plugin) {
2932
- const handler = new PluginRouteHandler(plugin, this.factoryOptions);
2933
- this.handlers.set(plugin.id, handler);
2934
- }
2935
- /**
2936
- * Unregister a plugin's routes
2937
- */
2938
- unregister(pluginId) {
2939
- this.handlers.delete(pluginId);
2940
- }
2941
- /**
2942
- * Invoke a plugin route
2943
- */
2944
- async invoke(pluginId, routeName, options) {
2945
- const handler = this.handlers.get(pluginId);
2946
- if (!handler) return {
2947
- success: false,
2948
- error: {
2949
- code: "PLUGIN_NOT_FOUND",
2950
- message: `Plugin "${pluginId}" not found`
2951
- },
2952
- status: 404
2953
- };
2954
- return handler.invoke(routeName, options);
2955
- }
2956
- /**
2957
- * Get all registered plugin IDs
2958
- */
2959
- getPluginIds() {
2960
- return [...this.handlers.keys()];
2961
- }
2962
- /**
2963
- * Get routes for a plugin
2964
- */
2965
- getRoutes(pluginId) {
2966
- return this.handlers.get(pluginId)?.getRouteNames() ?? [];
2967
- }
2968
- /**
2969
- * Get route metadata for a specific plugin route.
2970
- * Returns null if the plugin or route doesn't exist.
2971
- */
2972
- getRouteMeta(pluginId, routeName) {
2973
- const handler = this.handlers.get(pluginId);
2974
- if (!handler) return null;
2975
- return handler.getRouteMeta(routeName);
2976
- }
2977
- };
2978
-
2979
- //#endregion
2980
- //#region src/plugins/manager.ts
2981
- /** Options table key prefix for exclusive hook DB reads via PluginManager */
2982
- const EXCLUSIVE_HOOK_KEY_PREFIX = "emdash:exclusive_hook:";
2983
- /**
2984
- * Plugin Manager v2
2985
- *
2986
- * Manages the full lifecycle of plugins and coordinates hooks/routes.
2987
- */
2988
- var PluginManager = class {
2989
- plugins = /* @__PURE__ */ new Map();
2990
- hookPipeline = null;
2991
- routeRegistry = null;
2992
- factoryOptions;
2993
- initialized = false;
2994
- constructor(options) {
2995
- this.options = options;
2996
- this.factoryOptions = {
2997
- db: options.db,
2998
- storage: options.storage,
2999
- getUploadUrl: options.getUploadUrl,
3000
- trustedProxyHeaders: options.trustedProxyHeaders
3001
- };
3002
- }
3003
- /**
3004
- * Set the email pipeline used when creating plugin contexts.
3005
- * Reinitializes routes/hooks if already initialized so ctx.email is available immediately.
3006
- */
3007
- setEmailPipeline(pipeline) {
3008
- this.factoryOptions.emailPipeline = pipeline;
3009
- if (this.initialized) this.reinitialize();
3010
- }
3011
- /**
3012
- * Register a plugin definition
3013
- * This resolves the definition and adds it to the manager, but doesn't install it
3014
- */
3015
- register(definition) {
3016
- const resolved = definePlugin(definition);
3017
- if (this.plugins.has(resolved.id)) throw new Error(`Plugin "${resolved.id}" is already registered`);
3018
- this.plugins.set(resolved.id, {
3019
- plugin: resolved,
3020
- state: "registered"
3021
- });
3022
- this.initialized = false;
3023
- return resolved;
3024
- }
3025
- /**
3026
- * Register multiple plugins
3027
- */
3028
- registerAll(definitions) {
3029
- for (const def of definitions) this.register(def);
3030
- }
3031
- /**
3032
- * Unregister a plugin
3033
- * Plugin must be inactive or just registered
3034
- */
3035
- unregister(pluginId) {
3036
- const entry = this.plugins.get(pluginId);
3037
- if (!entry) return false;
3038
- if (entry.state === "active") throw new Error(`Cannot unregister active plugin "${pluginId}". Deactivate it first.`);
3039
- this.plugins.delete(pluginId);
3040
- this.initialized = false;
3041
- return true;
3042
- }
3043
- /**
3044
- * Install a plugin (run install hooks, set up storage)
3045
- */
3046
- async install(pluginId) {
3047
- const entry = this.plugins.get(pluginId);
3048
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
3049
- if (entry.state !== "registered") throw new Error(`Plugin "${pluginId}" is already installed (state: ${entry.state})`);
3050
- this.ensureInitialized();
3051
- const results = await this.hookPipeline.runPluginInstall(pluginId);
3052
- const failed = results.find((r) => !r.success);
3053
- if (failed) throw new Error(`Plugin install failed: ${failed.error?.message ?? "Unknown error"}`);
3054
- entry.state = "installed";
3055
- return results;
3056
- }
3057
- /**
3058
- * Activate a plugin (run activate hooks, enable hooks/routes)
3059
- */
3060
- async activate(pluginId) {
3061
- const entry = this.plugins.get(pluginId);
3062
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
3063
- if (entry.state === "active") return [];
3064
- if (entry.state === "registered") await this.install(pluginId);
3065
- this.ensureInitialized();
3066
- const results = await this.hookPipeline.runPluginActivate(pluginId);
3067
- const failed = results.find((r) => !r.success);
3068
- if (failed) throw new Error(`Plugin activation failed: ${failed.error?.message ?? "Unknown error"}`);
3069
- entry.state = "active";
3070
- await setCronTasksEnabled(this.options.db, pluginId, true);
3071
- this.reinitialize();
3072
- await this.resolveExclusiveHooks();
3073
- return results;
3074
- }
3075
- /**
3076
- * Deactivate a plugin (run deactivate hooks, disable hooks/routes)
3077
- */
3078
- async deactivate(pluginId) {
3079
- const entry = this.plugins.get(pluginId);
3080
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
3081
- if (entry.state !== "active") return [];
3082
- this.ensureInitialized();
3083
- const results = await this.hookPipeline.runPluginDeactivate(pluginId);
3084
- await setCronTasksEnabled(this.options.db, pluginId, false);
3085
- entry.state = "inactive";
3086
- this.reinitialize();
3087
- await this.resolveExclusiveHooks();
3088
- return results;
3089
- }
3090
- /**
3091
- * Uninstall a plugin (run uninstall hooks, optionally delete data)
3092
- */
3093
- async uninstall(pluginId, deleteData = false) {
3094
- const entry = this.plugins.get(pluginId);
3095
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
3096
- if (entry.state === "active") await this.deactivate(pluginId);
3097
- this.ensureInitialized();
3098
- const results = await this.hookPipeline.runPluginUninstall(pluginId, deleteData);
3099
- await this.deleteCronTasks(pluginId);
3100
- this.plugins.delete(pluginId);
3101
- this.initialized = false;
3102
- await this.resolveExclusiveHooks();
3103
- return results;
3104
- }
3105
- /**
3106
- * Run content:beforeSave hooks across all active plugins
3107
- */
3108
- async runContentBeforeSave(content, collection, isNew, id, actor) {
3109
- this.ensureInitialized();
3110
- return this.hookPipeline.runContentBeforeSave(content, collection, isNew, id, actor);
3111
- }
3112
- /**
3113
- * Run content:afterSave hooks across all active plugins
3114
- */
3115
- async runContentAfterSave(content, collection, isNew, actor) {
3116
- this.ensureInitialized();
3117
- return this.hookPipeline.runContentAfterSave(content, collection, isNew, actor);
3118
- }
3119
- /**
3120
- * Run content:beforeDelete hooks across all active plugins
3121
- */
3122
- async runContentBeforeDelete(id, collection) {
3123
- this.ensureInitialized();
3124
- return this.hookPipeline.runContentBeforeDelete(id, collection);
3125
- }
3126
- /**
3127
- * Run content:afterDelete hooks across all active plugins
3128
- */
3129
- async runContentAfterDelete(id, collection, permanent) {
3130
- this.ensureInitialized();
3131
- return this.hookPipeline.runContentAfterDelete(id, collection, permanent);
3132
- }
3133
- /**
3134
- * Run content:afterPublish hooks across all active plugins
3135
- */
3136
- async runContentAfterPublish(content, collection) {
3137
- this.ensureInitialized();
3138
- return this.hookPipeline.runContentAfterPublish(content, collection);
3139
- }
3140
- /**
3141
- * Run content:afterUnpublish hooks across all active plugins
3142
- */
3143
- async runContentAfterUnpublish(content, collection) {
3144
- this.ensureInitialized();
3145
- return this.hookPipeline.runContentAfterUnpublish(content, collection);
3146
- }
3147
- /**
3148
- * Run content:afterRestore hooks across all active plugins
3149
- */
3150
- async runContentAfterRestore(content, collection) {
3151
- this.ensureInitialized();
3152
- return this.hookPipeline.runContentAfterRestore(content, collection);
3153
- }
3154
- /**
3155
- * Run content:afterSchedule hooks across all active plugins
3156
- */
3157
- async runContentAfterSchedule(content, collection) {
3158
- this.ensureInitialized();
3159
- return this.hookPipeline.runContentAfterSchedule(content, collection);
3160
- }
3161
- /**
3162
- * Run content:afterUnschedule hooks across all active plugins
3163
- */
3164
- async runContentAfterUnschedule(content, collection) {
3165
- this.ensureInitialized();
3166
- return this.hookPipeline.runContentAfterUnschedule(content, collection);
3167
- }
3168
- /**
3169
- * Run media:beforeUpload hooks across all active plugins
3170
- */
3171
- async runMediaBeforeUpload(file) {
3172
- this.ensureInitialized();
3173
- return this.hookPipeline.runMediaBeforeUpload(file);
3174
- }
3175
- /**
3176
- * Run media:afterUpload hooks across all active plugins
3177
- */
3178
- async runMediaAfterUpload(media) {
3179
- this.ensureInitialized();
3180
- return this.hookPipeline.runMediaAfterUpload(media);
3181
- }
3182
- /**
3183
- * Invoke the cron hook for a specific plugin (per-plugin dispatch).
3184
- * Used as the InvokeCronHookFn callback for CronExecutor.
3185
- */
3186
- async invokeCronHook(pluginId, event) {
3187
- this.ensureInitialized();
3188
- const result = await this.hookPipeline.invokeCronHook(pluginId, event);
3189
- if (!result.success && result.error) throw result.error;
3190
- }
3191
- /**
3192
- * Invoke a plugin route
3193
- */
3194
- async invokeRoute(pluginId, routeName, options) {
3195
- this.ensureInitialized();
3196
- return this.routeRegistry.invoke(pluginId, routeName, options);
3197
- }
3198
- /**
3199
- * Get all routes for a plugin
3200
- */
3201
- getPluginRoutes(pluginId) {
3202
- this.ensureInitialized();
3203
- return this.routeRegistry.getRoutes(pluginId);
3204
- }
3205
- /**
3206
- * Get a plugin by ID
3207
- */
3208
- getPlugin(pluginId) {
3209
- return this.plugins.get(pluginId)?.plugin;
3210
- }
3211
- /**
3212
- * Get plugin state
3213
- */
3214
- getPluginState(pluginId) {
3215
- return this.plugins.get(pluginId)?.state;
3216
- }
3217
- /**
3218
- * Get all registered plugins
3219
- */
3220
- getAllPlugins() {
3221
- return Array.from(this.plugins.values(), (entry) => ({
3222
- plugin: entry.plugin,
3223
- state: entry.state
3224
- }));
3225
- }
3226
- /**
3227
- * Get all active plugins
3228
- */
3229
- getActivePlugins() {
3230
- return [...this.plugins.values()].filter((entry) => entry.state === "active").map((entry) => entry.plugin);
3231
- }
3232
- /**
3233
- * Check if a plugin exists
3234
- */
3235
- hasPlugin(pluginId) {
3236
- return this.plugins.has(pluginId);
3237
- }
3238
- /**
3239
- * Check if a plugin is active
3240
- */
3241
- isActive(pluginId) {
3242
- return this.plugins.get(pluginId)?.state === "active";
3243
- }
3244
- /**
3245
- * Get all plugins that registered a handler for an exclusive hook.
3246
- */
3247
- getExclusiveHookProviders(hookName) {
3248
- this.ensureInitialized();
3249
- return this.hookPipeline.getExclusiveHookProviders(hookName).map((p) => {
3250
- const plugin = this.plugins.get(p.pluginId);
3251
- return {
3252
- pluginId: p.pluginId,
3253
- pluginName: plugin?.plugin.id ?? p.pluginId
3254
- };
3255
- });
3256
- }
3257
- /**
3258
- * Read the selected provider for an exclusive hook from the options table.
3259
- */
3260
- async getExclusiveHookSelection(hookName) {
3261
- return new OptionsRepository(this.options.db).get(`${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`);
3262
- }
3263
- /**
3264
- * Set the selected provider for an exclusive hook in the options table.
3265
- * Pass null to clear the selection.
3266
- */
3267
- async setExclusiveHookSelection(hookName, pluginId) {
3268
- const optionsRepo = new OptionsRepository(this.options.db);
3269
- const key = `${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`;
3270
- if (pluginId === null) {
3271
- await optionsRepo.delete(key);
3272
- this.hookPipeline?.clearExclusiveSelection(hookName);
3273
- return;
3274
- }
3275
- const entry = this.plugins.get(pluginId);
3276
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
3277
- if (entry.state !== "active") throw new Error(`Plugin "${pluginId}" is not active`);
3278
- await optionsRepo.set(key, pluginId);
3279
- this.hookPipeline?.setExclusiveSelection(hookName, pluginId);
3280
- }
3281
- /**
3282
- * Resolution algorithm for exclusive hooks.
3283
- *
3284
- * Delegates to the shared resolveExclusiveHooks() function.
3285
- * See hooks.ts for the full algorithm description.
3286
- */
3287
- async resolveExclusiveHooks(preferredHints) {
3288
- this.ensureInitialized();
3289
- const optionsRepo = new OptionsRepository(this.options.db);
3290
- await resolveExclusiveHooks({
3291
- pipeline: this.hookPipeline,
3292
- isActive: (pluginId) => this.isActive(pluginId),
3293
- getOption: (key) => optionsRepo.get(key),
3294
- getOptions: (keys) => optionsRepo.getMany(keys),
3295
- setOption: (key, value) => optionsRepo.set(key, value),
3296
- deleteOption: async (key) => {
3297
- await optionsRepo.delete(key);
3298
- },
3299
- preferredHints
3300
- });
3301
- }
3302
- /**
3303
- * Get all exclusive hooks with their providers and current selections.
3304
- * Used by the admin API.
3305
- */
3306
- async getExclusiveHooksInfo() {
3307
- this.ensureInitialized();
3308
- const exclusiveHookNames = this.hookPipeline.getRegisteredExclusiveHooks();
3309
- const result = [];
3310
- for (const hookName of exclusiveHookNames) {
3311
- const providers = this.hookPipeline.getExclusiveHookProviders(hookName);
3312
- const selection = await this.getExclusiveHookSelection(hookName);
3313
- result.push({
3314
- hookName,
3315
- providers,
3316
- selectedPluginId: selection
3317
- });
3318
- }
3319
- return result;
3320
- }
3321
- /**
3322
- * Initialize or reinitialize the hook pipeline and route registry
3323
- */
3324
- ensureInitialized() {
3325
- if (this.initialized) return;
3326
- const activePlugins = this.getActivePlugins();
3327
- this.hookPipeline = new HookPipeline(activePlugins, this.factoryOptions);
3328
- this.routeRegistry = new PluginRouteRegistry(this.factoryOptions);
3329
- for (const plugin of activePlugins) this.routeRegistry.register(plugin);
3330
- this.initialized = true;
3331
- }
3332
- /**
3333
- * Force reinitialization (useful after plugin state changes)
3334
- */
3335
- reinitialize() {
3336
- this.initialized = false;
3337
- this.ensureInitialized();
3338
- }
3339
- /**
3340
- * Delete all cron tasks for a plugin.
3341
- * Used during uninstall.
3342
- */
3343
- async deleteCronTasks(pluginId) {
3344
- try {
3345
- await sql`
3346
- DELETE FROM _emdash_cron_tasks
3347
- WHERE plugin_id = ${pluginId}
3348
- `.execute(this.options.db);
3349
- } catch {}
3350
- }
3351
- };
3352
- /**
3353
- * Create a plugin manager
3354
- */
3355
- function createPluginManager(options) {
3356
- return new PluginManager(options);
3357
- }
3358
-
3359
- //#endregion
3360
- //#region src/plugins/scheduler/node.ts
3361
- /** Minimum polling interval (ms) — prevents tight loops if next_run_at is in the past */
3362
- const MIN_INTERVAL_MS = 1e3;
3363
- /**
3364
- * Maximum polling interval (ms). Each wake runs the maintenance pass — stale
3365
- * lock recovery *and* the scheduled-publishing sweep + system cleanup. The cap
3366
- * is the worst-case latency for scheduled content when no plugin cron task is
3367
- * due sooner (`getNextDueTime()` only knows about cron tasks, not content
3368
- * `scheduled_at`). Held at 60s so Node publish latency matches the Cloudflare
3369
- * Cron Trigger cadence (`* * * * *`) rather than lagging up to five minutes.
3370
- */
3371
- const MAX_INTERVAL_MS = 60 * 1e3;
3372
- var NodeCronScheduler = class {
3373
- timer = null;
3374
- running = false;
3375
- systemCleanup = null;
3376
- constructor(executor) {
3377
- this.executor = executor;
3378
- }
3379
- setSystemCleanup(fn) {
3380
- this.systemCleanup = fn;
3381
- }
3382
- start() {
3383
- this.running = true;
3384
- this.arm();
3385
- }
3386
- stop() {
3387
- this.running = false;
3388
- if (this.timer) {
3389
- clearTimeout(this.timer);
3390
- this.timer = null;
3391
- }
3392
- }
3393
- reschedule() {
3394
- if (!this.running) return;
3395
- if (this.timer) {
3396
- clearTimeout(this.timer);
3397
- this.timer = null;
3398
- }
3399
- this.arm();
3400
- }
3401
- arm() {
3402
- if (!this.running) return;
3403
- this.executor.getNextDueTime().then((nextDue) => {
3404
- if (!this.running) return void 0;
3405
- let delayMs;
3406
- if (nextDue) {
3407
- const dueAt = new Date(nextDue).getTime();
3408
- delayMs = Math.max(dueAt - Date.now(), MIN_INTERVAL_MS);
3409
- delayMs = Math.min(delayMs, MAX_INTERVAL_MS);
3410
- } else delayMs = MAX_INTERVAL_MS;
3411
- this.timer = setTimeout(() => {
3412
- if (!this.running) return;
3413
- this.executeTick();
3414
- }, delayMs);
3415
- if (this.timer && typeof this.timer === "object" && "unref" in this.timer) this.timer.unref();
3416
- }).catch((error) => {
3417
- console.error("[cron:node] Failed to get next due time:", error);
3418
- if (this.running) {
3419
- this.timer = setTimeout(() => this.arm(), MAX_INTERVAL_MS);
3420
- if (this.timer && typeof this.timer === "object" && "unref" in this.timer) this.timer.unref();
3421
- }
3422
- });
3423
- }
3424
- executeTick() {
3425
- if (!this.running) return;
3426
- const tasks = [this.executor.tick(), this.executor.recoverStaleLocks()];
3427
- if (this.systemCleanup) tasks.push(this.systemCleanup());
3428
- Promise.allSettled(tasks).then((results) => {
3429
- for (const r of results) if (r.status === "rejected") console.error("[cron:node] Tick task failed:", r.reason);
3430
- }).finally(() => {
3431
- if (this.running) this.arm();
3432
- });
3433
- }
3434
- };
3435
-
3436
- //#endregion
3437
- //#region src/plugins/sandbox/noop.ts
3438
- /**
3439
- * Error thrown when attempting to use sandboxing on an unsupported platform.
3440
- */
3441
- var SandboxNotAvailableError = class extends Error {
3442
- constructor() {
3443
- super("Plugin sandboxing is not available. Configure a sandbox runner: use @emdash-cms/cloudflare/sandbox on Cloudflare, or @emdash-cms/sandbox-workerd/sandbox on Node.js (requires workerd). Without sandboxing, use trusted plugins (from config) instead.");
3444
- this.name = "SandboxNotAvailableError";
3445
- }
3446
- };
3447
- /**
3448
- * No-op sandbox runner for platforms without isolation support.
3449
- *
3450
- * - `isAvailable()` returns false
3451
- * - `load()` throws SandboxNotAvailableError
3452
- * - `terminateAll()` is a no-op
3453
- *
3454
- * This is the default runner when no platform adapter is configured.
3455
- */
3456
- var NoopSandboxRunner = class {
3457
- /**
3458
- * Always returns false - sandboxing is not available.
3459
- */
3460
- isAvailable() {
3461
- return false;
3462
- }
3463
- /**
3464
- * Always returns false - no sandbox runtime to be healthy.
3465
- */
3466
- isHealthy() {
3467
- return false;
3468
- }
3469
- /**
3470
- * Always throws - can't load sandboxed plugins without isolation.
3471
- */
3472
- async load(_manifest, _code) {
3473
- throw new SandboxNotAvailableError();
3474
- }
3475
- /**
3476
- * No-op - sandboxing not available, email callback is irrelevant.
3477
- */
3478
- setEmailSend() {}
3479
- /**
3480
- * No-op - nothing to terminate.
3481
- */
3482
- async terminateAll() {}
3483
- };
3484
- /**
3485
- * Create a no-op sandbox runner.
3486
- * This is used as the default when no platform adapter is configured.
3487
- */
3488
- function createNoopSandboxRunner(_options) {
3489
- return new NoopSandboxRunner();
3490
- }
3491
-
3492
- //#endregion
3493
- //#region src/plugins/sandbox/hook-result.ts
3494
- /** Current wire-format version for sandbox hook result envelopes. */
3495
- const SANDBOX_HOOK_RESULT_VERSION = 1;
3496
- /** Maximum editor-facing rejection reason accepted from a sandboxed plugin. */
3497
- const MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH = 500;
3498
- function isRecord(value) {
3499
- return typeof value === "object" && value !== null && !Array.isArray(value);
3500
- }
3501
- /** Validate and normalize an untrusted value returned across the sandbox boundary. */
3502
- function inspectSandboxHookResult(value) {
3503
- if (!isRecord(value) || !Object.hasOwn(value, "__emdashSandboxHookResult")) return { kind: "value" };
3504
- if (value.__emdashSandboxHookResult !== true || value.version !== SANDBOX_HOOK_RESULT_VERSION || !isRecord(value.error) || value.error.code !== "SAVE_REJECTED" || typeof value.error.reason !== "string") return { kind: "malformed" };
3505
- const reason = value.error.reason.trim();
3506
- if (reason.length === 0 || reason.length > MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH) return { kind: "malformed" };
3507
- return {
3508
- kind: "error",
3509
- error: {
3510
- code: "SAVE_REJECTED",
3511
- reason
3512
- }
3513
- };
3514
- }
3515
-
3516
- //#endregion
3517
- //#region src/comments/ranking.ts
3518
- /**
3519
- * Comment ranking utilities (Tier 1 of the best-in-class comments RFC).
3520
- *
3521
- * Wilson score lower-bound (95% confidence) — the same primitive Reddit uses
3522
- * for its "Best" comment sort. Ranks by the statistical lower bound of the
3523
- * positive-reaction proportion rather than the raw count, so a comment with a
3524
- * couple of reactions can't outrank a heavily-reacted one until it earns
3525
- * confidence, and a late-but-popular comment still rises (submission time is
3526
- * irrelevant).
3527
- *
3528
- * Positive-only reactions (the recommended default) degrade gracefully: with
3529
- * `down = 0` the score still increases monotonically with `up` while penalising
3530
- * low-sample comments — wilson(1,0) ≈ 0.21, wilson(10,0) ≈ 0.73,
3531
- * wilson(200,0) ≈ 0.98.
3532
- */
3533
- /** z for a 95% two-sided confidence interval. */
3534
- const DEFAULT_Z = 1.96;
3535
- /** Reactions that count against a comment when both signals are in use. */
3536
- const NEGATIVE_REACTIONS = new Set(["dislike", "down"]);
3537
- /**
3538
- * Wilson score lower bound of the positive proportion.
3539
- *
3540
- * @param up count of positive reactions
3541
- * @param down count of negative reactions
3542
- * @returns a score in [0, 1]; 0 when there are no reactions
3543
- */
3544
- function wilsonLowerBound(up, down, z = DEFAULT_Z) {
3545
- const n = up + down;
3546
- if (n <= 0) return 0;
3547
- const phat = up / n;
3548
- const z2 = z * z;
3549
- const denom = 1 + z2 / n;
3550
- return (phat + z2 / (2 * n) - z * Math.sqrt((phat * (1 - phat) + z2 / (4 * n)) / n)) / denom;
3551
- }
3552
- /**
3553
- * Reduce a per-reaction count map to a single rank score via the Wilson
3554
- * lower bound. Any reaction not in {@link NEGATIVE_REACTIONS} is treated as
3555
- * positive, so the positive-only default (just `like`) works without special
3556
- * casing.
3557
- */
3558
- function reactionScore(counts) {
3559
- let up = 0;
3560
- let down = 0;
3561
- for (const [reaction, count] of Object.entries(counts)) if (NEGATIVE_REACTIONS.has(reaction)) down += count;
3562
- else up += count;
3563
- return wilsonLowerBound(up, down);
3564
- }
3565
-
3566
- //#endregion
3567
- //#region src/comments/query.ts
3568
- /**
3569
- * Get approved comments for a content item.
3570
- *
3571
- * @example
3572
- * ```ts
3573
- * import { getComments } from "emdash";
3574
- *
3575
- * const { items, total } = await getComments({
3576
- * collection: "posts",
3577
- * contentId: post.id,
3578
- * threaded: true,
3579
- * });
3580
- * ```
3581
- */
3582
- async function getComments(options) {
3583
- const sort = options.sort ?? "oldest";
3584
- const withReactions = options.reactions || sort === "best";
3585
- const threaded = options.threaded ? "t" : "f";
3586
- return cachedQuery({
3587
- namespace: CacheNamespace.COMMENTS,
3588
- key: `comments:${options.collection}:${options.contentId}:${threaded}:${withReactions ? "r" : "n"}:${sort}`,
3589
- load: async () => {
3590
- return getCommentsWithDb(await getDb(), options);
3591
- }
3592
- });
3593
- }
3594
- /**
3595
- * Get approved comments with an explicit db handle.
3596
- *
3597
- * @internal Use `getComments()` in templates. This variant is for routes
3598
- * that already have a database handle.
3599
- */
3600
- async function getCommentsWithDb(db, options) {
3601
- const repo = new CommentRepository(db);
3602
- const total = await repo.countByContent(options.collection, options.contentId, "approved");
3603
- const result = await repo.findByContent(options.collection, options.contentId, {
3604
- status: "approved",
3605
- limit: 500
3606
- });
3607
- const items = options.threaded ? CommentRepository.assembleThreads(result.items).map((c) => CommentRepository.toPublicComment(c)) : result.items.map((c) => CommentRepository.toPublicComment(c));
3608
- if (options.reactions || options.sort === "best") {
3609
- await attachReactions(db, items);
3610
- if (options.sort === "best") sortByBest(items);
3611
- }
3612
- return {
3613
- items,
3614
- total
3615
- };
3616
- }
3617
- /**
3618
- * Attach aggregate reaction counts to a list of public comments (and their
3619
- * replies), in a single batched query.
3620
- */
3621
- async function attachReactions(db, items) {
3622
- const ids = [];
3623
- for (const comment of items) {
3624
- ids.push(comment.id);
3625
- if (comment.replies) for (const reply of comment.replies) ids.push(reply.id);
3626
- }
3627
- if (ids.length === 0) return;
3628
- const counts = await new CommentReactionRepository(db).countsForComments(ids);
3629
- const assign = (comment) => {
3630
- const reactions = counts.get(comment.id);
3631
- if (reactions) comment.reactions = reactions;
3632
- };
3633
- for (const comment of items) {
3634
- assign(comment);
3635
- comment.replies?.forEach(assign);
3636
- }
3637
- }
3638
- /**
3639
- * Sort top-level comments by Wilson-scored reactions (descending), tie-broken
3640
- * by oldest-first to keep ordering stable.
3641
- */
3642
- function sortByBest(items) {
3643
- items.sort((a, b) => {
3644
- const scoreDelta = reactionScore(b.reactions ?? {}) - reactionScore(a.reactions ?? {});
3645
- if (scoreDelta !== 0) return scoreDelta;
3646
- if (a.createdAt < b.createdAt) return -1;
3647
- if (a.createdAt > b.createdAt) return 1;
3648
- return 0;
3649
- });
3650
- }
3651
- /**
3652
- * Get the count of approved comments for a content item.
3653
- *
3654
- * @example
3655
- * ```ts
3656
- * import { getCommentCount } from "emdash";
3657
- *
3658
- * const count = await getCommentCount("posts", post.id);
3659
- * ```
3660
- */
3661
- async function getCommentCount(collection, contentId) {
3662
- return getCommentCountWithDb(await getDb(), collection, contentId);
3663
- }
3664
- /**
3665
- * Get comment count with an explicit db handle.
3666
- *
3667
- * @internal Use `getCommentCount()` in templates.
3668
- */
3669
- async function getCommentCountWithDb(db, collection, contentId) {
3670
- return new CommentRepository(db).countByContent(collection, contentId, "approved");
3671
- }
3672
-
3673
- //#endregion
3674
- //#region src/menus/index.ts
3675
- /**
3676
- * Get a menu by name with resolved URLs.
3677
- *
3678
- * @example
3679
- * ```ts
3680
- * const menu = await getMenu("primary");
3681
- * const menuEs = await getMenu("primary", { locale: "es" });
3682
- * ```
3683
- */
3684
- function getMenu(name, options = {}) {
3685
- const locale = resolveLocale(options.locale);
3686
- return requestCached(`menu:${name}:${locale ?? "*"}`, () => cachedQuery({
3687
- namespace: CacheNamespace.MENUS,
3688
- key: `${name}:${locale ?? "*"}`,
3689
- load: async () => {
3690
- return getMenuWithDb(name, await getDb(), { locale });
3691
- }
3692
- }));
3693
- }
3694
- /**
3695
- * Get menu by name with resolved URLs (with explicit db). Internal helper for
3696
- * admin routes that already have a database handle.
3697
- */
3698
- async function getMenuWithDb(name, db, options = {}) {
3699
- const chain = resolveLocaleChain(options.locale);
3700
- const selectMenu = () => db.selectFrom("_emdash_menus").selectAll().where("name", "=", name);
3701
- let menuRow;
3702
- if (chain.length === 0) menuRow = await selectMenu().orderBy("locale", "asc").executeTakeFirst();
3703
- else {
3704
- menuRow = void 0;
3705
- for (const locale of chain) {
3706
- menuRow = await selectMenu().where("locale", "=", locale).executeTakeFirst();
3707
- if (menuRow) break;
3708
- }
3709
- }
3710
- if (!menuRow) return null;
3711
- const items = await buildMenuTree(await db.selectFrom("_emdash_menu_items").selectAll().$castTo().where("menu_id", "=", menuRow.id).orderBy("sort_order", "asc").execute(), db, menuRow.locale);
3712
- return {
3713
- id: menuRow.id,
3714
- name: menuRow.name,
3715
- label: menuRow.label,
3716
- items,
3717
- locale: menuRow.locale,
3718
- translationGroup: menuRow.translation_group
3719
- };
3720
- }
3721
- /**
3722
- * Get all menus (without items, locale-filtered — for admin list / site nav
3723
- * summaries). When no locale is configured, returns menus across all locales.
3724
- */
3725
- async function getMenus(options = {}) {
3726
- return getMenusWithDb(await getDb(), options);
3727
- }
3728
- /**
3729
- * Get all menus (with explicit db)
3730
- *
3731
- * @internal Use `getMenus()` in templates. This variant is for admin routes
3732
- * that already have a database handle.
3733
- */
3734
- async function getMenusWithDb(db, options = {}) {
3735
- const locale = resolveLocale(options.locale);
3736
- let query = db.selectFrom("_emdash_menus").select([
3737
- "id",
3738
- "name",
3739
- "label",
3740
- "locale"
3741
- ]).orderBy("name", "asc");
3742
- if (locale !== void 0) query = query.where("locale", "=", locale);
3743
- return query.execute();
3744
- }
3745
- /**
3746
- * Get a menu by name with a Workers edge-cache hint.
3747
- *
3748
- * Use the returned `cacheHint` with `Astro.cache.set()` so pages that render
3749
- * this menu can be purged automatically when the menu is edited.
3750
- */
3751
- async function getMenuWithCacheHint(name, options = {}) {
3752
- return {
3753
- data: await getMenu(name, options),
3754
- cacheHint: { tags: [menuTag(name)] }
3755
- };
3756
- }
3757
- /**
3758
- * Build a hierarchical menu tree from a flat list of items. Items are
3759
- * resolved against the given `locale` so references land on the right
3760
- * per-locale content rows.
3761
- */
3762
- async function buildMenuTree(items, db, locale) {
3763
- const contentReferences = collectContentReferences(items);
3764
- const taxonomyReferences = new Set(items.flatMap((item) => item.type === "taxonomy" && item.reference_id ? [item.reference_id] : []));
3765
- const [urlPatterns, contentLookup, taxonomyLookup] = await Promise.all([
3766
- contentReferences.size > 0 ? getCollectionUrlPatterns(db, new Set(contentReferences.keys())) : /* @__PURE__ */ new Map(),
3767
- resolveContentReferences(db, contentReferences, locale),
3768
- resolveTaxonomyReferences(db, taxonomyReferences, locale)
3769
- ]);
3770
- const validItems = items.map((item) => resolveMenuItem(item, urlPatterns, contentLookup, taxonomyLookup)).filter((item) => item !== null);
3771
- const itemMap = /* @__PURE__ */ new Map();
3772
- const rootItems = [];
3773
- for (const item of validItems) itemMap.set(item.id, {
3774
- ...item,
3775
- children: []
3776
- });
3777
- for (const item of items) {
3778
- const menuItem = itemMap.get(item.id);
3779
- if (!menuItem) continue;
3780
- if (item.parent_id) {
3781
- const parent = itemMap.get(item.parent_id);
3782
- if (parent) parent.children.push(menuItem);
3783
- else rootItems.push(menuItem);
3784
- } else rootItems.push(menuItem);
3785
- }
3786
- return rootItems;
3787
- }
3788
- function collectContentReferences(items) {
3789
- const references = /* @__PURE__ */ new Map();
3790
- for (const item of items) {
3791
- const reference = getContentReference(item);
3792
- if (!reference) continue;
3793
- let ids = references.get(reference.collection);
3794
- if (!ids) {
3795
- ids = /* @__PURE__ */ new Set();
3796
- references.set(reference.collection, ids);
3797
- }
3798
- ids.add(reference.id);
3799
- }
3800
- return references;
3801
- }
3802
- function getContentReference(item) {
3803
- if (item.type === "page" || item.type === "post") {
3804
- if (!item.reference_id) return null;
3805
- return {
3806
- collection: item.reference_collection || `${item.type}s`,
3807
- id: item.reference_id
3808
- };
3809
- }
3810
- if (item.type === "collection") {
3811
- if (!item.reference_collection || !item.reference_id) return null;
3812
- return {
3813
- collection: item.reference_collection,
3814
- id: item.reference_id
3815
- };
3816
- }
3817
- if (item.type !== "custom" && item.type !== "taxonomy" && item.reference_collection && item.reference_id) return {
3818
- collection: item.reference_collection,
3819
- id: item.reference_id
3820
- };
3821
- return null;
3822
- }
3823
- /**
3824
- * Look up the `url_pattern` for a set of collection slugs, request-cached so
3825
- * a page rendering several menus (header, footer, ...) only pays for the
3826
- * lookup once per distinct slug set. Callers must treat the returned map as
3827
- * read-only — it is shared across cache hits within the request.
3828
- */
3829
- function getCollectionUrlPatterns(db, collectionSlugs) {
3830
- return requestCached(`menu-collection-patterns:${[...collectionSlugs].toSorted().join(",")}`, async () => {
3831
- const rows = await db.selectFrom("_emdash_collections").select(["slug", "url_pattern"]).where("slug", "in", [...collectionSlugs]).execute();
3832
- const urlPatterns = /* @__PURE__ */ new Map();
3833
- for (const row of rows) urlPatterns.set(row.slug, row.url_pattern);
3834
- return urlPatterns;
3835
- });
3836
- }
3837
- /**
3838
- * Resolve a single menu item's URL. `reference_id` is a translation_group
3839
- * (migration 036 remapped all existing references); we look it up against
3840
- * the per-locale ec_* row or per-locale taxonomy row.
3841
- */
3842
- function resolveMenuItem(item, urlPatterns, contentLookup, taxonomyLookup) {
3843
- let url;
3844
- switch (item.type) {
3845
- case "custom":
3846
- url = item.custom_url || "#";
3847
- break;
3848
- case "page":
3849
- case "post":
3850
- url = resolveContentUrl(item.reference_collection || `${item.type}s`, item.reference_id, urlPatterns, contentLookup);
3851
- if (url === null) return null;
3852
- break;
3853
- case "taxonomy":
3854
- url = resolveTaxonomyUrl(item.reference_id, taxonomyLookup);
3855
- if (url === null) return null;
3856
- break;
3857
- case "collection":
3858
- if (!item.reference_collection) return null;
3859
- if (item.reference_id) {
3860
- url = resolveContentUrl(item.reference_collection, item.reference_id, urlPatterns, contentLookup);
3861
- if (url === null) return null;
3862
- } else url = `/${item.reference_collection}/`;
3863
- break;
3864
- default: if (item.reference_collection && item.reference_id) {
3865
- url = resolveContentUrl(item.reference_collection, item.reference_id, urlPatterns, contentLookup);
3866
- if (url === null) return null;
3867
- } else url = "#";
3868
- }
3869
- return {
3870
- id: item.id,
3871
- label: item.label,
3872
- url: sanitizeHref(url),
3873
- target: item.target || void 0,
3874
- titleAttr: item.title_attr || void 0,
3875
- cssClasses: item.css_classes || void 0,
3876
- children: []
3877
- };
3878
- }
3879
- async function resolveContentReferences(db, references, locale) {
3880
- const entries = await Promise.all(Array.from(references, async ([collection, referenceGroups]) => {
3881
- const lookup = /* @__PURE__ */ new Map();
3882
- const localized = /* @__PURE__ */ new Map();
3883
- try {
3884
- validateIdentifier(collection, "menu item collection");
3885
- for (const batch of chunks([...referenceGroups], SQL_BATCH_SIZE)) {
3886
- const result = await sql`
3887
- SELECT id, slug, published_at, locale, translation_group
3888
- FROM ${sql.ref(`ec_${collection}`)}
3889
- WHERE translation_group IN (${sql.join(batch)})
3890
- `.execute(db);
3891
- for (const row of result.rows) if (shouldPreferLocalizedRow(row, localized.get(row.translation_group), locale)) localized.set(row.translation_group, row);
3892
- }
3893
- for (const [referenceGroup, row] of localized) lookup.set(referenceGroup, {
3894
- id: row.id,
3895
- slug: row.slug,
3896
- publishedAt: row.published_at
3897
- });
3898
- const unresolved = [...referenceGroups].filter((id) => !lookup.has(id));
3899
- for (const batch of chunks(unresolved, SQL_BATCH_SIZE)) {
3900
- const result = await sql`
3901
- SELECT id, slug, published_at FROM ${sql.ref(`ec_${collection}`)}
3902
- WHERE id IN (${sql.join(batch)})
3903
- `.execute(db);
3904
- for (const row of result.rows) lookup.set(row.id, {
3905
- id: row.id,
3906
- slug: row.slug,
3907
- publishedAt: row.published_at
3908
- });
3909
- }
3910
- } catch (error) {
3911
- console.error(`Failed to resolve content URLs for ${collection}:`, error);
3912
- }
3913
- return [collection, lookup];
3914
- }));
3915
- return new Map(entries);
3916
- }
3917
- function shouldPreferLocalizedRow(candidate, existing, locale) {
3918
- if (!existing) return true;
3919
- if (candidate.locale === locale) return existing.locale !== locale || candidate.id < existing.id;
3920
- if (existing.locale === locale) return false;
3921
- return candidate.locale < existing.locale || candidate.locale === existing.locale && candidate.id < existing.id;
3922
- }
3923
- /**
3924
- * Resolve the URL for a content reference. `referenceGroup` is the content
3925
- * row's translation_group; we look up the row in the requested locale
3926
- * (falling back to the source if no translation exists so the menu link is
3927
- * still clickable).
3928
- */
3929
- function resolveContentUrl(collection, referenceGroup, urlPatterns, contentLookup) {
3930
- if (!referenceGroup) return null;
3931
- const row = contentLookup.get(collection)?.get(referenceGroup);
3932
- if (!row) return null;
3933
- return interpolateUrlPattern({
3934
- pattern: urlPatterns.get(collection) ?? null,
3935
- collection,
3936
- slug: row.slug,
3937
- id: row.id,
3938
- date: row.publishedAt
3939
- });
3940
- }
3941
- async function resolveTaxonomyReferences(db, referenceGroups, locale) {
3942
- const lookup = /* @__PURE__ */ new Map();
3943
- const localized = /* @__PURE__ */ new Map();
3944
- try {
3945
- for (const batch of chunks([...referenceGroups], SQL_BATCH_SIZE)) {
3946
- const rows = await db.selectFrom("taxonomies").select([
3947
- "id",
3948
- "name",
3949
- "slug",
3950
- "locale",
3951
- "translation_group"
3952
- ]).where("translation_group", "in", batch).$narrowType().execute();
3953
- for (const row of rows) if (shouldPreferLocalizedRow(row, localized.get(row.translation_group), locale)) localized.set(row.translation_group, row);
3954
- }
3955
- for (const [referenceGroup, row] of localized) lookup.set(referenceGroup, {
3956
- name: row.name,
3957
- slug: row.slug
3958
- });
3959
- const unresolved = [...referenceGroups].filter((id) => !lookup.has(id));
3960
- for (const batch of chunks(unresolved, SQL_BATCH_SIZE)) {
3961
- const rows = await db.selectFrom("taxonomies").select([
3962
- "id",
3963
- "name",
3964
- "slug"
3965
- ]).where("id", "in", batch).execute();
3966
- for (const row of rows) lookup.set(row.id, {
3967
- name: row.name,
3968
- slug: row.slug
3969
- });
3970
- }
3971
- } catch (error) {
3972
- console.error("Failed to resolve taxonomy URLs:", error);
3973
- }
3974
- return lookup;
3975
- }
3976
- /**
3977
- * Resolve URL for a taxonomy term reference. `referenceGroup` is the term's
3978
- * translation_group; we pick the row in the active locale (or fall back).
3979
- */
3980
- function resolveTaxonomyUrl(referenceGroup, taxonomyLookup) {
3981
- if (!referenceGroup) return null;
3982
- const taxonomy = taxonomyLookup.get(referenceGroup);
3983
- if (!taxonomy) return null;
3984
- return `/${taxonomy.name}/${taxonomy.slug}`;
3985
- }
3986
-
3987
- //#endregion
3988
- export { portableText as A, HookPipeline as C, portableTextToProsemirror as D, definePlugin as E, EmDashConfigurationError as F, file as M, image as N, prosemirrorToPortableText as O, AuditRepository as P, isContentSaveRejection as S, resolveExclusiveHooks as T, buildRouteMeta as _, getComments as a, EmailPipeline as b, inspectSandboxHookResult as c, createNoopSandboxRunner as d, NodeCronScheduler as f, PluginRouteRegistry as g, PluginRouteError as h, getCommentCount as i, reference as j, portableTextIdentityExtensions as k, NoopSandboxRunner as l, createPluginManager as m, getMenuWithCacheHint as n, MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH as o, PluginManager as p, getMenus as r, SANDBOX_HOOK_RESULT_VERSION as s, getMenu as t, SandboxNotAvailableError as u, parseRouteInput as v, createHookPipeline as w, ContentSaveRejectedError as x, toRouteCallerInfo as y };
3989
- //# sourceMappingURL=menus-D8mC4eaN.mjs.map