dineway 0.2.40 → 0.2.42

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 (460) hide show
  1. package/dist/{activity-LXZdjKwI.mjs → activity-BuhkMdv8.mjs} +2 -2
  2. package/dist/{activity-events-DoqeOM8x.mjs → activity-events-DkHsy7Y0.mjs} +1 -1
  3. package/dist/{allowed-origins-B4zstd2d.mjs → allowed-origins-DASdFW-l.mjs} +1 -1
  4. package/dist/api/route-utils.d.mts +15 -12
  5. package/dist/api/route-utils.mjs +27 -20
  6. package/dist/api/schemas/index.d.mts +1 -1
  7. package/dist/api/schemas/index.mjs +10 -5
  8. package/dist/{api-CQishNjZ.mjs → api-BBXfpMJw.mjs} +41 -13
  9. package/dist/{api-tokens-CNHnKO57.mjs → api-tokens-ciHNTdN2.mjs} +1 -1
  10. package/dist/{apply-D4rZHDyg.mjs → apply-CZDKUvZ4.mjs} +62 -18
  11. package/dist/astro/index.d.mts +16 -13
  12. package/dist/astro/index.mjs +31 -5
  13. package/dist/astro/middleware/auth.d.mts +14 -11
  14. package/dist/astro/middleware/auth.mjs +8 -8
  15. package/dist/astro/middleware/redirect.mjs +10 -6
  16. package/dist/astro/middleware/request-context.mjs +5 -5
  17. package/dist/astro/middleware/seed.d.mts +1 -1
  18. package/dist/astro/middleware/seed.mjs +2 -2
  19. package/dist/astro/middleware/setup.mjs +1 -1
  20. package/dist/astro/middleware.d.mts +2 -2
  21. package/dist/astro/middleware.mjs +266 -176
  22. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +12 -7
  23. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +12 -7
  24. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +4 -4
  25. package/dist/astro/routes/api/admin/api-tokens/index.mjs +7 -7
  26. package/dist/astro/routes/api/admin/briefing.mjs +41 -22
  27. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -4
  28. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +14 -10
  29. package/dist/astro/routes/api/admin/byline-fields/index.mjs +14 -10
  30. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +14 -10
  31. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +25 -19
  32. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +25 -19
  33. package/dist/astro/routes/api/admin/bylines/index.mjs +25 -19
  34. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +20 -16
  35. package/dist/astro/routes/api/admin/comments/_id_.mjs +10 -7
  36. package/dist/astro/routes/api/admin/comments/bulk.mjs +18 -13
  37. package/dist/astro/routes/api/admin/comments/counts.mjs +10 -7
  38. package/dist/astro/routes/api/admin/comments/index.mjs +18 -13
  39. package/dist/astro/routes/api/admin/context/_id_/history.mjs +51 -39
  40. package/dist/astro/routes/api/admin/context/_id_/index.mjs +51 -39
  41. package/dist/astro/routes/api/admin/context/_id_/review.mjs +57 -44
  42. package/dist/astro/routes/api/admin/context/_id_/supersede.mjs +57 -44
  43. package/dist/astro/routes/api/admin/context/diff.mjs +56 -43
  44. package/dist/astro/routes/api/admin/context/index.mjs +57 -44
  45. package/dist/astro/routes/api/admin/context/stale.mjs +56 -43
  46. package/dist/astro/routes/api/admin/hitl-requests/_id_/index.mjs +51 -39
  47. package/dist/astro/routes/api/admin/hitl-requests/_id_/resolve.mjs +56 -43
  48. package/dist/astro/routes/api/admin/hitl-requests/index.mjs +56 -43
  49. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +52 -40
  50. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
  51. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +7 -7
  52. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +7 -7
  53. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +78 -68
  54. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +78 -68
  55. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +71 -60
  56. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +78 -67
  57. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +78 -67
  58. package/dist/astro/routes/api/admin/plugins/index.mjs +71 -60
  59. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
  60. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +71 -60
  61. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +78 -67
  62. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +71 -60
  63. package/dist/astro/routes/api/admin/plugins/updates.mjs +71 -60
  64. package/dist/astro/routes/api/admin/review-requests/_id_/image.mjs +38 -23
  65. package/dist/astro/routes/api/admin/review-requests/_id_/index.mjs +46 -36
  66. package/dist/astro/routes/api/admin/review-requests/_id_/resolve.mjs +63 -52
  67. package/dist/astro/routes/api/admin/review-requests/_id_/revoke.mjs +9 -9
  68. package/dist/astro/routes/api/admin/review-requests/index.mjs +61 -50
  69. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +71 -60
  70. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
  71. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +71 -60
  72. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +1 -1
  73. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
  74. package/dist/astro/routes/api/admin/users/_id_/index.mjs +11 -7
  75. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +3 -3
  76. package/dist/astro/routes/api/admin/users/index.mjs +12 -7
  77. package/dist/astro/routes/api/auth/dev-bypass.mjs +4 -4
  78. package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
  79. package/dist/astro/routes/api/auth/invite/complete.mjs +17 -12
  80. package/dist/astro/routes/api/auth/invite/index.mjs +14 -9
  81. package/dist/astro/routes/api/auth/invite/register-options.mjs +16 -11
  82. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  83. package/dist/astro/routes/api/auth/magic-link/send.mjs +17 -12
  84. package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
  85. package/dist/astro/routes/api/auth/me.mjs +14 -11
  86. package/dist/astro/routes/api/auth/mode.mjs +1 -1
  87. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +3 -3
  88. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +3 -3
  89. package/dist/astro/routes/api/auth/passkey/_id_.mjs +12 -7
  90. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
  91. package/dist/astro/routes/api/auth/passkey/options.mjs +19 -14
  92. package/dist/astro/routes/api/auth/passkey/register/options.mjs +16 -11
  93. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +17 -12
  94. package/dist/astro/routes/api/auth/passkey/verify.mjs +17 -12
  95. package/dist/astro/routes/api/auth/setup-token/index.mjs +6 -6
  96. package/dist/astro/routes/api/auth/setup-token/verify.mjs +2 -2
  97. package/dist/astro/routes/api/auth/signup/complete.mjs +17 -12
  98. package/dist/astro/routes/api/auth/signup/request.mjs +17 -12
  99. package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
  100. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.d.mts +14 -11
  101. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +23 -19
  102. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +23 -18
  103. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  104. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +8 -8
  105. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +8 -8
  106. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +8 -8
  107. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +25 -20
  108. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +41 -31
  109. package/dist/astro/routes/api/content/_collection_/_id_/release-readiness.mjs +14 -9
  110. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +8 -8
  111. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
  112. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +41 -31
  113. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +30 -20
  114. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  115. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +8 -8
  116. package/dist/astro/routes/api/content/_collection_/_id_.mjs +25 -14
  117. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  118. package/dist/astro/routes/api/content/_collection_/index.mjs +25 -14
  119. package/dist/astro/routes/api/content/_collection_/trash.mjs +13 -8
  120. package/dist/astro/routes/api/dashboard.mjs +21 -13
  121. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  122. package/dist/astro/routes/api/health.mjs +1 -1
  123. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  124. package/dist/astro/routes/api/import/probe.mjs +30 -23
  125. package/dist/astro/routes/api/import/wordpress/analyze.mjs +13 -10
  126. package/dist/astro/routes/api/import/wordpress/execute.d.mts +14 -11
  127. package/dist/astro/routes/api/import/wordpress/execute.mjs +58 -47
  128. package/dist/astro/routes/api/import/wordpress/media.d.mts +14 -11
  129. package/dist/astro/routes/api/import/wordpress/media.mjs +17 -14
  130. package/dist/astro/routes/api/import/wordpress/prepare.mjs +61 -48
  131. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +15 -12
  132. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +58 -45
  133. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  134. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +32 -26
  135. package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
  136. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +14 -11
  137. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +63 -52
  138. package/dist/astro/routes/api/integration/artifact.mjs +9 -9
  139. package/dist/astro/routes/api/integration/dispatch.mjs +14 -14
  140. package/dist/astro/routes/api/integrations/_provider_.mjs +9 -9
  141. package/dist/astro/routes/api/integrations/index.mjs +8 -8
  142. package/dist/astro/routes/api/manifest.mjs +5 -5
  143. package/dist/astro/routes/api/mcp.mjs +141 -93
  144. package/dist/astro/routes/api/media/_id_/confirm.mjs +15 -12
  145. package/dist/astro/routes/api/media/_id_.mjs +14 -9
  146. package/dist/astro/routes/api/media/file/_...key_.mjs +1 -1
  147. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
  148. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  149. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  150. package/dist/astro/routes/api/media/upload-url.mjs +16 -13
  151. package/dist/astro/routes/api/media.mjs +19 -16
  152. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +57 -44
  153. package/dist/astro/routes/api/menus/_name_/items.mjs +57 -44
  154. package/dist/astro/routes/api/menus/_name_/reorder.mjs +57 -44
  155. package/dist/astro/routes/api/menus/_name_/translations.mjs +57 -44
  156. package/dist/astro/routes/api/menus/_name_.mjs +57 -44
  157. package/dist/astro/routes/api/menus/index.mjs +57 -44
  158. package/dist/astro/routes/api/oauth/authorize.mjs +7 -7
  159. package/dist/astro/routes/api/oauth/device/authorize.mjs +5 -5
  160. package/dist/astro/routes/api/oauth/device/code.mjs +9 -9
  161. package/dist/astro/routes/api/oauth/device/token.mjs +8 -8
  162. package/dist/astro/routes/api/oauth/register.mjs +4 -4
  163. package/dist/astro/routes/api/oauth/token/refresh.mjs +5 -5
  164. package/dist/astro/routes/api/oauth/token/revoke.mjs +5 -5
  165. package/dist/astro/routes/api/oauth/token.mjs +6 -6
  166. package/dist/astro/routes/api/openapi.json.mjs +10 -5
  167. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +4 -4
  168. package/dist/astro/routes/api/redirects/404s/index.mjs +15 -13
  169. package/dist/astro/routes/api/redirects/404s/summary.mjs +15 -13
  170. package/dist/astro/routes/api/redirects/_id_.mjs +57 -44
  171. package/dist/astro/routes/api/redirects/index.mjs +57 -44
  172. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  173. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +2 -2
  174. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +73 -62
  175. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +73 -62
  176. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +73 -62
  177. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +73 -62
  178. package/dist/astro/routes/api/schema/collections/index.mjs +73 -62
  179. package/dist/astro/routes/api/schema/index.mjs +13 -10
  180. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +71 -60
  181. package/dist/astro/routes/api/schema/orphans/index.mjs +71 -60
  182. package/dist/astro/routes/api/search/enable.mjs +20 -13
  183. package/dist/astro/routes/api/search/index.mjs +19 -12
  184. package/dist/astro/routes/api/search/rebuild.mjs +20 -13
  185. package/dist/astro/routes/api/search/stats.mjs +12 -7
  186. package/dist/astro/routes/api/search/suggest.mjs +19 -12
  187. package/dist/astro/routes/api/sections/_slug_.mjs +57 -44
  188. package/dist/astro/routes/api/sections/index.mjs +57 -44
  189. package/dist/astro/routes/api/settings/email.mjs +5 -5
  190. package/dist/astro/routes/api/settings/reviews.mjs +11 -11
  191. package/dist/astro/routes/api/settings.mjs +57 -44
  192. package/dist/astro/routes/api/setup/admin-verify.mjs +19 -14
  193. package/dist/astro/routes/api/setup/admin.mjs +17 -12
  194. package/dist/astro/routes/api/setup/dev-bypass.mjs +44 -32
  195. package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
  196. package/dist/astro/routes/api/setup/index.mjs +47 -34
  197. package/dist/astro/routes/api/setup/status.mjs +3 -3
  198. package/dist/astro/routes/api/snapshot.mjs +9 -9
  199. package/dist/astro/routes/api/system/heartbeat.mjs +2 -2
  200. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +60 -47
  201. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +60 -47
  202. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +60 -47
  203. package/dist/astro/routes/api/taxonomies/index.mjs +60 -47
  204. package/dist/astro/routes/api/themes/preview.mjs +7 -7
  205. package/dist/astro/routes/api/typegen.mjs +4 -4
  206. package/dist/astro/routes/api/well-known/auth.mjs +3 -3
  207. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +3 -3
  208. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +3 -3
  209. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +56 -43
  210. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +57 -44
  211. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +57 -44
  212. package/dist/astro/routes/api/widget-areas/_name_.mjs +53 -41
  213. package/dist/astro/routes/api/widget-areas/index.mjs +57 -44
  214. package/dist/astro/routes/api/widget-components.mjs +2 -2
  215. package/dist/astro/routes/robots.txt.mjs +14 -9
  216. package/dist/astro/routes/sitemap-_collection_.xml.mjs +20 -16
  217. package/dist/astro/routes/sitemap.xml.mjs +19 -15
  218. package/dist/astro/session-driver.d.mts +1 -1
  219. package/dist/astro/session-driver.mjs +8 -3
  220. package/dist/astro/types.d.mts +21 -14
  221. package/dist/{atomic-authority-CnBQJ14T.mjs → atomic-authority-Bf5QZboB.mjs} +2 -2
  222. package/dist/{audit-Cl495Ze3.mjs → audit-hXJBTPY0.mjs} +1 -1
  223. package/dist/auth/providers/github.d.mts +1 -1
  224. package/dist/auth/providers/google.d.mts +1 -1
  225. package/dist/{auth-control-guard-DbjgJdlo.mjs → auth-control-guard-DpUP6Fs_.mjs} +1 -1
  226. package/dist/{authorize-DDmgmnW-.mjs → authorize-DWNOqMKq.mjs} +1 -1
  227. package/dist/{briefing-DsD-Ouwc.mjs → briefing-BShyAm_Z.mjs} +1 -1
  228. package/dist/{briefing-COw-WcYz.mjs → briefing-CaeEFvkD.mjs} +995 -7
  229. package/dist/{bundle-bhiszAui.mjs → bundle-DWn5eFKz.mjs} +2 -2
  230. package/dist/{byline-fields-D-b9CWux.d.mts → byline-fields-B7pQ3LMi.d.mts} +14 -10
  231. package/dist/{byline-fields-BKj5f3Ub.mjs → byline-fields-DRMCc0V_.mjs} +1 -1
  232. package/dist/{byline-fields-DZ46DF10.mjs → byline-fields-wWu2Cb3l.mjs} +3 -3
  233. package/dist/{byline-registry-CJihchD1.mjs → byline-registry-Caj0_gbU.mjs} +1 -1
  234. package/dist/{byline-TYk2kad6.mjs → byline-uuVB2B3E.mjs} +65 -14
  235. package/dist/{bylines-6T9iVC9j.mjs → bylines-PLlsL31L.mjs} +3 -3
  236. package/dist/{bylines-CvTSCAw9.mjs → bylines-XGlNK0Lo.mjs} +5 -5
  237. package/dist/{patterns-Ay-4KImK.mjs → cache-DsEbwFVE.mjs} +51 -1
  238. package/dist/{chunks-C8vSD_5L.mjs → chunks-Bb56aCtB.mjs} +1 -1
  239. package/dist/cli/index.mjs +486 -48
  240. package/dist/cli/plugin-kit.d.mts +14 -11
  241. package/dist/cli/plugin-kit.mjs +2 -2
  242. package/dist/client/external-auth-headers.d.mts +1 -1
  243. package/dist/client/index.d.mts +16 -13
  244. package/dist/client/index.mjs +2 -2
  245. package/dist/{client-factory-C1ZQCMog.mjs → client-factory-BLbm250o.mjs} +1 -1
  246. package/dist/{comment-DAQfUjqt.mjs → comment-BWDG1nQm.mjs} +2 -2
  247. package/dist/{comment-reaction-Dp3G7UZc.mjs → comment-reaction-B7pLTlQ7.mjs} +1 -1
  248. package/dist/{comments-BrvIaRAx.mjs → comments-xkten8nV.mjs} +1 -1
  249. package/dist/config-6R0bchVE.mjs +125 -0
  250. package/dist/{content-CIKsrvU9.mjs → content-BNeuaVCS.mjs} +302 -45
  251. package/dist/content-Dr22fzA_.mjs +390 -0
  252. package/dist/{content-refresh-BilzqcLt.mjs → content-refresh-D7wpVFJ_.mjs} +14 -8
  253. package/dist/content-storage/index.d.mts +193 -0
  254. package/dist/content-storage/index.mjs +29 -0
  255. package/dist/content-storage/store.d.mts +3 -0
  256. package/dist/content-storage/store.mjs +5 -0
  257. package/dist/{review-payload-Bap86e75.mjs → content-write-43KZZ7dz.mjs} +838 -131
  258. package/dist/{context-DAs_MZjJ.mjs → context-Cjz0y4Al.mjs} +292 -23
  259. package/dist/{context-DVTvucNb.mjs → context-DuYXPlfZ.mjs} +2 -2
  260. package/dist/{context-route-helpers-BP-UJ4u8.mjs → context-route-helpers-TP3EqxRQ.mjs} +2 -2
  261. package/dist/{dashboard-BAjWCGCP.mjs → dashboard-BquGX1ue.mjs} +4 -4
  262. package/dist/database/batch.d.mts +1 -1
  263. package/dist/database/batch.mjs +1 -1
  264. package/dist/database/d1/index.d.mts +14 -11
  265. package/dist/database/d1/index.mjs +4 -4
  266. package/dist/database/instrumentation.mjs +3 -2
  267. package/dist/db/index.d.mts +3 -3
  268. package/dist/db/index.mjs +1 -1
  269. package/dist/db/libsql.d.mts +1 -1
  270. package/dist/db/postgres.d.mts +1 -1
  271. package/dist/db/sqlite.d.mts +1 -1
  272. package/dist/{device-flow-Dh0rNlh1.mjs → device-flow-SoZh-HvN.mjs} +3 -3
  273. package/dist/{discovery-V0e0Gg8j.mjs → discovery-BwCZFUXm.mjs} +4 -4
  274. package/dist/{enrich-B7PIJ8Iy.mjs → enrich-CAMsD1aT.mjs} +1 -1
  275. package/dist/{error-B5a45Tfb.mjs → error-sL4aemcW.mjs} +2 -0
  276. package/dist/{evidence-Vnp_fQbC.mjs → evidence-1Gr8TlTf.mjs} +7 -7
  277. package/dist/{field-defs-cache-aXUeXJdC.mjs → field-defs-cache-dn5Tw79A.mjs} +4 -4
  278. package/dist/{fts-manager-BrPpYtK0.mjs → fts-manager-Zu5ITic0.mjs} +1 -1
  279. package/dist/{hitl-requests-BxMMON3s.mjs → hitl-requests-Bdab4DhO.mjs} +2 -2
  280. package/dist/{hitl-route-helpers-sdnjpx2k.mjs → hitl-route-helpers-DGMLQajA.mjs} +5 -5
  281. package/dist/hook-events-BQw73jc7.d.mts +32 -0
  282. package/dist/{import-C2-v4FCs.mjs → import-DJFlvQey.mjs} +9 -9
  283. package/dist/{index-BVGe04wF.d.mts → index-CLj17kW9.d.mts} +12 -5
  284. package/dist/index.d.mts +19 -16
  285. package/dist/index.mjs +107 -98
  286. package/dist/{integration-credentials-DMEXZU2J.mjs → integration-credentials-DpuRw1kx.mjs} +2 -2
  287. package/dist/{jsonld-wRF85RXo.d.mts → jsonld-CPijKSUe.d.mts} +2 -2
  288. package/dist/{load-DvCVppOF.mjs → load-CiRTddkJ.mjs} +1 -1
  289. package/dist/{loader-Dp6zLmQm.mjs → loader-Bq1aW12P.mjs} +16 -5
  290. package/dist/{manifest-schema-CCvogfrP.mjs → manifest-schema-DaQpgyTB.mjs} +1 -1
  291. package/dist/{mcp-reviewed-executor-B8Gbin3T.mjs → mcp-reviewed-executor-DtTnFcqC.mjs} +6 -6
  292. package/dist/media/image-endpoint.mjs +1 -1
  293. package/dist/media/index.d.mts +1 -1
  294. package/dist/media/index.mjs +2 -2
  295. package/dist/media/local-runtime.d.mts +16 -13
  296. package/dist/media/local-runtime.mjs +3 -3
  297. package/dist/{media-C5ba8fvI.mjs → media-BjH5OD-A.mjs} +1 -1
  298. package/dist/{media-allowlist-DQvscVkS.mjs → media-allowlist-C8HJ2O61.mjs} +1 -1
  299. package/dist/{menus-w5xwT-f5.mjs → menus-BXkfzNR1.mjs} +7 -7
  300. package/dist/{menus-CyNpBQrX.mjs → menus-CbBi7Ad7.mjs} +2 -2
  301. package/dist/migration-D9OY6vI9.mjs +526 -0
  302. package/dist/{migrations-CLlX25HO.mjs → migrations-BAjF60cl.mjs} +1 -1
  303. package/dist/{oauth-authorization-CdqJZUMf.mjs → oauth-authorization-CSSRMOKn.mjs} +4 -4
  304. package/dist/{oauth-clients-CHNb9MAZ.mjs → oauth-clients-DX5HIJJv.mjs} +2 -2
  305. package/dist/object-cache/memory.d.mts +1 -1
  306. package/dist/{object-cache-mxCW-Rpt.mjs → object-cache-DyI1SOBK.mjs} +3 -1
  307. package/dist/owned-metadata-C99DzQuq.mjs +69 -0
  308. package/dist/page/index.d.mts +15 -12
  309. package/dist/page/index.mjs +1 -1
  310. package/dist/{parse-THHCpJLB.mjs → parse-C6kCR1OT.mjs} +1 -1
  311. package/dist/plugin-utils.d.mts +14 -11
  312. package/dist/plugins/adapt-sandbox-entry.d.mts +14 -11
  313. package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
  314. package/dist/{plugins-pfraURNp.mjs → plugins-LtyuDuIb.mjs} +16 -962
  315. package/dist/{policy-D2USlibj.mjs → policy-Drg5yr1-.mjs} +2 -2
  316. package/dist/{preview-Bh7D7F27.mjs → preview-CWiIjMDi.mjs} +2 -2
  317. package/dist/{provider-loader-DT7vQ5FI.d.mts → provider-loader-oLKm1AU8.d.mts} +1 -1
  318. package/dist/{public-url-Ccv0Xmue.d.mts → public-url-CEC1vj02.d.mts} +2 -2
  319. package/dist/{public-url-CG5YbNqB.d.mts → public-url-cMnsBUZB.d.mts} +1 -1
  320. package/dist/{publication-authorization-B_HJSnzR.mjs → publication-authorization-CJ4Jr5Hg.mjs} +43 -17
  321. package/dist/{query-xspvw7Ui.mjs → query-CLWTwcTr.mjs} +14 -14
  322. package/dist/{query-DLeahg3x.mjs → query-CP9M8xxX.mjs} +4 -4
  323. package/dist/{rate-limit-BsBr_U9g.mjs → rate-limit-DeVLLe4z.mjs} +2 -2
  324. package/dist/{redirect-BQFa1THe.mjs → redirect-CJ-FAbNK.mjs} +2 -2
  325. package/dist/{redirects-DJcsgz_X.mjs → redirects-BKi6mek4.mjs} +4 -5
  326. package/dist/{redirects-CVfxefrz.mjs → redirects-I78-ZYLV.mjs} +5 -386
  327. package/dist/{registry-Dclv9iHv.mjs → registry-B-HULaJI.mjs} +7 -7
  328. package/dist/{release-Da2UFygt.mjs → release-D615eKav.mjs} +173 -22
  329. package/dist/request-context.d.mts +30 -0
  330. package/dist/{request-meta-CjORiJQ_.mjs → request-meta-DZYuLXx_.mjs} +1 -1
  331. package/dist/review-payload-Bhi52CbI.mjs +112 -0
  332. package/dist/{review-requests-CcSUTm_l.mjs → review-requests-CGQ1u7uY.mjs} +2 -2
  333. package/dist/{review-requests-CUVn0RBl.mjs → review-requests-DZYM51yI.mjs} +2 -2
  334. package/dist/{review-route-helpers-CKBfGKCi.mjs → review-route-helpers-DXNDyx_q.mjs} +2 -2
  335. package/dist/{revision-W6FDfDqx.mjs → revision-DlxUfOD5.mjs} +42 -7
  336. package/dist/revisions-qNkae-Dq.mjs +57 -0
  337. package/dist/{revocation-C_ZQvGRT.mjs → revocation-4we8kfBg.mjs} +2 -2
  338. package/dist/{runner-CRU7BXjr.mjs → runner-CuG8o1uW.mjs} +558 -487
  339. package/dist/{runner-SoP1rphP.d.mts → runner-DXQkyPeX.d.mts} +1 -1
  340. package/dist/{runs-BtaAiLTw.mjs → runs-BjgLfqCn.mjs} +5 -5
  341. package/dist/runtime-Bs2JMbb2.d.mts +45 -0
  342. package/dist/runtime-Ch5G-tnG.mjs +400 -0
  343. package/dist/runtime.d.mts +15 -12
  344. package/dist/runtime.mjs +9 -4
  345. package/dist/schema-DVeOJpqA.mjs +8 -0
  346. package/dist/{search-BI9uKr7U.mjs → search-zMoM2_uq.mjs} +4 -98
  347. package/dist/{secrets-D_pergcD.mjs → secrets-CIYcw9T9.mjs} +4 -4
  348. package/dist/{sections-BqqYq9RW.mjs → sections-BtO0Zdv5.mjs} +2 -2
  349. package/dist/seed/index.d.mts +2 -2
  350. package/dist/seed/index.mjs +38 -26
  351. package/dist/seo/index.d.mts +3 -3
  352. package/dist/seo/index.mjs +12 -9
  353. package/dist/{seo-B-5PsaJO.mjs → seo-DwcULb78.mjs} +1 -1
  354. package/dist/{seo-Bs_DUxJf.mjs → seo-uliFa7s-.mjs} +44 -5
  355. package/dist/{service-W2xuGLgw.mjs → service-BBJM08uD.mjs} +2 -2
  356. package/dist/{service-B65aJsN7.mjs → service-CkMuD5AE.mjs} +3 -3
  357. package/dist/{settings-CyJ2-MKx.mjs → settings-D31Y4msD.mjs} +2 -2
  358. package/dist/{settings-DsBzKeUQ.mjs → settings-DDOB3gW1.mjs} +7 -7
  359. package/dist/{setup-complete-t9yamqBb.mjs → setup-complete-5GxB7hiF.mjs} +1 -1
  360. package/dist/{site-activity-DU0UPDji.mjs → site-activity-hpfJkmxQ.mjs} +1 -1
  361. package/dist/{site-context-Dic2jHuw.mjs → site-context-D3AmDdpQ.mjs} +15 -15
  362. package/dist/{site-url-Tw6CfBB2.mjs → site-url-CYatfe3q.mjs} +1 -1
  363. package/dist/{state-jx6Yiwsm.mjs → state-ClG1I4wl.mjs} +1 -1
  364. package/dist/storage/local.d.mts +1 -1
  365. package/dist/storage/local.mjs +1 -1
  366. package/dist/storage/s3.d.mts +1 -1
  367. package/dist/storage/s3.mjs +2 -2
  368. package/dist/{store-32e6dfD-.mjs → store-BzaAtszy.mjs} +3 -3
  369. package/dist/submission-DgLES24O.mjs +205 -0
  370. package/dist/{taxonomies-BFsUR7kc.mjs → taxonomies-B4hE8Yb3.mjs} +3 -3
  371. package/dist/{taxonomies-lWGNLKgn.mjs → taxonomies-BI26Bk-M.mjs} +7 -7
  372. package/dist/{taxonomy-DN6i1upz.mjs → taxonomy-B8w8F2Cs.mjs} +53 -3
  373. package/dist/terms-EskuqbKE.mjs +104 -0
  374. package/dist/text-extraction-CdqMGYQK.mjs +96 -0
  375. package/dist/{tokens-D-StaTAQ.mjs → tokens-D8HEH277.mjs} +1 -1
  376. package/dist/{trusted-proxy-hYufGFPK.mjs → trusted-proxy-Dg3U9Lrv.mjs} +1 -1
  377. package/dist/{types-D5JfvPvx.d.mts → types-0gRlZbhN.d.mts} +88 -32
  378. package/dist/{types-RFzE_V1M.mjs → types-BI3ULB3A.mjs} +2 -2
  379. package/dist/{types-B--VyN3n.d.mts → types-Dpv_MvwZ.d.mts} +1 -1
  380. package/dist/{types-CgcOeaiQ.d.mts → types-ex-UrNlz.d.mts} +1 -1
  381. package/dist/types-qOEot0UQ.d.mts +83 -0
  382. package/dist/ui/server-runtime.d.mts +18 -15
  383. package/dist/ui/server-runtime.mjs +29 -25
  384. package/dist/{user-Btai9rl3.mjs → user-Bl2_8rhJ.mjs} +2 -2
  385. package/dist/{utils-CYxGuO_P.mjs → utils-CklSLz9F.mjs} +2 -2
  386. package/dist/{validate-C05z0m7M.mjs → validate-C-yk7mmX.mjs} +3 -3
  387. package/dist/{validate-kmN2lS8H.d.mts → validate-DUscf6VG.d.mts} +3 -3
  388. package/dist/version-Co258u70.mjs +6 -0
  389. package/dist/version-store-BXv2D0de.mjs +208 -0
  390. package/dist/version-store-B_THJCc0.d.mts +98 -0
  391. package/dist/{widgets-BOrDZdQ3.mjs → widgets-B99mnftw.mjs} +3 -3
  392. package/dist/{wordpress-slugs-ROzITIBK.mjs → wordpress-slugs-yaeD7cxn.mjs} +1 -1
  393. package/dist/{worker-CKU70ODm.mjs → worker-DdI-KtvF.mjs} +10 -10
  394. package/dist/write-intent-DuHVqks9.mjs +108 -0
  395. package/dist/{zod-generator-DkrWuID7.mjs → zod-generator-B5Pt8fv0.mjs} +2 -2
  396. package/package.json +16 -4
  397. package/dist/cache-B5NSHhxG.mjs +0 -52
  398. package/dist/cron-C7HCJPPl.mjs +0 -271
  399. package/dist/schema-CosVhHJt.mjs +0 -8
  400. package/dist/submission-DJmRejGR.mjs +0 -411
  401. package/dist/version-CISd4wX_.mjs +0 -6
  402. /package/dist/{actor-DxUAJgQX.mjs → actor-D0AW80ld.mjs} +0 -0
  403. /package/dist/{adapter-symbols-Bq3JsWGM.d.mts → adapter-symbols-B9mi-BUh.d.mts} +0 -0
  404. /package/dist/{adapters-C8nRpUuj.d.mts → adapters-lDnJjNDz.d.mts} +0 -0
  405. /package/dist/{api-tokens-0N3nafqZ.mjs → api-tokens-CdfsE9PL.mjs} +0 -0
  406. /package/dist/{base64-Cz-aU0X1.mjs → base64-qvSs0Gxy.mjs} +0 -0
  407. /package/dist/{challenge-store-DFGsDtCj.mjs → challenge-store-Dq5HiMO3.mjs} +0 -0
  408. /package/dist/{components-rFN8NH3N.mjs → components-JA6tFHmE.mjs} +0 -0
  409. /package/dist/{context-types-CPWAJRs5.mjs → context-types-DDIJhGLs.mjs} +0 -0
  410. /package/dist/{default-BS6VQRkB.mjs → default-C2azCFSB.mjs} +0 -0
  411. /package/dist/{email-console-GqK6hgMJ.mjs → email-console-BYQp_5Qr.mjs} +0 -0
  412. /package/dist/{escape-CE7xOWzJ.mjs → escape-4_NNa6GR.mjs} +0 -0
  413. /package/dist/{experimental-workflows-BbxpWwBy.mjs → experimental-workflows-CPNiI2EL.mjs} +0 -0
  414. /package/dist/{forgeway-account-DcTxh3Gw.mjs → forgeway-account-7N-3srH-.mjs} +0 -0
  415. /package/dist/{hash-D2Rqd2J2.mjs → hash-qSYPMJ8w.mjs} +0 -0
  416. /package/dist/{media-url-D9kdpoLS.mjs → media-url-D5E1a47B.mjs} +0 -0
  417. /package/dist/{mime-BnVhH671.mjs → mime-FkfazULS.mjs} +0 -0
  418. /package/dist/{mode-BJwb_MgK.mjs → mode-B_m1BGFh.mjs} +0 -0
  419. /package/dist/{normalize-aTwryvvi.mjs → normalize-DrmlLn40.mjs} +0 -0
  420. /package/dist/{oauth-authority-P5YMSk2z.mjs → oauth-authority-DVlLFhsZ.mjs} +0 -0
  421. /package/dist/{oauth-state-store-CMqLdo4I.mjs → oauth-state-store-nf-78RbK.mjs} +0 -0
  422. /package/dist/{options-JiLWB6Bt.mjs → options-yFkLUuTw.mjs} +0 -0
  423. /package/dist/{output-7HDrYTSQ.mjs → output-B1GiXeT8.mjs} +0 -0
  424. /package/dist/{parser-kettsjWc.mjs → parser-CTlxybRo.mjs} +0 -0
  425. /package/dist/{passkey-config-DVzQ3dv3.mjs → passkey-config-BLon3ct9.mjs} +0 -0
  426. /package/dist/{placeholder-DJLP_HY7.d.mts → placeholder-DdZV3I8x.d.mts} +0 -0
  427. /package/dist/{portable-text-BE7nszX6.d.mts → portable-text-HNmwL-7L.d.mts} +0 -0
  428. /package/dist/{portable-text-tQhvPLf1.mjs → portable-text-p0Ojfpfo.mjs} +0 -0
  429. /package/dist/{process-cache-C19OA3am.mjs → process-cache-CMy5M80h.mjs} +0 -0
  430. /package/dist/{provider-loader-DERzBMUz.mjs → provider-loader-DlaT1usE.mjs} +0 -0
  431. /package/dist/{public-discovery-BGyhuD5U.mjs → public-discovery-BnqYofSK.mjs} +0 -0
  432. /package/dist/{public-url-DFXUU6Wp.mjs → public-url-BHjYWuaN.mjs} +0 -0
  433. /package/dist/{public-url-sR8SVmTt.mjs → public-url-GQygrYmg.mjs} +0 -0
  434. /package/dist/{redirect-BxacnBYL.mjs → redirect-CokmLN5o.mjs} +0 -0
  435. /package/dist/{request-cache-8_ifFzVw.mjs → request-cache-CizvDoxV.mjs} +0 -0
  436. /package/dist/{resolve-DEKC4qVa.mjs → resolve-BxFGSKYu.mjs} +0 -0
  437. /package/dist/{runtime-env-CPTzh0mZ.mjs → runtime-env-DpYGy4pT.mjs} +0 -0
  438. /package/dist/{scheduled-publish-BxdShRGs.d.mts → scheduled-publish-eCNGpvNm.d.mts} +0 -0
  439. /package/dist/{seo-contributions-LEFs1d7w.mjs → seo-contributions-ZKqrqsdT.mjs} +0 -0
  440. /package/dist/{service-kQ5ljRzX.mjs → service-DeX1PRNt.mjs} +0 -0
  441. /package/dist/{session-user-B8yYh0g5.mjs → session-user-B0XMp1GC.mjs} +0 -0
  442. /package/dist/{setup-nonce-B6A5Y1ea.mjs → setup-nonce-B9IO7PbK.mjs} +0 -0
  443. /package/dist/{sidecar-client-BwPhhz-F.mjs → sidecar-client-2hx5G46s.mjs} +0 -0
  444. /package/dist/{slugify-kD31VIv2.mjs → slugify-DvoaEPtL.mjs} +0 -0
  445. /package/dist/{ssrf-C9dyjU8O.mjs → ssrf-DcD8vn3E.mjs} +0 -0
  446. /package/dist/{stable-hash-B9Tbb2f_.mjs → stable-hash-9RDJgfif.mjs} +0 -0
  447. /package/dist/{status-Bjf_uSrW.mjs → status-B2xUokyJ.mjs} +0 -0
  448. /package/dist/{transport-BrU1aDY5.mjs → transport-BK_me2MZ.mjs} +0 -0
  449. /package/dist/{transport-CZbtxgKZ.d.mts → transport-CVU5rp7W.d.mts} +0 -0
  450. /package/dist/{types-DNBL-4Sn.mjs → types-B3Uq7Czg.mjs} +0 -0
  451. /package/dist/{types-DsJTXStN.d.mts → types-BJztoTbF.d.mts} +0 -0
  452. /package/dist/{types-COvyXIp7.mjs → types-BgUxCuwu.mjs} +0 -0
  453. /package/dist/{types-KFzuijKE.d.mts → types-C0heD9oI.d.mts} +0 -0
  454. /package/dist/{types-B03h5jt_.d.mts → types-DheoByey.d.mts} +0 -0
  455. /package/dist/{types-SlLXjRpg.d.mts → types-I5LHzk_M.d.mts} +0 -0
  456. /package/dist/{types-PLJ9hlhh.mjs → types-Nm0cMxEh.mjs} +0 -0
  457. /package/dist/{types-CtGSEKEJ.d.mts → types-PxxPTFSl.d.mts} +0 -0
  458. /package/dist/{url-DGG3hw_h.mjs → url-Coamqvs4.mjs} +0 -0
  459. /package/dist/{url-DUz3LbCs.mjs → url-dn4mFfCI.mjs} +0 -0
  460. /package/dist/{workers-build-BkmPhclj.mjs → workers-build-XNBt1wGF.mjs} +0 -0
@@ -1,12 +1,12 @@
1
1
  import { r as validatePluginIdentifier, t as validateIdentifier } from "./validate-Co3j6T_K.mjs";
2
- import { i as encodeBase64url, n as decodeBase64url } from "./base64-Cz-aU0X1.mjs";
3
- import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-C8vSD_5L.mjs";
4
- import { t as OptionsRepository } from "./options-JiLWB6Bt.mjs";
5
- import { n as createPluginContext, t as PluginContextFactory } from "./context-DAs_MZjJ.mjs";
6
- import { t as readRuntimeEnv } from "./runtime-env-CPTzh0mZ.mjs";
7
- import { i as parseEncryptionKeys, t as DinewaySecretsError } from "./secrets-D_pergcD.mjs";
8
- import { t as extractRequestMeta } from "./request-meta-CjORiJQ_.mjs";
9
- import { r as setCronTasksEnabled } from "./cron-C7HCJPPl.mjs";
2
+ import { t as readRuntimeEnv } from "./runtime-env-DpYGy4pT.mjs";
3
+ import { i as encodeBase64url, n as decodeBase64url } from "./base64-qvSs0Gxy.mjs";
4
+ import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-Bb56aCtB.mjs";
5
+ import { t as OptionsRepository } from "./options-yFkLUuTw.mjs";
6
+ import { a as setCronTasksEnabled, n as createPluginContext, t as PluginContextFactory } from "./context-Cjz0y4Al.mjs";
7
+ import { d as HookPipeline, p as resolveExclusiveHooks } from "./briefing-CaeEFvkD.mjs";
8
+ import { i as parseEncryptionKeys, t as DinewaySecretsError } from "./secrets-CIYcw9T9.mjs";
9
+ import { t as extractRequestMeta } from "./request-meta-DZYuLXx_.mjs";
10
10
  import { AsyncLocalStorage } from "node:async_hooks";
11
11
  import { sql } from "kysely";
12
12
  import { ulid } from "ulidx";
@@ -1425,8 +1425,10 @@ function isHookConfig(hook) {
1425
1425
  */
1426
1426
  function resolveHook(hook, pluginId) {
1427
1427
  if (isHookConfig(hook)) {
1428
+ if (hook.idempotent !== void 0 && typeof hook.idempotent !== "boolean") throw new Error(`Invalid idempotent hook declaration in plugin ${pluginId}.`);
1428
1429
  if (hook.exclusive !== void 0 && typeof hook.exclusive !== "boolean") throw new Error(`Invalid "exclusive" value in hook config for plugin "${pluginId}". Must be boolean.`);
1429
1430
  return {
1431
+ ...hook.idempotent !== void 0 ? { idempotent: hook.idempotent } : {},
1430
1432
  priority: hook.priority ?? 100,
1431
1433
  timeout: hook.timeout ?? 5e3,
1432
1434
  dependencies: hook.dependencies ?? [],
@@ -1447,957 +1449,6 @@ function resolveHook(hook, pluginId) {
1447
1449
  };
1448
1450
  }
1449
1451
 
1450
- //#endregion
1451
- //#region src/plugins/hooks.ts
1452
- /**
1453
- * Plugin Hooks System v2
1454
- *
1455
- * Uses the unified PluginContext for all hooks.
1456
- * Manages lifecycle hooks with:
1457
- * - Deterministic ordering via priority + dependencies
1458
- * - Timeout enforcement
1459
- * - Error isolation
1460
- * - Observability
1461
- *
1462
- */
1463
- /**
1464
- * Hook pipeline for executing hooks in order
1465
- */
1466
- var HookPipeline = class HookPipeline {
1467
- hooks = /* @__PURE__ */ new Map();
1468
- pluginMap = /* @__PURE__ */ new Map();
1469
- contextFactory = null;
1470
- /** Stored so setContextFactory can merge incrementally. */
1471
- contextFactoryOptions = {};
1472
- /** Hook names where at least one handler declared exclusive: true */
1473
- exclusiveHookNames = /* @__PURE__ */ new Set();
1474
- /**
1475
- * Selected provider plugin ID for each exclusive hook.
1476
- * Set by the PluginManager after resolution.
1477
- */
1478
- exclusiveSelections = /* @__PURE__ */ new Map();
1479
- constructor(plugins, factoryOptions) {
1480
- if (factoryOptions) {
1481
- this.contextFactory = new PluginContextFactory(factoryOptions);
1482
- this.contextFactoryOptions = { ...factoryOptions };
1483
- }
1484
- for (const plugin of plugins) this.pluginMap.set(plugin.id, plugin);
1485
- this.registerPlugins(plugins);
1486
- }
1487
- /**
1488
- * Set or update the context factory options.
1489
- *
1490
- * When called on a pipeline that already has a factory, the new options
1491
- * are merged on top of the existing ones so that callers don't need to
1492
- * repeat every field (e.g. adding `cronReschedule` without losing
1493
- * `storage` / `getUploadUrl`).
1494
- */
1495
- setContextFactory(options) {
1496
- const merged = {
1497
- ...this.contextFactoryOptions,
1498
- ...options
1499
- };
1500
- this.contextFactory = new PluginContextFactory(merged);
1501
- this.contextFactoryOptions = merged;
1502
- }
1503
- /**
1504
- * Get context for a plugin
1505
- */
1506
- getContext(pluginId) {
1507
- const plugin = this.pluginMap.get(pluginId);
1508
- if (!plugin) throw new Error(`Plugin "${pluginId}" not found`);
1509
- if (!this.contextFactory) throw new Error("Context factory not initialized - call setContextFactory first");
1510
- return this.contextFactory.createContext(plugin);
1511
- }
1512
- /**
1513
- * Get typed hooks for a specific hook name.
1514
- * The internal map stores ResolvedHook<unknown>, but we know each name
1515
- * maps to a specific handler type via HookHandlerMap.
1516
- *
1517
- * Exclusive hooks that have a selected provider are filtered out — they
1518
- * should only run via invokeExclusiveHook(), not in the regular pipeline.
1519
- */
1520
- getTypedHooks(name) {
1521
- const all = this.hooks.get(name) ?? [];
1522
- if (this.exclusiveSelections.has(name)) return all.filter((h) => !h.exclusive);
1523
- return all;
1524
- }
1525
- /**
1526
- * Register all hooks from plugins.
1527
- *
1528
- * Registers each hook name individually to preserve type safety. The
1529
- * internal map stores ResolvedHook<unknown> since it's keyed by string,
1530
- * but getTypedHooks() restores the correct handler type on retrieval.
1531
- */
1532
- registerPlugins(plugins) {
1533
- for (const plugin of plugins) {
1534
- this.registerPluginHook(plugin, "plugin:install");
1535
- this.registerPluginHook(plugin, "plugin:activate");
1536
- this.registerPluginHook(plugin, "plugin:deactivate");
1537
- this.registerPluginHook(plugin, "plugin:uninstall");
1538
- this.registerPluginHook(plugin, "content:beforeSave");
1539
- this.registerPluginHook(plugin, "content:afterSave");
1540
- this.registerPluginHook(plugin, "content:beforeDelete");
1541
- this.registerPluginHook(plugin, "content:afterDelete");
1542
- this.registerPluginHook(plugin, "content:afterPublish");
1543
- this.registerPluginHook(plugin, "content:afterUnpublish");
1544
- this.registerPluginHook(plugin, "content:afterRestore");
1545
- this.registerPluginHook(plugin, "content:afterSchedule");
1546
- this.registerPluginHook(plugin, "content:afterUnschedule");
1547
- this.registerPluginHook(plugin, "media:beforeUpload");
1548
- this.registerPluginHook(plugin, "media:afterUpload");
1549
- this.registerPluginHook(plugin, "cron");
1550
- this.registerPluginHook(plugin, "email:beforeSend");
1551
- this.registerPluginHook(plugin, "email:deliver");
1552
- this.registerPluginHook(plugin, "email:afterSend");
1553
- this.registerPluginHook(plugin, "comment:beforeCreate");
1554
- this.registerPluginHook(plugin, "comment:moderate");
1555
- this.registerPluginHook(plugin, "comment:afterCreate");
1556
- this.registerPluginHook(plugin, "comment:afterModerate");
1557
- this.registerPluginHook(plugin, "page:metadata");
1558
- this.registerPluginHook(plugin, "page:fragments");
1559
- }
1560
- for (const [hookName, hooks] of this.hooks) this.hooks.set(hookName, this.sortHooks(hooks));
1561
- }
1562
- /**
1563
- * Maps hook names to the capability required to register them.
1564
- *
1565
- * Hooks not listed here have no capability requirement (e.g. lifecycle
1566
- * hooks, cron). Any plugin declaring a listed hook without the required
1567
- * capability will have that hook silently skipped at registration time.
1568
- */
1569
- static HOOK_REQUIRED_CAPABILITY = new Map([
1570
- ["email:beforeSend", "hooks.email-events:register"],
1571
- ["email:afterSend", "hooks.email-events:register"],
1572
- ["email:deliver", "hooks.email-transport:register"],
1573
- ["content:beforeSave", "content:write"],
1574
- ["content:afterSave", "content:read"],
1575
- ["content:beforeDelete", "content:read"],
1576
- ["content:afterDelete", "content:read"],
1577
- ["content:afterPublish", "content:read"],
1578
- ["content:afterUnpublish", "content:read"],
1579
- ["content:afterRestore", "content:read"],
1580
- ["content:afterSchedule", "content:read"],
1581
- ["content:afterUnschedule", "content:read"],
1582
- ["media:beforeUpload", "media:write"],
1583
- ["media:afterUpload", "media:read"],
1584
- ["comment:beforeCreate", "users:read"],
1585
- ["comment:moderate", "users:read"],
1586
- ["comment:afterCreate", "users:read"],
1587
- ["comment:afterModerate", "users:read"],
1588
- ["page:fragments", "hooks.page-fragments:register"]
1589
- ]);
1590
- /**
1591
- * Register a single plugin's hook by name
1592
- */
1593
- registerPluginHook(plugin, name) {
1594
- const hook = plugin.hooks[name];
1595
- if (!hook) return;
1596
- const requiredCapability = HookPipeline.HOOK_REQUIRED_CAPABILITY.get(name);
1597
- if (requiredCapability && !plugin.capabilities.includes(requiredCapability)) {
1598
- console.warn(`[hooks] Plugin "${plugin.id}" declares ${name} hook without ${requiredCapability} capability — skipping`);
1599
- return;
1600
- }
1601
- if (hook.exclusive) this.exclusiveHookNames.add(name);
1602
- this.registerHook(name, hook);
1603
- }
1604
- /**
1605
- * Register a single hook
1606
- */
1607
- registerHook(name, hook) {
1608
- const existing = this.hooks.get(name) || [];
1609
- existing.push(hook);
1610
- this.hooks.set(name, existing);
1611
- }
1612
- /**
1613
- * Sort hooks by priority and dependencies
1614
- */
1615
- sortHooks(hooks) {
1616
- const sorted = [];
1617
- const remaining = [...hooks];
1618
- while (remaining.length > 0) {
1619
- const ready = remaining.filter((hook) => hook.dependencies.every((dep) => sorted.some((s) => s.pluginId === dep)));
1620
- if (ready.length === 0) {
1621
- const pluginIds = remaining.map((hook) => hook.pluginId).join(", ");
1622
- console.warn(`[hooks] Hook dependency cycle or missing dependency detected among plugins: ${pluginIds}. Falling back to priority order.`);
1623
- remaining.sort((a, b) => a.priority - b.priority);
1624
- sorted.push(...remaining);
1625
- break;
1626
- }
1627
- ready.sort((a, b) => a.priority - b.priority);
1628
- const next = ready[0];
1629
- sorted.push(next);
1630
- remaining.splice(remaining.indexOf(next), 1);
1631
- }
1632
- return sorted;
1633
- }
1634
- /**
1635
- * Execute a hook with timeout
1636
- */
1637
- async executeWithTimeout(fn, timeout) {
1638
- let timer;
1639
- const timeoutPromise = new Promise((_, reject) => {
1640
- timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Hook timeout after ${timeout}ms`)), timeout);
1641
- });
1642
- try {
1643
- return await Promise.race([fn(), timeoutPromise]);
1644
- } finally {
1645
- if (timer) clearTimeout(timer);
1646
- }
1647
- }
1648
- /**
1649
- * Run plugin:install hooks
1650
- */
1651
- async runPluginInstall(pluginId) {
1652
- return this.runLifecycleHook("plugin:install", pluginId);
1653
- }
1654
- /**
1655
- * Run plugin:activate hooks
1656
- */
1657
- async runPluginActivate(pluginId) {
1658
- return this.runLifecycleHook("plugin:activate", pluginId);
1659
- }
1660
- /**
1661
- * Run plugin:deactivate hooks
1662
- */
1663
- async runPluginDeactivate(pluginId) {
1664
- return this.runLifecycleHook("plugin:deactivate", pluginId);
1665
- }
1666
- /**
1667
- * Run plugin:uninstall hooks
1668
- */
1669
- async runPluginUninstall(pluginId, deleteData) {
1670
- const hooks = this.getTypedHooks("plugin:uninstall");
1671
- const results = [];
1672
- const hook = hooks.find((h) => h.pluginId === pluginId);
1673
- if (!hook) return results;
1674
- const { handler } = hook;
1675
- const event = { deleteData };
1676
- const ctx = this.getContext(pluginId);
1677
- const start = Date.now();
1678
- try {
1679
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1680
- results.push({
1681
- success: true,
1682
- pluginId: hook.pluginId,
1683
- duration: Date.now() - start
1684
- });
1685
- } catch (error) {
1686
- results.push({
1687
- success: false,
1688
- error: error instanceof Error ? error : new Error(String(error)),
1689
- pluginId: hook.pluginId,
1690
- duration: Date.now() - start
1691
- });
1692
- }
1693
- return results;
1694
- }
1695
- async runLifecycleHook(hookName, pluginId) {
1696
- const hooks = this.getTypedHooks(hookName);
1697
- const results = [];
1698
- const hook = hooks.find((h) => h.pluginId === pluginId);
1699
- if (!hook) return results;
1700
- const { handler } = hook;
1701
- const event = {};
1702
- const ctx = this.getContext(pluginId);
1703
- const start = Date.now();
1704
- try {
1705
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1706
- results.push({
1707
- success: true,
1708
- pluginId: hook.pluginId,
1709
- duration: Date.now() - start
1710
- });
1711
- } catch (error) {
1712
- results.push({
1713
- success: false,
1714
- error: error instanceof Error ? error : new Error(String(error)),
1715
- pluginId: hook.pluginId,
1716
- duration: Date.now() - start
1717
- });
1718
- }
1719
- return results;
1720
- }
1721
- /**
1722
- * Run content:beforeSave hooks
1723
- * Returns modified content from the pipeline
1724
- */
1725
- async runContentBeforeSave(content, collection, isNew) {
1726
- const hooks = this.getTypedHooks("content:beforeSave");
1727
- const results = [];
1728
- let currentContent = content;
1729
- for (const hook of hooks) {
1730
- const { handler } = hook;
1731
- const event = {
1732
- content: currentContent,
1733
- collection,
1734
- isNew
1735
- };
1736
- const ctx = this.getContext(hook.pluginId);
1737
- const start = Date.now();
1738
- try {
1739
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1740
- if (result !== void 0) currentContent = result;
1741
- results.push({
1742
- success: true,
1743
- value: currentContent,
1744
- pluginId: hook.pluginId,
1745
- duration: Date.now() - start
1746
- });
1747
- } catch (error) {
1748
- results.push({
1749
- success: false,
1750
- error: error instanceof Error ? error : new Error(String(error)),
1751
- pluginId: hook.pluginId,
1752
- duration: Date.now() - start
1753
- });
1754
- if (hook.errorPolicy === "abort") throw error;
1755
- }
1756
- }
1757
- return {
1758
- content: currentContent,
1759
- results
1760
- };
1761
- }
1762
- /**
1763
- * Run content:afterSave hooks
1764
- */
1765
- async runContentAfterSave(content, collection, isNew, previousContent) {
1766
- const hooks = this.getTypedHooks("content:afterSave");
1767
- const results = [];
1768
- for (const hook of hooks) {
1769
- const { handler } = hook;
1770
- const event = {
1771
- content,
1772
- collection,
1773
- isNew,
1774
- ...previousContent ? { previousContent } : {}
1775
- };
1776
- const ctx = this.getContext(hook.pluginId);
1777
- const start = Date.now();
1778
- try {
1779
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1780
- results.push({
1781
- success: true,
1782
- pluginId: hook.pluginId,
1783
- duration: Date.now() - start
1784
- });
1785
- } catch (error) {
1786
- results.push({
1787
- success: false,
1788
- error: error instanceof Error ? error : new Error(String(error)),
1789
- pluginId: hook.pluginId,
1790
- duration: Date.now() - start
1791
- });
1792
- if (hook.errorPolicy === "abort") throw error;
1793
- }
1794
- }
1795
- return results;
1796
- }
1797
- /**
1798
- * Run content:beforeDelete hooks
1799
- * Returns whether deletion is allowed
1800
- */
1801
- async runContentBeforeDelete(id, collection) {
1802
- const hooks = this.getTypedHooks("content:beforeDelete");
1803
- const results = [];
1804
- let allowed = true;
1805
- for (const hook of hooks) {
1806
- const { handler } = hook;
1807
- const event = {
1808
- id,
1809
- collection,
1810
- permanent: false
1811
- };
1812
- const ctx = this.getContext(hook.pluginId);
1813
- const start = Date.now();
1814
- try {
1815
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1816
- if (result === false) allowed = false;
1817
- results.push({
1818
- success: true,
1819
- value: result !== false,
1820
- pluginId: hook.pluginId,
1821
- duration: Date.now() - start
1822
- });
1823
- } catch (error) {
1824
- results.push({
1825
- success: false,
1826
- error: error instanceof Error ? error : new Error(String(error)),
1827
- pluginId: hook.pluginId,
1828
- duration: Date.now() - start
1829
- });
1830
- if (hook.errorPolicy === "abort") throw error;
1831
- }
1832
- }
1833
- return {
1834
- allowed,
1835
- results
1836
- };
1837
- }
1838
- /**
1839
- * Run content:afterDelete hooks
1840
- */
1841
- async runContentAfterDelete(id, collection, permanent, previousContent) {
1842
- const hooks = this.getTypedHooks("content:afterDelete");
1843
- const results = [];
1844
- for (const hook of hooks) {
1845
- const { handler } = hook;
1846
- const event = {
1847
- id,
1848
- collection,
1849
- permanent,
1850
- ...previousContent ? { previousContent } : {}
1851
- };
1852
- const ctx = this.getContext(hook.pluginId);
1853
- const start = Date.now();
1854
- try {
1855
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1856
- results.push({
1857
- success: true,
1858
- pluginId: hook.pluginId,
1859
- duration: Date.now() - start
1860
- });
1861
- } catch (error) {
1862
- results.push({
1863
- success: false,
1864
- error: error instanceof Error ? error : new Error(String(error)),
1865
- pluginId: hook.pluginId,
1866
- duration: Date.now() - start
1867
- });
1868
- if (hook.errorPolicy === "abort") throw error;
1869
- }
1870
- }
1871
- return results;
1872
- }
1873
- /**
1874
- * Run content:afterPublish hooks (fire-and-forget).
1875
- */
1876
- async runContentAfterPublish(content, collection, previousContent) {
1877
- return this.runContentStateChangeHook("content:afterPublish", content, collection, previousContent);
1878
- }
1879
- /**
1880
- * Run content:afterUnpublish hooks (fire-and-forget).
1881
- */
1882
- async runContentAfterUnpublish(content, collection, previousContent) {
1883
- return this.runContentStateChangeHook("content:afterUnpublish", content, collection, previousContent);
1884
- }
1885
- /**
1886
- * Run content:afterRestore hooks (fire-and-forget).
1887
- */
1888
- async runContentAfterRestore(content, collection) {
1889
- return this.runContentStateChangeHook("content:afterRestore", content, collection);
1890
- }
1891
- /**
1892
- * Run content:afterSchedule hooks (fire-and-forget).
1893
- */
1894
- async runContentAfterSchedule(content, collection) {
1895
- return this.runContentStateChangeHook("content:afterSchedule", content, collection);
1896
- }
1897
- /**
1898
- * Run content:afterUnschedule hooks (fire-and-forget).
1899
- */
1900
- async runContentAfterUnschedule(content, collection) {
1901
- return this.runContentStateChangeHook("content:afterUnschedule", content, collection);
1902
- }
1903
- async runContentStateChangeHook(name, content, collection, previousContent) {
1904
- const hooks = this.getTypedHooks(name);
1905
- const results = [];
1906
- for (const hook of hooks) {
1907
- const { handler } = hook;
1908
- const event = {
1909
- content,
1910
- collection,
1911
- ...previousContent ? { previousContent } : {}
1912
- };
1913
- const ctx = this.getContext(hook.pluginId);
1914
- const start = Date.now();
1915
- try {
1916
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1917
- results.push({
1918
- success: true,
1919
- pluginId: hook.pluginId,
1920
- duration: Date.now() - start
1921
- });
1922
- } catch (error) {
1923
- results.push({
1924
- success: false,
1925
- error: error instanceof Error ? error : new Error(String(error)),
1926
- pluginId: hook.pluginId,
1927
- duration: Date.now() - start
1928
- });
1929
- if (hook.errorPolicy === "abort") throw error;
1930
- }
1931
- }
1932
- return results;
1933
- }
1934
- /**
1935
- * Run media:beforeUpload hooks
1936
- */
1937
- async runMediaBeforeUpload(file) {
1938
- const hooks = this.getTypedHooks("media:beforeUpload");
1939
- const results = [];
1940
- let currentFile = file;
1941
- for (const hook of hooks) {
1942
- const { handler } = hook;
1943
- const event = { file: currentFile };
1944
- const ctx = this.getContext(hook.pluginId);
1945
- const start = Date.now();
1946
- try {
1947
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1948
- if (result !== void 0) currentFile = result;
1949
- results.push({
1950
- success: true,
1951
- value: currentFile,
1952
- pluginId: hook.pluginId,
1953
- duration: Date.now() - start
1954
- });
1955
- } catch (error) {
1956
- results.push({
1957
- success: false,
1958
- error: error instanceof Error ? error : new Error(String(error)),
1959
- pluginId: hook.pluginId,
1960
- duration: Date.now() - start
1961
- });
1962
- if (hook.errorPolicy === "abort") throw error;
1963
- }
1964
- }
1965
- return {
1966
- file: currentFile,
1967
- results
1968
- };
1969
- }
1970
- /**
1971
- * Run media:afterUpload hooks
1972
- */
1973
- async runMediaAfterUpload(media) {
1974
- const hooks = this.getTypedHooks("media:afterUpload");
1975
- const results = [];
1976
- for (const hook of hooks) {
1977
- const { handler } = hook;
1978
- const event = { media };
1979
- const ctx = this.getContext(hook.pluginId);
1980
- const start = Date.now();
1981
- try {
1982
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
1983
- results.push({
1984
- success: true,
1985
- pluginId: hook.pluginId,
1986
- duration: Date.now() - start
1987
- });
1988
- } catch (error) {
1989
- results.push({
1990
- success: false,
1991
- error: error instanceof Error ? error : new Error(String(error)),
1992
- pluginId: hook.pluginId,
1993
- duration: Date.now() - start
1994
- });
1995
- if (hook.errorPolicy === "abort") throw error;
1996
- }
1997
- }
1998
- return results;
1999
- }
2000
- /**
2001
- * Invoke the cron hook for a specific plugin.
2002
- *
2003
- * Unlike other hooks which broadcast to all plugins, the cron hook is
2004
- * dispatched only to the target plugin — the one that owns the task.
2005
- */
2006
- async invokeCronHook(pluginId, event) {
2007
- const hook = this.getTypedHooks("cron").find((h) => h.pluginId === pluginId);
2008
- if (!hook) return {
2009
- success: false,
2010
- error: /* @__PURE__ */ new Error(`Plugin "${pluginId}" has no cron hook registered`),
2011
- pluginId,
2012
- duration: 0
2013
- };
2014
- const { handler } = hook;
2015
- const ctx = this.getContext(pluginId);
2016
- const start = Date.now();
2017
- try {
2018
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2019
- return {
2020
- success: true,
2021
- pluginId,
2022
- duration: Date.now() - start
2023
- };
2024
- } catch (error) {
2025
- return {
2026
- success: false,
2027
- error: error instanceof Error ? error : new Error(String(error)),
2028
- pluginId,
2029
- duration: Date.now() - start
2030
- };
2031
- }
2032
- }
2033
- /**
2034
- * Run email:beforeSend hooks (middleware pipeline).
2035
- *
2036
- * Each handler receives the message and returns a modified message or
2037
- * `false` to cancel delivery. The pipeline chains message transformations —
2038
- * each handler receives the output of the previous one.
2039
- */
2040
- async runEmailBeforeSend(message, source) {
2041
- const hooks = this.getTypedHooks("email:beforeSend");
2042
- const results = [];
2043
- let currentMessage = message;
2044
- for (const hook of hooks) {
2045
- const { handler } = hook;
2046
- const event = {
2047
- message: { ...currentMessage },
2048
- source
2049
- };
2050
- const ctx = this.getContext(hook.pluginId);
2051
- const start = Date.now();
2052
- try {
2053
- const result = await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2054
- if (result === false) {
2055
- results.push({
2056
- success: true,
2057
- value: false,
2058
- pluginId: hook.pluginId,
2059
- duration: Date.now() - start
2060
- });
2061
- return {
2062
- message: false,
2063
- results
2064
- };
2065
- }
2066
- if (result && typeof result === "object") currentMessage = result;
2067
- results.push({
2068
- success: true,
2069
- value: currentMessage,
2070
- pluginId: hook.pluginId,
2071
- duration: Date.now() - start
2072
- });
2073
- } catch (error) {
2074
- results.push({
2075
- success: false,
2076
- error: error instanceof Error ? error : new Error(String(error)),
2077
- pluginId: hook.pluginId,
2078
- duration: Date.now() - start
2079
- });
2080
- if (hook.errorPolicy === "abort") throw error;
2081
- }
2082
- }
2083
- return {
2084
- message: currentMessage,
2085
- results
2086
- };
2087
- }
2088
- /**
2089
- * Run email:afterSend hooks (fire-and-forget).
2090
- *
2091
- * Errors are logged but don't propagate — they don't affect the caller.
2092
- */
2093
- async runEmailAfterSend(message, source) {
2094
- const hooks = this.getTypedHooks("email:afterSend");
2095
- const results = [];
2096
- for (const hook of hooks) {
2097
- const { handler } = hook;
2098
- const event = {
2099
- message,
2100
- source
2101
- };
2102
- const ctx = this.getContext(hook.pluginId);
2103
- const start = Date.now();
2104
- try {
2105
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2106
- results.push({
2107
- success: true,
2108
- pluginId: hook.pluginId,
2109
- duration: Date.now() - start
2110
- });
2111
- } catch (error) {
2112
- console.error(`[email:afterSend] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2113
- results.push({
2114
- success: false,
2115
- error: error instanceof Error ? error : new Error(String(error)),
2116
- pluginId: hook.pluginId,
2117
- duration: Date.now() - start
2118
- });
2119
- }
2120
- }
2121
- return results;
2122
- }
2123
- /**
2124
- * Run comment:beforeCreate hooks (middleware pipeline).
2125
- *
2126
- * Each handler receives the event and returns a modified event or
2127
- * `false` to reject the comment. The pipeline chains transformations —
2128
- * each handler receives the output of the previous one.
2129
- */
2130
- async runCommentBeforeCreate(event) {
2131
- const hooks = this.getTypedHooks("comment:beforeCreate");
2132
- let currentEvent = event;
2133
- for (const hook of hooks) {
2134
- const { handler } = hook;
2135
- const ctx = this.getContext(hook.pluginId);
2136
- const start = Date.now();
2137
- try {
2138
- const result = await this.executeWithTimeout(() => handler({ ...currentEvent }, ctx), hook.timeout);
2139
- if (result === false) return false;
2140
- if (result && typeof result === "object") currentEvent = result;
2141
- } catch (error) {
2142
- console.error(`[comment:beforeCreate] Plugin "${hook.pluginId}" error (${Date.now() - start}ms):`, error instanceof Error ? error.message : error);
2143
- if (hook.errorPolicy === "abort") throw error;
2144
- }
2145
- }
2146
- return currentEvent;
2147
- }
2148
- /**
2149
- * Run comment:afterCreate hooks (fire-and-forget).
2150
- *
2151
- * Errors are logged but don't propagate — they don't affect the caller.
2152
- */
2153
- async runCommentAfterCreate(event) {
2154
- const hooks = this.getTypedHooks("comment:afterCreate");
2155
- for (const hook of hooks) {
2156
- const { handler } = hook;
2157
- const ctx = this.getContext(hook.pluginId);
2158
- try {
2159
- await this.executeWithTimeout(() => handler(event, ctx), hook.timeout);
2160
- } catch (error) {
2161
- console.error(`[comment:afterCreate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2162
- }
2163
- }
2164
- }
2165
- /**
2166
- * Run comment:afterModerate hooks (fire-and-forget).
2167
- *
2168
- * Errors are logged but don't propagate — they don't affect the caller.
2169
- */
2170
- async runCommentAfterModerate(event) {
2171
- const hooks = this.getTypedHooks("comment:afterModerate");
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:afterModerate] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2179
- }
2180
- }
2181
- }
2182
- /**
2183
- * Run page:metadata hooks. Each handler returns contributions that are
2184
- * merged by the metadata collector. Errors are logged but don't propagate.
2185
- */
2186
- async runPageMetadata(event) {
2187
- const hooks = this.getTypedHooks("page:metadata");
2188
- const results = [];
2189
- for (const hook of hooks) {
2190
- const { handler } = hook;
2191
- const ctx = this.getContext(hook.pluginId);
2192
- try {
2193
- const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
2194
- if (result != null) {
2195
- const contributions = Array.isArray(result) ? result : [result];
2196
- results.push({
2197
- pluginId: hook.pluginId,
2198
- contributions
2199
- });
2200
- }
2201
- } catch (error) {
2202
- console.error(`[page:metadata] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2203
- }
2204
- }
2205
- return results;
2206
- }
2207
- /**
2208
- * Run page:fragments hooks. Only trusted plugins should be registered
2209
- * for this hook. Errors are logged but don't propagate.
2210
- */
2211
- async runPageFragments(event) {
2212
- const hooks = this.getTypedHooks("page:fragments");
2213
- const results = [];
2214
- for (const hook of hooks) {
2215
- const { handler } = hook;
2216
- const ctx = this.getContext(hook.pluginId);
2217
- try {
2218
- const result = await this.executeWithTimeout(() => Promise.resolve(handler(event, ctx)), hook.timeout);
2219
- if (result != null) {
2220
- const contributions = Array.isArray(result) ? result : [result];
2221
- results.push({
2222
- pluginId: hook.pluginId,
2223
- contributions
2224
- });
2225
- }
2226
- } catch (error) {
2227
- console.error(`[page:fragments] Plugin "${hook.pluginId}" error:`, error instanceof Error ? error.message : error);
2228
- }
2229
- }
2230
- return results;
2231
- }
2232
- /**
2233
- * Check if any hooks are registered for a given name
2234
- */
2235
- hasHooks(name) {
2236
- const hooks = this.hooks.get(name);
2237
- return hooks !== void 0 && hooks.length > 0;
2238
- }
2239
- /**
2240
- * Get hook count for debugging
2241
- */
2242
- getHookCount(name) {
2243
- return this.hooks.get(name)?.length || 0;
2244
- }
2245
- /**
2246
- * Get all registered hook names
2247
- */
2248
- getRegisteredHooks() {
2249
- return [...this.hooks.keys()];
2250
- }
2251
- /**
2252
- * Returns hook names where at least one handler declared exclusive: true
2253
- */
2254
- getRegisteredExclusiveHooks() {
2255
- return [...this.exclusiveHookNames];
2256
- }
2257
- /**
2258
- * Check if a hook is exclusive
2259
- */
2260
- isExclusiveHook(name) {
2261
- return this.exclusiveHookNames.has(name);
2262
- }
2263
- /**
2264
- * Set the selected provider for an exclusive hook.
2265
- * Called by PluginManager after resolution.
2266
- */
2267
- setExclusiveSelection(hookName, pluginId) {
2268
- this.exclusiveSelections.set(hookName, pluginId);
2269
- }
2270
- /**
2271
- * Clear the selected provider for an exclusive hook.
2272
- */
2273
- clearExclusiveSelection(hookName) {
2274
- this.exclusiveSelections.delete(hookName);
2275
- }
2276
- /**
2277
- * Get the selected provider for an exclusive hook (if any).
2278
- */
2279
- getExclusiveSelection(hookName) {
2280
- return this.exclusiveSelections.get(hookName);
2281
- }
2282
- /**
2283
- * Get all plugins that registered a handler for a given exclusive hook.
2284
- */
2285
- getExclusiveHookProviders(hookName) {
2286
- return (this.hooks.get(hookName) ?? []).filter((h) => h.exclusive).map((h) => ({ pluginId: h.pluginId }));
2287
- }
2288
- /**
2289
- * Get all plugins that registered a non-exclusive handler for a given hook,
2290
- * preserving priority order. This partitions with getExclusiveHookProviders().
2291
- */
2292
- getHookProviders(hookName) {
2293
- return (this.hooks.get(hookName) ?? []).filter((h) => !h.exclusive).map((h) => ({ pluginId: h.pluginId }));
2294
- }
2295
- /**
2296
- * Invoke an exclusive hook — dispatch only to the selected provider.
2297
- * Returns null if no provider is selected or if the selected hook
2298
- * is not found in the pipeline.
2299
- *
2300
- * This is a generic dispatch used by the email pipeline and other
2301
- * exclusive hook consumers. The handler type is unknown — callers
2302
- * must know the expected signature.
2303
- *
2304
- * Errors are isolated: a failing handler returns an error result
2305
- * instead of propagating the exception to the caller.
2306
- */
2307
- async invokeExclusiveHook(hookName, event) {
2308
- const selectedPluginId = this.exclusiveSelections.get(hookName);
2309
- if (!selectedPluginId) return null;
2310
- const hook = (this.hooks.get(hookName) ?? []).find((h) => h.pluginId === selectedPluginId && h.exclusive);
2311
- if (!hook) return null;
2312
- const start = Date.now();
2313
- try {
2314
- const ctx = this.getContext(selectedPluginId);
2315
- const handler = hook.handler;
2316
- return {
2317
- result: await this.executeWithTimeout(() => handler(event, ctx), hook.timeout),
2318
- pluginId: selectedPluginId,
2319
- duration: Date.now() - start
2320
- };
2321
- } catch (error) {
2322
- return {
2323
- result: void 0,
2324
- pluginId: selectedPluginId,
2325
- error: error instanceof Error ? error : new Error(String(error)),
2326
- duration: Date.now() - start
2327
- };
2328
- }
2329
- }
2330
- };
2331
- /**
2332
- * Create a hook pipeline from plugins
2333
- */
2334
- function createHookPipeline(plugins, factoryOptions) {
2335
- return new HookPipeline(plugins, factoryOptions);
2336
- }
2337
- /** Options table key prefix for exclusive hook selections */
2338
- const EXCLUSIVE_HOOK_KEY_PREFIX$1 = "dineway:exclusive_hook:";
2339
- /**
2340
- * Resolve exclusive hook selections.
2341
- *
2342
- * Shared algorithm used by both PluginManager and DinewayRuntime:
2343
- * 1. If a DB selection exists and that plugin is active → keep it.
2344
- * 2. If DB selection is stale (plugin inactive/gone) → clear it.
2345
- * 3. If no selection and only one active provider → auto-select it.
2346
- * 4. If preferred hints match an active provider → first match wins.
2347
- * 5. If multiple providers and no hint → leave unselected (admin must choose).
2348
- */
2349
- async function resolveExclusiveHooks(opts) {
2350
- const { pipeline, isActive, getOption, getOptions, setOption, deleteOption, preferredHints } = opts;
2351
- const exclusiveHookNames = pipeline.getRegisteredExclusiveHooks();
2352
- if (exclusiveHookNames.length === 0) return;
2353
- let currentSelections;
2354
- if (getOptions) try {
2355
- currentSelections = await getOptions(exclusiveHookNames.map((hookName) => `${EXCLUSIVE_HOOK_KEY_PREFIX$1}${hookName}`));
2356
- } catch {
2357
- return;
2358
- }
2359
- for (const hookName of exclusiveHookNames) {
2360
- const providers = pipeline.getExclusiveHookProviders(hookName);
2361
- const activeProviderIds = new Set(providers.map((p) => p.pluginId).filter((id) => isActive(id)));
2362
- const key = `${EXCLUSIVE_HOOK_KEY_PREFIX$1}${hookName}`;
2363
- let currentSelection = null;
2364
- if (currentSelections) currentSelection = currentSelections.get(key) ?? null;
2365
- else try {
2366
- currentSelection = await getOption(key);
2367
- } catch {
2368
- continue;
2369
- }
2370
- if (currentSelection && activeProviderIds.has(currentSelection)) {
2371
- pipeline.setExclusiveSelection(hookName, currentSelection);
2372
- continue;
2373
- }
2374
- if (currentSelection) try {
2375
- await deleteOption(key);
2376
- } catch {}
2377
- if (activeProviderIds.size === 1) {
2378
- const [onlyProvider] = activeProviderIds;
2379
- try {
2380
- await setOption(key, onlyProvider);
2381
- } catch {}
2382
- pipeline.setExclusiveSelection(hookName, onlyProvider);
2383
- continue;
2384
- }
2385
- if (preferredHints) {
2386
- let found = false;
2387
- for (const [pluginId, hooks] of preferredHints) if (hooks.includes(hookName) && activeProviderIds.has(pluginId)) {
2388
- try {
2389
- await setOption(key, pluginId);
2390
- } catch {}
2391
- pipeline.setExclusiveSelection(hookName, pluginId);
2392
- found = true;
2393
- break;
2394
- }
2395
- if (found) continue;
2396
- }
2397
- pipeline.clearExclusiveSelection(hookName);
2398
- }
2399
- }
2400
-
2401
1452
  //#endregion
2402
1453
  //#region src/plugins/email.ts
2403
1454
  /**
@@ -3547,7 +2598,7 @@ function createContext() {
3547
2598
  const items = await bridge.storageGetMany(collectionName, ids);
3548
2599
  return new Map(items.map((item) => [item.id, item.data]));
3549
2600
  },
3550
- putMany: (items) => bridge.storagePutMany(collectionName, items),
2601
+ putMany: (items,options) => bridge.storagePutMany(collectionName, items,options),
3551
2602
  deleteMany: (ids) => bridge.storageDeleteMany(collectionName, ids),
3552
2603
  };
3553
2604
  }
@@ -4004,6 +3055,9 @@ function isMediaListOptions(value) {
4004
3055
  function isStoragePutManyItems(value) {
4005
3056
  return Array.isArray(value) && value.every((item) => isRecord(item) && typeof item.id === "string" && "data" in item);
4006
3057
  }
3058
+ function isStoragePutOptions(value) {
3059
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).every((key) => key === "ifAbsent") && (!("ifAbsent" in value) || typeof value.ifAbsent === "boolean");
3060
+ }
4007
3061
  function isUserListOptions(value) {
4008
3062
  if (!isRecord(value)) return false;
4009
3063
  if ("role" in value && value.role !== void 0 && typeof value.role !== "number") return false;
@@ -4125,7 +3179,7 @@ var NodeSandboxedPlugin = class {
4125
3179
  id,
4126
3180
  data
4127
3181
  })));
4128
- case "storagePutMany": return requireStorageCollection(ctx.storage, stringArg(0, "collection")).putMany(expectValue(args[1], `${String(method)} items`, isStoragePutManyItems));
3182
+ case "storagePutMany": return requireStorageCollection(ctx.storage, stringArg(0, "collection")).putMany(expectValue(args[1], `${String(method)} items`, isStoragePutManyItems), expectOptional(args[2], `${String(method)} options`, isStoragePutOptions));
4129
3183
  case "storageDeleteMany": return requireStorageCollection(ctx.storage, stringArg(0, "collection")).deleteMany(expectStringArray(args[1], `${String(method)} ids`));
4130
3184
  case "contentGet": return ctx.content?.get(stringArg(0, "collection"), stringArg(1, "id")) ?? null;
4131
3185
  case "contentList": return ctx.content?.list(stringArg(0, "collection"), expectOptional(args[1], `${String(method)} options`, isContentListOptions)) ?? null;
@@ -4275,4 +3329,4 @@ function createNodeSandboxRunner(options) {
4275
3329
  }
4276
3330
 
4277
3331
  //#endregion
4278
- export { prosemirrorToPortableText as C, RelationRepository as D, image as E, portableTextToProsemirror as S, reference as T, readBoundedPluginRouteBody as _, createNoopSandboxRunner as a, issueGuestAccessToken as b, PluginSecretStore as c, EmailPipeline as d, HookPipeline as f, DEFAULT_PLUGIN_RAW_BODY_LIMIT_BYTES as g, definePlugin as h, SandboxNotAvailableError as i, PluginRouteError as l, resolveExclusiveHooks as m, createNodeSandboxRunner as n, PluginManager as o, createHookPipeline as p, NoopSandboxRunner as r, createPluginManager as s, NodeSandboxRunner as t, PluginRouteRegistry as u, GuestAccessTokenConfigurationError as v, portableText as w, verifyGuestAccessToken as x, hashGuestAccessToken as y };
3332
+ export { image as C, reference as S, issueGuestAccessToken as _, createNoopSandboxRunner as a, prosemirrorToPortableText as b, PluginSecretStore as c, EmailPipeline as d, definePlugin as f, hashGuestAccessToken as g, GuestAccessTokenConfigurationError as h, SandboxNotAvailableError as i, PluginRouteError as l, readBoundedPluginRouteBody as m, createNodeSandboxRunner as n, PluginManager as o, DEFAULT_PLUGIN_RAW_BODY_LIMIT_BYTES as p, NoopSandboxRunner as r, createPluginManager as s, NodeSandboxRunner as t, PluginRouteRegistry as u, verifyGuestAccessToken as v, RelationRepository as w, portableText as x, portableTextToProsemirror as y };