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