dineway 0.2.33 → 0.2.35

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 (458) hide show
  1. package/dist/{activity-CfryM8jO.mjs → activity-BbtYp_4V.mjs} +2 -2
  2. package/dist/{activity-events-BVo9rMUz.mjs → activity-events-CiFN61xq.mjs} +1 -1
  3. package/dist/{actor-DrJJsvy6.mjs → actor-DxUAJgQX.mjs} +20 -6
  4. package/dist/{adapters-DHt3f2lu.d.mts → adapters-Rol-inz6.d.mts} +5 -7
  5. package/dist/after-BVaUn7bK.mjs +24 -0
  6. package/dist/{allowed-origins-DGSyhRCz.mjs → allowed-origins-Cp7BI3L9.mjs} +1 -1
  7. package/dist/api/route-utils.d.mts +10 -10
  8. package/dist/api/route-utils.mjs +23 -19
  9. package/dist/api/schemas/index.d.mts +1 -1
  10. package/dist/api/schemas/index.mjs +5 -5
  11. package/dist/{api-CTf1SLmg.mjs → api-CwhrR7H5.mjs} +55 -1215
  12. package/dist/api-tokens-DA18zxza.mjs +3 -0
  13. package/dist/{api-tokens-CSomx-l3.mjs → api-tokens-OAgvq4xg.mjs} +1 -1
  14. package/dist/{apply-Bs2jXsms.mjs → apply-BTfAReIv.mjs} +109 -93
  15. package/dist/astro/index.d.mts +16 -12
  16. package/dist/astro/index.mjs +50 -9
  17. package/dist/astro/middleware/auth.d.mts +9 -9
  18. package/dist/astro/middleware/auth.mjs +29 -8
  19. package/dist/astro/middleware/redirect.mjs +8 -7
  20. package/dist/astro/middleware/request-context.mjs +17 -10
  21. package/dist/astro/middleware/seed.d.mts +1 -1
  22. package/dist/astro/middleware/seed.mjs +93 -71
  23. package/dist/astro/middleware/setup.mjs +1 -1
  24. package/dist/astro/middleware/workers.d.mts +6 -0
  25. package/dist/astro/middleware/workers.mjs +8 -0
  26. package/dist/astro/middleware.mjs +287 -159
  27. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +7 -7
  28. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +7 -7
  29. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +4 -4
  30. package/dist/astro/routes/api/admin/api-tokens/index.mjs +7 -7
  31. package/dist/astro/routes/api/admin/briefing.mjs +25 -23
  32. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +5 -4
  33. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +11 -10
  34. package/dist/astro/routes/api/admin/byline-fields/index.mjs +11 -10
  35. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +11 -10
  36. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +22 -20
  37. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +22 -20
  38. package/dist/astro/routes/api/admin/bylines/index.mjs +22 -20
  39. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +18 -16
  40. package/dist/astro/routes/api/admin/comments/_id_.mjs +8 -7
  41. package/dist/astro/routes/api/admin/comments/bulk.mjs +14 -13
  42. package/dist/astro/routes/api/admin/comments/counts.mjs +8 -7
  43. package/dist/astro/routes/api/admin/comments/index.mjs +14 -13
  44. package/dist/astro/routes/api/admin/context/_id_/history.mjs +42 -31
  45. package/dist/astro/routes/api/admin/context/_id_/index.mjs +42 -31
  46. package/dist/astro/routes/api/admin/context/_id_/review.mjs +47 -36
  47. package/dist/astro/routes/api/admin/context/_id_/supersede.mjs +47 -36
  48. package/dist/astro/routes/api/admin/context/diff.mjs +46 -35
  49. package/dist/astro/routes/api/admin/context/index.mjs +47 -36
  50. package/dist/astro/routes/api/admin/context/stale.mjs +46 -35
  51. package/dist/astro/routes/api/admin/hitl-requests/_id_/index.mjs +42 -31
  52. package/dist/astro/routes/api/admin/hitl-requests/_id_/resolve.mjs +46 -35
  53. package/dist/astro/routes/api/admin/hitl-requests/index.mjs +46 -35
  54. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +43 -32
  55. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
  56. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +7 -7
  57. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +7 -7
  58. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +71 -66
  59. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +71 -66
  60. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +63 -58
  61. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +70 -65
  62. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +70 -65
  63. package/dist/astro/routes/api/admin/plugins/index.mjs +63 -58
  64. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
  65. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +63 -58
  66. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +70 -65
  67. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +63 -58
  68. package/dist/astro/routes/api/admin/plugins/updates.mjs +63 -58
  69. package/dist/astro/routes/api/admin/review-requests/_id_/image.mjs +26 -23
  70. package/dist/astro/routes/api/admin/review-requests/_id_/index.mjs +39 -25
  71. package/dist/astro/routes/api/admin/review-requests/_id_/resolve.mjs +55 -43
  72. package/dist/astro/routes/api/admin/review-requests/_id_/revoke.mjs +10 -9
  73. package/dist/astro/routes/api/admin/review-requests/index.mjs +53 -41
  74. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +63 -58
  75. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
  76. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +63 -58
  77. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +20 -12
  78. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
  79. package/dist/astro/routes/api/admin/users/_id_/index.mjs +40 -32
  80. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +3 -3
  81. package/dist/astro/routes/api/admin/users/index.mjs +7 -7
  82. package/dist/astro/routes/api/auth/dev-bypass.mjs +6 -5
  83. package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
  84. package/dist/astro/routes/api/auth/invite/complete.mjs +12 -12
  85. package/dist/astro/routes/api/auth/invite/index.mjs +9 -9
  86. package/dist/astro/routes/api/auth/invite/register-options.mjs +11 -11
  87. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  88. package/dist/astro/routes/api/auth/magic-link/send.mjs +12 -11
  89. package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
  90. package/dist/astro/routes/api/auth/me.mjs +11 -11
  91. package/dist/astro/routes/api/auth/mode.mjs +1 -1
  92. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +5 -4
  93. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +5 -4
  94. package/dist/astro/routes/api/auth/passkey/_id_.mjs +7 -7
  95. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
  96. package/dist/astro/routes/api/auth/passkey/options.mjs +14 -13
  97. package/dist/astro/routes/api/auth/passkey/register/options.mjs +11 -11
  98. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +12 -12
  99. package/dist/astro/routes/api/auth/passkey/verify.mjs +12 -12
  100. package/dist/astro/routes/api/auth/setup-token/index.mjs +32 -23
  101. package/dist/astro/routes/api/auth/setup-token/verify.mjs +32 -26
  102. package/dist/astro/routes/api/auth/signup/complete.mjs +12 -12
  103. package/dist/astro/routes/api/auth/signup/request.mjs +12 -11
  104. package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
  105. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.d.mts +73 -2
  106. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +91 -49
  107. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +19 -16
  108. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  109. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +8 -7
  110. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +8 -7
  111. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +8 -7
  112. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +24 -21
  113. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +34 -22
  114. package/dist/astro/routes/api/content/_collection_/_id_/release-readiness.mjs +9 -9
  115. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +8 -7
  116. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
  117. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +34 -22
  118. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +23 -19
  119. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  120. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +8 -7
  121. package/dist/astro/routes/api/content/_collection_/_id_.mjs +14 -13
  122. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  123. package/dist/astro/routes/api/content/_collection_/index.mjs +14 -13
  124. package/dist/astro/routes/api/content/_collection_/trash.mjs +8 -8
  125. package/dist/astro/routes/api/dashboard.mjs +16 -11
  126. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  127. package/dist/astro/routes/api/health.mjs +1 -1
  128. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  129. package/dist/astro/routes/api/import/probe.mjs +25 -24
  130. package/dist/astro/routes/api/import/wordpress/analyze.mjs +12 -11
  131. package/dist/astro/routes/api/import/wordpress/execute.d.mts +9 -9
  132. package/dist/astro/routes/api/import/wordpress/execute.mjs +50 -42
  133. package/dist/astro/routes/api/import/wordpress/media.d.mts +9 -9
  134. package/dist/astro/routes/api/import/wordpress/media.mjs +14 -14
  135. package/dist/astro/routes/api/import/wordpress/prepare.mjs +51 -40
  136. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +10 -10
  137. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +49 -38
  138. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  139. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +29 -27
  140. package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
  141. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +9 -9
  142. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +55 -47
  143. package/dist/astro/routes/api/integration/artifact.mjs +11 -8
  144. package/dist/astro/routes/api/integration/dispatch.mjs +17 -14
  145. package/dist/astro/routes/api/integrations/_provider_.mjs +11 -8
  146. package/dist/astro/routes/api/integrations/index.mjs +10 -7
  147. package/dist/astro/routes/api/manifest.mjs +5 -5
  148. package/dist/astro/routes/api/mcp.mjs +97 -88
  149. package/dist/astro/routes/api/media/_id_/confirm.mjs +12 -12
  150. package/dist/astro/routes/api/media/_id_.mjs +9 -9
  151. package/dist/astro/routes/api/media/file/_...key_.mjs +1 -1
  152. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
  153. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  154. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  155. package/dist/astro/routes/api/media/upload-url.mjs +13 -13
  156. package/dist/astro/routes/api/media.mjs +16 -16
  157. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +47 -36
  158. package/dist/astro/routes/api/menus/_name_/items.mjs +47 -36
  159. package/dist/astro/routes/api/menus/_name_/reorder.mjs +47 -36
  160. package/dist/astro/routes/api/menus/_name_/translations.mjs +47 -36
  161. package/dist/astro/routes/api/menus/_name_.mjs +47 -36
  162. package/dist/astro/routes/api/menus/index.mjs +47 -36
  163. package/dist/astro/routes/api/oauth/authorize.mjs +9 -7
  164. package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -6
  165. package/dist/astro/routes/api/oauth/device/code.mjs +11 -9
  166. package/dist/astro/routes/api/oauth/device/token.mjs +10 -8
  167. package/dist/astro/routes/api/oauth/register.mjs +4 -4
  168. package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -6
  169. package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -6
  170. package/dist/astro/routes/api/oauth/token.mjs +8 -6
  171. package/dist/astro/routes/api/openapi.json.mjs +5 -5
  172. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +4 -4
  173. package/dist/astro/routes/api/redirects/404s/index.mjs +15 -14
  174. package/dist/astro/routes/api/redirects/404s/summary.mjs +15 -14
  175. package/dist/astro/routes/api/redirects/_id_.mjs +47 -37
  176. package/dist/astro/routes/api/redirects/index.mjs +47 -37
  177. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  178. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +2 -2
  179. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +65 -60
  180. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +65 -60
  181. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +65 -60
  182. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +65 -60
  183. package/dist/astro/routes/api/schema/collections/index.mjs +65 -60
  184. package/dist/astro/routes/api/schema/index.mjs +12 -11
  185. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +63 -58
  186. package/dist/astro/routes/api/schema/orphans/index.mjs +63 -58
  187. package/dist/astro/routes/api/search/enable.mjs +15 -14
  188. package/dist/astro/routes/api/search/index.mjs +14 -13
  189. package/dist/astro/routes/api/search/rebuild.mjs +15 -14
  190. package/dist/astro/routes/api/search/stats.mjs +9 -8
  191. package/dist/astro/routes/api/search/suggest.mjs +14 -13
  192. package/dist/astro/routes/api/sections/_slug_.mjs +47 -36
  193. package/dist/astro/routes/api/sections/index.mjs +47 -36
  194. package/dist/astro/routes/api/settings/email.mjs +5 -5
  195. package/dist/astro/routes/api/settings/reviews.mjs +11 -10
  196. package/dist/astro/routes/api/settings.mjs +47 -36
  197. package/dist/astro/routes/api/setup/admin-verify.mjs +14 -14
  198. package/dist/astro/routes/api/setup/admin.mjs +12 -12
  199. package/dist/astro/routes/api/setup/dev-bypass.mjs +35 -31
  200. package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
  201. package/dist/astro/routes/api/setup/index.mjs +37 -33
  202. package/dist/astro/routes/api/setup/status.mjs +3 -3
  203. package/dist/astro/routes/api/snapshot.mjs +11 -9
  204. package/dist/astro/routes/api/system/heartbeat.mjs +2 -2
  205. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +50 -39
  206. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +50 -39
  207. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +50 -39
  208. package/dist/astro/routes/api/taxonomies/index.mjs +50 -39
  209. package/dist/astro/routes/api/themes/preview.mjs +8 -6
  210. package/dist/astro/routes/api/typegen.mjs +4 -4
  211. package/dist/astro/routes/api/well-known/auth.mjs +3 -3
  212. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +3 -3
  213. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +3 -3
  214. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +46 -35
  215. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +47 -36
  216. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +47 -36
  217. package/dist/astro/routes/api/widget-areas/_name_.mjs +44 -33
  218. package/dist/astro/routes/api/widget-areas/index.mjs +47 -36
  219. package/dist/astro/routes/api/widget-components.mjs +2 -2
  220. package/dist/astro/routes/robots.txt.mjs +11 -10
  221. package/dist/astro/routes/sitemap-_collection_.xml.mjs +20 -18
  222. package/dist/astro/routes/sitemap.xml.mjs +19 -17
  223. package/dist/astro/session-driver.d.mts +1 -1
  224. package/dist/astro/session-driver.mjs +4 -4
  225. package/dist/astro/types.d.mts +13 -13
  226. package/dist/atomic-authority-CnBQJ14T.mjs +33 -0
  227. package/dist/{audit-CYjfxG9i.mjs → audit-F5iWkbcJ.mjs} +11 -4
  228. package/dist/auth/providers/github.d.mts +1 -1
  229. package/dist/auth/providers/google.d.mts +1 -1
  230. package/dist/{auth-control-guard-CITT8ZA_.mjs → auth-control-guard-DPOSBNFI.mjs} +1 -1
  231. package/dist/{authorize-KcI0pAfN.mjs → authorize-CXIjxIfC.mjs} +1 -1
  232. package/dist/{briefing-BgQTljQt.mjs → briefing-5zf0YZbR.mjs} +445 -447
  233. package/dist/{briefing-r3hXCDQC.mjs → briefing-DiupPvyN.mjs} +1 -1
  234. package/dist/{bundle-S6zx-V4D.mjs → bundle-DImnxo71.mjs} +3 -3
  235. package/dist/{byline-Ctil4rij.mjs → byline-DEZKlzD9.mjs} +107 -113
  236. package/dist/{byline-fields-51ja6JDa.d.mts → byline-fields-BO96fXLv.d.mts} +8 -8
  237. package/dist/{byline-fields-DiCyW6eQ.mjs → byline-fields-CY6V0ew1.mjs} +1 -1
  238. package/dist/{byline-fields-QpmruT5r.mjs → byline-fields-DGNKitg3.mjs} +3 -3
  239. package/dist/{byline-registry-rkr73qSE.mjs → byline-registry-CkuVVeJJ.mjs} +46 -76
  240. package/dist/{bylines-v_ZUQnR-.mjs → bylines-CXyKpVLQ.mjs} +6 -6
  241. package/dist/{bylines-BcuBpzVi.mjs → bylines-gSAfpHl4.mjs} +4 -4
  242. package/dist/{cache-V2BCplaY.mjs → cache-DZDOBJv3.mjs} +2 -2
  243. package/dist/{chunks-CnuL55JE.mjs → chunks-BnG3LPMN.mjs} +1 -1
  244. package/dist/cli/index.mjs +452 -263
  245. package/dist/cli/plugin-kit.d.mts +9 -9
  246. package/dist/cli/plugin-kit.mjs +2 -2
  247. package/dist/client/external-auth-headers.d.mts +1 -1
  248. package/dist/client/index.d.mts +11 -11
  249. package/dist/client/index.mjs +2 -2
  250. package/dist/{client-factory-C-y9VZDX.mjs → client-factory-6vLLT06O.mjs} +1 -1
  251. package/dist/{comment-_nvJSS-A.mjs → comment-kgLTdtQD.mjs} +15 -8
  252. package/dist/{comment-reaction-DhVgJ17S.mjs → comment-reaction-Cun5eIXL.mjs} +1 -1
  253. package/dist/{comments-D4mIDjvA.mjs → comments-ZYK_cZvx.mjs} +1 -1
  254. package/dist/{content-CVCrcuvD.mjs → content-D9xKUSno.mjs} +287 -165
  255. package/dist/{content-refresh-QvBIyb_g.mjs → content-refresh-9M9cc55-.mjs} +170 -193
  256. package/dist/{context-JjKucxBm.mjs → context-BU8AbLmY.mjs} +2 -2
  257. package/dist/{context-MftkHbWx.mjs → context-C5lPtfeh.mjs} +95 -77
  258. package/dist/{context-route-helpers-e1APrqSm.mjs → context-route-helpers-CWAHJFl3.mjs} +2 -2
  259. package/dist/{cron-mGVPQ5e6.mjs → cron-BVYo08mi.mjs} +36 -32
  260. package/dist/d1-binding-D6HZa3ks.mjs +8 -0
  261. package/dist/d1-dialect-BBxPg6Om.mjs +48 -0
  262. package/dist/{dashboard-ZJ7sMcBI.mjs → dashboard-BnD5krLg.mjs} +5 -5
  263. package/dist/database/batch.d.mts +22 -0
  264. package/dist/database/batch.mjs +92 -0
  265. package/dist/database/d1/index.d.mts +18 -0
  266. package/dist/database/d1/index.mjs +8 -0
  267. package/dist/db/d1.d.mts +7 -0
  268. package/dist/db/d1.mjs +13 -0
  269. package/dist/db/index.d.mts +4 -4
  270. package/dist/db/index.mjs +10 -7
  271. package/dist/db/libsql.d.mts +1 -1
  272. package/dist/db/libsql.mjs +46 -3
  273. package/dist/db/postgres.d.mts +1 -1
  274. package/dist/db/sqlite.d.mts +1 -1
  275. package/dist/{device-flow-eOcL5m0Q.mjs → device-flow-Prqg6ycD.mjs} +130 -94
  276. package/dist/{dialect-helpers-fk43GbDb.mjs → dialect-helpers-C6xtO-Ui.mjs} +1 -1
  277. package/dist/{discovery-CJkuHGhZ.mjs → discovery-CYcZJ1o3.mjs} +5 -5
  278. package/dist/{enrich-KErvJOuI.mjs → enrich-BjF-J4sF.mjs} +1 -1
  279. package/dist/{evidence-6IUv9ML3.mjs → evidence-krrA3uiG.mjs} +7 -7
  280. package/dist/{field-defs-cache-CwrIyZFT.mjs → field-defs-cache-BKKFFf_V.mjs} +5 -5
  281. package/dist/{forgeway-account-lYJ8iX3G.mjs → forgeway-account-CnWOIusE.mjs} +1 -1
  282. package/dist/{fts-manager-DX7ZkrCa.mjs → fts-manager-DA74x_uP.mjs} +72 -57
  283. package/dist/{hitl-requests-CmYVunm-.mjs → hitl-requests-CGjA1jND.mjs} +2 -2
  284. package/dist/{hitl-route-helpers-CRm537zS.mjs → hitl-route-helpers-BxSL0iZB.mjs} +5 -5
  285. package/dist/{import-DqRAgsKr.mjs → import-CayDCPaH.mjs} +9 -9
  286. package/dist/{index-Co7xtjkd.d.mts → index-mlJSqFkG.d.mts} +7 -4
  287. package/dist/index.d.mts +16 -16
  288. package/dist/index.mjs +103 -96
  289. package/dist/{integration-credentials-qudN6yRr.mjs → integration-credentials-Br16M1VE.mjs} +2 -2
  290. package/dist/{jsonld-BpvnSp2m.d.mts → jsonld-BUiFEiCZ.d.mts} +2 -2
  291. package/dist/{load-fCOciq0Q.mjs → load-B2oitobd.mjs} +1 -1
  292. package/dist/{loader-BDje8ME2.mjs → loader-Cgsx23wU.mjs} +4 -4
  293. package/dist/{manifest-schema-CfKD0thC.mjs → manifest-schema-DBXM_g8l.mjs} +1 -1
  294. package/dist/{mcp-reviewed-executor-DmhM3Cy6.mjs → mcp-reviewed-executor-RJ71uyQb.mjs} +7 -7
  295. package/dist/media/image-endpoint.mjs +1 -1
  296. package/dist/media/index.d.mts +1 -1
  297. package/dist/media/index.mjs +2 -2
  298. package/dist/media/local-runtime.d.mts +11 -11
  299. package/dist/media/local-runtime.mjs +3 -3
  300. package/dist/{media-dvRjj4po.mjs → media-BZqwtRTZ.mjs} +12 -4
  301. package/dist/{media-allowlist-DaG6lNoy.mjs → media-allowlist-CyByjUXh.mjs} +1 -1
  302. package/dist/{menus-CZbz5L_V.mjs → menus-2o-DVcwA.mjs} +8 -8
  303. package/dist/{menus-CpuR4Qkm.mjs → menus-5liJusbp.mjs} +138 -90
  304. package/dist/migrations-C7YXse7V.mjs +76 -0
  305. package/dist/oauth-authority-DOjME4Hh.mjs +43 -0
  306. package/dist/{oauth-authorization-Jf5e3azH.mjs → oauth-authorization-B_mmz7O2.mjs} +89 -98
  307. package/dist/{oauth-clients-tovQ4D4h.mjs → oauth-clients-Cr4pdIAE.mjs} +2 -2
  308. package/dist/object-cache/memory.d.mts +1 -1
  309. package/dist/{object-cache-D51qOseS.mjs → object-cache-BGjIlY9s.mjs} +1 -1
  310. package/dist/page/index.d.mts +10 -10
  311. package/dist/page/index.mjs +1 -1
  312. package/dist/{parse-IsGn-5lt.mjs → parse-BscLr3p2.mjs} +1 -1
  313. package/dist/plugin-utils.d.mts +9 -9
  314. package/dist/plugins/adapt-sandbox-entry.d.mts +9 -9
  315. package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
  316. package/dist/{plugins-DXyLI3Hb.mjs → plugins-f48yrwfI.mjs} +35 -84
  317. package/dist/{policy-DKdNMv8y.mjs → policy-CrK1vl8l.mjs} +2 -2
  318. package/dist/{preview-BXmS1SXL.mjs → preview-E1xKZGsX.mjs} +2 -2
  319. package/dist/{provider-loader-DDq7R_RN.d.mts → provider-loader-H2wdGD0o.d.mts} +1 -1
  320. package/dist/{public-url-Ci7UbC0W.d.mts → public-url-CI700CW4.d.mts} +1 -1
  321. package/dist/{public-url-BQ9vf0AS.d.mts → public-url-zoO-QbN6.d.mts} +2 -2
  322. package/dist/{publication-authorization-C-vYPGD8.mjs → publication-authorization-Dq_20SZR.mjs} +458 -33
  323. package/dist/{query-DcB9uGTW.mjs → query-BkWWdxyb.mjs} +4 -4
  324. package/dist/{query-CrW2yI6G.mjs → query-D6oNo9iz.mjs} +15 -15
  325. package/dist/{rate-limit-DEkoxTsP.mjs → rate-limit-RaBJEgyt.mjs} +2 -2
  326. package/dist/{redirect-DG-o0CKV.mjs → redirect-HLI3wT5Y.mjs} +26 -14
  327. package/dist/{redirects-Bjp4iKJU.mjs → redirects-D16GFaOa.mjs} +5 -5
  328. package/dist/{redirects-N8gmWhVM.mjs → redirects-DpRiuRWn.mjs} +3 -3
  329. package/dist/{registry-D-IV_h50.mjs → registry-DcV93OL_.mjs} +183 -186
  330. package/dist/release-CZfAeyXm.mjs +5148 -0
  331. package/dist/request-context.d.mts +8 -0
  332. package/dist/{request-meta-BW0the1R.mjs → request-meta-C6yGqnGD.mjs} +1 -1
  333. package/dist/{resolve-pZ4NQM-X.mjs → resolve-CpOV2jt_.mjs} +1 -1
  334. package/dist/review-payload-LLIi1sxO.mjs +1386 -0
  335. package/dist/{review-requests-DICrYH2-.mjs → review-requests-BF2eEKr8.mjs} +93 -37
  336. package/dist/{review-requests-BTKfeWlS.mjs → review-requests-C7prIbCo.mjs} +2 -2
  337. package/dist/{review-route-helpers-DaZBBps8.mjs → review-route-helpers-BYx3Px90.mjs} +2 -2
  338. package/dist/{revision-De7OmYVD.mjs → revision-090sZyGc.mjs} +28 -22
  339. package/dist/revocation-DZ8e4JCS.mjs +53 -0
  340. package/dist/{runner-DJiRFyLI.mjs → runner-CVeq0266.mjs} +594 -491
  341. package/dist/{runner-Dye73myO.d.mts → runner-Cxl-vyk2.d.mts} +1 -1
  342. package/dist/{runs-DEujUDOj.mjs → runs-B8kCirJ6.mjs} +5 -5
  343. package/dist/runtime-env-v-1UXPAH.mjs +19 -0
  344. package/dist/runtime.d.mts +10 -10
  345. package/dist/runtime.mjs +5 -5
  346. package/dist/schema-DFeC5axi.mjs +8 -0
  347. package/dist/{search-DxUKN9Zz.mjs → search-C9qOBgvo.mjs} +4 -4
  348. package/dist/{secrets-AdCrGg1c.mjs → secrets-BP2YTPWn.mjs} +10 -11
  349. package/dist/{sections-BPFOEMK6.mjs → sections-CkoQY7Z9.mjs} +2 -2
  350. package/dist/seed/index.d.mts +2 -2
  351. package/dist/seed/index.mjs +29 -25
  352. package/dist/seo/index.d.mts +3 -3
  353. package/dist/seo/index.mjs +11 -10
  354. package/dist/{seo-GfovzqpU.mjs → seo-Bypxm1iD.mjs} +1 -1
  355. package/dist/{seo-DWHdo5aW.mjs → seo-DYpc_rQ1.mjs} +25 -15
  356. package/dist/{service-BrNKVCjC.mjs → service-DOFqfUVv.mjs} +46 -21
  357. package/dist/{service-DbgjHWyW.mjs → service-mJBl4ZP4.mjs} +2 -2
  358. package/dist/{session-user-D8WwGEPH.mjs → session-user-DacoiKrJ.mjs} +1 -1
  359. package/dist/{settings-BKEHw6Bu.mjs → settings-2p7TuNWG.mjs} +2 -2
  360. package/dist/{settings-CAsQLi0N.mjs → settings-DRFy8JQx.mjs} +8 -8
  361. package/dist/{setup-complete-CHCYS5KV.mjs → setup-complete-CWMnrNFN.mjs} +1 -1
  362. package/dist/{site-activity-7oezuHXK.mjs → site-activity-BrN2NviL.mjs} +11 -4
  363. package/dist/{site-context-CA7rbxux.mjs → site-context-D9oETfxF.mjs} +50 -37
  364. package/dist/{site-url-DoZf_jVj.mjs → site-url-DoTPKRND.mjs} +1 -1
  365. package/dist/state-D8AogXCV.mjs +30 -0
  366. package/dist/storage/local.d.mts +1 -1
  367. package/dist/storage/local.mjs +1 -1
  368. package/dist/storage/s3.d.mts +1 -1
  369. package/dist/storage/s3.mjs +3 -3
  370. package/dist/{store-c4qx3gVh.mjs → store-CjmmGlVw.mjs} +37 -12
  371. package/dist/submission-BLvkvewK.mjs +411 -0
  372. package/dist/{taxonomies-ALDiRQ84.mjs → taxonomies-C5ayPp3T.mjs} +3 -3
  373. package/dist/{taxonomies-93DV-1QT.mjs → taxonomies-DW6Fps-w.mjs} +7 -7
  374. package/dist/{taxonomy-BOBTJ_aE.mjs → taxonomy-DWxxLpp5.mjs} +3 -3
  375. package/dist/{tokens-c-qxNqzC.mjs → tokens-I3tSjoFI.mjs} +1 -1
  376. package/dist/{trusted-proxy-CdEl6g6B.mjs → trusted-proxy-CvDP0g0F.mjs} +4 -12
  377. package/dist/{types-6KmeXInJ.d.mts → types-BFoQ5a1v.d.mts} +1 -1
  378. package/dist/{types-BpSTdH1H.mjs → types-BqxIv8Il.mjs} +2 -2
  379. package/dist/{types-BRCUO8NR.d.mts → types-CVRNRAA5.d.mts} +1 -0
  380. package/dist/{types-CfpX1og5.d.mts → types-Tt_IGMno.d.mts} +360 -172
  381. package/dist/ui/server-runtime.d.mts +13 -13
  382. package/dist/ui/server-runtime.mjs +28 -26
  383. package/dist/{user-D0NJ7gYf.mjs → user-1-YV30lf.mjs} +2 -2
  384. package/dist/{utils-BK2efsHv.mjs → utils-BoWkoty8.mjs} +2 -2
  385. package/dist/{validate-CDWVODvc.d.mts → validate-CCOsvPg2.d.mts} +3 -3
  386. package/dist/{validate-C9g9iX3q.mjs → validate-CupwWNWL.mjs} +3 -3
  387. package/dist/version-DpT-k_Ny.mjs +6 -0
  388. package/dist/{widgets-Cm5Qx2Np.mjs → widgets-DbOctkXv.mjs} +3 -3
  389. package/dist/{wordpress-slugs-WdPZaVXf.mjs → wordpress-slugs-pQlLXbKn.mjs} +1 -1
  390. package/dist/{worker-Bhuu7eqS.mjs → worker-wjRq4FI9.mjs} +76 -47
  391. package/dist/workers-build-QVrquLLe.mjs +36 -0
  392. package/dist/{zod-generator-DS5oZNaL.mjs → zod-generator-BzACAoR5.mjs} +2 -2
  393. package/package.json +34 -8
  394. package/dist/after-BfniwgIf.mjs +0 -9
  395. package/dist/api-tokens-CmT83Bgj.mjs +0 -3
  396. package/dist/db/libsql-http.d.mts +0 -27
  397. package/dist/db/libsql-http.mjs +0 -29
  398. package/dist/libsql-dialect-CANq6UNI.mjs +0 -47
  399. package/dist/oauth-user-lookup-B451pZmd.mjs +0 -25
  400. package/dist/review-payload-f1L4lzQg.mjs +0 -111
  401. package/dist/revocation-CkTOhdlw.mjs +0 -42
  402. package/dist/schema-IjuRxkqq.mjs +0 -8
  403. package/dist/submission-C47cHBIg.mjs +0 -67
  404. package/dist/transaction-BGQgnwUi.mjs +0 -28
  405. package/dist/version-CJqc1mwj.mjs +0 -6
  406. /package/dist/{base64-F8-DUraK.mjs → base64-Cz-aU0X1.mjs} +0 -0
  407. /package/dist/{challenge-store-CDKfye2r.mjs → challenge-store-DFGsDtCj.mjs} +0 -0
  408. /package/dist/{components-DAq_4iPX.mjs → components-gMTtJqHg.mjs} +0 -0
  409. /package/dist/{config-CVssduLe.mjs → config-XW5tMrH8.mjs} +0 -0
  410. /package/dist/{content-index-names-Bbu1FY1r.mjs → content-index-names-CDc2IQIx.mjs} +0 -0
  411. /package/dist/{context-types-CPWAJRs5.mjs → context-types-DLD_HnKT.mjs} +0 -0
  412. /package/dist/{default-BeIzUa1e.mjs → default-w3MwLng7.mjs} +0 -0
  413. /package/dist/{email-console-Bfi_exVg.mjs → email-console-CpvgEN1w.mjs} +0 -0
  414. /package/dist/{error-DLg1H2LT.mjs → error-B-44r5TD.mjs} +0 -0
  415. /package/dist/{escape-C6lkys0j.mjs → escape-B1GM0yJU.mjs} +0 -0
  416. /package/dist/{experimental-workflows-B9x8delL.mjs → experimental-workflows-fzJHB3ZI.mjs} +0 -0
  417. /package/dist/{hash-jhbF98tT.mjs → hash-DvMZXj2L.mjs} +0 -0
  418. /package/dist/{media-url-CL3NzgLh.mjs → media-url-D-elxQjL.mjs} +0 -0
  419. /package/dist/{mime-CDTtL7jE.mjs → mime-D_ae-u_U.mjs} +0 -0
  420. /package/dist/{mode-DJeacFCZ.mjs → mode-BJwb_MgK.mjs} +0 -0
  421. /package/dist/{normalize-Ev3FiBMx.mjs → normalize-5rct_U0I.mjs} +0 -0
  422. /package/dist/{oauth-state-store-Do1a_o3H.mjs → oauth-state-store-D2H9hKcN.mjs} +0 -0
  423. /package/dist/{options-1dBRkoCl.mjs → options-BcqHWpc-.mjs} +0 -0
  424. /package/dist/{output-8j9oltTf.mjs → output-CdmbQioY.mjs} +0 -0
  425. /package/dist/{parser-C9rzPuSZ.mjs → parser-ehIlj32k.mjs} +0 -0
  426. /package/dist/{passkey-config-CRN44T04.mjs → passkey-config-sUQoLEj_.mjs} +0 -0
  427. /package/dist/{patterns-3XE9bU4r.mjs → patterns-CZ7D4y_R.mjs} +0 -0
  428. /package/dist/{placeholder-D03pGvqM.d.mts → placeholder-CQKI6vLd.d.mts} +0 -0
  429. /package/dist/{portable-text-BdRm4uZq.d.mts → portable-text-BE7nszX6.d.mts} +0 -0
  430. /package/dist/{portable-text-tIk9_uz_.mjs → portable-text-DH3Om_2D.mjs} +0 -0
  431. /package/dist/{process-cache-B-L-A9zg.mjs → process-cache-MHM4Sqzs.mjs} +0 -0
  432. /package/dist/{provider-loader-C4i82ll1.mjs → provider-loader-Dnv2neOu.mjs} +0 -0
  433. /package/dist/{public-discovery-CyDzK1-S.mjs → public-discovery-CTql6jdZ.mjs} +0 -0
  434. /package/dist/{public-url-BVIjzMo3.mjs → public-url-4sMO36Gw.mjs} +0 -0
  435. /package/dist/{public-url-oudwI7K0.mjs → public-url-DNt9A1yS.mjs} +0 -0
  436. /package/dist/{redirect-Dp5u-8dH.mjs → redirect-Cjjb5VYr.mjs} +0 -0
  437. /package/dist/{request-cache-BruBnFAR.mjs → request-cache-DPmV5nk4.mjs} +0 -0
  438. /package/dist/{seo-contributions-BAtRDXEQ.mjs → seo-contributions-atY3jZEV.mjs} +0 -0
  439. /package/dist/{service-DeX1PRNt.mjs → service-CeEi6nax.mjs} +0 -0
  440. /package/dist/{setup-nonce-D-CEYlw7.mjs → setup-nonce-BUmfCiY1.mjs} +0 -0
  441. /package/dist/{sidecar-client-Bw2C0XTf.mjs → sidecar-client-CbrX8nuw.mjs} +0 -0
  442. /package/dist/{slugify-KSsVD_D3.mjs → slugify-Di8Q_MFq.mjs} +0 -0
  443. /package/dist/{ssrf-C7tTSD1r.mjs → ssrf-COxLChKv.mjs} +0 -0
  444. /package/dist/{stable-hash-DF7R5eN8.mjs → stable-hash-DEtJgcp7.mjs} +0 -0
  445. /package/dist/{status-Bba6RbkS.mjs → status-DBSB6tdS.mjs} +0 -0
  446. /package/dist/{transport-ktLL9r2O.d.mts → transport-CZbtxgKZ.d.mts} +0 -0
  447. /package/dist/{transport-BddGhTAI.mjs → transport-aPKvM53n.mjs} +0 -0
  448. /package/dist/{types-CKIt_jmM.d.mts → types-1qU0-N1P.d.mts} +0 -0
  449. /package/dist/{types-BQZFeZjd.mjs → types-BKsk4nnM.mjs} +0 -0
  450. /package/dist/{types-CLMOusxP.d.mts → types-BWsEjujW.d.mts} +0 -0
  451. /package/dist/{types--3oJQ0hs.d.mts → types-CAD4OvmF.d.mts} +0 -0
  452. /package/dist/{types-BbkkkAb6.mjs → types-ChSk0dmw.mjs} +0 -0
  453. /package/dist/{types-C0DPvhR5.mjs → types-CyBH89BS.mjs} +0 -0
  454. /package/dist/{types-CU3Wn2HC.d.mts → types-DNPP-eu4.d.mts} +0 -0
  455. /package/dist/{types-CPaVj_GC.d.mts → types-SddyDti7.d.mts} +0 -0
  456. /package/dist/{url-C_pLSrGZ.mjs → url-Ce0qtSdB.mjs} +0 -0
  457. /package/dist/{url-Dumsft7G.mjs → url-DfqolpO2.mjs} +0 -0
  458. /package/dist/{validate-VPnKoIzW.mjs → validate-Co3j6T_K.mjs} +0 -0
@@ -1,17 +1,26 @@
1
- import { a as __exportAll } from "./runner-DJiRFyLI.mjs";
2
- import { n as getI18nConfig } from "./config-CVssduLe.mjs";
3
- import { c as invalidateMenuObjectCache } from "./object-cache-D51qOseS.mjs";
4
- import { t as withTransaction } from "./transaction-BGQgnwUi.mjs";
1
+ import { c as __exportAll } from "./runner-CVeq0266.mjs";
2
+ import { AtomicWriteConflict, atomicBatch, rowUnchanged } from "./database/batch.mjs";
3
+ import { n as getI18nConfig } from "./config-XW5tMrH8.mjs";
4
+ import { c as invalidateMenuObjectCache } from "./object-cache-BGjIlY9s.mjs";
5
+ import { sql } from "kysely";
5
6
  import { ulid } from "ulidx";
6
7
 
7
8
  //#region src/database/repositories/menu.ts
8
9
  /**
9
- * Thrown from inside a repository transaction when the menu the caller
10
- * resolved earlier has since been deleted. Handlers translate this to a
11
- * `NOT_FOUND` API response. Necessary because D1 disables FK enforcement
12
- * (so `ON DELETE CASCADE` won't fire), and an unchecked `setItems` would
13
- * happily insert items whose `menu_id` no longer exists, leaving orphans.
10
+ * Menu repository
11
+ *
12
+ * Owns every SQL touch for `_dineway_menus` and `_dineway_menu_items`, plus the
13
+ * row→entity mapping. Matches the architecture used by every other resource
14
+ * (content, taxonomies, redirects, comments, media): handlers stay thin and
15
+ * orchestrate; the repository is the single place where snake_case DB columns
16
+ * become camelCase entities (and vice versa).
17
+ *
18
+ * i18n: menus are per-locale. `(name, locale)` is unique. Translations of the
19
+ * same menu share a `translation_group` ULID. Menu item `reference_id` stores
20
+ * the referenced content's translation_group (not a specific row id) so a
21
+ * single menu item survives content translations.
14
22
  */
23
+ /** The resolved menu disappeared before its atomic mutation could commit. */
15
24
  var MenuGoneError = class extends Error {
16
25
  constructor(menuId) {
17
26
  super(`Menu ${menuId} was deleted while being modified`);
@@ -136,45 +145,40 @@ var MenuRepository = class {
136
145
  */
137
146
  async create(input) {
138
147
  const id = ulid();
139
- let translationGroup = id;
140
- let sourceMenuId = null;
141
- if (input.translationOf) {
142
- const source = await this.findById(input.translationOf);
143
- if (!source) throw new Error("Source menu for translation not found");
144
- translationGroup = source.translationGroup ?? source.id;
145
- sourceMenuId = source.id;
146
- }
147
- await withTransaction(this.db, async (trx) => {
148
- await trx.insertInto("_dineway_menus").values({
149
- id,
150
- name: input.name,
151
- label: input.label,
148
+ const source = input.translationOf ? await this.db.selectFrom("_dineway_menus").selectAll().where("id", "=", input.translationOf).executeTakeFirst() : null;
149
+ if (input.translationOf && !source) throw new Error("Source menu for translation not found");
150
+ const checks = source ? [rowUnchanged("_dineway_menus", source)] : [];
151
+ const statements = [this.db.insertInto("_dineway_menus").values({
152
+ id,
153
+ name: input.name,
154
+ label: input.label,
155
+ ...input.locale !== void 0 ? { locale: input.locale } : {},
156
+ translation_group: source?.translation_group ?? source?.id ?? id
157
+ }).compile()];
158
+ if (source) {
159
+ const items = await this.snapshotItems(source.id);
160
+ checks.push(...items.checks);
161
+ const idMap = new Map(items.rows.map((item) => [item.id, ulid()]));
162
+ for (const item of orderParentsFirst(items.rows)) statements.push(this.db.insertInto("_dineway_menu_items").values({
163
+ id: idMap.get(item.id),
164
+ menu_id: id,
165
+ parent_id: item.parent_id ? idMap.get(item.parent_id) : null,
166
+ sort_order: item.sort_order,
167
+ type: item.type,
168
+ reference_collection: item.reference_collection,
169
+ reference_id: item.reference_id,
170
+ custom_url: item.custom_url,
171
+ label: item.label,
172
+ title_attr: item.title_attr,
173
+ target: item.target,
174
+ css_classes: item.css_classes,
152
175
  ...input.locale !== void 0 ? { locale: input.locale } : {},
153
- translation_group: translationGroup
154
- }).execute();
155
- if (sourceMenuId) {
156
- const sourceItems = await trx.selectFrom("_dineway_menu_items").selectAll().where("menu_id", "=", sourceMenuId).orderBy("sort_order", "asc").execute();
157
- if (sourceItems.length > 0) {
158
- const idMap = /* @__PURE__ */ new Map();
159
- for (const item of sourceItems) idMap.set(item.id, ulid());
160
- await trx.insertInto("_dineway_menu_items").values(sourceItems.map((item) => ({
161
- id: idMap.get(item.id),
162
- menu_id: id,
163
- parent_id: item.parent_id ? idMap.get(item.parent_id) ?? null : null,
164
- sort_order: item.sort_order,
165
- type: item.type,
166
- reference_collection: item.reference_collection,
167
- reference_id: item.reference_id,
168
- custom_url: item.custom_url,
169
- label: item.label,
170
- title_attr: item.title_attr,
171
- target: item.target,
172
- css_classes: item.css_classes,
173
- ...input.locale !== void 0 ? { locale: input.locale } : {},
174
- translation_group: item.translation_group ?? item.id
175
- }))).execute();
176
- }
177
- }
176
+ translation_group: item.translation_group ?? item.id
177
+ }).compile());
178
+ }
179
+ await atomicBatch(this.db, {
180
+ checks,
181
+ statements
178
182
  });
179
183
  invalidateMenuObjectCache();
180
184
  const created = await this.findById(id);
@@ -191,17 +195,13 @@ var MenuRepository = class {
191
195
  }
192
196
  return await this.findById(id);
193
197
  }
194
- /**
195
- * Delete a menu. Items are deleted explicitly first because D1 disables
196
- * FK enforcement at the database level, so `ON DELETE CASCADE` declared in
197
- * migration 005 cannot be relied on. On SQLite/Postgres the cascade also
198
- * fires, making the explicit delete a no-op there.
199
- */
198
+ /** Delete the menu and its items in one commit. */
200
199
  async delete(id) {
201
- if (!await this.findById(id)) return false;
202
- await withTransaction(this.db, async (trx) => {
203
- await trx.deleteFrom("_dineway_menu_items").where("menu_id", "=", id).execute();
204
- await trx.deleteFrom("_dineway_menus").where("id", "=", id).execute();
200
+ const existing = await this.db.selectFrom("_dineway_menus").selectAll().where("id", "=", id).executeTakeFirst();
201
+ if (!existing) return false;
202
+ await atomicBatch(this.db, {
203
+ checks: [rowUnchanged("_dineway_menus", existing)],
204
+ statements: [this.db.deleteFrom("_dineway_menu_items").where("menu_id", "=", id).compile(), this.db.deleteFrom("_dineway_menus").where("id", "=", id).compile()]
205
205
  });
206
206
  invalidateMenuObjectCache();
207
207
  return true;
@@ -294,34 +294,39 @@ var MenuRepository = class {
294
294
  * Returns the count of inserted items (matches the existing handler API).
295
295
  */
296
296
  async setItems(menuId, locale, items) {
297
- await withTransaction(this.db, async (trx) => {
298
- if (!await trx.selectFrom("_dineway_menus").select("id").where("id", "=", menuId).executeTakeFirst()) throw new MenuGoneError(menuId);
299
- await trx.deleteFrom("_dineway_menu_items").where("menu_id", "=", menuId).execute();
300
- const insertedIds = [];
301
- for (let i = 0; i < items.length; i++) {
302
- const item = items[i];
303
- if (!item) continue;
304
- const id = ulid();
305
- const parentId = item.parentIndex !== void 0 ? insertedIds[item.parentIndex] ?? null : null;
306
- await trx.insertInto("_dineway_menu_items").values({
307
- id,
308
- menu_id: menuId,
309
- parent_id: parentId,
310
- sort_order: i,
311
- type: item.type,
312
- reference_collection: item.referenceCollection ?? null,
313
- reference_id: item.referenceId ?? null,
314
- custom_url: item.customUrl ?? null,
315
- label: item.label,
316
- title_attr: item.titleAttr ?? null,
317
- target: item.target ?? null,
318
- css_classes: item.cssClasses ?? null,
319
- locale
320
- }).execute();
321
- insertedIds.push(id);
322
- }
323
- await trx.updateTable("_dineway_menus").set({ updated_at: (/* @__PURE__ */ new Date()).toISOString() }).where("id", "=", menuId).execute();
324
- });
297
+ const menu = await this.db.selectFrom("_dineway_menus").selectAll().where("id", "=", menuId).executeTakeFirst();
298
+ if (!menu) throw new MenuGoneError(menuId);
299
+ const previous = await this.snapshotItems(menuId);
300
+ const statements = [this.db.deleteFrom("_dineway_menu_items").where("menu_id", "=", menuId).compile()];
301
+ const ids = items.map(() => ulid());
302
+ for (const [index, item] of items.entries()) {
303
+ if (item.parentIndex !== void 0 && (!Number.isInteger(item.parentIndex) || item.parentIndex < 0 || item.parentIndex >= index)) throw new Error("Menu parents must reference an earlier item");
304
+ statements.push(this.db.insertInto("_dineway_menu_items").values({
305
+ id: ids[index],
306
+ menu_id: menuId,
307
+ parent_id: item.parentIndex !== void 0 ? ids[item.parentIndex] : null,
308
+ sort_order: index,
309
+ type: item.type,
310
+ reference_collection: item.referenceCollection ?? null,
311
+ reference_id: item.referenceId ?? null,
312
+ custom_url: item.customUrl ?? null,
313
+ label: item.label,
314
+ title_attr: item.titleAttr ?? null,
315
+ target: item.target ?? null,
316
+ css_classes: item.cssClasses ?? null,
317
+ locale
318
+ }).compile());
319
+ }
320
+ statements.push(this.db.updateTable("_dineway_menus").set({ updated_at: (/* @__PURE__ */ new Date()).toISOString() }).where("id", "=", menuId).compile());
321
+ try {
322
+ await atomicBatch(this.db, {
323
+ checks: [rowUnchanged("_dineway_menus", menu), ...previous.checks],
324
+ statements
325
+ });
326
+ } catch (error) {
327
+ if (error instanceof AtomicWriteConflict && !await this.findById(menuId)) throw new MenuGoneError(menuId);
328
+ throw error;
329
+ }
325
330
  invalidateMenuObjectCache();
326
331
  return { itemCount: items.length };
327
332
  }
@@ -330,16 +335,59 @@ var MenuRepository = class {
330
335
  * malicious payload cannot move foreign items into this menu's siblings.
331
336
  */
332
337
  async reorderItems(menuId, items) {
333
- invalidateMenuObjectCache();
334
- return withTransaction(this.db, async (trx) => {
335
- for (const item of items) await trx.updateTable("_dineway_menu_items").set({
338
+ const snapshot = await this.snapshotItems(menuId);
339
+ const rows = new Map(snapshot.rows.map((row) => [row.id, row]));
340
+ const statements = [];
341
+ for (const item of items) {
342
+ const row = rows.get(item.id);
343
+ if (!row) continue;
344
+ rows.set(item.id, {
345
+ ...row,
336
346
  parent_id: item.parentId,
337
347
  sort_order: item.sortOrder
338
- }).where("id", "=", item.id).where("menu_id", "=", menuId).execute();
339
- return (await trx.selectFrom("_dineway_menu_items").selectAll().where("menu_id", "=", menuId).orderBy("sort_order", "asc").execute()).map(rowToMenuItem);
348
+ });
349
+ statements.push(this.db.updateTable("_dineway_menu_items").set({
350
+ parent_id: item.parentId,
351
+ sort_order: item.sortOrder
352
+ }).where("id", "=", item.id).where("menu_id", "=", menuId).compile());
353
+ }
354
+ orderParentsFirst([...rows.values()]);
355
+ await atomicBatch(this.db, {
356
+ checks: snapshot.checks,
357
+ statements
340
358
  });
359
+ invalidateMenuObjectCache();
360
+ return this.findItems(menuId);
361
+ }
362
+ async snapshotItems(menuId) {
363
+ const rows = await this.db.selectFrom("_dineway_menu_items").selectAll().where("menu_id", "=", menuId).orderBy("sort_order", "asc").execute();
364
+ return {
365
+ rows,
366
+ checks: [sql`(SELECT COUNT(*) FROM _dineway_menu_items WHERE menu_id = ${menuId}) = ${rows.length}`, ...rows.map((row) => rowUnchanged("_dineway_menu_items", row))]
367
+ };
341
368
  }
342
369
  };
370
+ function orderParentsFirst(items) {
371
+ const remaining = new Map(items.map((item) => [item.id, item]));
372
+ const visited = /* @__PURE__ */ new Set();
373
+ const visiting = /* @__PURE__ */ new Set();
374
+ const ordered = [];
375
+ const visit = (item) => {
376
+ if (visited.has(item.id)) return;
377
+ if (visiting.has(item.id)) throw new Error("Menu parent links contain a cycle");
378
+ visiting.add(item.id);
379
+ if (item.parent_id) {
380
+ const parent = remaining.get(item.parent_id);
381
+ if (!parent) throw new Error("Menu parent must belong to the same menu");
382
+ visit(parent);
383
+ }
384
+ visiting.delete(item.id);
385
+ visited.add(item.id);
386
+ ordered.push(item);
387
+ };
388
+ for (const item of items) visit(item);
389
+ return ordered;
390
+ }
343
391
 
344
392
  //#endregion
345
393
  //#region src/api/handlers/menus.ts
@@ -0,0 +1,76 @@
1
+ import { o as assertD1Migrations } from "./runner-CVeq0266.mjs";
2
+ import { n as d1Database } from "./d1-binding-D6HZa3ks.mjs";
3
+ import { Migrator } from "kysely";
4
+
5
+ //#region src/plugins/migrations.ts
6
+ const LEADING_AT = /^@/;
7
+ var StaticPluginMigrationProvider = class {
8
+ constructor(migrations) {
9
+ this.migrations = migrations;
10
+ }
11
+ async getMigrations() {
12
+ return this.migrations;
13
+ }
14
+ };
15
+ /**
16
+ * Run migrations contributed by configured trusted native plugins.
17
+ *
18
+ * Each plugin receives isolated Kysely migration and lock tables. This keeps migration history valid
19
+ * when another plugin is removed and lets different plugins safely reuse local migration names.
20
+ */
21
+ async function runPluginMigrations(db, plugins) {
22
+ const applied = [];
23
+ for (const plugin of [...plugins].toSorted((left, right) => left.id.localeCompare(right.id))) {
24
+ if (Object.keys(plugin.migrations).length === 0) continue;
25
+ const tables = pluginMigrationTableNames(plugin.id);
26
+ if (d1Database(db)) {
27
+ await assertD1Migrations(db, tables.migrations, Object.keys(plugin.migrations));
28
+ applied.push({
29
+ pluginId: plugin.id,
30
+ applied: []
31
+ });
32
+ continue;
33
+ }
34
+ const { error, results } = await new Migrator({
35
+ db,
36
+ provider: new StaticPluginMigrationProvider(plugin.migrations),
37
+ migrationTableName: tables.migrations,
38
+ migrationLockTableName: tables.lock
39
+ }).migrateToLatest();
40
+ const successful = results?.filter((result) => result.status === "Success").map((result) => result.migrationName) ?? [];
41
+ if (error) {
42
+ const failed = results?.find((result) => result.status === "Error")?.migrationName;
43
+ throw new Error(`Plugin migration failed for ${plugin.id}${failed ? ` (${failed})` : ""}: ${errorMessage(error)}`, { cause: error });
44
+ }
45
+ applied.push({
46
+ pluginId: plugin.id,
47
+ applied: successful
48
+ });
49
+ }
50
+ return applied;
51
+ }
52
+ function pluginMigrationTableNames(pluginId) {
53
+ const slug = pluginId.replace(LEADING_AT, "").replaceAll("/", "_").replaceAll("-", "_").slice(0, 20);
54
+ const suffix = fnv1a(pluginId);
55
+ return {
56
+ migrations: `_dineway_plugin_migration_${slug}_${suffix}`,
57
+ lock: `_dineway_plugin_migration_lock_${slug}_${suffix}`
58
+ };
59
+ }
60
+ function fnv1a(value) {
61
+ let hash = 2166136261;
62
+ for (let index = 0; index < value.length; index++) {
63
+ hash ^= value.charCodeAt(index);
64
+ hash = Math.imul(hash, 16777619);
65
+ }
66
+ return (hash >>> 0).toString(16).padStart(8, "0");
67
+ }
68
+ function errorMessage(error) {
69
+ if (!(error instanceof Error)) return JSON.stringify(error);
70
+ if (error.message) return error.message;
71
+ if (error.cause instanceof Error && error.cause.message) return error.cause.message;
72
+ return "unknown error";
73
+ }
74
+
75
+ //#endregion
76
+ export { runPluginMigrations as n, pluginMigrationTableNames as t };
@@ -0,0 +1,43 @@
1
+ import { rowUnchanged } from "./database/batch.mjs";
2
+ import { sql } from "kysely";
3
+ import { toRoleLevel } from "@dineway-ai/auth";
4
+
5
+ //#region src/api/handlers/oauth-authority.ts
6
+ /** Keep token permissions tied to the same account and client state through commit. */
7
+ async function readTokenAuthority(db, userId, clientId) {
8
+ const user = await db.selectFrom("users").select([
9
+ "id",
10
+ "role",
11
+ "disabled"
12
+ ]).where("id", "=", userId).executeTakeFirst();
13
+ const client = clientId ? await db.selectFrom("_dineway_oauth_clients").select([
14
+ "id",
15
+ "redirect_uris",
16
+ "scopes"
17
+ ]).where("id", "=", clientId).executeTakeFirst() : void 0;
18
+ const checks = user ? [rowUnchanged("users", user)] : [];
19
+ if (client) checks.push(rowUnchanged("_dineway_oauth_clients", client));
20
+ else if (clientId) checks.push(sql`NOT EXISTS (SELECT 1 FROM _dineway_oauth_clients WHERE id = ${clientId})`);
21
+ return {
22
+ user: user ? {
23
+ role: toRoleLevel(user.role),
24
+ disabled: user.disabled === 1
25
+ } : null,
26
+ client: client ? {
27
+ scopes: client.scopes ? parseStringList(client.scopes) : null,
28
+ redirectUris: parseStringList(client.redirect_uris)
29
+ } : null,
30
+ checks
31
+ };
32
+ }
33
+ function parseStringList(value) {
34
+ const parsed = JSON.parse(value);
35
+ if (!Array.isArray(parsed)) throw new Error("Invalid stored OAuth client configuration");
36
+ return parsed.map((item) => {
37
+ if (typeof item !== "string") throw new Error("Invalid stored OAuth client configuration");
38
+ return item;
39
+ });
40
+ }
41
+
42
+ //#endregion
43
+ export { readTokenAuthority as t };
@@ -1,9 +1,11 @@
1
- import { t as withTransaction } from "./transaction-BGQgnwUi.mjs";
2
- import { a as hashApiToken, n as TOKEN_PREFIXES, r as generatePrefixedToken, t as ALL_VALID_SCOPES } from "./api-tokens-CmT83Bgj.mjs";
3
- import { a as filterExperimentalSiteContextWorkflowScopes, i as experimentalSiteContextWorkflowsEnabled, o as getExperimentalSiteContextWorkflowScopesDisabledMessage, r as disabledExperimentalSiteContextWorkflowScopes } from "./experimental-workflows-B9x8delL.mjs";
4
- import { c as validateRedirectUri, o as lookupOAuthClient, s as validateClientRedirectUri } from "./oauth-clients-tovQ4D4h.mjs";
5
- import { t as lookupUserRoleAndStatus } from "./oauth-user-lookup-B451pZmd.mjs";
6
- import { clampScopes, computeS256Challenge, secureCompare } from "@dineway-ai/auth";
1
+ import { AtomicWriteConflict, atomicBatch, rowUnchanged } from "./database/batch.mjs";
2
+ import { r as currentIsoTimestampValue } from "./dialect-helpers-C6xtO-Ui.mjs";
3
+ import { a as hashApiToken, n as TOKEN_PREFIXES, r as generatePrefixedToken, t as ALL_VALID_SCOPES } from "./api-tokens-DA18zxza.mjs";
4
+ import { a as filterExperimentalSiteContextWorkflowScopes, i as experimentalSiteContextWorkflowsEnabled, o as getExperimentalSiteContextWorkflowScopesDisabledMessage, r as disabledExperimentalSiteContextWorkflowScopes } from "./experimental-workflows-fzJHB3ZI.mjs";
5
+ import { c as validateRedirectUri, s as validateClientRedirectUri } from "./oauth-clients-Cr4pdIAE.mjs";
6
+ import { t as readTokenAuthority } from "./oauth-authority-DOjME4Hh.mjs";
7
+ import { sql } from "kysely";
8
+ import { clampScopes, computeS256Challenge, secureCompare, toRoleLevel } from "@dineway-ai/auth";
7
9
  import { generateCodeVerifier } from "arctic";
8
10
 
9
11
  //#region src/api/handlers/oauth-authorization.ts
@@ -58,7 +60,15 @@ async function handleAuthorizationApproval(db, userId, userRole, params) {
58
60
  message: uriError
59
61
  }
60
62
  };
61
- const client = await lookupOAuthClient(db, params.client_id);
63
+ const authority = await readTokenAuthority(db, userId, params.client_id);
64
+ if (!authority.user || authority.user.disabled) return {
65
+ success: false,
66
+ error: {
67
+ code: "FORBIDDEN",
68
+ message: "User account is unavailable"
69
+ }
70
+ };
71
+ const client = authority.client;
62
72
  if (!client) return {
63
73
  success: false,
64
74
  error: {
@@ -96,7 +106,7 @@ async function handleAuthorizationApproval(db, userId, userRole, params) {
96
106
  message: getExperimentalSiteContextWorkflowScopesDisabledMessage()
97
107
  }
98
108
  };
99
- const userScopes = clampScopes(normalizeScopes(requestedScopes), userRole, { includeExperimental: experimentalSiteContextWorkflowsEnabled() });
109
+ const userScopes = clampScopes(normalizeScopes(requestedScopes), toRoleLevel(Math.min(userRole, authority.user.role)), { includeExperimental: experimentalSiteContextWorkflowsEnabled() });
100
110
  const clientScopes = client.scopes;
101
111
  const scopes = clientScopes?.length ? userScopes.filter((s) => clientScopes.includes(s)) : userScopes;
102
112
  if (scopes.length === 0) return {
@@ -108,17 +118,20 @@ async function handleAuthorizationApproval(db, userId, userRole, params) {
108
118
  };
109
119
  const code = generateCodeVerifier();
110
120
  const codeHash = hashApiToken(code);
111
- await db.insertInto("_dineway_authorization_codes").values({
112
- code_hash: codeHash,
113
- client_id: params.client_id,
114
- redirect_uri: params.redirect_uri,
115
- user_id: userId,
116
- scopes: JSON.stringify(scopes),
117
- code_challenge: params.code_challenge,
118
- code_challenge_method: params.code_challenge_method,
119
- resource: params.resource ?? null,
120
- expires_at: expiresAt(AUTH_CODE_TTL_SECONDS)
121
- }).execute();
121
+ await atomicBatch(db, {
122
+ checks: authority.checks,
123
+ statements: [db.insertInto("_dineway_authorization_codes").values({
124
+ code_hash: codeHash,
125
+ client_id: params.client_id,
126
+ redirect_uri: params.redirect_uri,
127
+ user_id: userId,
128
+ scopes: JSON.stringify(scopes),
129
+ code_challenge: params.code_challenge,
130
+ code_challenge_method: params.code_challenge_method,
131
+ resource: params.resource ?? null,
132
+ expires_at: expiresAt(AUTH_CODE_TTL_SECONDS)
133
+ }).compile()]
134
+ });
122
135
  const redirectUrl = new URL(params.redirect_uri);
123
136
  redirectUrl.searchParams.set("code", code);
124
137
  if (params.state) redirectUrl.searchParams.set("state", params.state);
@@ -153,7 +166,7 @@ async function handleAuthorizationCodeExchange(db, params) {
153
166
  }
154
167
  };
155
168
  const codeHash = hashApiToken(params.code);
156
- const row = await db.deleteFrom("_dineway_authorization_codes").where("code_hash", "=", codeHash).returningAll().executeTakeFirst();
169
+ const row = await db.selectFrom("_dineway_authorization_codes").selectAll().where("code_hash", "=", codeHash).executeTakeFirst();
157
170
  if (!row) return {
158
171
  success: false,
159
172
  error: {
@@ -161,91 +174,62 @@ async function handleAuthorizationCodeExchange(db, params) {
161
174
  message: "Invalid authorization code"
162
175
  }
163
176
  };
164
- if (new Date(row.expires_at) < /* @__PURE__ */ new Date()) return {
165
- success: false,
166
- error: {
167
- code: "invalid_grant",
168
- message: "Authorization code expired"
169
- }
170
- };
171
- if (row.redirect_uri !== params.redirect_uri) return {
172
- success: false,
173
- error: {
174
- code: "invalid_grant",
175
- message: "redirect_uri mismatch"
176
- }
177
- };
178
- if (row.client_id !== params.client_id) return {
179
- success: false,
180
- error: {
181
- code: "invalid_grant",
182
- message: "client_id mismatch"
183
- }
184
- };
185
- if (!secureCompare(computeS256Challenge(params.code_verifier), row.code_challenge)) return {
186
- success: false,
187
- error: {
188
- code: "invalid_grant",
189
- message: "PKCE verification failed"
190
- }
191
- };
192
- if (row.resource && params.resource && row.resource !== params.resource) return {
193
- success: false,
194
- error: {
195
- code: "invalid_grant",
196
- message: "resource mismatch"
197
- }
198
- };
199
- const userInfo = await lookupUserRoleAndStatus(db, row.user_id);
200
- if (!userInfo) return {
201
- success: false,
202
- error: {
203
- code: "invalid_grant",
204
- message: "User not found"
205
- }
206
- };
207
- if (userInfo.disabled) return {
208
- success: false,
209
- error: {
210
- code: "invalid_grant",
211
- message: "User account is disabled"
212
- }
177
+ const rejectCode = async (message) => {
178
+ await db.deleteFrom("_dineway_authorization_codes").where("code_hash", "=", codeHash).execute();
179
+ return {
180
+ success: false,
181
+ error: {
182
+ code: "invalid_grant",
183
+ message
184
+ }
185
+ };
213
186
  };
187
+ if (new Date(row.expires_at) < /* @__PURE__ */ new Date()) return rejectCode("Authorization code expired");
188
+ if (row.redirect_uri !== params.redirect_uri) return rejectCode("redirect_uri mismatch");
189
+ if (row.client_id !== params.client_id) return rejectCode("client_id mismatch");
190
+ if (!secureCompare(computeS256Challenge(params.code_verifier), row.code_challenge)) return rejectCode("PKCE verification failed");
191
+ if (row.resource && params.resource && row.resource !== params.resource) return rejectCode("resource mismatch");
192
+ const authority = await readTokenAuthority(db, row.user_id, row.client_id);
193
+ const userInfo = authority.user;
194
+ if (!userInfo) return rejectCode("User not found");
195
+ if (userInfo.disabled) return rejectCode("User account is disabled");
214
196
  let scopes = clampScopes(filterExperimentalSiteContextWorkflowScopes(JSON.parse(row.scopes)), userInfo.role, { includeExperimental: experimentalSiteContextWorkflowsEnabled() });
215
- const client = await lookupOAuthClient(db, row.client_id);
197
+ const client = authority.client;
216
198
  if (client?.scopes?.length) scopes = scopes.filter((scope) => client.scopes.includes(scope));
217
- if (scopes.length === 0) return {
218
- success: false,
219
- error: {
220
- code: "invalid_grant",
221
- message: "User role no longer supports any of the requested scopes"
222
- }
223
- };
199
+ if (scopes.length === 0 || !client || !client.redirectUris.includes(row.redirect_uri)) return rejectCode("User role no longer supports any of the requested scopes");
224
200
  const accessToken = generatePrefixedToken(TOKEN_PREFIXES.OAUTH_ACCESS);
225
201
  const accessExpires = expiresAt(ACCESS_TOKEN_TTL_SECONDS);
226
202
  const refreshToken = generatePrefixedToken(TOKEN_PREFIXES.OAUTH_REFRESH);
227
203
  const refreshExpires = expiresAt(REFRESH_TOKEN_TTL_SECONDS);
228
- await withTransaction(db, async (trx) => {
229
- await trx.insertInto("_dineway_oauth_tokens").values({
230
- token_hash: accessToken.hash,
231
- token_type: "access",
232
- user_id: row.user_id,
233
- scopes: JSON.stringify(scopes),
234
- client_type: "mcp",
235
- expires_at: accessExpires,
236
- refresh_token_hash: refreshToken.hash,
237
- client_id: row.client_id
238
- }).execute();
239
- await trx.insertInto("_dineway_oauth_tokens").values({
240
- token_hash: refreshToken.hash,
241
- token_type: "refresh",
242
- user_id: row.user_id,
243
- scopes: JSON.stringify(scopes),
244
- client_type: "mcp",
245
- expires_at: refreshExpires,
246
- refresh_token_hash: null,
247
- client_id: row.client_id
248
- }).execute();
204
+ await atomicBatch(db, {
205
+ checks: [
206
+ rowUnchanged("_dineway_authorization_codes", row),
207
+ ...authority.checks,
208
+ sql`EXISTS (SELECT 1 FROM _dineway_authorization_codes WHERE code_hash = ${codeHash} AND expires_at > ${currentIsoTimestampValue(db)})`
209
+ ],
210
+ statements: [
211
+ db.deleteFrom("_dineway_authorization_codes").where("code_hash", "=", codeHash).compile(),
212
+ db.insertInto("_dineway_oauth_tokens").values({
213
+ token_hash: accessToken.hash,
214
+ token_type: "access",
215
+ user_id: row.user_id,
216
+ scopes: JSON.stringify(scopes),
217
+ client_type: "mcp",
218
+ expires_at: accessExpires,
219
+ refresh_token_hash: refreshToken.hash,
220
+ client_id: row.client_id
221
+ }).compile(),
222
+ db.insertInto("_dineway_oauth_tokens").values({
223
+ token_hash: refreshToken.hash,
224
+ token_type: "refresh",
225
+ user_id: row.user_id,
226
+ scopes: JSON.stringify(scopes),
227
+ client_type: "mcp",
228
+ expires_at: refreshExpires,
229
+ refresh_token_hash: null,
230
+ client_id: row.client_id
231
+ }).compile()
232
+ ]
249
233
  });
250
234
  return {
251
235
  success: true,
@@ -258,6 +242,13 @@ async function handleAuthorizationCodeExchange(db, params) {
258
242
  }
259
243
  };
260
244
  } catch (error) {
245
+ if (error instanceof AtomicWriteConflict) return {
246
+ success: false,
247
+ error: {
248
+ code: "invalid_grant",
249
+ message: "Authorization code or account permissions changed"
250
+ }
251
+ };
261
252
  console.error("Token exchange error:", error);
262
253
  return {
263
254
  success: false,
@@ -1,5 +1,5 @@
1
- import { s as validateScopes } from "./api-tokens-CmT83Bgj.mjs";
2
- import { o as getExperimentalSiteContextWorkflowScopesDisabledMessage, r as disabledExperimentalSiteContextWorkflowScopes } from "./experimental-workflows-B9x8delL.mjs";
1
+ import { s as validateScopes } from "./api-tokens-DA18zxza.mjs";
2
+ import { o as getExperimentalSiteContextWorkflowScopesDisabledMessage, r as disabledExperimentalSiteContextWorkflowScopes } from "./experimental-workflows-fzJHB3ZI.mjs";
3
3
 
4
4
  //#region src/api/oauth/redirect-uri.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { t as CreateObjectCacheBackendFn } from "../types-CU3Wn2HC.mjs";
1
+ import { t as CreateObjectCacheBackendFn } from "../types-DNPP-eu4.mjs";
2
2
 
3
3
  //#region src/object-cache/memory.d.ts
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { getRequestContext } from "./request-context.mjs";
2
- import { t as after } from "./after-BfniwgIf.mjs";
2
+ import { t as after } from "./after-BVaUn7bK.mjs";
3
3
 
4
4
  //#region src/object-cache/codec.ts
5
5
  /**