emdash 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1618) hide show
  1. package/dist/action-token-DyXQ5VhB.mjs +26 -0
  2. package/dist/action-token-DyXQ5VhB.mjs.map +1 -0
  3. package/dist/activation-BRmrunZ3.mjs +387 -0
  4. package/dist/activation-BRmrunZ3.mjs.map +1 -0
  5. package/dist/adapters-CMuwJgdX.d.mts +173 -0
  6. package/dist/adapters-CMuwJgdX.d.mts.map +1 -0
  7. package/dist/after-B8cG5P6f.mjs +53 -0
  8. package/dist/after-B8cG5P6f.mjs.map +1 -0
  9. package/dist/allowed-origins-CUNAP6hl.mjs +116 -0
  10. package/dist/allowed-origins-CUNAP6hl.mjs.map +1 -0
  11. package/dist/api/route-utils.d.mts +4 -4
  12. package/dist/api/route-utils.mjs +6 -5
  13. package/dist/api/route-utils.mjs.map +1 -1
  14. package/dist/api/schemas/index.d.mts +2 -2
  15. package/dist/api/schemas/index.mjs +7 -7
  16. package/dist/api-tokens-BIwfh_Ke.mjs +173 -0
  17. package/dist/api-tokens-BIwfh_Ke.mjs.map +1 -0
  18. package/dist/apply-CmE9k57Q.mjs +1774 -0
  19. package/dist/apply-CmE9k57Q.mjs.map +1 -0
  20. package/dist/approvals-DbCK12-7.mjs +460 -0
  21. package/dist/approvals-DbCK12-7.mjs.map +1 -0
  22. package/dist/artifact-fetch-DXHP2vKC.mjs +659 -0
  23. package/dist/artifact-fetch-DXHP2vKC.mjs.map +1 -0
  24. package/dist/artifacts-a_0bb4Ks.mjs +323 -0
  25. package/dist/artifacts-a_0bb4Ks.mjs.map +1 -0
  26. package/dist/astro/image-endpoint.d.mts.map +1 -1
  27. package/dist/astro/image-endpoint.mjs +12 -4
  28. package/dist/astro/image-endpoint.mjs.map +1 -1
  29. package/dist/astro/index.d.mts +17 -17
  30. package/dist/astro/index.d.mts.map +1 -1
  31. package/dist/astro/index.mjs +28 -12
  32. package/dist/astro/index.mjs.map +1 -1
  33. package/dist/astro/middleware/auth.d.mts +17 -15
  34. package/dist/astro/middleware/auth.d.mts.map +1 -1
  35. package/dist/astro/middleware/auth.mjs +31 -20
  36. package/dist/astro/middleware/auth.mjs.map +1 -1
  37. package/dist/astro/middleware/media-usage-write-fence.mjs +2 -2
  38. package/dist/astro/middleware/redirect.d.mts +2 -1
  39. package/dist/astro/middleware/redirect.d.mts.map +1 -1
  40. package/dist/astro/middleware/redirect.mjs +29 -19
  41. package/dist/astro/middleware/redirect.mjs.map +1 -1
  42. package/dist/astro/middleware/request-context.d.mts.map +1 -1
  43. package/dist/astro/middleware/request-context.mjs +6 -5
  44. package/dist/astro/middleware/request-context.mjs.map +1 -1
  45. package/dist/astro/middleware.d.mts +19 -21
  46. package/dist/astro/middleware.d.mts.map +1 -1
  47. package/dist/astro/middleware.mjs +179 -129
  48. package/dist/astro/middleware.mjs.map +1 -1
  49. package/dist/astro/routes/PluginRegistry.d.mts +2 -3
  50. package/dist/astro/routes/PluginRegistry.d.mts.map +1 -1
  51. package/dist/astro/routes/PluginRegistry.mjs +1 -1
  52. package/dist/astro/routes/PluginRegistry.mjs.map +1 -1
  53. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +3 -3
  54. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +3 -3
  55. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +2 -2
  56. package/dist/astro/routes/api/admin/api-tokens/index.mjs +3 -3
  57. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -5
  58. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs.map +1 -1
  59. package/dist/astro/routes/api/admin/byline-fields/_slug_.d.mts.map +1 -1
  60. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +8 -11
  61. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs.map +1 -1
  62. package/dist/astro/routes/api/admin/byline-fields/index.d.mts.map +1 -1
  63. package/dist/astro/routes/api/admin/byline-fields/index.mjs +7 -9
  64. package/dist/astro/routes/api/admin/byline-fields/index.mjs.map +1 -1
  65. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +6 -7
  66. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs.map +1 -1
  67. package/dist/astro/routes/api/admin/bylines/_id_/index.d.mts.map +1 -1
  68. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +9 -10
  69. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs.map +1 -1
  70. package/dist/astro/routes/api/admin/bylines/_id_/translations.d.mts.map +1 -1
  71. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +10 -12
  72. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs.map +1 -1
  73. package/dist/astro/routes/api/admin/bylines/index.mjs +8 -8
  74. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +8 -8
  75. package/dist/astro/routes/api/admin/comments/_id_/status.mjs.map +1 -1
  76. package/dist/astro/routes/api/admin/comments/_id_.d.mts.map +1 -1
  77. package/dist/astro/routes/api/admin/comments/_id_.mjs +7 -8
  78. package/dist/astro/routes/api/admin/comments/_id_.mjs.map +1 -1
  79. package/dist/astro/routes/api/admin/comments/bulk.mjs +9 -9
  80. package/dist/astro/routes/api/admin/comments/bulk.mjs.map +1 -1
  81. package/dist/astro/routes/api/admin/comments/counts.mjs +5 -5
  82. package/dist/astro/routes/api/admin/comments/counts.mjs.map +1 -1
  83. package/dist/astro/routes/api/admin/comments/index.mjs +7 -7
  84. package/dist/astro/routes/api/admin/comments/index.mjs.map +1 -1
  85. package/dist/astro/routes/api/admin/core-update.mjs +6 -6
  86. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +3 -3
  87. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +2 -2
  88. package/dist/astro/routes/api/admin/media-usage/activation.d.mts.map +1 -1
  89. package/dist/astro/routes/api/admin/media-usage/activation.mjs +8 -10
  90. package/dist/astro/routes/api/admin/media-usage/activation.mjs.map +1 -1
  91. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +7 -8
  92. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs.map +1 -1
  93. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +7 -8
  94. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs.map +1 -1
  95. package/dist/astro/routes/api/admin/media-usage/progress.d.mts.map +1 -1
  96. package/dist/astro/routes/api/admin/media-usage/progress.mjs +6 -8
  97. package/dist/astro/routes/api/admin/media-usage/progress.mjs.map +1 -1
  98. package/dist/astro/routes/api/admin/media-usage/repair.mjs +6 -7
  99. package/dist/astro/routes/api/admin/media-usage/repair.mjs.map +1 -1
  100. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +7 -8
  101. package/dist/astro/routes/api/admin/media-usage/work/index.mjs.map +1 -1
  102. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +7 -8
  103. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs.map +1 -1
  104. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +3 -3
  105. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +3 -3
  106. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +4 -4
  107. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +4 -4
  108. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +3 -3
  109. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +4 -4
  110. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +4 -4
  111. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +5 -5
  112. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +9 -8
  113. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  114. package/dist/astro/routes/api/admin/plugins/index.mjs +3 -3
  115. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +3 -3
  116. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +3 -3
  117. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +8 -7
  118. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  119. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +3 -3
  120. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +7 -7
  121. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +14 -13
  122. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  123. package/dist/astro/routes/api/admin/plugins/registry/artifact.d.mts.map +1 -1
  124. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +6 -6
  125. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
  126. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +10 -10
  127. package/dist/astro/routes/api/admin/plugins/registry/publisher-handle.mjs +4 -4
  128. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +8 -8
  129. package/dist/astro/routes/api/admin/plugins/updates.mjs +7 -7
  130. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs +2 -2
  131. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +3 -3
  132. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +3 -3
  133. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +3 -3
  134. package/dist/astro/routes/api/admin/transfer/_...path_.mjs +1 -1
  135. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs +7 -8
  136. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs.map +1 -1
  137. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs +7 -8
  138. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs.map +1 -1
  139. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs +9 -10
  140. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs.map +1 -1
  141. package/dist/astro/routes/api/admin/transfer/capabilities.mjs +9 -10
  142. package/dist/astro/routes/api/admin/transfer/capabilities.mjs.map +1 -1
  143. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs +8 -9
  144. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs.map +1 -1
  145. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs +9 -10
  146. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs.map +1 -1
  147. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs +9 -10
  148. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs.map +1 -1
  149. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs +8 -9
  150. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs.map +1 -1
  151. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs +9 -10
  152. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs.map +1 -1
  153. package/dist/astro/routes/api/admin/transfer/exports/index.d.mts.map +1 -1
  154. package/dist/astro/routes/api/admin/transfer/exports/index.mjs +11 -13
  155. package/dist/astro/routes/api/admin/transfer/exports/index.mjs.map +1 -1
  156. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs +8 -9
  157. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs.map +1 -1
  158. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs +8 -9
  159. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs.map +1 -1
  160. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs +10 -11
  161. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs.map +1 -1
  162. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs +8 -9
  163. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs.map +1 -1
  164. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs +11 -12
  165. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs.map +1 -1
  166. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs +9 -10
  167. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs.map +1 -1
  168. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs +8 -9
  169. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs.map +1 -1
  170. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs +10 -11
  171. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs.map +1 -1
  172. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs +8 -9
  173. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs.map +1 -1
  174. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs +8 -9
  175. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs.map +1 -1
  176. package/dist/astro/routes/api/admin/transfer/imports/index.d.mts.map +1 -1
  177. package/dist/astro/routes/api/admin/transfer/imports/index.mjs +13 -15
  178. package/dist/astro/routes/api/admin/transfer/imports/index.mjs.map +1 -1
  179. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +2 -2
  180. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
  181. package/dist/astro/routes/api/admin/users/_id_/index.mjs +4 -4
  182. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +4 -4
  183. package/dist/astro/routes/api/admin/users/index.mjs +3 -3
  184. package/dist/astro/routes/api/auth/dev-bypass.mjs +2 -2
  185. package/dist/astro/routes/api/auth/handover.mjs +3 -3
  186. package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
  187. package/dist/astro/routes/api/auth/invite/complete.d.mts.map +1 -1
  188. package/dist/astro/routes/api/auth/invite/complete.mjs +10 -9
  189. package/dist/astro/routes/api/auth/invite/complete.mjs.map +1 -1
  190. package/dist/astro/routes/api/auth/invite/index.mjs +6 -6
  191. package/dist/astro/routes/api/auth/invite/register-options.mjs +6 -6
  192. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  193. package/dist/astro/routes/api/auth/magic-link/send.mjs +8 -8
  194. package/dist/astro/routes/api/auth/magic-link/verify.d.mts.map +1 -1
  195. package/dist/astro/routes/api/auth/magic-link/verify.mjs +7 -6
  196. package/dist/astro/routes/api/auth/magic-link/verify.mjs.map +1 -1
  197. package/dist/astro/routes/api/auth/me.mjs +4 -4
  198. package/dist/astro/routes/api/auth/mode.mjs +1 -1
  199. package/dist/astro/routes/api/auth/oauth/_provider_/callback.d.mts.map +1 -1
  200. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +6 -5
  201. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs.map +1 -1
  202. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  203. package/dist/astro/routes/api/auth/passkey/_id_.mjs +3 -3
  204. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
  205. package/dist/astro/routes/api/auth/passkey/options.mjs +9 -9
  206. package/dist/astro/routes/api/auth/passkey/register/options.mjs +6 -6
  207. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +7 -7
  208. package/dist/astro/routes/api/auth/passkey/verify.d.mts.map +1 -1
  209. package/dist/astro/routes/api/auth/passkey/verify.mjs +10 -9
  210. package/dist/astro/routes/api/auth/passkey/verify.mjs.map +1 -1
  211. package/dist/astro/routes/api/auth/signup/complete.d.mts.map +1 -1
  212. package/dist/astro/routes/api/auth/signup/complete.mjs +10 -9
  213. package/dist/astro/routes/api/auth/signup/complete.mjs.map +1 -1
  214. package/dist/astro/routes/api/auth/signup/register-options.d.mts +8 -0
  215. package/dist/astro/routes/api/auth/signup/register-options.d.mts.map +1 -0
  216. package/dist/astro/routes/api/auth/signup/register-options.mjs +44 -0
  217. package/dist/astro/routes/api/auth/signup/register-options.mjs.map +1 -0
  218. package/dist/astro/routes/api/auth/signup/request.mjs +7 -7
  219. package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
  220. package/dist/astro/routes/api/calendar.mjs +4 -4
  221. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.d.mts.map +1 -1
  222. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +6 -7
  223. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs.map +1 -1
  224. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.d.mts.map +1 -1
  225. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +11 -12
  226. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs.map +1 -1
  227. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  228. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +9 -10
  229. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs.map +1 -1
  230. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +6 -7
  231. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs.map +1 -1
  232. package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts.map +1 -1
  233. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +15 -15
  234. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs.map +1 -1
  235. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +2 -2
  236. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs +2 -2
  237. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +8 -8
  238. package/dist/astro/routes/api/content/_collection_/_id_/publish.d.mts.map +1 -1
  239. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +9 -10
  240. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
  241. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +6 -7
  242. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
  243. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +6 -7
  244. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
  245. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +3 -3
  246. package/dist/astro/routes/api/content/_collection_/_id_/revisions/editors.mjs +2 -2
  247. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +6 -6
  248. package/dist/astro/routes/api/content/_collection_/_id_/room.mjs +4 -4
  249. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +6 -6
  250. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.d.mts.map +1 -1
  251. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +16 -19
  252. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  253. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  254. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +9 -10
  255. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs.map +1 -1
  256. package/dist/astro/routes/api/content/_collection_/_id_.d.mts.map +1 -1
  257. package/dist/astro/routes/api/content/_collection_/_id_.mjs +19 -19
  258. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  259. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  260. package/dist/astro/routes/api/content/_collection_/index.mjs +5 -5
  261. package/dist/astro/routes/api/content/_collection_/trash.mjs +4 -4
  262. package/dist/astro/routes/api/dashboard.mjs +6 -6
  263. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  264. package/dist/astro/routes/api/dev/scheduled-tasks.mjs +4 -3
  265. package/dist/astro/routes/api/dev/scheduled-tasks.mjs.map +1 -1
  266. package/dist/astro/routes/api/health.mjs +3 -3
  267. package/dist/astro/routes/api/import/probe.d.mts +4 -4
  268. package/dist/astro/routes/api/import/probe.mjs +6 -6
  269. package/dist/astro/routes/api/import/wordpress/analyze.d.mts +3 -3
  270. package/dist/astro/routes/api/import/wordpress/analyze.mjs +3 -3
  271. package/dist/astro/routes/api/import/wordpress/execute.d.mts +16 -16
  272. package/dist/astro/routes/api/import/wordpress/execute.mjs +7 -7
  273. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  274. package/dist/astro/routes/api/import/wordpress/media.d.mts +15 -15
  275. package/dist/astro/routes/api/import/wordpress/media.d.mts.map +1 -1
  276. package/dist/astro/routes/api/import/wordpress/media.mjs +9 -8
  277. package/dist/astro/routes/api/import/wordpress/media.mjs.map +1 -1
  278. package/dist/astro/routes/api/import/wordpress/prepare.mjs +7 -7
  279. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +16 -16
  280. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +6 -6
  281. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  282. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +6 -6
  283. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +16 -16
  284. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +13 -13
  285. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  286. package/dist/astro/routes/api/manifest.mjs +4 -4
  287. package/dist/astro/routes/api/mcp.mjs +84 -77
  288. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  289. package/dist/astro/routes/api/media/_id_/confirm.mjs +7 -7
  290. package/dist/astro/routes/api/media/_id_/replace.d.mts.map +1 -1
  291. package/dist/astro/routes/api/media/_id_/replace.mjs +8 -6
  292. package/dist/astro/routes/api/media/_id_/replace.mjs.map +1 -1
  293. package/dist/astro/routes/api/media/_id_/upload.mjs +5 -5
  294. package/dist/astro/routes/api/media/_id_/usage.mjs +6 -6
  295. package/dist/astro/routes/api/media/_id_.d.mts.map +1 -1
  296. package/dist/astro/routes/api/media/_id_.mjs +11 -8
  297. package/dist/astro/routes/api/media/_id_.mjs.map +1 -1
  298. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs +3 -3
  299. package/dist/astro/routes/api/media/file/_...key_.d.mts.map +1 -1
  300. package/dist/astro/routes/api/media/file/_...key_.mjs +7 -5
  301. package/dist/astro/routes/api/media/file/_...key_.mjs.map +1 -1
  302. package/dist/astro/routes/api/media/folders/_id_.mjs +5 -5
  303. package/dist/astro/routes/api/media/folders/index.mjs +5 -5
  304. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.d.mts.map +1 -1
  305. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +10 -4
  306. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs.map +1 -1
  307. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  308. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  309. package/dist/astro/routes/api/media/upload-url.mjs +7 -7
  310. package/dist/astro/routes/api/media.mjs +9 -9
  311. package/dist/astro/routes/api/menus/_name_/items/_id_.d.mts.map +1 -1
  312. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +8 -6
  313. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  314. package/dist/astro/routes/api/menus/_name_/items.mjs +7 -6
  315. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  316. package/dist/astro/routes/api/menus/_name_/reorder.mjs +7 -6
  317. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  318. package/dist/astro/routes/api/menus/_name_/translations.d.mts.map +1 -1
  319. package/dist/astro/routes/api/menus/_name_/translations.mjs +7 -9
  320. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  321. package/dist/astro/routes/api/menus/_name_.d.mts.map +1 -1
  322. package/dist/astro/routes/api/menus/_name_.mjs +9 -6
  323. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  324. package/dist/astro/routes/api/menus/index.d.mts.map +1 -1
  325. package/dist/astro/routes/api/menus/index.mjs +8 -6
  326. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  327. package/dist/astro/routes/api/oauth/authorize.mjs +3 -3
  328. package/dist/astro/routes/api/oauth/device/authorize.mjs +3 -3
  329. package/dist/astro/routes/api/oauth/device/code.mjs +6 -6
  330. package/dist/astro/routes/api/oauth/device/token.mjs +5 -5
  331. package/dist/astro/routes/api/oauth/register.mjs +4 -4
  332. package/dist/astro/routes/api/oauth/token/refresh.mjs +3 -3
  333. package/dist/astro/routes/api/oauth/token/revoke.mjs +3 -3
  334. package/dist/astro/routes/api/oauth/token.mjs +4 -4
  335. package/dist/astro/routes/api/openapi.json.mjs +9 -9
  336. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  337. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +2 -2
  338. package/dist/astro/routes/api/redirects/404s/index.d.mts.map +1 -1
  339. package/dist/astro/routes/api/redirects/404s/index.mjs +8 -11
  340. package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
  341. package/dist/astro/routes/api/redirects/404s/summary.mjs +6 -7
  342. package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
  343. package/dist/astro/routes/api/redirects/_id_.d.mts.map +1 -1
  344. package/dist/astro/routes/api/redirects/_id_.mjs +9 -12
  345. package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
  346. package/dist/astro/routes/api/redirects/index.d.mts.map +1 -1
  347. package/dist/astro/routes/api/redirects/index.mjs +8 -10
  348. package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
  349. package/dist/astro/routes/api/relations/_id_/index.d.mts.map +1 -1
  350. package/dist/astro/routes/api/relations/_id_/index.mjs +8 -11
  351. package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
  352. package/dist/astro/routes/api/relations/index.d.mts.map +1 -1
  353. package/dist/astro/routes/api/relations/index.mjs +7 -9
  354. package/dist/astro/routes/api/relations/index.mjs.map +1 -1
  355. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  356. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +6 -6
  357. package/dist/astro/routes/api/schema/block-types/_slug_/index.d.mts.map +1 -1
  358. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs +7 -9
  359. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs.map +1 -1
  360. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs +6 -7
  361. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs.map +1 -1
  362. package/dist/astro/routes/api/schema/block-types/index.d.mts.map +1 -1
  363. package/dist/astro/routes/api/schema/block-types/index.mjs +7 -9
  364. package/dist/astro/routes/api/schema/block-types/index.mjs.map +1 -1
  365. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.d.mts.map +1 -1
  366. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +8 -11
  367. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  368. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.d.mts.map +1 -1
  369. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +7 -9
  370. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  371. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +6 -7
  372. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  373. package/dist/astro/routes/api/schema/collections/_slug_/index.d.mts.map +1 -1
  374. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +8 -11
  375. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  376. package/dist/astro/routes/api/schema/collections/index.d.mts.map +1 -1
  377. package/dist/astro/routes/api/schema/collections/index.mjs +7 -9
  378. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  379. package/dist/astro/routes/api/schema/collections/reorder.mjs +6 -7
  380. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  381. package/dist/astro/routes/api/schema/index.mjs +4 -5
  382. package/dist/astro/routes/api/schema/index.mjs.map +1 -1
  383. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +6 -7
  384. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  385. package/dist/astro/routes/api/schema/orphans/index.mjs +4 -5
  386. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  387. package/dist/astro/routes/api/search/enable.d.mts.map +1 -1
  388. package/dist/astro/routes/api/search/enable.mjs +8 -5
  389. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  390. package/dist/astro/routes/api/search/index.d.mts.map +1 -1
  391. package/dist/astro/routes/api/search/index.mjs +7 -4
  392. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  393. package/dist/astro/routes/api/search/rebuild.d.mts.map +1 -1
  394. package/dist/astro/routes/api/search/rebuild.mjs +8 -5
  395. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  396. package/dist/astro/routes/api/search/stats.d.mts.map +1 -1
  397. package/dist/astro/routes/api/search/stats.mjs +6 -3
  398. package/dist/astro/routes/api/search/stats.mjs.map +1 -1
  399. package/dist/astro/routes/api/search/suggest.d.mts.map +1 -1
  400. package/dist/astro/routes/api/search/suggest.mjs +7 -4
  401. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  402. package/dist/astro/routes/api/sections/_slug_.d.mts.map +1 -1
  403. package/dist/astro/routes/api/sections/_slug_.mjs +8 -11
  404. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  405. package/dist/astro/routes/api/sections/index.d.mts.map +1 -1
  406. package/dist/astro/routes/api/sections/index.mjs +7 -9
  407. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  408. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +4 -4
  409. package/dist/astro/routes/api/settings/backups/archives/index.mjs +3 -3
  410. package/dist/astro/routes/api/settings/backups/export.mjs +4 -4
  411. package/dist/astro/routes/api/settings/backups/index.mjs +5 -5
  412. package/dist/astro/routes/api/settings/domain-notify.mjs +6 -6
  413. package/dist/astro/routes/api/settings/domain.mjs +6 -6
  414. package/dist/astro/routes/api/settings/email.mjs +5 -5
  415. package/dist/astro/routes/api/settings.mjs +5 -5
  416. package/dist/astro/routes/api/setup/admin-verify.d.mts.map +1 -1
  417. package/dist/astro/routes/api/setup/admin-verify.mjs +12 -11
  418. package/dist/astro/routes/api/setup/admin-verify.mjs.map +1 -1
  419. package/dist/astro/routes/api/setup/admin.mjs +7 -7
  420. package/dist/astro/routes/api/setup/dev-bypass.mjs +8 -8
  421. package/dist/astro/routes/api/setup/dev-reset.mjs +1 -1
  422. package/dist/astro/routes/api/setup/index.mjs +8 -8
  423. package/dist/astro/routes/api/setup/status.mjs +2 -2
  424. package/dist/astro/routes/api/site/domain-proof.mjs +2 -2
  425. package/dist/astro/routes/api/snapshot.mjs +6 -6
  426. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +6 -7
  427. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -1
  428. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.d.mts.map +1 -1
  429. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +7 -9
  430. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
  431. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.d.mts.map +1 -1
  432. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +9 -12
  433. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
  434. package/dist/astro/routes/api/taxonomies/_name_/terms/index.d.mts.map +1 -1
  435. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +7 -9
  436. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
  437. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +6 -7
  438. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -1
  439. package/dist/astro/routes/api/taxonomies/_name_.d.mts.map +1 -1
  440. package/dist/astro/routes/api/taxonomies/_name_.mjs +9 -12
  441. package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -1
  442. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs +12 -13
  443. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs.map +1 -1
  444. package/dist/astro/routes/api/taxonomies/index.d.mts.map +1 -1
  445. package/dist/astro/routes/api/taxonomies/index.mjs +8 -10
  446. package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
  447. package/dist/astro/routes/api/themes/preview.mjs +4 -4
  448. package/dist/astro/routes/api/typegen.mjs +3 -3
  449. package/dist/astro/routes/api/visual-editing/action-token.mjs +3 -3
  450. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs +3 -3
  451. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs +1 -1
  452. package/dist/astro/routes/api/well-known/auth.mjs +1 -1
  453. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +1 -1
  454. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +1 -1
  455. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +6 -5
  456. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
  457. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.d.mts.map +1 -1
  458. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +8 -6
  459. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
  460. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +7 -6
  461. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
  462. package/dist/astro/routes/api/widget-areas/_name_.d.mts.map +1 -1
  463. package/dist/astro/routes/api/widget-areas/_name_.mjs +6 -4
  464. package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
  465. package/dist/astro/routes/api/widget-areas/index.d.mts.map +1 -1
  466. package/dist/astro/routes/api/widget-areas/index.mjs +8 -6
  467. package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
  468. package/dist/astro/routes/api/widget-components.mjs +2 -2
  469. package/dist/astro/routes/robots.txt.mjs +2 -2
  470. package/dist/astro/routes/sitemap-_collection_.xml.mjs +5 -5
  471. package/dist/astro/routes/sitemap.xml.mjs +3 -3
  472. package/dist/astro/types.d.mts +82 -69
  473. package/dist/astro/types.d.mts.map +1 -1
  474. package/dist/auth/providers/github.d.mts +1 -1
  475. package/dist/auth/providers/google.d.mts +1 -1
  476. package/dist/auth/providers/microsoft.d.mts +1 -1
  477. package/dist/authoritative-records-DFHFmreO.mjs +5183 -0
  478. package/dist/authoritative-records-DFHFmreO.mjs.map +1 -0
  479. package/dist/authorize-6a0h5NN5.mjs +74 -0
  480. package/dist/authorize-6a0h5NN5.mjs.map +1 -0
  481. package/dist/backup-GBRxixs1.mjs +246 -0
  482. package/dist/backup-GBRxixs1.mjs.map +1 -0
  483. package/dist/block-types-BeLZ85Sw.mjs +132 -0
  484. package/dist/block-types-BeLZ85Sw.mjs.map +1 -0
  485. package/dist/block-values-BRJZHvF4.mjs +215 -0
  486. package/dist/block-values-BRJZHvF4.mjs.map +1 -0
  487. package/dist/byline-BufjxQyd.mjs +930 -0
  488. package/dist/byline-BufjxQyd.mjs.map +1 -0
  489. package/dist/byline-fields-Bw7z2opJ.mjs +123 -0
  490. package/dist/byline-fields-Bw7z2opJ.mjs.map +1 -0
  491. package/dist/byline-registry-edmv55U7.mjs +406 -0
  492. package/dist/byline-registry-edmv55U7.mjs.map +1 -0
  493. package/dist/bylines-C8ZT6iWw.mjs +234 -0
  494. package/dist/bylines-C8ZT6iWw.mjs.map +1 -0
  495. package/dist/bylines-a01JW9yq.mjs +150 -0
  496. package/dist/bylines-a01JW9yq.mjs.map +1 -0
  497. package/dist/cache-LOb3NthC.mjs +151 -0
  498. package/dist/cache-LOb3NthC.mjs.map +1 -0
  499. package/dist/canonical-CUkatNPc.mjs +174 -0
  500. package/dist/canonical-CUkatNPc.mjs.map +1 -0
  501. package/dist/capture-triggers-BK2pp_kZ.mjs +362 -0
  502. package/dist/capture-triggers-BK2pp_kZ.mjs.map +1 -0
  503. package/dist/checksum-C8lkApUe.mjs +162 -0
  504. package/dist/checksum-C8lkApUe.mjs.map +1 -0
  505. package/dist/chunks-CvgCLYip.mjs +25 -0
  506. package/dist/chunks-CvgCLYip.mjs.map +1 -0
  507. package/dist/cli/index.mjs +24 -24
  508. package/dist/client/cf-access.d.mts +1 -1
  509. package/dist/client/index.d.mts +63 -63
  510. package/dist/client/index.d.mts.map +1 -1
  511. package/dist/client/index.mjs +6 -4
  512. package/dist/client/index.mjs.map +1 -1
  513. package/dist/collection-slugs-cache-CLR_8fY5.mjs +91 -0
  514. package/dist/collection-slugs-cache-CLR_8fY5.mjs.map +1 -0
  515. package/dist/comment-C163Gl_4.mjs +335 -0
  516. package/dist/comment-C163Gl_4.mjs.map +1 -0
  517. package/dist/comment-reaction-1Df3G-ij.mjs +85 -0
  518. package/dist/comment-reaction-1Df3G-ij.mjs.map +1 -0
  519. package/dist/comments-BFyw2y-m.mjs +99 -0
  520. package/dist/comments-BFyw2y-m.mjs.map +1 -0
  521. package/dist/comments-D73Sy_2U.mjs +195 -0
  522. package/dist/comments-D73Sy_2U.mjs.map +1 -0
  523. package/dist/components-DjV1sxUL.mjs +112 -0
  524. package/dist/components-DjV1sxUL.mjs.map +1 -0
  525. package/dist/config-B27hvMjf.d.mts +7274 -0
  526. package/dist/config-B27hvMjf.d.mts.map +1 -0
  527. package/dist/config-DLzKVQBA.d.mts +41 -0
  528. package/dist/config-DLzKVQBA.d.mts.map +1 -0
  529. package/dist/config-DeluGa9H.mjs +228 -0
  530. package/dist/config-DeluGa9H.mjs.map +1 -0
  531. package/dist/connection-D6aKSo2Y.mjs +36 -0
  532. package/dist/connection-D6aKSo2Y.mjs.map +1 -0
  533. package/dist/content-2gjSbGP3.mjs +2295 -0
  534. package/dist/content-2gjSbGP3.mjs.map +1 -0
  535. package/dist/content-list-query-B9SlIDbL.d.mts +26 -0
  536. package/dist/content-list-query-B9SlIDbL.d.mts.map +1 -0
  537. package/dist/content-repair-Dizo4qiY.mjs +443 -0
  538. package/dist/content-repair-Dizo4qiY.mjs.map +1 -0
  539. package/dist/content-save-BKDTKmkx.mjs +202 -0
  540. package/dist/content-save-BKDTKmkx.mjs.map +1 -0
  541. package/dist/context-DCQrjN95.mjs +2242 -0
  542. package/dist/context-DCQrjN95.mjs.map +1 -0
  543. package/dist/credits-Bxp4F72g.mjs +110 -0
  544. package/dist/credits-Bxp4F72g.mjs.map +1 -0
  545. package/dist/cron-DEV8oz3R.mjs +310 -0
  546. package/dist/cron-DEV8oz3R.mjs.map +1 -0
  547. package/dist/db/index.d.mts +3 -3
  548. package/dist/db/index.mjs +1 -1
  549. package/dist/db/libsql-migrations.d.mts +1 -1
  550. package/dist/db/libsql-migrations.mjs +2 -2
  551. package/dist/db/libsql.d.mts +1 -1
  552. package/dist/db/postgres-migrations.d.mts +1 -1
  553. package/dist/db/postgres-migrations.mjs +2 -2
  554. package/dist/db/postgres.d.mts +1 -1
  555. package/dist/db/sqlite-migrations.d.mts +1 -1
  556. package/dist/db/sqlite-migrations.mjs +2 -2
  557. package/dist/db/sqlite.d.mts +1 -1
  558. package/dist/db/sqlite.mjs +1 -1
  559. package/dist/default-DKs7zP7m.mjs +81 -0
  560. package/dist/default-DKs7zP7m.mjs.map +1 -0
  561. package/dist/deferred-tasks-B5LQWb5F.d.mts +10 -0
  562. package/dist/deferred-tasks-B5LQWb5F.d.mts.map +1 -0
  563. package/dist/device-flow-D6kyi3jX.mjs +519 -0
  564. package/dist/device-flow-D6kyi3jX.mjs.map +1 -0
  565. package/dist/dialect-helpers-DRe1Y08G.mjs +355 -0
  566. package/dist/dialect-helpers-DRe1Y08G.mjs.map +1 -0
  567. package/dist/digest-DSsUd9oL.mjs +194 -0
  568. package/dist/digest-DSsUd9oL.mjs.map +1 -0
  569. package/dist/direct-executor-DAcU8MTG.mjs +117 -0
  570. package/dist/direct-executor-DAcU8MTG.mjs.map +1 -0
  571. package/dist/email-console-CBZpj1VI.mjs +50 -0
  572. package/dist/email-console-CBZpj1VI.mjs.map +1 -0
  573. package/dist/email-locale-CGjBa23b.mjs +25 -0
  574. package/dist/email-locale-CGjBa23b.mjs.map +1 -0
  575. package/dist/email-smtp-CE6nESRL.mjs +643 -0
  576. package/dist/email-smtp-CE6nESRL.mjs.map +1 -0
  577. package/dist/emdash-runtime-CF6KAut9.mjs +5576 -0
  578. package/dist/emdash-runtime-CF6KAut9.mjs.map +1 -0
  579. package/dist/enrich-C4vKniyi.mjs +203 -0
  580. package/dist/enrich-C4vKniyi.mjs.map +1 -0
  581. package/dist/entry-lock-DJgDNfMf.mjs +1230 -0
  582. package/dist/entry-lock-DJgDNfMf.mjs.map +1 -0
  583. package/dist/entry-lock-GKD0lJI5.mjs +207 -0
  584. package/dist/entry-lock-GKD0lJI5.mjs.map +1 -0
  585. package/dist/entry-locks-B58Q9LZh.mjs +173 -0
  586. package/dist/entry-locks-B58Q9LZh.mjs.map +1 -0
  587. package/dist/env-types-EL7WTMzr.mjs +38 -0
  588. package/dist/env-types-EL7WTMzr.mjs.map +1 -0
  589. package/dist/error-0Y0dFPxm.mjs +82 -0
  590. package/dist/error-0Y0dFPxm.mjs.map +1 -0
  591. package/dist/errors-OTWh4SC_.mjs +502 -0
  592. package/dist/errors-OTWh4SC_.mjs.map +1 -0
  593. package/dist/errors-u5rZhbVQ.mjs +120 -0
  594. package/dist/errors-u5rZhbVQ.mjs.map +1 -0
  595. package/dist/fence-CkdbSoZX.mjs +162 -0
  596. package/dist/fence-CkdbSoZX.mjs.map +1 -0
  597. package/dist/field-defs-cache-BW0Y9Wrp.mjs +79 -0
  598. package/dist/field-defs-cache-BW0Y9Wrp.mjs.map +1 -0
  599. package/dist/field-map-Bhqs6zUK.mjs +84 -0
  600. package/dist/field-map-Bhqs6zUK.mjs.map +1 -0
  601. package/dist/fts-manager-m8GPxogO.mjs +532 -0
  602. package/dist/fts-manager-m8GPxogO.mjs.map +1 -0
  603. package/dist/gc-CEhfEMLY.mjs +62 -0
  604. package/dist/gc-CEhfEMLY.mjs.map +1 -0
  605. package/dist/hook-result-CG0uHAT5.d.mts +31 -0
  606. package/dist/hook-result-CG0uHAT5.d.mts.map +1 -0
  607. package/dist/hook-result-mOyk-VCt.mjs +3855 -0
  608. package/dist/hook-result-mOyk-VCt.mjs.map +1 -0
  609. package/dist/hreflang-B1E64c5R.d.mts +51 -0
  610. package/dist/hreflang-B1E64c5R.d.mts.map +1 -0
  611. package/dist/hreflang-DaMRoUor.mjs +105 -0
  612. package/dist/hreflang-DaMRoUor.mjs.map +1 -0
  613. package/dist/http-route-dispatch-Y8bwyixm.mjs +348 -0
  614. package/dist/http-route-dispatch-Y8bwyixm.mjs.map +1 -0
  615. package/dist/identity-cqdOzgy9.mjs +35 -0
  616. package/dist/identity-cqdOzgy9.mjs.map +1 -0
  617. package/dist/index-CzbH8FX2.d.mts +261 -0
  618. package/dist/index-CzbH8FX2.d.mts.map +1 -0
  619. package/dist/index.d.mts +25 -25
  620. package/dist/index.mjs +60 -53
  621. package/dist/index.mjs.map +1 -1
  622. package/dist/install-finalization-B02IcpqW.mjs +58 -0
  623. package/dist/install-finalization-B02IcpqW.mjs.map +1 -0
  624. package/dist/json-recordset-2VNAgija.mjs +12 -0
  625. package/dist/json-recordset-2VNAgija.mjs.map +1 -0
  626. package/dist/json-schema-CnImQ4DF.mjs +15 -0
  627. package/dist/json-schema-CnImQ4DF.mjs.map +1 -0
  628. package/dist/keys-B5WUGmYK.mjs +61 -0
  629. package/dist/keys-B5WUGmYK.mjs.map +1 -0
  630. package/dist/kinds-DyAmbNrx.mjs +974 -0
  631. package/dist/kinds-DyAmbNrx.mjs.map +1 -0
  632. package/dist/lifecycle-1Nl01SeB.mjs +53 -0
  633. package/dist/lifecycle-1Nl01SeB.mjs.map +1 -0
  634. package/dist/limits-BuiMu9zx.mjs +44 -0
  635. package/dist/limits-BuiMu9zx.mjs.map +1 -0
  636. package/dist/load-CEt0TQ4_.mjs +36 -0
  637. package/dist/load-CEt0TQ4_.mjs.map +1 -0
  638. package/dist/loader-DF6J1Fpd.mjs +1537 -0
  639. package/dist/loader-DF6J1Fpd.mjs.map +1 -0
  640. package/dist/loops-3DdrfQ6y.mjs +217 -0
  641. package/dist/loops-3DdrfQ6y.mjs.map +1 -0
  642. package/dist/manifest-builder-Dcfqd9Aw.mjs +196 -0
  643. package/dist/manifest-builder-Dcfqd9Aw.mjs.map +1 -0
  644. package/dist/manifest-schema-Pi_JP_Wi.mjs +497 -0
  645. package/dist/manifest-schema-Pi_JP_Wi.mjs.map +1 -0
  646. package/dist/marketplace-BsMC_Z7o.mjs +257 -0
  647. package/dist/marketplace-BsMC_Z7o.mjs.map +1 -0
  648. package/dist/marketplace-D9fChLav.mjs +965 -0
  649. package/dist/marketplace-D9fChLav.mjs.map +1 -0
  650. package/dist/media/image-endpoint.d.mts +33 -1
  651. package/dist/media/image-endpoint.d.mts.map +1 -1
  652. package/dist/media/image-endpoint.mjs +77 -1
  653. package/dist/media/image-endpoint.mjs.map +1 -1
  654. package/dist/media/index.d.mts +1 -1
  655. package/dist/media/index.mjs +1 -1
  656. package/dist/media/local-runtime.d.mts +17 -17
  657. package/dist/media/local-runtime.mjs +3 -3
  658. package/dist/media--P-IEycF.mjs +2813 -0
  659. package/dist/media--P-IEycF.mjs.map +1 -0
  660. package/dist/media-CTA82rU1.mjs +295 -0
  661. package/dist/media-CTA82rU1.mjs.map +1 -0
  662. package/dist/media-Cq_oKN_Y.mjs +425 -0
  663. package/dist/media-Cq_oKN_Y.mjs.map +1 -0
  664. package/dist/media-DRDkfiDv.d.mts +203 -0
  665. package/dist/media-DRDkfiDv.d.mts.map +1 -0
  666. package/dist/media-allowlist-C_kSleFj.mjs +103 -0
  667. package/dist/media-allowlist-C_kSleFj.mjs.map +1 -0
  668. package/dist/media-folders-Lc9Ks8az.mjs +205 -0
  669. package/dist/media-folders-Lc9Ks8az.mjs.map +1 -0
  670. package/dist/media-url-BEvOId4Z.mjs +43 -0
  671. package/dist/media-url-BEvOId4Z.mjs.map +1 -0
  672. package/dist/media-usage-D6LjfdGn.mjs +282 -0
  673. package/dist/media-usage-D6LjfdGn.mjs.map +1 -0
  674. package/dist/media-usage-activation-i6tqb6cn.mjs +78 -0
  675. package/dist/media-usage-activation-i6tqb6cn.mjs.map +1 -0
  676. package/dist/media-usage-work-C5HHgfEU.mjs +1036 -0
  677. package/dist/media-usage-work-C5HHgfEU.mjs.map +1 -0
  678. package/dist/media-usage-work-CxqS_Ny9.mjs +151 -0
  679. package/dist/media-usage-work-CxqS_Ny9.mjs.map +1 -0
  680. package/dist/menu-CvWToneO.mjs +420 -0
  681. package/dist/menu-CvWToneO.mjs.map +1 -0
  682. package/dist/menus-BzjHvAM4.mjs +434 -0
  683. package/dist/menus-BzjHvAM4.mjs.map +1 -0
  684. package/dist/menus-CnEw5nz8.mjs +92 -0
  685. package/dist/menus-CnEw5nz8.mjs.map +1 -0
  686. package/dist/menus-DoVbs2sn.mjs +433 -0
  687. package/dist/menus-DoVbs2sn.mjs.map +1 -0
  688. package/dist/migrations/index.d.mts +1 -1
  689. package/dist/migrations/index.mjs +2 -2
  690. package/dist/mime-C_YV5Mjm.mjs +90 -0
  691. package/dist/mime-C_YV5Mjm.mjs.map +1 -0
  692. package/dist/node-sqlite-compat-DHFDZMe2.mjs +68 -0
  693. package/dist/node-sqlite-compat-DHFDZMe2.mjs.map +1 -0
  694. package/dist/oauth-authorization-CvT-8KtG.mjs +287 -0
  695. package/dist/oauth-authorization-CvT-8KtG.mjs.map +1 -0
  696. package/dist/oauth-clients-ohsH0FlQ.mjs +266 -0
  697. package/dist/oauth-clients-ohsH0FlQ.mjs.map +1 -0
  698. package/dist/oauth-state-store-V4y2qZwD.mjs +80 -0
  699. package/dist/oauth-state-store-V4y2qZwD.mjs.map +1 -0
  700. package/dist/oauth-user-lookup-D2NTHxcr.mjs +26 -0
  701. package/dist/oauth-user-lookup-D2NTHxcr.mjs.map +1 -0
  702. package/dist/object-cache/memory.d.mts +1 -1
  703. package/dist/object-cache-I4Re7BOR.mjs +807 -0
  704. package/dist/object-cache-I4Re7BOR.mjs.map +1 -0
  705. package/dist/options-CbSYZAwr.d.mts +81 -0
  706. package/dist/options-CbSYZAwr.d.mts.map +1 -0
  707. package/dist/page/index.d.mts +2 -2
  708. package/dist/parse-BTfkfMuL.mjs +82 -0
  709. package/dist/parse-BTfkfMuL.mjs.map +1 -0
  710. package/dist/parse-CBM779p-.d.mts +180 -0
  711. package/dist/parse-CBM779p-.d.mts.map +1 -0
  712. package/dist/parts-i0nNljq-.mjs +68 -0
  713. package/dist/parts-i0nNljq-.mjs.map +1 -0
  714. package/dist/passkey-config-D9iYgt4G.mjs +46 -0
  715. package/dist/passkey-config-D9iYgt4G.mjs.map +1 -0
  716. package/dist/paths-B1TgS0ir.mjs +77 -0
  717. package/dist/paths-B1TgS0ir.mjs.map +1 -0
  718. package/dist/placeholder-PFMxMYTa.d.mts +316 -0
  719. package/dist/placeholder-PFMxMYTa.d.mts.map +1 -0
  720. package/dist/plan-DQoNgF2Y.mjs +135 -0
  721. package/dist/plan-DQoNgF2Y.mjs.map +1 -0
  722. package/dist/plugin-settings-CKffVNYE.mjs +162 -0
  723. package/dist/plugin-settings-CKffVNYE.mjs.map +1 -0
  724. package/dist/plugin-test-runtime.d.mts +23 -22
  725. package/dist/plugin-test-runtime.d.mts.map +1 -1
  726. package/dist/plugin-test-runtime.mjs +9 -8
  727. package/dist/plugin-types.d.mts +2 -2
  728. package/dist/plugin-utils.d.mts +15 -15
  729. package/dist/plugins/adapt-sandbox-entry.d.mts +15 -15
  730. package/dist/plugins/adapt-sandbox-entry.mjs +4 -4
  731. package/dist/plugins/host.d.mts +6 -6
  732. package/dist/plugins/host.mjs +8 -7
  733. package/dist/plugins-DDiWIA_N.mjs +261 -0
  734. package/dist/plugins-DDiWIA_N.mjs.map +1 -0
  735. package/dist/policy-72PGoCgJ.mjs +56 -0
  736. package/dist/policy-72PGoCgJ.mjs.map +1 -0
  737. package/dist/portable-text-D18C1jR6.mjs +457 -0
  738. package/dist/portable-text-D18C1jR6.mjs.map +1 -0
  739. package/dist/protocol-CbSoh3FE.d.mts +65 -0
  740. package/dist/protocol-CbSoh3FE.d.mts.map +1 -0
  741. package/dist/public-plugin-api-routes-Bq55wwHn.mjs +323 -0
  742. package/dist/public-plugin-api-routes-Bq55wwHn.mjs.map +1 -0
  743. package/dist/public-submission-BEcSmcWi.mjs +253 -0
  744. package/dist/public-submission-BEcSmcWi.mjs.map +1 -0
  745. package/dist/public-url-DYZMfvpa.mjs +123 -0
  746. package/dist/public-url-DYZMfvpa.mjs.map +1 -0
  747. package/dist/query-CslUTGOV.mjs +1221 -0
  748. package/dist/query-CslUTGOV.mjs.map +1 -0
  749. package/dist/query-Cv8bjIwl.mjs +41 -0
  750. package/dist/query-Cv8bjIwl.mjs.map +1 -0
  751. package/dist/range-CzdsIs-O.mjs +51 -0
  752. package/dist/range-CzdsIs-O.mjs.map +1 -0
  753. package/dist/rate-limit-iZgsy_oY.mjs +127 -0
  754. package/dist/rate-limit-iZgsy_oY.mjs.map +1 -0
  755. package/dist/receipt-CqxAacXn.mjs +43 -0
  756. package/dist/receipt-CqxAacXn.mjs.map +1 -0
  757. package/dist/redirect-3A3kqsD-.mjs +19 -0
  758. package/dist/redirect-3A3kqsD-.mjs.map +1 -0
  759. package/dist/redirect-DsaFuuQi.mjs +466 -0
  760. package/dist/redirect-DsaFuuQi.mjs.map +1 -0
  761. package/dist/redirect-paths-DgkkN0qJ.mjs +36 -0
  762. package/dist/redirect-paths-DgkkN0qJ.mjs.map +1 -0
  763. package/dist/redirects-DfvdrgF1.mjs +446 -0
  764. package/dist/redirects-DfvdrgF1.mjs.map +1 -0
  765. package/dist/redirects-Yo8YTJMV.mjs +148 -0
  766. package/dist/redirects-Yo8YTJMV.mjs.map +1 -0
  767. package/dist/registry/testing.mjs +2 -2
  768. package/dist/registry-2vAYgqCz.mjs +755 -0
  769. package/dist/registry-2vAYgqCz.mjs.map +1 -0
  770. package/dist/registry-COR9pjyi.mjs +1449 -0
  771. package/dist/registry-COR9pjyi.mjs.map +1 -0
  772. package/dist/registry-CSLrHSx1.mjs +6139 -0
  773. package/dist/registry-CSLrHSx1.mjs.map +1 -0
  774. package/dist/relations-5fVj42fZ.mjs +798 -0
  775. package/dist/relations-5fVj42fZ.mjs.map +1 -0
  776. package/dist/request-context.d.mts +2 -2
  777. package/dist/request-meta-B0TPrDpq.mjs +141 -0
  778. package/dist/request-meta-B0TPrDpq.mjs.map +1 -0
  779. package/dist/resolve--EmZidEz.mjs +92 -0
  780. package/dist/resolve--EmZidEz.mjs.map +1 -0
  781. package/dist/revision-Dk9VI8Vf.mjs +503 -0
  782. package/dist/revision-Dk9VI8Vf.mjs.map +1 -0
  783. package/dist/rooms/index.d.mts +15 -15
  784. package/dist/rooms/index.mjs +3 -3
  785. package/dist/rooms/node/index.d.mts +15 -15
  786. package/dist/rooms/node/index.mjs +6 -6
  787. package/dist/rooms/notifications.d.mts +15 -15
  788. package/dist/rooms/notifications.mjs +2 -2
  789. package/dist/rooms/room.d.mts +15 -15
  790. package/dist/rooms/room.mjs +2 -2
  791. package/dist/rooms/site.d.mts +15 -15
  792. package/dist/rooms/site.mjs +4 -4
  793. package/dist/rooms-AcO0YNUt.mjs +335 -0
  794. package/dist/rooms-AcO0YNUt.mjs.map +1 -0
  795. package/dist/rooms-B2P1xIS_.d.mts +4778 -0
  796. package/dist/rooms-B2P1xIS_.d.mts.map +1 -0
  797. package/dist/rooms-C08U-F8Y.mjs +169 -0
  798. package/dist/rooms-C08U-F8Y.mjs.map +1 -0
  799. package/dist/route-cache-CvTJlNVT.mjs +30 -0
  800. package/dist/route-cache-CvTJlNVT.mjs.map +1 -0
  801. package/dist/route-wire-NAkNES3Z.mjs +197 -0
  802. package/dist/route-wire-NAkNES3Z.mjs.map +1 -0
  803. package/dist/routes-BScyES_G.mjs +272 -0
  804. package/dist/routes-BScyES_G.mjs.map +1 -0
  805. package/dist/runner-C6gBIcTD.d.mts +79 -0
  806. package/dist/runner-C6gBIcTD.d.mts.map +1 -0
  807. package/dist/runner-Nv0yWP-G.mjs +6964 -0
  808. package/dist/runner-Nv0yWP-G.mjs.map +1 -0
  809. package/dist/runtime-holder-DkZ_0f7A.mjs +36 -0
  810. package/dist/runtime-holder-DkZ_0f7A.mjs.map +1 -0
  811. package/dist/runtime.d.mts +16 -16
  812. package/dist/runtime.mjs +1 -1
  813. package/dist/scheduler-health-B5n19775.mjs +31 -0
  814. package/dist/scheduler-health-B5n19775.mjs.map +1 -0
  815. package/dist/schema/project-env-types.mjs +6 -6
  816. package/dist/schema-B7ODIkP4.mjs +13 -0
  817. package/dist/schema-B7ODIkP4.mjs.map +1 -0
  818. package/dist/schema-D04_n_7j.mjs +815 -0
  819. package/dist/schema-D04_n_7j.mjs.map +1 -0
  820. package/dist/scopes-CHc86VzZ.mjs +34 -0
  821. package/dist/scopes-CHc86VzZ.mjs.map +1 -0
  822. package/dist/search-BxBg7Xq1.mjs +503 -0
  823. package/dist/search-BxBg7Xq1.mjs.map +1 -0
  824. package/dist/search-SRLBXKJU.mjs +12 -0
  825. package/dist/search-SRLBXKJU.mjs.map +1 -0
  826. package/dist/secrets-O25WpEe_.mjs +369 -0
  827. package/dist/secrets-O25WpEe_.mjs.map +1 -0
  828. package/dist/sections-BK7soA2U.mjs +222 -0
  829. package/dist/sections-BK7soA2U.mjs.map +1 -0
  830. package/dist/sections-CLejSkAG.mjs +129 -0
  831. package/dist/sections-CLejSkAG.mjs.map +1 -0
  832. package/dist/seed/index.d.mts +2 -2
  833. package/dist/seed/index.mjs +4 -4
  834. package/dist/seo/index.d.mts +3 -3
  835. package/dist/seo/index.mjs +3 -3
  836. package/dist/seo-Ie7B6cud.mjs +194 -0
  837. package/dist/seo-Ie7B6cud.mjs.map +1 -0
  838. package/dist/service-DbKGSUHC.mjs +150 -0
  839. package/dist/service-DbKGSUHC.mjs.map +1 -0
  840. package/dist/session-user-BrCPLyWB.mjs +61 -0
  841. package/dist/session-user-BrCPLyWB.mjs.map +1 -0
  842. package/dist/settings-BApLX_aS.mjs +413 -0
  843. package/dist/settings-BApLX_aS.mjs.map +1 -0
  844. package/dist/settings-Ces2K0VL.mjs +74 -0
  845. package/dist/settings-Ces2K0VL.mjs.map +1 -0
  846. package/dist/settings-DMHIgDyb.mjs +66 -0
  847. package/dist/settings-DMHIgDyb.mjs.map +1 -0
  848. package/dist/settings-DgnWX0GN.mjs +157 -0
  849. package/dist/settings-DgnWX0GN.mjs.map +1 -0
  850. package/dist/setup-complete-DQ1nNEjm.mjs +65 -0
  851. package/dist/setup-complete-DQ1nNEjm.mjs.map +1 -0
  852. package/dist/setup-nonce-5k8BY3W_.mjs +25 -0
  853. package/dist/setup-nonce-5k8BY3W_.mjs.map +1 -0
  854. package/dist/site-domain-B2KvJstd.mjs +131 -0
  855. package/dist/site-domain-B2KvJstd.mjs.map +1 -0
  856. package/dist/site-settings-B7VxSqP6.mjs +50 -0
  857. package/dist/site-settings-B7VxSqP6.mjs.map +1 -0
  858. package/dist/site-title-DHgWlyMw.mjs +14 -0
  859. package/dist/site-title-DHgWlyMw.mjs.map +1 -0
  860. package/dist/site-url-OBYES-gb.mjs +45 -0
  861. package/dist/site-url-OBYES-gb.mjs.map +1 -0
  862. package/dist/sitemap-name-BZXv5sf0.mjs +26 -0
  863. package/dist/sitemap-name-BZXv5sf0.mjs.map +1 -0
  864. package/dist/slug-CFsfrxUp.mjs +16 -0
  865. package/dist/slug-CFsfrxUp.mjs.map +1 -0
  866. package/dist/snapshot-BaIv7afB.mjs +466 -0
  867. package/dist/snapshot-BaIv7afB.mjs.map +1 -0
  868. package/dist/snapshot-VQM7BcdM.mjs +184 -0
  869. package/dist/snapshot-VQM7BcdM.mjs.map +1 -0
  870. package/dist/ssrf-Em0CeaaN.mjs +406 -0
  871. package/dist/ssrf-Em0CeaaN.mjs.map +1 -0
  872. package/dist/stage-Ctas_E7M.mjs +662 -0
  873. package/dist/stage-Ctas_E7M.mjs.map +1 -0
  874. package/dist/staged-C746SkS0.mjs +686 -0
  875. package/dist/staged-C746SkS0.mjs.map +1 -0
  876. package/dist/start-user-session-CdyNie0P.mjs +9 -0
  877. package/dist/start-user-session-CdyNie0P.mjs.map +1 -0
  878. package/dist/state-Cdkt6b1h.mjs +282 -0
  879. package/dist/state-Cdkt6b1h.mjs.map +1 -0
  880. package/dist/storage/local.d.mts +1 -1
  881. package/dist/storage/local.mjs +2 -2
  882. package/dist/storage/s3.d.mts +1 -1
  883. package/dist/storage/s3.mjs +1 -1
  884. package/dist/storage-query-DdKo8oes.d.mts +1614 -0
  885. package/dist/storage-query-DdKo8oes.d.mts.map +1 -0
  886. package/dist/tar-Tbl91sMI.mjs +449 -0
  887. package/dist/tar-Tbl91sMI.mjs.map +1 -0
  888. package/dist/target-Bjxlaj4T.mjs +27 -0
  889. package/dist/target-Bjxlaj4T.mjs.map +1 -0
  890. package/dist/taxonomies-D5bavOHA.mjs +937 -0
  891. package/dist/taxonomies-D5bavOHA.mjs.map +1 -0
  892. package/dist/taxonomies-DApyZAJq.mjs +722 -0
  893. package/dist/taxonomies-DApyZAJq.mjs.map +1 -0
  894. package/dist/taxonomy-D4Fl2smf.mjs +593 -0
  895. package/dist/taxonomy-D4Fl2smf.mjs.map +1 -0
  896. package/dist/tokens-DvEbszXd.mjs +171 -0
  897. package/dist/tokens-DvEbszXd.mjs.map +1 -0
  898. package/dist/transaction-D5Kq7MTL.mjs +44 -0
  899. package/dist/transaction-D5Kq7MTL.mjs.map +1 -0
  900. package/dist/transfer-BwKpOrTV.mjs +8963 -0
  901. package/dist/transfer-BwKpOrTV.mjs.map +1 -0
  902. package/dist/transfer-CafpWTD6.mjs +166 -0
  903. package/dist/transfer-CafpWTD6.mjs.map +1 -0
  904. package/dist/transfer-download-H8beYs2r.mjs +33 -0
  905. package/dist/transfer-download-H8beYs2r.mjs.map +1 -0
  906. package/dist/transformations-DX_dwSfp.mjs +196 -0
  907. package/dist/transformations-DX_dwSfp.mjs.map +1 -0
  908. package/dist/transport-7mI_Nvnn.d.mts +42 -0
  909. package/dist/transport-7mI_Nvnn.d.mts.map +1 -0
  910. package/dist/transport-Cs1Xl7-v.mjs +144 -0
  911. package/dist/transport-Cs1Xl7-v.mjs.map +1 -0
  912. package/dist/trusted-proxy-DaSru7xW.mjs +51 -0
  913. package/dist/trusted-proxy-DaSru7xW.mjs.map +1 -0
  914. package/dist/turnstile-DNR0cwtt.mjs +58 -0
  915. package/dist/turnstile-DNR0cwtt.mjs.map +1 -0
  916. package/dist/types-8q-gxKfV.d.mts +935 -0
  917. package/dist/types-8q-gxKfV.d.mts.map +1 -0
  918. package/dist/types-BBH-w_KS.mjs.map +1 -1
  919. package/dist/types-BE4og6EZ.d.mts +292 -0
  920. package/dist/types-BE4og6EZ.d.mts.map +1 -0
  921. package/dist/types-BbOWBoRk.d.mts +384 -0
  922. package/dist/types-BbOWBoRk.d.mts.map +1 -0
  923. package/dist/types-BmBK2cqf.mjs.map +1 -1
  924. package/dist/types-C3tTVw9y.mjs +37 -0
  925. package/dist/types-C3tTVw9y.mjs.map +1 -0
  926. package/dist/types-CTQEkZcI.mjs +16 -0
  927. package/dist/types-CTQEkZcI.mjs.map +1 -0
  928. package/dist/types-CbfB5YfA.d.mts +209 -0
  929. package/dist/types-CbfB5YfA.d.mts.map +1 -0
  930. package/dist/types-CeknTiV0.d.mts +93 -0
  931. package/dist/types-CeknTiV0.d.mts.map +1 -0
  932. package/dist/types-CpFfDrGH.mjs.map +1 -1
  933. package/dist/types-DHjtQujX.mjs +77 -0
  934. package/dist/types-DHjtQujX.mjs.map +1 -0
  935. package/dist/types-EYyvAjNA.d.mts +125 -0
  936. package/dist/types-EYyvAjNA.d.mts.map +1 -0
  937. package/dist/types-VMZCO8hc.d.mts +366 -0
  938. package/dist/types-VMZCO8hc.d.mts.map +1 -0
  939. package/dist/types-YTpIfKXX.d.mts +1756 -0
  940. package/dist/types-YTpIfKXX.d.mts.map +1 -0
  941. package/dist/types-iSBIMGiz.d.mts +227 -0
  942. package/dist/types-iSBIMGiz.d.mts.map +1 -0
  943. package/dist/upload-attempts-ChkgAfye.mjs +32 -0
  944. package/dist/upload-attempts-ChkgAfye.mjs.map +1 -0
  945. package/dist/url-CBR5ZBBQ.mjs +87 -0
  946. package/dist/url-CBR5ZBBQ.mjs.map +1 -0
  947. package/dist/url-pattern-DViEwhDu.mjs +41 -0
  948. package/dist/url-pattern-DViEwhDu.mjs.map +1 -0
  949. package/dist/urls-BCnpTM3T.mjs +79 -0
  950. package/dist/urls-BCnpTM3T.mjs.map +1 -0
  951. package/dist/user-Cy4kOmtD.mjs +184 -0
  952. package/dist/user-Cy4kOmtD.mjs.map +1 -0
  953. package/dist/utils-0R0olFJs.d.mts +374 -0
  954. package/dist/utils-0R0olFJs.d.mts.map +1 -0
  955. package/dist/utils-DIfKXQ5o.mjs +450 -0
  956. package/dist/utils-DIfKXQ5o.mjs.map +1 -0
  957. package/dist/validate-CYHbSQ-M.d.mts +472 -0
  958. package/dist/validate-CYHbSQ-M.d.mts.map +1 -0
  959. package/dist/validate-DBnEN6hU.mjs +524 -0
  960. package/dist/validate-DBnEN6hU.mjs.map +1 -0
  961. package/dist/validation-Becbh-zl.mjs +204 -0
  962. package/dist/validation-Becbh-zl.mjs.map +1 -0
  963. package/dist/version-BE4RahxC.mjs +7 -0
  964. package/dist/version-BE4RahxC.mjs.map +1 -0
  965. package/dist/version-C3C6o1xi.mjs +9 -0
  966. package/dist/version-C3C6o1xi.mjs.map +1 -0
  967. package/dist/version-PIyVra05.mjs +49 -0
  968. package/dist/version-PIyVra05.mjs.map +1 -0
  969. package/dist/video-Cgw31pIP.mjs +18 -0
  970. package/dist/video-Cgw31pIP.mjs.map +1 -0
  971. package/dist/virtual-modules-DAvm-Tct.mjs +565 -0
  972. package/dist/virtual-modules-DAvm-Tct.mjs.map +1 -0
  973. package/dist/widgets-HYhp_QtR.mjs +134 -0
  974. package/dist/widgets-HYhp_QtR.mjs.map +1 -0
  975. package/dist/wxr-CDtij4U5.mjs +1054 -0
  976. package/dist/wxr-CDtij4U5.mjs.map +1 -0
  977. package/dist/wxr-taxonomies-fliLjgKD.mjs +735 -0
  978. package/dist/wxr-taxonomies-fliLjgKD.mjs.map +1 -0
  979. package/dist/wxr-taxonomies-uZgPVgPe.d.mts +34 -0
  980. package/dist/wxr-taxonomies-uZgPVgPe.d.mts.map +1 -0
  981. package/package.json +11 -10
  982. package/src/after.ts +17 -10
  983. package/src/api/error.ts +0 -13
  984. package/src/api/handlers/manifest.ts +1 -0
  985. package/src/api/handlers/media-allowlist.ts +66 -7
  986. package/src/api/handlers/media-usage.ts +2 -1
  987. package/src/api/handlers/media.ts +4 -2
  988. package/src/api/handlers/seo.ts +19 -7
  989. package/src/api/openapi/document.ts +1 -1
  990. package/src/api/schemas/auth.ts +7 -0
  991. package/src/api/schemas/media-usage.ts +1 -0
  992. package/src/api/schemas/media.ts +13 -3
  993. package/src/api/schemas/schema.ts +14 -0
  994. package/src/api/search.ts +15 -0
  995. package/src/api/types.ts +3 -0
  996. package/src/astro/image-endpoint.ts +30 -4
  997. package/src/astro/integration/dev-scheduler-bridge.ts +1 -2
  998. package/src/astro/integration/index.ts +22 -1
  999. package/src/astro/integration/routes.ts +4 -0
  1000. package/src/astro/integration/virtual-modules.ts +3 -6
  1001. package/src/astro/integration/vite-config.ts +13 -6
  1002. package/src/astro/middleware/auth.ts +18 -11
  1003. package/src/astro/middleware/redirect.ts +41 -23
  1004. package/src/astro/middleware/request-context.ts +4 -2
  1005. package/src/astro/middleware/scoped-db.ts +4 -4
  1006. package/src/astro/middleware.ts +288 -204
  1007. package/src/astro/prefetch.ts +21 -17
  1008. package/src/astro/public-plugin-api-routes.ts +4 -4
  1009. package/src/astro/routes/PluginRegistry.tsx +2 -3
  1010. package/src/astro/routes/api/admin/byline-fields/[slug]/usage.ts +4 -3
  1011. package/src/astro/routes/api/admin/byline-fields/[slug].ts +10 -7
  1012. package/src/astro/routes/api/admin/byline-fields/index.ts +7 -5
  1013. package/src/astro/routes/api/admin/byline-fields/reorder.ts +4 -3
  1014. package/src/astro/routes/api/admin/bylines/[id]/index.ts +4 -3
  1015. package/src/astro/routes/api/admin/bylines/[id]/translations.ts +7 -5
  1016. package/src/astro/routes/api/admin/comments/[id]/status.ts +4 -3
  1017. package/src/astro/routes/api/admin/comments/[id].ts +7 -5
  1018. package/src/astro/routes/api/admin/comments/bulk.ts +4 -3
  1019. package/src/astro/routes/api/admin/comments/counts.ts +4 -3
  1020. package/src/astro/routes/api/admin/comments/index.ts +4 -3
  1021. package/src/astro/routes/api/admin/media-usage/activation.ts +7 -5
  1022. package/src/astro/routes/api/admin/media-usage/collection-deletions/index.ts +4 -3
  1023. package/src/astro/routes/api/admin/media-usage/collection-deletions/retry.ts +4 -3
  1024. package/src/astro/routes/api/admin/media-usage/progress.ts +7 -5
  1025. package/src/astro/routes/api/admin/media-usage/repair.ts +4 -3
  1026. package/src/astro/routes/api/admin/media-usage/work/index.ts +4 -3
  1027. package/src/astro/routes/api/admin/media-usage/work/retry.ts +4 -3
  1028. package/src/astro/routes/api/admin/plugins/registry/artifact.ts +7 -4
  1029. package/src/astro/routes/api/admin/transfer/approvals/[id]/approve.ts +4 -3
  1030. package/src/astro/routes/api/admin/transfer/approvals/[id]/deny.ts +4 -3
  1031. package/src/astro/routes/api/admin/transfer/approvals/index.ts +4 -3
  1032. package/src/astro/routes/api/admin/transfer/capabilities.ts +4 -3
  1033. package/src/astro/routes/api/admin/transfer/exports/[id]/advance.ts +4 -3
  1034. package/src/astro/routes/api/admin/transfer/exports/[id]/archive.ts +4 -3
  1035. package/src/astro/routes/api/admin/transfer/exports/[id]/files/[...path].ts +4 -3
  1036. package/src/astro/routes/api/admin/transfer/exports/[id]/index.ts +4 -3
  1037. package/src/astro/routes/api/admin/transfer/exports/[id]/manifest.ts +4 -3
  1038. package/src/astro/routes/api/admin/transfer/exports/index.ts +7 -5
  1039. package/src/astro/routes/api/admin/transfer/imports/[id]/abandon.ts +4 -3
  1040. package/src/astro/routes/api/admin/transfer/imports/[id]/advance.ts +4 -3
  1041. package/src/astro/routes/api/admin/transfer/imports/[id]/analyze.ts +4 -3
  1042. package/src/astro/routes/api/admin/transfer/imports/[id]/cancel.ts +4 -3
  1043. package/src/astro/routes/api/admin/transfer/imports/[id]/execute.ts +4 -3
  1044. package/src/astro/routes/api/admin/transfer/imports/[id]/files/[...path].ts +4 -3
  1045. package/src/astro/routes/api/admin/transfer/imports/[id]/index.ts +4 -3
  1046. package/src/astro/routes/api/admin/transfer/imports/[id]/missing.ts +4 -3
  1047. package/src/astro/routes/api/admin/transfer/imports/[id]/plan.ts +4 -3
  1048. package/src/astro/routes/api/admin/transfer/imports/[id]/receipt.ts +4 -3
  1049. package/src/astro/routes/api/admin/transfer/imports/index.ts +7 -5
  1050. package/src/astro/routes/api/auth/invite/complete.ts +2 -1
  1051. package/src/astro/routes/api/auth/magic-link/verify.ts +2 -1
  1052. package/src/astro/routes/api/auth/oauth/[provider]/callback.ts +2 -1
  1053. package/src/astro/routes/api/auth/passkey/verify.ts +2 -1
  1054. package/src/astro/routes/api/auth/signup/complete.ts +2 -1
  1055. package/src/astro/routes/api/auth/signup/register-options.ts +69 -0
  1056. package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +7 -5
  1057. package/src/astro/routes/api/comments/[collection]/[contentId]/reactions.ts +7 -5
  1058. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +3 -13
  1059. package/src/astro/routes/api/content/[collection]/[id]/duplicate.ts +3 -13
  1060. package/src/astro/routes/api/content/[collection]/[id]/lock.ts +19 -19
  1061. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +3 -12
  1062. package/src/astro/routes/api/content/[collection]/[id]/references/[relation]/children.ts +4 -3
  1063. package/src/astro/routes/api/content/[collection]/[id]/references/[relation]/parents.ts +4 -3
  1064. package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +11 -19
  1065. package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +3 -12
  1066. package/src/astro/routes/api/content/[collection]/[id].ts +12 -34
  1067. package/src/astro/routes/api/import/wordpress/execute.ts +1 -4
  1068. package/src/astro/routes/api/import/wordpress/media.ts +3 -2
  1069. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +1 -4
  1070. package/src/astro/routes/api/media/[id]/replace.ts +11 -2
  1071. package/src/astro/routes/api/media/[id].ts +16 -3
  1072. package/src/astro/routes/api/media/file/[...key].ts +11 -0
  1073. package/src/astro/routes/api/media/providers/[providerId]/[itemId].ts +18 -2
  1074. package/src/astro/routes/api/menus/[name]/items/[id].ts +6 -0
  1075. package/src/astro/routes/api/menus/[name]/items.ts +4 -1
  1076. package/src/astro/routes/api/menus/[name]/reorder.ts +4 -1
  1077. package/src/astro/routes/api/menus/[name]/translations.ts +7 -5
  1078. package/src/astro/routes/api/menus/[name].ts +10 -1
  1079. package/src/astro/routes/api/menus/index.ts +7 -1
  1080. package/src/astro/routes/api/redirects/404s/index.ts +10 -7
  1081. package/src/astro/routes/api/redirects/404s/summary.ts +4 -3
  1082. package/src/astro/routes/api/redirects/[id].ts +10 -7
  1083. package/src/astro/routes/api/redirects/index.ts +7 -5
  1084. package/src/astro/routes/api/relations/[id]/index.ts +10 -7
  1085. package/src/astro/routes/api/relations/index.ts +7 -5
  1086. package/src/astro/routes/api/schema/block-types/[slug]/index.ts +7 -5
  1087. package/src/astro/routes/api/schema/block-types/[slug]/versions/[version]/activate.ts +4 -3
  1088. package/src/astro/routes/api/schema/block-types/index.ts +7 -5
  1089. package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +10 -7
  1090. package/src/astro/routes/api/schema/collections/[slug]/fields/index.ts +7 -5
  1091. package/src/astro/routes/api/schema/collections/[slug]/fields/reorder.ts +4 -3
  1092. package/src/astro/routes/api/schema/collections/[slug]/index.ts +10 -7
  1093. package/src/astro/routes/api/schema/collections/index.ts +7 -5
  1094. package/src/astro/routes/api/schema/collections/reorder.ts +4 -3
  1095. package/src/astro/routes/api/schema/index.ts +4 -3
  1096. package/src/astro/routes/api/schema/orphans/[slug].ts +4 -3
  1097. package/src/astro/routes/api/schema/orphans/index.ts +4 -3
  1098. package/src/astro/routes/api/search/enable.ts +4 -0
  1099. package/src/astro/routes/api/search/index.ts +5 -3
  1100. package/src/astro/routes/api/search/rebuild.ts +4 -0
  1101. package/src/astro/routes/api/search/stats.ts +4 -0
  1102. package/src/astro/routes/api/search/suggest.ts +4 -0
  1103. package/src/astro/routes/api/sections/[slug].ts +10 -7
  1104. package/src/astro/routes/api/sections/index.ts +7 -5
  1105. package/src/astro/routes/api/setup/admin-verify.ts +2 -1
  1106. package/src/astro/routes/api/taxonomies/[name]/reorder.ts +4 -3
  1107. package/src/astro/routes/api/taxonomies/[name]/terms/[slug]/translations.ts +7 -5
  1108. package/src/astro/routes/api/taxonomies/[name]/terms/[slug].ts +10 -7
  1109. package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +7 -5
  1110. package/src/astro/routes/api/taxonomies/[name]/translations.ts +4 -3
  1111. package/src/astro/routes/api/taxonomies/[name].ts +10 -7
  1112. package/src/astro/routes/api/taxonomies/bulk-tag.ts +4 -3
  1113. package/src/astro/routes/api/taxonomies/index.ts +7 -5
  1114. package/src/astro/routes/api/widget-areas/[name]/reorder.ts +3 -0
  1115. package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +6 -0
  1116. package/src/astro/routes/api/widget-areas/[name]/widgets.ts +3 -0
  1117. package/src/astro/routes/api/widget-areas/[name].ts +6 -0
  1118. package/src/astro/routes/api/widget-areas/index.ts +6 -0
  1119. package/src/astro/session-user.ts +8 -4
  1120. package/src/astro/types.ts +77 -53
  1121. package/src/auth/start-user-session.ts +16 -0
  1122. package/src/cleanup.ts +24 -5
  1123. package/src/client/index.ts +5 -3
  1124. package/src/client/portable-text.ts +9 -1
  1125. package/src/comments/public-submission.ts +1 -1
  1126. package/src/components/Code.astro +6 -1
  1127. package/src/components/Comments.astro +17 -6
  1128. package/src/components/InlinePortableTextEditor.tsx +9 -1
  1129. package/src/database/dialect-helpers.ts +18 -3
  1130. package/src/database/migrations/098_user_last_login.ts +13 -0
  1131. package/src/database/migrations/runner.ts +2 -0
  1132. package/src/database/repositories/content.ts +37 -0
  1133. package/src/database/repositories/media-folders.ts +2 -6
  1134. package/src/database/repositories/media.ts +16 -7
  1135. package/src/database/repositories/revision.ts +2 -2
  1136. package/src/database/repositories/seo.ts +34 -10
  1137. package/src/database/repositories/types.ts +2 -2
  1138. package/src/database/repositories/user.ts +2 -2
  1139. package/src/database/types.ts +1 -0
  1140. package/src/db/node-sqlite-compat.ts +13 -0
  1141. package/src/emdash-runtime.ts +775 -308
  1142. package/src/mcp/server.ts +27 -34
  1143. package/src/media/image-endpoint.ts +84 -0
  1144. package/src/media/url.ts +16 -3
  1145. package/src/media/usage/content-fields.ts +7 -5
  1146. package/src/media/usage/content-lock.ts +71 -0
  1147. package/src/media/usage/content-refresh.ts +3 -72
  1148. package/src/media/usage/content-snapshots.ts +26 -0
  1149. package/src/media/usage/extractor.ts +132 -32
  1150. package/src/media/usage/types.ts +3 -1
  1151. package/src/object-cache/index.ts +16 -12
  1152. package/src/plugins/context.ts +22 -1
  1153. package/src/plugins/http-route-dispatch.ts +16 -8
  1154. package/src/plugins/lifecycle.ts +16 -4
  1155. package/src/plugins/sandbox/proxy.ts +2 -2
  1156. package/src/plugins/scheduler/node.ts +17 -11
  1157. package/src/plugins/state.ts +236 -78
  1158. package/src/query.ts +36 -5
  1159. package/src/scheduled-publish.ts +54 -6
  1160. package/src/schema/block-type-contract.ts +35 -4
  1161. package/src/schema/block-type-registry.ts +1 -1
  1162. package/src/schema/types.ts +3 -0
  1163. package/src/search/fts-manager.ts +79 -19
  1164. package/src/search/query.ts +212 -101
  1165. package/src/search/types.ts +6 -1
  1166. package/src/virtual-modules.d.ts +3 -10
  1167. package/dist/action-token-CKphU6ur.mjs +0 -26
  1168. package/dist/action-token-CKphU6ur.mjs.map +0 -1
  1169. package/dist/activation-X5iMalte.mjs +0 -387
  1170. package/dist/activation-X5iMalte.mjs.map +0 -1
  1171. package/dist/adapters-DFsc9XjW.d.mts +0 -173
  1172. package/dist/adapters-DFsc9XjW.d.mts.map +0 -1
  1173. package/dist/after-B3AvMfBQ.mjs +0 -50
  1174. package/dist/after-B3AvMfBQ.mjs.map +0 -1
  1175. package/dist/allowed-origins-BFDNF-05.mjs +0 -116
  1176. package/dist/allowed-origins-BFDNF-05.mjs.map +0 -1
  1177. package/dist/api-tokens-D27OQ0oQ.mjs +0 -173
  1178. package/dist/api-tokens-D27OQ0oQ.mjs.map +0 -1
  1179. package/dist/apply-Culv7QJl.mjs +0 -1774
  1180. package/dist/apply-Culv7QJl.mjs.map +0 -1
  1181. package/dist/approvals-oLE5G5jw.mjs +0 -460
  1182. package/dist/approvals-oLE5G5jw.mjs.map +0 -1
  1183. package/dist/artifact-fetch-ByK_1pck.mjs +0 -659
  1184. package/dist/artifact-fetch-ByK_1pck.mjs.map +0 -1
  1185. package/dist/artifacts-BXKMIV2F.mjs +0 -323
  1186. package/dist/artifacts-BXKMIV2F.mjs.map +0 -1
  1187. package/dist/authoritative-records-Cd5BVXRs.mjs +0 -5183
  1188. package/dist/authoritative-records-Cd5BVXRs.mjs.map +0 -1
  1189. package/dist/authorize-B-4ogCQG.mjs +0 -74
  1190. package/dist/authorize-B-4ogCQG.mjs.map +0 -1
  1191. package/dist/backup-BQhg3MEK.mjs +0 -246
  1192. package/dist/backup-BQhg3MEK.mjs.map +0 -1
  1193. package/dist/block-types-BTzqdEZV.mjs +0 -132
  1194. package/dist/block-types-BTzqdEZV.mjs.map +0 -1
  1195. package/dist/block-values-DzZIh7WN.mjs +0 -215
  1196. package/dist/block-values-DzZIh7WN.mjs.map +0 -1
  1197. package/dist/byline--sweE_MZ.mjs +0 -930
  1198. package/dist/byline--sweE_MZ.mjs.map +0 -1
  1199. package/dist/byline-fields-Czdq4Yad.mjs +0 -123
  1200. package/dist/byline-fields-Czdq4Yad.mjs.map +0 -1
  1201. package/dist/byline-registry-Cr7kjrxM.mjs +0 -406
  1202. package/dist/byline-registry-Cr7kjrxM.mjs.map +0 -1
  1203. package/dist/bylines-DnuH3H8z.mjs +0 -234
  1204. package/dist/bylines-DnuH3H8z.mjs.map +0 -1
  1205. package/dist/bylines-txlwgzIK.mjs +0 -150
  1206. package/dist/bylines-txlwgzIK.mjs.map +0 -1
  1207. package/dist/cache-BjnpmIpb.mjs +0 -151
  1208. package/dist/cache-BjnpmIpb.mjs.map +0 -1
  1209. package/dist/canonical-Cb-rJGRU.mjs +0 -174
  1210. package/dist/canonical-Cb-rJGRU.mjs.map +0 -1
  1211. package/dist/capture-triggers-BZmIEdX2.mjs +0 -362
  1212. package/dist/capture-triggers-BZmIEdX2.mjs.map +0 -1
  1213. package/dist/checksum-CH9TyM-N.mjs +0 -162
  1214. package/dist/checksum-CH9TyM-N.mjs.map +0 -1
  1215. package/dist/chunks-DRnEstVb.mjs +0 -25
  1216. package/dist/chunks-DRnEstVb.mjs.map +0 -1
  1217. package/dist/collection-slugs-cache-CYMrqHZ6.mjs +0 -91
  1218. package/dist/collection-slugs-cache-CYMrqHZ6.mjs.map +0 -1
  1219. package/dist/comment-BGeXmJ8F.mjs +0 -335
  1220. package/dist/comment-BGeXmJ8F.mjs.map +0 -1
  1221. package/dist/comment-reaction-ty-JEDYR.mjs +0 -85
  1222. package/dist/comment-reaction-ty-JEDYR.mjs.map +0 -1
  1223. package/dist/comments-ByrrLvZL.mjs +0 -99
  1224. package/dist/comments-ByrrLvZL.mjs.map +0 -1
  1225. package/dist/comments-DqhARoef.mjs +0 -195
  1226. package/dist/comments-DqhARoef.mjs.map +0 -1
  1227. package/dist/components-u2HE5Mu9.mjs +0 -112
  1228. package/dist/components-u2HE5Mu9.mjs.map +0 -1
  1229. package/dist/config-B4F2ttAZ.d.mts +0 -7230
  1230. package/dist/config-B4F2ttAZ.d.mts.map +0 -1
  1231. package/dist/config-BnrtMvHW.mjs +0 -228
  1232. package/dist/config-BnrtMvHW.mjs.map +0 -1
  1233. package/dist/config-DEse9gaE.d.mts +0 -41
  1234. package/dist/config-DEse9gaE.d.mts.map +0 -1
  1235. package/dist/connection-BaIVuaDX.mjs +0 -36
  1236. package/dist/connection-BaIVuaDX.mjs.map +0 -1
  1237. package/dist/content-Dxztag5t.mjs +0 -2270
  1238. package/dist/content-Dxztag5t.mjs.map +0 -1
  1239. package/dist/content-list-query-yYbBU-dB.d.mts +0 -26
  1240. package/dist/content-list-query-yYbBU-dB.d.mts.map +0 -1
  1241. package/dist/content-repair-2PdahlgZ.mjs +0 -443
  1242. package/dist/content-repair-2PdahlgZ.mjs.map +0 -1
  1243. package/dist/content-save-KMll0S7E.mjs +0 -202
  1244. package/dist/content-save-KMll0S7E.mjs.map +0 -1
  1245. package/dist/context-C3OZjexd.mjs +0 -2225
  1246. package/dist/context-C3OZjexd.mjs.map +0 -1
  1247. package/dist/credits-C8uXoWfN.mjs +0 -110
  1248. package/dist/credits-C8uXoWfN.mjs.map +0 -1
  1249. package/dist/cron-CrjBjDuy.mjs +0 -310
  1250. package/dist/cron-CrjBjDuy.mjs.map +0 -1
  1251. package/dist/default-DPoN3H5H.mjs +0 -81
  1252. package/dist/default-DPoN3H5H.mjs.map +0 -1
  1253. package/dist/deferred-tasks-uSx5qCFn.d.mts +0 -10
  1254. package/dist/deferred-tasks-uSx5qCFn.d.mts.map +0 -1
  1255. package/dist/device-flow-hT8lKWXq.mjs +0 -519
  1256. package/dist/device-flow-hT8lKWXq.mjs.map +0 -1
  1257. package/dist/dialect-helpers-DqUMP9fJ.mjs +0 -350
  1258. package/dist/dialect-helpers-DqUMP9fJ.mjs.map +0 -1
  1259. package/dist/digest-xYRiuW_E.mjs +0 -194
  1260. package/dist/digest-xYRiuW_E.mjs.map +0 -1
  1261. package/dist/direct-executor-CZ2SH1bq.mjs +0 -117
  1262. package/dist/direct-executor-CZ2SH1bq.mjs.map +0 -1
  1263. package/dist/email-console-CochjAlh.mjs +0 -50
  1264. package/dist/email-console-CochjAlh.mjs.map +0 -1
  1265. package/dist/email-locale-BoxaIPG8.mjs +0 -25
  1266. package/dist/email-locale-BoxaIPG8.mjs.map +0 -1
  1267. package/dist/email-smtp-BnHR_Ccx.mjs +0 -643
  1268. package/dist/email-smtp-BnHR_Ccx.mjs.map +0 -1
  1269. package/dist/emdash-runtime-CXsdCQnM.mjs +0 -5262
  1270. package/dist/emdash-runtime-CXsdCQnM.mjs.map +0 -1
  1271. package/dist/enrich-BReo_COC.mjs +0 -203
  1272. package/dist/enrich-BReo_COC.mjs.map +0 -1
  1273. package/dist/entry-lock-BfnhlRhC.mjs +0 -207
  1274. package/dist/entry-lock-BfnhlRhC.mjs.map +0 -1
  1275. package/dist/entry-lock-DsVhZcJN.mjs +0 -1228
  1276. package/dist/entry-lock-DsVhZcJN.mjs.map +0 -1
  1277. package/dist/entry-locks-D_kjygT1.mjs +0 -173
  1278. package/dist/entry-locks-D_kjygT1.mjs.map +0 -1
  1279. package/dist/env-types-CXI9uaMU.mjs +0 -38
  1280. package/dist/env-types-CXI9uaMU.mjs.map +0 -1
  1281. package/dist/error-DcDNU7hZ.mjs +0 -92
  1282. package/dist/error-DcDNU7hZ.mjs.map +0 -1
  1283. package/dist/errors-CJ6711al.mjs +0 -120
  1284. package/dist/errors-CJ6711al.mjs.map +0 -1
  1285. package/dist/errors-CwYHYcWF.mjs +0 -502
  1286. package/dist/errors-CwYHYcWF.mjs.map +0 -1
  1287. package/dist/fence-C3MLClBo.mjs +0 -162
  1288. package/dist/fence-C3MLClBo.mjs.map +0 -1
  1289. package/dist/field-defs-cache-Cpk0eFsQ.mjs +0 -79
  1290. package/dist/field-defs-cache-Cpk0eFsQ.mjs.map +0 -1
  1291. package/dist/field-map-6o9hPcRl.mjs +0 -84
  1292. package/dist/field-map-6o9hPcRl.mjs.map +0 -1
  1293. package/dist/fts-manager-B3iLXCGz.mjs +0 -500
  1294. package/dist/fts-manager-B3iLXCGz.mjs.map +0 -1
  1295. package/dist/gc-D24C-KP7.mjs +0 -62
  1296. package/dist/gc-D24C-KP7.mjs.map +0 -1
  1297. package/dist/hook-result-BU5rI-6M.d.mts +0 -31
  1298. package/dist/hook-result-BU5rI-6M.d.mts.map +0 -1
  1299. package/dist/hook-result-CO4E3zDv.mjs +0 -3854
  1300. package/dist/hook-result-CO4E3zDv.mjs.map +0 -1
  1301. package/dist/hreflang-Bzvlo9Ci.mjs +0 -105
  1302. package/dist/hreflang-Bzvlo9Ci.mjs.map +0 -1
  1303. package/dist/hreflang-Ds0WbBOu.d.mts +0 -51
  1304. package/dist/hreflang-Ds0WbBOu.d.mts.map +0 -1
  1305. package/dist/http-route-dispatch-BsjkWBZF.mjs +0 -348
  1306. package/dist/http-route-dispatch-BsjkWBZF.mjs.map +0 -1
  1307. package/dist/identity-CahxkBZC.mjs +0 -35
  1308. package/dist/identity-CahxkBZC.mjs.map +0 -1
  1309. package/dist/index-BauU0yTw.d.mts +0 -261
  1310. package/dist/index-BauU0yTw.d.mts.map +0 -1
  1311. package/dist/install-finalization-CIl610wT.mjs +0 -58
  1312. package/dist/install-finalization-CIl610wT.mjs.map +0 -1
  1313. package/dist/json-recordset-CrS6ZqMk.mjs +0 -12
  1314. package/dist/json-recordset-CrS6ZqMk.mjs.map +0 -1
  1315. package/dist/json-schema-CBcJlGcY.mjs +0 -15
  1316. package/dist/json-schema-CBcJlGcY.mjs.map +0 -1
  1317. package/dist/keys-DJ62Wt5b.mjs +0 -61
  1318. package/dist/keys-DJ62Wt5b.mjs.map +0 -1
  1319. package/dist/kinds-D7_f3Qu3.mjs +0 -974
  1320. package/dist/kinds-D7_f3Qu3.mjs.map +0 -1
  1321. package/dist/lifecycle-DPCkpFHV.mjs +0 -49
  1322. package/dist/lifecycle-DPCkpFHV.mjs.map +0 -1
  1323. package/dist/limits-Bv6mXNM-.mjs +0 -44
  1324. package/dist/limits-Bv6mXNM-.mjs.map +0 -1
  1325. package/dist/load-r9P0fsRH.mjs +0 -36
  1326. package/dist/load-r9P0fsRH.mjs.map +0 -1
  1327. package/dist/loader-CSEfTKzr.mjs +0 -1537
  1328. package/dist/loader-CSEfTKzr.mjs.map +0 -1
  1329. package/dist/loops-BxzrcxPO.mjs +0 -217
  1330. package/dist/loops-BxzrcxPO.mjs.map +0 -1
  1331. package/dist/manifest-builder-BLWqITXR.mjs +0 -196
  1332. package/dist/manifest-builder-BLWqITXR.mjs.map +0 -1
  1333. package/dist/manifest-schema-BRpk5V7x.mjs +0 -497
  1334. package/dist/manifest-schema-BRpk5V7x.mjs.map +0 -1
  1335. package/dist/marketplace-5YFgYPVr.mjs +0 -257
  1336. package/dist/marketplace-5YFgYPVr.mjs.map +0 -1
  1337. package/dist/marketplace-zPVE4UY5.mjs +0 -965
  1338. package/dist/marketplace-zPVE4UY5.mjs.map +0 -1
  1339. package/dist/media-C5fg1Xte.d.mts +0 -203
  1340. package/dist/media-C5fg1Xte.d.mts.map +0 -1
  1341. package/dist/media-CPETKjop.mjs +0 -424
  1342. package/dist/media-CPETKjop.mjs.map +0 -1
  1343. package/dist/media-Cid3xIHk.mjs +0 -294
  1344. package/dist/media-Cid3xIHk.mjs.map +0 -1
  1345. package/dist/media-DJaAAYI2.mjs +0 -2805
  1346. package/dist/media-DJaAAYI2.mjs.map +0 -1
  1347. package/dist/media-allowlist-B7JwNf-U.mjs +0 -75
  1348. package/dist/media-allowlist-B7JwNf-U.mjs.map +0 -1
  1349. package/dist/media-folders-BI7B7XUM.mjs +0 -210
  1350. package/dist/media-folders-BI7B7XUM.mjs.map +0 -1
  1351. package/dist/media-url-xWuPVfqO.mjs +0 -43
  1352. package/dist/media-url-xWuPVfqO.mjs.map +0 -1
  1353. package/dist/media-usage-SwtWPxy4.mjs +0 -282
  1354. package/dist/media-usage-SwtWPxy4.mjs.map +0 -1
  1355. package/dist/media-usage-activation-BTa1H4wE.mjs +0 -78
  1356. package/dist/media-usage-activation-BTa1H4wE.mjs.map +0 -1
  1357. package/dist/media-usage-work-BxHWfbKq.mjs +0 -1036
  1358. package/dist/media-usage-work-BxHWfbKq.mjs.map +0 -1
  1359. package/dist/media-usage-work-DYenZS8y.mjs +0 -151
  1360. package/dist/media-usage-work-DYenZS8y.mjs.map +0 -1
  1361. package/dist/menu-FtSf33fF.mjs +0 -420
  1362. package/dist/menu-FtSf33fF.mjs.map +0 -1
  1363. package/dist/menus--MSfZ5Eu.mjs +0 -433
  1364. package/dist/menus--MSfZ5Eu.mjs.map +0 -1
  1365. package/dist/menus-C8h6Jtpu.mjs +0 -92
  1366. package/dist/menus-C8h6Jtpu.mjs.map +0 -1
  1367. package/dist/menus-CpFAi_LK.mjs +0 -434
  1368. package/dist/menus-CpFAi_LK.mjs.map +0 -1
  1369. package/dist/mime-Dx6aHTsR.mjs +0 -82
  1370. package/dist/mime-Dx6aHTsR.mjs.map +0 -1
  1371. package/dist/node-sqlite-compat-DvYkqx7Q.mjs +0 -63
  1372. package/dist/node-sqlite-compat-DvYkqx7Q.mjs.map +0 -1
  1373. package/dist/oauth-authorization-CBxtOboy.mjs +0 -287
  1374. package/dist/oauth-authorization-CBxtOboy.mjs.map +0 -1
  1375. package/dist/oauth-clients-HLGHmHqI.mjs +0 -266
  1376. package/dist/oauth-clients-HLGHmHqI.mjs.map +0 -1
  1377. package/dist/oauth-state-store-B4YAveSb.mjs +0 -80
  1378. package/dist/oauth-state-store-B4YAveSb.mjs.map +0 -1
  1379. package/dist/oauth-user-lookup-CTYMaKlq.mjs +0 -26
  1380. package/dist/oauth-user-lookup-CTYMaKlq.mjs.map +0 -1
  1381. package/dist/object-cache-DeATK4vw.mjs +0 -805
  1382. package/dist/object-cache-DeATK4vw.mjs.map +0 -1
  1383. package/dist/options-BJZMHnpx.d.mts +0 -81
  1384. package/dist/options-BJZMHnpx.d.mts.map +0 -1
  1385. package/dist/parse-B1E5cdyD.mjs +0 -82
  1386. package/dist/parse-B1E5cdyD.mjs.map +0 -1
  1387. package/dist/parse-Clt6wmpy.d.mts +0 -178
  1388. package/dist/parse-Clt6wmpy.d.mts.map +0 -1
  1389. package/dist/parts-CMwESQ6e.mjs +0 -68
  1390. package/dist/parts-CMwESQ6e.mjs.map +0 -1
  1391. package/dist/passkey-config-DiVZI-cx.mjs +0 -46
  1392. package/dist/passkey-config-DiVZI-cx.mjs.map +0 -1
  1393. package/dist/paths-NrYImb_h.mjs +0 -77
  1394. package/dist/paths-NrYImb_h.mjs.map +0 -1
  1395. package/dist/placeholder-B0vI-EQ9.d.mts +0 -316
  1396. package/dist/placeholder-B0vI-EQ9.d.mts.map +0 -1
  1397. package/dist/plan-CSb3BdFS.mjs +0 -135
  1398. package/dist/plan-CSb3BdFS.mjs.map +0 -1
  1399. package/dist/plugin-settings-HdYYRFi3.mjs +0 -162
  1400. package/dist/plugin-settings-HdYYRFi3.mjs.map +0 -1
  1401. package/dist/plugins-Bc70Xs37.mjs +0 -261
  1402. package/dist/plugins-Bc70Xs37.mjs.map +0 -1
  1403. package/dist/policy-C-ngDrxa.mjs +0 -56
  1404. package/dist/policy-C-ngDrxa.mjs.map +0 -1
  1405. package/dist/portable-text-T17rOqF7.mjs +0 -454
  1406. package/dist/portable-text-T17rOqF7.mjs.map +0 -1
  1407. package/dist/protocol-CmSX4cXv.d.mts +0 -65
  1408. package/dist/protocol-CmSX4cXv.d.mts.map +0 -1
  1409. package/dist/public-plugin-api-routes-_xsWTlwE.mjs +0 -316
  1410. package/dist/public-plugin-api-routes-_xsWTlwE.mjs.map +0 -1
  1411. package/dist/public-submission-ui3pFYtq.mjs +0 -253
  1412. package/dist/public-submission-ui3pFYtq.mjs.map +0 -1
  1413. package/dist/public-url-DMRZPAiW.mjs +0 -123
  1414. package/dist/public-url-DMRZPAiW.mjs.map +0 -1
  1415. package/dist/query-C1K9PzUc.mjs +0 -41
  1416. package/dist/query-C1K9PzUc.mjs.map +0 -1
  1417. package/dist/query-DdmHrvie.mjs +0 -1201
  1418. package/dist/query-DdmHrvie.mjs.map +0 -1
  1419. package/dist/range-BaF0521t.mjs +0 -51
  1420. package/dist/range-BaF0521t.mjs.map +0 -1
  1421. package/dist/rate-limit-6MngP0_m.mjs +0 -127
  1422. package/dist/rate-limit-6MngP0_m.mjs.map +0 -1
  1423. package/dist/receipt-BFm5eaN7.mjs +0 -43
  1424. package/dist/receipt-BFm5eaN7.mjs.map +0 -1
  1425. package/dist/redirect-ChcHI1KC.mjs +0 -466
  1426. package/dist/redirect-ChcHI1KC.mjs.map +0 -1
  1427. package/dist/redirect-EpidEf_5.mjs +0 -19
  1428. package/dist/redirect-EpidEf_5.mjs.map +0 -1
  1429. package/dist/redirect-paths-B9cXh9Wv.mjs +0 -36
  1430. package/dist/redirect-paths-B9cXh9Wv.mjs.map +0 -1
  1431. package/dist/redirects-D3zHoxhn.mjs +0 -446
  1432. package/dist/redirects-D3zHoxhn.mjs.map +0 -1
  1433. package/dist/redirects-dFPJ0HrD.mjs +0 -148
  1434. package/dist/redirects-dFPJ0HrD.mjs.map +0 -1
  1435. package/dist/registry-CDzYrAFY.mjs +0 -6074
  1436. package/dist/registry-CDzYrAFY.mjs.map +0 -1
  1437. package/dist/registry-Cf9vkVxW.mjs +0 -1449
  1438. package/dist/registry-Cf9vkVxW.mjs.map +0 -1
  1439. package/dist/registry-mZi_lxtT.mjs +0 -755
  1440. package/dist/registry-mZi_lxtT.mjs.map +0 -1
  1441. package/dist/relations-Eyop_U4o.mjs +0 -798
  1442. package/dist/relations-Eyop_U4o.mjs.map +0 -1
  1443. package/dist/request-meta-DsSkOdO0.mjs +0 -141
  1444. package/dist/request-meta-DsSkOdO0.mjs.map +0 -1
  1445. package/dist/resolve-s7ANHtFx.mjs +0 -92
  1446. package/dist/resolve-s7ANHtFx.mjs.map +0 -1
  1447. package/dist/revision-D7EedSdU.mjs +0 -503
  1448. package/dist/revision-D7EedSdU.mjs.map +0 -1
  1449. package/dist/rooms-CSNLTJsG.mjs +0 -331
  1450. package/dist/rooms-CSNLTJsG.mjs.map +0 -1
  1451. package/dist/rooms-CVsLla78.mjs +0 -169
  1452. package/dist/rooms-CVsLla78.mjs.map +0 -1
  1453. package/dist/rooms-CyXG83RZ.d.mts +0 -4653
  1454. package/dist/rooms-CyXG83RZ.d.mts.map +0 -1
  1455. package/dist/route-cache-CBpXPq-N.mjs +0 -30
  1456. package/dist/route-cache-CBpXPq-N.mjs.map +0 -1
  1457. package/dist/route-wire-DKSTaEz_.mjs +0 -197
  1458. package/dist/route-wire-DKSTaEz_.mjs.map +0 -1
  1459. package/dist/routes-QcHRiebw.mjs +0 -272
  1460. package/dist/routes-QcHRiebw.mjs.map +0 -1
  1461. package/dist/runner-4BfB04Rg.mjs +0 -6950
  1462. package/dist/runner-4BfB04Rg.mjs.map +0 -1
  1463. package/dist/runner-CAHS_KER.d.mts +0 -79
  1464. package/dist/runner-CAHS_KER.d.mts.map +0 -1
  1465. package/dist/runtime-holder-0g6pqbzx.mjs +0 -36
  1466. package/dist/runtime-holder-0g6pqbzx.mjs.map +0 -1
  1467. package/dist/scheduler-health-C5HEg2Yl.mjs +0 -31
  1468. package/dist/scheduler-health-C5HEg2Yl.mjs.map +0 -1
  1469. package/dist/schema-DS7ooMmp.mjs +0 -13
  1470. package/dist/schema-DS7ooMmp.mjs.map +0 -1
  1471. package/dist/schema-Mjtj7n1t.mjs +0 -815
  1472. package/dist/schema-Mjtj7n1t.mjs.map +0 -1
  1473. package/dist/scopes-BaR6WUyq.mjs +0 -34
  1474. package/dist/scopes-BaR6WUyq.mjs.map +0 -1
  1475. package/dist/search-B9RFgr0N.mjs +0 -450
  1476. package/dist/search-B9RFgr0N.mjs.map +0 -1
  1477. package/dist/secrets-C4UrjPiG.mjs +0 -369
  1478. package/dist/secrets-C4UrjPiG.mjs.map +0 -1
  1479. package/dist/sections-Bfa0oF8Q.mjs +0 -129
  1480. package/dist/sections-Bfa0oF8Q.mjs.map +0 -1
  1481. package/dist/sections-Bn2C6we7.mjs +0 -222
  1482. package/dist/sections-Bn2C6we7.mjs.map +0 -1
  1483. package/dist/seo-DPW6k5_-.mjs +0 -188
  1484. package/dist/seo-DPW6k5_-.mjs.map +0 -1
  1485. package/dist/service-B4mHMku9.mjs +0 -150
  1486. package/dist/service-B4mHMku9.mjs.map +0 -1
  1487. package/dist/session-user-CF2jNfj7.mjs +0 -61
  1488. package/dist/session-user-CF2jNfj7.mjs.map +0 -1
  1489. package/dist/settings-4r88LLIM.mjs +0 -66
  1490. package/dist/settings-4r88LLIM.mjs.map +0 -1
  1491. package/dist/settings-BB2xxz3Y.mjs +0 -74
  1492. package/dist/settings-BB2xxz3Y.mjs.map +0 -1
  1493. package/dist/settings-BTkGl-bX.mjs +0 -413
  1494. package/dist/settings-BTkGl-bX.mjs.map +0 -1
  1495. package/dist/settings-y8Jx8b7g.mjs +0 -157
  1496. package/dist/settings-y8Jx8b7g.mjs.map +0 -1
  1497. package/dist/setup-complete-BGRiC59t.mjs +0 -65
  1498. package/dist/setup-complete-BGRiC59t.mjs.map +0 -1
  1499. package/dist/setup-nonce-D43FsOgZ.mjs +0 -25
  1500. package/dist/setup-nonce-D43FsOgZ.mjs.map +0 -1
  1501. package/dist/site-domain-CFX7g6ik.mjs +0 -131
  1502. package/dist/site-domain-CFX7g6ik.mjs.map +0 -1
  1503. package/dist/site-settings-C0D9fv7e.mjs +0 -50
  1504. package/dist/site-settings-C0D9fv7e.mjs.map +0 -1
  1505. package/dist/site-title-C0JVN6en.mjs +0 -14
  1506. package/dist/site-title-C0JVN6en.mjs.map +0 -1
  1507. package/dist/site-url-DzVnHJ8j.mjs +0 -45
  1508. package/dist/site-url-DzVnHJ8j.mjs.map +0 -1
  1509. package/dist/sitemap-name-Ja_Cvwx9.mjs +0 -26
  1510. package/dist/sitemap-name-Ja_Cvwx9.mjs.map +0 -1
  1511. package/dist/slug-CO2jtUda.mjs +0 -16
  1512. package/dist/slug-CO2jtUda.mjs.map +0 -1
  1513. package/dist/snapshot-C9OWUtFr.mjs +0 -466
  1514. package/dist/snapshot-C9OWUtFr.mjs.map +0 -1
  1515. package/dist/snapshot-CR5tan8p.mjs +0 -184
  1516. package/dist/snapshot-CR5tan8p.mjs.map +0 -1
  1517. package/dist/ssrf-Lj1KZxYt.mjs +0 -406
  1518. package/dist/ssrf-Lj1KZxYt.mjs.map +0 -1
  1519. package/dist/stage-ChbGIslu.mjs +0 -662
  1520. package/dist/stage-ChbGIslu.mjs.map +0 -1
  1521. package/dist/staged-BN8pRZwX.mjs +0 -686
  1522. package/dist/staged-BN8pRZwX.mjs.map +0 -1
  1523. package/dist/state-DtcE0eN3.mjs +0 -178
  1524. package/dist/state-DtcE0eN3.mjs.map +0 -1
  1525. package/dist/storage-query-BDUX3Cef.d.mts +0 -1608
  1526. package/dist/storage-query-BDUX3Cef.d.mts.map +0 -1
  1527. package/dist/tar-CAvEHFbE.mjs +0 -449
  1528. package/dist/tar-CAvEHFbE.mjs.map +0 -1
  1529. package/dist/target-BM_6fT9m.mjs +0 -27
  1530. package/dist/target-BM_6fT9m.mjs.map +0 -1
  1531. package/dist/taxonomies-BMuFLd53.mjs +0 -722
  1532. package/dist/taxonomies-BMuFLd53.mjs.map +0 -1
  1533. package/dist/taxonomies-ClkYcmcH.mjs +0 -937
  1534. package/dist/taxonomies-ClkYcmcH.mjs.map +0 -1
  1535. package/dist/taxonomy-s1GcBCRo.mjs +0 -593
  1536. package/dist/taxonomy-s1GcBCRo.mjs.map +0 -1
  1537. package/dist/tokens-Cpm6FIKJ.mjs +0 -171
  1538. package/dist/tokens-Cpm6FIKJ.mjs.map +0 -1
  1539. package/dist/transaction-SKrr6u84.mjs +0 -44
  1540. package/dist/transaction-SKrr6u84.mjs.map +0 -1
  1541. package/dist/transfer-B3CsI5MG.mjs +0 -8963
  1542. package/dist/transfer-B3CsI5MG.mjs.map +0 -1
  1543. package/dist/transfer-DqUiK3ca.mjs +0 -166
  1544. package/dist/transfer-DqUiK3ca.mjs.map +0 -1
  1545. package/dist/transfer-download-CWPfhL91.mjs +0 -33
  1546. package/dist/transfer-download-CWPfhL91.mjs.map +0 -1
  1547. package/dist/transformations-ClH4dJeM.mjs +0 -196
  1548. package/dist/transformations-ClH4dJeM.mjs.map +0 -1
  1549. package/dist/transport-C6Ps8ejN.mjs +0 -144
  1550. package/dist/transport-C6Ps8ejN.mjs.map +0 -1
  1551. package/dist/transport-D4hWYmO_.d.mts +0 -42
  1552. package/dist/transport-D4hWYmO_.d.mts.map +0 -1
  1553. package/dist/trusted-proxy-CWX1sqgb.mjs +0 -51
  1554. package/dist/trusted-proxy-CWX1sqgb.mjs.map +0 -1
  1555. package/dist/turnstile-B6zM50Mh.mjs +0 -58
  1556. package/dist/turnstile-B6zM50Mh.mjs.map +0 -1
  1557. package/dist/types-Ba3bWb9D.mjs +0 -37
  1558. package/dist/types-Ba3bWb9D.mjs.map +0 -1
  1559. package/dist/types-C0M6z2A4.mjs +0 -16
  1560. package/dist/types-C0M6z2A4.mjs.map +0 -1
  1561. package/dist/types-CG1dR_Cm.d.mts +0 -934
  1562. package/dist/types-CG1dR_Cm.d.mts.map +0 -1
  1563. package/dist/types-CImd8MBY.d.mts +0 -1756
  1564. package/dist/types-CImd8MBY.d.mts.map +0 -1
  1565. package/dist/types-CML-oGr6.d.mts +0 -293
  1566. package/dist/types-CML-oGr6.d.mts.map +0 -1
  1567. package/dist/types-CZO9f_vJ.d.mts +0 -381
  1568. package/dist/types-CZO9f_vJ.d.mts.map +0 -1
  1569. package/dist/types-DLKviL1s.d.mts +0 -93
  1570. package/dist/types-DLKviL1s.d.mts.map +0 -1
  1571. package/dist/types-Df0R58Wu.mjs +0 -77
  1572. package/dist/types-Df0R58Wu.mjs.map +0 -1
  1573. package/dist/types-DwNwhyWP.d.mts +0 -227
  1574. package/dist/types-DwNwhyWP.d.mts.map +0 -1
  1575. package/dist/types-DwZgl0Zn.d.mts +0 -366
  1576. package/dist/types-DwZgl0Zn.d.mts.map +0 -1
  1577. package/dist/types-Dyb_OuSw.d.mts +0 -125
  1578. package/dist/types-Dyb_OuSw.d.mts.map +0 -1
  1579. package/dist/types-iOnPkHRk.d.mts +0 -209
  1580. package/dist/types-iOnPkHRk.d.mts.map +0 -1
  1581. package/dist/upload-attempts-5Ot7-vsw.mjs +0 -32
  1582. package/dist/upload-attempts-5Ot7-vsw.mjs.map +0 -1
  1583. package/dist/url-ZCjpMO-q.mjs +0 -74
  1584. package/dist/url-ZCjpMO-q.mjs.map +0 -1
  1585. package/dist/url-pattern-BQT-sGmD.mjs +0 -41
  1586. package/dist/url-pattern-BQT-sGmD.mjs.map +0 -1
  1587. package/dist/urls-Cq_hUk4P.mjs +0 -79
  1588. package/dist/urls-Cq_hUk4P.mjs.map +0 -1
  1589. package/dist/user-C4km6fox.mjs +0 -184
  1590. package/dist/user-C4km6fox.mjs.map +0 -1
  1591. package/dist/utils-Cpo0_V09.d.mts +0 -374
  1592. package/dist/utils-Cpo0_V09.d.mts.map +0 -1
  1593. package/dist/utils-DMDmdhU3.mjs +0 -450
  1594. package/dist/utils-DMDmdhU3.mjs.map +0 -1
  1595. package/dist/validate-BNupiQtz.mjs +0 -524
  1596. package/dist/validate-BNupiQtz.mjs.map +0 -1
  1597. package/dist/validate-DBfkJa3O.d.mts +0 -472
  1598. package/dist/validate-DBfkJa3O.d.mts.map +0 -1
  1599. package/dist/validation-W_efZFgP.mjs +0 -204
  1600. package/dist/validation-W_efZFgP.mjs.map +0 -1
  1601. package/dist/version-C61rw8-y.mjs +0 -9
  1602. package/dist/version-C61rw8-y.mjs.map +0 -1
  1603. package/dist/version-DhGLeLRo.mjs +0 -7
  1604. package/dist/version-DhGLeLRo.mjs.map +0 -1
  1605. package/dist/version-eqLBDtcz.mjs +0 -49
  1606. package/dist/version-eqLBDtcz.mjs.map +0 -1
  1607. package/dist/video-My3h7vwE.mjs +0 -18
  1608. package/dist/video-My3h7vwE.mjs.map +0 -1
  1609. package/dist/virtual-modules-BZKqvjRC.mjs +0 -568
  1610. package/dist/virtual-modules-BZKqvjRC.mjs.map +0 -1
  1611. package/dist/widgets-DAdni19y.mjs +0 -134
  1612. package/dist/widgets-DAdni19y.mjs.map +0 -1
  1613. package/dist/wxr-DDPJOgkM.mjs +0 -1054
  1614. package/dist/wxr-DDPJOgkM.mjs.map +0 -1
  1615. package/dist/wxr-taxonomies-B0U2fJgs.mjs +0 -735
  1616. package/dist/wxr-taxonomies-B0U2fJgs.mjs.map +0 -1
  1617. package/dist/wxr-taxonomies-CyP2k4-Q.d.mts +0 -34
  1618. package/dist/wxr-taxonomies-CyP2k4-Q.d.mts.map +0 -1
@@ -0,0 +1,2295 @@
1
+ import { m as __exportAll } from "./runner-Nv0yWP-G.mjs";
2
+ import { r as isMissingTableError } from "./db-errors-unnO6yiZ.mjs";
3
+ import { t as validateIdentifier } from "./validate-DANX1-Qi.mjs";
4
+ import { c as executeAtomicBatchIfSupported, u as isPostgres } from "./dialect-helpers-DRe1Y08G.mjs";
5
+ import { i as getLocaleCandidates } from "./config-Cs_AwWXI.mjs";
6
+ import { i as normalizeExplicitDatetime } from "./datetime-normalization-PeiEdcRY.mjs";
7
+ import { n as localeMatches, r as localeOrder, t as canonicalLocaleColumn } from "./query-EVjg8-Bq.mjs";
8
+ import { d as invalidateCollectionCache } from "./object-cache-I4Re7BOR.mjs";
9
+ import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-CvgCLYip.mjs";
10
+ import { notifyRoom } from "./rooms/notifications.mjs";
11
+ import { f as isIndexableFieldType, m as isStoragelessFieldRow } from "./types-BmBK2cqf.mjs";
12
+ import { n as slugify } from "./slugify-sxuydlHd.mjs";
13
+ import { a as InvalidCursorError, c as ScheduledNotDueError, i as EmDashValidationError, l as decodeCursor, n as ContentMutationConflictError, r as ContentSlugConflictError, t as ContentCollectionNotFoundError, u as encodeCursor } from "./types-BBH-w_KS.mjs";
14
+ import { a as ContentDatetimeNormalizer, i as startingRevisionId, n as createRevisionId, t as RevisionRepository } from "./revision-Dk9VI8Vf.mjs";
15
+ import { t as withTransaction } from "./transaction-D5Kq7MTL.mjs";
16
+ import { sql } from "kysely";
17
+ import { ulid } from "ulidx";
18
+
19
+ //#region src/content/known-fields.ts
20
+ /**
21
+ * Reconcile an entry's keys with the fields its collection currently declares.
22
+ *
23
+ * A draft revision stores the whole `data` as JSON, so deleting a field leaves the old
24
+ * value inside the revision. Every content-write surface needs the same two rules to keep
25
+ * that from stranding the entry, so they live here rather than in one caller.
26
+ */
27
+ /** Keys EmDash reserves (`_slug` and the like). No field declares them. */
28
+ function isReservedKey(key) {
29
+ return key.startsWith("_");
30
+ }
31
+ /**
32
+ * The entry data without the keys the collection has no field for.
33
+ *
34
+ * Reserved keys are kept.
35
+ */
36
+ function keepKnownFields(data, knownFieldSlugs) {
37
+ const result = {};
38
+ for (const [key, value] of Object.entries(data)) if (isReservedKey(key) || knownFieldSlugs.has(key)) result[key] = value;
39
+ return result;
40
+ }
41
+ /**
42
+ * Incoming keys with no matching field that the entry already stores.
43
+ *
44
+ * Dropping these lets a read-then-write save succeed after the field was deleted. A key the
45
+ * entry has never stored is not returned, so a genuinely unknown field is still reported.
46
+ */
47
+ function staleStoredKeys(data, stored, knownFieldSlugs) {
48
+ return Object.keys(data).filter((key) => !isReservedKey(key) && !knownFieldSlugs.has(key) && Object.hasOwn(stored, key));
49
+ }
50
+
51
+ //#endregion
52
+ //#region src/search/match.ts
53
+ /**
54
+ * FTS5 match-expression builder for structured (non-user-syntax) queries.
55
+ *
56
+ * Unlike `escapeQuery` in `query.ts` (which powers the public search API and
57
+ * deliberately passes through FTS5 operators like AND/OR/NOT), this builder
58
+ * treats the input as plain words: every term is double-quoted with interior
59
+ * quotes escaped, so the result can never produce an FTS5 syntax error. Used
60
+ * by the admin content-list filter, where the input is a filter box, not a
61
+ * search-syntax field.
62
+ */
63
+ const WHITESPACE_RE = /\s+/;
64
+ const DOUBLE_QUOTE_RE = /"/g;
65
+ const GLOB_SPECIAL_RE = /[[\]*?]/g;
66
+ /**
67
+ * Build a prefix-matching FTS5 MATCH expression from free-form input.
68
+ *
69
+ * `hello wor` becomes `"hello"* "wor"*` — implicit AND with per-term prefix
70
+ * matching. Returns `""` when the input contains no usable terms; callers
71
+ * must fall back to their non-FTS path in that case.
72
+ */
73
+ function buildFtsPrefixMatch(input) {
74
+ const terms = input.trim().split(WHITESPACE_RE).map((term) => term.replace(DOUBLE_QUOTE_RE, "\"\"")).filter((term) => term.length > 0);
75
+ if (terms.length === 0) return "";
76
+ return terms.map((term) => `"${term}"*`).join(" ");
77
+ }
78
+ /**
79
+ * Build a GLOB prefix pattern from free-form input, treating GLOB
80
+ * metacharacters (`* ? [ ]`) literally by wrapping each in a character
81
+ * class (GLOB has no ESCAPE clause).
82
+ *
83
+ * GLOB (unlike default LIKE) is case-sensitive, so with a lowercased
84
+ * pattern it matches slugs (lowercase by construction) while staying
85
+ * servable by the ordinary BINARY-collated slug index — SQLite's GLOB
86
+ * optimization turns a `prefix*` pattern into an index range scan.
87
+ */
88
+ function buildSlugGlobPrefix(input) {
89
+ return `${input.trim().toLowerCase().replace(GLOB_SPECIAL_RE, (c) => `[${c}]`)}*`;
90
+ }
91
+
92
+ //#endregion
93
+ //#region src/database/repositories/content.ts
94
+ var content_exports = /* @__PURE__ */ __exportAll({
95
+ ContentRepository: () => ContentRepository,
96
+ findNextScheduledAt: () => findNextScheduledAt,
97
+ findTypesWithDueContent: () => findTypesWithDueContent,
98
+ isConfirmedStatementFailure: () => isConfirmedStatementFailure,
99
+ isSystemOrderField: () => isSystemOrderField
100
+ });
101
+ const ULID_PATTERN = /^[0-9A-Z]{26}$/;
102
+ const SQLSTATE_PATTERN = /^[0-9A-Z]{5}$/;
103
+ const MAX_DRAFT_STAGE_ATTEMPTS = 32;
104
+ const LIKE_WILDCARD_RE = /[\\%_]/g;
105
+ const MAX_INDEXED_FIELD_FILTERS = 20;
106
+ const MAX_IN_FILTER_VALUES = SQL_BATCH_SIZE;
107
+ const MAX_FILTER_STRING_LENGTH = 2048;
108
+ function readyToPublishCondition(now) {
109
+ return sql`scheduled_at IS NOT NULL AND scheduled_at <= ${now} AND deleted_at IS NULL`;
110
+ }
111
+ function assertRevisionPrecondition(item, expected) {
112
+ if (expected && (item.version !== expected.version || item.updatedAt !== expected.updatedAt)) throw new ContentMutationConflictError();
113
+ }
114
+ /** The values outside a room's document that an update writes. */
115
+ function outsideValuesWritten(input) {
116
+ const outside = [];
117
+ if (input.authorId !== void 0) outside.push("author");
118
+ if (input.publishedAt !== void 0) outside.push("publishedAt");
119
+ return outside;
120
+ }
121
+ function nullableColumnMatch(column, value) {
122
+ validateIdentifier(column, "content column");
123
+ return value === null ? sql`${sql.ref(column)} IS NULL` : sql`${sql.ref(column)} = ${value}`;
124
+ }
125
+ function sameStoredValue(left, right) {
126
+ return Object.is(serializeValue(left), serializeValue(right));
127
+ }
128
+ function matchesPublication(observed, existing, revisionData, revisionId, slug, publishedAt, updatedAt) {
129
+ if (observed.version !== existing.version + 1 || observed.status !== "published" || observed.slug !== slug || observed.liveRevisionId !== revisionId || observed.draftRevisionId !== null || observed.scheduledAt !== null || observed.publishedAt !== publishedAt || observed.updatedAt !== updatedAt) return false;
130
+ return Object.entries(revisionData).every(([key, value]) => SYSTEM_COLUMNS.has(key) || key.startsWith("_") || sameStoredValue(observed.data[key], value));
131
+ }
132
+ function matchesLifecyclePublication(observed, existing, liveRevisionId, publishedAt, updatedAt) {
133
+ if (observed.version !== existing.version + 1 || observed.status !== "published" || observed.slug !== existing.slug || observed.liveRevisionId !== liveRevisionId || observed.draftRevisionId !== null || observed.scheduledAt !== null || observed.publishedAt !== publishedAt || observed.updatedAt !== updatedAt) return false;
134
+ return Object.entries(existing.data).every(([key, value]) => sameStoredValue(observed.data[key], value));
135
+ }
136
+ function matchesPublicationFence(observed, existing) {
137
+ return observed.version === existing.version && observed.status === existing.status && observed.liveRevisionId === existing.liveRevisionId && observed.draftRevisionId === existing.draftRevisionId && observed.scheduledAt === existing.scheduledAt;
138
+ }
139
+ function isConfirmedStatementFailure(error) {
140
+ if (typeof error !== "object" || error === null || !("code" in error)) return false;
141
+ const code = error.code;
142
+ return typeof code === "string" && (code === "ERR_SQLITE_ERROR" || code.startsWith("SQLITE_") || SQLSTATE_PATTERN.test(code));
143
+ }
144
+ function encodeNullableOrderCursor(field, value, id) {
145
+ const payload = {
146
+ version: 1,
147
+ field,
148
+ value
149
+ };
150
+ return encodeCursor(JSON.stringify(payload), id);
151
+ }
152
+ /**
153
+ * `acceptPlain` also accepts the plain `{ orderValue, id }` cursor that
154
+ * built-in and collection sort fields were paged with before, which wrote a
155
+ * NULL as "".
156
+ */
157
+ function decodeNullableOrderCursor(cursor, field, { acceptPlain = false } = {}) {
158
+ const { orderValue, id } = decodeCursor(cursor);
159
+ let payload;
160
+ try {
161
+ payload = JSON.parse(orderValue);
162
+ } catch {
163
+ payload = void 0;
164
+ }
165
+ if (payload === null || typeof payload !== "object") {
166
+ if (acceptPlain) return {
167
+ value: orderValue === "" ? null : orderValue,
168
+ id
169
+ };
170
+ throw new InvalidCursorError(cursor);
171
+ }
172
+ const candidate = payload;
173
+ const validValue = candidate.value === null || typeof candidate.value === "string" || typeof candidate.value === "number";
174
+ if (candidate.version !== 1 || candidate.field !== field || !validValue) throw new InvalidCursorError(cursor);
175
+ return {
176
+ value: candidate.value,
177
+ id
178
+ };
179
+ }
180
+ /**
181
+ * Keyset condition for the rows after (`value`, `cursorId`) in a sort by the
182
+ * nullable `column`, then `id`. The ORDER BY keeps each dialect's own NULL
183
+ * position, lowest on SQLite and highest on Postgres, so the condition follows
184
+ * it.
185
+ */
186
+ function nullableOrderCondition(db, column, direction, value, cursorId) {
187
+ const sort = sql.ref(column);
188
+ const id = sql.ref("id");
189
+ const cmp = direction === "ASC" ? sql.raw(">") : sql.raw("<");
190
+ const nullsFirst = direction === "ASC" !== isPostgres(db);
191
+ if (value === null) return nullsFirst ? sql`(${sort} IS NOT NULL OR ${id} ${cmp} ${cursorId})` : sql`(${sort} IS NULL AND ${id} ${cmp} ${cursorId})`;
192
+ const past = sql`(${sort}, ${id}) ${cmp} (${value}, ${cursorId})`;
193
+ return nullsFirst ? past : sql`(${past} OR ${sort} IS NULL)`;
194
+ }
195
+ /**
196
+ * Whitelist mapping a public date-filter field to its physical column. Keeping
197
+ * this separate from `mapOrderField` makes the filterable set explicit and
198
+ * prevents filtering on arbitrary columns.
199
+ */
200
+ const DATE_FILTER_COLUMNS = {
201
+ createdAt: "created_at",
202
+ updatedAt: "updated_at",
203
+ publishedAt: "published_at"
204
+ };
205
+ /**
206
+ * Built-in sort fields → their physical columns. A closed set that blocks
207
+ * sorting by arbitrary columns; per-collection fields are allowed
208
+ * separately via `mapOrderField`'s `sortableExtras`.
209
+ */
210
+ const ORDER_FIELD_COLUMNS = {
211
+ createdAt: "created_at",
212
+ updatedAt: "updated_at",
213
+ publishedAt: "published_at",
214
+ scheduledAt: "scheduled_at",
215
+ deletedAt: "deleted_at",
216
+ title: "title",
217
+ name: "name",
218
+ slug: "slug",
219
+ status: "status",
220
+ locale: "locale"
221
+ };
222
+ /**
223
+ * Order columns every row has a value for. Their cursors keep the plain
224
+ * `{ orderValue, id }` shape; a cursor for any other order column records a
225
+ * NULL explicitly.
226
+ */
227
+ const NON_NULL_ORDER_COLUMNS = new Set([
228
+ "created_at",
229
+ "updated_at",
230
+ "status",
231
+ "locale"
232
+ ]);
233
+ /** True when `field` maps to a system column and needs no per-collection resolution. */
234
+ function isSystemOrderField(field) {
235
+ return field in ORDER_FIELD_COLUMNS;
236
+ }
237
+ /**
238
+ * System columns that exist in every ec_* table
239
+ */
240
+ const SYSTEM_COLUMNS = new Set([
241
+ "id",
242
+ "slug",
243
+ "status",
244
+ "author_id",
245
+ "primary_byline_id",
246
+ "created_at",
247
+ "updated_at",
248
+ "published_at",
249
+ "scheduled_at",
250
+ "deleted_at",
251
+ "version",
252
+ "live_revision_id",
253
+ "draft_revision_id",
254
+ "locale",
255
+ "translation_group"
256
+ ]);
257
+ /**
258
+ * Get the table name for a collection type
259
+ */
260
+ function getTableName(type) {
261
+ validateIdentifier(type, "collection type");
262
+ return `ec_${type}`;
263
+ }
264
+ /**
265
+ * Which of `types` have at least one entry `findReadyToPublish` would return
266
+ * at `currentTime`, ignoring its cursor and limit.
267
+ *
268
+ * One statement per `SQL_BATCH_SIZE` collections, one column each: every column
269
+ * binds `now` once, and D1 caps both bound parameters and result columns at 100.
270
+ */
271
+ async function findTypesWithDueContent(db, types, currentTime) {
272
+ const now = currentTime.toISOString();
273
+ const due = /* @__PURE__ */ new Set();
274
+ for (const chunk of chunks(types, SQL_BATCH_SIZE)) {
275
+ const columns = chunk.map((type, index) => sql`CASE WHEN EXISTS (
276
+ SELECT 1 FROM ${sql.ref(getTableName(type))}
277
+ WHERE ${readyToPublishCondition(now)}
278
+ ) THEN 1 ELSE 0 END AS ${sql.ref(`due_${index}`)}`);
279
+ const row = (await sql`SELECT ${sql.join(columns)}`.execute(db)).rows[0];
280
+ if (!row) throw new Error("Due-content check returned no row");
281
+ for (const [index, type] of chunk.entries()) if (Number(row[`due_${index}`]) === 1) due.add(type);
282
+ }
283
+ return due;
284
+ }
285
+ /**
286
+ * Earliest `scheduled_at` across `types` that is after `after` and no later
287
+ * than `until`, or `null` when nothing is scheduled in that window.
288
+ */
289
+ async function findNextScheduledAt(db, types, after, until) {
290
+ const from = after.toISOString();
291
+ const to = until.toISOString();
292
+ let next = null;
293
+ for (const chunk of chunks(types, Math.floor(SQL_BATCH_SIZE / 2))) {
294
+ const columns = chunk.map((type, index) => sql`(
295
+ SELECT MIN(scheduled_at) FROM ${sql.ref(getTableName(type))}
296
+ WHERE scheduled_at > ${from} AND scheduled_at <= ${to} AND deleted_at IS NULL
297
+ ) AS ${sql.ref(`next_${index}`)}`);
298
+ const row = (await sql`SELECT ${sql.join(columns)}`.execute(db)).rows[0];
299
+ if (!row) throw new Error("Upcoming-content check returned no row");
300
+ for (const index of chunk.keys()) {
301
+ const value = row[`next_${index}`];
302
+ const scheduledAt = value instanceof Date ? value : typeof value === "string" ? new Date(value) : null;
303
+ if (!scheduledAt || Number.isNaN(scheduledAt.getTime())) continue;
304
+ if (!next || scheduledAt < next) next = scheduledAt;
305
+ }
306
+ }
307
+ return next;
308
+ }
309
+ function assertPageOffset(offset, cursor) {
310
+ if (offset === void 0) return;
311
+ if (cursor !== void 0) throw new EmDashValidationError("cursor and offset cannot be used together");
312
+ if (!Number.isSafeInteger(offset) || offset < 0) throw new EmDashValidationError("offset must be a non-negative integer");
313
+ }
314
+ /**
315
+ * Serialize a value for database storage
316
+ * Objects/arrays are JSON-stringified
317
+ * Booleans are converted to 0/1 for SQLite
318
+ */
319
+ function serializeValue(value) {
320
+ if (value === null || value === void 0) return null;
321
+ if (typeof value === "boolean") return value ? 1 : 0;
322
+ if (typeof value === "object") return JSON.stringify(value);
323
+ return value;
324
+ }
325
+ function writableContentData(data) {
326
+ const writable = {};
327
+ for (const [key, value] of Object.entries(data)) {
328
+ if (SYSTEM_COLUMNS.has(key)) continue;
329
+ validateIdentifier(key, "content field name");
330
+ writable[key] = value;
331
+ }
332
+ return writable;
333
+ }
334
+ /**
335
+ * Deserialize a value from database storage
336
+ * Attempts to parse JSON strings that look like objects/arrays
337
+ */
338
+ function deserializeValue(value) {
339
+ if (typeof value === "string") {
340
+ if (value.startsWith("{") || value.startsWith("[")) try {
341
+ return JSON.parse(value);
342
+ } catch {
343
+ return value;
344
+ }
345
+ }
346
+ return value;
347
+ }
348
+ /** Pattern for escaping special regex characters */
349
+ const REGEX_ESCAPE_PATTERN = /[.*+?^${}()|[\]\\]/g;
350
+ /**
351
+ * Escape special regex characters in a string for use in `new RegExp()`
352
+ */
353
+ function escapeRegExp(s) {
354
+ return s.replace(REGEX_ESCAPE_PATTERN, "\\$&");
355
+ }
356
+ /**
357
+ * Repository for content CRUD operations
358
+ *
359
+ * Content is stored in per-collection tables (ec_posts, ec_pages, etc.)
360
+ * Each field becomes a real column in the table.
361
+ */
362
+ var ContentRepository = class {
363
+ datetimes;
364
+ constructor(db, datetimeContexts) {
365
+ this.db = db;
366
+ this.datetimeContexts = datetimeContexts;
367
+ this.datetimes = new ContentDatetimeNormalizer(db, datetimeContexts);
368
+ }
369
+ async assertAliasAwareSlugAvailable(type, slug, locale, excludeId) {
370
+ if (!slug || !locale || getLocaleCandidates(locale).length <= 1) return;
371
+ const tableName = getTableName(type);
372
+ if ((await sql`
373
+ SELECT id FROM ${sql.ref(tableName)}
374
+ WHERE slug = ${slug}
375
+ AND ${localeMatches("locale", locale)}
376
+ ${excludeId === void 0 ? sql`` : sql`AND id <> ${excludeId}
377
+ AND coalesce((SELECT existing_row.slug FROM ${sql.ref(tableName)} AS existing_row WHERE existing_row.id = ${excludeId}), '') <> ${slug}`}
378
+ LIMIT 1
379
+ `.execute(this.db)).rows.length > 0) throw new ContentSlugConflictError();
380
+ }
381
+ /**
382
+ * Create a new content item
383
+ */
384
+ async create(input) {
385
+ const id = input.id ?? ulid();
386
+ const now = (/* @__PURE__ */ new Date()).toISOString();
387
+ const { type, slug, data: inputData, status = "draft", authorId, primaryBylineId, locale, translationOf, inheritFields = [], publishedAt, createdAt } = input;
388
+ const data = await this.datetimes.normalizeInput(type, inputData);
389
+ const normalizedCreatedAt = createdAt ? await this.datetimes.normalizeValue(type, createdAt) : now;
390
+ const normalizedPublishedAt = publishedAt ? await this.datetimes.normalizeValue(type, publishedAt) : null;
391
+ if (!type) throw new EmDashValidationError("Content type is required");
392
+ const tableName = getTableName(type);
393
+ if (translationOf && getLocaleCandidates(locale ?? "en").length > 1) {
394
+ if ((await sql`
395
+ SELECT sibling.id FROM ${sql.ref(tableName)} AS sibling
396
+ INNER JOIN ${sql.ref(tableName)} AS source
397
+ ON coalesce(source.translation_group, source.id) = sibling.translation_group
398
+ WHERE source.id = ${translationOf} AND source.deleted_at IS NULL
399
+ AND sibling.deleted_at IS NULL AND ${localeMatches("sibling.locale", locale ?? "en")}
400
+ LIMIT 1
401
+ `.execute(this.db)).rows.length > 0) throw new ContentMutationConflictError(`Translation already exists in locale "${locale ?? "en"}" for this content item`);
402
+ }
403
+ await this.assertAliasAwareSlugAvailable(type, slug, locale);
404
+ const columns = [
405
+ "id",
406
+ "slug",
407
+ "status",
408
+ "author_id",
409
+ "primary_byline_id",
410
+ "created_at",
411
+ "updated_at",
412
+ "published_at",
413
+ "version",
414
+ "locale",
415
+ "translation_group"
416
+ ];
417
+ const values = [
418
+ id,
419
+ slug || null,
420
+ status,
421
+ authorId || null,
422
+ primaryBylineId ?? null,
423
+ normalizedCreatedAt,
424
+ now,
425
+ normalizedPublishedAt,
426
+ 1,
427
+ locale || "en",
428
+ id
429
+ ];
430
+ const inherited = new Set(inheritFields);
431
+ for (const field of inherited) {
432
+ validateIdentifier(field, "inherited content field name");
433
+ if (!SYSTEM_COLUMNS.has(field) && !Object.hasOwn(data, field)) {
434
+ columns.push(field);
435
+ values.push(null);
436
+ }
437
+ }
438
+ if (data && typeof data === "object") {
439
+ for (const [key, value] of Object.entries(data)) if (!SYSTEM_COLUMNS.has(key)) {
440
+ validateIdentifier(key, "content field name");
441
+ columns.push(key);
442
+ values.push(serializeValue(value));
443
+ }
444
+ }
445
+ const columnRefs = columns.map((c) => sql.ref(c));
446
+ const valuePlaceholders = values.map((value, index) => {
447
+ const column = columns[index];
448
+ if (translationOf && column === "translation_group") return sql`COALESCE(${sql.ref("translation_source.translation_group")}, ${sql.ref("translation_source.id")})`;
449
+ if (translationOf && inherited.has(column)) return sql.ref(`translation_source.${column}`);
450
+ return value === null ? sql`NULL` : sql`${value}`;
451
+ });
452
+ if (translationOf) await sql`
453
+ INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
454
+ SELECT ${sql.join(valuePlaceholders, sql`, `)}
455
+ FROM ${sql.ref(tableName)} AS translation_source
456
+ WHERE translation_source.id = ${translationOf}
457
+ AND translation_source.deleted_at IS NULL
458
+ `.execute(this.db);
459
+ else await sql`
460
+ INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
461
+ VALUES (${sql.join(valuePlaceholders, sql`, `)})
462
+ `.execute(this.db);
463
+ invalidateCollectionCache(type);
464
+ const item = await this.findById(type, id);
465
+ if (!item) {
466
+ if (translationOf) throw new EmDashValidationError("Translation source content not found");
467
+ throw new Error("Failed to create content");
468
+ }
469
+ return item;
470
+ }
471
+ /**
472
+ * Generate a unique slug for a content item within a collection.
473
+ *
474
+ * Checks the collection table for existing slugs that match `baseSlug`
475
+ * (optionally scoped to a locale) and appends a numeric suffix (`-1`,
476
+ * `-2`, etc.) on collision to guarantee uniqueness.
477
+ *
478
+ * Returns null when slug normalization cannot produce a value.
479
+ */
480
+ async generateUniqueSlug(type, text, locale) {
481
+ const baseSlug = slugify(text);
482
+ if (!baseSlug) return null;
483
+ const tableName = getTableName(type);
484
+ if ((locale ? await sql`
485
+ SELECT slug FROM ${sql.ref(tableName)}
486
+ WHERE slug = ${baseSlug}
487
+ AND ${localeMatches("locale", locale)}
488
+ LIMIT 1
489
+ `.execute(this.db) : await sql`
490
+ SELECT slug FROM ${sql.ref(tableName)}
491
+ WHERE slug = ${baseSlug}
492
+ LIMIT 1
493
+ `.execute(this.db)).rows.length === 0) return baseSlug;
494
+ const prefix = `${baseSlug}-`;
495
+ const candidates = locale ? await sql`
496
+ SELECT slug FROM ${sql.ref(tableName)}
497
+ WHERE (slug = ${baseSlug} OR substr(slug, 1, length(${prefix})) = ${prefix})
498
+ AND ${localeMatches("locale", locale)}
499
+ `.execute(this.db) : await sql`
500
+ SELECT slug FROM ${sql.ref(tableName)}
501
+ WHERE slug = ${baseSlug} OR substr(slug, 1, length(${prefix})) = ${prefix}
502
+ `.execute(this.db);
503
+ let maxSuffix = 0;
504
+ const suffixPattern = new RegExp(`^${escapeRegExp(baseSlug)}-(\\d+)$`);
505
+ for (const row of candidates.rows) {
506
+ const match = suffixPattern.exec(row.slug);
507
+ if (match) {
508
+ const n = parseInt(match[1], 10);
509
+ if (n > maxSuffix) maxSuffix = n;
510
+ }
511
+ }
512
+ return `${baseSlug}-${maxSuffix + 1}`;
513
+ }
514
+ /**
515
+ * Duplicate a content item
516
+ * Creates a new draft copy with "(Copy)" appended to the title.
517
+ * A slug is auto-generated from the new title by the handler layer.
518
+ */
519
+ async duplicate(type, id, authorId) {
520
+ const original = await this.findById(type, id);
521
+ if (!original) throw new EmDashValidationError("Content item not found");
522
+ const newData = { ...original.data };
523
+ if (typeof newData.title === "string") newData.title = `${newData.title} (Copy)`;
524
+ else if (typeof newData.name === "string") newData.name = `${newData.name} (Copy)`;
525
+ const slugSource = typeof newData.title === "string" ? newData.title : typeof newData.name === "string" ? newData.name : null;
526
+ const slug = slugSource ? await this.generateUniqueSlug(type, slugSource, original.locale ?? void 0) : null;
527
+ return this.create({
528
+ type,
529
+ slug,
530
+ data: newData,
531
+ status: "draft",
532
+ authorId: authorId || original.authorId || void 0,
533
+ locale: original.locale ?? void 0
534
+ });
535
+ }
536
+ /**
537
+ * Find content by ID
538
+ */
539
+ async findById(type, id) {
540
+ const tableName = getTableName(type);
541
+ const row = (await sql`
542
+ SELECT * FROM ${sql.ref(tableName)}
543
+ WHERE id = ${id}
544
+ AND deleted_at IS NULL
545
+ `.execute(this.db)).rows[0];
546
+ if (!row) return null;
547
+ return this.mapRow(type, row);
548
+ }
549
+ async findManyByIds(type, ids, options = {}) {
550
+ const items = /* @__PURE__ */ new Map();
551
+ if (ids.length === 0) return items;
552
+ const tableName = getTableName(type);
553
+ const deletedFilter = options.includeTrashed ? sql`` : sql`AND deleted_at IS NULL`;
554
+ for (const batch of chunks([...new Set(ids)], SQL_BATCH_SIZE)) {
555
+ const result = await sql`
556
+ SELECT * FROM ${sql.ref(tableName)}
557
+ WHERE id IN (${sql.join(batch)}) ${deletedFilter}
558
+ `.execute(this.db);
559
+ for (const row of result.rows) {
560
+ const item = this.mapRow(type, row);
561
+ items.set(item.id, item);
562
+ }
563
+ }
564
+ return items;
565
+ }
566
+ async findManyBySlugsInLocale(type, slugs, locale, options = {}) {
567
+ const items = /* @__PURE__ */ new Map();
568
+ if (slugs.length === 0) return items;
569
+ const tableName = getTableName(type);
570
+ const deletedFilter = options.includeTrashed ? sql`` : sql`AND deleted_at IS NULL`;
571
+ const statusFilter = options.publishedOnly ? sql`AND status = ${"published"}` : sql``;
572
+ for (const batch of chunks([...new Set(slugs)], SQL_BATCH_SIZE)) {
573
+ const result = await sql`
574
+ SELECT * FROM ${sql.ref(tableName)}
575
+ WHERE slug IN (${sql.join(batch)}) AND ${localeMatches("locale", locale)} ${deletedFilter} ${statusFilter}
576
+ ORDER BY ${localeOrder("locale", locale)}, id ASC
577
+ `.execute(this.db);
578
+ for (const row of result.rows) {
579
+ const item = this.mapRow(type, row);
580
+ if (item.slug !== null && !items.has(item.slug)) items.set(item.slug, item);
581
+ }
582
+ }
583
+ return items;
584
+ }
585
+ /**
586
+ * Find content by id, including trashed (soft-deleted) items.
587
+ * Used by restore endpoint for ownership checks.
588
+ *
589
+ * `deletedAt` rides along because the row is already in hand: a caller that
590
+ * has to know whether the row is trashed before touching anything else would
591
+ * otherwise pay a second read for a column this row already carries.
592
+ */
593
+ async findByIdIncludingTrashed(type, id) {
594
+ const tableName = getTableName(type);
595
+ const row = (await sql`
596
+ SELECT * FROM ${sql.ref(tableName)}
597
+ WHERE id = ${id}
598
+ `.execute(this.db)).rows[0];
599
+ if (!row) return null;
600
+ return {
601
+ ...this.mapRow(type, row),
602
+ deletedAt: typeof row.deleted_at === "string" ? row.deleted_at : null
603
+ };
604
+ }
605
+ /**
606
+ * Find content by ID or slug. Tries ID first if it looks like a ULID,
607
+ * otherwise tries slug. Falls back to the other if the first lookup misses.
608
+ */
609
+ async findByIdOrSlug(type, identifier, locale) {
610
+ return this._findByIdOrSlug(type, identifier, false, locale);
611
+ }
612
+ /**
613
+ * Find content by ID or slug, including trashed (soft-deleted) items.
614
+ * Used by restore/permanent-delete endpoints.
615
+ */
616
+ async findByIdOrSlugIncludingTrashed(type, identifier, locale) {
617
+ return this._findByIdOrSlug(type, identifier, true, locale);
618
+ }
619
+ async isTrashed(type, id) {
620
+ const tableName = getTableName(type);
621
+ return await this.db.selectFrom(tableName).select("id").where("id", "=", id).where("deleted_at", "is not", null).executeTakeFirst() !== void 0;
622
+ }
623
+ async _findByIdOrSlug(type, identifier, includeTrashed, locale) {
624
+ const looksLikeUlid = ULID_PATTERN.test(identifier);
625
+ const findById = includeTrashed ? (t, id) => this.findByIdIncludingTrashed(t, id) : (t, id) => this.findById(t, id);
626
+ const findBySlug = includeTrashed ? (t, s) => this.findBySlugIncludingTrashed(t, s, locale) : (t, s) => this.findBySlug(t, s, locale);
627
+ try {
628
+ if (looksLikeUlid) {
629
+ const byId = await findById(type, identifier);
630
+ if (byId) return byId;
631
+ return await findBySlug(type, identifier);
632
+ }
633
+ const bySlug = await findBySlug(type, identifier);
634
+ if (bySlug) return bySlug;
635
+ return await findById(type, identifier);
636
+ } catch (error) {
637
+ if (isMissingTableError(error)) return null;
638
+ throw error;
639
+ }
640
+ }
641
+ /**
642
+ * Find content by slug
643
+ */
644
+ async findBySlug(type, slug, locale) {
645
+ const tableName = getTableName(type);
646
+ const row = (locale ? await sql`
647
+ SELECT * FROM ${sql.ref(tableName)}
648
+ WHERE slug = ${slug}
649
+ AND ${localeMatches("locale", locale)}
650
+ AND deleted_at IS NULL
651
+ ORDER BY ${localeOrder("locale", locale)}, id ASC
652
+ `.execute(this.db) : await sql`
653
+ SELECT * FROM ${sql.ref(tableName)}
654
+ WHERE slug = ${slug}
655
+ AND deleted_at IS NULL
656
+ ORDER BY locale ASC
657
+ LIMIT 1
658
+ `.execute(this.db)).rows[0];
659
+ if (!row) return null;
660
+ return this.mapRow(type, row);
661
+ }
662
+ /**
663
+ * Find content by slug, including trashed (soft-deleted) items.
664
+ * Used by restore/permanent-delete endpoints.
665
+ */
666
+ async findBySlugIncludingTrashed(type, slug, locale) {
667
+ const tableName = getTableName(type);
668
+ const row = (locale ? await sql`
669
+ SELECT * FROM ${sql.ref(tableName)}
670
+ WHERE slug = ${slug}
671
+ AND ${localeMatches("locale", locale)}
672
+ ORDER BY ${localeOrder("locale", locale)}, id ASC
673
+ `.execute(this.db) : await sql`
674
+ SELECT * FROM ${sql.ref(tableName)}
675
+ WHERE slug = ${slug}
676
+ ORDER BY locale ASC
677
+ LIMIT 1
678
+ `.execute(this.db)).rows[0];
679
+ if (!row) return null;
680
+ return this.mapRow(type, row);
681
+ }
682
+ /**
683
+ * Find many content items with filtering and pagination
684
+ */
685
+ async findMany(type, options = {}) {
686
+ const tableName = getTableName(type);
687
+ const limit = Math.max(1, Math.min(options.limit || 50, 100));
688
+ assertPageOffset(options.offset, options.cursor);
689
+ const orderField = options.orderBy?.field || "createdAt";
690
+ const orderDirection = options.orderBy?.direction || "desc";
691
+ const resolvedOrderField = await this.resolveOrderField(type, orderField, options.sortableExtras);
692
+ const dbField = resolvedOrderField.column;
693
+ const nullableOrder = resolvedOrderField.indexedCustomField || !NON_NULL_ORDER_COLUMNS.has(dbField);
694
+ const resolvedFieldFilters = await this.resolveFieldFilters(type, options.where?.fieldFilters);
695
+ const safeOrderDirection = orderDirection.toLowerCase() === "asc" ? "ASC" : "DESC";
696
+ let query = this.db.selectFrom(tableName).selectAll().where("deleted_at", "is", null);
697
+ if (options.where?.status) query = query.where("status", "=", options.where.status);
698
+ if (options.where?.authorId) query = query.where("author_id", "=", options.where.authorId);
699
+ if (options.where?.locale) query = query.where(localeMatches("locale", options.where.locale));
700
+ query = this.applySearchFilter(query, options.where, type);
701
+ query = this.applyDateFilter(query, options.where);
702
+ query = this.applyBylineFilter(query, options.where, type);
703
+ query = this.applyFieldFilters(query, resolvedFieldFilters);
704
+ if (options.cursor) if (resolvedOrderField.indexedCustomField) {
705
+ const { value, id: cursorId } = decodeNullableOrderCursor(options.cursor, orderField);
706
+ const isPresent = sql`${sql.ref(dbField)} IS NOT NULL`;
707
+ const falseLiteral = sql`FALSE`;
708
+ const trueLiteral = sql`TRUE`;
709
+ if (safeOrderDirection === "ASC" && value === null) query = query.where(sql`(
710
+ (${isPresent}) > ${falseLiteral}
711
+ OR ((${isPresent}) = ${falseLiteral} AND ${sql.ref("id")} > ${cursorId})
712
+ )`);
713
+ else if (safeOrderDirection === "DESC" && value === null) query = query.where(sql`
714
+ (${isPresent}) = ${falseLiteral} AND ${sql.ref("id")} < ${cursorId}
715
+ `);
716
+ else if (safeOrderDirection === "ASC") query = query.where(sql`
717
+ (${isPresent}, ${sql.ref(dbField)}, ${sql.ref("id")})
718
+ > (${trueLiteral}, ${value}, ${cursorId})
719
+ `);
720
+ else query = query.where(sql`
721
+ (${isPresent}, ${sql.ref(dbField)}, ${sql.ref("id")})
722
+ < (${trueLiteral}, ${value}, ${cursorId})
723
+ `);
724
+ } else if (nullableOrder) {
725
+ const { value, id: cursorId } = decodeNullableOrderCursor(options.cursor, orderField, { acceptPlain: true });
726
+ query = query.where(nullableOrderCondition(this.db, dbField, safeOrderDirection, value, cursorId));
727
+ } else {
728
+ const { orderValue, id: cursorId } = decodeCursor(options.cursor);
729
+ if (safeOrderDirection === "DESC") query = query.where((eb) => eb.or([eb(dbField, "<", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", "<", cursorId)])]));
730
+ else query = query.where((eb) => eb.or([eb(dbField, ">", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", ">", cursorId)])]));
731
+ }
732
+ const indexedOrderFilter = resolvedOrderField.indexedCustomField ? resolvedFieldFilters.find((filter) => filter.column === dbField) : void 0;
733
+ if (resolvedOrderField.indexedCustomField && !indexedOrderFilter) query = query.orderBy(sql`${sql.ref(dbField)} IS NOT NULL`, safeOrderDirection === "ASC" ? "asc" : "desc");
734
+ if (indexedOrderFilter?.kind !== "null") query = query.orderBy(dbField, safeOrderDirection === "ASC" ? "asc" : "desc");
735
+ query = query.orderBy("id", safeOrderDirection === "ASC" ? "asc" : "desc");
736
+ query = options.offset === void 0 ? query.limit(limit + 1) : query.limit(limit).offset(options.offset);
737
+ const [rowsResult, countResult] = await Promise.allSettled([query.execute(), this.countWithResolvedFilters(type, options.where, resolvedFieldFilters)]);
738
+ if (rowsResult.status === "rejected") throw rowsResult.reason;
739
+ if (countResult.status === "rejected") throw countResult.reason;
740
+ const rows = rowsResult.value;
741
+ const total = countResult.value;
742
+ const hasMore = rows.length > limit;
743
+ const items = rows.slice(0, limit);
744
+ const mappedResult = {
745
+ items: items.map((row) => this.mapRow(type, row)),
746
+ total
747
+ };
748
+ if (hasMore && items.length > 0) {
749
+ const lastRow = items.at(-1);
750
+ const lastOrderValue = lastRow[dbField];
751
+ if (nullableOrder) {
752
+ if (lastOrderValue !== null && typeof lastOrderValue !== "string" && typeof lastOrderValue !== "number") throw new EmDashValidationError(`Invalid value for order field: ${orderField}`);
753
+ mappedResult.nextCursor = encodeNullableOrderCursor(orderField, lastOrderValue, String(lastRow.id));
754
+ } else mappedResult.nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
755
+ }
756
+ return mappedResult;
757
+ }
758
+ /**
759
+ * Update content
760
+ */
761
+ async update(type, id, input, expectedRevision) {
762
+ const tableName = getTableName(type);
763
+ const now = (/* @__PURE__ */ new Date()).toISOString();
764
+ await this.assertAliasAwareSlugAvailable(type, input.slug, input.locale, id);
765
+ const updates = {};
766
+ if (input.status !== void 0) updates.status = input.status;
767
+ if (input.slug !== void 0) updates.slug = input.slug;
768
+ if (input.publishedAt !== void 0) updates.published_at = input.publishedAt === null ? null : await this.datetimes.normalizeValue(type, input.publishedAt);
769
+ if (input.scheduledAt !== void 0) updates.scheduled_at = input.scheduledAt === null ? null : await this.datetimes.normalizeValue(type, input.scheduledAt);
770
+ if (input.authorId !== void 0) updates.author_id = input.authorId;
771
+ if (input.primaryBylineId !== void 0) updates.primary_byline_id = input.primaryBylineId;
772
+ if (input.data !== void 0 && typeof input.data === "object") {
773
+ const data = await this.datetimes.normalizeInput(type, writableContentData(input.data));
774
+ for (const [key, value] of Object.entries(data)) updates[key] = serializeValue(value);
775
+ }
776
+ const hasColumnWrites = Object.keys(updates).length > 0;
777
+ if (hasColumnWrites) updates.updated_at = now;
778
+ if (input.draftRevisionId === null) updates.draft_revision_id = null;
779
+ updates.version = sql`version + 1`;
780
+ let query = this.db.updateTable(tableName).set(updates).where("id", "=", id).where("deleted_at", "is", null);
781
+ if (expectedRevision) query = query.where(sql`version = ${expectedRevision.version}`).where(sql`updated_at = ${expectedRevision.updatedAt}`);
782
+ const result = await query.executeTakeFirst();
783
+ if (expectedRevision && result.numUpdatedRows === 0n) throw new ContentMutationConflictError();
784
+ if (hasColumnWrites) invalidateCollectionCache(type);
785
+ if (result.numUpdatedRows > 0n) notifyRoom({
786
+ collection: type,
787
+ id
788
+ }, outsideValuesWritten(input));
789
+ const updated = await this.findById(type, id);
790
+ if (!updated) throw new Error("Content not found");
791
+ return updated;
792
+ }
793
+ async restoreRevision(type, id, revisionData, authorId) {
794
+ const tableName = getTableName(type);
795
+ const existing = await this.findById(type, id);
796
+ if (!existing) throw new EmDashValidationError("Content item not found");
797
+ const normalizedSnapshot = await this.datetimes.normalizeData(type, revisionData);
798
+ const { _slug } = normalizedSnapshot;
799
+ const snapshotFields = {};
800
+ for (const [key, value] of Object.entries(normalizedSnapshot)) if (!key.startsWith("_")) snapshotFields[key] = value;
801
+ const fieldData = writableContentData(snapshotFields);
802
+ const revisionId = createRevisionId();
803
+ const now = (/* @__PURE__ */ new Date()).toISOString();
804
+ const assignments = [];
805
+ if (typeof _slug === "string") assignments.push(sql`slug = ${_slug}`);
806
+ for (const [field, value] of Object.entries(fieldData)) {
807
+ validateIdentifier(field, "content field name");
808
+ assignments.push(sql`${sql.ref(field)} = ${serializeValue(value)}`);
809
+ }
810
+ assignments.push(sql`draft_revision_id = ${revisionId}`, sql`updated_at = ${now}`, sql`version = version + 1`);
811
+ const buildQueries = () => {
812
+ return [
813
+ sql`
814
+ INSERT INTO revisions (id, collection, entry_id, data, author_id)
815
+ VALUES (${revisionId}, ${type}, ${id}, ${JSON.stringify(normalizedSnapshot)}, ${authorId})
816
+ RETURNING id
817
+ `,
818
+ sql`
819
+ UPDATE ${sql.ref(tableName)}
820
+ SET ${sql.join(assignments, sql`, `)}
821
+ WHERE id = ${id}
822
+ AND deleted_at IS NULL
823
+ AND version = ${existing.version}
824
+ AND updated_at = ${existing.updatedAt}
825
+ AND status = ${existing.status}
826
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
827
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
828
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
829
+ RETURNING id
830
+ `,
831
+ sql`
832
+ DELETE FROM revisions
833
+ WHERE id = ${revisionId}
834
+ AND NOT EXISTS (
835
+ SELECT 1 FROM ${sql.ref(tableName)}
836
+ WHERE id = ${id}
837
+ AND draft_revision_id = ${revisionId}
838
+ AND version = ${existing.version + 1}
839
+ )
840
+ `,
841
+ sql`
842
+ UPDATE ${sql.ref(tableName)}
843
+ SET draft_revision_id = ${existing.draftRevisionId}
844
+ WHERE id = ${id}
845
+ AND draft_revision_id = ${revisionId}
846
+ AND version = ${existing.version + 1}
847
+ RETURNING id
848
+ `
849
+ ];
850
+ };
851
+ const batched = await executeAtomicBatchIfSupported(this.db, buildQueries());
852
+ if (batched) {
853
+ if (batched[0]?.rows.length !== 1 || batched[1]?.rows.length !== 1 || batched[3]?.rows.length !== 1) throw new ContentMutationConflictError();
854
+ } else await withTransaction(this.db, async (trx) => {
855
+ const [audit, update, removeUnappliedAudit, releaseMarker] = buildQueries();
856
+ if ((await audit.execute(trx)).rows.length !== 1) throw new ContentMutationConflictError();
857
+ const updateResult = await update.execute(trx);
858
+ await removeUnappliedAudit.execute(trx);
859
+ const releaseResult = await releaseMarker.execute(trx);
860
+ if (updateResult.rows.length !== 1 || releaseResult.rows.length !== 1) throw new ContentMutationConflictError();
861
+ });
862
+ invalidateCollectionCache(type);
863
+ notifyRoom({
864
+ collection: type,
865
+ id
866
+ });
867
+ const item = await this.findById(type, id);
868
+ if (!item) throw new Error("Content not found");
869
+ await new RevisionRepository(this.db, this.datetimeContexts).queuePruning(type, id, revisionId);
870
+ return {
871
+ item,
872
+ revisionId
873
+ };
874
+ }
875
+ async restoreDraftRevision(type, id, revisionData, authorId) {
876
+ const tableName = getTableName(type);
877
+ const existing = await this.findById(type, id);
878
+ if (!existing) return null;
879
+ const normalizedSnapshot = await this.datetimes.normalizeData(type, revisionData);
880
+ const revisionId = createRevisionId();
881
+ const buildQueries = () => {
882
+ return [
883
+ sql`
884
+ INSERT INTO revisions (id, collection, entry_id, data, author_id)
885
+ VALUES (${revisionId}, ${type}, ${id}, ${JSON.stringify(normalizedSnapshot)}, ${authorId})
886
+ RETURNING id
887
+ `,
888
+ sql`
889
+ UPDATE ${sql.ref(tableName)}
890
+ SET draft_revision_id = ${revisionId},
891
+ version = version + 1
892
+ WHERE id = ${id}
893
+ AND deleted_at IS NULL
894
+ AND version = ${existing.version}
895
+ AND updated_at = ${existing.updatedAt}
896
+ AND status = ${existing.status}
897
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
898
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
899
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
900
+ RETURNING id
901
+ `,
902
+ sql`
903
+ DELETE FROM revisions
904
+ WHERE id = ${revisionId}
905
+ AND NOT EXISTS (
906
+ SELECT 1 FROM ${sql.ref(tableName)}
907
+ WHERE id = ${id}
908
+ AND draft_revision_id = ${revisionId}
909
+ AND version = ${existing.version + 1}
910
+ )
911
+ `
912
+ ];
913
+ };
914
+ const batched = await executeAtomicBatchIfSupported(this.db, buildQueries());
915
+ if (batched) {
916
+ if (batched[0]?.rows.length !== 1 || batched[1]?.rows.length !== 1) throw new ContentMutationConflictError();
917
+ } else await withTransaction(this.db, async (trx) => {
918
+ const [audit, stage, removeUnstagedAudit] = buildQueries();
919
+ if ((await audit.execute(trx)).rows.length !== 1) throw new ContentMutationConflictError();
920
+ const stageResult = await stage.execute(trx);
921
+ await removeUnstagedAudit.execute(trx);
922
+ if (stageResult.rows.length !== 1) throw new ContentMutationConflictError();
923
+ });
924
+ invalidateCollectionCache(type);
925
+ notifyRoom({
926
+ collection: type,
927
+ id
928
+ });
929
+ await new RevisionRepository(this.db, this.datetimeContexts).queuePruning(type, id, revisionId);
930
+ return revisionId;
931
+ }
932
+ /**
933
+ * Update plugin-authored fields without letting content columns diverge
934
+ * from the revision pointers that publication promotes.
935
+ */
936
+ async updateDraftAware(type, id, input) {
937
+ const data = input.data ? await this.datetimes.normalizeInput(type, writableContentData(input.data)) : {};
938
+ const stagedSlug = typeof input.slug === "string" ? input.slug : void 0;
939
+ if (!(Object.keys(data).length > 0 || stagedSlug !== void 0)) return this.update(type, id, {
940
+ ...input,
941
+ data
942
+ });
943
+ const collectionRows = await this.db.selectFrom("_emdash_collections as collection").leftJoin("_emdash_fields as field", "field.collection_id", "collection.id").select(["collection.supports", "field.slug as fieldSlug"]).where("collection.slug", "=", type).execute();
944
+ const supportsRaw = collectionRows[0]?.supports;
945
+ const supports = supportsRaw ? JSON.parse(supportsRaw) : [];
946
+ if (!Array.isArray(supports) || !supports.includes("revisions")) return this.update(type, id, {
947
+ ...input,
948
+ data,
949
+ draftRevisionId: null
950
+ });
951
+ const fieldSlugs = new Set(collectionRows.map((row) => row.fieldSlug).filter((slug) => Boolean(slug)));
952
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
953
+ let existing = await this.findById(type, id);
954
+ let incoming = data;
955
+ if (existing) {
956
+ let stored = existing.data ?? {};
957
+ if (existing.draftRevisionId) {
958
+ const draft = await revisionRepo.findById(existing.draftRevisionId);
959
+ if (draft?.data) stored = {
960
+ ...stored,
961
+ ...draft.data
962
+ };
963
+ }
964
+ const stale = staleStoredKeys(data, stored, fieldSlugs);
965
+ if (stale.length > 0) {
966
+ incoming = { ...data };
967
+ for (const key of stale) delete incoming[key];
968
+ }
969
+ }
970
+ for (const field of Object.keys(incoming)) if (!fieldSlugs.has(field)) throw new EmDashValidationError(`Unknown field '${field}' in collection '${type}'`);
971
+ for (let attempt = 0; existing && attempt < MAX_DRAFT_STAGE_ATTEMPTS; attempt++) {
972
+ let baseData = existing.data;
973
+ if (existing.draftRevisionId) {
974
+ const draft = await revisionRepo.findById(existing.draftRevisionId);
975
+ if (draft) baseData = draft.data;
976
+ }
977
+ const mergedData = keepKnownFields({
978
+ ...baseData,
979
+ ...incoming
980
+ }, fieldSlugs);
981
+ if (stagedSlug !== void 0) mergedData._slug = stagedSlug;
982
+ await this.keepStartingRevision(revisionRepo, type, existing);
983
+ const revision = await revisionRepo.create({
984
+ collection: type,
985
+ entryId: id,
986
+ data: mergedData,
987
+ ...input.revisionAuthorId ? { authorId: input.revisionAuthorId } : {}
988
+ });
989
+ let staged;
990
+ try {
991
+ staged = await this.replaceDraftRevisionForUpdate(type, id, revision.id, existing, input);
992
+ } catch (error) {
993
+ await this.deleteUnstagedRevision(revisionRepo, type, id, revision.id);
994
+ throw error;
995
+ }
996
+ if (staged) {
997
+ const updated = await this.findById(type, id);
998
+ if (!updated) throw new Error("Content not found");
999
+ const draftData = {};
1000
+ for (const [key, value] of Object.entries(mergedData)) if (!key.startsWith("_")) draftData[key] = value;
1001
+ return {
1002
+ ...updated,
1003
+ data: {
1004
+ ...updated.data,
1005
+ ...draftData
1006
+ }
1007
+ };
1008
+ }
1009
+ await this.deleteUnstagedRevision(revisionRepo, type, id, revision.id);
1010
+ existing = await this.findById(type, id);
1011
+ }
1012
+ if (!existing) throw new Error("Content not found");
1013
+ throw new ContentMutationConflictError();
1014
+ }
1015
+ /**
1016
+ * Keep an entry's starting content as a revision before any other revision of it is written.
1017
+ * Until then only the columns hold it, and publishing a later draft overwrites them. A save
1018
+ * writes it ahead of its own draft, and publishing an entry with no live or draft revision
1019
+ * publishes it. Neither removes it, so a save that finds any revision already there can skip
1020
+ * writing it. Returns its id while it is the entry's newest revision and holds the stored
1021
+ * content, otherwise null.
1022
+ */
1023
+ async keepStartingRevision(revisionRepo, type, existing, extraData) {
1024
+ if (existing.draftRevisionId || existing.liveRevisionId) return null;
1025
+ const id = startingRevisionId(type, existing.id, existing.createdAt);
1026
+ const latest = await revisionRepo.findLatest(type, existing.id);
1027
+ if (latest) return latest.id === id && Object.entries(existing.data).every(([key, value]) => sameStoredValue(latest.data[key], value)) ? id : null;
1028
+ await revisionRepo.createIfMissing({
1029
+ id,
1030
+ collection: type,
1031
+ entryId: existing.id,
1032
+ data: {
1033
+ ...existing.data,
1034
+ ...await extraData?.()
1035
+ },
1036
+ authorId: existing.authorId ?? void 0
1037
+ });
1038
+ return id;
1039
+ }
1040
+ async deleteUnstagedRevision(revisionRepo, type, id, revisionId) {
1041
+ try {
1042
+ await revisionRepo.deleteIfUnreferenced(type, id, revisionId);
1043
+ } catch (error) {
1044
+ console.error(`[content] Failed to clean up unstaged revision ${revisionId}:`, error);
1045
+ }
1046
+ }
1047
+ async replaceDraftRevisionForUpdate(type, id, revisionId, expected, input) {
1048
+ const tableName = getTableName(type);
1049
+ const assignments = [sql`draft_revision_id = ${revisionId}`];
1050
+ let liveMetadataChanged = false;
1051
+ if (input.status !== void 0) {
1052
+ assignments.push(sql`status = ${input.status}`);
1053
+ liveMetadataChanged = true;
1054
+ }
1055
+ if (input.slug === null) {
1056
+ assignments.push(sql`slug = NULL`);
1057
+ liveMetadataChanged = true;
1058
+ }
1059
+ if (input.publishedAt !== void 0) {
1060
+ const publishedAt = input.publishedAt === null ? null : await this.datetimes.normalizeValue(type, input.publishedAt);
1061
+ assignments.push(sql`published_at = ${publishedAt}`);
1062
+ liveMetadataChanged = true;
1063
+ }
1064
+ if (input.scheduledAt !== void 0) {
1065
+ const scheduledAt = input.scheduledAt === null ? null : await this.datetimes.normalizeValue(type, input.scheduledAt);
1066
+ assignments.push(sql`scheduled_at = ${scheduledAt}`);
1067
+ liveMetadataChanged = true;
1068
+ }
1069
+ if (input.authorId !== void 0) {
1070
+ assignments.push(sql`author_id = ${input.authorId}`);
1071
+ liveMetadataChanged = true;
1072
+ }
1073
+ if (input.primaryBylineId !== void 0) {
1074
+ assignments.push(sql`primary_byline_id = ${input.primaryBylineId}`);
1075
+ liveMetadataChanged = true;
1076
+ }
1077
+ if (liveMetadataChanged) assignments.push(sql`updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}`);
1078
+ assignments.push(sql`version = version + 1`);
1079
+ const changed = ((await sql`
1080
+ UPDATE ${sql.ref(tableName)}
1081
+ SET ${sql.join(assignments, sql`, `)}
1082
+ WHERE id = ${id}
1083
+ AND deleted_at IS NULL
1084
+ AND version = ${expected.version}
1085
+ AND ${nullableColumnMatch("live_revision_id", expected.liveRevisionId)}
1086
+ AND ${nullableColumnMatch("draft_revision_id", expected.draftRevisionId)}
1087
+ AND EXISTS (
1088
+ SELECT 1 FROM revisions
1089
+ WHERE revisions.id = ${revisionId}
1090
+ AND revisions.collection = ${type}
1091
+ AND revisions.entry_id = ${id}
1092
+ )
1093
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1094
+ if (changed && liveMetadataChanged) invalidateCollectionCache(type);
1095
+ if (changed) notifyRoom({
1096
+ collection: type,
1097
+ id
1098
+ }, outsideValuesWritten(input));
1099
+ return changed;
1100
+ }
1101
+ /**
1102
+ * Copy non-translatable field values to every other entry in the
1103
+ * translation group, trashed entries included.
1104
+ *
1105
+ * Only the fields present in `data` are copied. With `previous`, `data` is
1106
+ * the entry's complete new state and only the fields whose value differs
1107
+ * from `previous` are copied, an absent field as null. An entry that already
1108
+ * holds every copied value is left untouched, so its `updated_at` does not
1109
+ * move.
1110
+ *
1111
+ * On collections with revisions a changed entry also gets a new live
1112
+ * revision, because republishing and unpublishing read that revision rather
1113
+ * than the columns. A pending draft takes a value only where it still holds
1114
+ * the entry's previous value, so an unpublished edit to the field survives.
1115
+ */
1116
+ async syncNonTranslatableFields(type, sourceId, translationGroup, data, options = {}) {
1117
+ const tableName = getTableName(type);
1118
+ const collectionRows = await this.db.selectFrom("_emdash_collections as collection").leftJoin("_emdash_fields as field", (join) => join.onRef("field.collection_id", "=", "collection.id").on("field.translatable", "=", 0)).select(["collection.supports", "field.slug as fieldSlug"]).where("collection.slug", "=", type).execute();
1119
+ const { previous } = options;
1120
+ const values = {};
1121
+ for (const { fieldSlug } of collectionRows) {
1122
+ if (!fieldSlug) continue;
1123
+ if (previous) {
1124
+ if (!sameStoredValue(previous[fieldSlug], data[fieldSlug])) values[fieldSlug] = data[fieldSlug] ?? null;
1125
+ } else if (fieldSlug in data) values[fieldSlug] = data[fieldSlug];
1126
+ }
1127
+ if (Object.keys(values).length === 0) return;
1128
+ const normalizedValues = await this.datetimes.normalizeData(type, values);
1129
+ const supportsRaw = collectionRows[0]?.supports;
1130
+ const supports = supportsRaw ? JSON.parse(supportsRaw) : [];
1131
+ const usesRevisions = Array.isArray(supports) && supports.includes("revisions");
1132
+ const siblings = await sql`
1133
+ SELECT * FROM ${sql.ref(tableName)}
1134
+ WHERE translation_group = ${translationGroup}
1135
+ AND id != ${sourceId}
1136
+ `.execute(this.db);
1137
+ let changed = false;
1138
+ for (const row of siblings.rows) if (await this.syncSiblingValues(type, this.mapRow(type, row), normalizedValues, usesRevisions)) changed = true;
1139
+ if (changed) invalidateCollectionCache(type);
1140
+ }
1141
+ async syncSiblingValues(type, initial, values, usesRevisions) {
1142
+ const tableName = getTableName(type);
1143
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1144
+ let sibling = initial;
1145
+ for (let attempt = 0; sibling && attempt < MAX_DRAFT_STAGE_ATTEMPTS; attempt++) {
1146
+ const current = sibling;
1147
+ const changed = {};
1148
+ for (const [field, value] of Object.entries(values)) if (!sameStoredValue(current.data[field], value)) changed[field] = value;
1149
+ if (Object.keys(changed).length === 0) return false;
1150
+ const assignments = [];
1151
+ for (const [field, value] of Object.entries(changed)) {
1152
+ validateIdentifier(field, "content field name");
1153
+ assignments.push(sql`${sql.ref(field)} = ${serializeValue(value)}`);
1154
+ }
1155
+ const createdRevisionIds = [];
1156
+ const cleanUp = async () => {
1157
+ for (const revisionId of createdRevisionIds) await this.deleteUnstagedRevision(revisionRepo, type, current.id, revisionId);
1158
+ };
1159
+ let synced;
1160
+ try {
1161
+ const live = usesRevisions && current.liveRevisionId ? await revisionRepo.findById(current.liveRevisionId) : null;
1162
+ if (live) {
1163
+ const revision = await revisionRepo.create({
1164
+ collection: type,
1165
+ entryId: current.id,
1166
+ data: {
1167
+ ...live.data,
1168
+ ...changed
1169
+ }
1170
+ });
1171
+ createdRevisionIds.push(revision.id);
1172
+ assignments.push(sql`live_revision_id = ${revision.id}`);
1173
+ }
1174
+ const draft = usesRevisions && current.draftRevisionId ? await revisionRepo.findById(current.draftRevisionId) : null;
1175
+ const carried = {};
1176
+ for (const [field, value] of Object.entries(changed)) if (draft && sameStoredValue(draft.data[field], current.data[field])) carried[field] = value;
1177
+ if (draft && Object.keys(carried).length > 0) {
1178
+ const revision = await revisionRepo.create({
1179
+ collection: type,
1180
+ entryId: current.id,
1181
+ data: {
1182
+ ...draft.data,
1183
+ ...carried
1184
+ }
1185
+ });
1186
+ createdRevisionIds.push(revision.id);
1187
+ assignments.push(sql`draft_revision_id = ${revision.id}`);
1188
+ }
1189
+ assignments.push(sql`updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}`, sql`version = version + 1`);
1190
+ synced = ((await sql`
1191
+ UPDATE ${sql.ref(tableName)}
1192
+ SET ${sql.join(assignments, sql`, `)}
1193
+ WHERE id = ${current.id}
1194
+ AND version = ${current.version}
1195
+ AND ${nullableColumnMatch("live_revision_id", current.liveRevisionId)}
1196
+ AND ${nullableColumnMatch("draft_revision_id", current.draftRevisionId)}
1197
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1198
+ } catch (error) {
1199
+ await cleanUp();
1200
+ throw error;
1201
+ }
1202
+ if (synced) {
1203
+ notifyRoom({
1204
+ collection: type,
1205
+ id: current.id
1206
+ });
1207
+ return true;
1208
+ }
1209
+ await cleanUp();
1210
+ sibling = await this.findByIdIncludingTrashed(type, current.id);
1211
+ }
1212
+ if (!sibling) return false;
1213
+ throw new ContentMutationConflictError();
1214
+ }
1215
+ /**
1216
+ * Delete content (soft delete - moves to trash)
1217
+ */
1218
+ async delete(type, id) {
1219
+ const tableName = getTableName(type);
1220
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1221
+ const changed = ((await sql`
1222
+ UPDATE ${sql.ref(tableName)}
1223
+ SET deleted_at = ${now}
1224
+ WHERE id = ${id}
1225
+ AND deleted_at IS NULL
1226
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1227
+ if (changed) {
1228
+ invalidateCollectionCache(type);
1229
+ notifyRoom({
1230
+ collection: type,
1231
+ id
1232
+ });
1233
+ }
1234
+ return changed;
1235
+ }
1236
+ /**
1237
+ * Restore content from trash
1238
+ *
1239
+ * The entry comes back as a draft with no schedule. The live version is not
1240
+ * copied into a draft revision: collections without revisions save to the
1241
+ * columns, and a draft revision would hide those saves.
1242
+ */
1243
+ async restore(type, id, expectedRevision) {
1244
+ const tableName = getTableName(type);
1245
+ const existing = await this.findByIdOrSlugIncludingTrashed(type, id);
1246
+ if (!existing) return null;
1247
+ assertRevisionPrecondition(existing, expectedRevision);
1248
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1249
+ const restored = (await sql`
1250
+ UPDATE ${sql.ref(tableName)}
1251
+ SET deleted_at = NULL,
1252
+ live_revision_id = NULL,
1253
+ status = 'draft',
1254
+ scheduled_at = NULL,
1255
+ updated_at = ${now},
1256
+ version = ${existing.version + 1}
1257
+ WHERE id = ${existing.id}
1258
+ AND deleted_at IS NOT NULL
1259
+ AND version = ${existing.version}
1260
+ AND updated_at = ${existing.updatedAt}
1261
+ RETURNING *
1262
+ `.execute(this.db)).rows[0];
1263
+ if (!restored) throw new ContentMutationConflictError("Content changed while restoring");
1264
+ invalidateCollectionCache(type);
1265
+ notifyRoom({
1266
+ collection: type,
1267
+ id: existing.id
1268
+ });
1269
+ return this.mapRow(type, restored);
1270
+ }
1271
+ /**
1272
+ * Permanently delete content (cannot be undone)
1273
+ */
1274
+ /**
1275
+ * Permanently delete a soft-deleted content row.
1276
+ *
1277
+ * Returns `true` only when a soft-deleted (trashed) row was removed.
1278
+ * Returns `false` when no row exists OR when the row exists but is live —
1279
+ * the caller is responsible for distinguishing these cases (typically via
1280
+ * a follow-up `findByIdOrSlugIncludingTrashed` to surface NOT_FOUND vs
1281
+ * NOT_TRASHED). The `AND deleted_at IS NOT NULL` clause is the safety net
1282
+ * that prevents permanent delete from bypassing the trash workflow.
1283
+ */
1284
+ async permanentDelete(type, id) {
1285
+ const tableName = getTableName(type);
1286
+ const changed = ((await sql`
1287
+ DELETE FROM ${sql.ref(tableName)}
1288
+ WHERE id = ${id}
1289
+ AND deleted_at IS NOT NULL
1290
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1291
+ if (changed) {
1292
+ invalidateCollectionCache(type);
1293
+ notifyRoom({
1294
+ collection: type,
1295
+ id
1296
+ });
1297
+ }
1298
+ return changed;
1299
+ }
1300
+ /**
1301
+ * Find trashed content items
1302
+ */
1303
+ async findTrashed(type, options = {}) {
1304
+ const tableName = getTableName(type);
1305
+ const limit = Math.max(1, Math.min(options.limit || 50, 100));
1306
+ assertPageOffset(options.offset, options.cursor);
1307
+ const orderField = options.orderBy?.field || "deletedAt";
1308
+ const orderDirection = options.orderBy?.direction || "desc";
1309
+ const dbField = this.mapOrderField(orderField);
1310
+ const safeOrderDirection = orderDirection.toLowerCase() === "asc" ? "ASC" : "DESC";
1311
+ let query = this.db.selectFrom(tableName).selectAll().where("deleted_at", "is not", null);
1312
+ if (options.where?.locale) query = query.where(localeMatches("locale", options.where.locale));
1313
+ if (options.cursor) {
1314
+ const { orderValue, id: cursorId } = decodeCursor(options.cursor);
1315
+ if (safeOrderDirection === "DESC") query = query.where((eb) => eb.or([eb(dbField, "<", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", "<", cursorId)])]));
1316
+ else query = query.where((eb) => eb.or([eb(dbField, ">", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", ">", cursorId)])]));
1317
+ }
1318
+ query = query.orderBy(dbField, safeOrderDirection === "ASC" ? "asc" : "desc").orderBy("id", safeOrderDirection === "ASC" ? "asc" : "desc");
1319
+ query = options.offset === void 0 ? query.limit(limit + 1) : query.limit(limit).offset(options.offset);
1320
+ const rows = await query.execute();
1321
+ const hasMore = rows.length > limit;
1322
+ const items = rows.slice(0, limit);
1323
+ const mappedResult = { items: items.map((row) => {
1324
+ const record = row;
1325
+ return {
1326
+ ...this.mapRow(type, record),
1327
+ deletedAt: typeof record.deleted_at === "string" ? record.deleted_at : ""
1328
+ };
1329
+ }) };
1330
+ if (hasMore && items.length > 0) {
1331
+ const lastRow = items.at(-1);
1332
+ const lastOrderValue = lastRow[dbField];
1333
+ mappedResult.nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
1334
+ }
1335
+ return mappedResult;
1336
+ }
1337
+ /**
1338
+ * Count trashed content items
1339
+ */
1340
+ async countTrashed(type, options = {}) {
1341
+ const tableName = getTableName(type);
1342
+ let query = this.db.selectFrom(tableName).select((eb) => eb.fn.count("id").as("count")).where("deleted_at", "is not", null);
1343
+ if (options.locale) query = query.where(localeMatches("locale", options.locale));
1344
+ const result = await query.executeTakeFirst();
1345
+ return Number(result?.count || 0);
1346
+ }
1347
+ /**
1348
+ * Apply the optional `q` filter.
1349
+ *
1350
+ * When the handler sets `useFts` (collection has a healthy FTS5 index
1351
+ * covering the display columns; SQLite only), the filter is served from
1352
+ * the index: a token-prefix MATCH against `_emdash_fts_<slug>` OR'd with
1353
+ * an index-served `slug GLOB 'term*'` prefix (the slug is not in the FTS
1354
+ * index). Both sides are index-backed, so SQLite's OR optimization avoids
1355
+ * the full-table scan the LIKE fallback needs (#1517). The trade-off is
1356
+ * search semantics: token-prefix matching instead of arbitrary substring.
1357
+ *
1358
+ * Fallback (Postgres, search disabled, or no usable terms): case-
1359
+ * insensitive substring LIKE across the handler-resolved `searchColumns`
1360
+ * (OR'd). User input is treated literally (LIKE wildcards escaped) and
1361
+ * `lower()` is applied on both sides for SQLite/Postgres parity.
1362
+ */
1363
+ applySearchFilter(query, where, type) {
1364
+ const term = where?.q?.trim();
1365
+ const columns = where?.searchColumns;
1366
+ if (!term || !columns || columns.length === 0) return query;
1367
+ if (where.useFts) {
1368
+ const match = buildFtsPrefixMatch(term);
1369
+ if (match) {
1370
+ validateIdentifier(type, "collection slug");
1371
+ const ftsTable = `_emdash_fts_${type}`;
1372
+ const slugPrefix = buildSlugGlobPrefix(term);
1373
+ return query.where((eb) => eb.or([sql`id IN (SELECT id FROM ${sql.ref(ftsTable)} WHERE ${sql.ref(ftsTable)} MATCH ${match})`, sql`slug GLOB ${slugPrefix}`]));
1374
+ }
1375
+ }
1376
+ const pattern = `%${term.replace(LIKE_WILDCARD_RE, (c) => `\\${c}`)}%`;
1377
+ return query.where((eb) => eb.or(columns.map((col) => {
1378
+ validateIdentifier(col, "search column");
1379
+ return sql`lower(CAST(${sql.ref(col)} AS TEXT)) LIKE lower(${pattern}) ESCAPE '\\'`;
1380
+ })));
1381
+ }
1382
+ /**
1383
+ * Apply the optional inclusive date-range filter. The field is mapped
1384
+ * through `DATE_FILTER_COLUMNS` (a closed whitelist), and bounds compare
1385
+ * lexicographically against the stored ISO 8601 timestamps. A `publishedAt`
1386
+ * range naturally excludes never-published rows (their column is NULL).
1387
+ */
1388
+ applyDateFilter(query, where) {
1389
+ const filter = where?.dateFilter;
1390
+ if (!filter) return query;
1391
+ const column = DATE_FILTER_COLUMNS[filter.field];
1392
+ if (!column) throw new EmDashValidationError(`Invalid date filter field: ${filter.field}`);
1393
+ const { from, to } = filter;
1394
+ if (!from && !to) return query;
1395
+ let next = query;
1396
+ if (from) next = next.where((eb) => eb(column, ">=", from));
1397
+ if (to) next = next.where((eb) => eb(column, "<=", to));
1398
+ return next;
1399
+ }
1400
+ /**
1401
+ * Apply the optional byline filter as a correlated (NOT) EXISTS against
1402
+ * `_emdash_content_bylines`.
1403
+ *
1404
+ * Correlating from the content table preserves the outer sort index so
1405
+ * `LIMIT` can short-circuit. `mode: "none"` tests the junction rather than
1406
+ * `primary_byline_id` because the two are written in the same call but
1407
+ * are not atomically consistent, so the junction is authoritative.
1408
+ *
1409
+ * Whether a credit *renders* is locale-scoped; whether one *exists* is
1410
+ * not. Both are needed: the first decides what the filter matches, the
1411
+ * second decides whether the author fallback applies at all.
1412
+ */
1413
+ applyBylineFilter(query, where, type) {
1414
+ const filter = where?.bylineFilter;
1415
+ if (!filter) return query;
1416
+ const tableName = getTableName(type);
1417
+ const idColumn = `${tableName}.id`;
1418
+ const authorColumn = `${tableName}.author_id`;
1419
+ const localeColumn = `${tableName}.locale`;
1420
+ const creditRenders = (eb, bylineIds) => {
1421
+ let sub = eb.selectFrom("_emdash_content_bylines as cb").innerJoin("_emdash_bylines as b", "b.translation_group", "cb.byline_id").select("cb.id").where("cb.collection_slug", "=", type).whereRef("cb.content_id", "=", idColumn);
1422
+ sub = filter.locale ? sub.where(localeMatches("b.locale", filter.locale)) : sub.where(sql`${canonicalLocaleColumn("b.locale")} = ${canonicalLocaleColumn(localeColumn)}`);
1423
+ if (bylineIds) sub = sub.where("cb.byline_id", "in", bylineIds);
1424
+ return eb.exists(sub);
1425
+ };
1426
+ const hasExplicitCredit = (eb) => eb.exists(eb.selectFrom("_emdash_content_bylines as cb").select("cb.id").where("cb.collection_slug", "=", type).whereRef("cb.content_id", "=", idColumn));
1427
+ const authorHasByline = (eb, bylineIds) => {
1428
+ let sub = eb.selectFrom("_emdash_bylines as b").select("b.id").whereRef("b.user_id", "=", authorColumn);
1429
+ sub = filter.locale ? sub.where(localeMatches("b.locale", filter.locale)) : sub.where(sql`${canonicalLocaleColumn("b.locale")} = ${canonicalLocaleColumn(localeColumn)}`);
1430
+ if (bylineIds) sub = sub.where("b.translation_group", "in", bylineIds);
1431
+ return eb.exists(sub);
1432
+ };
1433
+ if (filter.mode === "none") return query.where((eb) => {
1434
+ const uncredited = eb.not(creditRenders(eb));
1435
+ return filter.includeInferred ? eb.and([uncredited, eb.or([hasExplicitCredit(eb), eb.not(authorHasByline(eb))])]) : uncredited;
1436
+ });
1437
+ const bylineIds = filter.bylineIds ?? [];
1438
+ if (bylineIds.length === 0) return query.where(() => sql`1 = 0`);
1439
+ return query.where((eb) => {
1440
+ if (!filter.includeInferred) return creditRenders(eb, bylineIds);
1441
+ return eb.or([creditRenders(eb, bylineIds), eb.and([eb.not(hasExplicitCredit(eb)), authorHasByline(eb, bylineIds)])]);
1442
+ });
1443
+ }
1444
+ /**
1445
+ * Count content items
1446
+ */
1447
+ async count(type, where) {
1448
+ const resolvedFieldFilters = await this.resolveFieldFilters(type, where?.fieldFilters);
1449
+ return this.countWithResolvedFilters(type, where, resolvedFieldFilters);
1450
+ }
1451
+ async countWithResolvedFilters(type, where, resolvedFieldFilters) {
1452
+ const tableName = getTableName(type);
1453
+ let query = this.db.selectFrom(tableName).select((eb) => eb.fn.count("id").as("count")).where("deleted_at", "is", null);
1454
+ if (where?.status) query = query.where("status", "=", where.status);
1455
+ if (where?.authorId) query = query.where("author_id", "=", where.authorId);
1456
+ if (where?.locale) query = query.where(localeMatches("locale", where.locale));
1457
+ query = this.applySearchFilter(query, where, type);
1458
+ query = this.applyDateFilter(query, where);
1459
+ query = this.applyBylineFilter(query, where, type);
1460
+ query = this.applyFieldFilters(query, resolvedFieldFilters);
1461
+ const result = await query.executeTakeFirst();
1462
+ return Number(result?.count || 0);
1463
+ }
1464
+ /**
1465
+ * Distinct, non-null `author_id` values across the collection's live
1466
+ * (non-trashed) content. Used to populate the admin author filter with
1467
+ * only the users who have actually authored entries, rather than the
1468
+ * full user directory (which requires admin privileges to read).
1469
+ */
1470
+ async findDistinctAuthorIds(type) {
1471
+ const tableName = getTableName(type);
1472
+ return (await this.db.selectFrom(tableName).select("author_id").distinct().where("deleted_at", "is", null).where("author_id", "is not", null).execute()).map((row) => row.author_id).filter((id) => id !== null);
1473
+ }
1474
+ async getStats(type, now = /* @__PURE__ */ new Date()) {
1475
+ const tableName = getTableName(type);
1476
+ const nowIso = now.toISOString();
1477
+ const result = await this.db.selectFrom(tableName).select((eb) => [
1478
+ eb.fn.count("id").as("total"),
1479
+ eb.fn.sum(eb.case().when("status", "=", "published").then(1).else(0).end()).as("published"),
1480
+ eb.fn.sum(eb.case().when("status", "=", "draft").then(1).else(0).end()).as("draft"),
1481
+ sql`SUM(CASE WHEN scheduled_at IS NOT NULL THEN 1 ELSE 0 END)`.as("scheduled"),
1482
+ sql`SUM(CASE WHEN scheduled_at IS NOT NULL AND scheduled_at <= ${nowIso} THEN 1 ELSE 0 END)`.as("overdue_scheduled")
1483
+ ]).where("deleted_at", "is", null).executeTakeFirst();
1484
+ return {
1485
+ total: Number(result?.total || 0),
1486
+ published: Number(result?.published || 0),
1487
+ draft: Number(result?.draft || 0),
1488
+ scheduled: Number(result?.scheduled || 0),
1489
+ overdueScheduled: Number(result?.overdue_scheduled || 0)
1490
+ };
1491
+ }
1492
+ /**
1493
+ * Schedule content for future publishing
1494
+ *
1495
+ * Sets status to 'scheduled' and stores the scheduled publish time.
1496
+ * The content will be auto-published when the scheduled time is reached.
1497
+ */
1498
+ async schedule(type, id, scheduledAt, currentTime = /* @__PURE__ */ new Date(), expectedRevision) {
1499
+ const tableName = getTableName(type);
1500
+ const now = currentTime.toISOString();
1501
+ const normalizedScheduledAt = await this.datetimes.normalizeValue(type, scheduledAt);
1502
+ if (new Date(normalizedScheduledAt) <= currentTime) throw new EmDashValidationError("Scheduled date must be in the future");
1503
+ const existing = await this.findById(type, id);
1504
+ if (!existing) throw new EmDashValidationError("Content item not found");
1505
+ assertRevisionPrecondition(existing, expectedRevision);
1506
+ const newStatus = existing.status === "published" ? "published" : "scheduled";
1507
+ if (((await sql`
1508
+ UPDATE ${sql.ref(tableName)}
1509
+ SET status = ${newStatus},
1510
+ scheduled_at = ${normalizedScheduledAt},
1511
+ updated_at = ${now}
1512
+ WHERE id = ${id}
1513
+ AND deleted_at IS NULL
1514
+ AND version = ${existing.version}
1515
+ AND updated_at = ${existing.updatedAt}
1516
+ AND status = ${existing.status}
1517
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1518
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError("Content changed while scheduling");
1519
+ invalidateCollectionCache(type);
1520
+ notifyRoom({
1521
+ collection: type,
1522
+ id
1523
+ });
1524
+ const updated = await this.findById(type, id);
1525
+ if (!updated) throw new Error("Content not found");
1526
+ return updated;
1527
+ }
1528
+ /**
1529
+ * Unschedule content
1530
+ *
1531
+ * Clears the scheduled time. Published posts stay published;
1532
+ * draft/scheduled posts revert to 'draft'.
1533
+ */
1534
+ async unschedule(type, id, expectedRevision) {
1535
+ const tableName = getTableName(type);
1536
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1537
+ const existing = await this.findById(type, id);
1538
+ if (!existing) throw new EmDashValidationError("Content item not found");
1539
+ assertRevisionPrecondition(existing, expectedRevision);
1540
+ const newStatus = existing.status === "published" ? "published" : "draft";
1541
+ const result = await sql`
1542
+ UPDATE ${sql.ref(tableName)}
1543
+ SET status = ${newStatus},
1544
+ scheduled_at = NULL,
1545
+ updated_at = ${now}
1546
+ WHERE id = ${id}
1547
+ AND scheduled_at IS NOT NULL
1548
+ AND deleted_at IS NULL
1549
+ AND version = ${existing.version}
1550
+ AND updated_at = ${existing.updatedAt}
1551
+ AND status = ${existing.status}
1552
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1553
+ `.execute(this.db);
1554
+ if (existing.scheduledAt !== null && (result.numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError("Content changed while unscheduling");
1555
+ invalidateCollectionCache(type);
1556
+ if ((result.numAffectedRows ?? 0n) > 0n) notifyRoom({
1557
+ collection: type,
1558
+ id
1559
+ });
1560
+ const updated = await this.findById(type, id);
1561
+ if (!updated) throw new Error("Content not found");
1562
+ return updated;
1563
+ }
1564
+ /**
1565
+ * Find content that is ready to be published
1566
+ *
1567
+ * Returns all content where scheduled_at <= now, regardless of status.
1568
+ * This covers both draft-scheduled posts (status='scheduled') and
1569
+ * published posts with scheduled draft changes (status='published').
1570
+ *
1571
+ * `limit` (optional) caps how many due rows are returned, oldest-due first.
1572
+ * The scheduled-publishing sweep passes a limit so a large backlog can't
1573
+ * fan out unbounded publish/webhook work in a single tick (and blow a Worker
1574
+ * invocation's CPU/subrequest budget); the remainder drains on later ticks.
1575
+ */
1576
+ async findReadyToPublish(type, limit, currentTime = /* @__PURE__ */ new Date(), after) {
1577
+ const tableName = getTableName(type);
1578
+ const now = currentTime.toISOString();
1579
+ const limitClause = typeof limit === "number" && Number.isInteger(limit) && limit > 0 ? sql`LIMIT ${limit}` : sql``;
1580
+ const afterClause = after ? sql`AND (scheduled_at > ${after.scheduledAt} OR (scheduled_at = ${after.scheduledAt} AND id > ${after.id}))` : sql``;
1581
+ return (await sql`
1582
+ SELECT * FROM ${sql.ref(tableName)}
1583
+ WHERE ${readyToPublishCondition(now)}
1584
+ ${afterClause}
1585
+ ORDER BY scheduled_at ASC, id ASC
1586
+ ${limitClause}
1587
+ `.execute(this.db)).rows.map((row) => this.mapRow(type, row));
1588
+ }
1589
+ async findTranslationIds(type, translationGroup) {
1590
+ const tableName = getTableName(type);
1591
+ return (await sql`
1592
+ SELECT id FROM ${sql.ref(tableName)}
1593
+ WHERE translation_group = ${translationGroup}
1594
+ AND deleted_at IS NULL
1595
+ `.execute(this.db)).rows.map((row) => row.id);
1596
+ }
1597
+ async findTranslationIdsForGroups(type, translationGroups) {
1598
+ const ids = /* @__PURE__ */ new Map();
1599
+ if (translationGroups.length === 0) return ids;
1600
+ const tableName = getTableName(type);
1601
+ for (const batch of chunks([...new Set(translationGroups)], SQL_BATCH_SIZE)) {
1602
+ const result = await sql`
1603
+ SELECT id, translation_group FROM ${sql.ref(tableName)}
1604
+ WHERE translation_group IN (${sql.join(batch)}) AND deleted_at IS NULL
1605
+ `.execute(this.db);
1606
+ for (const row of result.rows) {
1607
+ const group = ids.get(row.translation_group) ?? [];
1608
+ group.push(row.id);
1609
+ ids.set(row.translation_group, group);
1610
+ }
1611
+ }
1612
+ return ids;
1613
+ }
1614
+ /**
1615
+ * Find all translations in a translation group
1616
+ */
1617
+ async findTranslations(type, translationGroup) {
1618
+ const tableName = getTableName(type);
1619
+ return (await sql`
1620
+ SELECT * FROM ${sql.ref(tableName)}
1621
+ WHERE translation_group = ${translationGroup}
1622
+ AND deleted_at IS NULL
1623
+ ORDER BY locale ASC
1624
+ `.execute(this.db)).rows.map((row) => this.mapRow(type, row));
1625
+ }
1626
+ /**
1627
+ * Whether any row still shares `translationGroup`, trashed rows included.
1628
+ * Group-keyed satellite data (term assignments, reference edges) is owned by
1629
+ * the group, not by a single locale row, so a purge may only cascade to it
1630
+ * once nothing is left to own it — and a trashed sibling is still restorable.
1631
+ */
1632
+ async hasTranslationsIncludingTrashed(type, translationGroup, options = {}) {
1633
+ const tableName = getTableName(type);
1634
+ const exclusion = options.excludeId ? sql`AND id != ${options.excludeId}` : sql``;
1635
+ return (await sql`
1636
+ SELECT id FROM ${sql.ref(tableName)}
1637
+ WHERE translation_group = ${translationGroup}
1638
+ ${exclusion}
1639
+ LIMIT 1
1640
+ `.execute(this.db)).rows.length > 0;
1641
+ }
1642
+ /**
1643
+ * Batch variant of {@link findTranslations}: every (non-deleted) locale
1644
+ * variant for any of `translationGroups`, in one `WHERE translation_group IN
1645
+ * (...)` query chunked at `SQL_BATCH_SIZE` for D1's bind-parameter limit.
1646
+ * Lets callers resolve many edge groups without an N+1 per group. The caller
1647
+ * groups the flat result by `translationGroup` itself.
1648
+ *
1649
+ * `translation_group` leads the sort so the ordering follows
1650
+ * `idx_{table}_del_tg_locale` past its `deleted_at` equality; callers group by
1651
+ * `translationGroup`, so the per-group locale order they rely on is preserved.
1652
+ *
1653
+ * `publishedOnly` restricts the result to `status = 'published'` — reference
1654
+ * reads pass this for callers without `content:read_drafts` so draft/scheduled
1655
+ * entries never leak through an edge traversal.
1656
+ *
1657
+ * A reference edge stores only a collection slug (no SQL FK), so the table may
1658
+ * have been dropped since the edge was written. That is a tolerated dangling
1659
+ * state, not an error: a missing table resolves to no rows, mirroring how the
1660
+ * content read handlers treat `isMissingTableError`.
1661
+ */
1662
+ async findTranslationsForGroups(type, translationGroups, options = {}) {
1663
+ if (translationGroups.length === 0) return [];
1664
+ const tableName = getTableName(type);
1665
+ const publishedFilter = options.publishedOnly ? sql`AND status = 'published'` : sql``;
1666
+ const items = [];
1667
+ try {
1668
+ for (const chunk of chunks(translationGroups, SQL_BATCH_SIZE)) {
1669
+ const result = await sql`
1670
+ SELECT * FROM ${sql.ref(tableName)}
1671
+ WHERE translation_group IN (${sql.join(chunk)})
1672
+ AND deleted_at IS NULL
1673
+ ${publishedFilter}
1674
+ ORDER BY translation_group ASC, locale ASC
1675
+ `.execute(this.db);
1676
+ for (const row of result.rows) items.push(this.mapRow(type, row));
1677
+ }
1678
+ } catch (error) {
1679
+ if (isMissingTableError(error)) return [];
1680
+ throw error;
1681
+ }
1682
+ return items;
1683
+ }
1684
+ /**
1685
+ * Batch variant of {@link findByIdOrSlug}: resolve many identifiers (each an
1686
+ * id OR a slug) within `type` in a constant number of queries — one `WHERE id
1687
+ * IN (...)` and one `WHERE slug IN (...)`, each chunked at `SQL_BATCH_SIZE`.
1688
+ * Returns a map from the input identifier to its resolved item; identifiers
1689
+ * that match nothing are absent. Used on write paths that accept a list of
1690
+ * references, so a single request doesn't fan out to an N+1 of point lookups.
1691
+ *
1692
+ * Resolution mirrors {@link findByIdOrSlug}: a ULID-shaped identifier prefers
1693
+ * the id match and falls back to slug; anything else prefers the slug match
1694
+ * and falls back to id. Slug matches collapse to the lowest-locale variant
1695
+ * (`ORDER BY locale ASC`), matching the slug-without-locale lookup.
1696
+ */
1697
+ async findManyByIdOrSlug(type, identifiers) {
1698
+ const resolved = /* @__PURE__ */ new Map();
1699
+ const unique = [...new Set(identifiers)];
1700
+ if (unique.length === 0) return resolved;
1701
+ const tableName = getTableName(type);
1702
+ const byId = /* @__PURE__ */ new Map();
1703
+ const bySlug = /* @__PURE__ */ new Map();
1704
+ try {
1705
+ for (const chunk of chunks(unique, SQL_BATCH_SIZE)) {
1706
+ const idRows = await sql`
1707
+ SELECT * FROM ${sql.ref(tableName)}
1708
+ WHERE id IN (${sql.join(chunk)})
1709
+ AND deleted_at IS NULL
1710
+ `.execute(this.db);
1711
+ for (const row of idRows.rows) {
1712
+ const item = this.mapRow(type, row);
1713
+ byId.set(item.id, item);
1714
+ }
1715
+ const slugRows = await sql`
1716
+ SELECT * FROM ${sql.ref(tableName)}
1717
+ WHERE slug IN (${sql.join(chunk)})
1718
+ AND deleted_at IS NULL
1719
+ ORDER BY locale ASC
1720
+ `.execute(this.db);
1721
+ for (const row of slugRows.rows) {
1722
+ const item = this.mapRow(type, row);
1723
+ if (item.slug != null && !bySlug.has(item.slug)) bySlug.set(item.slug, item);
1724
+ }
1725
+ }
1726
+ } catch (error) {
1727
+ if (isMissingTableError(error)) return resolved;
1728
+ throw error;
1729
+ }
1730
+ for (const identifier of unique) {
1731
+ const item = ULID_PATTERN.test(identifier) ? byId.get(identifier) ?? bySlug.get(identifier) : bySlug.get(identifier) ?? byId.get(identifier);
1732
+ if (item) resolved.set(identifier, item);
1733
+ }
1734
+ return resolved;
1735
+ }
1736
+ /**
1737
+ * Publish the current draft
1738
+ *
1739
+ * Promotes draft_revision_id to live_revision_id and clears draft pointer.
1740
+ * Syncs the draft revision's data into the content table columns so the
1741
+ * content table always reflects the published version.
1742
+ * If no draft revision exists, creates one from current data and publishes it.
1743
+ * When `promoteRevision` is false, publishes the current content-table data
1744
+ * by changing lifecycle metadata only.
1745
+ *
1746
+ * `publishedAt` (optional) overrides the publication timestamp. If omitted,
1747
+ * the existing `published_at` is preserved (idempotent re-publish keeps the
1748
+ * original date) and falls back to the current time on first publish. Pass
1749
+ * an explicit value to backdate a publish (e.g. when migrating content from
1750
+ * another CMS).
1751
+ *
1752
+ * `requireDue` gates the final update on the row still being due.
1753
+ * `expectedScheduledAt` additionally fences changes made after a sweep
1754
+ * selected the row but before publication preparation began.
1755
+ */
1756
+ async publish(type, id, publishedAt, requireDue = false, expectedScheduledAt, promoteRevision = true, requireSlug = true, expectedRevision, currentTime = /* @__PURE__ */ new Date()) {
1757
+ const tableName = getTableName(type);
1758
+ const now = currentTime.toISOString();
1759
+ const existing = await this.findById(type, id);
1760
+ if (!existing) throw new EmDashValidationError("Content item not found");
1761
+ assertRevisionPrecondition(existing, expectedRevision);
1762
+ const requestedPublishedAt = publishedAt ? await this.datetimes.normalizeValue(type, publishedAt) : void 0;
1763
+ const currentPublishedAt = existing.publishedAt ? await this.datetimes.normalizeValue(type, existing.publishedAt) : null;
1764
+ if (requireDue && expectedScheduledAt !== void 0 && existing.scheduledAt !== expectedScheduledAt) throw new ScheduledNotDueError();
1765
+ if (!promoteRevision && requireSlug && !existing.slug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
1766
+ if (!promoteRevision) {
1767
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1768
+ let provisionalRevisionId = null;
1769
+ try {
1770
+ let liveRevisionId = existing.liveRevisionId;
1771
+ if (!liveRevisionId) {
1772
+ const revision = await revisionRepo.create({
1773
+ collection: type,
1774
+ entryId: id,
1775
+ data: existing.data
1776
+ });
1777
+ liveRevisionId = revision.id;
1778
+ provisionalRevisionId = revision.id;
1779
+ }
1780
+ const intendedPublishedAt = requestedPublishedAt ?? currentPublishedAt ?? now;
1781
+ const duePredicate = requireDue ? sql`AND scheduled_at IS NOT NULL AND scheduled_at <= ${now}` : sql``;
1782
+ let published = false;
1783
+ try {
1784
+ published = ((await sql`
1785
+ UPDATE ${sql.ref(tableName)}
1786
+ SET live_revision_id = ${liveRevisionId},
1787
+ draft_revision_id = NULL,
1788
+ status = 'published',
1789
+ scheduled_at = NULL,
1790
+ published_at = ${intendedPublishedAt},
1791
+ updated_at = ${now},
1792
+ version = version + 1
1793
+ WHERE id = ${id}
1794
+ AND deleted_at IS NULL
1795
+ AND version = ${existing.version}
1796
+ AND updated_at = ${existing.updatedAt}
1797
+ AND status = ${existing.status}
1798
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1799
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1800
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1801
+ ${duePredicate}
1802
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1803
+ } catch (error) {
1804
+ if (isConfirmedStatementFailure(error)) throw error;
1805
+ let observed;
1806
+ try {
1807
+ observed = await this.findById(type, id);
1808
+ } catch (reconciliationError) {
1809
+ throw new Error("Unable to confirm whether content publication completed", { cause: reconciliationError });
1810
+ }
1811
+ if (!observed) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1812
+ published = matchesLifecyclePublication(observed, existing, liveRevisionId, intendedPublishedAt, now);
1813
+ if (!published && matchesPublicationFence(observed, existing)) throw error;
1814
+ if (!published) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1815
+ }
1816
+ if (!published) throw requireDue ? new ScheduledNotDueError() : new ContentMutationConflictError();
1817
+ invalidateCollectionCache(type);
1818
+ notifyRoom({
1819
+ collection: type,
1820
+ id
1821
+ }, ["publishedAt"]);
1822
+ const updated = await this.findById(type, id);
1823
+ if (!updated) throw new Error("Content not found");
1824
+ return updated;
1825
+ } catch (error) {
1826
+ if (provisionalRevisionId) try {
1827
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1828
+ } catch (cleanupError) {
1829
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1830
+ }
1831
+ throw error;
1832
+ }
1833
+ }
1834
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1835
+ let provisionalRevisionId = null;
1836
+ try {
1837
+ let revisionToPublish = existing.draftRevisionId || existing.liveRevisionId || await this.keepStartingRevision(revisionRepo, type, existing);
1838
+ if (!revisionToPublish) {
1839
+ const revision = await revisionRepo.create({
1840
+ collection: type,
1841
+ entryId: id,
1842
+ data: existing.data
1843
+ });
1844
+ revisionToPublish = revision.id;
1845
+ provisionalRevisionId = revision.id;
1846
+ }
1847
+ const revision = await revisionRepo.findById(revisionToPublish);
1848
+ if (!revision || revision.collection !== type || revision.entryId !== id) throw new EmDashValidationError("Revision does not belong to the specified content item");
1849
+ const writableFieldSlugs = await this.datetimes.writableFieldSlugs(type);
1850
+ const revisionData = keepKnownFields(revision.data, writableFieldSlugs);
1851
+ const stagedSlug = typeof revision.data._slug === "string" ? revision.data._slug : null;
1852
+ const intendedSlug = stagedSlug ?? existing.slug;
1853
+ if (requireSlug && !intendedSlug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
1854
+ const intendedPublishedAt = requestedPublishedAt ?? currentPublishedAt ?? now;
1855
+ if (stagedSlug !== null && stagedSlug !== existing.slug && existing.locale !== null) {
1856
+ const conflict = await this.findBySlugIncludingTrashed(type, stagedSlug, existing.locale);
1857
+ if (conflict && conflict.id !== id) throw new EmDashValidationError(`Cannot publish: slug '${stagedSlug}' is already used by another entry in this collection (id: ${conflict.id}). Choose a different slug.`, { code: "SLUG_CONFLICT" });
1858
+ }
1859
+ const assignments = [];
1860
+ if (stagedSlug !== null) assignments.push(sql`slug = ${stagedSlug}`);
1861
+ for (const [key, value] of Object.entries(revisionData)) {
1862
+ if (SYSTEM_COLUMNS.has(key) || key.startsWith("_")) continue;
1863
+ validateIdentifier(key, "content field name");
1864
+ assignments.push(sql`${sql.ref(key)} = ${serializeValue(value)}`);
1865
+ }
1866
+ assignments.push(sql`live_revision_id = ${revisionToPublish}`, sql`draft_revision_id = NULL`, sql`status = 'published'`, sql`scheduled_at = NULL`, sql`published_at = ${intendedPublishedAt}`, sql`updated_at = ${now}`, sql`version = version + 1`);
1867
+ const duePredicate = requireDue ? sql`AND scheduled_at IS NOT NULL AND scheduled_at <= ${now}` : sql``;
1868
+ let promoted = false;
1869
+ try {
1870
+ promoted = ((await sql`
1871
+ UPDATE ${sql.ref(tableName)}
1872
+ SET ${sql.join(assignments, sql`, `)}
1873
+ WHERE id = ${id}
1874
+ AND deleted_at IS NULL
1875
+ AND version = ${existing.version}
1876
+ AND updated_at = ${existing.updatedAt}
1877
+ AND status = ${existing.status}
1878
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1879
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1880
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1881
+ ${duePredicate}
1882
+ AND EXISTS (
1883
+ SELECT 1 FROM revisions
1884
+ WHERE revisions.id = ${revisionToPublish}
1885
+ AND revisions.collection = ${type}
1886
+ AND revisions.entry_id = ${id}
1887
+ )
1888
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1889
+ } catch (error) {
1890
+ if (isConfirmedStatementFailure(error)) throw error;
1891
+ let observed;
1892
+ try {
1893
+ observed = await this.findById(type, id);
1894
+ } catch (reconciliationError) {
1895
+ throw new Error("Unable to confirm whether content publication completed", { cause: reconciliationError });
1896
+ }
1897
+ if (!observed) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1898
+ promoted = matchesPublication(observed, existing, revisionData, revisionToPublish, intendedSlug, intendedPublishedAt, now);
1899
+ if (!promoted && matchesPublicationFence(observed, existing)) throw error;
1900
+ if (!promoted) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1901
+ }
1902
+ if (!promoted) throw requireDue ? new ScheduledNotDueError() : new ContentMutationConflictError();
1903
+ invalidateCollectionCache(type);
1904
+ notifyRoom({
1905
+ collection: type,
1906
+ id
1907
+ }, ["publishedAt"]);
1908
+ const updated = await this.findById(type, id);
1909
+ if (!updated) throw new Error("Content not found");
1910
+ return updated;
1911
+ } catch (error) {
1912
+ if (provisionalRevisionId) try {
1913
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1914
+ } catch (cleanupError) {
1915
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1916
+ }
1917
+ throw error;
1918
+ }
1919
+ }
1920
+ /**
1921
+ * Unpublish content
1922
+ *
1923
+ * Removes live pointer and cancels any pending schedule, but preserves the
1924
+ * draft and publication date. If no draft exists and `draftFromLive` is set,
1925
+ * creates one from the live version so the content isn't lost. Collections
1926
+ * without revisions save to the columns, and a draft revision would hide
1927
+ * those saves.
1928
+ */
1929
+ async unpublish(type, id, expectedRevision, draftFromLive = true) {
1930
+ const tableName = getTableName(type);
1931
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1932
+ const existing = await this.findById(type, id);
1933
+ if (!existing) throw new EmDashValidationError("Content item not found");
1934
+ assertRevisionPrecondition(existing, expectedRevision);
1935
+ if (existing.status === "draft" && !existing.liveRevisionId && !existing.scheduledAt) return existing;
1936
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1937
+ let provisionalRevisionId = null;
1938
+ try {
1939
+ let draftRevisionId = existing.draftRevisionId;
1940
+ if (draftFromLive && !draftRevisionId && existing.liveRevisionId) {
1941
+ const liveRevision = await revisionRepo.findById(existing.liveRevisionId);
1942
+ if (liveRevision) {
1943
+ const draft = await revisionRepo.create({
1944
+ collection: type,
1945
+ entryId: id,
1946
+ data: liveRevision.data
1947
+ });
1948
+ draftRevisionId = draft.id;
1949
+ provisionalRevisionId = draft.id;
1950
+ }
1951
+ }
1952
+ if (((await sql`
1953
+ UPDATE ${sql.ref(tableName)}
1954
+ SET live_revision_id = NULL,
1955
+ draft_revision_id = ${draftRevisionId},
1956
+ status = 'draft',
1957
+ scheduled_at = NULL,
1958
+ updated_at = ${now},
1959
+ version = version + 1
1960
+ WHERE id = ${id}
1961
+ AND deleted_at IS NULL
1962
+ AND version = ${existing.version}
1963
+ AND updated_at = ${existing.updatedAt}
1964
+ AND status = ${existing.status}
1965
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1966
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1967
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1968
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError();
1969
+ invalidateCollectionCache(type);
1970
+ notifyRoom({
1971
+ collection: type,
1972
+ id
1973
+ });
1974
+ const updated = await this.findById(type, id);
1975
+ if (!updated) throw new Error("Content not found");
1976
+ return updated;
1977
+ } catch (error) {
1978
+ if (provisionalRevisionId) try {
1979
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1980
+ } catch (cleanupError) {
1981
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1982
+ }
1983
+ throw error;
1984
+ }
1985
+ }
1986
+ /**
1987
+ * Set the draft revision pointer for a content item.
1988
+ *
1989
+ * Used by seed/import paths that stage a new revision's data before
1990
+ * promoting it to live via `publish()`.
1991
+ *
1992
+ * Validates that the content item exists and is not soft-deleted, that
1993
+ * the revision exists, and that the revision belongs to the same
1994
+ * collection and entry. Without these checks, a caller could leave the
1995
+ * content row pointing at a missing or unrelated revision.
1996
+ */
1997
+ async setDraftRevision(type, id, revisionId) {
1998
+ const existing = await this.findById(type, id);
1999
+ if (!existing) throw new EmDashValidationError("Content item not found");
2000
+ const revision = await new RevisionRepository(this.db, this.datetimeContexts).findById(revisionId);
2001
+ if (!revision) throw new EmDashValidationError("Revision not found");
2002
+ if (revision.collection !== type || revision.entryId !== id) throw new EmDashValidationError("Revision does not belong to the specified content item");
2003
+ if (!await this.replaceDraftRevision(type, id, revisionId, existing)) throw new ContentMutationConflictError();
2004
+ }
2005
+ async replaceDraftRevision(type, id, revisionId, expected) {
2006
+ return await this.stageDraftRevision(type, id, revisionId, expected) !== null;
2007
+ }
2008
+ /**
2009
+ * `replaceDraftRevision`, returning the `version` and `updatedAt` the entry has after the
2010
+ * update, or null when the entry no longer matches `expected`. Scheduling moves `updatedAt`
2011
+ * without bumping `version`, so the entry's `_rev` can't be derived from `expected`.
2012
+ */
2013
+ async stageDraftRevision(type, id, revisionId, expected) {
2014
+ const tableName = getTableName(type);
2015
+ const row = (await sql`
2016
+ UPDATE ${sql.ref(tableName)}
2017
+ SET draft_revision_id = ${revisionId},
2018
+ version = version + 1
2019
+ WHERE id = ${id}
2020
+ AND deleted_at IS NULL
2021
+ AND version = ${expected.version}
2022
+ AND ${nullableColumnMatch("live_revision_id", expected.liveRevisionId)}
2023
+ AND ${nullableColumnMatch("draft_revision_id", expected.draftRevisionId)}
2024
+ AND EXISTS (
2025
+ SELECT 1 FROM revisions
2026
+ WHERE revisions.id = ${revisionId}
2027
+ AND revisions.collection = ${type}
2028
+ AND revisions.entry_id = ${id}
2029
+ )
2030
+ RETURNING version, updated_at
2031
+ `.execute(this.db)).rows[0];
2032
+ if (!row) return null;
2033
+ notifyRoom({
2034
+ collection: type,
2035
+ id
2036
+ });
2037
+ return {
2038
+ version: row.version,
2039
+ updatedAt: row.updated_at
2040
+ };
2041
+ }
2042
+ /**
2043
+ * Marks the entry's draft revision kept if it is an autosave and the entry still has
2044
+ * `expected`'s `version` and `updatedAt`, in one statement. Changes neither. Resolves to
2045
+ * whether a revision was marked.
2046
+ */
2047
+ async markDraftRevisionKept(type, id, expected) {
2048
+ const tableName = getTableName(type);
2049
+ return (await sql`
2050
+ UPDATE revisions
2051
+ SET kind = NULL
2052
+ WHERE kind = 'autosave'
2053
+ AND id = (
2054
+ SELECT draft_revision_id FROM ${sql.ref(tableName)}
2055
+ WHERE id = ${id}
2056
+ AND deleted_at IS NULL
2057
+ AND version = ${expected.version}
2058
+ AND updated_at = ${expected.updatedAt}
2059
+ )
2060
+ RETURNING id
2061
+ `.execute(this.db)).rows.length > 0;
2062
+ }
2063
+ /**
2064
+ * Discard pending draft changes
2065
+ *
2066
+ * Clears draft_revision_id. The content table columns already hold the
2067
+ * published version, so no data sync is needed.
2068
+ */
2069
+ async discardDraft(type, id, expectedRevision) {
2070
+ const tableName = getTableName(type);
2071
+ const existing = await this.findById(type, id);
2072
+ if (!existing) throw new EmDashValidationError("Content item not found");
2073
+ assertRevisionPrecondition(existing, expectedRevision);
2074
+ if (!existing.draftRevisionId) return existing;
2075
+ if (((await sql`
2076
+ UPDATE ${sql.ref(tableName)}
2077
+ SET draft_revision_id = NULL,
2078
+ version = version + 1
2079
+ WHERE id = ${id}
2080
+ AND deleted_at IS NULL
2081
+ AND version = ${existing.version}
2082
+ AND updated_at = ${existing.updatedAt}
2083
+ AND status = ${existing.status}
2084
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
2085
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
2086
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
2087
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError();
2088
+ notifyRoom({
2089
+ collection: type,
2090
+ id
2091
+ });
2092
+ const updated = await this.findById(type, id);
2093
+ if (!updated) throw new Error("Content not found");
2094
+ return updated;
2095
+ }
2096
+ /**
2097
+ * Count content items with a pending schedule.
2098
+ * Includes both draft-scheduled (status='scheduled') and published
2099
+ * posts with scheduled draft changes (status='published', scheduled_at set).
2100
+ */
2101
+ async countScheduled(type) {
2102
+ const tableName = getTableName(type);
2103
+ const result = await sql`
2104
+ SELECT COUNT(id) as count FROM ${sql.ref(tableName)}
2105
+ WHERE scheduled_at IS NOT NULL
2106
+ AND deleted_at IS NULL
2107
+ `.execute(this.db);
2108
+ return Number(result.rows[0]?.count || 0);
2109
+ }
2110
+ /**
2111
+ * Map database row to ContentItem
2112
+ * Extracts system columns and puts content fields in data
2113
+ * Excludes null values from data to match input semantics
2114
+ */
2115
+ mapRow(type, row) {
2116
+ const data = {};
2117
+ for (const [key, value] of Object.entries(row)) if (!SYSTEM_COLUMNS.has(key) && value !== null) data[key] = deserializeValue(value);
2118
+ return {
2119
+ id: row.id,
2120
+ type,
2121
+ slug: row.slug,
2122
+ status: row.status,
2123
+ data,
2124
+ authorId: row.author_id,
2125
+ primaryBylineId: row.primary_byline_id ?? null,
2126
+ createdAt: row.created_at,
2127
+ updatedAt: row.updated_at,
2128
+ publishedAt: row.published_at,
2129
+ scheduledAt: row.scheduled_at,
2130
+ liveRevisionId: row.live_revision_id ?? null,
2131
+ draftRevisionId: row.draft_revision_id ?? null,
2132
+ version: typeof row.version === "number" ? row.version : 1,
2133
+ locale: row.locale ?? null,
2134
+ translationGroup: row.translation_group ?? null
2135
+ };
2136
+ }
2137
+ normalizeFilterScalar(field, type, value) {
2138
+ if (type === "number" || type === "integer") {
2139
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new EmDashValidationError(`Filter for field "${field}" must use a finite number`);
2140
+ if (type === "integer" && !Number.isInteger(value)) throw new EmDashValidationError(`Filter for field "${field}" must use an integer`);
2141
+ return value;
2142
+ }
2143
+ if (type === "boolean") {
2144
+ if (typeof value !== "boolean") throw new EmDashValidationError(`Filter for field "${field}" must use a boolean`);
2145
+ return value ? 1 : 0;
2146
+ }
2147
+ if (typeof value !== "string") throw new EmDashValidationError(`Filter for field "${field}" must use a string`);
2148
+ if (value.length > MAX_FILTER_STRING_LENGTH) throw new EmDashValidationError(`Filter value for field "${field}" exceeds ${MAX_FILTER_STRING_LENGTH} characters`);
2149
+ if (type === "datetime") try {
2150
+ return normalizeExplicitDatetime(value);
2151
+ } catch {
2152
+ throw new EmDashValidationError(`Filter for datetime field "${field}" must use an ISO 8601 datetime with Z or an explicit offset`);
2153
+ }
2154
+ return value;
2155
+ }
2156
+ normalizeFieldFilter(field, type, value) {
2157
+ if (value === null) return {
2158
+ column: field,
2159
+ kind: "null"
2160
+ };
2161
+ if (typeof value !== "object") return {
2162
+ column: field,
2163
+ kind: "exact",
2164
+ value: this.normalizeFilterScalar(field, type, value)
2165
+ };
2166
+ if (Array.isArray(value)) throw new EmDashValidationError(`Invalid filter for field "${field}"`);
2167
+ const record = value;
2168
+ const keys = Object.keys(record);
2169
+ if (keys.length === 1 && keys[0] === "in") {
2170
+ if (!Array.isArray(record.in) || record.in.length === 0) throw new EmDashValidationError(`IN filter for field "${field}" must not be empty`);
2171
+ if (record.in.length > MAX_IN_FILTER_VALUES) throw new EmDashValidationError(`IN filter for field "${field}" exceeds ${MAX_IN_FILTER_VALUES} values`);
2172
+ return {
2173
+ column: field,
2174
+ kind: "in",
2175
+ values: record.in.map((entry) => this.normalizeFilterScalar(field, type, entry))
2176
+ };
2177
+ }
2178
+ const rangeKeys = new Set([
2179
+ "gt",
2180
+ "gte",
2181
+ "lt",
2182
+ "lte"
2183
+ ]);
2184
+ if (keys.length === 0 || keys.some((key) => !rangeKeys.has(key))) throw new EmDashValidationError(`Invalid filter operator for field "${field}"`);
2185
+ if (type === "boolean") throw new EmDashValidationError(`Boolean field "${field}" does not support range filters`);
2186
+ const bounds = {};
2187
+ for (const key of keys) {
2188
+ if (record[key] === void 0) continue;
2189
+ bounds[key] = this.normalizeFilterScalar(field, type, record[key]);
2190
+ }
2191
+ if (Object.keys(bounds).length === 0) throw new EmDashValidationError(`Range filter for field "${field}" has no bounds`);
2192
+ return {
2193
+ column: field,
2194
+ kind: "range",
2195
+ bounds
2196
+ };
2197
+ }
2198
+ async collectionExists(type) {
2199
+ return await this.db.selectFrom("_emdash_collections").where("slug", "=", type).select("id").executeTakeFirst() !== void 0;
2200
+ }
2201
+ async resolveFieldFilters(type, filters) {
2202
+ const resolvedFilters = filters ?? {};
2203
+ const fields = Object.keys(resolvedFilters);
2204
+ if (fields.length === 0) return [];
2205
+ if (fields.length > MAX_INDEXED_FIELD_FILTERS) {
2206
+ if (!await this.collectionExists(type)) return [];
2207
+ throw new EmDashValidationError(`Content list queries support at most ${MAX_INDEXED_FIELD_FILTERS} indexed field filters`);
2208
+ }
2209
+ const rows = await this.db.selectFrom("_emdash_fields as field").innerJoin("_emdash_collections as collection", "collection.id", "field.collection_id").where("collection.slug", "=", type).where("field.slug", "in", fields).where("field.indexed", "=", 1).select([
2210
+ "field.slug",
2211
+ "field.type",
2212
+ "field.validation"
2213
+ ]).execute();
2214
+ const metadata = new Map(rows.filter((row) => !isStoragelessFieldRow(row)).map((row) => [row.slug, row.type]));
2215
+ if (metadata.size === 0 && !await this.collectionExists(type)) return [];
2216
+ for (const field of fields) try {
2217
+ validateIdentifier(field, "content filter field");
2218
+ } catch {
2219
+ throw new EmDashValidationError(`Invalid content filter field: ${field}`);
2220
+ }
2221
+ const normalized = fields.map((field) => {
2222
+ const fieldType = metadata.get(field);
2223
+ if (!fieldType || !isIndexableFieldType(fieldType)) throw new EmDashValidationError(`Cannot filter by field "${field}". Custom fields must be indexed before filtering.`);
2224
+ return this.normalizeFieldFilter(field, fieldType, resolvedFilters[field]);
2225
+ });
2226
+ if (normalized.reduce((total, filter) => {
2227
+ if (filter.kind === "null") return total;
2228
+ if (filter.kind === "exact") return total + 1;
2229
+ if (filter.kind === "in") return total + filter.values.length;
2230
+ return total + Object.keys(filter.bounds).length;
2231
+ }, 0) > SQL_BATCH_SIZE) throw new EmDashValidationError(`Indexed field filters have a total operand budget of ${SQL_BATCH_SIZE}`);
2232
+ return normalized;
2233
+ }
2234
+ applyFieldFilters(query, filters) {
2235
+ let next = query;
2236
+ for (const filter of filters) {
2237
+ const column = sql.ref(filter.column);
2238
+ const isPresent = sql`${column} IS NOT NULL`;
2239
+ if (filter.kind === "null") {
2240
+ next = next.where(() => sql`(${isPresent}) = FALSE AND ${column} IS NULL`);
2241
+ continue;
2242
+ }
2243
+ if (filter.kind === "exact") {
2244
+ next = next.where(() => sql`(${isPresent}) = TRUE AND ${column} = ${filter.value}`);
2245
+ continue;
2246
+ }
2247
+ if (filter.kind === "in") {
2248
+ const values = sql.join(filter.values.map((value) => sql`${value}`), sql`, `);
2249
+ next = next.where(() => sql`(${isPresent}) = TRUE AND ${column} IN (${values})`);
2250
+ continue;
2251
+ }
2252
+ next = next.where(() => sql`(${isPresent}) = TRUE`);
2253
+ if (filter.bounds.gt !== void 0) next = next.where(() => sql`${column} > ${filter.bounds.gt}`);
2254
+ if (filter.bounds.gte !== void 0) next = next.where(() => sql`${column} >= ${filter.bounds.gte}`);
2255
+ if (filter.bounds.lt !== void 0) next = next.where(() => sql`${column} < ${filter.bounds.lt}`);
2256
+ if (filter.bounds.lte !== void 0) next = next.where(() => sql`${column} <= ${filter.bounds.lte}`);
2257
+ }
2258
+ return next;
2259
+ }
2260
+ /**
2261
+ * Map order field names to database columns.
2262
+ * Only allows known fields to prevent column enumeration via crafted orderBy values.
2263
+ */
2264
+ mapOrderField(field, sortableExtras = []) {
2265
+ const mapped = ORDER_FIELD_COLUMNS[field];
2266
+ if (mapped) return mapped;
2267
+ if (sortableExtras.includes(field)) {
2268
+ validateIdentifier(field, "order field");
2269
+ return field;
2270
+ }
2271
+ throw new EmDashValidationError(`Invalid order field: ${field}`);
2272
+ }
2273
+ async resolveOrderField(type, field, sortableExtras = []) {
2274
+ try {
2275
+ return {
2276
+ column: this.mapOrderField(field, sortableExtras),
2277
+ indexedCustomField: false
2278
+ };
2279
+ } catch (error) {
2280
+ if (!(error instanceof EmDashValidationError)) throw error;
2281
+ }
2282
+ const customField = await this.db.selectFrom("_emdash_collections as collection").leftJoin("_emdash_fields as field", (join) => join.onRef("field.collection_id", "=", "collection.id").on("field.slug", "=", field).on("field.indexed", "=", 1)).where("collection.slug", "=", type).select(["collection.id as collectionId", "field.slug as fieldSlug"]).executeTakeFirst();
2283
+ if (!customField) throw new ContentCollectionNotFoundError(type);
2284
+ if (!customField.fieldSlug) throw new EmDashValidationError(`Invalid order field: ${field}. Custom fields must be indexed before sorting.`);
2285
+ validateIdentifier(customField.fieldSlug, "content order field");
2286
+ return {
2287
+ column: customField.fieldSlug,
2288
+ indexedCustomField: true
2289
+ };
2290
+ }
2291
+ };
2292
+
2293
+ //#endregion
2294
+ export { isSystemOrderField as a, findTypesWithDueContent as i, content_exports as n, keepKnownFields as o, findNextScheduledAt as r, staleStoredKeys as s, ContentRepository as t };
2295
+ //# sourceMappingURL=content-2gjSbGP3.mjs.map