emdash 0.40.0 → 0.41.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 (1258) hide show
  1. package/dist/action-token-CbKDcPJi.mjs +26 -0
  2. package/dist/action-token-CbKDcPJi.mjs.map +1 -0
  3. package/dist/activation-PtniBLt9.mjs +382 -0
  4. package/dist/activation-PtniBLt9.mjs.map +1 -0
  5. package/dist/adapters-C_Tf5x90.d.mts +171 -0
  6. package/dist/adapters-C_Tf5x90.d.mts.map +1 -0
  7. package/dist/allowed-origins-U1z4TdEZ.mjs +116 -0
  8. package/dist/allowed-origins-U1z4TdEZ.mjs.map +1 -0
  9. package/dist/api/route-utils.d.mts +4 -4
  10. package/dist/api/route-utils.mjs +46 -45
  11. package/dist/api/route-utils.mjs.map +1 -1
  12. package/dist/api/schemas/index.d.mts +2 -2
  13. package/dist/api/schemas/index.mjs +10 -10
  14. package/dist/api-CXwQkV_m.mjs +5122 -0
  15. package/dist/api-CXwQkV_m.mjs.map +1 -0
  16. package/dist/api-tokens-89WlohEN.mjs +166 -0
  17. package/dist/api-tokens-89WlohEN.mjs.map +1 -0
  18. package/dist/apply-Do3KNnUk.mjs +1659 -0
  19. package/dist/apply-Do3KNnUk.mjs.map +1 -0
  20. package/dist/approvals-CAX9Yw33.mjs +460 -0
  21. package/dist/approvals-CAX9Yw33.mjs.map +1 -0
  22. package/dist/artifact-fetch-B9W4CEST.mjs +659 -0
  23. package/dist/artifact-fetch-B9W4CEST.mjs.map +1 -0
  24. package/dist/astro/index.d.mts +14 -14
  25. package/dist/astro/index.mjs +26 -30
  26. package/dist/astro/index.mjs.map +1 -1
  27. package/dist/astro/middleware/auth.d.mts +12 -12
  28. package/dist/astro/middleware/auth.mjs +10 -10
  29. package/dist/astro/middleware/media-usage-write-fence.mjs +5 -5
  30. package/dist/astro/middleware/redirect.mjs +7 -7
  31. package/dist/astro/middleware/request-context.mjs +3 -3
  32. package/dist/astro/middleware/setup.mjs +1 -1
  33. package/dist/astro/middleware.d.mts +12 -12
  34. package/dist/astro/middleware.d.mts.map +1 -1
  35. package/dist/astro/middleware.mjs +110 -106
  36. package/dist/astro/middleware.mjs.map +1 -1
  37. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +14 -14
  38. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +14 -14
  39. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +6 -6
  40. package/dist/astro/routes/api/admin/api-tokens/index.mjs +7 -7
  41. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +7 -7
  42. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +17 -17
  43. package/dist/astro/routes/api/admin/byline-fields/index.mjs +17 -17
  44. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +17 -17
  45. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +23 -23
  46. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +23 -23
  47. package/dist/astro/routes/api/admin/bylines/index.mjs +23 -23
  48. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +18 -18
  49. package/dist/astro/routes/api/admin/comments/_id_.mjs +7 -7
  50. package/dist/astro/routes/api/admin/comments/bulk.mjs +17 -17
  51. package/dist/astro/routes/api/admin/comments/counts.mjs +7 -7
  52. package/dist/astro/routes/api/admin/comments/index.mjs +17 -17
  53. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +6 -6
  54. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +5 -5
  55. package/dist/astro/routes/api/admin/media-usage/activation.mjs +20 -20
  56. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +22 -22
  57. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +22 -22
  58. package/dist/astro/routes/api/admin/media-usage/progress.mjs +25 -25
  59. package/dist/astro/routes/api/admin/media-usage/repair.mjs +31 -31
  60. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +22 -22
  61. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +22 -22
  62. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +6 -6
  63. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +6 -6
  64. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +8 -8
  65. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +8 -8
  66. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +72 -68
  67. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  68. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +7 -7
  69. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +71 -67
  70. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
  71. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +72 -68
  72. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  73. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +82 -78
  74. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  75. package/dist/astro/routes/api/admin/plugins/index.mjs +72 -68
  76. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  77. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +5 -5
  78. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +71 -67
  79. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  80. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +81 -77
  81. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  82. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +71 -67
  83. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  84. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +72 -68
  85. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  86. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +83 -79
  87. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  88. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +9 -9
  89. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +74 -70
  90. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  91. package/dist/astro/routes/api/admin/plugins/registry/publisher-handle.mjs +7 -7
  92. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +72 -68
  93. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs.map +1 -1
  94. package/dist/astro/routes/api/admin/plugins/updates.mjs +71 -67
  95. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  96. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs +6 -6
  97. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +71 -67
  98. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  99. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +5 -5
  100. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +71 -67
  101. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  102. package/dist/astro/routes/api/admin/transfer/_...path_.mjs +4 -4
  103. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs +40 -40
  104. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs +40 -40
  105. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs +42 -42
  106. package/dist/astro/routes/api/admin/transfer/capabilities.mjs +42 -42
  107. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs +42 -42
  108. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs +43 -43
  109. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs +43 -43
  110. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs +42 -42
  111. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs +43 -43
  112. package/dist/astro/routes/api/admin/transfer/exports/index.mjs +44 -44
  113. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs +42 -42
  114. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs +42 -42
  115. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs +44 -44
  116. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs +42 -42
  117. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs +44 -44
  118. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs +42 -42
  119. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs +42 -42
  120. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs +44 -44
  121. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs +42 -42
  122. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs +42 -42
  123. package/dist/astro/routes/api/admin/transfer/imports/index.mjs +44 -44
  124. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +5 -5
  125. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +4 -4
  126. package/dist/astro/routes/api/admin/users/_id_/index.mjs +15 -15
  127. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +6 -6
  128. package/dist/astro/routes/api/admin/users/index.mjs +14 -14
  129. package/dist/astro/routes/api/auth/dev-bypass.mjs +6 -6
  130. package/dist/astro/routes/api/auth/invite/accept.mjs +4 -4
  131. package/dist/astro/routes/api/auth/invite/complete.mjs +18 -18
  132. package/dist/astro/routes/api/auth/invite/index.mjs +16 -16
  133. package/dist/astro/routes/api/auth/invite/register-options.mjs +17 -17
  134. package/dist/astro/routes/api/auth/logout.mjs +5 -5
  135. package/dist/astro/routes/api/auth/magic-link/send.mjs +18 -18
  136. package/dist/astro/routes/api/auth/magic-link/verify.mjs +14 -14
  137. package/dist/astro/routes/api/auth/me.mjs +15 -15
  138. package/dist/astro/routes/api/auth/mode.mjs +5 -5
  139. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +3 -3
  140. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  141. package/dist/astro/routes/api/auth/passkey/_id_.mjs +14 -14
  142. package/dist/astro/routes/api/auth/passkey/index.mjs +4 -4
  143. package/dist/astro/routes/api/auth/passkey/options.mjs +19 -19
  144. package/dist/astro/routes/api/auth/passkey/register/options.mjs +17 -17
  145. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +18 -18
  146. package/dist/astro/routes/api/auth/passkey/verify.mjs +18 -18
  147. package/dist/astro/routes/api/auth/signup/complete.mjs +18 -18
  148. package/dist/astro/routes/api/auth/signup/request.mjs +17 -17
  149. package/dist/astro/routes/api/auth/signup/verify.mjs +4 -4
  150. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +12 -12
  151. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +18 -18
  152. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +5 -5
  153. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +17 -17
  154. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +5 -5
  155. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +17 -17
  156. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +5 -5
  157. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs +11 -11
  158. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +31 -31
  159. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +17 -17
  160. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.d.mts +1 -2
  161. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.d.mts.map +1 -1
  162. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +42 -53
  163. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
  164. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +34 -29
  165. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
  166. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +5 -5
  167. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +5 -5
  168. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +17 -17
  169. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +25 -24
  170. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  171. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +5 -5
  172. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +17 -17
  173. package/dist/astro/routes/api/content/_collection_/_id_.d.mts.map +1 -1
  174. package/dist/astro/routes/api/content/_collection_/_id_.mjs +18 -18
  175. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  176. package/dist/astro/routes/api/content/_collection_/authors.mjs +5 -5
  177. package/dist/astro/routes/api/content/_collection_/index.mjs +15 -15
  178. package/dist/astro/routes/api/content/_collection_/trash.mjs +15 -15
  179. package/dist/astro/routes/api/dashboard.mjs +10 -9
  180. package/dist/astro/routes/api/dashboard.mjs.map +1 -1
  181. package/dist/astro/routes/api/dev/emails.mjs +5 -5
  182. package/dist/astro/routes/api/health.mjs +6 -6
  183. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  184. package/dist/astro/routes/api/import/probe.mjs +23 -23
  185. package/dist/astro/routes/api/import/wordpress/analyze.mjs +6 -6
  186. package/dist/astro/routes/api/import/wordpress/execute.d.mts +13 -13
  187. package/dist/astro/routes/api/import/wordpress/execute.mjs +16 -16
  188. package/dist/astro/routes/api/import/wordpress/media.d.mts +12 -12
  189. package/dist/astro/routes/api/import/wordpress/media.mjs +19 -19
  190. package/dist/astro/routes/api/import/wordpress/prepare.mjs +18 -18
  191. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +13 -13
  192. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +28 -28
  193. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  194. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +23 -23
  195. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +13 -13
  196. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +34 -34
  197. package/dist/astro/routes/api/manifest.mjs +6 -6
  198. package/dist/astro/routes/api/mcp.mjs +98 -118
  199. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  200. package/dist/astro/routes/api/media/_id_/confirm.mjs +19 -19
  201. package/dist/astro/routes/api/media/_id_/replace.mjs +16 -16
  202. package/dist/astro/routes/api/media/_id_/upload.mjs +9 -9
  203. package/dist/astro/routes/api/media/_id_/usage.mjs +33 -33
  204. package/dist/astro/routes/api/media/_id_.mjs +31 -31
  205. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs +6 -6
  206. package/dist/astro/routes/api/media/file/_...key_.mjs +9 -9
  207. package/dist/astro/routes/api/media/folders/_id_.mjs +16 -16
  208. package/dist/astro/routes/api/media/folders/index.mjs +16 -16
  209. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +5 -5
  210. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +5 -5
  211. package/dist/astro/routes/api/media/providers/index.mjs +5 -5
  212. package/dist/astro/routes/api/media/upload-url.mjs +18 -18
  213. package/dist/astro/routes/api/media.mjs +35 -35
  214. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +17 -17
  215. package/dist/astro/routes/api/menus/_name_/items.mjs +17 -17
  216. package/dist/astro/routes/api/menus/_name_/reorder.mjs +17 -17
  217. package/dist/astro/routes/api/menus/_name_/translations.mjs +17 -17
  218. package/dist/astro/routes/api/menus/_name_.mjs +17 -17
  219. package/dist/astro/routes/api/menus/index.mjs +17 -17
  220. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  221. package/dist/astro/routes/api/oauth/device/authorize.d.mts +2 -1
  222. package/dist/astro/routes/api/oauth/device/authorize.d.mts.map +1 -1
  223. package/dist/astro/routes/api/oauth/device/authorize.mjs +23 -9
  224. package/dist/astro/routes/api/oauth/device/authorize.mjs.map +1 -1
  225. package/dist/astro/routes/api/oauth/device/code.mjs +11 -11
  226. package/dist/astro/routes/api/oauth/device/token.mjs +10 -10
  227. package/dist/astro/routes/api/oauth/register.mjs +5 -5
  228. package/dist/astro/routes/api/oauth/token/refresh.mjs +8 -8
  229. package/dist/astro/routes/api/oauth/token/revoke.mjs +8 -8
  230. package/dist/astro/routes/api/oauth/token.mjs +8 -8
  231. package/dist/astro/routes/api/openapi.json.mjs +20 -20
  232. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +11 -11
  233. package/dist/astro/routes/api/redirects/404s/index.mjs +19 -19
  234. package/dist/astro/routes/api/redirects/404s/summary.mjs +19 -19
  235. package/dist/astro/routes/api/redirects/_id_.mjs +19 -19
  236. package/dist/astro/routes/api/redirects/index.mjs +19 -19
  237. package/dist/astro/routes/api/relations/_id_/index.mjs +34 -29
  238. package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
  239. package/dist/astro/routes/api/relations/index.mjs +36 -31
  240. package/dist/astro/routes/api/relations/index.mjs.map +1 -1
  241. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +5 -5
  242. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +5 -5
  243. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs +71 -67
  244. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs.map +1 -1
  245. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs +71 -67
  246. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs.map +1 -1
  247. package/dist/astro/routes/api/schema/block-types/index.mjs +71 -67
  248. package/dist/astro/routes/api/schema/block-types/index.mjs.map +1 -1
  249. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +73 -69
  250. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  251. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +71 -67
  252. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  253. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +71 -67
  254. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  255. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +71 -67
  256. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  257. package/dist/astro/routes/api/schema/collections/index.mjs +71 -67
  258. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  259. package/dist/astro/routes/api/schema/collections/reorder.mjs +71 -67
  260. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  261. package/dist/astro/routes/api/schema/index.mjs +16 -16
  262. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +71 -67
  263. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  264. package/dist/astro/routes/api/schema/orphans/index.mjs +71 -67
  265. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  266. package/dist/astro/routes/api/search/enable.mjs +19 -19
  267. package/dist/astro/routes/api/search/index.mjs +18 -18
  268. package/dist/astro/routes/api/search/rebuild.mjs +19 -19
  269. package/dist/astro/routes/api/search/stats.mjs +9 -9
  270. package/dist/astro/routes/api/search/suggest.mjs +18 -18
  271. package/dist/astro/routes/api/sections/_slug_.mjs +18 -18
  272. package/dist/astro/routes/api/sections/index.mjs +18 -18
  273. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +7 -7
  274. package/dist/astro/routes/api/settings/backups/archives/index.mjs +7 -7
  275. package/dist/astro/routes/api/settings/backups/export.mjs +7 -7
  276. package/dist/astro/routes/api/settings/backups/index.mjs +8 -8
  277. package/dist/astro/routes/api/settings/email.mjs +6 -6
  278. package/dist/astro/routes/api/settings.mjs +21 -21
  279. package/dist/astro/routes/api/setup/admin-verify.mjs +19 -19
  280. package/dist/astro/routes/api/setup/admin.mjs +18 -18
  281. package/dist/astro/routes/api/setup/dev-bypass.mjs +45 -39
  282. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  283. package/dist/astro/routes/api/setup/dev-reset.mjs +4 -4
  284. package/dist/astro/routes/api/setup/index.d.mts.map +1 -1
  285. package/dist/astro/routes/api/setup/index.mjs +80 -49
  286. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  287. package/dist/astro/routes/api/setup/status.mjs +6 -6
  288. package/dist/astro/routes/api/snapshot.mjs +9 -9
  289. package/dist/astro/routes/api/snapshot.mjs.map +1 -1
  290. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +23 -23
  291. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +23 -23
  292. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +23 -23
  293. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +23 -23
  294. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +22 -22
  295. package/dist/astro/routes/api/taxonomies/_name_.mjs +23 -23
  296. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs +36 -35
  297. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs.map +1 -1
  298. package/dist/astro/routes/api/taxonomies/index.mjs +23 -23
  299. package/dist/astro/routes/api/themes/preview.mjs +6 -6
  300. package/dist/astro/routes/api/typegen.mjs +8 -8
  301. package/dist/astro/routes/api/visual-editing/action-token.mjs +6 -6
  302. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs +19 -19
  303. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs +4 -4
  304. package/dist/astro/routes/api/well-known/auth.mjs +1 -1
  305. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  306. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  307. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +16 -16
  308. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +19 -19
  309. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +19 -19
  310. package/dist/astro/routes/api/widget-areas/_name_.mjs +9 -9
  311. package/dist/astro/routes/api/widget-areas/index.mjs +19 -19
  312. package/dist/astro/routes/api/widget-components.mjs +5 -5
  313. package/dist/astro/routes/robots.txt.mjs +6 -6
  314. package/dist/astro/routes/sitemap-_collection_.xml.mjs +9 -9
  315. package/dist/astro/routes/sitemap.xml.mjs +7 -7
  316. package/dist/astro/types.d.mts +28 -18
  317. package/dist/astro/types.d.mts.map +1 -1
  318. package/dist/audit-CrgmE9LE.mjs +127 -0
  319. package/dist/audit-CrgmE9LE.mjs.map +1 -0
  320. package/dist/auth/providers/github.d.mts +1 -1
  321. package/dist/auth/providers/google.d.mts +1 -1
  322. package/dist/authoritative-records-C2YzIdbu.mjs +5172 -0
  323. package/dist/authoritative-records-C2YzIdbu.mjs.map +1 -0
  324. package/dist/authorize-WgdKF8QY.mjs +49 -0
  325. package/dist/authorize-WgdKF8QY.mjs.map +1 -0
  326. package/dist/backup-Ck8_lMO3.mjs +246 -0
  327. package/dist/backup-Ck8_lMO3.mjs.map +1 -0
  328. package/dist/block-types-BQ90asVI.mjs +132 -0
  329. package/dist/block-types-BQ90asVI.mjs.map +1 -0
  330. package/dist/block-values-ACFqgB1D.mjs +175 -0
  331. package/dist/block-values-ACFqgB1D.mjs.map +1 -0
  332. package/dist/bundle-Db1iNMv_.mjs +667 -0
  333. package/dist/bundle-Db1iNMv_.mjs.map +1 -0
  334. package/dist/byline-BayaYGoj.mjs +909 -0
  335. package/dist/byline-BayaYGoj.mjs.map +1 -0
  336. package/dist/byline-fields-B8HH-35f.mjs +254 -0
  337. package/dist/byline-fields-B8HH-35f.mjs.map +1 -0
  338. package/dist/byline-fields-hMPjf6Eu.mjs +123 -0
  339. package/dist/byline-fields-hMPjf6Eu.mjs.map +1 -0
  340. package/dist/byline-registry-B_EK_TQf.mjs +406 -0
  341. package/dist/byline-registry-B_EK_TQf.mjs.map +1 -0
  342. package/dist/bylines-DFAaFXWi.mjs +214 -0
  343. package/dist/bylines-DFAaFXWi.mjs.map +1 -0
  344. package/dist/bylines-DkIxUxmr.mjs +232 -0
  345. package/dist/bylines-DkIxUxmr.mjs.map +1 -0
  346. package/dist/cache-DkvhQ8XE.mjs +108 -0
  347. package/dist/cache-DkvhQ8XE.mjs.map +1 -0
  348. package/dist/canonical-CcSuuTlH.mjs +174 -0
  349. package/dist/canonical-CcSuuTlH.mjs.map +1 -0
  350. package/dist/capture-triggers-DJEoOTOq.mjs +362 -0
  351. package/dist/capture-triggers-DJEoOTOq.mjs.map +1 -0
  352. package/dist/challenge-store-CvBl81AQ.mjs +51 -0
  353. package/dist/challenge-store-CvBl81AQ.mjs.map +1 -0
  354. package/dist/checksum-CClweQzI.mjs +162 -0
  355. package/dist/checksum-CClweQzI.mjs.map +1 -0
  356. package/dist/chrome-tags-D5caJwwp.mjs +24 -0
  357. package/dist/chrome-tags-D5caJwwp.mjs.map +1 -0
  358. package/dist/chunks-DwBaj8aT.mjs +25 -0
  359. package/dist/chunks-DwBaj8aT.mjs.map +1 -0
  360. package/dist/cli/index.mjs +374 -761
  361. package/dist/cli/index.mjs.map +1 -1
  362. package/dist/client/cf-access.d.mts +1 -1
  363. package/dist/client/index.d.mts +18 -18
  364. package/dist/client/index.mjs +2 -2
  365. package/dist/collection-deletion-CLCdXsnV.mjs +436 -0
  366. package/dist/collection-deletion-CLCdXsnV.mjs.map +1 -0
  367. package/dist/collection-deletion-processor-hNw8x01F.mjs +217 -0
  368. package/dist/collection-deletion-processor-hNw8x01F.mjs.map +1 -0
  369. package/dist/collection-slugs-cache-CUuiduLq.mjs +85 -0
  370. package/dist/collection-slugs-cache-CUuiduLq.mjs.map +1 -0
  371. package/dist/comment-D2uvL63j.mjs +313 -0
  372. package/dist/comment-D2uvL63j.mjs.map +1 -0
  373. package/dist/comment-reaction-DevUuzg4.mjs +85 -0
  374. package/dist/comment-reaction-DevUuzg4.mjs.map +1 -0
  375. package/dist/comments-Cq0s7_hO.mjs +195 -0
  376. package/dist/comments-Cq0s7_hO.mjs.map +1 -0
  377. package/dist/comments-M4EDYAHw.mjs +99 -0
  378. package/dist/comments-M4EDYAHw.mjs.map +1 -0
  379. package/dist/components-CuIGwXMs.mjs +108 -0
  380. package/dist/components-CuIGwXMs.mjs.map +1 -0
  381. package/dist/config-52Ea5IWt.d.mts +39 -0
  382. package/dist/config-52Ea5IWt.d.mts.map +1 -0
  383. package/dist/config-CCz3xOLc.mjs +242 -0
  384. package/dist/config-CCz3xOLc.mjs.map +1 -0
  385. package/dist/config-D3d5Qudq.d.mts +6669 -0
  386. package/dist/config-D3d5Qudq.d.mts.map +1 -0
  387. package/dist/content-CbnufDsM.mjs +2018 -0
  388. package/dist/content-CbnufDsM.mjs.map +1 -0
  389. package/dist/content-list-query-D_7B1FE5.d.mts +26 -0
  390. package/dist/content-list-query-D_7B1FE5.d.mts.map +1 -0
  391. package/dist/content-policy-CYu6K1KB.mjs +46 -0
  392. package/dist/content-policy-CYu6K1KB.mjs.map +1 -0
  393. package/dist/content-repair-DlDUgFGp.mjs +442 -0
  394. package/dist/content-repair-DlDUgFGp.mjs.map +1 -0
  395. package/dist/context-CGQLA1-a.mjs +1922 -0
  396. package/dist/context-CGQLA1-a.mjs.map +1 -0
  397. package/dist/cron-c4D5C5Fx.mjs +284 -0
  398. package/dist/cron-c4D5C5Fx.mjs.map +1 -0
  399. package/dist/dashboard-CBq9kmOn.mjs +151 -0
  400. package/dist/dashboard-CBq9kmOn.mjs.map +1 -0
  401. package/dist/db/index.d.mts +3 -3
  402. package/dist/db/index.mjs +1 -1
  403. package/dist/db/libsql-migrations.d.mts +1 -1
  404. package/dist/db/libsql-migrations.mjs +4 -4
  405. package/dist/db/libsql.d.mts +1 -1
  406. package/dist/db/postgres-migrations.d.mts +1 -1
  407. package/dist/db/postgres-migrations.mjs +4 -4
  408. package/dist/db/postgres.d.mts +1 -1
  409. package/dist/db/sqlite-migrations.d.mts +1 -1
  410. package/dist/db/sqlite-migrations.mjs +4 -4
  411. package/dist/db/sqlite.d.mts +1 -1
  412. package/dist/db/sqlite.mjs +1 -1
  413. package/dist/default-DPsys51U.mjs +81 -0
  414. package/dist/default-DPsys51U.mjs.map +1 -0
  415. package/dist/deferred-tasks-CZ7rzBdo.d.mts +9 -0
  416. package/dist/deferred-tasks-CZ7rzBdo.d.mts.map +1 -0
  417. package/dist/dev-typegen-HRxwLRcT.mjs +29 -0
  418. package/dist/dev-typegen-HRxwLRcT.mjs.map +1 -0
  419. package/dist/device-flow-OcSqE9uY.mjs +521 -0
  420. package/dist/device-flow-OcSqE9uY.mjs.map +1 -0
  421. package/dist/digest-DVZ--cE9.mjs +194 -0
  422. package/dist/digest-DVZ--cE9.mjs.map +1 -0
  423. package/dist/direct-executor-DyjAqkpT.mjs +104 -0
  424. package/dist/direct-executor-DyjAqkpT.mjs.map +1 -0
  425. package/dist/dist-FPR93_xf.mjs +810 -0
  426. package/dist/dist-FPR93_xf.mjs.map +1 -0
  427. package/dist/email-console-DyQIgEnz.mjs +50 -0
  428. package/dist/email-console-DyQIgEnz.mjs.map +1 -0
  429. package/dist/email-locale-BYb16rVd.mjs +25 -0
  430. package/dist/email-locale-BYb16rVd.mjs.map +1 -0
  431. package/dist/emdash-runtime-CrzxJFmF.mjs +4214 -0
  432. package/dist/emdash-runtime-CrzxJFmF.mjs.map +1 -0
  433. package/dist/enrich-DBtCncE2.mjs +194 -0
  434. package/dist/enrich-DBtCncE2.mjs.map +1 -0
  435. package/dist/entry-lock-BN5y4YbO.d.mts +4481 -0
  436. package/dist/entry-lock-BN5y4YbO.d.mts.map +1 -0
  437. package/dist/entry-lock-BaRBHCsH.mjs +1173 -0
  438. package/dist/entry-lock-BaRBHCsH.mjs.map +1 -0
  439. package/dist/entry-lock-C6NcnZPV.mjs +163 -0
  440. package/dist/entry-lock-C6NcnZPV.mjs.map +1 -0
  441. package/dist/entry-locks-BTyQLdbC.mjs +167 -0
  442. package/dist/entry-locks-BTyQLdbC.mjs.map +1 -0
  443. package/dist/error-BfsNNrIE.mjs +90 -0
  444. package/dist/error-BfsNNrIE.mjs.map +1 -0
  445. package/dist/errors-BN1QAnEY.mjs +460 -0
  446. package/dist/errors-BN1QAnEY.mjs.map +1 -0
  447. package/dist/errors-Bt3goF8I.mjs +120 -0
  448. package/dist/errors-Bt3goF8I.mjs.map +1 -0
  449. package/dist/escape-BveidMa2.mjs +9 -0
  450. package/dist/escape-BveidMa2.mjs.map +1 -0
  451. package/dist/fence-Bb_IbCxI.mjs +162 -0
  452. package/dist/fence-Bb_IbCxI.mjs.map +1 -0
  453. package/dist/field-defs-cache-CsZctvbu.mjs +77 -0
  454. package/dist/field-defs-cache-CsZctvbu.mjs.map +1 -0
  455. package/dist/field-map-6m9rF49t.mjs +83 -0
  456. package/dist/field-map-6m9rF49t.mjs.map +1 -0
  457. package/dist/focal-point-CZ3d1wK5.mjs +23 -0
  458. package/dist/focal-point-CZ3d1wK5.mjs.map +1 -0
  459. package/dist/fts-manager-CCaZTp8y.mjs +443 -0
  460. package/dist/fts-manager-CCaZTp8y.mjs.map +1 -0
  461. package/dist/gc-xowRjczI.mjs +75 -0
  462. package/dist/gc-xowRjczI.mjs.map +1 -0
  463. package/dist/hash-COVK27Pc.mjs +37 -0
  464. package/dist/hash-COVK27Pc.mjs.map +1 -0
  465. package/dist/hook-result-CYSk0XFe.d.mts +31 -0
  466. package/dist/hook-result-CYSk0XFe.d.mts.map +1 -0
  467. package/dist/hreflang-CChPV7jx.mjs +105 -0
  468. package/dist/hreflang-CChPV7jx.mjs.map +1 -0
  469. package/dist/hreflang-DRslq3QI.d.mts +50 -0
  470. package/dist/hreflang-DRslq3QI.d.mts.map +1 -0
  471. package/dist/http-route-dispatch-CAdp2onn.mjs +339 -0
  472. package/dist/http-route-dispatch-CAdp2onn.mjs.map +1 -0
  473. package/dist/identity-NVTOOQyq.mjs +35 -0
  474. package/dist/identity-NVTOOQyq.mjs.map +1 -0
  475. package/dist/import-wpSO2N0x.mjs +2020 -0
  476. package/dist/import-wpSO2N0x.mjs.map +1 -0
  477. package/dist/index-CDs2wq4X.d.mts +623 -0
  478. package/dist/index-CDs2wq4X.d.mts.map +1 -0
  479. package/dist/index.d.mts +24 -24
  480. package/dist/index.mjs +103 -101
  481. package/dist/install-finalization-D9R9R-W8.mjs +58 -0
  482. package/dist/install-finalization-D9R9R-W8.mjs.map +1 -0
  483. package/dist/keys-Bck6LBfF.mjs +61 -0
  484. package/dist/keys-Bck6LBfF.mjs.map +1 -0
  485. package/dist/kinds-CYmRESWj.mjs +974 -0
  486. package/dist/kinds-CYmRESWj.mjs.map +1 -0
  487. package/dist/lifecycle-C815ZQfV.mjs +25 -0
  488. package/dist/lifecycle-C815ZQfV.mjs.map +1 -0
  489. package/dist/load-D99axixL.mjs +28 -0
  490. package/dist/load-D99axixL.mjs.map +1 -0
  491. package/dist/loader-CrRPfkHS.mjs +1197 -0
  492. package/dist/loader-CrRPfkHS.mjs.map +1 -0
  493. package/dist/loops-DMKlygqX.mjs +203 -0
  494. package/dist/loops-DMKlygqX.mjs.map +1 -0
  495. package/dist/manifest-builder-BQzCHNgB.mjs +189 -0
  496. package/dist/manifest-builder-BQzCHNgB.mjs.map +1 -0
  497. package/dist/manifest-schema-Ci2gmd0u.mjs +492 -0
  498. package/dist/manifest-schema-Ci2gmd0u.mjs.map +1 -0
  499. package/dist/media/image-endpoint.mjs +1 -1
  500. package/dist/media/index.d.mts +1 -1
  501. package/dist/media/index.mjs +4 -4
  502. package/dist/media/local-runtime.d.mts +14 -14
  503. package/dist/media/local-runtime.mjs +6 -6
  504. package/dist/media-BUQePMxP.mjs +373 -0
  505. package/dist/media-BUQePMxP.mjs.map +1 -0
  506. package/dist/media-DH8ibNlY.mjs +294 -0
  507. package/dist/media-DH8ibNlY.mjs.map +1 -0
  508. package/dist/media-OEIQ3bVc.mjs +408 -0
  509. package/dist/media-OEIQ3bVc.mjs.map +1 -0
  510. package/dist/media-allowlist-pYtaBA95.mjs +44 -0
  511. package/dist/media-allowlist-pYtaBA95.mjs.map +1 -0
  512. package/dist/media-folders-Bf8_s4de.mjs +210 -0
  513. package/dist/media-folders-Bf8_s4de.mjs.map +1 -0
  514. package/dist/media-url-C6klEuNd.mjs +43 -0
  515. package/dist/media-url-C6klEuNd.mjs.map +1 -0
  516. package/dist/media-usage-D7Y64m6v.mjs +1629 -0
  517. package/dist/media-usage-D7Y64m6v.mjs.map +1 -0
  518. package/dist/media-usage-activation-DrqbmgLA.mjs +78 -0
  519. package/dist/media-usage-activation-DrqbmgLA.mjs.map +1 -0
  520. package/dist/media-usage-work-DommYhYA.mjs +152 -0
  521. package/dist/media-usage-work-DommYhYA.mjs.map +1 -0
  522. package/dist/media-usage-work-HU63hNDu.mjs +586 -0
  523. package/dist/media-usage-work-HU63hNDu.mjs.map +1 -0
  524. package/dist/menus-BQfusWEC.mjs +3608 -0
  525. package/dist/menus-BQfusWEC.mjs.map +1 -0
  526. package/dist/menus-BtwjQt5s.mjs +753 -0
  527. package/dist/menus-BtwjQt5s.mjs.map +1 -0
  528. package/dist/menus-p_M1V7J_.mjs +139 -0
  529. package/dist/menus-p_M1V7J_.mjs.map +1 -0
  530. package/dist/migrations/index.d.mts +1 -1
  531. package/dist/migrations/index.mjs +3 -3
  532. package/dist/mime-C94qBG-P.mjs +36 -0
  533. package/dist/mime-C94qBG-P.mjs.map +1 -0
  534. package/dist/mode-DpYW3w6U.mjs +23 -0
  535. package/dist/mode-DpYW3w6U.mjs.map +1 -0
  536. package/dist/node-sqlite-compat-pWFw0lcc.mjs +46 -0
  537. package/dist/node-sqlite-compat-pWFw0lcc.mjs.map +1 -0
  538. package/dist/normalize-DduyxBjf.mjs +191 -0
  539. package/dist/normalize-DduyxBjf.mjs.map +1 -0
  540. package/dist/oauth-authorization-DAXsH1H9.mjs +274 -0
  541. package/dist/oauth-authorization-DAXsH1H9.mjs.map +1 -0
  542. package/dist/oauth-clients-DENiDQri.mjs +266 -0
  543. package/dist/oauth-clients-DENiDQri.mjs.map +1 -0
  544. package/dist/oauth-state-store-y8mEYVq9.mjs +50 -0
  545. package/dist/oauth-state-store-y8mEYVq9.mjs.map +1 -0
  546. package/dist/oauth-user-lookup-CtTYAy-O.mjs +26 -0
  547. package/dist/oauth-user-lookup-CtTYAy-O.mjs.map +1 -0
  548. package/dist/object-cache/memory.d.mts +1 -1
  549. package/dist/options-BYa1FgIM.d.mts +81 -0
  550. package/dist/options-BYa1FgIM.d.mts.map +1 -0
  551. package/dist/page/index.d.mts +2 -2
  552. package/dist/page/index.mjs +5 -5
  553. package/dist/parse-CORGGhHf.mjs +81 -0
  554. package/dist/parse-CORGGhHf.mjs.map +1 -0
  555. package/dist/parse-avNM1xWV.d.mts +168 -0
  556. package/dist/parse-avNM1xWV.d.mts.map +1 -0
  557. package/dist/passkey-config-Dih5YeIS.mjs +46 -0
  558. package/dist/passkey-config-Dih5YeIS.mjs.map +1 -0
  559. package/dist/paths-d51RFm8M.mjs +77 -0
  560. package/dist/paths-d51RFm8M.mjs.map +1 -0
  561. package/dist/patterns-CoqlXUvk.mjs +145 -0
  562. package/dist/patterns-CoqlXUvk.mjs.map +1 -0
  563. package/dist/placeholder-D2aksPMF.d.mts +306 -0
  564. package/dist/placeholder-D2aksPMF.d.mts.map +1 -0
  565. package/dist/plan-DqeZKuaR.mjs +135 -0
  566. package/dist/plan-DqeZKuaR.mjs.map +1 -0
  567. package/dist/plugin-test-runtime.d.mts +14 -14
  568. package/dist/plugin-test-runtime.mjs +110 -107
  569. package/dist/plugin-types.d.mts +2 -2
  570. package/dist/plugin-utils.d.mts +12 -12
  571. package/dist/plugins/adapt-sandbox-entry.d.mts +12 -12
  572. package/dist/plugins/adapt-sandbox-entry.mjs +3 -3
  573. package/dist/plugins/host.d.mts +5 -5
  574. package/dist/plugins/host.mjs +42 -41
  575. package/dist/plugins-Bb7oqjQA.mjs +277 -0
  576. package/dist/plugins-Bb7oqjQA.mjs.map +1 -0
  577. package/dist/policy-BcEqut3n.mjs +45 -0
  578. package/dist/policy-BcEqut3n.mjs.map +1 -0
  579. package/dist/portable-text-DXE8ymtD.mjs +307 -0
  580. package/dist/portable-text-DXE8ymtD.mjs.map +1 -0
  581. package/dist/preview-DEDWbwA_.mjs +107 -0
  582. package/dist/preview-DEDWbwA_.mjs.map +1 -0
  583. package/dist/protocol-BJbTzvwl.d.mts +61 -0
  584. package/dist/protocol-BJbTzvwl.d.mts.map +1 -0
  585. package/dist/public-submission-D9c9S14m.mjs +250 -0
  586. package/dist/public-submission-D9c9S14m.mjs.map +1 -0
  587. package/dist/public-url-CIRe-2T6.mjs +101 -0
  588. package/dist/public-url-CIRe-2T6.mjs.map +1 -0
  589. package/dist/query-BzifXlPS.mjs +1156 -0
  590. package/dist/query-BzifXlPS.mjs.map +1 -0
  591. package/dist/query-OzMJ6vJP.mjs +41 -0
  592. package/dist/query-OzMJ6vJP.mjs.map +1 -0
  593. package/dist/rate-limit-Csp60Vik.mjs +120 -0
  594. package/dist/rate-limit-Csp60Vik.mjs.map +1 -0
  595. package/dist/receipt-B-aU4hpJ.mjs +43 -0
  596. package/dist/receipt-B-aU4hpJ.mjs.map +1 -0
  597. package/dist/redirect-CDSw1sU3.mjs +17 -0
  598. package/dist/redirect-CDSw1sU3.mjs.map +1 -0
  599. package/dist/redirect-D1ArbO85.mjs +411 -0
  600. package/dist/redirect-D1ArbO85.mjs.map +1 -0
  601. package/dist/redirects-BjTwDTsV.mjs +148 -0
  602. package/dist/redirects-BjTwDTsV.mjs.map +1 -0
  603. package/dist/redirects-Ck50kH3n.mjs +446 -0
  604. package/dist/redirects-Ck50kH3n.mjs.map +1 -0
  605. package/dist/registry/testing.mjs +3 -3
  606. package/dist/registry-CFcNCayZ.mjs +6754 -0
  607. package/dist/registry-CFcNCayZ.mjs.map +1 -0
  608. package/dist/relations-Cfaa1fDl.mjs +776 -0
  609. package/dist/relations-Cfaa1fDl.mjs.map +1 -0
  610. package/dist/request-cache-iHRlHx1d.mjs +104 -0
  611. package/dist/request-cache-iHRlHx1d.mjs.map +1 -0
  612. package/dist/request-context.d.mts +1 -1
  613. package/dist/request-meta-D47mqyev.mjs +141 -0
  614. package/dist/request-meta-D47mqyev.mjs.map +1 -0
  615. package/dist/resolve-BPE8sMvx.mjs +99 -0
  616. package/dist/resolve-BPE8sMvx.mjs.map +1 -0
  617. package/dist/resolve-C0s1E_fH.mjs +199 -0
  618. package/dist/resolve-C0s1E_fH.mjs.map +1 -0
  619. package/dist/revision-j1p4-bOj.mjs +302 -0
  620. package/dist/revision-j1p4-bOj.mjs.map +1 -0
  621. package/dist/route-wire-C9PJV9aL.mjs +197 -0
  622. package/dist/route-wire-C9PJV9aL.mjs.map +1 -0
  623. package/dist/routes-lyYw0mMf.mjs +272 -0
  624. package/dist/routes-lyYw0mMf.mjs.map +1 -0
  625. package/dist/runner-B3eyB9Gb.mjs +6121 -0
  626. package/dist/runner-B3eyB9Gb.mjs.map +1 -0
  627. package/dist/runner-DoYH2Jcu.d.mts +68 -0
  628. package/dist/runner-DoYH2Jcu.d.mts.map +1 -0
  629. package/dist/runtime.d.mts +13 -13
  630. package/dist/runtime.mjs +3 -3
  631. package/dist/schema-BAayK46S.mjs +13 -0
  632. package/dist/schema-BAayK46S.mjs.map +1 -0
  633. package/dist/schema-Gqcl-8G4.mjs +815 -0
  634. package/dist/schema-Gqcl-8G4.mjs.map +1 -0
  635. package/dist/scopes-BqPOKoKf.mjs +34 -0
  636. package/dist/scopes-BqPOKoKf.mjs.map +1 -0
  637. package/dist/search-YJKPIEV6.mjs +448 -0
  638. package/dist/search-YJKPIEV6.mjs.map +1 -0
  639. package/dist/sections-BR_e-wK5.mjs +346 -0
  640. package/dist/sections-BR_e-wK5.mjs.map +1 -0
  641. package/dist/seed/index.d.mts +2 -2
  642. package/dist/seed/index.mjs +37 -31
  643. package/dist/seo/index.d.mts +3 -3
  644. package/dist/seo/index.mjs +22 -21
  645. package/dist/seo/index.mjs.map +1 -1
  646. package/dist/seo-Dsj8hy3j.mjs +114 -0
  647. package/dist/seo-Dsj8hy3j.mjs.map +1 -0
  648. package/dist/seo-XvH4LNNp.mjs +133 -0
  649. package/dist/seo-XvH4LNNp.mjs.map +1 -0
  650. package/dist/service-BsVG05gS.mjs +150 -0
  651. package/dist/service-BsVG05gS.mjs.map +1 -0
  652. package/dist/session-user-DgKbYrlj.mjs +51 -0
  653. package/dist/session-user-DgKbYrlj.mjs.map +1 -0
  654. package/dist/settings-CNPUntkh.mjs +51 -0
  655. package/dist/settings-CNPUntkh.mjs.map +1 -0
  656. package/dist/settings-D5EHi0Tk.mjs +439 -0
  657. package/dist/settings-D5EHi0Tk.mjs.map +1 -0
  658. package/dist/settings-DSfE7wOa.mjs +61 -0
  659. package/dist/settings-DSfE7wOa.mjs.map +1 -0
  660. package/dist/setup-complete-B8W8sJ9v.mjs +26 -0
  661. package/dist/setup-complete-B8W8sJ9v.mjs.map +1 -0
  662. package/dist/setup-nonce-DnSBP260.mjs +25 -0
  663. package/dist/setup-nonce-DnSBP260.mjs.map +1 -0
  664. package/dist/site-settings-NGzdrt7O.mjs +50 -0
  665. package/dist/site-settings-NGzdrt7O.mjs.map +1 -0
  666. package/dist/site-url-D6JB7tLW.mjs +16 -0
  667. package/dist/site-url-D6JB7tLW.mjs.map +1 -0
  668. package/dist/snapshot-CdcwwWAf.mjs +414 -0
  669. package/dist/snapshot-CdcwwWAf.mjs.map +1 -0
  670. package/dist/ssrf-Dv0_tRpo.mjs +406 -0
  671. package/dist/ssrf-Dv0_tRpo.mjs.map +1 -0
  672. package/dist/stage-CUjhED3P.mjs +662 -0
  673. package/dist/stage-CUjhED3P.mjs.map +1 -0
  674. package/dist/staged-C36IWXff.mjs +659 -0
  675. package/dist/staged-C36IWXff.mjs.map +1 -0
  676. package/dist/state-CKouMCSY.mjs +153 -0
  677. package/dist/state-CKouMCSY.mjs.map +1 -0
  678. package/dist/status-lzyj4Uu7.mjs +30 -0
  679. package/dist/status-lzyj4Uu7.mjs.map +1 -0
  680. package/dist/storage/local.d.mts +1 -1
  681. package/dist/storage/local.mjs +1 -1
  682. package/dist/storage/s3.d.mts +1 -1
  683. package/dist/storage/s3.mjs +1 -1
  684. package/dist/storage-query-B-cWcTjJ.d.mts +1594 -0
  685. package/dist/storage-query-B-cWcTjJ.d.mts.map +1 -0
  686. package/dist/tar-DsTXX6ch.mjs +449 -0
  687. package/dist/tar-DsTXX6ch.mjs.map +1 -0
  688. package/dist/target-DLQCwp_Z.mjs +27 -0
  689. package/dist/target-DLQCwp_Z.mjs.map +1 -0
  690. package/dist/taxonomies-BlAjr4BL.mjs +697 -0
  691. package/dist/taxonomies-BlAjr4BL.mjs.map +1 -0
  692. package/dist/taxonomies-Byyo7LOZ.mjs +939 -0
  693. package/dist/taxonomies-Byyo7LOZ.mjs.map +1 -0
  694. package/dist/taxonomy-CKDwM61Y.mjs +525 -0
  695. package/dist/taxonomy-CKDwM61Y.mjs.map +1 -0
  696. package/dist/tokens-BojXlk49.mjs +171 -0
  697. package/dist/tokens-BojXlk49.mjs.map +1 -0
  698. package/dist/transaction-DLPQWik1.mjs +29 -0
  699. package/dist/transaction-DLPQWik1.mjs.map +1 -0
  700. package/dist/transfer-XSTh2BCr.mjs +8706 -0
  701. package/dist/transfer-XSTh2BCr.mjs.map +1 -0
  702. package/dist/transfer-download-DkoCDA9d.mjs +33 -0
  703. package/dist/transfer-download-DkoCDA9d.mjs.map +1 -0
  704. package/dist/transfer-iQ26J-RT.mjs +166 -0
  705. package/dist/transfer-iQ26J-RT.mjs.map +1 -0
  706. package/dist/transformations-C7RQabKQ.mjs +196 -0
  707. package/dist/transformations-C7RQabKQ.mjs.map +1 -0
  708. package/dist/transport-D3RulfD6.mjs +136 -0
  709. package/dist/transport-D3RulfD6.mjs.map +1 -0
  710. package/dist/transport-DhlZlf4D.d.mts +42 -0
  711. package/dist/transport-DhlZlf4D.d.mts.map +1 -0
  712. package/dist/trusted-proxy-B6ECOZJc.mjs +51 -0
  713. package/dist/trusted-proxy-B6ECOZJc.mjs.map +1 -0
  714. package/dist/turnstile-lqUiY7lP.mjs +53 -0
  715. package/dist/turnstile-lqUiY7lP.mjs.map +1 -0
  716. package/dist/types-4Dn9bZhu.mjs +77 -0
  717. package/dist/types-4Dn9bZhu.mjs.map +1 -0
  718. package/dist/types-5LSo7PPx.d.mts +85 -0
  719. package/dist/types-5LSo7PPx.d.mts.map +1 -0
  720. package/dist/types-BQ3hwYJT.d.mts +896 -0
  721. package/dist/types-BQ3hwYJT.d.mts.map +1 -0
  722. package/dist/types-BYEk7qo3.d.mts +198 -0
  723. package/dist/types-BYEk7qo3.d.mts.map +1 -0
  724. package/dist/types-CJKsWVFR.mjs +199 -0
  725. package/dist/types-CJKsWVFR.mjs.map +1 -0
  726. package/dist/types-Ca_w8mmY.d.mts +363 -0
  727. package/dist/types-Ca_w8mmY.d.mts.map +1 -0
  728. package/dist/types-CkE41ZAG.mjs +18 -0
  729. package/dist/types-CkE41ZAG.mjs.map +1 -0
  730. package/dist/types-D0aJW2uR.d.mts +1641 -0
  731. package/dist/types-D0aJW2uR.d.mts.map +1 -0
  732. package/dist/types-DbpN4Qto.d.mts +372 -0
  733. package/dist/types-DbpN4Qto.d.mts.map +1 -0
  734. package/dist/types-ILDI1sdY.mjs +16 -0
  735. package/dist/types-ILDI1sdY.mjs.map +1 -0
  736. package/dist/types-OC5c-edM.mjs +22 -0
  737. package/dist/types-OC5c-edM.mjs.map +1 -0
  738. package/dist/types-aOOxRSx6.mjs +103 -0
  739. package/dist/types-aOOxRSx6.mjs.map +1 -0
  740. package/dist/types-m1WbUffD.d.mts +198 -0
  741. package/dist/types-m1WbUffD.d.mts.map +1 -0
  742. package/dist/types-uxLoPBio.d.mts +124 -0
  743. package/dist/types-uxLoPBio.d.mts.map +1 -0
  744. package/dist/types-we5uR-tV.d.mts +287 -0
  745. package/dist/types-we5uR-tV.d.mts.map +1 -0
  746. package/dist/upload-attempts-DduMy6B0.mjs +32 -0
  747. package/dist/upload-attempts-DduMy6B0.mjs.map +1 -0
  748. package/dist/url-pattern-B3EwxAAk.mjs +33 -0
  749. package/dist/url-pattern-B3EwxAAk.mjs.map +1 -0
  750. package/dist/user-ElwQjTQT.mjs +171 -0
  751. package/dist/user-ElwQjTQT.mjs.map +1 -0
  752. package/dist/utils-BlAXmfOG.mjs +439 -0
  753. package/dist/utils-BlAXmfOG.mjs.map +1 -0
  754. package/dist/validate-CH0X5b2c.d.mts +468 -0
  755. package/dist/validate-CH0X5b2c.d.mts.map +1 -0
  756. package/dist/validate-CfgRpcjA.mjs +492 -0
  757. package/dist/validate-CfgRpcjA.mjs.map +1 -0
  758. package/dist/validation-DvYJtv4k.mjs +218 -0
  759. package/dist/validation-DvYJtv4k.mjs.map +1 -0
  760. package/dist/version-DgYjhTud.mjs +9 -0
  761. package/dist/version-DgYjhTud.mjs.map +1 -0
  762. package/dist/version-Dq71scUb.mjs +7 -0
  763. package/dist/version-Dq71scUb.mjs.map +1 -0
  764. package/dist/widgets-ChFIj0be.mjs +126 -0
  765. package/dist/widgets-ChFIj0be.mjs.map +1 -0
  766. package/dist/wxr-taxonomies-CBZMp2YX.mjs +372 -0
  767. package/dist/wxr-taxonomies-CBZMp2YX.mjs.map +1 -0
  768. package/dist/wxr-taxonomies-DlKDpWN1.d.mts +34 -0
  769. package/dist/wxr-taxonomies-DlKDpWN1.d.mts.map +1 -0
  770. package/dist/zod-generator-DmTKI-Ig.mjs +426 -0
  771. package/dist/zod-generator-DmTKI-Ig.mjs.map +1 -0
  772. package/package.json +7 -6
  773. package/src/api/handlers/content.ts +593 -16
  774. package/src/api/handlers/device-flow.ts +74 -21
  775. package/src/api/handlers/index.ts +1 -0
  776. package/src/api/handlers/manifest.ts +79 -5
  777. package/src/api/handlers/media-upload.ts +17 -71
  778. package/src/api/handlers/media.ts +97 -3
  779. package/src/api/handlers/relations.ts +638 -157
  780. package/src/api/handlers/revision.ts +30 -0
  781. package/src/api/handlers/schema.ts +403 -1
  782. package/src/api/handlers/snapshot.ts +257 -3
  783. package/src/api/handlers/staged-references.ts +142 -0
  784. package/src/api/handlers/validate-references.ts +146 -0
  785. package/src/api/schemas/content.ts +13 -0
  786. package/src/api/schemas/relations.ts +54 -44
  787. package/src/api/schemas/schema.ts +14 -0
  788. package/src/astro/integration/routes.ts +15 -19
  789. package/src/astro/integration/vite-config.ts +10 -4
  790. package/src/astro/middleware.ts +1 -0
  791. package/src/astro/routes/api/content/[collection]/[id]/references/[relation]/children.ts +11 -54
  792. package/src/astro/routes/api/content/[collection]/[id].ts +3 -1
  793. package/src/astro/routes/api/oauth/device/authorize.ts +33 -4
  794. package/src/astro/routes/api/relations/index.ts +4 -4
  795. package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +6 -2
  796. package/src/astro/routes/api/setup/index.ts +66 -23
  797. package/src/astro/routes/api/snapshot.ts +2 -1
  798. package/src/astro/types.ts +10 -0
  799. package/src/cleanup.ts +10 -0
  800. package/src/cli/commands/export-seed.ts +510 -89
  801. package/src/components/Columns.astro +3 -1
  802. package/src/components/Cover.astro +3 -1
  803. package/src/components/WidgetArea.astro +3 -2
  804. package/src/database/migrations/086_relations_structural.ts +197 -0
  805. package/src/database/migrations/087_reference_field_relations.ts +407 -0
  806. package/src/database/migrations/runner.ts +4 -0
  807. package/src/database/reference-backfill.ts +141 -0
  808. package/src/database/repositories/content.ts +43 -8
  809. package/src/database/repositories/media.ts +40 -1
  810. package/src/database/repositories/redirect.ts +17 -34
  811. package/src/database/repositories/relation.ts +620 -208
  812. package/src/database/repositories/revision.ts +16 -0
  813. package/src/database/repositories/types.ts +38 -0
  814. package/src/database/transaction.ts +12 -1
  815. package/src/database/types.ts +14 -5
  816. package/src/emdash-runtime.ts +114 -11
  817. package/src/index.ts +11 -0
  818. package/src/loader.ts +169 -22
  819. package/src/mcp/server.ts +13 -48
  820. package/src/query.ts +455 -25
  821. package/src/references/field-map.ts +115 -0
  822. package/src/references/resolve.ts +160 -0
  823. package/src/references/staged.ts +117 -0
  824. package/src/references/types.ts +16 -0
  825. package/src/registry/artifact-fetch.ts +45 -271
  826. package/src/schema/registry.ts +99 -24
  827. package/src/schema/types.ts +58 -0
  828. package/src/schema/zod-generator.ts +67 -1
  829. package/src/seed/apply.ts +841 -103
  830. package/src/seed/types.ts +36 -2
  831. package/src/seed/validate.ts +78 -2
  832. package/src/transfer/analyze/unique-keys.ts +3 -12
  833. package/src/transfer/analyze/validate.ts +65 -39
  834. package/src/transfer/analyze/values.ts +12 -1
  835. package/src/transfer/export/readers.ts +12 -8
  836. package/src/transfer/format/columns.ts +26 -6
  837. package/src/transfer/format/kinds.ts +21 -5
  838. package/src/transfer/import/context.ts +8 -1
  839. package/src/transfer/ops/package-index.ts +1 -1
  840. package/dist/action-token-DYwe4Pk0.mjs +0 -26
  841. package/dist/action-token-DYwe4Pk0.mjs.map +0 -1
  842. package/dist/activation-LOkDM5WT.mjs +0 -382
  843. package/dist/activation-LOkDM5WT.mjs.map +0 -1
  844. package/dist/adapters-B64LbYcB.d.mts +0 -171
  845. package/dist/adapters-B64LbYcB.d.mts.map +0 -1
  846. package/dist/allowed-origins-CHB8oZNM.mjs +0 -116
  847. package/dist/allowed-origins-CHB8oZNM.mjs.map +0 -1
  848. package/dist/api-cFFZpyS0.mjs +0 -4718
  849. package/dist/api-cFFZpyS0.mjs.map +0 -1
  850. package/dist/api-tokens-s4i4aUp_.mjs +0 -166
  851. package/dist/api-tokens-s4i4aUp_.mjs.map +0 -1
  852. package/dist/apply-CoT603H3.mjs +0 -1163
  853. package/dist/apply-CoT603H3.mjs.map +0 -1
  854. package/dist/approvals-CqMfNxak.mjs +0 -460
  855. package/dist/approvals-CqMfNxak.mjs.map +0 -1
  856. package/dist/artifact-fetch-DZMOGZ3-.mjs +0 -818
  857. package/dist/artifact-fetch-DZMOGZ3-.mjs.map +0 -1
  858. package/dist/astro/routes/api/relations/_id_/translations.d.mts +0 -8
  859. package/dist/astro/routes/api/relations/_id_/translations.d.mts.map +0 -1
  860. package/dist/astro/routes/api/relations/_id_/translations.mjs +0 -47
  861. package/dist/astro/routes/api/relations/_id_/translations.mjs.map +0 -1
  862. package/dist/audit-RfCugiSB.mjs +0 -127
  863. package/dist/audit-RfCugiSB.mjs.map +0 -1
  864. package/dist/authoritative-records-CoJvBXAD.mjs +0 -5172
  865. package/dist/authoritative-records-CoJvBXAD.mjs.map +0 -1
  866. package/dist/authorize-seCifOMJ.mjs +0 -49
  867. package/dist/authorize-seCifOMJ.mjs.map +0 -1
  868. package/dist/backup-CBu0LrXf.mjs +0 -246
  869. package/dist/backup-CBu0LrXf.mjs.map +0 -1
  870. package/dist/block-type-registry-DUI_3KxT.mjs +0 -6709
  871. package/dist/block-type-registry-DUI_3KxT.mjs.map +0 -1
  872. package/dist/block-types-BmZmLmAD.mjs +0 -132
  873. package/dist/block-types-BmZmLmAD.mjs.map +0 -1
  874. package/dist/block-values-C_VIPr5t.mjs +0 -175
  875. package/dist/block-values-C_VIPr5t.mjs.map +0 -1
  876. package/dist/byline-DYmkXqvo.mjs +0 -909
  877. package/dist/byline-DYmkXqvo.mjs.map +0 -1
  878. package/dist/byline-fields-D28AT-Fh.mjs +0 -123
  879. package/dist/byline-fields-D28AT-Fh.mjs.map +0 -1
  880. package/dist/byline-registry-gnKscbQX.mjs +0 -406
  881. package/dist/byline-registry-gnKscbQX.mjs.map +0 -1
  882. package/dist/bylines-BPwJqoYH.mjs +0 -232
  883. package/dist/bylines-BPwJqoYH.mjs.map +0 -1
  884. package/dist/bylines-ukLaYpVZ.mjs +0 -214
  885. package/dist/bylines-ukLaYpVZ.mjs.map +0 -1
  886. package/dist/cache-m7UEkRFV.mjs +0 -108
  887. package/dist/cache-m7UEkRFV.mjs.map +0 -1
  888. package/dist/canonical-YhEQezjg.mjs +0 -174
  889. package/dist/canonical-YhEQezjg.mjs.map +0 -1
  890. package/dist/capture-triggers-kJyl_yyM.mjs +0 -362
  891. package/dist/capture-triggers-kJyl_yyM.mjs.map +0 -1
  892. package/dist/challenge-store-ppU6Uv13.mjs +0 -51
  893. package/dist/challenge-store-ppU6Uv13.mjs.map +0 -1
  894. package/dist/checksum-B2IINIlN.mjs +0 -162
  895. package/dist/checksum-B2IINIlN.mjs.map +0 -1
  896. package/dist/chrome-tags-DApCQSIk.mjs +0 -24
  897. package/dist/chrome-tags-DApCQSIk.mjs.map +0 -1
  898. package/dist/chunks-Dms7Uxbt.mjs +0 -25
  899. package/dist/chunks-Dms7Uxbt.mjs.map +0 -1
  900. package/dist/collection-deletion-BIm28mo3.mjs +0 -436
  901. package/dist/collection-deletion-BIm28mo3.mjs.map +0 -1
  902. package/dist/collection-deletion-processor-Br6rxs3u.mjs +0 -217
  903. package/dist/collection-deletion-processor-Br6rxs3u.mjs.map +0 -1
  904. package/dist/collection-slugs-cache-CjGk__zp.mjs +0 -85
  905. package/dist/collection-slugs-cache-CjGk__zp.mjs.map +0 -1
  906. package/dist/comment-CrBl22OF.mjs +0 -313
  907. package/dist/comment-CrBl22OF.mjs.map +0 -1
  908. package/dist/comment-reaction-JEQ2Fpd8.mjs +0 -85
  909. package/dist/comment-reaction-JEQ2Fpd8.mjs.map +0 -1
  910. package/dist/comments-2ah9du9y.mjs +0 -195
  911. package/dist/comments-2ah9du9y.mjs.map +0 -1
  912. package/dist/comments-fHZ8ON9O.mjs +0 -99
  913. package/dist/comments-fHZ8ON9O.mjs.map +0 -1
  914. package/dist/components-CXbq7CSM.mjs +0 -108
  915. package/dist/components-CXbq7CSM.mjs.map +0 -1
  916. package/dist/config-5ii2haYu.d.mts +0 -6528
  917. package/dist/config-5ii2haYu.d.mts.map +0 -1
  918. package/dist/config-IhybvkIQ.mjs +0 -242
  919. package/dist/config-IhybvkIQ.mjs.map +0 -1
  920. package/dist/config-Py43JK9r.d.mts +0 -39
  921. package/dist/config-Py43JK9r.d.mts.map +0 -1
  922. package/dist/content-DFaIEDj9.mjs +0 -2281
  923. package/dist/content-DFaIEDj9.mjs.map +0 -1
  924. package/dist/content-list-query-Dra4Dalc.d.mts +0 -26
  925. package/dist/content-list-query-Dra4Dalc.d.mts.map +0 -1
  926. package/dist/content-policy-DFNw91-d.mjs +0 -46
  927. package/dist/content-policy-DFNw91-d.mjs.map +0 -1
  928. package/dist/content-repair-Q8IUrpLL.mjs +0 -442
  929. package/dist/content-repair-Q8IUrpLL.mjs.map +0 -1
  930. package/dist/context-BeGccdUX.mjs +0 -1921
  931. package/dist/context-BeGccdUX.mjs.map +0 -1
  932. package/dist/cron-7DCJwPXq.mjs +0 -284
  933. package/dist/cron-7DCJwPXq.mjs.map +0 -1
  934. package/dist/dashboard-DjrB-xxZ.mjs +0 -151
  935. package/dist/dashboard-DjrB-xxZ.mjs.map +0 -1
  936. package/dist/default-DQ6vsviu.mjs +0 -81
  937. package/dist/default-DQ6vsviu.mjs.map +0 -1
  938. package/dist/deferred-tasks-BPxXUB4x.d.mts +0 -9
  939. package/dist/deferred-tasks-BPxXUB4x.d.mts.map +0 -1
  940. package/dist/dev-typegen-CZaPLl3V.mjs +0 -29
  941. package/dist/dev-typegen-CZaPLl3V.mjs.map +0 -1
  942. package/dist/device-flow-CRd6DXmW.mjs +0 -466
  943. package/dist/device-flow-CRd6DXmW.mjs.map +0 -1
  944. package/dist/digest-BarSh-pN.mjs +0 -194
  945. package/dist/digest-BarSh-pN.mjs.map +0 -1
  946. package/dist/direct-executor-BmuFJJZV.mjs +0 -104
  947. package/dist/direct-executor-BmuFJJZV.mjs.map +0 -1
  948. package/dist/dist-BNwANFJR.mjs +0 -810
  949. package/dist/dist-BNwANFJR.mjs.map +0 -1
  950. package/dist/email-console-bJn3ctqA.mjs +0 -50
  951. package/dist/email-console-bJn3ctqA.mjs.map +0 -1
  952. package/dist/email-locale-CN6WAMx0.mjs +0 -25
  953. package/dist/email-locale-CN6WAMx0.mjs.map +0 -1
  954. package/dist/emdash-runtime-DAjghyEG.mjs +0 -4186
  955. package/dist/emdash-runtime-DAjghyEG.mjs.map +0 -1
  956. package/dist/enrich-Dl3kZ-lP.mjs +0 -194
  957. package/dist/enrich-Dl3kZ-lP.mjs.map +0 -1
  958. package/dist/entry-lock-BJYdBfXb.mjs +0 -1097
  959. package/dist/entry-lock-BJYdBfXb.mjs.map +0 -1
  960. package/dist/entry-lock-DHQOxN7R.mjs +0 -163
  961. package/dist/entry-lock-DHQOxN7R.mjs.map +0 -1
  962. package/dist/entry-lock-DVhCt49A.d.mts +0 -4368
  963. package/dist/entry-lock-DVhCt49A.d.mts.map +0 -1
  964. package/dist/entry-locks-D0foLdjQ.mjs +0 -167
  965. package/dist/entry-locks-D0foLdjQ.mjs.map +0 -1
  966. package/dist/error-CfvOHP0M.mjs +0 -90
  967. package/dist/error-CfvOHP0M.mjs.map +0 -1
  968. package/dist/errors-BF0_LFhW.mjs +0 -460
  969. package/dist/errors-BF0_LFhW.mjs.map +0 -1
  970. package/dist/errors-DgE1zJGG.mjs +0 -120
  971. package/dist/errors-DgE1zJGG.mjs.map +0 -1
  972. package/dist/escape-CuaZhZvL.mjs +0 -9
  973. package/dist/escape-CuaZhZvL.mjs.map +0 -1
  974. package/dist/fence-CMDXJYc_.mjs +0 -162
  975. package/dist/fence-CMDXJYc_.mjs.map +0 -1
  976. package/dist/field-defs-cache-HIgBbqZZ.mjs +0 -77
  977. package/dist/field-defs-cache-HIgBbqZZ.mjs.map +0 -1
  978. package/dist/focal-point-Gr34o-4o.mjs +0 -23
  979. package/dist/focal-point-Gr34o-4o.mjs.map +0 -1
  980. package/dist/fts-manager-S-K0laoS.mjs +0 -443
  981. package/dist/fts-manager-S-K0laoS.mjs.map +0 -1
  982. package/dist/gc-DjKY0Ay1.mjs +0 -75
  983. package/dist/gc-DjKY0Ay1.mjs.map +0 -1
  984. package/dist/hash-SDAW6zC-.mjs +0 -37
  985. package/dist/hash-SDAW6zC-.mjs.map +0 -1
  986. package/dist/hook-result-B5bXDgS2.d.mts +0 -31
  987. package/dist/hook-result-B5bXDgS2.d.mts.map +0 -1
  988. package/dist/hreflang-D5uNnsGJ.d.mts +0 -50
  989. package/dist/hreflang-D5uNnsGJ.d.mts.map +0 -1
  990. package/dist/hreflang-DMFBL2eb.mjs +0 -105
  991. package/dist/hreflang-DMFBL2eb.mjs.map +0 -1
  992. package/dist/http-route-dispatch-BitqzwMy.mjs +0 -339
  993. package/dist/http-route-dispatch-BitqzwMy.mjs.map +0 -1
  994. package/dist/identity-IyNWwXr6.mjs +0 -35
  995. package/dist/identity-IyNWwXr6.mjs.map +0 -1
  996. package/dist/import-C3JZplWq.mjs +0 -2020
  997. package/dist/import-C3JZplWq.mjs.map +0 -1
  998. package/dist/index-D-hdtLe8.d.mts +0 -623
  999. package/dist/index-D-hdtLe8.d.mts.map +0 -1
  1000. package/dist/install-finalization-DfM1fj5x.mjs +0 -58
  1001. package/dist/install-finalization-DfM1fj5x.mjs.map +0 -1
  1002. package/dist/keys-yxLm5l35.mjs +0 -61
  1003. package/dist/keys-yxLm5l35.mjs.map +0 -1
  1004. package/dist/kinds-CRu_T5T5.mjs +0 -961
  1005. package/dist/kinds-CRu_T5T5.mjs.map +0 -1
  1006. package/dist/lifecycle-BzeGPeQ-.mjs +0 -25
  1007. package/dist/lifecycle-BzeGPeQ-.mjs.map +0 -1
  1008. package/dist/load-XgJiE6_3.mjs +0 -28
  1009. package/dist/load-XgJiE6_3.mjs.map +0 -1
  1010. package/dist/loader-BzqeR1ZN.mjs +0 -1086
  1011. package/dist/loader-BzqeR1ZN.mjs.map +0 -1
  1012. package/dist/loops-BQSzv5Zn.mjs +0 -203
  1013. package/dist/loops-BQSzv5Zn.mjs.map +0 -1
  1014. package/dist/manifest-builder-B8zR-73J.mjs +0 -189
  1015. package/dist/manifest-builder-B8zR-73J.mjs.map +0 -1
  1016. package/dist/manifest-schema-CY3zng_M.mjs +0 -492
  1017. package/dist/manifest-schema-CY3zng_M.mjs.map +0 -1
  1018. package/dist/media-Pu1L6xir.mjs +0 -408
  1019. package/dist/media-Pu1L6xir.mjs.map +0 -1
  1020. package/dist/media-Qp5S3eH3.mjs +0 -355
  1021. package/dist/media-Qp5S3eH3.mjs.map +0 -1
  1022. package/dist/media-allowlist-BSoa9Vvm.mjs +0 -44
  1023. package/dist/media-allowlist-BSoa9Vvm.mjs.map +0 -1
  1024. package/dist/media-folders-BE0oo2eX.mjs +0 -210
  1025. package/dist/media-folders-BE0oo2eX.mjs.map +0 -1
  1026. package/dist/media-h7tOiDLj.mjs +0 -221
  1027. package/dist/media-h7tOiDLj.mjs.map +0 -1
  1028. package/dist/media-url-jArBpzIG.mjs +0 -43
  1029. package/dist/media-url-jArBpzIG.mjs.map +0 -1
  1030. package/dist/media-usage-My-Vi-ex.mjs +0 -1629
  1031. package/dist/media-usage-My-Vi-ex.mjs.map +0 -1
  1032. package/dist/media-usage-activation-HKp7zk7W.mjs +0 -78
  1033. package/dist/media-usage-activation-HKp7zk7W.mjs.map +0 -1
  1034. package/dist/media-usage-work-C2OZLCAd.mjs +0 -586
  1035. package/dist/media-usage-work-C2OZLCAd.mjs.map +0 -1
  1036. package/dist/media-usage-work-DwUNbgvS.mjs +0 -152
  1037. package/dist/media-usage-work-DwUNbgvS.mjs.map +0 -1
  1038. package/dist/menus-BM7BPLOb.mjs +0 -139
  1039. package/dist/menus-BM7BPLOb.mjs.map +0 -1
  1040. package/dist/menus-ITeAbcIF.mjs +0 -753
  1041. package/dist/menus-ITeAbcIF.mjs.map +0 -1
  1042. package/dist/menus-TsSGmSR4.mjs +0 -3608
  1043. package/dist/menus-TsSGmSR4.mjs.map +0 -1
  1044. package/dist/mime-ChLqYwDk.mjs +0 -36
  1045. package/dist/mime-ChLqYwDk.mjs.map +0 -1
  1046. package/dist/mode-CCuKXUci.mjs +0 -23
  1047. package/dist/mode-CCuKXUci.mjs.map +0 -1
  1048. package/dist/node-sqlite-compat-CONMsl-x.mjs +0 -46
  1049. package/dist/node-sqlite-compat-CONMsl-x.mjs.map +0 -1
  1050. package/dist/normalize-CO2P8-iE.mjs +0 -191
  1051. package/dist/normalize-CO2P8-iE.mjs.map +0 -1
  1052. package/dist/oauth-authorization-DlMIL5_h.mjs +0 -274
  1053. package/dist/oauth-authorization-DlMIL5_h.mjs.map +0 -1
  1054. package/dist/oauth-clients-Djq9r_KP.mjs +0 -266
  1055. package/dist/oauth-clients-Djq9r_KP.mjs.map +0 -1
  1056. package/dist/oauth-state-store-BbjnZXNC.mjs +0 -50
  1057. package/dist/oauth-state-store-BbjnZXNC.mjs.map +0 -1
  1058. package/dist/oauth-user-lookup-vue9a64A.mjs +0 -26
  1059. package/dist/oauth-user-lookup-vue9a64A.mjs.map +0 -1
  1060. package/dist/options-SQCHQCPH.d.mts +0 -81
  1061. package/dist/options-SQCHQCPH.d.mts.map +0 -1
  1062. package/dist/parse-CVgO-Qai.d.mts +0 -168
  1063. package/dist/parse-CVgO-Qai.d.mts.map +0 -1
  1064. package/dist/parse-DY6OD1j_.mjs +0 -81
  1065. package/dist/parse-DY6OD1j_.mjs.map +0 -1
  1066. package/dist/passkey-config-X_H8128a.mjs +0 -46
  1067. package/dist/passkey-config-X_H8128a.mjs.map +0 -1
  1068. package/dist/paths-JxokKIbr.mjs +0 -77
  1069. package/dist/paths-JxokKIbr.mjs.map +0 -1
  1070. package/dist/patterns-BhAvqO0S.mjs +0 -145
  1071. package/dist/patterns-BhAvqO0S.mjs.map +0 -1
  1072. package/dist/placeholder-MSEd8gty.d.mts +0 -306
  1073. package/dist/placeholder-MSEd8gty.d.mts.map +0 -1
  1074. package/dist/plan-xjcWrAah.mjs +0 -135
  1075. package/dist/plan-xjcWrAah.mjs.map +0 -1
  1076. package/dist/plugins-DUXUt8B9.mjs +0 -277
  1077. package/dist/plugins-DUXUt8B9.mjs.map +0 -1
  1078. package/dist/policy-CUvwAARc.mjs +0 -45
  1079. package/dist/policy-CUvwAARc.mjs.map +0 -1
  1080. package/dist/portable-text-5O_ZGUjB.mjs +0 -307
  1081. package/dist/portable-text-5O_ZGUjB.mjs.map +0 -1
  1082. package/dist/preview-CIUcPYr6.mjs +0 -107
  1083. package/dist/preview-CIUcPYr6.mjs.map +0 -1
  1084. package/dist/protocol-B97DZaFr.d.mts +0 -61
  1085. package/dist/protocol-B97DZaFr.d.mts.map +0 -1
  1086. package/dist/public-submission-BFBUrqst.mjs +0 -250
  1087. package/dist/public-submission-BFBUrqst.mjs.map +0 -1
  1088. package/dist/public-url-Bn7U0D7-.mjs +0 -101
  1089. package/dist/public-url-Bn7U0D7-.mjs.map +0 -1
  1090. package/dist/query-B48peoRT.mjs +0 -890
  1091. package/dist/query-B48peoRT.mjs.map +0 -1
  1092. package/dist/query-C4IH0uhR.mjs +0 -41
  1093. package/dist/query-C4IH0uhR.mjs.map +0 -1
  1094. package/dist/rate-limit-BZ6nybgc.mjs +0 -120
  1095. package/dist/rate-limit-BZ6nybgc.mjs.map +0 -1
  1096. package/dist/receipt-B4wJj5Jq.mjs +0 -43
  1097. package/dist/receipt-B4wJj5Jq.mjs.map +0 -1
  1098. package/dist/redirect-Cd1E7VUt.mjs +0 -17
  1099. package/dist/redirect-Cd1E7VUt.mjs.map +0 -1
  1100. package/dist/redirect-iJf5fltD.mjs +0 -415
  1101. package/dist/redirect-iJf5fltD.mjs.map +0 -1
  1102. package/dist/redirects-CYu1u1aK.mjs +0 -446
  1103. package/dist/redirects-CYu1u1aK.mjs.map +0 -1
  1104. package/dist/redirects-Cv9apQKj.mjs +0 -148
  1105. package/dist/redirects-Cv9apQKj.mjs.map +0 -1
  1106. package/dist/relation-M4NUCb0b.mjs +0 -334
  1107. package/dist/relation-M4NUCb0b.mjs.map +0 -1
  1108. package/dist/relations-CCif47Oq.mjs +0 -403
  1109. package/dist/relations-CCif47Oq.mjs.map +0 -1
  1110. package/dist/relations-CK9CYUyr.mjs +0 -310
  1111. package/dist/relations-CK9CYUyr.mjs.map +0 -1
  1112. package/dist/request-cache-DzLYKm_x.mjs +0 -104
  1113. package/dist/request-cache-DzLYKm_x.mjs.map +0 -1
  1114. package/dist/request-meta-sZXt3sRo.mjs +0 -141
  1115. package/dist/request-meta-sZXt3sRo.mjs.map +0 -1
  1116. package/dist/resolve-2WbQsCvT.mjs +0 -199
  1117. package/dist/resolve-2WbQsCvT.mjs.map +0 -1
  1118. package/dist/route-wire--1hLuACz.mjs +0 -197
  1119. package/dist/route-wire--1hLuACz.mjs.map +0 -1
  1120. package/dist/routes-CUsM40Cc.mjs +0 -272
  1121. package/dist/routes-CUsM40Cc.mjs.map +0 -1
  1122. package/dist/runner-1y4J9fJB.mjs +0 -5742
  1123. package/dist/runner-1y4J9fJB.mjs.map +0 -1
  1124. package/dist/runner-D5_LzKXI.d.mts +0 -68
  1125. package/dist/runner-D5_LzKXI.d.mts.map +0 -1
  1126. package/dist/schema-BABiRdsH.mjs +0 -13
  1127. package/dist/schema-BABiRdsH.mjs.map +0 -1
  1128. package/dist/schema-Du3MzCG0.mjs +0 -446
  1129. package/dist/schema-Du3MzCG0.mjs.map +0 -1
  1130. package/dist/scopes-Dbk-ElhT.mjs +0 -34
  1131. package/dist/scopes-Dbk-ElhT.mjs.map +0 -1
  1132. package/dist/search-Bt1PL1jf.mjs +0 -448
  1133. package/dist/search-Bt1PL1jf.mjs.map +0 -1
  1134. package/dist/sections-Ddptx_o9.mjs +0 -346
  1135. package/dist/sections-Ddptx_o9.mjs.map +0 -1
  1136. package/dist/seo-CZT2oLtT.mjs +0 -114
  1137. package/dist/seo-CZT2oLtT.mjs.map +0 -1
  1138. package/dist/seo-D5w3-Azy.mjs +0 -133
  1139. package/dist/seo-D5w3-Azy.mjs.map +0 -1
  1140. package/dist/service-DuykXPyW.mjs +0 -150
  1141. package/dist/service-DuykXPyW.mjs.map +0 -1
  1142. package/dist/session-user-BhaVp8w0.mjs +0 -51
  1143. package/dist/session-user-BhaVp8w0.mjs.map +0 -1
  1144. package/dist/settings-2xNYr90o.mjs +0 -51
  1145. package/dist/settings-2xNYr90o.mjs.map +0 -1
  1146. package/dist/settings-CgjRWGW9.mjs +0 -439
  1147. package/dist/settings-CgjRWGW9.mjs.map +0 -1
  1148. package/dist/settings-DYidIB26.mjs +0 -61
  1149. package/dist/settings-DYidIB26.mjs.map +0 -1
  1150. package/dist/setup-complete-bOogcHWG.mjs +0 -26
  1151. package/dist/setup-complete-bOogcHWG.mjs.map +0 -1
  1152. package/dist/setup-nonce-0EGuKM4s.mjs +0 -25
  1153. package/dist/setup-nonce-0EGuKM4s.mjs.map +0 -1
  1154. package/dist/site-settings-DOgRUoFX.mjs +0 -50
  1155. package/dist/site-settings-DOgRUoFX.mjs.map +0 -1
  1156. package/dist/site-url-BU_bbxwj.mjs +0 -16
  1157. package/dist/site-url-BU_bbxwj.mjs.map +0 -1
  1158. package/dist/snapshot-CugwUqKQ.mjs +0 -237
  1159. package/dist/snapshot-CugwUqKQ.mjs.map +0 -1
  1160. package/dist/ssrf-CJUnJymJ.mjs +0 -406
  1161. package/dist/ssrf-CJUnJymJ.mjs.map +0 -1
  1162. package/dist/stage-DgrBz_du.mjs +0 -662
  1163. package/dist/stage-DgrBz_du.mjs.map +0 -1
  1164. package/dist/state-DDiPySSG.mjs +0 -153
  1165. package/dist/state-DDiPySSG.mjs.map +0 -1
  1166. package/dist/status-DZKIG4a9.mjs +0 -30
  1167. package/dist/status-DZKIG4a9.mjs.map +0 -1
  1168. package/dist/storage-query-Bdv7A62k.d.mts +0 -1576
  1169. package/dist/storage-query-Bdv7A62k.d.mts.map +0 -1
  1170. package/dist/tar-_1AgTYFu.mjs +0 -449
  1171. package/dist/tar-_1AgTYFu.mjs.map +0 -1
  1172. package/dist/target-_7pn2Gbg.mjs +0 -27
  1173. package/dist/target-_7pn2Gbg.mjs.map +0 -1
  1174. package/dist/taxonomies-C1IwNe8Q.mjs +0 -697
  1175. package/dist/taxonomies-C1IwNe8Q.mjs.map +0 -1
  1176. package/dist/taxonomies-C_XMoRcX.mjs +0 -939
  1177. package/dist/taxonomies-C_XMoRcX.mjs.map +0 -1
  1178. package/dist/taxonomy-C3Fu1YeH.mjs +0 -525
  1179. package/dist/taxonomy-C3Fu1YeH.mjs.map +0 -1
  1180. package/dist/tokens-u78jETkX.mjs +0 -171
  1181. package/dist/tokens-u78jETkX.mjs.map +0 -1
  1182. package/dist/transaction-BcJO4Tmc.mjs +0 -29
  1183. package/dist/transaction-BcJO4Tmc.mjs.map +0 -1
  1184. package/dist/transfer-BhUCrgDc.mjs +0 -8675
  1185. package/dist/transfer-BhUCrgDc.mjs.map +0 -1
  1186. package/dist/transfer-DIGvR9Af.mjs +0 -166
  1187. package/dist/transfer-DIGvR9Af.mjs.map +0 -1
  1188. package/dist/transfer-download-Pml7RMio.mjs +0 -33
  1189. package/dist/transfer-download-Pml7RMio.mjs.map +0 -1
  1190. package/dist/transformations-9gfpwY65.mjs +0 -196
  1191. package/dist/transformations-9gfpwY65.mjs.map +0 -1
  1192. package/dist/transport-BIfH7_hx.d.mts +0 -42
  1193. package/dist/transport-BIfH7_hx.d.mts.map +0 -1
  1194. package/dist/transport-DKWIq53q.mjs +0 -136
  1195. package/dist/transport-DKWIq53q.mjs.map +0 -1
  1196. package/dist/trusted-proxy-tKiVtyTD.mjs +0 -51
  1197. package/dist/trusted-proxy-tKiVtyTD.mjs.map +0 -1
  1198. package/dist/turnstile-DpsoyOfg.mjs +0 -53
  1199. package/dist/turnstile-DpsoyOfg.mjs.map +0 -1
  1200. package/dist/types-B4sUC2p1.d.mts +0 -198
  1201. package/dist/types-B4sUC2p1.d.mts.map +0 -1
  1202. package/dist/types-B7Lmsh1E.d.mts +0 -887
  1203. package/dist/types-B7Lmsh1E.d.mts.map +0 -1
  1204. package/dist/types-BZakh7Ym.mjs +0 -22
  1205. package/dist/types-BZakh7Ym.mjs.map +0 -1
  1206. package/dist/types-B_CppEmv.d.mts +0 -264
  1207. package/dist/types-B_CppEmv.d.mts.map +0 -1
  1208. package/dist/types-BcrBrE6-.mjs +0 -159
  1209. package/dist/types-BcrBrE6-.mjs.map +0 -1
  1210. package/dist/types-BkUg2yHx.mjs +0 -92
  1211. package/dist/types-BkUg2yHx.mjs.map +0 -1
  1212. package/dist/types-CAZgq9fO.d.mts +0 -124
  1213. package/dist/types-CAZgq9fO.d.mts.map +0 -1
  1214. package/dist/types-Cd-O03VG.d.mts +0 -363
  1215. package/dist/types-Cd-O03VG.d.mts.map +0 -1
  1216. package/dist/types-Cr-Kg-3D.d.mts +0 -1641
  1217. package/dist/types-Cr-Kg-3D.d.mts.map +0 -1
  1218. package/dist/types-D2fvWd1i.d.mts +0 -359
  1219. package/dist/types-D2fvWd1i.d.mts.map +0 -1
  1220. package/dist/types-D7HUsguf.mjs +0 -77
  1221. package/dist/types-D7HUsguf.mjs.map +0 -1
  1222. package/dist/types-DA1Te3Oy.d.mts +0 -198
  1223. package/dist/types-DA1Te3Oy.d.mts.map +0 -1
  1224. package/dist/types-DhV6Q5bP.mjs +0 -18
  1225. package/dist/types-DhV6Q5bP.mjs.map +0 -1
  1226. package/dist/types-DnnVSl6Y.d.mts +0 -85
  1227. package/dist/types-DnnVSl6Y.d.mts.map +0 -1
  1228. package/dist/types-VT4-BugW.mjs +0 -16
  1229. package/dist/types-VT4-BugW.mjs.map +0 -1
  1230. package/dist/upload-attempts-B68ZGNu9.mjs +0 -32
  1231. package/dist/upload-attempts-B68ZGNu9.mjs.map +0 -1
  1232. package/dist/url-pattern-CCeZMGOh.mjs +0 -33
  1233. package/dist/url-pattern-CCeZMGOh.mjs.map +0 -1
  1234. package/dist/user-DDSL-sGw.mjs +0 -171
  1235. package/dist/user-DDSL-sGw.mjs.map +0 -1
  1236. package/dist/utils-DdhmO9w9.mjs +0 -439
  1237. package/dist/utils-DdhmO9w9.mjs.map +0 -1
  1238. package/dist/validate-CHosPEhs.mjs +0 -453
  1239. package/dist/validate-CHosPEhs.mjs.map +0 -1
  1240. package/dist/validate-CM79QXYE.d.mts +0 -432
  1241. package/dist/validate-CM79QXYE.d.mts.map +0 -1
  1242. package/dist/validation-BFecQczG.mjs +0 -218
  1243. package/dist/validation-BFecQczG.mjs.map +0 -1
  1244. package/dist/version-BRZXVifl.mjs +0 -9
  1245. package/dist/version-BRZXVifl.mjs.map +0 -1
  1246. package/dist/version-DUQDHgrf.mjs +0 -7
  1247. package/dist/version-DUQDHgrf.mjs.map +0 -1
  1248. package/dist/widgets-WdV72brA.mjs +0 -126
  1249. package/dist/widgets-WdV72brA.mjs.map +0 -1
  1250. package/dist/wxr-taxonomies-BHTdqkmZ.d.mts +0 -34
  1251. package/dist/wxr-taxonomies-BHTdqkmZ.d.mts.map +0 -1
  1252. package/dist/wxr-taxonomies-DP6ESgMN.mjs +0 -372
  1253. package/dist/wxr-taxonomies-DP6ESgMN.mjs.map +0 -1
  1254. package/dist/zod-generator-D6uE4WiS.mjs +0 -389
  1255. package/dist/zod-generator-D6uE4WiS.mjs.map +0 -1
  1256. package/src/astro/routes/api/relations/[id]/translations.ts +0 -33
  1257. /package/dist/{api-tokens-CE1ECIg0.mjs → api-tokens-FaG1zPsj.mjs} +0 -0
  1258. /package/dist/{ssrf-DpBH7aOt.mjs → ssrf-DZOt8Qof.mjs} +0 -0
@@ -1,3608 +0,0 @@
1
- import { t as validateIdentifier } from "./validate-DANX1-Qi.mjs";
2
- import { t as OptionsRepository } from "./options-DhrI7eMv.mjs";
3
- import { n as cachedQuery, t as CacheNamespace } from "./object-cache-CqWNY5uP.mjs";
4
- import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-Dms7Uxbt.mjs";
5
- import { t as CommentRepository } from "./comment-CrBl22OF.mjs";
6
- import { t as PluginContextFactory } from "./context-BeGccdUX.mjs";
7
- import { a as resolveLocalizedContentRoutePath, i as resolveLocaleChain, r as resolveLocale } from "./resolve-2WbQsCvT.mjs";
8
- import { r as requestCached } from "./request-cache-DzLYKm_x.mjs";
9
- import { n as inspectContentPolicyDecision } from "./content-policy-DFNw91-d.mjs";
10
- import { t as menuTag } from "./chrome-tags-DApCQSIk.mjs";
11
- import { s as getDb } from "./loader-BzqeR1ZN.mjs";
12
- import { s as normalizePluginCapabilities } from "./types-BZakh7Ym.mjs";
13
- import { m as sanitizeHref } from "./menus-BM7BPLOb.mjs";
14
- import { i as sanitizeGalleryImages, r as resolveImageMedia } from "./apply-CoT603H3.mjs";
15
- import { r as setCronTasksEnabled } from "./cron-7DCJwPXq.mjs";
16
- import { t as PluginRouteRegistry } from "./routes-CUsM40Cc.mjs";
17
- import { t as CommentReactionRepository } from "./comment-reaction-JEQ2Fpd8.mjs";
18
- import { sql } from "kysely";
19
- import { AsyncLocalStorage } from "node:async_hooks";
20
- import { z } from "astro/zod";
21
- import { PLUGIN_CAPABILITIES, isJsonPostRouteContract } from "@emdash-cms/plugin-types";
22
- import { UnsafePortableTextTableError, portableTextTableToProseMirror, proseMirrorTableToPortableText } from "@emdash-cms/admin/portable-text-table";
23
- import { Extension, Mark, Node } from "@tiptap/core";
24
-
25
- //#region src/config/errors.ts
26
- /** A configuration failure whose message is safe to return from the API. */
27
- var EmDashConfigurationError = class extends Error {
28
- constructor(message, code, cause) {
29
- super(message);
30
- this.code = code;
31
- this.cause = cause;
32
- this.name = "EmDashConfigurationError";
33
- }
34
- };
35
-
36
- //#endregion
37
- //#region src/fields/image.ts
38
- const mediaSchema = z.object({
39
- id: z.string(),
40
- src: z.string().optional(),
41
- alt: z.string().optional(),
42
- width: z.number().optional(),
43
- height: z.number().optional(),
44
- filename: z.string().optional(),
45
- mimeType: z.string().optional(),
46
- blurhash: z.string().optional(),
47
- dominantColor: z.string().optional(),
48
- focalX: z.number().optional(),
49
- focalY: z.number().optional(),
50
- provider: z.string().optional(),
51
- previewUrl: z.string().optional(),
52
- meta: z.record(z.string(), z.unknown()).optional()
53
- });
54
- const imageSchema = mediaSchema.extend({ darkVariant: mediaSchema.optional() });
55
- function image(options = {}) {
56
- const validation = options.allowedTypes && options.allowedTypes.length > 0 ? { allowedMimeTypes: [...options.allowedTypes] } : void 0;
57
- return {
58
- type: "image",
59
- columnType: "TEXT",
60
- schema: options.required === false ? imageSchema.optional() : imageSchema,
61
- options,
62
- ui: { widget: "image" },
63
- validation
64
- };
65
- }
66
-
67
- //#endregion
68
- //#region src/fields/file.ts
69
- function file(options = {}) {
70
- const fileObjSchema = z.object({
71
- id: z.string(),
72
- url: z.string().optional(),
73
- src: z.string().optional(),
74
- filename: z.string().optional(),
75
- mimeType: z.string().optional(),
76
- size: z.number().optional(),
77
- provider: z.string().optional(),
78
- meta: z.record(z.string(), z.unknown()).optional()
79
- });
80
- return {
81
- type: "file",
82
- columnType: "TEXT",
83
- schema: options.required ? fileObjSchema : fileObjSchema.optional(),
84
- options,
85
- ui: {
86
- widget: "file",
87
- helpText: options.helpText,
88
- maxSize: options.maxSize
89
- },
90
- validation: options.allowedTypes && options.allowedTypes.length > 0 ? { allowedMimeTypes: [...options.allowedTypes] } : void 0
91
- };
92
- }
93
-
94
- //#endregion
95
- //#region src/fields/reference.ts
96
- /**
97
- * Reference field
98
- * References another content item by ID
99
- */
100
- function reference(collection, options) {
101
- const schema = z.string();
102
- return {
103
- type: "reference",
104
- columnType: "TEXT",
105
- schema: options?.required === false ? schema.optional() : schema,
106
- options: {
107
- ...options,
108
- collection
109
- },
110
- ui: { widget: "reference" }
111
- };
112
- }
113
-
114
- //#endregion
115
- //#region src/fields/portable-text.ts
116
- /**
117
- * Portable Text block schema
118
- */
119
- const portableTextBlockSchema = z.object({
120
- _type: z.string(),
121
- _key: z.string()
122
- }).loose();
123
- /**
124
- * Portable Text field
125
- * Stores structured content in Portable Text format
126
- */
127
- function portableText(options) {
128
- const schema = z.array(portableTextBlockSchema);
129
- return {
130
- type: "portableText",
131
- columnType: "JSON",
132
- schema: options?.required === false ? schema.optional() : schema,
133
- options,
134
- ui: { widget: "portableText" }
135
- };
136
- }
137
-
138
- //#endregion
139
- //#region src/content/converters/mark-safety.ts
140
- const SUPPORTED_PORTABLE_TEXT_DECORATORS = new Set([
141
- "strong",
142
- "em",
143
- "underline",
144
- "strike-through",
145
- "subscript",
146
- "superscript",
147
- "code"
148
- ]);
149
- const SUPPORTED_PROSEMIRROR_MARKS = new Set([
150
- "bold",
151
- "strong",
152
- "italic",
153
- "em",
154
- "underline",
155
- "strike",
156
- "strikethrough",
157
- "subscript",
158
- "superscript",
159
- "code",
160
- "link",
161
- "emdashPortableTextSpan"
162
- ]);
163
- function isRecord$2(value) {
164
- return typeof value === "object" && value !== null && !Array.isArray(value);
165
- }
166
- function collectPortableTextMarks(value, inheritedMarkDefs, unsupported) {
167
- if (Array.isArray(value)) {
168
- for (const item of value) collectPortableTextMarks(item, inheritedMarkDefs, unsupported);
169
- return;
170
- }
171
- if (!isRecord$2(value)) return;
172
- let markDefs = inheritedMarkDefs;
173
- if (Array.isArray(value.markDefs)) {
174
- const localMarkDefs = new Map(inheritedMarkDefs);
175
- for (const markDef of value.markDefs) if (isRecord$2(markDef) && typeof markDef._key === "string") localMarkDefs.set(markDef._key, markDef);
176
- markDefs = localMarkDefs;
177
- }
178
- if (value._type === "span" && Array.isArray(value.marks)) for (const mark of value.marks) {
179
- if (typeof mark !== "string" || SUPPORTED_PORTABLE_TEXT_DECORATORS.has(mark)) continue;
180
- const markDef = markDefs.get(mark);
181
- if (markDef?._type === "link") continue;
182
- unsupported.add(typeof markDef?._type === "string" ? markDef._type : mark);
183
- }
184
- for (const [key, child] of Object.entries(value)) if (key !== "markDefs") collectPortableTextMarks(child, markDefs, unsupported);
185
- }
186
- function collectProseMirrorMarks(node, unsupported) {
187
- for (const mark of node.marks ?? []) if (!SUPPORTED_PROSEMIRROR_MARKS.has(mark.type)) unsupported.add(mark.type);
188
- for (const child of node.content ?? []) collectProseMirrorMarks(child, unsupported);
189
- }
190
- var UnsupportedPortableTextMarksError = class extends Error {
191
- marks;
192
- constructor(marks) {
193
- const sortedMarks = [...new Set(marks)].toSorted();
194
- super(`Unsupported Portable Text marks: ${sortedMarks.join(", ")}`);
195
- this.name = "UnsupportedPortableTextMarksError";
196
- this.marks = sortedMarks;
197
- }
198
- };
199
- function findUnsupportedPortableTextMarks(blocks) {
200
- const unsupported = /* @__PURE__ */ new Set();
201
- for (const block of blocks) if (block._type === "block" || block._type === "table") collectPortableTextMarks(block, /* @__PURE__ */ new Map(), unsupported);
202
- return [...unsupported].toSorted();
203
- }
204
- function assertPortableTextMarksSupported(blocks) {
205
- const unsupported = findUnsupportedPortableTextMarks(blocks);
206
- if (unsupported.length > 0) throw new UnsupportedPortableTextMarksError(unsupported);
207
- }
208
- function assertProseMirrorMarksSupported(document) {
209
- const unsupported = /* @__PURE__ */ new Set();
210
- for (const node of document.content) collectProseMirrorMarks(node, unsupported);
211
- if (unsupported.size > 0) throw new UnsupportedPortableTextMarksError(unsupported);
212
- }
213
-
214
- //#endregion
215
- //#region src/content/converters/numbered-list.ts
216
- const MAX_ORDERED_LIST_START = 2147483647;
217
- function normalizeListId(value) {
218
- if (typeof value !== "string") return void 0;
219
- const normalized = value.trim();
220
- return normalized.length > 0 && normalized.length <= 128 ? normalized : void 0;
221
- }
222
- function normalizeListStart(value) {
223
- return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= MAX_ORDERED_LIST_START ? value : void 0;
224
- }
225
- function deriveLegacyListId(seed) {
226
- const readable = `legacy:${seed}`;
227
- if (readable.length <= 128) return readable;
228
- let hash = 2166136261;
229
- for (let i = 0; i < seed.length; i++) {
230
- hash ^= seed.charCodeAt(i);
231
- hash = Math.imul(hash, 16777619);
232
- }
233
- return `legacy:${seed.slice(0, 96)}:${(hash >>> 0).toString(36)}:${seed.length.toString(36)}`;
234
- }
235
- function readOrderedListMetadata(attrs, fallbackId) {
236
- return {
237
- listId: normalizeListId(attrs?.listId) ?? deriveLegacyListId(fallbackId),
238
- listStart: normalizeListStart(attrs?.listStart) ?? normalizeListStart(attrs?.start) ?? 1
239
- };
240
- }
241
- function collectProseMirrorOrderedLists(doc) {
242
- const lists = [];
243
- const visit = (node, path, depth, context) => {
244
- if (node.type === "orderedList") lists.push({
245
- node,
246
- path,
247
- depth,
248
- context
249
- });
250
- for (const [index, child] of (node.content ?? []).entries()) {
251
- const childPath = `${path}:${index}`;
252
- visit(child, childPath, depth + 1, child.type === "listItem" ? `listItem:${childPath}` : context);
253
- }
254
- };
255
- for (const [index, node] of doc.content.entries()) visit(node, `root:${index}`, 0, "root");
256
- return lists;
257
- }
258
- function cloneProseMirrorNode(node) {
259
- return {
260
- ...node,
261
- attrs: node.attrs ? { ...node.attrs } : void 0,
262
- content: node.content?.map(cloneProseMirrorNode),
263
- marks: node.marks?.map((mark) => ({
264
- ...mark,
265
- attrs: mark.attrs ? { ...mark.attrs } : void 0
266
- }))
267
- };
268
- }
269
- function createRepairId(sourceId, scope, attempt) {
270
- const base = deriveLegacyListId(`repair:${sourceId}:${scope}`);
271
- const suffix = `:${attempt.toString(36)}`;
272
- return `${base.slice(0, 128 - suffix.length)}${suffix}`;
273
- }
274
- function normalizeProseMirrorOrderedListJson(doc) {
275
- const normalized = {
276
- ...doc,
277
- content: doc.content.map(cloneProseMirrorNode)
278
- };
279
- const canonicalBySourceScope = /* @__PURE__ */ new Map();
280
- const assignedCanonicalIds = /* @__PURE__ */ new Set();
281
- const lists = collectProseMirrorOrderedLists(normalized).map((list) => {
282
- const sourceId = normalizeListId(list.node.attrs?.listId) ?? deriveLegacyListId(`pm-json:${list.path}:${list.depth}:${list.context}`);
283
- const scope = JSON.stringify([list.depth, list.context]);
284
- const sourceScope = JSON.stringify([sourceId, scope]);
285
- let listId = canonicalBySourceScope.get(sourceScope);
286
- if (!listId) {
287
- if (!assignedCanonicalIds.has(sourceId)) listId = sourceId;
288
- else {
289
- let attempt = 0;
290
- do
291
- listId = createRepairId(sourceId, scope, attempt++);
292
- while (assignedCanonicalIds.has(listId));
293
- }
294
- canonicalBySourceScope.set(sourceScope, listId);
295
- assignedCanonicalIds.add(listId);
296
- }
297
- return {
298
- ...list,
299
- listId,
300
- scopeKey: JSON.stringify([
301
- listId,
302
- list.depth,
303
- list.context
304
- ])
305
- };
306
- });
307
- const bases = /* @__PURE__ */ new Map();
308
- for (const list of lists) {
309
- const listStart = normalizeListStart(list.node.attrs?.listStart);
310
- if (listStart !== void 0 && !bases.has(list.scopeKey)) bases.set(list.scopeKey, listStart);
311
- }
312
- for (const list of lists) if (!bases.has(list.scopeKey)) bases.set(list.scopeKey, normalizeListStart(list.node.attrs?.start) ?? 1);
313
- const counts = /* @__PURE__ */ new Map();
314
- for (const list of lists) {
315
- const listStart = bases.get(list.scopeKey);
316
- const count = counts.get(list.scopeKey) ?? 0;
317
- const start = normalizeListStart(listStart + count) ?? 1;
318
- const directItemCount = list.node.content?.filter((node) => node.type === "listItem").length ?? 0;
319
- counts.set(list.scopeKey, count + directItemCount);
320
- list.node.attrs = {
321
- ...list.node.attrs,
322
- listId: list.listId,
323
- listStart,
324
- start
325
- };
326
- }
327
- return normalized;
328
- }
329
-
330
- //#endregion
331
- //#region src/content/converters/portable-text-identity.ts
332
- const PORTABLE_TEXT_BLOCK_NODE = "emdashPortableTextBlock";
333
- const PORTABLE_TEXT_BLOCK_ATTR = "emdashPortableTextBlock";
334
- const PORTABLE_TEXT_KEY_ATTR = "emdashPortableTextKey";
335
- const PORTABLE_TEXT_SPAN_MARK = "emdashPortableTextSpan";
336
- function isRecord$1(value) {
337
- return typeof value === "object" && value !== null && !Array.isArray(value);
338
- }
339
- function attrsWithPortableTextKey(attrs, key) {
340
- return {
341
- ...attrs,
342
- [PORTABLE_TEXT_KEY_ATTR]: key
343
- };
344
- }
345
- function portableTextKeyFromAttrs(attrs) {
346
- const key = attrs?.[PORTABLE_TEXT_KEY_ATTR];
347
- return typeof key === "string" && key ? key : void 0;
348
- }
349
- function portableTextSpanKeyFromMarks(marks) {
350
- for (const mark of marks ?? []) {
351
- if (!isRecord$1(mark) || mark.type !== PORTABLE_TEXT_SPAN_MARK || !isRecord$1(mark.attrs)) continue;
352
- const key = mark.attrs.key;
353
- if (typeof key === "string" && key) return key;
354
- }
355
- }
356
- function portableTextMarkDefsFromMarks(marks) {
357
- const identity = (marks ?? []).find((mark) => isRecord$1(mark) && mark.type === PORTABLE_TEXT_SPAN_MARK && isRecord$1(mark.attrs));
358
- if (!isRecord$1(identity) || !isRecord$1(identity.attrs) || !Array.isArray(identity.attrs.markDefs)) return [];
359
- return identity.attrs.markDefs.filter((markDef) => isRecord$1(markDef) && typeof markDef._type === "string" && typeof markDef._key === "string");
360
- }
361
- function portableTextBlockFromAttrs(attrs) {
362
- const block = attrs?.[PORTABLE_TEXT_BLOCK_ATTR];
363
- if (!isRecord$1(block) || typeof block._type !== "string" || typeof block._key !== "string") return;
364
- return {
365
- ...block,
366
- _type: block._type,
367
- _key: block._key
368
- };
369
- }
370
- const PortableTextIdentityExtension = Extension.create({
371
- name: "emdashPortableTextIdentity",
372
- addGlobalAttributes() {
373
- const hiddenAttribute = {
374
- default: null,
375
- rendered: false
376
- };
377
- return [{
378
- types: [
379
- "paragraph",
380
- "heading",
381
- "blockquote",
382
- "codeBlock",
383
- "htmlBlock",
384
- "image",
385
- "horizontalRule",
386
- "gallery",
387
- PORTABLE_TEXT_BLOCK_NODE
388
- ],
389
- attributes: { [PORTABLE_TEXT_KEY_ATTR]: hiddenAttribute }
390
- }];
391
- }
392
- });
393
- const PortableTextSpanIdentity = Mark.create({
394
- name: PORTABLE_TEXT_SPAN_MARK,
395
- inclusive: false,
396
- spanning: false,
397
- addAttributes() {
398
- return {
399
- key: {
400
- default: null,
401
- rendered: false
402
- },
403
- markDefs: {
404
- default: [],
405
- rendered: false
406
- }
407
- };
408
- },
409
- parseHTML() {
410
- return [];
411
- },
412
- renderHTML() {
413
- return ["span", 0];
414
- }
415
- });
416
- const PortableTextOpaqueBlock = Node.create({
417
- name: PORTABLE_TEXT_BLOCK_NODE,
418
- group: "block",
419
- atom: true,
420
- selectable: true,
421
- draggable: true,
422
- addAttributes() {
423
- return { [PORTABLE_TEXT_BLOCK_ATTR]: {
424
- default: null,
425
- rendered: false
426
- } };
427
- },
428
- parseHTML() {
429
- return [{ tag: "div[data-emdash-portable-text-block]" }];
430
- },
431
- renderHTML({ node }) {
432
- const blockType = portableTextBlockFromAttrs(node.attrs)?._type ?? "unknown";
433
- return [
434
- "div",
435
- {
436
- "data-emdash-portable-text-block": blockType,
437
- contenteditable: "false"
438
- },
439
- `[Unknown block type: ${blockType}]`
440
- ];
441
- }
442
- });
443
- const portableTextIdentityExtensions = [
444
- PortableTextIdentityExtension,
445
- PortableTextSpanIdentity,
446
- PortableTextOpaqueBlock
447
- ];
448
-
449
- //#endregion
450
- //#region src/content/converters/prosemirror-to-portable-text.ts
451
- /**
452
- * ProseMirror to Portable Text Converter
453
- *
454
- * Converts TipTap's ProseMirror JSON format to Portable Text for storage.
455
- */
456
- /**
457
- * Generate a unique key for Portable Text blocks
458
- */
459
- function generateKey$1() {
460
- return Math.random().toString(36).substring(2, 11);
461
- }
462
- /**
463
- * Convert ProseMirror document to Portable Text
464
- */
465
- function prosemirrorToPortableText(doc) {
466
- if (!doc || doc.type !== "doc" || !doc.content) return [];
467
- assertProseMirrorMarksSupported(doc);
468
- const blocks = [];
469
- const usedBlockKeys = /* @__PURE__ */ new Set();
470
- for (const [i, node] of doc.content.entries()) {
471
- if (i === doc.content.length - 1 && isUnkeyedEmptyParagraph(node)) continue;
472
- const converted = convertNode(node, `root:${i}`);
473
- for (const block of converted ? Array.isArray(converted) ? converted : [converted] : []) {
474
- let key = block._key;
475
- if (usedBlockKeys.has(key)) do
476
- key = generateKey$1();
477
- while (usedBlockKeys.has(key));
478
- usedBlockKeys.add(key);
479
- blocks.push(key === block._key ? block : {
480
- ...block,
481
- _key: key
482
- });
483
- }
484
- }
485
- return blocks;
486
- }
487
- function isUnkeyedEmptyParagraph(node) {
488
- return node.type === "paragraph" && (node.content?.length ?? 0) === 0 && portableTextKeyFromAttrs(node.attrs) === void 0;
489
- }
490
- /**
491
- * Convert a single ProseMirror node to Portable Text block(s)
492
- */
493
- function convertNode(node, path) {
494
- switch (node.type) {
495
- case PORTABLE_TEXT_BLOCK_NODE: return portableTextBlockFromAttrs(node.attrs) ?? null;
496
- case "paragraph": return convertParagraph(node);
497
- case "heading": return convertHeading(node);
498
- case "bulletList": return convertList$1(node, "bullet", path);
499
- case "orderedList": return convertList$1(node, "number", path);
500
- case "blockquote": return convertBlockquote(node);
501
- case "codeBlock": return convertCodeBlock$1(node);
502
- case "htmlBlock": return convertHtmlBlock(node);
503
- case "image": return convertImage$1(node);
504
- case "gallery": return convertGallery(node);
505
- case "table": {
506
- const result = proseMirrorTableToPortableText(node, {
507
- path,
508
- createKey: generateKey$1,
509
- inlineToSpans: (content) => {
510
- const { children, markDefs } = convertInlineContent(content, true);
511
- return {
512
- content: children,
513
- markDefs
514
- };
515
- }
516
- });
517
- if (!result.ok) throw new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);
518
- return result.table;
519
- }
520
- case "horizontalRule": return {
521
- _type: "break",
522
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
523
- style: "lineBreak"
524
- };
525
- default: return {
526
- _type: node.type,
527
- _key: generateKey$1(),
528
- ...node.attrs,
529
- _pmContent: node.content
530
- };
531
- }
532
- }
533
- /**
534
- * Convert paragraph to Portable Text block
535
- */
536
- function convertParagraph(node) {
537
- const { children, markDefs } = convertInlineContent(node.content || []);
538
- if (children.length === 0) return null;
539
- const ta = node.attrs?.textAlign;
540
- const textAlign = ta === "center" || ta === "right" || ta === "justify" ? ta : void 0;
541
- return {
542
- _type: "block",
543
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
544
- style: "normal",
545
- children,
546
- ...markDefs.length > 0 ? { markDefs } : {},
547
- ...textAlign ? { textAlign } : {}
548
- };
549
- }
550
- /** Map heading level number to Portable Text style */
551
- function headingLevelToStyle(level) {
552
- switch (level) {
553
- case 1: return "h1";
554
- case 2: return "h2";
555
- case 3: return "h3";
556
- case 4: return "h4";
557
- case 5: return "h5";
558
- case 6: return "h6";
559
- default: return "h1";
560
- }
561
- }
562
- /**
563
- * Convert heading to Portable Text block
564
- */
565
- function convertHeading(node) {
566
- const { children, markDefs } = convertInlineContent(node.content || []);
567
- const style = headingLevelToStyle(typeof node.attrs?.level === "number" ? node.attrs.level : 1);
568
- if (children.length === 0) return null;
569
- const ta = node.attrs?.textAlign;
570
- const textAlign = ta === "center" || ta === "right" || ta === "justify" ? ta : void 0;
571
- return {
572
- _type: "block",
573
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
574
- style,
575
- children,
576
- markDefs: markDefs.length > 0 ? markDefs : void 0,
577
- ...textAlign ? { textAlign } : {}
578
- };
579
- }
580
- /**
581
- * Convert list to Portable Text blocks
582
- */
583
- function convertList$1(node, listItem, path) {
584
- const blocks = [];
585
- const metadata = listItem === "number" ? readOrderedListMetadata(node.attrs, path) : void 0;
586
- for (const [i, item] of (node.content ?? []).entries()) if (item.type === "listItem") {
587
- const itemBlocks = convertListItem$1(item, listItem, 1, `${path}:${i}`, metadata);
588
- blocks.push(...itemBlocks);
589
- }
590
- return blocks;
591
- }
592
- /**
593
- * Convert list item to Portable Text blocks
594
- */
595
- function convertListItem$1(item, listItem, level, path, metadata) {
596
- const blocks = [];
597
- for (const [i, child] of (item.content ?? []).entries()) if (child.type === "paragraph") {
598
- const { children, markDefs } = convertInlineContent(child.content || []);
599
- if (children.length > 0) blocks.push({
600
- _type: "block",
601
- _key: portableTextKeyFromAttrs(child.attrs) ?? generateKey$1(),
602
- style: "normal",
603
- listItem,
604
- level,
605
- ...metadata,
606
- children,
607
- markDefs: markDefs.length > 0 ? markDefs : void 0
608
- });
609
- } else if (child.type === "bulletList") blocks.push(...convertListItemNested(child, "bullet", level + 1, `${path}:${i}`));
610
- else if (child.type === "orderedList") blocks.push(...convertListItemNested(child, "number", level + 1, `${path}:${i}`));
611
- return blocks;
612
- }
613
- /**
614
- * Convert nested list
615
- */
616
- function convertListItemNested(node, listItem, level, path) {
617
- const blocks = [];
618
- const metadata = listItem === "number" ? readOrderedListMetadata(node.attrs, path) : void 0;
619
- for (const [i, item] of (node.content ?? []).entries()) if (item.type === "listItem") blocks.push(...convertListItem$1(item, listItem, level, `${path}:${i}`, metadata));
620
- return blocks;
621
- }
622
- /**
623
- * Convert blockquote to Portable Text blocks
624
- */
625
- function convertBlockquote(node) {
626
- const blocks = [];
627
- for (const child of node.content || []) if (child.type === "paragraph") {
628
- const { children, markDefs } = convertInlineContent(child.content || []);
629
- if (children.length > 0) blocks.push({
630
- _type: "block",
631
- _key: portableTextKeyFromAttrs(child.attrs) ?? portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
632
- style: "blockquote",
633
- children,
634
- markDefs: markDefs.length > 0 ? markDefs : void 0
635
- });
636
- }
637
- return blocks.length === 1 ? blocks[0] : blocks.length > 0 ? blocks : null;
638
- }
639
- /**
640
- * Convert code block to Portable Text
641
- */
642
- function convertCodeBlock$1(node) {
643
- const code = node.content?.map((n) => n.text || "").join("") || "";
644
- const language = typeof node.attrs?.language === "string" ? node.attrs.language : void 0;
645
- return {
646
- _type: "code",
647
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
648
- code,
649
- language: language || void 0
650
- };
651
- }
652
- /**
653
- * Convert HTML block to Portable Text
654
- */
655
- function convertHtmlBlock(node) {
656
- const rawHtml = node.attrs?.html;
657
- return {
658
- _type: "htmlBlock",
659
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
660
- html: typeof rawHtml === "string" ? rawHtml : ""
661
- };
662
- }
663
- /**
664
- * Convert image to Portable Text
665
- */
666
- function convertImage$1(node) {
667
- const attrs = node.attrs;
668
- const provider = typeof attrs?.provider === "string" ? attrs.provider : void 0;
669
- const mediaId = typeof attrs?.mediaId === "string" ? attrs.mediaId : void 0;
670
- const src = typeof attrs?.src === "string" ? attrs.src : "";
671
- const alt = typeof attrs?.alt === "string" ? attrs.alt : void 0;
672
- const title = typeof attrs?.title === "string" ? attrs.title : void 0;
673
- const width = typeof attrs?.width === "number" ? attrs.width : void 0;
674
- const height = typeof attrs?.height === "number" ? attrs.height : void 0;
675
- const displayWidth = typeof attrs?.displayWidth === "number" ? attrs.displayWidth : void 0;
676
- const displayHeight = typeof attrs?.displayHeight === "number" ? attrs.displayHeight : void 0;
677
- const alignment = attrs?.alignment;
678
- let link;
679
- const rawLink = attrs?.link;
680
- if (rawLink && typeof rawLink === "object") {
681
- const linkObj = rawLink;
682
- const href = typeof linkObj.href === "string" ? linkObj.href.trim() : "";
683
- if (href) {
684
- link = { href };
685
- if (linkObj.blank === true) link.blank = true;
686
- }
687
- }
688
- return {
689
- _type: "image",
690
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
691
- asset: {
692
- _ref: mediaId || src || "",
693
- url: src || "",
694
- provider: provider && provider !== "local" ? provider : void 0
695
- },
696
- alt: alt || void 0,
697
- caption: title || void 0,
698
- width: width || void 0,
699
- height: height || void 0,
700
- displayWidth: displayWidth || void 0,
701
- displayHeight: displayHeight || void 0,
702
- alignment: alignment === "left" || alignment === "center" || alignment === "right" || alignment === "wide" || alignment === "full" ? alignment : void 0,
703
- link
704
- };
705
- }
706
- /**
707
- * Convert gallery node to Portable Text
708
- */
709
- function convertGallery(node) {
710
- const columns = node.attrs?.columns;
711
- return {
712
- _type: "gallery",
713
- _key: portableTextKeyFromAttrs(node.attrs) ?? generateKey$1(),
714
- images: sanitizeGalleryImages(node.attrs?.images, generateKey$1),
715
- ...typeof columns === "number" ? { columns } : {}
716
- };
717
- }
718
- /**
719
- * Convert inline content (text nodes with marks) to Portable Text spans
720
- */
721
- function convertInlineContent(nodes, preserveHardBreakBoundary = false) {
722
- const children = [];
723
- const markDefs = [];
724
- const markDefMap = /* @__PURE__ */ new Map();
725
- const usedSpanKeys = /* @__PURE__ */ new Set();
726
- const claimSpanKey = (preferred) => {
727
- if (preferred && !usedSpanKeys.has(preferred)) {
728
- usedSpanKeys.add(preferred);
729
- return preferred;
730
- }
731
- let key;
732
- do
733
- key = generateKey$1();
734
- while (usedSpanKeys.has(key));
735
- usedSpanKeys.add(key);
736
- return key;
737
- };
738
- for (const node of nodes) if (node.type === "text" && node.text) {
739
- const marks = [];
740
- const originalMarkDefs = portableTextMarkDefsFromMarks(node.marks);
741
- for (const mark of node.marks || []) {
742
- const markType = convertMark(mark, markDefs, markDefMap, originalMarkDefs);
743
- if (markType) marks.push(markType);
744
- }
745
- const preferredKey = portableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs);
746
- const normalizedMarks = marks.length > 0 ? marks : void 0;
747
- const previous = children.at(-1);
748
- if (preferredKey && previous?._key === preferredKey && JSON.stringify(previous.marks) === JSON.stringify(normalizedMarks)) {
749
- previous.text += node.text;
750
- continue;
751
- }
752
- children.push({
753
- _type: "span",
754
- _key: claimSpanKey(preferredKey),
755
- text: node.text,
756
- marks: normalizedMarks
757
- });
758
- } else if (node.type === "hardBreak") if (children.length > 0 && !preserveHardBreakBoundary) {
759
- const lastChild = children.at(-1);
760
- lastChild.text += "\n";
761
- } else children.push({
762
- _type: "span",
763
- _key: claimSpanKey(portableTextSpanKeyFromMarks(node.marks) ?? portableTextKeyFromAttrs(node.attrs)),
764
- text: "\n"
765
- });
766
- if (children.length === 0) children.push({
767
- _type: "span",
768
- _key: claimSpanKey(),
769
- text: ""
770
- });
771
- return {
772
- children,
773
- markDefs
774
- };
775
- }
776
- /**
777
- * Convert a ProseMirror mark to Portable Text mark
778
- */
779
- function convertMark(mark, markDefs, markDefMap, originalMarkDefs) {
780
- switch (mark.type) {
781
- case "bold":
782
- case "strong": return "strong";
783
- case "italic":
784
- case "em": return "em";
785
- case "underline": return "underline";
786
- case "strike":
787
- case "strikethrough": return "strike-through";
788
- case "subscript": return "subscript";
789
- case "superscript": return "superscript";
790
- case "code": return "code";
791
- case PORTABLE_TEXT_SPAN_MARK: return null;
792
- case "link": {
793
- const href = (typeof mark.attrs?.href === "string" ? mark.attrs.href : "") || "";
794
- const blank = mark.attrs?.target === "_blank";
795
- const originalMarkDef = originalMarkDefs.find((markDef) => markDef._type === "link");
796
- const mapKey = originalMarkDef ? `key:${originalMarkDef._key}` : `value:${JSON.stringify([href, blank])}`;
797
- if (markDefMap.has(mapKey)) return markDefMap.get(mapKey);
798
- const key = originalMarkDef?._key || generateKey$1();
799
- markDefs.push({
800
- ...originalMarkDef,
801
- _type: "link",
802
- _key: key,
803
- href,
804
- ...originalMarkDef ? blank || Object.hasOwn(originalMarkDef, "blank") ? { blank } : {} : { blank }
805
- });
806
- markDefMap.set(mapKey, key);
807
- return key;
808
- }
809
- default: throw new UnsupportedPortableTextMarksError([mark.type]);
810
- }
811
- }
812
-
813
- //#endregion
814
- //#region src/content/converters/image-link.ts
815
- function normalizeImageLink(raw) {
816
- if (typeof raw === "string") {
817
- const href = raw.trim();
818
- return href ? { href } : null;
819
- }
820
- if (typeof raw !== "object" || raw === null) return null;
821
- const { href, blank } = raw;
822
- if (typeof href !== "string") return null;
823
- const trimmed = href.trim();
824
- if (!trimmed) return null;
825
- return blank === true ? {
826
- href: trimmed,
827
- blank: true
828
- } : { href: trimmed };
829
- }
830
-
831
- //#endregion
832
- //#region src/content/converters/portable-text-to-prosemirror.ts
833
- /**
834
- * Portable Text to ProseMirror Converter
835
- *
836
- * Converts Portable Text to TipTap's ProseMirror JSON format for editing.
837
- */
838
- function generateKey() {
839
- return Math.random().toString(36).substring(2, 11);
840
- }
841
- /** Convert Portable Text to a ProseMirror document. */
842
- function portableTextToProsemirror(blocks, options = {}) {
843
- if (!blocks || blocks.length === 0) return {
844
- type: "doc",
845
- content: [{ type: "paragraph" }]
846
- };
847
- assertPortableTextMarksSupported(blocks);
848
- const preserveIdentity = options.preserveIdentity === true;
849
- const content = [];
850
- let i = 0;
851
- while (i < blocks.length) {
852
- const block = blocks[i];
853
- if (isTextBlock(block) && block.listItem) {
854
- const listBlocks = [];
855
- const listType = block.listItem;
856
- const runStart = i;
857
- const rootId = listType === "number" ? normalizeListId(block.listId) : void 0;
858
- while (i < blocks.length) {
859
- const current = blocks[i];
860
- if (!isTextBlock(current) || !current.listItem) break;
861
- const level = current.level || 1;
862
- const currentId = current.listItem === "number" ? normalizeListId(current.listId) : void 0;
863
- const sameRootIdentity = listType !== "number" || level > 1 || (rootId ? currentId === rootId : currentId === void 0);
864
- if (level > 1 || current.listItem === listType && sameRootIdentity) {
865
- listBlocks.push(current);
866
- i++;
867
- } else break;
868
- }
869
- content.push(convertList(listBlocks, listType, `root:${runStart}`, preserveIdentity));
870
- } else if (isTextBlock(block) && block.style === "blockquote") {
871
- const quoteBlocks = [];
872
- while (i < blocks.length) {
873
- const current = blocks[i];
874
- if (!isTextBlock(current) || current.style !== "blockquote" || current.listItem !== void 0) break;
875
- quoteBlocks.push(current);
876
- i++;
877
- }
878
- content.push({
879
- type: "blockquote",
880
- content: quoteBlocks.map((quoteBlock) => {
881
- const paragraph = convertSpans(quoteBlock.children, quoteBlock.markDefs || [], preserveIdentity);
882
- return {
883
- type: "paragraph",
884
- attrs: identityAttrs(void 0, quoteBlock._key, preserveIdentity),
885
- content: paragraph.length > 0 ? paragraph : void 0
886
- };
887
- })
888
- });
889
- } else {
890
- const converted = convertBlock(block, `root:${i}`, preserveIdentity);
891
- if (converted) content.push(converted);
892
- i++;
893
- }
894
- }
895
- return normalizeProseMirrorOrderedListJson({
896
- type: "doc",
897
- content: content.length > 0 ? content : [{ type: "paragraph" }]
898
- });
899
- }
900
- function identityAttrs(attrs, key, preserveIdentity) {
901
- return preserveIdentity ? attrsWithPortableTextKey(attrs, key) : attrs;
902
- }
903
- function getListMetadata(item, fallbackSeed) {
904
- const listId = normalizeListId(item.listId) ?? deriveLegacyListId(fallbackSeed);
905
- const listStart = normalizeListStart(item.listStart);
906
- return {
907
- listId,
908
- ...listStart === void 0 ? {} : { listStart }
909
- };
910
- }
911
- function belongsToNestedGroup(item, minLevel, parentListType, anchorType, anchorId) {
912
- if ((item.level || 2) > minLevel) return true;
913
- if ((item.listItem || parentListType) !== anchorType) return false;
914
- if (anchorType !== "number") return true;
915
- const itemId = normalizeListId(item.listId);
916
- return anchorId ? itemId === anchorId : itemId === void 0;
917
- }
918
- /**
919
- * Type guard for text blocks
920
- */
921
- function isTextBlock(block) {
922
- return block._type === "block";
923
- }
924
- /**
925
- * Type guard for image blocks.
926
- * Checks both `_type` and that `asset` is a valid object — image blocks
927
- * without an `asset` wrapper (e.g. `{ _type: "image", url: "..." }`) are
928
- * malformed and should not be cast to `PortableTextImageBlock`.
929
- */
930
- function isImageBlock(block) {
931
- return block._type === "image" && "asset" in block && typeof block.asset === "object" && block.asset !== null;
932
- }
933
- /**
934
- * Type guard for gallery blocks that carry a usable `images` array.
935
- * Galleries without one are handled separately in `convertBlock`.
936
- */
937
- function isGalleryBlock(block) {
938
- return block._type === "gallery" && "images" in block && Array.isArray(block.images);
939
- }
940
- /**
941
- * Type guard for code blocks
942
- */
943
- function isCodeBlock(block) {
944
- return block._type === "code";
945
- }
946
- /**
947
- * Convert a single Portable Text block to ProseMirror node
948
- */
949
- function convertBlock(block, path, preserveIdentity) {
950
- if (isTextBlock(block)) return convertTextBlock(block, preserveIdentity);
951
- if (isImageBlock(block)) return convertImage(block, preserveIdentity);
952
- if (block._type === "image") return convertMalformedImage(block, preserveIdentity);
953
- if (isGalleryBlock(block)) return {
954
- type: "gallery",
955
- attrs: identityAttrs({
956
- images: sanitizeGalleryImages(block.images),
957
- columns: typeof block.columns === "number" ? block.columns : void 0
958
- }, block._key, preserveIdentity)
959
- };
960
- if (isCodeBlock(block)) return convertCodeBlock(block, preserveIdentity);
961
- if (block._type === "htmlBlock") return {
962
- type: "htmlBlock",
963
- attrs: identityAttrs({ html: block.html || "" }, block._key, preserveIdentity)
964
- };
965
- if (block._type === "break") return {
966
- type: "horizontalRule",
967
- attrs: identityAttrs(void 0, block._key, preserveIdentity)
968
- };
969
- if (block._type === "gallery") {
970
- if (preserveIdentity) return {
971
- type: PORTABLE_TEXT_BLOCK_NODE,
972
- attrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block }
973
- };
974
- return {
975
- type: "paragraph",
976
- content: [{
977
- type: "text",
978
- text: `[Unknown block type: ${block._type}]`,
979
- marks: [{ type: "code" }]
980
- }]
981
- };
982
- }
983
- if (preserveIdentity) return {
984
- type: PORTABLE_TEXT_BLOCK_NODE,
985
- attrs: { [PORTABLE_TEXT_BLOCK_ATTR]: block }
986
- };
987
- if (block._type === "table") {
988
- const result = portableTextTableToProseMirror(block, {
989
- path,
990
- createKey: generateKey,
991
- spansToInline: (content, markDefs) => convertSpans(content, markDefs, preserveIdentity)
992
- });
993
- if (!result.ok) throw new UnsafePortableTextTableError(result.reason, result.raw, result.renderFallback);
994
- return result.node;
995
- }
996
- return {
997
- type: "paragraph",
998
- content: [{
999
- type: "text",
1000
- text: `[Unknown block type: ${block._type}]`,
1001
- marks: [{ type: "code" }]
1002
- }]
1003
- };
1004
- }
1005
- /**
1006
- * Convert text block to ProseMirror paragraph or heading
1007
- */
1008
- function convertTextBlock(block, preserveIdentity) {
1009
- const { style = "normal", children, markDefs = [] } = block;
1010
- const content = convertSpans(children, markDefs, preserveIdentity);
1011
- switch (style) {
1012
- case "h1":
1013
- case "h2":
1014
- case "h3":
1015
- case "h4":
1016
- case "h5":
1017
- case "h6": return {
1018
- type: "heading",
1019
- attrs: identityAttrs({
1020
- level: parseInt(style.substring(1), 10),
1021
- ...block.textAlign ? { textAlign: block.textAlign } : {}
1022
- }, block._key, preserveIdentity),
1023
- content: content.length > 0 ? content : void 0
1024
- };
1025
- case "blockquote": return {
1026
- type: "blockquote",
1027
- attrs: identityAttrs(void 0, block._key, preserveIdentity),
1028
- content: [{
1029
- type: "paragraph",
1030
- content: content.length > 0 ? content : void 0
1031
- }]
1032
- };
1033
- default: return {
1034
- type: "paragraph",
1035
- attrs: identityAttrs(block.textAlign ? { textAlign: block.textAlign } : void 0, block._key, preserveIdentity),
1036
- content: content.length > 0 ? content : void 0
1037
- };
1038
- }
1039
- }
1040
- /**
1041
- * Convert list items to ProseMirror list
1042
- */
1043
- function convertList(items, listType, context, preserveIdentity) {
1044
- const rootItems = [];
1045
- let i = 0;
1046
- while (i < items.length) {
1047
- const item = items[i];
1048
- if ((item.level || 1) === 1) {
1049
- const nestedItems = [];
1050
- i++;
1051
- while (i < items.length && (items[i].level || 1) > 1) {
1052
- nestedItems.push(items[i]);
1053
- i++;
1054
- }
1055
- rootItems.push(convertListItem(item, nestedItems, listType, `${context}:${rootItems.length}`, preserveIdentity));
1056
- } else {
1057
- rootItems.push(convertListItem(item, [], listType, `${context}:${rootItems.length}`, preserveIdentity));
1058
- i++;
1059
- }
1060
- }
1061
- const metadata = listType === "number" ? getListMetadata(items[0], `${context}:${items[0]._key}`) : void 0;
1062
- return {
1063
- type: listType === "bullet" ? "bulletList" : "orderedList",
1064
- attrs: metadata ? {
1065
- ...metadata,
1066
- start: metadata.listStart ?? 1
1067
- } : void 0,
1068
- content: rootItems
1069
- };
1070
- }
1071
- /**
1072
- * Convert a single list item to ProseMirror
1073
- */
1074
- function convertListItem(item, nestedItems, parentListType, context, preserveIdentity) {
1075
- const content = [];
1076
- const spans = convertSpans(item.children, item.markDefs || [], preserveIdentity);
1077
- content.push({
1078
- type: "paragraph",
1079
- attrs: identityAttrs(void 0, item._key, preserveIdentity),
1080
- content: spans.length > 0 ? spans : void 0
1081
- });
1082
- if (nestedItems.length > 0) {
1083
- let minLevel = Infinity;
1084
- for (const ni of nestedItems) {
1085
- const level = ni.level || 2;
1086
- if (level < minLevel) minLevel = level;
1087
- }
1088
- let j = 0;
1089
- while (j < nestedItems.length) {
1090
- const anchorType = nestedItems[j].listItem || parentListType;
1091
- const anchorId = anchorType === "number" ? normalizeListId(nestedItems[j].listId) : void 0;
1092
- const nestedGroup = [];
1093
- do {
1094
- nestedGroup.push(nestedItems[j]);
1095
- j++;
1096
- } while (j < nestedItems.length && belongsToNestedGroup(nestedItems[j], minLevel, parentListType, anchorType, anchorId));
1097
- if (nestedGroup.length > 0) {
1098
- const adjustedGroup = nestedGroup.map((ni) => ({
1099
- ...ni,
1100
- level: (ni.level || 2) - 1
1101
- }));
1102
- content.push(convertList(adjustedGroup, anchorType, `${context}:nested:${j - nestedGroup.length}`, preserveIdentity));
1103
- }
1104
- }
1105
- }
1106
- return {
1107
- type: "listItem",
1108
- content
1109
- };
1110
- }
1111
- /**
1112
- * Convert Portable Text spans to ProseMirror text nodes
1113
- */
1114
- function convertSpans(spans, markDefs, preserveIdentity) {
1115
- const nodes = [];
1116
- const markDefsMap = new Map(markDefs.map((md) => [md._key, md]));
1117
- for (const span of spans) {
1118
- if (span._type !== "span") continue;
1119
- const referencedMarkDefs = markDefs.filter((markDef) => span.marks?.includes(markDef._key));
1120
- const parts = span.text.split("\n");
1121
- for (let i = 0; i < parts.length; i++) {
1122
- const text = parts[i];
1123
- if (text.length > 0) {
1124
- const marks = convertMarks(span.marks || [], markDefsMap);
1125
- if (preserveIdentity) marks.push({
1126
- type: PORTABLE_TEXT_SPAN_MARK,
1127
- attrs: {
1128
- key: span._key,
1129
- markDefs: referencedMarkDefs
1130
- }
1131
- });
1132
- const node = {
1133
- type: "text",
1134
- text
1135
- };
1136
- if (marks.length > 0) node.marks = marks;
1137
- nodes.push(node);
1138
- }
1139
- if (i < parts.length - 1) nodes.push(preserveIdentity ? {
1140
- type: "hardBreak",
1141
- marks: [{
1142
- type: PORTABLE_TEXT_SPAN_MARK,
1143
- attrs: {
1144
- key: span._key,
1145
- markDefs: referencedMarkDefs
1146
- }
1147
- }]
1148
- } : { type: "hardBreak" });
1149
- }
1150
- }
1151
- return nodes;
1152
- }
1153
- /**
1154
- * Convert Portable Text marks to ProseMirror marks
1155
- */
1156
- function convertMarks(marks, markDefs) {
1157
- const pmMarks = [];
1158
- for (const mark of marks) switch (mark) {
1159
- case "strong":
1160
- pmMarks.push({ type: "bold" });
1161
- break;
1162
- case "em":
1163
- pmMarks.push({ type: "italic" });
1164
- break;
1165
- case "underline":
1166
- pmMarks.push({ type: "underline" });
1167
- break;
1168
- case "strike-through":
1169
- pmMarks.push({ type: "strike" });
1170
- break;
1171
- case "subscript":
1172
- pmMarks.push({ type: "subscript" });
1173
- break;
1174
- case "superscript":
1175
- pmMarks.push({ type: "superscript" });
1176
- break;
1177
- case "code":
1178
- pmMarks.push({ type: "code" });
1179
- break;
1180
- default: {
1181
- const markDef = markDefs.get(mark);
1182
- if (markDef?._type === "link") pmMarks.push({
1183
- type: "link",
1184
- attrs: {
1185
- href: markDef.href,
1186
- target: markDef.blank ? "_blank" : null
1187
- }
1188
- });
1189
- else throw new UnsupportedPortableTextMarksError([typeof markDef?._type === "string" ? markDef._type : mark]);
1190
- break;
1191
- }
1192
- }
1193
- return pmMarks;
1194
- }
1195
- function imageAlignment(value) {
1196
- return value === "left" || value === "center" || value === "right" || value === "wide" || value === "full" ? value : void 0;
1197
- }
1198
- /**
1199
- * Convert image block to ProseMirror
1200
- */
1201
- function convertImage(block, preserveIdentity) {
1202
- const { asset, alt, width, height } = resolveImageMedia(block);
1203
- return {
1204
- type: "image",
1205
- attrs: identityAttrs({
1206
- src: asset.url || asset._ref,
1207
- alt: alt || "",
1208
- title: block.caption || "",
1209
- mediaId: asset._ref,
1210
- provider: asset.provider,
1211
- width,
1212
- height,
1213
- displayWidth: block.displayWidth,
1214
- displayHeight: block.displayHeight,
1215
- alignment: imageAlignment(block.alignment),
1216
- link: normalizeImageLink(block.link)
1217
- }, block._key, preserveIdentity)
1218
- };
1219
- }
1220
- /**
1221
- * Convert a malformed image block (missing `asset` wrapper) to ProseMirror.
1222
- * Handles blocks like `{ _type: "image", url: "...", alt: "..." }` that may
1223
- * originate from migrations or third-party imports.
1224
- */
1225
- function convertMalformedImage(block, preserveIdentity) {
1226
- return {
1227
- type: "image",
1228
- attrs: identityAttrs({
1229
- src: "url" in block && typeof block.url === "string" ? block.url : "",
1230
- alt: "alt" in block && typeof block.alt === "string" ? block.alt : "",
1231
- title: "caption" in block && typeof block.caption === "string" ? block.caption : "",
1232
- mediaId: void 0,
1233
- provider: void 0,
1234
- width: "width" in block && typeof block.width === "number" ? block.width : void 0,
1235
- height: "height" in block && typeof block.height === "number" ? block.height : void 0,
1236
- displayWidth: "displayWidth" in block && typeof block.displayWidth === "number" ? block.displayWidth : void 0,
1237
- displayHeight: "displayHeight" in block && typeof block.displayHeight === "number" ? block.displayHeight : void 0,
1238
- alignment: imageAlignment("alignment" in block ? block.alignment : void 0)
1239
- }, block._key, preserveIdentity)
1240
- };
1241
- }
1242
- /**
1243
- * Convert code block to ProseMirror
1244
- */
1245
- function convertCodeBlock(block, preserveIdentity) {
1246
- return {
1247
- type: "codeBlock",
1248
- attrs: identityAttrs({ language: block.language || null }, block._key, preserveIdentity),
1249
- content: block.code ? [{
1250
- type: "text",
1251
- text: block.code
1252
- }] : void 0
1253
- };
1254
- }
1255
-
1256
- //#endregion
1257
- //#region src/plugins/define-plugin.ts
1258
- /**
1259
- * definePlugin() Helper
1260
- *
1261
- * Native plugin authoring entry. Returns a fully-resolved
1262
- * `ResolvedPlugin` ready for the host integration to mount.
1263
- *
1264
- * Sandboxed plugins do NOT use this function. They default-export
1265
- * a bare `{ hooks?, routes? }` object with a `satisfies SandboxedPlugin`
1266
- * annotation from `emdash/plugin`. See the `emdash` changeset for the
1267
- * authoring shape.
1268
- */
1269
- const MCP_TOOL_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
1270
- /**
1271
- * Define a native EmDash plugin.
1272
- *
1273
- * Native plugins ship as regular npm modules, get installed via
1274
- * `pnpm add` + an `astro.config.mjs` edit, and run in the host
1275
- * process. They have full access to the runtime — capabilities are
1276
- * still enforced by `PluginContextFactory`, but there is no isolation
1277
- * boundary.
1278
- *
1279
- * @example
1280
- * ```typescript
1281
- * import { definePlugin } from "emdash";
1282
- *
1283
- * export default definePlugin({
1284
- * id: "my-plugin",
1285
- * version: "1.0.0",
1286
- * capabilities: ["content:read"],
1287
- * hooks: {
1288
- * "content:beforeSave": async (event, ctx) => {
1289
- * ctx.log.info("Saving content", { collection: event.collection });
1290
- * return event.content;
1291
- * }
1292
- * },
1293
- * routes: {
1294
- * "sync": {
1295
- * handler: async (ctx) => {
1296
- * return { status: "ok" };
1297
- * }
1298
- * }
1299
- * }
1300
- * });
1301
- * ```
1302
- *
1303
- * Sandboxed-format plugins do not use `definePlugin`. They
1304
- * default-export a bare `{ hooks?, routes? }` object with a
1305
- * `satisfies SandboxedPlugin` annotation from `emdash/plugin`. Calling
1306
- * `definePlugin` with an object that has no `id` throws at runtime
1307
- * (the type system already rejects it at compile time — this check is
1308
- * for callers that bypass typechecking). Passing a plugin descriptor
1309
- * (an object with an `entrypoint`) also throws.
1310
- */
1311
- function definePlugin(definition) {
1312
- 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\`.`);
1313
- 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().`);
1314
- return defineNativePlugin(definition);
1315
- }
1316
- function definePluginRoute(route) {
1317
- return route;
1318
- }
1319
- /**
1320
- * Internal: define a native-format plugin with full validation and normalization.
1321
- */
1322
- function defineNativePlugin(definition) {
1323
- const SIMPLE_ID = /^[a-z0-9-]+$/;
1324
- const SCOPED_ID = /^@[a-z0-9-]+\/[a-z0-9-]+$/;
1325
- const SEMVER_PATTERN = /^\d+\.\d+\.\d+/;
1326
- const { id, version, capabilities = [], allowedHosts = [], hooks = {}, routes = {}, mcp = { tools: {} }, admin = {} } = definition;
1327
- const storage = definition.storage ?? {};
1328
- 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").`);
1329
- if (!SEMVER_PATTERN.test(version)) throw new Error(`Invalid plugin version "${version}". Must be semver format (e.g., "1.0.0").`);
1330
- for (const [name, tool] of Object.entries(mcp.tools)) {
1331
- if (!MCP_TOOL_NAME_PATTERN.test(name)) throw new Error(`Invalid MCP tool name "${name}" in plugin "${id}".`);
1332
- const route = routes[tool.route];
1333
- if (!route) throw new Error(`MCP tool "${name}" references unknown route "${tool.route}".`);
1334
- if (route.public) throw new Error(`MCP tool "${name}" cannot reference a public route.`);
1335
- if (route.response === "raw") throw new Error(`MCP tool "${name}" cannot reference a raw response route.`);
1336
- if (!isJsonPostRouteContract(route)) throw new Error(`MCP tool "${name}" must reference a POST-compatible JSON route.`);
1337
- if (!route.permission) throw new Error(`MCP route "${tool.route}" must declare a permission.`);
1338
- }
1339
- for (const [kind, extensions] of [["editor panel", admin.editorPanels], ["editor action", admin.editorActions]]) for (const extension of extensions ?? []) {
1340
- const route = routes[extension.route];
1341
- if (!route) throw new Error(`Plugin ${kind} "${extension.id}" references unknown route "${extension.route}".`);
1342
- if (route.public) throw new Error(`Plugin ${kind} "${extension.id}" must reference a private route.`);
1343
- if (!isJsonPostRouteContract(route)) throw new Error(`Plugin ${kind} "${extension.id}" must reference a route that accepts POST JSON requests and returns JSON.`);
1344
- }
1345
- if ((admin.pages?.length ?? 0) > 0 || (admin.widgets?.length ?? 0) > 0) {
1346
- const adminRoute = routes.admin;
1347
- if (adminRoute && (adminRoute.public === true || !isJsonPostRouteContract(adminRoute))) throw new Error("Block Kit admin route must accept POST JSON requests and return JSON.");
1348
- }
1349
- const validCapabilities = new Set(PLUGIN_CAPABILITIES);
1350
- for (const cap of capabilities) if (!validCapabilities.has(cap)) throw new Error(`Invalid capability "${cap}" in plugin "${id}".`);
1351
- return {
1352
- id,
1353
- version,
1354
- capabilities: normalizePluginCapabilities(capabilities),
1355
- allowedHosts,
1356
- storage,
1357
- hooks: resolveHooks(hooks, id),
1358
- routes,
1359
- mcp,
1360
- admin
1361
- };
1362
- }
1363
- /**
1364
- * Resolve hooks to normalized format with defaults.
1365
- *
1366
- * PluginHooks and ResolvedPluginHooks share the same keys — each input value is
1367
- * `HookConfig<H> | H` and the output is `ResolvedHook<H>`. TS can't narrow
1368
- * the handler type through a dynamic key, so we assert at the loop boundary.
1369
- */
1370
- function resolveHooks(hooks, pluginId) {
1371
- const resolved = {};
1372
- for (const key of Object.keys(hooks)) {
1373
- const hook = hooks[key];
1374
- if (hook) resolved[key] = resolveHook(hook, pluginId);
1375
- }
1376
- return resolved;
1377
- }
1378
- /**
1379
- * Check if a hook value is a config object (has a `handler` property)
1380
- */
1381
- function isHookConfig(hook) {
1382
- return typeof hook === "object" && hook !== null && "handler" in hook;
1383
- }
1384
- /**
1385
- * Resolve a single hook to normalized format
1386
- */
1387
- function resolveHook(hook, pluginId) {
1388
- if (isHookConfig(hook)) {
1389
- if (hook.exclusive !== void 0 && typeof hook.exclusive !== "boolean") throw new Error(`Invalid "exclusive" value in hook config for plugin "${pluginId}". Must be boolean.`);
1390
- return {
1391
- priority: hook.priority ?? 100,
1392
- timeout: hook.timeout ?? 5e3,
1393
- dependencies: hook.dependencies ?? [],
1394
- errorPolicy: hook.errorPolicy ?? "abort",
1395
- exclusive: hook.exclusive ?? false,
1396
- handler: hook.handler,
1397
- pluginId
1398
- };
1399
- }
1400
- return {
1401
- priority: 100,
1402
- timeout: 5e3,
1403
- dependencies: [],
1404
- errorPolicy: "abort",
1405
- exclusive: false,
1406
- handler: hook,
1407
- pluginId
1408
- };
1409
- }
1410
-
1411
- //#endregion
1412
- //#region src/plugins/hooks.ts
1413
- /**
1414
- * Plugin Hooks System v2
1415
- *
1416
- * Uses the unified PluginContext for all hooks.
1417
- * Manages lifecycle hooks with:
1418
- * - Deterministic ordering via priority + dependencies
1419
- * - Timeout enforcement
1420
- * - Error isolation
1421
- * - Observability
1422
- *
1423
- */
1424
- const CONTENT_SAVE_HOOK_CONTEXT_KEY = Symbol.for("emdash:content-save-hook-context");
1425
- const contentSaveHookContext = globalThis[CONTENT_SAVE_HOOK_CONTEXT_KEY] ?? new AsyncLocalStorage();
1426
- globalThis[CONTENT_SAVE_HOOK_CONTEXT_KEY] = contentSaveHookContext;
1427
- function getActiveContentSaveHookName() {
1428
- return contentSaveHookContext.getStore();
1429
- }
1430
- /**
1431
- * Hook pipeline for executing hooks in order
1432
- */
1433
- var HookPipeline = class HookPipeline {
1434
- hooks = /* @__PURE__ */ new Map();
1435
- pluginMap = /* @__PURE__ */ new Map();
1436
- contextFactory = null;
1437
- /** Stored so setContextFactory can merge incrementally. */
1438
- contextFactoryOptions = {};
1439
- /** Hook names where at least one handler declared exclusive: true */
1440
- exclusiveHookNames = /* @__PURE__ */ new Set();
1441
- /**
1442
- * Selected provider plugin ID for each exclusive hook.
1443
- * Set by the PluginManager after resolution.
1444
- */
1445
- exclusiveSelections = /* @__PURE__ */ new Map();
1446
- constructor(plugins, factoryOptions) {
1447
- if (factoryOptions) {
1448
- this.contextFactory = new PluginContextFactory(factoryOptions);
1449
- this.contextFactoryOptions = { ...factoryOptions };
1450
- }
1451
- for (const plugin of plugins) this.pluginMap.set(plugin.id, plugin);
1452
- this.registerPlugins(plugins);
1453
- }
1454
- /**
1455
- * Set or update the context factory options.
1456
- *
1457
- * When called on a pipeline that already has a factory, the new options
1458
- * are merged on top of the existing ones so that callers don't need to
1459
- * repeat every field (e.g. adding `cronReschedule` without losing
1460
- * `storage` / `getUploadUrl`).
1461
- */
1462
- setContextFactory(options) {
1463
- const merged = {
1464
- ...this.contextFactoryOptions,
1465
- ...options
1466
- };
1467
- this.contextFactory = new PluginContextFactory(merged);
1468
- this.contextFactoryOptions = merged;
1469
- }
1470
- /**
1471
- * Get context for a plugin
1472
- */
1473
- getContext(pluginId) {
1474
- const plugin = this.pluginMap.get(pluginId);
1475
- if (!plugin) throw new Error(`Plugin "${pluginId}" not found`);
1476
- if (!this.contextFactory) throw new Error("Context factory not initialized - call setContextFactory first");
1477
- return this.contextFactory.createContext(plugin);
1478
- }
1479
- /**
1480
- * Get typed hooks for a specific hook name.
1481
- * The internal map stores ResolvedHook<unknown>, but we know each name
1482
- * maps to a specific handler type via HookHandlerMap.
1483
- *
1484
- * Exclusive hooks that have a selected provider are filtered out — they
1485
- * should only run via invokeExclusiveHook(), not in the regular pipeline.
1486
- */
1487
- getTypedHooks(name) {
1488
- const all = this.hooks.get(name) ?? [];
1489
- if (this.exclusiveSelections.has(name)) return all.filter((h) => !h.exclusive);
1490
- return all;
1491
- }
1492
- /**
1493
- * Register all hooks from plugins.
1494
- *
1495
- * Registers each hook name individually to preserve type safety. The
1496
- * internal map stores ResolvedHook<unknown> since it's keyed by string,
1497
- * but getTypedHooks() restores the correct handler type on retrieval.
1498
- */
1499
- registerPlugins(plugins) {
1500
- for (const plugin of plugins) {
1501
- this.registerPluginHook(plugin, "plugin:install");
1502
- this.registerPluginHook(plugin, "plugin:activate");
1503
- this.registerPluginHook(plugin, "plugin:deactivate");
1504
- this.registerPluginHook(plugin, "plugin:uninstall");
1505
- this.registerPluginHook(plugin, "content:beforeSave");
1506
- this.registerPluginHook(plugin, "content:afterSave");
1507
- this.registerPluginHook(plugin, "content:beforeDelete");
1508
- this.registerPluginHook(plugin, "content:afterDelete");
1509
- this.registerPluginHook(plugin, "content:beforePublish");
1510
- this.registerPluginHook(plugin, "content:beforeSchedule");
1511
- this.registerPluginHook(plugin, "content:beforeUnpublish");
1512
- this.registerPluginHook(plugin, "content:afterPublish");
1513
- this.registerPluginHook(plugin, "content:afterUnpublish");
1514
- this.registerPluginHook(plugin, "content:afterRestore");
1515
- this.registerPluginHook(plugin, "content:afterSchedule");
1516
- this.registerPluginHook(plugin, "content:afterUnschedule");
1517
- this.registerPluginHook(plugin, "media:beforeUpload");
1518
- this.registerPluginHook(plugin, "media:afterUpload");
1519
- this.registerPluginHook(plugin, "cron");
1520
- this.registerPluginHook(plugin, "email:beforeSend");
1521
- this.registerPluginHook(plugin, "email:deliver");
1522
- this.registerPluginHook(plugin, "email:afterSend");
1523
- this.registerPluginHook(plugin, "comment:beforeCreate");
1524
- this.registerPluginHook(plugin, "comment:moderate");
1525
- this.registerPluginHook(plugin, "comment:afterCreate");
1526
- this.registerPluginHook(plugin, "comment:afterModerate");
1527
- this.registerPluginHook(plugin, "page:metadata");
1528
- this.registerPluginHook(plugin, "page:fragments");
1529
- }
1530
- for (const [hookName, hooks] of this.hooks) this.hooks.set(hookName, this.sortHooks(hooks));
1531
- }
1532
- /**
1533
- * Maps hook names to the capability required to register them.
1534
- *
1535
- * Hooks not listed here have no capability requirement (e.g. lifecycle
1536
- * hooks, cron). Any plugin declaring a listed hook without the required
1537
- * capability will have that hook silently skipped at registration time.
1538
- */
1539
- static HOOK_REQUIRED_CAPABILITY = new Map([
1540
- ["email:beforeSend", "hooks.email-events:register"],
1541
- ["email:afterSend", "hooks.email-events:register"],
1542
- ["email:deliver", "hooks.email-transport:register"],
1543
- ["content:beforeSave", "content:write"],
1544
- ["content:afterSave", "content:read"],
1545
- ["content:beforeDelete", "content:read"],
1546
- ["content:afterDelete", "content:read"],
1547
- ["content:beforePublish", "hooks.content-policy:register"],
1548
- ["content:beforeSchedule", "hooks.content-policy:register"],
1549
- ["content:beforeUnpublish", "hooks.content-policy:register"],
1550
- ["content:afterPublish", "content:read"],
1551
- ["content:afterUnpublish", "content:read"],
1552
- ["content:afterRestore", "content:read"],
1553
- ["content:afterSchedule", "content:read"],
1554
- ["content:afterUnschedule", "content:read"],
1555
- ["media:beforeUpload", "media:write"],
1556
- ["media:afterUpload", "media:read"],
1557
- ["comment:beforeCreate", "users:read"],
1558
- ["comment:moderate", "users:read"],
1559
- ["comment:afterCreate", "users:read"],
1560
- ["comment:afterModerate", "users:read"],
1561
- ["page:fragments", "hooks.page-fragments:register"]
1562
- ]);
1563
- /**
1564
- * Register a single plugin's hook by name
1565
- */
1566
- registerPluginHook(plugin, name) {
1567
- const hook = plugin.hooks[name];
1568
- if (!hook) return;
1569
- const requiredCapability = HookPipeline.HOOK_REQUIRED_CAPABILITY.get(name);
1570
- if (requiredCapability && !plugin.capabilities.includes(requiredCapability)) {
1571
- console.warn(`[hooks] Plugin "${plugin.id}" declares ${name} hook without ${requiredCapability} capability — skipping`);
1572
- return;
1573
- }
1574
- if (hook.exclusive) this.exclusiveHookNames.add(name);
1575
- this.registerHook(name, hook);
1576
- }
1577
- /**
1578
- * Register a single hook
1579
- */
1580
- registerHook(name, hook) {
1581
- const existing = this.hooks.get(name) || [];
1582
- existing.push(hook);
1583
- this.hooks.set(name, existing);
1584
- }
1585
- /**
1586
- * Sort hooks by priority and dependencies
1587
- */
1588
- sortHooks(hooks) {
1589
- const sorted = [];
1590
- const remaining = [...hooks];
1591
- while (remaining.length > 0) {
1592
- const ready = remaining.filter((hook) => hook.dependencies.every((dep) => sorted.some((s) => s.pluginId === dep)));
1593
- if (ready.length === 0) {
1594
- const pluginIds = remaining.map((h) => h.pluginId).join(", ");
1595
- console.warn(`[hooks] Hook dependency cycle or missing dependency detected among plugins: ${pluginIds}. Falling back to priority order.`);
1596
- remaining.sort((a, b) => a.priority - b.priority);
1597
- sorted.push(...remaining);
1598
- break;
1599
- }
1600
- ready.sort((a, b) => a.priority - b.priority);
1601
- const next = ready[0];
1602
- sorted.push(next);
1603
- remaining.splice(remaining.indexOf(next), 1);
1604
- }
1605
- return sorted;
1606
- }
1607
- /**
1608
- * Execute a hook with timeout
1609
- */
1610
- async executeWithTimeout(fn, timeout) {
1611
- let timer;
1612
- const timeoutPromise = new Promise((_, reject) => timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Hook timeout after ${timeout}ms`)), timeout));
1613
- try {
1614
- return await Promise.race([fn(), timeoutPromise]);
1615
- } finally {
1616
- clearTimeout(timer);
1617
- }
1618
- }
1619
- /**
1620
- * Run plugin:install hooks
1621
- */
1622
- async runPluginInstall(pluginId) {
1623
- return this.runLifecycleHook("plugin:install", pluginId);
1624
- }
1625
- /**
1626
- * Run plugin:activate hooks
1627
- */
1628
- async runPluginActivate(pluginId) {
1629
- return this.runLifecycleHook("plugin:activate", pluginId);
1630
- }
1631
- /**
1632
- * Run plugin:deactivate hooks
1633
- */
1634
- async runPluginDeactivate(pluginId) {
1635
- return this.runLifecycleHook("plugin:deactivate", pluginId);
1636
- }
1637
- /**
1638
- * Run plugin:uninstall hooks
1639
- */
1640
- async runPluginUninstall(pluginId, deleteData) {
1641
- const hooks = this.getTypedHooks("plugin:uninstall");
1642
- const results = [];
1643
- const hook = hooks.find((h) => h.pluginId === pluginId);
1644
- if (!hook) return results;
1645
- const { handler } = hook;
1646
- const event = { deleteData };
1647
- const ctx = this.getContext(pluginId);
1648
- const start = Date.now();
1649
- try {
1650
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1651
- results.push({
1652
- success: true,
1653
- pluginId: hook.pluginId,
1654
- duration: Date.now() - start
1655
- });
1656
- } catch (error) {
1657
- results.push({
1658
- success: false,
1659
- error: error instanceof Error ? error : new Error(String(error)),
1660
- pluginId: hook.pluginId,
1661
- duration: Date.now() - start
1662
- });
1663
- }
1664
- return results;
1665
- }
1666
- async runLifecycleHook(hookName, pluginId) {
1667
- const hooks = this.getTypedHooks(hookName);
1668
- const results = [];
1669
- const hook = hooks.find((h) => h.pluginId === pluginId);
1670
- if (!hook) return results;
1671
- const { handler } = hook;
1672
- const event = {};
1673
- const ctx = this.getContext(pluginId);
1674
- const start = Date.now();
1675
- try {
1676
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1677
- results.push({
1678
- success: true,
1679
- pluginId: hook.pluginId,
1680
- duration: Date.now() - start
1681
- });
1682
- } catch (error) {
1683
- results.push({
1684
- success: false,
1685
- error: error instanceof Error ? error : new Error(String(error)),
1686
- pluginId: hook.pluginId,
1687
- duration: Date.now() - start
1688
- });
1689
- }
1690
- return results;
1691
- }
1692
- /**
1693
- * Run content:beforeSave hooks
1694
- * Returns modified content from the pipeline. `id` is the existing item's
1695
- * ID when updating. `actor` is the authenticated user that triggered the
1696
- * save, when one is available.
1697
- */
1698
- async runContentBeforeSave(content, collection, isNew, id, actor) {
1699
- const hooks = this.getTypedHooks("content:beforeSave");
1700
- const results = [];
1701
- let currentContent = content;
1702
- for (const hook of hooks) {
1703
- const { handler } = hook;
1704
- const event = {
1705
- content: currentContent,
1706
- collection,
1707
- isNew
1708
- };
1709
- if (id !== void 0) event.id = id;
1710
- if (actor !== void 0) event.actor = { ...actor };
1711
- const ctx = this.getContext(hook.pluginId);
1712
- const start = Date.now();
1713
- try {
1714
- const result = await contentSaveHookContext.run("content:beforeSave", () => this.executeWithTimeout(() => handler(event, ctx), hook.timeout));
1715
- if (result !== void 0) currentContent = result;
1716
- results.push({
1717
- success: true,
1718
- value: currentContent,
1719
- pluginId: hook.pluginId,
1720
- duration: Date.now() - start
1721
- });
1722
- } catch (error) {
1723
- results.push({
1724
- success: false,
1725
- error: error instanceof Error ? error : new Error(String(error)),
1726
- pluginId: hook.pluginId,
1727
- duration: Date.now() - start
1728
- });
1729
- if (hook.errorPolicy === "abort") throw error;
1730
- }
1731
- }
1732
- return {
1733
- content: currentContent,
1734
- results
1735
- };
1736
- }
1737
- /**
1738
- * Run content:afterSave hooks
1739
- */
1740
- async runContentAfterSave(content, collection, isNew, actor, excludePluginId) {
1741
- const hooks = this.getTypedHooks("content:afterSave");
1742
- const results = [];
1743
- for (const hook of hooks) {
1744
- if (hook.pluginId === excludePluginId) continue;
1745
- const { handler } = hook;
1746
- const event = {
1747
- content,
1748
- collection,
1749
- isNew
1750
- };
1751
- if (actor !== void 0) event.actor = { ...actor };
1752
- const ctx = this.getContext(hook.pluginId);
1753
- const start = Date.now();
1754
- try {
1755
- await contentSaveHookContext.run("content:afterSave", () => this.executeWithTimeout(() => handler(event, ctx), hook.timeout));
1756
- results.push({
1757
- success: true,
1758
- pluginId: hook.pluginId,
1759
- duration: Date.now() - start
1760
- });
1761
- } catch (error) {
1762
- results.push({
1763
- success: false,
1764
- error: error instanceof Error ? error : new Error(String(error)),
1765
- pluginId: hook.pluginId,
1766
- duration: Date.now() - start
1767
- });
1768
- if (hook.errorPolicy === "abort") throw error;
1769
- }
1770
- }
1771
- return results;
1772
- }
1773
- /**
1774
- * Run content:beforeDelete hooks
1775
- * Returns whether deletion is allowed
1776
- */
1777
- async runContentBeforeDelete(id, collection) {
1778
- const hooks = this.getTypedHooks("content:beforeDelete");
1779
- const results = [];
1780
- let allowed = true;
1781
- for (const hook of hooks) {
1782
- const { handler } = hook;
1783
- const event = {
1784
- id,
1785
- collection,
1786
- permanent: false
1787
- };
1788
- const ctx = this.getContext(hook.pluginId);
1789
- const start = Date.now();
1790
- try {
1791
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1792
- if (result === false) allowed = false;
1793
- results.push({
1794
- success: true,
1795
- value: result !== false,
1796
- pluginId: hook.pluginId,
1797
- duration: Date.now() - start
1798
- });
1799
- } catch (error) {
1800
- results.push({
1801
- success: false,
1802
- error: error instanceof Error ? error : new Error(String(error)),
1803
- pluginId: hook.pluginId,
1804
- duration: Date.now() - start
1805
- });
1806
- if (hook.errorPolicy === "abort") throw error;
1807
- }
1808
- }
1809
- return {
1810
- allowed,
1811
- results
1812
- };
1813
- }
1814
- /**
1815
- * Run content:afterDelete hooks
1816
- */
1817
- async runContentAfterDelete(id, collection, permanent) {
1818
- const hooks = this.getTypedHooks("content:afterDelete");
1819
- const results = [];
1820
- for (const hook of hooks) {
1821
- const { handler } = hook;
1822
- const event = {
1823
- id,
1824
- collection,
1825
- permanent
1826
- };
1827
- const ctx = this.getContext(hook.pluginId);
1828
- const start = Date.now();
1829
- try {
1830
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1831
- results.push({
1832
- success: true,
1833
- pluginId: hook.pluginId,
1834
- duration: Date.now() - start
1835
- });
1836
- } catch (error) {
1837
- results.push({
1838
- success: false,
1839
- error: error instanceof Error ? error : new Error(String(error)),
1840
- pluginId: hook.pluginId,
1841
- duration: Date.now() - start
1842
- });
1843
- if (hook.errorPolicy === "abort") throw error;
1844
- }
1845
- }
1846
- return results;
1847
- }
1848
- async runContentPolicy(name, event) {
1849
- if (name === "content:beforeSchedule") {
1850
- if (!("scheduledAt" in event)) throw new Error("content:beforeSchedule requires scheduledAt");
1851
- return this.runContentPolicyHooks(name, this.getTypedHooks(name), event);
1852
- }
1853
- return this.runContentPolicyHooks(name, this.getTypedHooks(name), event);
1854
- }
1855
- async runContentPolicyHooks(name, hooks, event) {
1856
- const results = [];
1857
- for (const hook of hooks) {
1858
- const ctx = this.getContext(hook.pluginId);
1859
- const start = Date.now();
1860
- try {
1861
- const decision = inspectContentPolicyDecision(await this.executeWithTimeout(() => hook.handler(event, ctx), hook.timeout));
1862
- if (decision.kind === "invalid") throw new Error(`Plugin "${hook.pluginId}" returned an invalid ${name} decision`);
1863
- results.push({
1864
- success: true,
1865
- pluginId: hook.pluginId,
1866
- duration: Date.now() - start
1867
- });
1868
- if (decision.kind === "cancel") return {
1869
- cancellation: {
1870
- pluginId: hook.pluginId,
1871
- reason: decision.reason
1872
- },
1873
- results
1874
- };
1875
- } catch (error) {
1876
- results.push({
1877
- success: false,
1878
- error: error instanceof Error ? error : new Error(String(error)),
1879
- pluginId: hook.pluginId,
1880
- duration: Date.now() - start
1881
- });
1882
- if (hook.errorPolicy === "abort") throw error;
1883
- console.error(`[content-policy] Plugin "${hook.pluginId}" failed ${name}; continuing by policy`);
1884
- }
1885
- }
1886
- return { results };
1887
- }
1888
- /**
1889
- * Run content state-change hooks that all share the same event shape.
1890
- */
1891
- async runContentStateChangeHook(name, content, collection) {
1892
- const hooks = this.getTypedHooks(name);
1893
- const results = [];
1894
- for (const hook of hooks) {
1895
- const { handler } = hook;
1896
- const event = {
1897
- content,
1898
- collection
1899
- };
1900
- const ctx = this.getContext(hook.pluginId);
1901
- const start = Date.now();
1902
- try {
1903
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1904
- results.push({
1905
- success: true,
1906
- pluginId: hook.pluginId,
1907
- duration: Date.now() - start
1908
- });
1909
- } catch (error) {
1910
- results.push({
1911
- success: false,
1912
- error: error instanceof Error ? error : new Error(String(error)),
1913
- pluginId: hook.pluginId,
1914
- duration: Date.now() - start
1915
- });
1916
- if (hook.errorPolicy === "abort") throw error;
1917
- }
1918
- }
1919
- return results;
1920
- }
1921
- /**
1922
- * Run content:afterPublish hooks (fire-and-forget).
1923
- */
1924
- async runContentAfterPublish(content, collection) {
1925
- return this.runContentStateChangeHook("content:afterPublish", content, collection);
1926
- }
1927
- /**
1928
- * Run content:afterUnpublish hooks (fire-and-forget).
1929
- */
1930
- async runContentAfterUnpublish(content, collection) {
1931
- return this.runContentStateChangeHook("content:afterUnpublish", content, collection);
1932
- }
1933
- /**
1934
- * Run content:afterRestore hooks (fire-and-forget).
1935
- */
1936
- async runContentAfterRestore(content, collection) {
1937
- return this.runContentStateChangeHook("content:afterRestore", content, collection);
1938
- }
1939
- /**
1940
- * Run content:afterSchedule hooks (fire-and-forget).
1941
- */
1942
- async runContentAfterSchedule(content, collection) {
1943
- return this.runContentStateChangeHook("content:afterSchedule", content, collection);
1944
- }
1945
- /**
1946
- * Run content:afterUnschedule hooks (fire-and-forget).
1947
- */
1948
- async runContentAfterUnschedule(content, collection) {
1949
- return this.runContentStateChangeHook("content:afterUnschedule", content, collection);
1950
- }
1951
- /**
1952
- * Run media:beforeUpload hooks
1953
- */
1954
- async runMediaBeforeUpload(file) {
1955
- const hooks = this.getTypedHooks("media:beforeUpload");
1956
- const results = [];
1957
- let currentFile = file;
1958
- for (const hook of hooks) {
1959
- const { handler } = hook;
1960
- const event = { file: currentFile };
1961
- const ctx = this.getContext(hook.pluginId);
1962
- const start = Date.now();
1963
- try {
1964
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1965
- if (result !== void 0) currentFile = result;
1966
- results.push({
1967
- success: true,
1968
- value: currentFile,
1969
- pluginId: hook.pluginId,
1970
- duration: Date.now() - start
1971
- });
1972
- } catch (error) {
1973
- results.push({
1974
- success: false,
1975
- error: error instanceof Error ? error : new Error(String(error)),
1976
- pluginId: hook.pluginId,
1977
- duration: Date.now() - start
1978
- });
1979
- if (hook.errorPolicy === "abort") throw error;
1980
- }
1981
- }
1982
- return {
1983
- file: currentFile,
1984
- results
1985
- };
1986
- }
1987
- /**
1988
- * Run media:afterUpload hooks
1989
- */
1990
- async runMediaAfterUpload(media) {
1991
- const hooks = this.getTypedHooks("media:afterUpload");
1992
- const results = [];
1993
- for (const hook of hooks) {
1994
- const { handler } = hook;
1995
- const event = { media };
1996
- const ctx = this.getContext(hook.pluginId);
1997
- const start = Date.now();
1998
- try {
1999
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2000
- results.push({
2001
- success: true,
2002
- pluginId: hook.pluginId,
2003
- duration: Date.now() - start
2004
- });
2005
- } catch (error) {
2006
- results.push({
2007
- success: false,
2008
- error: error instanceof Error ? error : new Error(String(error)),
2009
- pluginId: hook.pluginId,
2010
- duration: Date.now() - start
2011
- });
2012
- if (hook.errorPolicy === "abort") throw error;
2013
- }
2014
- }
2015
- return results;
2016
- }
2017
- /**
2018
- * Invoke the cron hook for a specific plugin.
2019
- *
2020
- * Unlike other hooks which broadcast to all plugins, the cron hook is
2021
- * dispatched only to the target plugin — the one that owns the task.
2022
- */
2023
- async invokeCronHook(pluginId, event) {
2024
- const hook = this.getTypedHooks("cron").find((h) => h.pluginId === pluginId);
2025
- if (!hook) return {
2026
- success: false,
2027
- error: /* @__PURE__ */ new Error(`Plugin "${pluginId}" has no cron hook registered`),
2028
- pluginId,
2029
- duration: 0
2030
- };
2031
- const { handler } = hook;
2032
- const ctx = this.getContext(pluginId);
2033
- const start = Date.now();
2034
- try {
2035
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2036
- return {
2037
- success: true,
2038
- pluginId,
2039
- duration: Date.now() - start
2040
- };
2041
- } catch (error) {
2042
- return {
2043
- success: false,
2044
- error: error instanceof Error ? error : new Error(String(error)),
2045
- pluginId,
2046
- duration: Date.now() - start
2047
- };
2048
- }
2049
- }
2050
- /**
2051
- * Run email:beforeSend hooks (middleware pipeline).
2052
- *
2053
- * Each handler receives the message and returns a modified message or
2054
- * `false` to cancel delivery. The pipeline chains message transformations —
2055
- * each handler receives the output of the previous one.
2056
- */
2057
- async runEmailBeforeSend(message, source) {
2058
- const hooks = this.getTypedHooks("email:beforeSend");
2059
- const results = [];
2060
- let currentMessage = message;
2061
- for (const hook of hooks) {
2062
- const { handler } = hook;
2063
- const event = {
2064
- message: { ...currentMessage },
2065
- source
2066
- };
2067
- const ctx = this.getContext(hook.pluginId);
2068
- const start = Date.now();
2069
- try {
2070
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2071
- if (result === false) {
2072
- results.push({
2073
- success: true,
2074
- value: false,
2075
- pluginId: hook.pluginId,
2076
- duration: Date.now() - start
2077
- });
2078
- return {
2079
- message: false,
2080
- results
2081
- };
2082
- }
2083
- if (result && typeof result === "object") currentMessage = result;
2084
- results.push({
2085
- success: true,
2086
- value: currentMessage,
2087
- pluginId: hook.pluginId,
2088
- duration: Date.now() - start
2089
- });
2090
- } catch (error) {
2091
- results.push({
2092
- success: false,
2093
- error: error instanceof Error ? error : new Error(String(error)),
2094
- pluginId: hook.pluginId,
2095
- duration: Date.now() - start
2096
- });
2097
- if (hook.errorPolicy === "abort") throw error;
2098
- }
2099
- }
2100
- return {
2101
- message: currentMessage,
2102
- results
2103
- };
2104
- }
2105
- /**
2106
- * Run email:afterSend hooks (fire-and-forget).
2107
- *
2108
- * Errors are logged but don't propagate — they don't affect the caller.
2109
- */
2110
- async runEmailAfterSend(message, source) {
2111
- const hooks = this.getTypedHooks("email:afterSend");
2112
- const results = [];
2113
- for (const hook of hooks) {
2114
- const { handler } = hook;
2115
- const event = {
2116
- message,
2117
- source
2118
- };
2119
- const ctx = this.getContext(hook.pluginId);
2120
- const start = Date.now();
2121
- try {
2122
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2123
- results.push({
2124
- success: true,
2125
- pluginId: hook.pluginId,
2126
- duration: Date.now() - start
2127
- });
2128
- } catch (error) {
2129
- console.error(`[email:afterSend] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2130
- results.push({
2131
- success: false,
2132
- error: error instanceof Error ? error : new Error(String(error)),
2133
- pluginId: hook.pluginId,
2134
- duration: Date.now() - start
2135
- });
2136
- }
2137
- }
2138
- return results;
2139
- }
2140
- /**
2141
- * Run comment:beforeCreate hooks (middleware pipeline).
2142
- *
2143
- * Each handler receives the event and returns a modified event or
2144
- * `false` to reject the comment. The pipeline chains transformations —
2145
- * each handler receives the output of the previous one.
2146
- */
2147
- async runCommentBeforeCreate(event) {
2148
- const hooks = this.getTypedHooks("comment:beforeCreate");
2149
- let currentEvent = event;
2150
- for (const hook of hooks) {
2151
- const { handler } = hook;
2152
- const ctx = this.getContext(hook.pluginId);
2153
- const start = Date.now();
2154
- try {
2155
- const result = await this.executeWithTimeout(() => handler({ ...currentEvent }, ctx), hook.timeout);
2156
- if (result === false) return false;
2157
- if (result && typeof result === "object") currentEvent = result;
2158
- } catch (error) {
2159
- console.error(`[comment:beforeCreate] Plugin "${hook.pluginId}" error (${Date.now() - start}ms):`, error instanceof Error ? error.message : error);
2160
- if (hook.errorPolicy === "abort") throw error;
2161
- }
2162
- }
2163
- return currentEvent;
2164
- }
2165
- /**
2166
- * Run comment:afterCreate hooks (fire-and-forget).
2167
- *
2168
- * Errors are logged but don't propagate — they don't affect the caller.
2169
- */
2170
- async runCommentAfterCreate(event) {
2171
- const hooks = this.getTypedHooks("comment:afterCreate");
2172
- for (const hook of hooks) {
2173
- const { handler } = hook;
2174
- const ctx = this.getContext(hook.pluginId);
2175
- try {
2176
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2177
- } catch (error) {
2178
- console.error(`[comment:afterCreate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2179
- }
2180
- }
2181
- }
2182
- /**
2183
- * Run comment:afterModerate hooks (fire-and-forget).
2184
- *
2185
- * Errors are logged but don't propagate — they don't affect the caller.
2186
- */
2187
- async runCommentAfterModerate(event) {
2188
- const hooks = this.getTypedHooks("comment:afterModerate");
2189
- for (const hook of hooks) {
2190
- const { handler } = hook;
2191
- const ctx = this.getContext(hook.pluginId);
2192
- try {
2193
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2194
- } catch (error) {
2195
- console.error(`[comment:afterModerate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2196
- }
2197
- }
2198
- }
2199
- /**
2200
- * Run page:metadata hooks. Each handler returns contributions that are
2201
- * merged by the metadata collector. Errors are logged but don't propagate.
2202
- */
2203
- async runPageMetadata(event) {
2204
- const hooks = this.getTypedHooks("page:metadata");
2205
- const results = [];
2206
- for (const hook of hooks) {
2207
- const { handler } = hook;
2208
- const ctx = this.getContext(hook.pluginId);
2209
- try {
2210
- const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
2211
- if (result != null) {
2212
- const contributions = Array.isArray(result) ? result : [result];
2213
- results.push({
2214
- pluginId: hook.pluginId,
2215
- contributions
2216
- });
2217
- }
2218
- } catch (error) {
2219
- console.error(`[page:metadata] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2220
- }
2221
- }
2222
- return results;
2223
- }
2224
- /**
2225
- * Run page:fragments hooks. Only trusted plugins should be registered
2226
- * for this hook. Errors are logged but don't propagate.
2227
- */
2228
- async runPageFragments(event) {
2229
- const hooks = this.getTypedHooks("page:fragments");
2230
- const results = [];
2231
- for (const hook of hooks) {
2232
- const { handler } = hook;
2233
- const ctx = this.getContext(hook.pluginId);
2234
- try {
2235
- const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
2236
- if (result != null) {
2237
- const contributions = Array.isArray(result) ? result : [result];
2238
- results.push({
2239
- pluginId: hook.pluginId,
2240
- contributions
2241
- });
2242
- }
2243
- } catch (error) {
2244
- console.error(`[page:fragments] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2245
- }
2246
- }
2247
- return results;
2248
- }
2249
- /**
2250
- * Check if any hooks are registered for a given name
2251
- */
2252
- hasHooks(name) {
2253
- const hooks = this.hooks.get(name);
2254
- return hooks !== void 0 && hooks.length > 0;
2255
- }
2256
- /**
2257
- * Get hook count for debugging
2258
- */
2259
- getHookCount(name) {
2260
- return this.hooks.get(name)?.length || 0;
2261
- }
2262
- /**
2263
- * Get all registered hook names
2264
- */
2265
- getRegisteredHooks() {
2266
- return [...this.hooks.keys()];
2267
- }
2268
- /**
2269
- * Returns hook names where at least one handler declared exclusive: true
2270
- */
2271
- getRegisteredExclusiveHooks() {
2272
- return [...this.exclusiveHookNames];
2273
- }
2274
- /**
2275
- * Check if a hook is exclusive
2276
- */
2277
- isExclusiveHook(name) {
2278
- return this.exclusiveHookNames.has(name);
2279
- }
2280
- /**
2281
- * Set the selected provider for an exclusive hook.
2282
- * Called by PluginManager after resolution.
2283
- */
2284
- setExclusiveSelection(hookName, pluginId) {
2285
- this.exclusiveSelections.set(hookName, pluginId);
2286
- }
2287
- /**
2288
- * Clear the selected provider for an exclusive hook.
2289
- */
2290
- clearExclusiveSelection(hookName) {
2291
- this.exclusiveSelections.delete(hookName);
2292
- }
2293
- /**
2294
- * Get the selected provider for an exclusive hook (if any).
2295
- */
2296
- getExclusiveSelection(hookName) {
2297
- return this.exclusiveSelections.get(hookName);
2298
- }
2299
- /**
2300
- * Get all plugins that registered a handler for a given exclusive hook.
2301
- */
2302
- getExclusiveHookProviders(hookName) {
2303
- return (this.hooks.get(hookName) ?? []).filter((h) => h.exclusive).map((h) => ({ pluginId: h.pluginId }));
2304
- }
2305
- /**
2306
- * Get all plugins that registered a non-exclusive handler for a given
2307
- * hook (e.g. `email:beforeSend`, `email:afterSend`), preserving priority
2308
- * order. Partitions with `getExclusiveHookProviders()`, which returns
2309
- * plugins whose registration is marked `exclusive: true`.
2310
- */
2311
- getHookProviders(hookName) {
2312
- return (this.hooks.get(hookName) ?? []).filter((h) => !h.exclusive).map((h) => ({ pluginId: h.pluginId }));
2313
- }
2314
- /**
2315
- * Invoke an exclusive hook — dispatch only to the selected provider.
2316
- * Returns null if no provider is selected or if the selected hook
2317
- * is not found in the pipeline.
2318
- *
2319
- * This is a generic dispatch used by the email pipeline and other
2320
- * exclusive hook consumers. The handler type is unknown — callers
2321
- * must know the expected signature.
2322
- *
2323
- * Errors are isolated: a failing handler returns an error result
2324
- * instead of propagating the exception to the caller.
2325
- */
2326
- async invokeExclusiveHook(hookName, event) {
2327
- const selectedPluginId = this.exclusiveSelections.get(hookName);
2328
- if (!selectedPluginId) return null;
2329
- const hook = (this.hooks.get(hookName) ?? []).find((h) => h.pluginId === selectedPluginId && h.exclusive);
2330
- if (!hook) return null;
2331
- const start = Date.now();
2332
- try {
2333
- const ctx = this.getContext(selectedPluginId);
2334
- const handler = hook.handler;
2335
- return {
2336
- result: await this.executeWithTimeout(() => handler(event, ctx), hook.timeout),
2337
- pluginId: selectedPluginId,
2338
- duration: Date.now() - start
2339
- };
2340
- } catch (error) {
2341
- return {
2342
- result: void 0,
2343
- pluginId: selectedPluginId,
2344
- error: error instanceof Error ? error : new Error(String(error)),
2345
- duration: Date.now() - start
2346
- };
2347
- }
2348
- }
2349
- };
2350
- /**
2351
- * Create a hook pipeline from plugins
2352
- */
2353
- function createHookPipeline(plugins, factoryOptions) {
2354
- return new HookPipeline(plugins, factoryOptions);
2355
- }
2356
- /** Options table key prefix for exclusive hook selections */
2357
- const EXCLUSIVE_HOOK_KEY_PREFIX$1 = "emdash:exclusive_hook:";
2358
- /**
2359
- * Resolve exclusive hook selections.
2360
- *
2361
- * Shared algorithm used by both PluginManager and EmDashRuntime:
2362
- * 1. If a DB selection exists and that plugin is active → keep it.
2363
- * 2. If DB selection is stale (plugin inactive/gone) → clear it.
2364
- * 3. If no selection and only one active provider → auto-select it. Fallback
2365
- * providers are not counted when another provider is active, so a single
2366
- * plugin provider is selected over a built-in fallback. A fallback
2367
- * selection is kept in memory only.
2368
- * 4. If preferred hints match an active provider → first match wins.
2369
- * 5. If multiple providers and no hint → leave unselected (admin must choose).
2370
- */
2371
- async function resolveExclusiveHooks(opts) {
2372
- const { pipeline, isActive, getOption, getOptions, setOption, deleteOption, preferredHints, fallbackProviders } = opts;
2373
- const exclusiveHookNames = pipeline.getRegisteredExclusiveHooks();
2374
- if (exclusiveHookNames.length === 0) return;
2375
- let batchedSelections;
2376
- if (getOptions) try {
2377
- batchedSelections = await getOptions(exclusiveHookNames.map((hookName) => `${EXCLUSIVE_HOOK_KEY_PREFIX$1}${hookName}`));
2378
- } catch {
2379
- return;
2380
- }
2381
- for (const hookName of exclusiveHookNames) {
2382
- const providers = pipeline.getExclusiveHookProviders(hookName);
2383
- const activeProviderIds = new Set(providers.map((p) => p.pluginId).filter((id) => isActive(id)));
2384
- const key = `${EXCLUSIVE_HOOK_KEY_PREFIX$1}${hookName}`;
2385
- let currentSelection = null;
2386
- if (batchedSelections) currentSelection = batchedSelections.get(key) ?? null;
2387
- else try {
2388
- currentSelection = await getOption(key);
2389
- } catch {
2390
- continue;
2391
- }
2392
- if (currentSelection && activeProviderIds.has(currentSelection)) {
2393
- pipeline.setExclusiveSelection(hookName, currentSelection);
2394
- continue;
2395
- }
2396
- if (currentSelection) try {
2397
- await deleteOption(key);
2398
- } catch {}
2399
- const candidates = activeProviderIds.size > 1 && fallbackProviders ? [...activeProviderIds].filter((id) => !fallbackProviders.has(id)) : [...activeProviderIds];
2400
- if (candidates.length === 1) {
2401
- const [onlyProvider] = candidates;
2402
- if (!fallbackProviders?.has(onlyProvider)) try {
2403
- await setOption(key, onlyProvider);
2404
- } catch {}
2405
- pipeline.setExclusiveSelection(hookName, onlyProvider);
2406
- continue;
2407
- }
2408
- if (preferredHints) {
2409
- let found = false;
2410
- for (const [pluginId, hooks] of preferredHints) if (hooks.includes(hookName) && activeProviderIds.has(pluginId)) {
2411
- try {
2412
- await setOption(key, pluginId);
2413
- } catch {}
2414
- pipeline.setExclusiveSelection(hookName, pluginId);
2415
- found = true;
2416
- break;
2417
- }
2418
- if (found) continue;
2419
- }
2420
- pipeline.clearExclusiveSelection(hookName);
2421
- }
2422
- }
2423
-
2424
- //#endregion
2425
- //#region src/plugins/save-rejection.ts
2426
- /**
2427
- * Thrown by a `content:beforeSave` hook to reject a save with a message
2428
- * that is safe to show to the editor. The runtime converts it into a
2429
- * structured `SAVE_REJECTED` API error; any other exception thrown by the
2430
- * hook cancels the save with a generic error that hides the exception
2431
- * message.
2432
- */
2433
- var ContentSaveRejectedError = class extends Error {
2434
- name = "ContentSaveRejectedError";
2435
- };
2436
- /**
2437
- * Matches by name as well as by prototype: bundlers can duplicate this
2438
- * module across SSR chunks, and an `instanceof` against the wrong copy of
2439
- * the class would misreport a rejection as a plugin crash.
2440
- */
2441
- function isContentSaveRejection(error) {
2442
- if (error instanceof ContentSaveRejectedError) return true;
2443
- return error instanceof Error && error.name === "ContentSaveRejectedError";
2444
- }
2445
-
2446
- //#endregion
2447
- //#region src/plugins/email.ts
2448
- /**
2449
- * Email Pipeline
2450
- *
2451
- * Orchestrates the three-stage email pipeline:
2452
- * 1. email:beforeSend hooks (middleware — transform, validate, cancel)
2453
- * 2. email:deliver hook (exclusive — exactly one provider delivers)
2454
- * 3. email:afterSend hooks (logging, analytics, fire-and-forget)
2455
- *
2456
- * Security features:
2457
- * - Recursion guard prevents re-entrant sends (e.g. plugin calling ctx.email.send from a hook)
2458
- * - System emails (source="system") bypass email:beforeSend and email:afterSend hooks entirely
2459
- * to protect auth tokens from exfiltration by plugin hooks
2460
- *
2461
- */
2462
- /** Hook name for the exclusive email delivery hook */
2463
- const EMAIL_DELIVER_HOOK = "email:deliver";
2464
- /** Source value used for auth emails (magic links, invites, password resets) */
2465
- const SYSTEM_SOURCE = "system";
2466
- /**
2467
- * Error thrown when ctx.email.send() is called but no provider is configured.
2468
- */
2469
- var EmailNotConfiguredError = class extends Error {
2470
- constructor() {
2471
- super("No email provider is configured. Install and activate an email provider plugin, then select it in Settings > Email.");
2472
- this.name = "EmailNotConfiguredError";
2473
- }
2474
- };
2475
- /**
2476
- * Error thrown when a recursive email send is detected.
2477
- */
2478
- var EmailRecursionError = class extends Error {
2479
- constructor() {
2480
- super("Recursive email send detected. A plugin hook attempted to send an email from within the email pipeline, which would cause infinite recursion.");
2481
- this.name = "EmailRecursionError";
2482
- }
2483
- };
2484
- /**
2485
- * Recursion guard using AsyncLocalStorage.
2486
- *
2487
- * EmailPipeline is a singleton (worker-lifetime cached via EmDashRuntime).
2488
- * Instance state like `sendDepth` would false-positive under concurrent
2489
- * requests because two unrelated sends would increment the same counter.
2490
- * ALS scopes the guard to the current async execution context, so concurrent
2491
- * requests each get their own independent recursion tracking.
2492
- */
2493
- const emailSendALS = new AsyncLocalStorage();
2494
- /**
2495
- * EmailPipeline orchestrates email delivery through the plugin hook system.
2496
- *
2497
- * The pipeline runs in three stages:
2498
- * 1. email:beforeSend — middleware hooks that can transform or cancel messages
2499
- * 2. email:deliver — exclusive hook dispatching to the selected provider
2500
- * 3. email:afterSend — fire-and-forget hooks for logging/analytics
2501
- */
2502
- var EmailPipeline = class {
2503
- pipeline;
2504
- constructor(pipeline) {
2505
- this.pipeline = pipeline;
2506
- }
2507
- /**
2508
- * Replace the underlying hook pipeline.
2509
- *
2510
- * Called by the runtime when rebuilding the hook pipeline after a
2511
- * plugin is enabled or disabled, so the email pipeline dispatches
2512
- * to the current set of active hooks.
2513
- */
2514
- setPipeline(pipeline) {
2515
- this.pipeline = pipeline;
2516
- }
2517
- /**
2518
- * Send an email through the full pipeline.
2519
- *
2520
- * @param message - The email to send
2521
- * @param source - Where the email originated ("system" for auth, plugin ID for plugins)
2522
- * @throws EmailNotConfiguredError if no provider is selected
2523
- * @throws EmailRecursionError if called re-entrantly from within a hook
2524
- * @throws Error if the provider handler throws
2525
- */
2526
- async send(message, source) {
2527
- const store = emailSendALS.getStore();
2528
- if (store && store.depth > 0) throw new EmailRecursionError();
2529
- const run = () => this.sendInner(message, source);
2530
- if (store) {
2531
- store.depth++;
2532
- try {
2533
- await run();
2534
- } finally {
2535
- store.depth--;
2536
- }
2537
- } else await emailSendALS.run({ depth: 1 }, run);
2538
- }
2539
- /**
2540
- * Inner send implementation, separated from the recursion guard.
2541
- */
2542
- async sendInner(message, source) {
2543
- if (!message || typeof message !== "object") throw new Error("Invalid email message: message must be an object");
2544
- if (!message.to || typeof message.to !== "string") throw new Error("Invalid email message: 'to' is required and must be a string");
2545
- if (message.cc !== void 0 && (!Array.isArray(message.cc) || message.cc.some((address) => typeof address !== "string"))) throw new Error("Invalid email message: 'cc' must be an array of strings");
2546
- if (message.replyTo !== void 0 && typeof message.replyTo !== "string") throw new Error("Invalid email message: 'replyTo' must be a string");
2547
- if (!message.subject || typeof message.subject !== "string") throw new Error("Invalid email message: 'subject' is required and must be a string");
2548
- if (!message.text || typeof message.text !== "string") throw new Error("Invalid email message: 'text' is required and must be a string");
2549
- const isSystemEmail = source === SYSTEM_SOURCE;
2550
- let finalMessage;
2551
- if (isSystemEmail) finalMessage = message;
2552
- else {
2553
- const beforeResult = await this.pipeline.runEmailBeforeSend(message, source);
2554
- if (beforeResult.message === false) {
2555
- const cancelledBy = beforeResult.results.find((r) => r.value === false)?.pluginId ?? "unknown";
2556
- console.info(`[email] Email to "${message.to}" cancelled by plugin "${cancelledBy}"`);
2557
- return;
2558
- }
2559
- finalMessage = beforeResult.message;
2560
- }
2561
- const deliverEvent = {
2562
- message: finalMessage,
2563
- source
2564
- };
2565
- const deliverResult = await this.pipeline.invokeExclusiveHook(EMAIL_DELIVER_HOOK, deliverEvent);
2566
- if (!deliverResult) throw new EmailNotConfiguredError();
2567
- if (deliverResult.error) {
2568
- console.error(`[email:deliver] Provider "${deliverResult.pluginId}" failed to send email to "${finalMessage.to}":`, deliverResult.error);
2569
- throw deliverResult.error;
2570
- }
2571
- if (!isSystemEmail) this.pipeline.runEmailAfterSend(finalMessage, source).catch((err) => console.error("[email] afterSend pipeline error:", err instanceof Error ? err.message : err));
2572
- }
2573
- /**
2574
- * Check if an email provider is configured and available.
2575
- *
2576
- * Returns true if an email:deliver provider is selected in the exclusive
2577
- * hook system. Plugins and auth code use this to decide whether to show
2578
- * "send invite" vs "copy invite link" UI.
2579
- */
2580
- isAvailable() {
2581
- return this.pipeline.getExclusiveSelection(EMAIL_DELIVER_HOOK) !== void 0;
2582
- }
2583
- };
2584
-
2585
- //#endregion
2586
- //#region src/plugins/manager.ts
2587
- /** Options table key prefix for exclusive hook DB reads via PluginManager */
2588
- const EXCLUSIVE_HOOK_KEY_PREFIX = "emdash:exclusive_hook:";
2589
- /**
2590
- * Plugin Manager v2
2591
- *
2592
- * Manages the full lifecycle of plugins and coordinates hooks/routes.
2593
- */
2594
- var PluginManager = class {
2595
- plugins = /* @__PURE__ */ new Map();
2596
- hookPipeline = null;
2597
- routeRegistry = null;
2598
- factoryOptions;
2599
- initialized = false;
2600
- constructor(options) {
2601
- this.options = options;
2602
- this.factoryOptions = {
2603
- db: options.db,
2604
- storage: options.storage,
2605
- getUploadUrl: options.getUploadUrl,
2606
- trustedProxyHeaders: options.trustedProxyHeaders
2607
- };
2608
- }
2609
- /**
2610
- * Set the email pipeline used when creating plugin contexts.
2611
- * Reinitializes routes/hooks if already initialized so ctx.email is available immediately.
2612
- */
2613
- setEmailPipeline(pipeline) {
2614
- this.factoryOptions.emailPipeline = pipeline;
2615
- if (this.initialized) this.reinitialize();
2616
- }
2617
- /**
2618
- * Register a plugin definition
2619
- * This resolves the definition and adds it to the manager, but doesn't install it
2620
- */
2621
- register(definition) {
2622
- const resolved = definePlugin(definition);
2623
- if (this.plugins.has(resolved.id)) throw new Error(`Plugin "${resolved.id}" is already registered`);
2624
- this.plugins.set(resolved.id, {
2625
- plugin: resolved,
2626
- state: "registered"
2627
- });
2628
- this.initialized = false;
2629
- return resolved;
2630
- }
2631
- /**
2632
- * Register multiple plugins
2633
- */
2634
- registerAll(definitions) {
2635
- for (const def of definitions) this.register(def);
2636
- }
2637
- /**
2638
- * Unregister a plugin
2639
- * Plugin must be inactive or just registered
2640
- */
2641
- unregister(pluginId) {
2642
- const entry = this.plugins.get(pluginId);
2643
- if (!entry) return false;
2644
- if (entry.state === "active") throw new Error(`Cannot unregister active plugin "${pluginId}". Deactivate it first.`);
2645
- this.plugins.delete(pluginId);
2646
- this.initialized = false;
2647
- return true;
2648
- }
2649
- /**
2650
- * Install a plugin (run install hooks, set up storage)
2651
- */
2652
- async install(pluginId) {
2653
- const entry = this.plugins.get(pluginId);
2654
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2655
- if (entry.state !== "registered") throw new Error(`Plugin "${pluginId}" is already installed (state: ${entry.state})`);
2656
- this.ensureInitialized();
2657
- const results = await this.hookPipeline.runPluginInstall(pluginId);
2658
- const failed = results.find((r) => !r.success);
2659
- if (failed) throw new Error(`Plugin install failed: ${failed.error?.message ?? "Unknown error"}`);
2660
- entry.state = "installed";
2661
- return results;
2662
- }
2663
- /**
2664
- * Activate a plugin (run activate hooks, enable hooks/routes)
2665
- */
2666
- async activate(pluginId) {
2667
- const entry = this.plugins.get(pluginId);
2668
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2669
- if (entry.state === "active") return [];
2670
- if (entry.state === "registered") await this.install(pluginId);
2671
- this.ensureInitialized();
2672
- const results = await this.hookPipeline.runPluginActivate(pluginId);
2673
- const failed = results.find((r) => !r.success);
2674
- if (failed) throw new Error(`Plugin activation failed: ${failed.error?.message ?? "Unknown error"}`);
2675
- entry.state = "active";
2676
- await setCronTasksEnabled(this.options.db, pluginId, true);
2677
- this.reinitialize();
2678
- await this.resolveExclusiveHooks();
2679
- return results;
2680
- }
2681
- /**
2682
- * Deactivate a plugin (run deactivate hooks, disable hooks/routes)
2683
- */
2684
- async deactivate(pluginId) {
2685
- const entry = this.plugins.get(pluginId);
2686
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2687
- if (entry.state !== "active") return [];
2688
- this.ensureInitialized();
2689
- const results = await this.hookPipeline.runPluginDeactivate(pluginId);
2690
- await setCronTasksEnabled(this.options.db, pluginId, false);
2691
- entry.state = "inactive";
2692
- this.reinitialize();
2693
- await this.resolveExclusiveHooks();
2694
- return results;
2695
- }
2696
- /**
2697
- * Uninstall a plugin (run uninstall hooks, optionally delete data)
2698
- */
2699
- async uninstall(pluginId, deleteData = false) {
2700
- const entry = this.plugins.get(pluginId);
2701
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2702
- if (entry.state === "active") await this.deactivate(pluginId);
2703
- this.ensureInitialized();
2704
- const results = await this.hookPipeline.runPluginUninstall(pluginId, deleteData);
2705
- await this.deleteCronTasks(pluginId);
2706
- this.plugins.delete(pluginId);
2707
- this.initialized = false;
2708
- await this.resolveExclusiveHooks();
2709
- return results;
2710
- }
2711
- /**
2712
- * Run content:beforeSave hooks across all active plugins
2713
- */
2714
- async runContentBeforeSave(content, collection, isNew, id, actor) {
2715
- this.ensureInitialized();
2716
- return this.hookPipeline.runContentBeforeSave(content, collection, isNew, id, actor);
2717
- }
2718
- /**
2719
- * Run content:afterSave hooks across all active plugins
2720
- */
2721
- async runContentAfterSave(content, collection, isNew, actor) {
2722
- this.ensureInitialized();
2723
- return this.hookPipeline.runContentAfterSave(content, collection, isNew, actor);
2724
- }
2725
- /**
2726
- * Run content:beforeDelete hooks across all active plugins
2727
- */
2728
- async runContentBeforeDelete(id, collection) {
2729
- this.ensureInitialized();
2730
- return this.hookPipeline.runContentBeforeDelete(id, collection);
2731
- }
2732
- /**
2733
- * Run content:afterDelete hooks across all active plugins
2734
- */
2735
- async runContentAfterDelete(id, collection, permanent) {
2736
- this.ensureInitialized();
2737
- return this.hookPipeline.runContentAfterDelete(id, collection, permanent);
2738
- }
2739
- /**
2740
- * Run content:afterPublish hooks across all active plugins
2741
- */
2742
- async runContentAfterPublish(content, collection) {
2743
- this.ensureInitialized();
2744
- return this.hookPipeline.runContentAfterPublish(content, collection);
2745
- }
2746
- /**
2747
- * Run content:afterUnpublish hooks across all active plugins
2748
- */
2749
- async runContentAfterUnpublish(content, collection) {
2750
- this.ensureInitialized();
2751
- return this.hookPipeline.runContentAfterUnpublish(content, collection);
2752
- }
2753
- /**
2754
- * Run content:afterRestore hooks across all active plugins
2755
- */
2756
- async runContentAfterRestore(content, collection) {
2757
- this.ensureInitialized();
2758
- return this.hookPipeline.runContentAfterRestore(content, collection);
2759
- }
2760
- /**
2761
- * Run content:afterSchedule hooks across all active plugins
2762
- */
2763
- async runContentAfterSchedule(content, collection) {
2764
- this.ensureInitialized();
2765
- return this.hookPipeline.runContentAfterSchedule(content, collection);
2766
- }
2767
- /**
2768
- * Run content:afterUnschedule hooks across all active plugins
2769
- */
2770
- async runContentAfterUnschedule(content, collection) {
2771
- this.ensureInitialized();
2772
- return this.hookPipeline.runContentAfterUnschedule(content, collection);
2773
- }
2774
- /**
2775
- * Run media:beforeUpload hooks across all active plugins
2776
- */
2777
- async runMediaBeforeUpload(file) {
2778
- this.ensureInitialized();
2779
- return this.hookPipeline.runMediaBeforeUpload(file);
2780
- }
2781
- /**
2782
- * Run media:afterUpload hooks across all active plugins
2783
- */
2784
- async runMediaAfterUpload(media) {
2785
- this.ensureInitialized();
2786
- return this.hookPipeline.runMediaAfterUpload(media);
2787
- }
2788
- /**
2789
- * Invoke the cron hook for a specific plugin (per-plugin dispatch).
2790
- * Used as the InvokeCronHookFn callback for CronExecutor.
2791
- */
2792
- async invokeCronHook(pluginId, event) {
2793
- this.ensureInitialized();
2794
- const result = await this.hookPipeline.invokeCronHook(pluginId, event);
2795
- if (!result.success && result.error) throw result.error;
2796
- }
2797
- /**
2798
- * Invoke a plugin route
2799
- */
2800
- async invokeRoute(pluginId, routeName, options) {
2801
- this.ensureInitialized();
2802
- return this.routeRegistry.invoke(pluginId, routeName, options);
2803
- }
2804
- /**
2805
- * Get all routes for a plugin
2806
- */
2807
- getPluginRoutes(pluginId) {
2808
- this.ensureInitialized();
2809
- return this.routeRegistry.getRoutes(pluginId);
2810
- }
2811
- /**
2812
- * Get a plugin by ID
2813
- */
2814
- getPlugin(pluginId) {
2815
- return this.plugins.get(pluginId)?.plugin;
2816
- }
2817
- /**
2818
- * Get plugin state
2819
- */
2820
- getPluginState(pluginId) {
2821
- return this.plugins.get(pluginId)?.state;
2822
- }
2823
- /**
2824
- * Get all registered plugins
2825
- */
2826
- getAllPlugins() {
2827
- return Array.from(this.plugins.values(), (entry) => ({
2828
- plugin: entry.plugin,
2829
- state: entry.state
2830
- }));
2831
- }
2832
- /**
2833
- * Get all active plugins
2834
- */
2835
- getActivePlugins() {
2836
- return [...this.plugins.values()].filter((entry) => entry.state === "active").map((entry) => entry.plugin);
2837
- }
2838
- /**
2839
- * Check if a plugin exists
2840
- */
2841
- hasPlugin(pluginId) {
2842
- return this.plugins.has(pluginId);
2843
- }
2844
- /**
2845
- * Check if a plugin is active
2846
- */
2847
- isActive(pluginId) {
2848
- return this.plugins.get(pluginId)?.state === "active";
2849
- }
2850
- /**
2851
- * Get all plugins that registered a handler for an exclusive hook.
2852
- */
2853
- getExclusiveHookProviders(hookName) {
2854
- this.ensureInitialized();
2855
- return this.hookPipeline.getExclusiveHookProviders(hookName).map((p) => {
2856
- const plugin = this.plugins.get(p.pluginId);
2857
- return {
2858
- pluginId: p.pluginId,
2859
- pluginName: plugin?.plugin.id ?? p.pluginId
2860
- };
2861
- });
2862
- }
2863
- /**
2864
- * Read the selected provider for an exclusive hook from the options table.
2865
- */
2866
- async getExclusiveHookSelection(hookName) {
2867
- return new OptionsRepository(this.options.db).get(`${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`);
2868
- }
2869
- /**
2870
- * Set the selected provider for an exclusive hook in the options table.
2871
- * Pass null to clear the selection.
2872
- */
2873
- async setExclusiveHookSelection(hookName, pluginId) {
2874
- const optionsRepo = new OptionsRepository(this.options.db);
2875
- const key = `${EXCLUSIVE_HOOK_KEY_PREFIX}${hookName}`;
2876
- if (pluginId === null) {
2877
- await optionsRepo.delete(key);
2878
- this.hookPipeline?.clearExclusiveSelection(hookName);
2879
- return;
2880
- }
2881
- const entry = this.plugins.get(pluginId);
2882
- if (!entry) throw new Error(`Plugin "${pluginId}" not found`);
2883
- if (entry.state !== "active") throw new Error(`Plugin "${pluginId}" is not active`);
2884
- await optionsRepo.set(key, pluginId);
2885
- this.hookPipeline?.setExclusiveSelection(hookName, pluginId);
2886
- }
2887
- /**
2888
- * Resolution algorithm for exclusive hooks.
2889
- *
2890
- * Delegates to the shared resolveExclusiveHooks() function.
2891
- * See hooks.ts for the full algorithm description.
2892
- */
2893
- async resolveExclusiveHooks(preferredHints) {
2894
- this.ensureInitialized();
2895
- const optionsRepo = new OptionsRepository(this.options.db);
2896
- await resolveExclusiveHooks({
2897
- pipeline: this.hookPipeline,
2898
- isActive: (pluginId) => this.isActive(pluginId),
2899
- getOption: (key) => optionsRepo.get(key),
2900
- getOptions: (keys) => optionsRepo.getMany(keys),
2901
- setOption: (key, value) => optionsRepo.set(key, value),
2902
- deleteOption: async (key) => {
2903
- await optionsRepo.delete(key);
2904
- },
2905
- preferredHints
2906
- });
2907
- }
2908
- /**
2909
- * Get all exclusive hooks with their providers and current selections.
2910
- * Used by the admin API.
2911
- */
2912
- async getExclusiveHooksInfo() {
2913
- this.ensureInitialized();
2914
- const exclusiveHookNames = this.hookPipeline.getRegisteredExclusiveHooks();
2915
- const result = [];
2916
- for (const hookName of exclusiveHookNames) {
2917
- const providers = this.hookPipeline.getExclusiveHookProviders(hookName);
2918
- const selection = await this.getExclusiveHookSelection(hookName);
2919
- result.push({
2920
- hookName,
2921
- providers,
2922
- selectedPluginId: selection
2923
- });
2924
- }
2925
- return result;
2926
- }
2927
- /**
2928
- * Initialize or reinitialize the hook pipeline and route registry
2929
- */
2930
- ensureInitialized() {
2931
- if (this.initialized) return;
2932
- const activePlugins = this.getActivePlugins();
2933
- this.hookPipeline = new HookPipeline(activePlugins, this.factoryOptions);
2934
- this.routeRegistry = new PluginRouteRegistry(this.factoryOptions);
2935
- for (const plugin of activePlugins) this.routeRegistry.register(plugin);
2936
- this.initialized = true;
2937
- }
2938
- /**
2939
- * Force reinitialization (useful after plugin state changes)
2940
- */
2941
- reinitialize() {
2942
- this.initialized = false;
2943
- this.ensureInitialized();
2944
- }
2945
- /**
2946
- * Delete all cron tasks for a plugin.
2947
- * Used during uninstall.
2948
- */
2949
- async deleteCronTasks(pluginId) {
2950
- try {
2951
- await sql`
2952
- DELETE FROM _emdash_cron_tasks
2953
- WHERE plugin_id = ${pluginId}
2954
- `.execute(this.options.db);
2955
- } catch {}
2956
- }
2957
- };
2958
- /**
2959
- * Create a plugin manager
2960
- */
2961
- function createPluginManager(options) {
2962
- return new PluginManager(options);
2963
- }
2964
-
2965
- //#endregion
2966
- //#region src/plugins/scheduler/node.ts
2967
- /** Minimum polling interval (ms) — prevents tight loops if next_run_at is in the past */
2968
- const MIN_INTERVAL_MS = 1e3;
2969
- /**
2970
- * Maximum polling interval (ms). Each wake runs the maintenance pass — stale
2971
- * lock recovery *and* the scheduled-publishing sweep + system cleanup. The cap
2972
- * is the worst-case latency for scheduled content when no plugin cron task is
2973
- * due sooner (`getNextDueTime()` only knows about cron tasks, not content
2974
- * `scheduled_at`). Held at 60s so Node publish latency matches the Cloudflare
2975
- * Cron Trigger cadence (`* * * * *`) rather than lagging up to five minutes.
2976
- */
2977
- const MAX_INTERVAL_MS = 60 * 1e3;
2978
- var NodeCronScheduler = class {
2979
- timer = null;
2980
- running = false;
2981
- systemCleanup = null;
2982
- constructor(executor) {
2983
- this.executor = executor;
2984
- }
2985
- setSystemCleanup(fn) {
2986
- this.systemCleanup = fn;
2987
- }
2988
- start() {
2989
- this.running = true;
2990
- this.arm();
2991
- }
2992
- stop() {
2993
- this.running = false;
2994
- if (this.timer) {
2995
- clearTimeout(this.timer);
2996
- this.timer = null;
2997
- }
2998
- }
2999
- reschedule() {
3000
- if (!this.running) return;
3001
- if (this.timer) {
3002
- clearTimeout(this.timer);
3003
- this.timer = null;
3004
- }
3005
- this.arm();
3006
- }
3007
- arm() {
3008
- if (!this.running) return;
3009
- this.executor.getNextDueTime().then((nextDue) => {
3010
- if (!this.running) return void 0;
3011
- let delayMs;
3012
- if (nextDue) {
3013
- const dueAt = new Date(nextDue).getTime();
3014
- delayMs = Math.max(dueAt - Date.now(), MIN_INTERVAL_MS);
3015
- delayMs = Math.min(delayMs, MAX_INTERVAL_MS);
3016
- } else delayMs = MAX_INTERVAL_MS;
3017
- this.timer = setTimeout(() => {
3018
- if (!this.running) return;
3019
- this.executeTick();
3020
- }, delayMs);
3021
- if (this.timer && typeof this.timer === "object" && "unref" in this.timer) this.timer.unref();
3022
- }).catch((error) => {
3023
- console.error("[cron:node] Failed to get next due time:", error);
3024
- if (this.running) {
3025
- this.timer = setTimeout(() => this.arm(), MAX_INTERVAL_MS);
3026
- if (this.timer && typeof this.timer === "object" && "unref" in this.timer) this.timer.unref();
3027
- }
3028
- });
3029
- }
3030
- executeTick() {
3031
- if (!this.running) return;
3032
- const tasks = [this.executor.tick(), this.executor.recoverStaleLocks()];
3033
- if (this.systemCleanup) tasks.push(this.systemCleanup());
3034
- Promise.allSettled(tasks).then((results) => {
3035
- for (const r of results) if (r.status === "rejected") console.error("[cron:node] Tick task failed:", r.reason);
3036
- }).finally(() => {
3037
- if (this.running) this.arm();
3038
- });
3039
- }
3040
- };
3041
-
3042
- //#endregion
3043
- //#region src/plugins/sandbox/noop.ts
3044
- /**
3045
- * Error thrown when attempting to use sandboxing on an unsupported platform.
3046
- */
3047
- var SandboxNotAvailableError = class extends Error {
3048
- constructor() {
3049
- super("Plugin sandboxing is not available. Configure a sandbox runner: use @emdash-cms/cloudflare/sandbox on Cloudflare, or @emdash-cms/sandbox-workerd/sandbox on Node.js (requires workerd). Without sandboxing, use trusted plugins (from config) instead.");
3050
- this.name = "SandboxNotAvailableError";
3051
- }
3052
- };
3053
- /**
3054
- * No-op sandbox runner for platforms without isolation support.
3055
- *
3056
- * - `isAvailable()` returns false
3057
- * - `load()` throws SandboxNotAvailableError
3058
- * - `terminateAll()` is a no-op
3059
- *
3060
- * This is the default runner when no platform adapter is configured.
3061
- */
3062
- var NoopSandboxRunner = class {
3063
- /**
3064
- * Always returns false - sandboxing is not available.
3065
- */
3066
- isAvailable() {
3067
- return false;
3068
- }
3069
- /**
3070
- * Always returns false - no sandbox runtime to be healthy.
3071
- */
3072
- isHealthy() {
3073
- return false;
3074
- }
3075
- /**
3076
- * Always throws - can't load sandboxed plugins without isolation.
3077
- */
3078
- async load(_manifest, _code) {
3079
- throw new SandboxNotAvailableError();
3080
- }
3081
- /**
3082
- * No-op - sandboxing not available, email callback is irrelevant.
3083
- */
3084
- setEmailSend() {}
3085
- /**
3086
- * No-op - nothing to terminate.
3087
- */
3088
- async terminateAll() {}
3089
- };
3090
- /**
3091
- * Create a no-op sandbox runner.
3092
- * This is used as the default when no platform adapter is configured.
3093
- */
3094
- function createNoopSandboxRunner(_options) {
3095
- return new NoopSandboxRunner();
3096
- }
3097
-
3098
- //#endregion
3099
- //#region src/plugins/sandbox/hook-result.ts
3100
- /** Current wire-format version for sandbox hook result envelopes. */
3101
- const SANDBOX_HOOK_RESULT_VERSION = 1;
3102
- /** Maximum editor-facing rejection reason accepted from a sandboxed plugin. */
3103
- const MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH = 500;
3104
- function isRecord(value) {
3105
- return typeof value === "object" && value !== null && !Array.isArray(value);
3106
- }
3107
- /** Validate and normalize an untrusted value returned across the sandbox boundary. */
3108
- function inspectSandboxHookResult(value) {
3109
- if (!isRecord(value) || !Object.hasOwn(value, "__emdashSandboxHookResult")) return { kind: "value" };
3110
- 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" };
3111
- const reason = value.error.reason.trim();
3112
- if (reason.length === 0 || reason.length > MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH) return { kind: "malformed" };
3113
- return {
3114
- kind: "error",
3115
- error: {
3116
- code: "SAVE_REJECTED",
3117
- reason
3118
- }
3119
- };
3120
- }
3121
-
3122
- //#endregion
3123
- //#region src/comments/ranking.ts
3124
- /**
3125
- * Comment ranking utilities (Tier 1 of the best-in-class comments RFC).
3126
- *
3127
- * Wilson score lower-bound (95% confidence) — the same primitive Reddit uses
3128
- * for its "Best" comment sort. Ranks by the statistical lower bound of the
3129
- * positive-reaction proportion rather than the raw count, so a comment with a
3130
- * couple of reactions can't outrank a heavily-reacted one until it earns
3131
- * confidence, and a late-but-popular comment still rises (submission time is
3132
- * irrelevant).
3133
- *
3134
- * Positive-only reactions (the recommended default) degrade gracefully: with
3135
- * `down = 0` the score still increases monotonically with `up` while penalising
3136
- * low-sample comments — wilson(1,0) ≈ 0.21, wilson(10,0) ≈ 0.73,
3137
- * wilson(200,0) ≈ 0.98.
3138
- */
3139
- /** z for a 95% two-sided confidence interval. */
3140
- const DEFAULT_Z = 1.96;
3141
- /** Reactions that count against a comment when both signals are in use. */
3142
- const NEGATIVE_REACTIONS = new Set(["dislike", "down"]);
3143
- /**
3144
- * Wilson score lower bound of the positive proportion.
3145
- *
3146
- * @param up count of positive reactions
3147
- * @param down count of negative reactions
3148
- * @returns a score in [0, 1]; 0 when there are no reactions
3149
- */
3150
- function wilsonLowerBound(up, down, z = DEFAULT_Z) {
3151
- const n = up + down;
3152
- if (n <= 0) return 0;
3153
- const phat = up / n;
3154
- const z2 = z * z;
3155
- const denom = 1 + z2 / n;
3156
- return (phat + z2 / (2 * n) - z * Math.sqrt((phat * (1 - phat) + z2 / (4 * n)) / n)) / denom;
3157
- }
3158
- /**
3159
- * Reduce a per-reaction count map to a single rank score via the Wilson
3160
- * lower bound. Any reaction not in {@link NEGATIVE_REACTIONS} is treated as
3161
- * positive, so the positive-only default (just `like`) works without special
3162
- * casing.
3163
- */
3164
- function reactionScore(counts) {
3165
- let up = 0;
3166
- let down = 0;
3167
- for (const [reaction, count] of Object.entries(counts)) if (NEGATIVE_REACTIONS.has(reaction)) down += count;
3168
- else up += count;
3169
- return wilsonLowerBound(up, down);
3170
- }
3171
-
3172
- //#endregion
3173
- //#region src/comments/query.ts
3174
- /**
3175
- * Get approved comments for a content item.
3176
- *
3177
- * @example
3178
- * ```ts
3179
- * import { getComments } from "emdash";
3180
- *
3181
- * const { items, total } = await getComments({
3182
- * collection: "posts",
3183
- * contentId: post.id,
3184
- * threaded: true,
3185
- * });
3186
- * ```
3187
- */
3188
- async function getComments(options) {
3189
- const sort = options.sort ?? "oldest";
3190
- const withReactions = options.reactions || sort === "best";
3191
- const threaded = options.threaded ? "t" : "f";
3192
- return cachedQuery({
3193
- namespace: CacheNamespace.COMMENTS,
3194
- key: `comments:${options.collection}:${options.contentId}:${threaded}:${withReactions ? "r" : "n"}:${sort}`,
3195
- load: async () => {
3196
- return getCommentsWithDb(await getDb(), options);
3197
- }
3198
- });
3199
- }
3200
- /**
3201
- * Get approved comments with an explicit db handle.
3202
- *
3203
- * @internal Use `getComments()` in templates. This variant is for routes
3204
- * that already have a database handle.
3205
- */
3206
- async function getCommentsWithDb(db, options) {
3207
- const repo = new CommentRepository(db);
3208
- const total = await repo.countByContent(options.collection, options.contentId, "approved");
3209
- const result = await repo.findByContent(options.collection, options.contentId, {
3210
- status: "approved",
3211
- limit: 500
3212
- });
3213
- const items = options.threaded ? CommentRepository.assembleThreads(result.items).map((c) => CommentRepository.toPublicComment(c)) : result.items.map((c) => CommentRepository.toPublicComment(c));
3214
- if (options.reactions || options.sort === "best") {
3215
- await attachReactions(db, items);
3216
- if (options.sort === "best") sortByBest(items);
3217
- }
3218
- return {
3219
- items,
3220
- total
3221
- };
3222
- }
3223
- /**
3224
- * Attach aggregate reaction counts to a list of public comments (and their
3225
- * replies), in a single batched query.
3226
- */
3227
- async function attachReactions(db, items) {
3228
- const ids = [];
3229
- for (const comment of items) {
3230
- ids.push(comment.id);
3231
- if (comment.replies) for (const reply of comment.replies) ids.push(reply.id);
3232
- }
3233
- if (ids.length === 0) return;
3234
- const counts = await new CommentReactionRepository(db).countsForComments(ids);
3235
- const assign = (comment) => {
3236
- const reactions = counts.get(comment.id);
3237
- if (reactions) comment.reactions = reactions;
3238
- };
3239
- for (const comment of items) {
3240
- assign(comment);
3241
- comment.replies?.forEach(assign);
3242
- }
3243
- }
3244
- /**
3245
- * Sort top-level comments by Wilson-scored reactions (descending), tie-broken
3246
- * by oldest-first to keep ordering stable.
3247
- */
3248
- function sortByBest(items) {
3249
- items.sort((a, b) => {
3250
- const scoreDelta = reactionScore(b.reactions ?? {}) - reactionScore(a.reactions ?? {});
3251
- if (scoreDelta !== 0) return scoreDelta;
3252
- if (a.createdAt < b.createdAt) return -1;
3253
- if (a.createdAt > b.createdAt) return 1;
3254
- return 0;
3255
- });
3256
- }
3257
- /**
3258
- * Get the count of approved comments for a content item.
3259
- *
3260
- * @example
3261
- * ```ts
3262
- * import { getCommentCount } from "emdash";
3263
- *
3264
- * const count = await getCommentCount("posts", post.id);
3265
- * ```
3266
- */
3267
- async function getCommentCount(collection, contentId) {
3268
- return getCommentCountWithDb(await getDb(), collection, contentId);
3269
- }
3270
- /**
3271
- * Get comment count with an explicit db handle.
3272
- *
3273
- * @internal Use `getCommentCount()` in templates.
3274
- */
3275
- async function getCommentCountWithDb(db, collection, contentId) {
3276
- return new CommentRepository(db).countByContent(collection, contentId, "approved");
3277
- }
3278
-
3279
- //#endregion
3280
- //#region src/menus/index.ts
3281
- /**
3282
- * Get a menu by name with resolved URLs.
3283
- *
3284
- * @example
3285
- * ```ts
3286
- * const menu = await getMenu("primary");
3287
- * const menuEs = await getMenu("primary", { locale: "es" });
3288
- * ```
3289
- */
3290
- async function getMenu(name, options = {}) {
3291
- const locale = resolveLocale(options.locale);
3292
- const trailingSlash = options.trailingSlash ?? await getHostTrailingSlash();
3293
- return requestCached(`menu:${name}:${locale ?? "*"}:${trailingSlash}`, () => cachedQuery({
3294
- namespace: CacheNamespace.MENUS,
3295
- key: `${name}:${locale ?? "*"}:${trailingSlash}`,
3296
- load: async () => {
3297
- return getMenuWithDb(name, await getDb(), {
3298
- locale,
3299
- trailingSlash
3300
- });
3301
- }
3302
- }));
3303
- }
3304
- async function getHostTrailingSlash() {
3305
- try {
3306
- return (await import("virtual:emdash/config")).default?.trailingSlash ?? "ignore";
3307
- } catch {
3308
- return "ignore";
3309
- }
3310
- }
3311
- /**
3312
- * Get menu by name with resolved URLs (with explicit db). Internal helper for
3313
- * admin routes that already have a database handle.
3314
- */
3315
- async function getMenuWithDb(name, db, options = {}) {
3316
- const chain = resolveLocaleChain(options.locale);
3317
- const selectMenu = () => db.selectFrom("_emdash_menus").selectAll().where("name", "=", name);
3318
- let menuRow;
3319
- if (chain.length === 0) menuRow = await selectMenu().orderBy("locale", "asc").executeTakeFirst();
3320
- else {
3321
- menuRow = void 0;
3322
- for (const locale of chain) {
3323
- menuRow = await selectMenu().where("locale", "=", locale).executeTakeFirst();
3324
- if (menuRow) break;
3325
- }
3326
- }
3327
- if (!menuRow) return null;
3328
- const items = await buildMenuTree(await db.selectFrom("_emdash_menu_items").selectAll().$castTo().where("menu_id", "=", menuRow.id).orderBy("sort_order", "asc").execute(), db, menuRow.locale, options.trailingSlash);
3329
- return {
3330
- id: menuRow.id,
3331
- name: menuRow.name,
3332
- label: menuRow.label,
3333
- items,
3334
- locale: menuRow.locale,
3335
- translationGroup: menuRow.translation_group
3336
- };
3337
- }
3338
- /**
3339
- * Get all menus (without items, locale-filtered — for admin list / site nav
3340
- * summaries). When no locale is configured, returns menus across all locales.
3341
- */
3342
- async function getMenus(options = {}) {
3343
- return getMenusWithDb(await getDb(), options);
3344
- }
3345
- /**
3346
- * Get all menus (with explicit db)
3347
- *
3348
- * @internal Use `getMenus()` in templates. This variant is for admin routes
3349
- * that already have a database handle.
3350
- */
3351
- async function getMenusWithDb(db, options = {}) {
3352
- const locale = resolveLocale(options.locale);
3353
- let query = db.selectFrom("_emdash_menus").select([
3354
- "id",
3355
- "name",
3356
- "label",
3357
- "locale"
3358
- ]).orderBy("name", "asc");
3359
- if (locale !== void 0) query = query.where("locale", "=", locale);
3360
- return query.execute();
3361
- }
3362
- /**
3363
- * Get a menu by name with a Workers edge-cache hint.
3364
- *
3365
- * Use the returned `cacheHint` with `Astro.cache.set()` so pages that render
3366
- * this menu can be purged automatically when the menu is edited.
3367
- */
3368
- async function getMenuWithCacheHint(name, options = {}) {
3369
- return {
3370
- data: await getMenu(name, options),
3371
- cacheHint: { tags: [menuTag(name)] }
3372
- };
3373
- }
3374
- /**
3375
- * Build a hierarchical menu tree from a flat list of items. Items are
3376
- * resolved against the given `locale` so references land on the right
3377
- * per-locale content rows.
3378
- */
3379
- async function buildMenuTree(items, db, locale, trailingSlash) {
3380
- const contentReferences = collectContentReferences(items);
3381
- const taxonomyReferences = new Set(items.flatMap((item) => item.type === "taxonomy" && item.reference_id ? [item.reference_id] : []));
3382
- const [urlPatterns, contentLookup, taxonomyLookup] = await Promise.all([
3383
- contentReferences.size > 0 ? getCollectionUrlPatterns(db, new Set(contentReferences.keys())) : /* @__PURE__ */ new Map(),
3384
- resolveContentReferences(db, contentReferences, locale),
3385
- resolveTaxonomyReferences(db, taxonomyReferences, locale)
3386
- ]);
3387
- const validItems = (await Promise.all(items.map((item) => resolveMenuItem(item, urlPatterns, contentLookup, taxonomyLookup, locale, trailingSlash)))).filter((item) => item !== null);
3388
- const itemMap = /* @__PURE__ */ new Map();
3389
- const rootItems = [];
3390
- for (const item of validItems) itemMap.set(item.id, {
3391
- ...item,
3392
- children: []
3393
- });
3394
- for (const item of items) {
3395
- const menuItem = itemMap.get(item.id);
3396
- if (!menuItem) continue;
3397
- if (item.parent_id) {
3398
- const parent = itemMap.get(item.parent_id);
3399
- if (parent) parent.children.push(menuItem);
3400
- else rootItems.push(menuItem);
3401
- } else rootItems.push(menuItem);
3402
- }
3403
- return rootItems;
3404
- }
3405
- function collectContentReferences(items) {
3406
- const references = /* @__PURE__ */ new Map();
3407
- for (const item of items) {
3408
- const reference = getContentReference(item);
3409
- if (!reference) continue;
3410
- let ids = references.get(reference.collection);
3411
- if (!ids) {
3412
- ids = /* @__PURE__ */ new Set();
3413
- references.set(reference.collection, ids);
3414
- }
3415
- ids.add(reference.id);
3416
- }
3417
- return references;
3418
- }
3419
- function getContentReference(item) {
3420
- if (item.type === "page" || item.type === "post") {
3421
- if (!item.reference_id) return null;
3422
- return {
3423
- collection: item.reference_collection || `${item.type}s`,
3424
- id: item.reference_id
3425
- };
3426
- }
3427
- if (item.type === "collection") {
3428
- if (!item.reference_collection || !item.reference_id) return null;
3429
- return {
3430
- collection: item.reference_collection,
3431
- id: item.reference_id
3432
- };
3433
- }
3434
- if (item.type !== "custom" && item.type !== "taxonomy" && item.reference_collection && item.reference_id) return {
3435
- collection: item.reference_collection,
3436
- id: item.reference_id
3437
- };
3438
- return null;
3439
- }
3440
- /**
3441
- * Look up the `url_pattern` for a set of collection slugs, request-cached so
3442
- * a page rendering several menus (header, footer, ...) only pays for the
3443
- * lookup once per distinct slug set. Callers must treat the returned map as
3444
- * read-only — it is shared across cache hits within the request.
3445
- */
3446
- function getCollectionUrlPatterns(db, collectionSlugs) {
3447
- return requestCached(`menu-collection-patterns:${[...collectionSlugs].toSorted().join(",")}`, async () => {
3448
- const rows = await db.selectFrom("_emdash_collections").select(["slug", "url_pattern"]).where("slug", "in", [...collectionSlugs]).execute();
3449
- const urlPatterns = /* @__PURE__ */ new Map();
3450
- for (const row of rows) urlPatterns.set(row.slug, row.url_pattern);
3451
- return urlPatterns;
3452
- });
3453
- }
3454
- /**
3455
- * Resolve a single menu item's URL. `reference_id` is a translation_group
3456
- * (migration 036 remapped all existing references); we look it up against
3457
- * the per-locale ec_* row or per-locale taxonomy row.
3458
- */
3459
- async function resolveMenuItem(item, urlPatterns, contentLookup, taxonomyLookup, locale, trailingSlash) {
3460
- let url;
3461
- switch (item.type) {
3462
- case "custom":
3463
- url = item.custom_url || "#";
3464
- break;
3465
- case "page":
3466
- case "post":
3467
- url = await resolveContentUrl(item.reference_collection || `${item.type}s`, item.reference_id, urlPatterns, contentLookup, locale, trailingSlash);
3468
- if (url === null) return null;
3469
- break;
3470
- case "taxonomy":
3471
- url = resolveTaxonomyUrl(item.reference_id, taxonomyLookup);
3472
- if (url === null) return null;
3473
- break;
3474
- case "collection":
3475
- if (!item.reference_collection) return null;
3476
- if (item.reference_id) {
3477
- url = await resolveContentUrl(item.reference_collection, item.reference_id, urlPatterns, contentLookup, locale, trailingSlash);
3478
- if (url === null) return null;
3479
- } else url = `/${item.reference_collection}/`;
3480
- break;
3481
- default: if (item.reference_collection && item.reference_id) {
3482
- url = await resolveContentUrl(item.reference_collection, item.reference_id, urlPatterns, contentLookup, locale, trailingSlash);
3483
- if (url === null) return null;
3484
- } else url = "#";
3485
- }
3486
- return {
3487
- id: item.id,
3488
- label: item.label,
3489
- url: sanitizeHref(url),
3490
- target: item.target || void 0,
3491
- titleAttr: item.title_attr || void 0,
3492
- cssClasses: item.css_classes || void 0,
3493
- children: []
3494
- };
3495
- }
3496
- async function resolveContentReferences(db, references, locale) {
3497
- const entries = await Promise.all(Array.from(references, async ([collection, referenceGroups]) => {
3498
- const lookup = /* @__PURE__ */ new Map();
3499
- const localized = /* @__PURE__ */ new Map();
3500
- try {
3501
- validateIdentifier(collection, "menu item collection");
3502
- for (const batch of chunks([...referenceGroups], SQL_BATCH_SIZE)) {
3503
- const result = await sql`
3504
- SELECT id, slug, published_at, locale, translation_group
3505
- FROM ${sql.ref(`ec_${collection}`)}
3506
- WHERE translation_group IN (${sql.join(batch)})
3507
- `.execute(db);
3508
- for (const row of result.rows) if (shouldPreferLocalizedRow(row, localized.get(row.translation_group), locale)) localized.set(row.translation_group, row);
3509
- }
3510
- for (const [referenceGroup, row] of localized) lookup.set(referenceGroup, {
3511
- id: row.id,
3512
- slug: row.slug,
3513
- publishedAt: row.published_at
3514
- });
3515
- const unresolved = [...referenceGroups].filter((id) => !lookup.has(id));
3516
- for (const batch of chunks(unresolved, SQL_BATCH_SIZE)) {
3517
- const result = await sql`
3518
- SELECT id, slug, published_at FROM ${sql.ref(`ec_${collection}`)}
3519
- WHERE id IN (${sql.join(batch)})
3520
- `.execute(db);
3521
- for (const row of result.rows) lookup.set(row.id, {
3522
- id: row.id,
3523
- slug: row.slug,
3524
- publishedAt: row.published_at
3525
- });
3526
- }
3527
- } catch (error) {
3528
- console.error(`Failed to resolve content URLs for ${collection}:`, error);
3529
- }
3530
- return [collection, lookup];
3531
- }));
3532
- return new Map(entries);
3533
- }
3534
- function shouldPreferLocalizedRow(candidate, existing, locale) {
3535
- if (!existing) return true;
3536
- if (candidate.locale === locale) return existing.locale !== locale || candidate.id < existing.id;
3537
- if (existing.locale === locale) return false;
3538
- return candidate.locale < existing.locale || candidate.locale === existing.locale && candidate.id < existing.id;
3539
- }
3540
- /**
3541
- * Resolve the URL for a content reference. `referenceGroup` is the content
3542
- * row's translation_group; we look up the row in the requested locale
3543
- * (falling back to the source if no translation exists so the menu link is
3544
- * still clickable).
3545
- */
3546
- async function resolveContentUrl(collection, referenceGroup, urlPatterns, contentLookup, locale, trailingSlash) {
3547
- if (!referenceGroup) return null;
3548
- const row = contentLookup.get(collection)?.get(referenceGroup);
3549
- if (!row) return null;
3550
- return resolveLocalizedContentRoutePath({
3551
- pattern: urlPatterns.get(collection) ?? null,
3552
- collection,
3553
- slug: row.slug,
3554
- id: row.id,
3555
- date: row.publishedAt,
3556
- locale,
3557
- trailingSlash
3558
- });
3559
- }
3560
- async function resolveTaxonomyReferences(db, referenceGroups, locale) {
3561
- const lookup = /* @__PURE__ */ new Map();
3562
- const localized = /* @__PURE__ */ new Map();
3563
- try {
3564
- for (const batch of chunks([...referenceGroups], SQL_BATCH_SIZE)) {
3565
- const rows = await db.selectFrom("taxonomies").select([
3566
- "id",
3567
- "name",
3568
- "slug",
3569
- "locale",
3570
- "translation_group"
3571
- ]).where("translation_group", "in", batch).$narrowType().execute();
3572
- for (const row of rows) if (shouldPreferLocalizedRow(row, localized.get(row.translation_group), locale)) localized.set(row.translation_group, row);
3573
- }
3574
- for (const [referenceGroup, row] of localized) lookup.set(referenceGroup, {
3575
- name: row.name,
3576
- slug: row.slug
3577
- });
3578
- const unresolved = [...referenceGroups].filter((id) => !lookup.has(id));
3579
- for (const batch of chunks(unresolved, SQL_BATCH_SIZE)) {
3580
- const rows = await db.selectFrom("taxonomies").select([
3581
- "id",
3582
- "name",
3583
- "slug"
3584
- ]).where("id", "in", batch).execute();
3585
- for (const row of rows) lookup.set(row.id, {
3586
- name: row.name,
3587
- slug: row.slug
3588
- });
3589
- }
3590
- } catch (error) {
3591
- console.error("Failed to resolve taxonomy URLs:", error);
3592
- }
3593
- return lookup;
3594
- }
3595
- /**
3596
- * Resolve URL for a taxonomy term reference. `referenceGroup` is the term's
3597
- * translation_group; we pick the row in the active locale (or fall back).
3598
- */
3599
- function resolveTaxonomyUrl(referenceGroup, taxonomyLookup) {
3600
- if (!referenceGroup) return null;
3601
- const taxonomy = taxonomyLookup.get(referenceGroup);
3602
- if (!taxonomy) return null;
3603
- return `/${taxonomy.name}/${taxonomy.slug}`;
3604
- }
3605
-
3606
- //#endregion
3607
- export { image as A, definePluginRoute as C, portableText as D, portableTextIdentityExtensions as E, reference as O, definePlugin as S, prosemirrorToPortableText as T, isContentSaveRejection as _, getComments as a, getActiveContentSaveHookName as b, inspectSandboxHookResult as c, createNoopSandboxRunner as d, NodeCronScheduler as f, ContentSaveRejectedError as g, EmailPipeline as h, getCommentCount as i, EmDashConfigurationError as j, file as k, NoopSandboxRunner as l, createPluginManager as m, getMenuWithCacheHint as n, MAX_SANDBOX_SAVE_REJECTION_REASON_LENGTH as o, PluginManager as p, getMenus as r, SANDBOX_HOOK_RESULT_VERSION as s, getMenu as t, SandboxNotAvailableError as u, HookPipeline as v, portableTextToProsemirror as w, resolveExclusiveHooks as x, createHookPipeline as y };
3608
- //# sourceMappingURL=menus-TsSGmSR4.mjs.map