dineway 0.2.32 → 0.2.34

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 (457) hide show
  1. package/dist/{activity-CfryM8jO.mjs → activity-CZnq5YlZ.mjs} +2 -2
  2. package/dist/{activity-events-BVo9rMUz.mjs → activity-events-D-yGV7cW.mjs} +1 -1
  3. package/dist/{actor-DrJJsvy6.mjs → actor-DxUAJgQX.mjs} +20 -6
  4. package/dist/{adapters-DHt3f2lu.d.mts → adapters-BQ8CQbBm.d.mts} +5 -7
  5. package/dist/after-BVaUn7bK.mjs +24 -0
  6. package/dist/{allowed-origins-DtBQa4JR.mjs → allowed-origins-DV3LWuWW.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-DF92r_un.mjs → api-CL4pG2zf.mjs} +55 -1215
  12. package/dist/api-tokens-D5K_Csub.mjs +3 -0
  13. package/dist/{api-tokens-CSomx-l3.mjs → api-tokens-_6tMD1W4.mjs} +1 -1
  14. package/dist/{apply-Bs2jXsms.mjs → apply-CYLUMiZg.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 +288 -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 +17 -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 +43 -31
  45. package/dist/astro/routes/api/admin/context/_id_/index.mjs +43 -31
  46. package/dist/astro/routes/api/admin/context/_id_/review.mjs +48 -36
  47. package/dist/astro/routes/api/admin/context/_id_/supersede.mjs +48 -36
  48. package/dist/astro/routes/api/admin/context/diff.mjs +47 -35
  49. package/dist/astro/routes/api/admin/context/index.mjs +48 -36
  50. package/dist/astro/routes/api/admin/context/stale.mjs +47 -35
  51. package/dist/astro/routes/api/admin/hitl-requests/_id_/index.mjs +43 -31
  52. package/dist/astro/routes/api/admin/hitl-requests/_id_/resolve.mjs +47 -35
  53. package/dist/astro/routes/api/admin/hitl-requests/index.mjs +47 -35
  54. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +44 -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 +72 -66
  59. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +72 -66
  60. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +64 -58
  61. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +71 -65
  62. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +71 -65
  63. package/dist/astro/routes/api/admin/plugins/index.mjs +64 -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 +64 -58
  66. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +71 -65
  67. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +64 -58
  68. package/dist/astro/routes/api/admin/plugins/updates.mjs +64 -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 +33 -25
  71. package/dist/astro/routes/api/admin/review-requests/_id_/resolve.mjs +56 -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 +54 -41
  74. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +64 -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 +64 -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.mjs +21 -18
  106. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +19 -16
  107. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  108. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +8 -7
  109. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +8 -7
  110. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +8 -7
  111. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +24 -21
  112. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +35 -22
  113. package/dist/astro/routes/api/content/_collection_/_id_/release-readiness.mjs +9 -9
  114. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +8 -7
  115. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
  116. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +35 -22
  117. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +23 -19
  118. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  119. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +8 -7
  120. package/dist/astro/routes/api/content/_collection_/_id_.mjs +14 -13
  121. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  122. package/dist/astro/routes/api/content/_collection_/index.mjs +14 -13
  123. package/dist/astro/routes/api/content/_collection_/trash.mjs +8 -8
  124. package/dist/astro/routes/api/dashboard.mjs +16 -11
  125. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  126. package/dist/astro/routes/api/health.mjs +1 -1
  127. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  128. package/dist/astro/routes/api/import/probe.mjs +25 -24
  129. package/dist/astro/routes/api/import/wordpress/analyze.mjs +12 -11
  130. package/dist/astro/routes/api/import/wordpress/execute.d.mts +9 -9
  131. package/dist/astro/routes/api/import/wordpress/execute.mjs +51 -42
  132. package/dist/astro/routes/api/import/wordpress/media.d.mts +9 -9
  133. package/dist/astro/routes/api/import/wordpress/media.mjs +14 -14
  134. package/dist/astro/routes/api/import/wordpress/prepare.mjs +52 -40
  135. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +10 -10
  136. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +50 -38
  137. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  138. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +29 -27
  139. package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
  140. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +9 -9
  141. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +56 -47
  142. package/dist/astro/routes/api/integration/artifact.mjs +11 -8
  143. package/dist/astro/routes/api/integration/dispatch.mjs +17 -14
  144. package/dist/astro/routes/api/integrations/_provider_.mjs +11 -8
  145. package/dist/astro/routes/api/integrations/index.mjs +10 -7
  146. package/dist/astro/routes/api/manifest.mjs +5 -5
  147. package/dist/astro/routes/api/mcp.mjs +98 -88
  148. package/dist/astro/routes/api/media/_id_/confirm.mjs +12 -12
  149. package/dist/astro/routes/api/media/_id_.mjs +9 -9
  150. package/dist/astro/routes/api/media/file/_...key_.mjs +1 -1
  151. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
  152. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  153. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  154. package/dist/astro/routes/api/media/upload-url.mjs +13 -13
  155. package/dist/astro/routes/api/media.mjs +16 -16
  156. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +48 -36
  157. package/dist/astro/routes/api/menus/_name_/items.mjs +48 -36
  158. package/dist/astro/routes/api/menus/_name_/reorder.mjs +48 -36
  159. package/dist/astro/routes/api/menus/_name_/translations.mjs +48 -36
  160. package/dist/astro/routes/api/menus/_name_.mjs +48 -36
  161. package/dist/astro/routes/api/menus/index.mjs +48 -36
  162. package/dist/astro/routes/api/oauth/authorize.mjs +9 -7
  163. package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -6
  164. package/dist/astro/routes/api/oauth/device/code.mjs +11 -9
  165. package/dist/astro/routes/api/oauth/device/token.mjs +10 -8
  166. package/dist/astro/routes/api/oauth/register.mjs +4 -4
  167. package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -6
  168. package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -6
  169. package/dist/astro/routes/api/oauth/token.mjs +8 -6
  170. package/dist/astro/routes/api/openapi.json.mjs +5 -5
  171. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +4 -4
  172. package/dist/astro/routes/api/redirects/404s/index.mjs +15 -14
  173. package/dist/astro/routes/api/redirects/404s/summary.mjs +15 -14
  174. package/dist/astro/routes/api/redirects/_id_.mjs +48 -37
  175. package/dist/astro/routes/api/redirects/index.mjs +48 -37
  176. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  177. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +2 -2
  178. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +66 -60
  179. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +66 -60
  180. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +66 -60
  181. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +66 -60
  182. package/dist/astro/routes/api/schema/collections/index.mjs +66 -60
  183. package/dist/astro/routes/api/schema/index.mjs +12 -11
  184. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +64 -58
  185. package/dist/astro/routes/api/schema/orphans/index.mjs +64 -58
  186. package/dist/astro/routes/api/search/enable.mjs +15 -14
  187. package/dist/astro/routes/api/search/index.mjs +14 -13
  188. package/dist/astro/routes/api/search/rebuild.mjs +15 -14
  189. package/dist/astro/routes/api/search/stats.mjs +9 -8
  190. package/dist/astro/routes/api/search/suggest.mjs +14 -13
  191. package/dist/astro/routes/api/sections/_slug_.mjs +48 -36
  192. package/dist/astro/routes/api/sections/index.mjs +48 -36
  193. package/dist/astro/routes/api/settings/email.mjs +5 -5
  194. package/dist/astro/routes/api/settings/reviews.mjs +11 -10
  195. package/dist/astro/routes/api/settings.mjs +48 -36
  196. package/dist/astro/routes/api/setup/admin-verify.mjs +14 -14
  197. package/dist/astro/routes/api/setup/admin.mjs +12 -12
  198. package/dist/astro/routes/api/setup/dev-bypass.mjs +35 -31
  199. package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
  200. package/dist/astro/routes/api/setup/index.mjs +37 -33
  201. package/dist/astro/routes/api/setup/status.mjs +3 -3
  202. package/dist/astro/routes/api/snapshot.mjs +11 -9
  203. package/dist/astro/routes/api/system/heartbeat.mjs +2 -2
  204. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +51 -39
  205. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +51 -39
  206. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +51 -39
  207. package/dist/astro/routes/api/taxonomies/index.mjs +51 -39
  208. package/dist/astro/routes/api/themes/preview.mjs +8 -6
  209. package/dist/astro/routes/api/typegen.mjs +4 -4
  210. package/dist/astro/routes/api/well-known/auth.mjs +3 -3
  211. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +3 -3
  212. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +3 -3
  213. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +47 -35
  214. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +48 -36
  215. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +48 -36
  216. package/dist/astro/routes/api/widget-areas/_name_.mjs +45 -33
  217. package/dist/astro/routes/api/widget-areas/index.mjs +48 -36
  218. package/dist/astro/routes/api/widget-components.mjs +2 -2
  219. package/dist/astro/routes/robots.txt.mjs +11 -10
  220. package/dist/astro/routes/sitemap-_collection_.xml.mjs +20 -18
  221. package/dist/astro/routes/sitemap.xml.mjs +19 -17
  222. package/dist/astro/session-driver.d.mts +1 -1
  223. package/dist/astro/session-driver.mjs +4 -4
  224. package/dist/astro/types.d.mts +13 -13
  225. package/dist/atomic-authority-CnBQJ14T.mjs +33 -0
  226. package/dist/{audit-CYjfxG9i.mjs → audit-F5iWkbcJ.mjs} +11 -4
  227. package/dist/auth/providers/github.d.mts +1 -1
  228. package/dist/auth/providers/google.d.mts +1 -1
  229. package/dist/{auth-control-guard-CITT8ZA_.mjs → auth-control-guard-D4WW-wFF.mjs} +1 -1
  230. package/dist/{authorize-KcI0pAfN.mjs → authorize-EnP57AQl.mjs} +1 -1
  231. package/dist/{briefing-r3hXCDQC.mjs → briefing-BXsVwd4P.mjs} +1 -1
  232. package/dist/{briefing-BgQTljQt.mjs → briefing-CkCi6S-W.mjs} +445 -447
  233. package/dist/{bundle-S6zx-V4D.mjs → bundle-Cgak1zGE.mjs} +3 -3
  234. package/dist/{byline-Ctil4rij.mjs → byline-DEZKlzD9.mjs} +107 -113
  235. package/dist/{byline-fields-QpmruT5r.mjs → byline-fields-BGEIA9dZ.mjs} +3 -3
  236. package/dist/{byline-fields-DNXKWUW9.d.mts → byline-fields-BmkhEDFF.d.mts} +2 -2
  237. package/dist/{byline-fields-DiCyW6eQ.mjs → byline-fields-Qg8TesxL.mjs} +1 -1
  238. package/dist/{byline-registry-rkr73qSE.mjs → byline-registry-CkuVVeJJ.mjs} +46 -76
  239. package/dist/{bylines-BcuBpzVi.mjs → bylines-7BQxRGyG.mjs} +4 -4
  240. package/dist/{bylines-v_ZUQnR-.mjs → bylines-LqNRjma2.mjs} +6 -6
  241. package/dist/{cache-V2BCplaY.mjs → cache-CSTy-R-K.mjs} +2 -2
  242. package/dist/{chunks-CnuL55JE.mjs → chunks-BnG3LPMN.mjs} +1 -1
  243. package/dist/cli/index.mjs +452 -263
  244. package/dist/cli/plugin-kit.d.mts +9 -9
  245. package/dist/cli/plugin-kit.mjs +2 -2
  246. package/dist/client/external-auth-headers.d.mts +1 -1
  247. package/dist/client/index.d.mts +11 -11
  248. package/dist/client/index.mjs +2 -2
  249. package/dist/{client-factory-C-y9VZDX.mjs → client-factory-BLSkgsTg.mjs} +1 -1
  250. package/dist/{comment-_nvJSS-A.mjs → comment-Bi7cJ9SS.mjs} +2 -2
  251. package/dist/{comment-reaction-DhVgJ17S.mjs → comment-reaction-BLqIj5mx.mjs} +1 -1
  252. package/dist/{comments-D4mIDjvA.mjs → comments-Dg_gWBEB.mjs} +1 -1
  253. package/dist/content-De_XeXy_.mjs +1230 -0
  254. package/dist/{content-CVCrcuvD.mjs → content-NobcQti0.mjs} +240 -161
  255. package/dist/{content-refresh-QvBIyb_g.mjs → content-refresh-l4mPoGeX.mjs} +170 -193
  256. package/dist/{context-MftkHbWx.mjs → context-6uqzU-M9.mjs} +95 -77
  257. package/dist/{context-JjKucxBm.mjs → context-B0SG9Xkc.mjs} +2 -2
  258. package/dist/{context-route-helpers-e1APrqSm.mjs → context-route-helpers-C8s26uDT.mjs} +2 -2
  259. package/dist/{cron-mGVPQ5e6.mjs → cron-D7zB6m8i.mjs} +36 -32
  260. package/dist/d1-binding-D6HZa3ks.mjs +8 -0
  261. package/dist/d1-dialect-B1b8cmxX.mjs +48 -0
  262. package/dist/{dashboard-ZJ7sMcBI.mjs → dashboard-B-OybCMw.mjs} +5 -5
  263. package/dist/database/batch.d.mts +20 -0
  264. package/dist/database/batch.mjs +69 -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-DhpCzMo0.mjs} +130 -94
  276. package/dist/{dialect-helpers-fk43GbDb.mjs → dialect-helpers-C6xtO-Ui.mjs} +1 -1
  277. package/dist/{discovery-CJkuHGhZ.mjs → discovery-CqXbN0WZ.mjs} +5 -5
  278. package/dist/{enrich-KErvJOuI.mjs → enrich-BjF-J4sF.mjs} +1 -1
  279. package/dist/{evidence-6IUv9ML3.mjs → evidence-xJf8hQgH.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-BeKJlKh1.mjs} +1 -1
  282. package/dist/{fts-manager-DX7ZkrCa.mjs → fts-manager-BeWtB7ZD.mjs} +72 -57
  283. package/dist/{hitl-requests-CmYVunm-.mjs → hitl-requests-evSsel48.mjs} +2 -2
  284. package/dist/{hitl-route-helpers-CRm537zS.mjs → hitl-route-helpers-D2kJSOFX.mjs} +5 -5
  285. package/dist/{import-DqRAgsKr.mjs → import-Jpta-CYE.mjs} +9 -9
  286. package/dist/{index-Co7xtjkd.d.mts → index-CSUSBfdD.d.mts} +7 -4
  287. package/dist/index.d.mts +16 -16
  288. package/dist/index.mjs +104 -96
  289. package/dist/{integration-credentials-qudN6yRr.mjs → integration-credentials-BrQr0fb_.mjs} +2 -2
  290. package/dist/{jsonld-DTd-AVWg.d.mts → jsonld-CqIVIeZK.d.mts} +2 -2
  291. package/dist/{load-fCOciq0Q.mjs → load-Dc5ttyg4.mjs} +1 -1
  292. package/dist/{loader-BDje8ME2.mjs → loader-Cgsx23wU.mjs} +4 -4
  293. package/dist/{manifest-schema-CfKD0thC.mjs → manifest-schema-DG29meRy.mjs} +1 -1
  294. package/dist/{mcp-reviewed-executor-DmhM3Cy6.mjs → mcp-reviewed-executor-DAZL3Ckt.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-3fK0u-bo.mjs} +1 -1
  301. package/dist/{media-allowlist-DaG6lNoy.mjs → media-allowlist-rN4qIF6W.mjs} +1 -1
  302. package/dist/{menus-CpuR4Qkm.mjs → menus-5liJusbp.mjs} +138 -90
  303. package/dist/{menus-CZbz5L_V.mjs → menus-CbR_J8cJ.mjs} +8 -8
  304. package/dist/migrations-CMdxWKx-.mjs +76 -0
  305. package/dist/oauth-authority-CCqo4eBm.mjs +43 -0
  306. package/dist/{oauth-authorization-Jf5e3azH.mjs → oauth-authorization--0UtTZpv.mjs} +89 -98
  307. package/dist/{oauth-clients-tovQ4D4h.mjs → oauth-clients-D4WBYaYW.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--7nG62_h.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-DK1wLuao.mjs} +35 -84
  317. package/dist/{policy-950odoX_.mjs → policy-Dej7NJFD.mjs} +2 -2
  318. package/dist/{preview-BXmS1SXL.mjs → preview-q0pkibNO.mjs} +2 -2
  319. package/dist/{provider-loader-DDq7R_RN.d.mts → provider-loader-C0GaLwKB.d.mts} +1 -1
  320. package/dist/{public-url-CT-T1D_w.d.mts → public-url-B9zEdO8p.d.mts} +1 -1
  321. package/dist/{public-url-BQ9vf0AS.d.mts → public-url-BV-YQ_LF.d.mts} +2 -2
  322. package/dist/{publication-authorization-C-vYPGD8.mjs → publication-authorization-BrEZ2TsE.mjs} +459 -33
  323. package/dist/{query-CrW2yI6G.mjs → query-CEn9HXnf.mjs} +15 -15
  324. package/dist/{query-DcB9uGTW.mjs → query-DAS6VbMS.mjs} +4 -4
  325. package/dist/{rate-limit-DEkoxTsP.mjs → rate-limit-Dd1TnzZP.mjs} +2 -2
  326. package/dist/{redirect-DG-o0CKV.mjs → redirect-HLI3wT5Y.mjs} +26 -14
  327. package/dist/{redirects-Bjp4iKJU.mjs → redirects-DmOdfRjI.mjs} +5 -5
  328. package/dist/{redirects-N8gmWhVM.mjs → redirects-UCXyL0lP.mjs} +3 -3
  329. package/dist/{registry-D-IV_h50.mjs → registry-RD9qTnYL.mjs} +183 -186
  330. package/dist/release-BR08Slqf.mjs +5148 -0
  331. package/dist/request-context.d.mts +8 -0
  332. package/dist/{request-meta-BW0the1R.mjs → request-meta-BOcuHAXD.mjs} +1 -1
  333. package/dist/{resolve-pZ4NQM-X.mjs → resolve-C80Pm2DW.mjs} +1 -1
  334. package/dist/{review-payload-f1L4lzQg.mjs → review-payload-DEylbssM.mjs} +52 -4
  335. package/dist/{review-requests-DICrYH2-.mjs → review-requests-BF2eEKr8.mjs} +93 -37
  336. package/dist/{review-requests-BTKfeWlS.mjs → review-requests-CyfWbJ6W.mjs} +2 -2
  337. package/dist/{review-route-helpers-DaZBBps8.mjs → review-route-helpers-lKA-CXms.mjs} +2 -2
  338. package/dist/{revision-De7OmYVD.mjs → revision-090sZyGc.mjs} +28 -22
  339. package/dist/revocation-B7GL5fMl.mjs +53 -0
  340. package/dist/{runner-DJiRFyLI.mjs → runner-CVeq0266.mjs} +594 -491
  341. package/dist/{runner-Dye73myO.d.mts → runner-JnJSGXEB.d.mts} +1 -1
  342. package/dist/{runs-DEujUDOj.mjs → runs-B5BExdKO.mjs} +5 -5
  343. package/dist/runtime-env-CQVAWHzH.mjs +19 -0
  344. package/dist/runtime.d.mts +10 -10
  345. package/dist/runtime.mjs +5 -5
  346. package/dist/schema-DLMkODQc.mjs +8 -0
  347. package/dist/{search-DxUKN9Zz.mjs → search-CRzWNfxX.mjs} +4 -4
  348. package/dist/{secrets-AdCrGg1c.mjs → secrets-Cg0D2gQW.mjs} +10 -11
  349. package/dist/{sections-BPFOEMK6.mjs → sections-BwUjOGqn.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-DWHdo5aW.mjs → seo-BOTuCeh-.mjs} +25 -15
  355. package/dist/{seo-GfovzqpU.mjs → seo-B_tBFyud.mjs} +1 -1
  356. package/dist/{service-DbgjHWyW.mjs → service--bQht6oN.mjs} +2 -2
  357. package/dist/{service-BrNKVCjC.mjs → service-DilVsWGD.mjs} +3 -3
  358. package/dist/{session-user-DyqWGIh4.mjs → session-user-DeqTcAmR.mjs} +1 -1
  359. package/dist/{settings-CAsQLi0N.mjs → settings-DFzevIrU.mjs} +8 -8
  360. package/dist/{settings-BKEHw6Bu.mjs → settings-Deqx3Upy.mjs} +2 -2
  361. package/dist/{setup-complete-C8LTo8cO.mjs → setup-complete-BFqudwbW.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-vCiDRr4H.mjs} +50 -37
  364. package/dist/{site-url-DoZf_jVj.mjs → site-url-wXFqbm9c.mjs} +1 -1
  365. package/dist/state-jyNZ6-7L.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-C1yDxxfv.mjs} +37 -12
  371. package/dist/submission-BsHNfHc7.mjs +155 -0
  372. package/dist/{taxonomies-ALDiRQ84.mjs → taxonomies-4cnTcbD6.mjs} +3 -3
  373. package/dist/{taxonomies-93DV-1QT.mjs → taxonomies-CllxqaH0.mjs} +7 -7
  374. package/dist/{taxonomy-BOBTJ_aE.mjs → taxonomy-DWxxLpp5.mjs} +3 -3
  375. package/dist/{tokens-c-qxNqzC.mjs → tokens-Bjuf1HID.mjs} +1 -1
  376. package/dist/{trusted-proxy-CdEl6g6B.mjs → trusted-proxy-CAW9o4Dw.mjs} +4 -12
  377. package/dist/{types-BRCUO8NR.d.mts → types-7Th6Mwz3.d.mts} +1 -0
  378. package/dist/{types-BpSTdH1H.mjs → types-BqxIv8Il.mjs} +2 -2
  379. package/dist/{types-6KmeXInJ.d.mts → types-CFgTpfPk.d.mts} +1 -1
  380. package/dist/{types-TpXK8km5.d.mts → types-QjOcidFc.d.mts} +300 -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-Cglcqpm2.mjs} +2 -2
  385. package/dist/{validate-CDWVODvc.d.mts → validate-A27peRc4.d.mts} +3 -3
  386. package/dist/{validate-C9g9iX3q.mjs → validate-Wl4MSf3V.mjs} +3 -3
  387. package/dist/version-BWxyC5s4.mjs +6 -0
  388. package/dist/{widgets-Cm5Qx2Np.mjs → widgets-Di-6yDH7.mjs} +3 -3
  389. package/dist/{wordpress-slugs-WdPZaVXf.mjs → wordpress-slugs-vOx7R1dM.mjs} +1 -1
  390. package/dist/{worker-D7OccgB8.mjs → worker-RpaMP71d.mjs} +76 -47
  391. package/dist/workers-build-BaQCrSmf.mjs +36 -0
  392. package/dist/{zod-generator-DS5oZNaL.mjs → zod-generator-Cylvl_SM.mjs} +2 -2
  393. package/package.json +35 -9
  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/revocation-CkTOhdlw.mjs +0 -42
  401. package/dist/schema-IjuRxkqq.mjs +0 -8
  402. package/dist/submission-C47cHBIg.mjs +0 -67
  403. package/dist/transaction-BGQgnwUi.mjs +0 -28
  404. package/dist/version-9orir5LL.mjs +0 -6
  405. /package/dist/{base64-F8-DUraK.mjs → base64-Cz-aU0X1.mjs} +0 -0
  406. /package/dist/{challenge-store-CYrg4F4t.mjs → challenge-store-D-_-VavY.mjs} +0 -0
  407. /package/dist/{components-DAq_4iPX.mjs → components-BWQUCJEr.mjs} +0 -0
  408. /package/dist/{config-CVssduLe.mjs → config-XW5tMrH8.mjs} +0 -0
  409. /package/dist/{content-index-names-Bbu1FY1r.mjs → content-index-names-CDc2IQIx.mjs} +0 -0
  410. /package/dist/{context-types-CPWAJRs5.mjs → context-types-DqTo6C79.mjs} +0 -0
  411. /package/dist/{default-BeIzUa1e.mjs → default-D9zxuUU7.mjs} +0 -0
  412. /package/dist/{email-console-Bfi_exVg.mjs → email-console-BONByQiC.mjs} +0 -0
  413. /package/dist/{error-DLg1H2LT.mjs → error-Dd8LtpG5.mjs} +0 -0
  414. /package/dist/{escape-C6lkys0j.mjs → escape-BWC4s5bV.mjs} +0 -0
  415. /package/dist/{experimental-workflows-B9x8delL.mjs → experimental-workflows-M5D3RTFo.mjs} +0 -0
  416. /package/dist/{hash-jhbF98tT.mjs → hash-lNx3KJis.mjs} +0 -0
  417. /package/dist/{media-url-CL3NzgLh.mjs → media-url-B4YtTY6c.mjs} +0 -0
  418. /package/dist/{mime-CDTtL7jE.mjs → mime-D_ae-u_U.mjs} +0 -0
  419. /package/dist/{mode-D554vAgH.mjs → mode-CPf_KZ37.mjs} +0 -0
  420. /package/dist/{normalize-Ev3FiBMx.mjs → normalize-5rct_U0I.mjs} +0 -0
  421. /package/dist/{oauth-state-store-Do1a_o3H.mjs → oauth-state-store-CMgcimzA.mjs} +0 -0
  422. /package/dist/{options-1dBRkoCl.mjs → options-BcqHWpc-.mjs} +0 -0
  423. /package/dist/{output-8j9oltTf.mjs → output-BYpiVUBf.mjs} +0 -0
  424. /package/dist/{parser-C9rzPuSZ.mjs → parser-BV0wzQHo.mjs} +0 -0
  425. /package/dist/{passkey-config-CRN44T04.mjs → passkey-config-BG4GO4OO.mjs} +0 -0
  426. /package/dist/{patterns-3XE9bU4r.mjs → patterns-CZ7D4y_R.mjs} +0 -0
  427. /package/dist/{placeholder-D03pGvqM.d.mts → placeholder-BHTaoCYx.d.mts} +0 -0
  428. /package/dist/{portable-text-tIk9_uz_.mjs → portable-text-B9YuySom.mjs} +0 -0
  429. /package/dist/{portable-text-BdRm4uZq.d.mts → portable-text-FKf3IrPz.d.mts} +0 -0
  430. /package/dist/{process-cache-B-L-A9zg.mjs → process-cache-MHM4Sqzs.mjs} +0 -0
  431. /package/dist/{provider-loader-C4i82ll1.mjs → provider-loader-3MY1SjzA.mjs} +0 -0
  432. /package/dist/{public-discovery-CyDzK1-S.mjs → public-discovery-BAbOvKiR.mjs} +0 -0
  433. /package/dist/{public-url-oudwI7K0.mjs → public-url-C7pbmS_7.mjs} +0 -0
  434. /package/dist/{public-url-BVIjzMo3.mjs → public-url-D5Wjq0sy.mjs} +0 -0
  435. /package/dist/{redirect-Dp5u-8dH.mjs → redirect-Bx96u2nS.mjs} +0 -0
  436. /package/dist/{request-cache-BruBnFAR.mjs → request-cache-DPmV5nk4.mjs} +0 -0
  437. /package/dist/{seo-contributions-BAtRDXEQ.mjs → seo-contributions-Dt57p6Sq.mjs} +0 -0
  438. /package/dist/{service-DeX1PRNt.mjs → service-wYQ_ePZ4.mjs} +0 -0
  439. /package/dist/{setup-nonce-D-CEYlw7.mjs → setup-nonce-CAqDUxxU.mjs} +0 -0
  440. /package/dist/{sidecar-client-Bw2C0XTf.mjs → sidecar-client-CnpGTvYq.mjs} +0 -0
  441. /package/dist/{slugify-KSsVD_D3.mjs → slugify-Di8Q_MFq.mjs} +0 -0
  442. /package/dist/{ssrf-C7tTSD1r.mjs → ssrf-LN16WMip.mjs} +0 -0
  443. /package/dist/{stable-hash-DF7R5eN8.mjs → stable-hash-DEtJgcp7.mjs} +0 -0
  444. /package/dist/{status-Bba6RbkS.mjs → status-Bwkeuz8g.mjs} +0 -0
  445. /package/dist/{transport-BddGhTAI.mjs → transport-472KVGBe.mjs} +0 -0
  446. /package/dist/{transport-ktLL9r2O.d.mts → transport-C0jj-Nc8.d.mts} +0 -0
  447. /package/dist/{types-BQZFeZjd.mjs → types-BDq9t5lG.mjs} +0 -0
  448. /package/dist/{types-CKIt_jmM.d.mts → types-Bs-7Geuh.d.mts} +0 -0
  449. /package/dist/{types-CLMOusxP.d.mts → types-CwkJp6zr.d.mts} +0 -0
  450. /package/dist/{types-C0DPvhR5.mjs → types-CyBH89BS.mjs} +0 -0
  451. /package/dist/{types-BbkkkAb6.mjs → types-D17dJRht.mjs} +0 -0
  452. /package/dist/{types--3oJQ0hs.d.mts → types-DTjrkhKU.d.mts} +0 -0
  453. /package/dist/{types-CPaVj_GC.d.mts → types-DkXuBo8k.d.mts} +0 -0
  454. /package/dist/{types-CU3Wn2HC.d.mts → types-b2sq7ZDk.d.mts} +0 -0
  455. /package/dist/{url-C_pLSrGZ.mjs → url-D375-6LM.mjs} +0 -0
  456. /package/dist/{url-Dumsft7G.mjs → url-bv5i4JN0.mjs} +0 -0
  457. /package/dist/{validate-VPnKoIzW.mjs → validate-Co3j6T_K.mjs} +0 -0
@@ -1,9 +1,12 @@
1
- import { a as __exportAll } from "./runner-DJiRFyLI.mjs";
2
- import { t as validateIdentifier } from "./validate-VPnKoIzW.mjs";
3
- import { i as encodeCursor, n as ScheduledNotDueError, r as decodeCursor, t as DinewayValidationError } from "./types-BpSTdH1H.mjs";
4
- import { o as invalidateCollectionCache } from "./object-cache-D51qOseS.mjs";
5
- import { n as slugify } from "./slugify-KSsVD_D3.mjs";
6
- import { t as RevisionRepository } from "./revision-De7OmYVD.mjs";
1
+ import { c as __exportAll } from "./runner-CVeq0266.mjs";
2
+ import { atomicBatch, rowUnchanged } from "./database/batch.mjs";
3
+ import { t as validateIdentifier } from "./validate-Co3j6T_K.mjs";
4
+ import { o as isPostgres } from "./dialect-helpers-C6xtO-Ui.mjs";
5
+ import { i as encodeCursor, n as ScheduledNotDueError, r as decodeCursor, t as DinewayValidationError } from "./types-BqxIv8Il.mjs";
6
+ import { t as contentWriteChecks } from "./atomic-authority-CnBQJ14T.mjs";
7
+ import { o as invalidateCollectionCache } from "./object-cache-BGjIlY9s.mjs";
8
+ import { n as slugify } from "./slugify-Di8Q_MFq.mjs";
9
+ import { t as RevisionRepository } from "./revision-090sZyGc.mjs";
7
10
  import { sql } from "kysely";
8
11
  import { ulid } from "ulidx";
9
12
 
@@ -89,17 +92,19 @@ var ContentRepository = class {
89
92
  /**
90
93
  * Create a new content item
91
94
  */
92
- async create(input) {
95
+ async prepareCreate(input) {
93
96
  const id = ulid();
94
97
  const now = (/* @__PURE__ */ new Date()).toISOString();
95
98
  const { type, slug, data, status = "draft", authorId, primaryBylineId, locale, translationOf, publishedAt, createdAt } = input;
96
99
  if (!type) throw new DinewayValidationError("Content type is required");
97
100
  const tableName = getTableName(type);
101
+ const checks = [];
98
102
  let translationGroup = id;
99
103
  if (translationOf) {
100
- const source = await this.findById(type, translationOf);
104
+ const source = (await sql`SELECT id, translation_group, deleted_at FROM ${sql.table(tableName)} WHERE id = ${translationOf} AND deleted_at IS NULL`.execute(this.db)).rows[0];
101
105
  if (!source) throw new DinewayValidationError("Translation source content not found");
102
- translationGroup = source.translationGroup || source.id;
106
+ translationGroup = String(source.translation_group || source.id);
107
+ checks.push(rowUnchanged(tableName, source));
103
108
  }
104
109
  const columns = [
105
110
  "id",
@@ -136,15 +141,63 @@ var ContentRepository = class {
136
141
  }
137
142
  const columnRefs = columns.map((c) => sql.ref(c));
138
143
  const valuePlaceholders = values.map((v) => v === null ? sql`NULL` : sql`${v}`);
139
- await sql`
144
+ return {
145
+ id,
146
+ batch: {
147
+ checks,
148
+ statements: [sql`
140
149
  INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
141
150
  VALUES (${sql.join(valuePlaceholders, sql`, `)})
142
- `.execute(this.db);
143
- invalidateCollectionCache(type);
144
- const item = await this.findById(type, id);
151
+ `.compile(this.db)]
152
+ }
153
+ };
154
+ }
155
+ async create(input) {
156
+ const prepared = await this.prepareCreate(input);
157
+ await atomicBatch(this.db, prepared.batch);
158
+ invalidateCollectionCache(input.type);
159
+ const item = await this.findById(input.type, prepared.id);
145
160
  if (!item) throw new Error("Failed to create content");
146
161
  return item;
147
162
  }
163
+ /** Capture database defaults and JSON values from the saved row inside the write batch. */
164
+ async prepareDraftSnapshot(type, id, authorId) {
165
+ const tableName = getTableName(type);
166
+ const checks = [];
167
+ let snapshot;
168
+ if (isPostgres(this.db)) snapshot = sql`(SELECT COALESCE(jsonb_object_agg(field.key, field.value), '{}'::jsonb)::text
169
+ FROM ${sql.table(tableName)} AS entry CROSS JOIN LATERAL jsonb_each(to_jsonb(entry)) AS field(key, value)
170
+ WHERE entry.id = ${id} AND field.value <> 'null'::jsonb
171
+ AND field.key NOT IN (${sql.join(Array.from(SYSTEM_COLUMNS, (name) => sql`${name}`))}))`;
172
+ else {
173
+ const schema = await sql`
174
+ SELECT m.sql AS definition, p.name FROM sqlite_master m
175
+ JOIN pragma_table_info(m.name) p WHERE m.name = ${tableName} AND m.type = 'table'
176
+ `.execute(this.db);
177
+ const definition = schema.rows[0]?.definition;
178
+ if (!definition) throw new DinewayValidationError("Content table not found");
179
+ const pairs = schema.rows.map((row) => row.name).filter((name) => !SYSTEM_COLUMNS.has(name)).map((name) => {
180
+ const column = sql.ref(name);
181
+ return sql`SELECT ${sql.lit(name)} AS name,
182
+ CASE WHEN typeof(${column}) = 'text' AND substr(${column}, 1, 1) IN ('{', '[') AND json_valid(${column})
183
+ THEN ${column} ELSE json_quote(${column}) END AS value
184
+ FROM candidate WHERE ${column} IS NOT NULL`;
185
+ });
186
+ snapshot = pairs.length ? sql`(WITH candidate AS (SELECT * FROM ${sql.table(tableName)} WHERE id = ${id})
187
+ SELECT json_group_object(name, json(value)) FROM (${sql.join(pairs, sql` UNION ALL `)}))` : sql`'{}'`;
188
+ checks.push(sql`EXISTS (SELECT 1 FROM sqlite_master WHERE name = ${tableName} AND sql = ${definition})`);
189
+ }
190
+ const revision = new RevisionRepository(this.db).prepareCreateSnapshot({
191
+ collection: type,
192
+ entryId: id,
193
+ data: snapshot,
194
+ authorId
195
+ });
196
+ return {
197
+ checks,
198
+ statements: [revision.statement, sql`UPDATE ${sql.table(tableName)} SET draft_revision_id = ${revision.id}, updated_at = ${(/* @__PURE__ */ new Date()).toISOString()} WHERE id = ${id}`.compile(this.db)]
199
+ };
200
+ }
148
201
  /**
149
202
  * Generate a unique slug for a content item within a collection.
150
203
  *
@@ -193,21 +246,42 @@ var ContentRepository = class {
193
246
  * Creates a new draft copy with "(Copy)" appended to the title.
194
247
  * A slug is auto-generated from the new title by the handler layer.
195
248
  */
196
- async duplicate(type, id, authorId) {
197
- const original = await this.findById(type, id);
198
- if (!original) throw new DinewayValidationError("Content item not found");
249
+ async prepareDuplicate(type, id, authorId) {
250
+ const snapshot = await this.snapshot(type, id);
251
+ if (!snapshot) throw new DinewayValidationError("Content item not found");
252
+ const original = snapshot.item;
199
253
  const newData = { ...original.data };
200
254
  if (typeof newData.title === "string") newData.title = `${newData.title} (Copy)`;
201
255
  else if (typeof newData.name === "string") newData.name = `${newData.name} (Copy)`;
202
256
  const slugSource = typeof newData.title === "string" ? newData.title : typeof newData.name === "string" ? newData.name : null;
203
257
  const slug = slugSource ? await this.generateUniqueSlug(type, slugSource, original.locale ?? void 0) : null;
204
- return this.create({
258
+ const prepared = await this.prepareCreate({
205
259
  type,
206
260
  slug,
207
261
  data: newData,
208
262
  status: "draft",
209
- authorId: authorId || original.authorId || void 0
263
+ authorId: authorId || original.authorId || void 0,
264
+ locale: original.locale ?? void 0
210
265
  });
266
+ return {
267
+ id: prepared.id,
268
+ batch: {
269
+ checks: [
270
+ snapshot.check,
271
+ ...contentWriteChecks(type, id, "edit"),
272
+ ...prepared.batch.checks ?? []
273
+ ],
274
+ statements: prepared.batch.statements
275
+ }
276
+ };
277
+ }
278
+ async duplicate(type, id, authorId) {
279
+ const prepared = await this.prepareDuplicate(type, id, authorId);
280
+ await atomicBatch(this.db, prepared.batch);
281
+ invalidateCollectionCache(type);
282
+ const item = await this.findById(type, prepared.id);
283
+ if (!item) throw new Error("Failed to reload duplicate");
284
+ return item;
211
285
  }
212
286
  /**
213
287
  * Find content by ID
@@ -343,7 +417,7 @@ var ContentRepository = class {
343
417
  /**
344
418
  * Update content
345
419
  */
346
- async update(type, id, input) {
420
+ prepareUpdate(type, id, input) {
347
421
  const tableName = getTableName(type);
348
422
  const updates = {
349
423
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -361,7 +435,21 @@ var ContentRepository = class {
361
435
  updates[key] = serializeValue(value);
362
436
  }
363
437
  }
364
- await this.db.updateTable(tableName).set(updates).where("id", "=", id).where("deleted_at", "is", null).execute();
438
+ return this.db.updateTable(tableName).set(updates).where("id", "=", id).where("deleted_at", "is", null).compile();
439
+ }
440
+ async snapshot(type, id, includeTrashed = false) {
441
+ const row = (await sql`SELECT * FROM ${sql.table(getTableName(type))} WHERE id = ${id} AND ${includeTrashed ? sql`true` : sql`deleted_at IS NULL`}`.execute(this.db)).rows[0];
442
+ return row ? {
443
+ item: this.mapRow(type, row),
444
+ deleted: row.deleted_at !== null,
445
+ check: rowUnchanged(getTableName(type), row)
446
+ } : null;
447
+ }
448
+ async update(type, id, input) {
449
+ await atomicBatch(this.db, {
450
+ checks: contentWriteChecks(type, id, "edit"),
451
+ statements: [this.prepareUpdate(type, id, input)]
452
+ });
365
453
  invalidateCollectionCache(type);
366
454
  const updated = await this.findById(type, id);
367
455
  if (!updated) throw new Error("Content not found");
@@ -370,15 +458,22 @@ var ContentRepository = class {
370
458
  /**
371
459
  * Delete content (soft delete - moves to trash)
372
460
  */
373
- async delete(type, id) {
461
+ prepareDelete(type, id) {
374
462
  const tableName = getTableName(type);
375
463
  const now = (/* @__PURE__ */ new Date()).toISOString();
376
- const changed = ((await sql`
464
+ return {
465
+ checks: contentWriteChecks(type, id, "delete"),
466
+ statements: [sql`
377
467
  UPDATE ${sql.ref(tableName)}
378
468
  SET deleted_at = ${now}
379
469
  WHERE id = ${id}
380
470
  AND deleted_at IS NULL
381
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
471
+ `.compile(this.db)]
472
+ };
473
+ }
474
+ async delete(type, id) {
475
+ const [result] = await atomicBatch(this.db, this.prepareDelete(type, id));
476
+ const changed = (result?.numAffectedRows ?? 0n) > 0n;
382
477
  if (changed) invalidateCollectionCache(type);
383
478
  return changed;
384
479
  }
@@ -387,13 +482,17 @@ var ContentRepository = class {
387
482
  */
388
483
  async restore(type, id) {
389
484
  const tableName = getTableName(type);
390
- const restored = (await sql`
485
+ const [result] = await atomicBatch(this.db, {
486
+ checks: contentWriteChecks(type, id, "edit"),
487
+ statements: [sql`
391
488
  UPDATE ${sql.ref(tableName)}
392
489
  SET deleted_at = NULL
393
490
  WHERE id = ${id}
394
491
  AND deleted_at IS NOT NULL
395
492
  RETURNING *
396
- `.execute(this.db)).rows[0];
493
+ `.compile(this.db)]
494
+ });
495
+ const restored = result?.rows[0];
397
496
  if (!restored) return null;
398
497
  invalidateCollectionCache(type);
399
498
  return this.mapRow(type, restored);
@@ -403,11 +502,15 @@ var ContentRepository = class {
403
502
  */
404
503
  async permanentDelete(type, id) {
405
504
  const tableName = getTableName(type);
406
- const changed = ((await sql`
505
+ const [result] = await atomicBatch(this.db, {
506
+ checks: contentWriteChecks(type, id, "permanent"),
507
+ statements: [sql`
407
508
  DELETE FROM ${sql.ref(tableName)}
408
509
  WHERE id = ${id}
409
510
  AND deleted_at IS NOT NULL
410
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
511
+ `.compile(this.db)]
512
+ });
513
+ const changed = (result?.numAffectedRows ?? 0n) > 0n;
411
514
  if (changed) invalidateCollectionCache(type);
412
515
  return changed;
413
516
  }
@@ -528,17 +631,20 @@ var ContentRepository = class {
528
631
  const scheduledDate = new Date(scheduledAt);
529
632
  if (isNaN(scheduledDate.getTime())) throw new DinewayValidationError("Invalid scheduled date");
530
633
  if (scheduledDate <= /* @__PURE__ */ new Date()) throw new DinewayValidationError("Scheduled date must be in the future");
531
- const existing = await this.findById(type, id);
532
- if (!existing) throw new DinewayValidationError("Content item not found");
533
- const newStatus = existing.status === "published" ? "published" : "scheduled";
534
- await sql`
634
+ const snapshot = await this.snapshot(type, id);
635
+ if (!snapshot) throw new DinewayValidationError("Content item not found");
636
+ const newStatus = snapshot.item.status === "published" ? "published" : "scheduled";
637
+ await atomicBatch(this.db, {
638
+ checks: [snapshot.check, ...contentWriteChecks(type, id, "publish")],
639
+ statements: [sql`
535
640
  UPDATE ${sql.ref(tableName)}
536
641
  SET status = ${newStatus},
537
642
  scheduled_at = ${scheduledAt},
538
643
  updated_at = ${now}
539
644
  WHERE id = ${id}
540
645
  AND deleted_at IS NULL
541
- `.execute(this.db);
646
+ `.compile(this.db)]
647
+ });
542
648
  invalidateCollectionCache(type);
543
649
  const updated = await this.findById(type, id);
544
650
  if (!updated) throw new Error("Content not found");
@@ -553,10 +659,12 @@ var ContentRepository = class {
553
659
  async unschedule(type, id) {
554
660
  const tableName = getTableName(type);
555
661
  const now = (/* @__PURE__ */ new Date()).toISOString();
556
- const existing = await this.findById(type, id);
557
- if (!existing) throw new DinewayValidationError("Content item not found");
558
- const newStatus = existing.status === "published" ? "published" : "draft";
559
- await sql`
662
+ const snapshot = await this.snapshot(type, id);
663
+ if (!snapshot) throw new DinewayValidationError("Content item not found");
664
+ const newStatus = snapshot.item.status === "published" ? "published" : "draft";
665
+ await atomicBatch(this.db, {
666
+ checks: [snapshot.check, ...contentWriteChecks(type, id, "publish")],
667
+ statements: [sql`
560
668
  UPDATE ${sql.ref(tableName)}
561
669
  SET status = ${newStatus},
562
670
  scheduled_at = NULL,
@@ -564,7 +672,8 @@ var ContentRepository = class {
564
672
  WHERE id = ${id}
565
673
  AND scheduled_at IS NOT NULL
566
674
  AND deleted_at IS NULL
567
- `.execute(this.db);
675
+ `.compile(this.db)]
676
+ });
568
677
  invalidateCollectionCache(type);
569
678
  const updated = await this.findById(type, id);
570
679
  if (!updated) throw new Error("Content not found");
@@ -613,88 +722,55 @@ var ContentRepository = class {
613
722
  * `publishedAt` overrides the publication timestamp. If omitted, an existing
614
723
  * `published_at` is preserved and first publish falls back to the current time.
615
724
  */
616
- async publish(type, id, publishedAt, requireScheduledDue = false) {
725
+ async preparePublish(type, id, publishedAt, requireScheduledDue = false) {
617
726
  const tableName = getTableName(type);
618
727
  const now = (/* @__PURE__ */ new Date()).toISOString();
619
- const existing = await this.findById(type, id);
620
- if (!existing) throw new DinewayValidationError("Content item not found");
621
- let claimedScheduledAt = null;
622
- let claimedUpdatedAt = null;
623
- if (requireScheduledDue) {
624
- const claim = await sql`
625
- UPDATE ${sql.ref(tableName)}
626
- SET scheduled_at = NULL,
627
- updated_at = ${now}
628
- WHERE id = ${id}
629
- AND scheduled_at IS NOT NULL
630
- AND scheduled_at <= ${now}
631
- AND deleted_at IS NULL
632
- `.execute(this.db);
633
- if (Number(claim.numAffectedRows ?? 0) === 0) throw new ScheduledNotDueError();
634
- claimedScheduledAt = existing.scheduledAt;
635
- claimedUpdatedAt = existing.updatedAt;
636
- }
637
- let publishCommitted = false;
638
- try {
639
- const revisionRepo = new RevisionRepository(this.db);
640
- let revisionToPublish = existing.draftRevisionId || existing.liveRevisionId;
641
- if (!revisionToPublish) revisionToPublish = (await revisionRepo.create({
728
+ const snapshot = await this.snapshot(type, id);
729
+ if (!snapshot) throw new DinewayValidationError("Content item not found");
730
+ const existing = snapshot.item;
731
+ if (requireScheduledDue && (!existing.scheduledAt || existing.scheduledAt > now)) throw new ScheduledNotDueError();
732
+ const checks = [snapshot.check];
733
+ const statements = [];
734
+ let revisionId = existing.draftRevisionId || existing.liveRevisionId;
735
+ let data = existing.data;
736
+ if (revisionId) {
737
+ const revision = await this.db.selectFrom("revisions").selectAll().where("id", "=", revisionId).executeTakeFirst();
738
+ if (!revision || revision.collection !== type || revision.entry_id !== id) throw new DinewayValidationError("Revision does not belong to the specified content item");
739
+ checks.push(rowUnchanged("revisions", revision));
740
+ data = JSON.parse(revision.data);
741
+ } else {
742
+ const revision = new RevisionRepository(this.db).prepareCreateSnapshot({
642
743
  collection: type,
643
744
  entryId: id,
644
- data: existing.data
645
- })).id;
646
- const revision = await revisionRepo.findById(revisionToPublish);
647
- if (revision) {
648
- await this.syncDataColumns(type, id, revision.data);
649
- if (typeof revision.data._slug === "string") await sql`
650
- UPDATE ${sql.ref(tableName)}
651
- SET slug = ${revision.data._slug}
652
- WHERE id = ${id}
653
- `.execute(this.db);
654
- }
655
- if (publishedAt !== void 0) await sql`
656
- UPDATE ${sql.ref(tableName)}
657
- SET live_revision_id = ${revisionToPublish},
658
- draft_revision_id = NULL,
659
- status = 'published',
660
- scheduled_at = NULL,
661
- published_at = ${publishedAt},
662
- updated_at = ${now}
663
- WHERE id = ${id}
664
- AND deleted_at IS NULL
665
- `.execute(this.db);
666
- else await sql`
667
- UPDATE ${sql.ref(tableName)}
668
- SET live_revision_id = ${revisionToPublish},
669
- draft_revision_id = NULL,
670
- status = 'published',
671
- scheduled_at = NULL,
672
- published_at = COALESCE(published_at, ${now}),
673
- updated_at = ${now}
674
- WHERE id = ${id}
675
- AND deleted_at IS NULL
676
- `.execute(this.db);
677
- publishCommitted = true;
678
- const updated = await this.findById(type, id);
679
- if (!updated) throw new Error("Content not found");
680
- invalidateCollectionCache(type);
681
- return updated;
682
- } catch (error) {
683
- if (requireScheduledDue && claimedScheduledAt && !publishCommitted) try {
684
- await sql`
685
- UPDATE ${sql.ref(tableName)}
686
- SET scheduled_at = ${claimedScheduledAt},
687
- updated_at = ${claimedUpdatedAt ?? now}
688
- WHERE id = ${id}
689
- AND scheduled_at IS NULL
690
- AND deleted_at IS NULL
691
- AND (status != 'published' OR draft_revision_id IS NOT NULL)
692
- `.execute(this.db);
693
- } catch (restoreError) {
694
- console.error(`[content] Failed to restore schedule for ${type}/${id} after publish failure:`, restoreError);
695
- }
696
- throw error;
745
+ data: sql`${JSON.stringify(data)}`
746
+ });
747
+ revisionId = revision.id;
748
+ statements.push(revision.statement);
697
749
  }
750
+ const sync = this.prepareSyncDataColumns(type, id, data);
751
+ if (sync) statements.push(sync);
752
+ const slug = typeof data._slug === "string" ? data._slug : existing.slug;
753
+ statements.push(sql`UPDATE ${sql.table(tableName)} SET slug = ${slug},
754
+ live_revision_id = ${revisionId}, draft_revision_id = NULL,
755
+ status = 'published', scheduled_at = NULL,
756
+ published_at = ${publishedAt !== void 0 ? sql`${publishedAt}` : sql`COALESCE(published_at, ${now})`}, updated_at = ${now}
757
+ WHERE id = ${id} AND deleted_at IS NULL`.compile(this.db));
758
+ return {
759
+ batch: {
760
+ checks,
761
+ statements
762
+ },
763
+ previous: existing,
764
+ slug
765
+ };
766
+ }
767
+ async publish(type, id, publishedAt, requireScheduledDue = false) {
768
+ const prepared = await this.preparePublish(type, id, publishedAt, requireScheduledDue);
769
+ await atomicBatch(this.db, prepared.batch);
770
+ invalidateCollectionCache(type);
771
+ const item = await this.findById(type, id);
772
+ if (!item) throw new Error("Content not found");
773
+ return item;
698
774
  }
699
775
  /**
700
776
  * Stage an existing revision as the draft for a content item.
@@ -704,18 +780,19 @@ var ContentRepository = class {
704
780
  */
705
781
  async setDraftRevision(type, id, revisionId) {
706
782
  const tableName = getTableName(type);
707
- const now = (/* @__PURE__ */ new Date()).toISOString();
708
- if (!await this.findById(type, id)) throw new DinewayValidationError("Content item not found");
709
- const revision = await new RevisionRepository(this.db).findById(revisionId);
783
+ const snapshot = await this.snapshot(type, id);
784
+ if (!snapshot) throw new DinewayValidationError("Content item not found");
785
+ const revision = await this.db.selectFrom("revisions").selectAll().where("id", "=", revisionId).executeTakeFirst();
710
786
  if (!revision) throw new DinewayValidationError("Revision not found");
711
- if (revision.collection !== type || revision.entryId !== id) throw new DinewayValidationError("Revision does not belong to the specified content item");
712
- await sql`
713
- UPDATE ${sql.ref(tableName)}
714
- SET draft_revision_id = ${revisionId},
715
- updated_at = ${now}
716
- WHERE id = ${id}
717
- AND deleted_at IS NULL
718
- `.execute(this.db);
787
+ if (revision.collection !== type || revision.entry_id !== id) throw new DinewayValidationError("Revision does not belong to the specified content item");
788
+ await atomicBatch(this.db, {
789
+ checks: [
790
+ snapshot.check,
791
+ rowUnchanged("revisions", revision),
792
+ ...contentWriteChecks(type, id, "edit")
793
+ ],
794
+ statements: [sql`UPDATE ${sql.table(tableName)} SET draft_revision_id = ${revisionId}, updated_at = ${(/* @__PURE__ */ new Date()).toISOString()} WHERE id = ${id} AND deleted_at IS NULL`.compile(this.db)]
795
+ });
719
796
  invalidateCollectionCache(type);
720
797
  }
721
798
  /**
@@ -726,37 +803,35 @@ var ContentRepository = class {
726
803
  */
727
804
  async unpublish(type, id) {
728
805
  const tableName = getTableName(type);
729
- const now = (/* @__PURE__ */ new Date()).toISOString();
730
- const existing = await this.findById(type, id);
731
- if (!existing) throw new DinewayValidationError("Content item not found");
732
- if (!existing.draftRevisionId && existing.liveRevisionId) {
733
- const revisionRepo = new RevisionRepository(this.db);
734
- const liveRevision = await revisionRepo.findById(existing.liveRevisionId);
735
- if (liveRevision) {
736
- const draft = await revisionRepo.create({
737
- collection: type,
738
- entryId: id,
739
- data: liveRevision.data
740
- });
741
- await sql`
742
- UPDATE ${sql.ref(tableName)}
743
- SET draft_revision_id = ${draft.id}
744
- WHERE id = ${id}
745
- `.execute(this.db);
746
- }
806
+ const snapshot = await this.snapshot(type, id);
807
+ if (!snapshot) throw new DinewayValidationError("Content item not found");
808
+ const existing = snapshot.item;
809
+ const checks = [snapshot.check, ...contentWriteChecks(type, id, "publish")];
810
+ const statements = [];
811
+ let draftId = existing.draftRevisionId;
812
+ if (!draftId && existing.liveRevisionId) {
813
+ const live = await this.db.selectFrom("revisions").selectAll().where("id", "=", existing.liveRevisionId).executeTakeFirst();
814
+ if (!live || live.collection !== type || live.entry_id !== id) throw new DinewayValidationError("Live revision not found");
815
+ checks.push(rowUnchanged("revisions", live));
816
+ const draft = new RevisionRepository(this.db).prepareCreateSnapshot({
817
+ collection: type,
818
+ entryId: id,
819
+ data: sql`${live.data}`
820
+ });
821
+ draftId = draft.id;
822
+ statements.push(draft.statement);
747
823
  }
748
- await sql`
749
- UPDATE ${sql.ref(tableName)}
750
- SET live_revision_id = NULL,
751
- status = 'draft',
752
- updated_at = ${now}
753
- WHERE id = ${id}
754
- AND deleted_at IS NULL
755
- `.execute(this.db);
824
+ statements.push(sql`UPDATE ${sql.table(tableName)} SET live_revision_id = NULL,
825
+ draft_revision_id = ${draftId}, status = 'draft', updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}
826
+ WHERE id = ${id} AND deleted_at IS NULL`.compile(this.db));
827
+ await atomicBatch(this.db, {
828
+ checks,
829
+ statements
830
+ });
756
831
  invalidateCollectionCache(type);
757
- const updated = await this.findById(type, id);
758
- if (!updated) throw new Error("Content not found");
759
- return updated;
832
+ const item = await this.findById(type, id);
833
+ if (!item) throw new Error("Content not found");
834
+ return item;
760
835
  }
761
836
  /**
762
837
  * Discard pending draft changes
@@ -767,16 +842,20 @@ var ContentRepository = class {
767
842
  async discardDraft(type, id) {
768
843
  const tableName = getTableName(type);
769
844
  const now = (/* @__PURE__ */ new Date()).toISOString();
770
- const existing = await this.findById(type, id);
771
- if (!existing) throw new DinewayValidationError("Content item not found");
845
+ const snapshot = await this.snapshot(type, id);
846
+ if (!snapshot) throw new DinewayValidationError("Content item not found");
847
+ const existing = snapshot.item;
772
848
  if (!existing.draftRevisionId) return existing;
773
- await sql`
849
+ await atomicBatch(this.db, {
850
+ checks: [snapshot.check, ...contentWriteChecks(type, id, "edit")],
851
+ statements: [sql`
774
852
  UPDATE ${sql.ref(tableName)}
775
853
  SET draft_revision_id = NULL,
776
854
  updated_at = ${now}
777
855
  WHERE id = ${id}
778
856
  AND deleted_at IS NULL
779
- `.execute(this.db);
857
+ `.compile(this.db)]
858
+ });
780
859
  invalidateCollectionCache(type);
781
860
  const updated = await this.findById(type, id);
782
861
  if (!updated) throw new Error("Content not found");
@@ -787,7 +866,7 @@ var ContentRepository = class {
787
866
  * Used to promote revision data into the content table on publish.
788
867
  * Keys starting with _ are revision metadata (e.g. _slug) and are skipped.
789
868
  */
790
- async syncDataColumns(type, id, data) {
869
+ prepareSyncDataColumns(type, id, data) {
791
870
  const tableName = getTableName(type);
792
871
  const updates = {};
793
872
  for (const [key, value] of Object.entries(data)) {
@@ -796,8 +875,8 @@ var ContentRepository = class {
796
875
  validateIdentifier(key, "content field name");
797
876
  updates[key] = serializeValue(value);
798
877
  }
799
- if (Object.keys(updates).length === 0) return;
800
- await this.db.updateTable(tableName).set(updates).where("id", "=", id).execute();
878
+ if (Object.keys(updates).length === 0) return null;
879
+ return this.db.updateTable(tableName).set(updates).where("id", "=", id).compile();
801
880
  }
802
881
  /**
803
882
  * Count content items with a pending schedule.