emdash 1.3.1 → 1.4.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 (1338) hide show
  1. package/dist/action-token-SK8zyN7w.mjs +26 -0
  2. package/dist/action-token-SK8zyN7w.mjs.map +1 -0
  3. package/dist/activation-CGlyigmg.mjs +387 -0
  4. package/dist/activation-CGlyigmg.mjs.map +1 -0
  5. package/dist/adapters-D9a1PfqH.d.mts +173 -0
  6. package/dist/adapters-D9a1PfqH.d.mts.map +1 -0
  7. package/dist/after-32yNRvd2.mjs +99 -0
  8. package/dist/after-32yNRvd2.mjs.map +1 -0
  9. package/dist/allowed-origins-CEug-p0t.mjs +116 -0
  10. package/dist/allowed-origins-CEug-p0t.mjs.map +1 -0
  11. package/dist/api/route-utils.d.mts +4 -4
  12. package/dist/api/route-utils.mjs +52 -53
  13. package/dist/api/route-utils.mjs.map +1 -1
  14. package/dist/api/schemas/index.d.mts +1 -1
  15. package/dist/api/schemas/index.mjs +9 -9
  16. package/dist/api--PYoyeTo.mjs +5098 -0
  17. package/dist/api--PYoyeTo.mjs.map +1 -0
  18. package/dist/api-tokens-DqSlkDVI.mjs +9 -0
  19. package/dist/api-tokens-DqSlkDVI.mjs.map +1 -0
  20. package/dist/api-tokens-GNCsIegW.mjs +173 -0
  21. package/dist/api-tokens-GNCsIegW.mjs.map +1 -0
  22. package/dist/apply-DVnupNeS.mjs +1760 -0
  23. package/dist/apply-DVnupNeS.mjs.map +1 -0
  24. package/dist/approvals-DTtYSB27.mjs +460 -0
  25. package/dist/approvals-DTtYSB27.mjs.map +1 -0
  26. package/dist/artifact-fetch-DIh7iyOV.mjs +659 -0
  27. package/dist/artifact-fetch-DIh7iyOV.mjs.map +1 -0
  28. package/dist/artifacts-Dvdp2KK-.mjs +323 -0
  29. package/dist/artifacts-Dvdp2KK-.mjs.map +1 -0
  30. package/dist/astro/index.d.mts +14 -13
  31. package/dist/astro/index.d.mts.map +1 -1
  32. package/dist/astro/index.mjs +52 -12
  33. package/dist/astro/index.mjs.map +1 -1
  34. package/dist/astro/middleware/auth.d.mts +12 -11
  35. package/dist/astro/middleware/auth.d.mts.map +1 -1
  36. package/dist/astro/middleware/auth.mjs +13 -11
  37. package/dist/astro/middleware/auth.mjs.map +1 -1
  38. package/dist/astro/middleware/media-usage-write-fence.mjs +5 -5
  39. package/dist/astro/middleware/redirect.mjs +17 -17
  40. package/dist/astro/middleware/request-context.mjs +12 -7
  41. package/dist/astro/middleware/request-context.mjs.map +1 -1
  42. package/dist/astro/middleware/setup.mjs +1 -1
  43. package/dist/astro/middleware.d.mts +12 -11
  44. package/dist/astro/middleware.d.mts.map +1 -1
  45. package/dist/astro/middleware.mjs +116 -116
  46. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +13 -13
  47. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +13 -13
  48. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +6 -6
  49. package/dist/astro/routes/api/admin/api-tokens/index.mjs +7 -7
  50. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +5 -5
  51. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +15 -15
  52. package/dist/astro/routes/api/admin/byline-fields/index.mjs +15 -15
  53. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +15 -15
  54. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +23 -24
  55. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs.map +1 -1
  56. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +23 -24
  57. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs.map +1 -1
  58. package/dist/astro/routes/api/admin/bylines/index.mjs +23 -24
  59. package/dist/astro/routes/api/admin/bylines/index.mjs.map +1 -1
  60. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +19 -19
  61. package/dist/astro/routes/api/admin/comments/_id_.mjs +8 -8
  62. package/dist/astro/routes/api/admin/comments/bulk.mjs +18 -18
  63. package/dist/astro/routes/api/admin/comments/counts.mjs +8 -8
  64. package/dist/astro/routes/api/admin/comments/index.mjs +18 -18
  65. package/dist/astro/routes/api/admin/core-update.mjs +7 -7
  66. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +5 -5
  67. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +4 -4
  68. package/dist/astro/routes/api/admin/media-usage/activation.mjs +20 -20
  69. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +21 -21
  70. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +21 -21
  71. package/dist/astro/routes/api/admin/media-usage/progress.mjs +24 -24
  72. package/dist/astro/routes/api/admin/media-usage/repair.mjs +30 -30
  73. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +21 -21
  74. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +21 -21
  75. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +5 -5
  76. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +5 -5
  77. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +8 -8
  78. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +8 -8
  79. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +74 -75
  80. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  81. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +6 -6
  82. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +73 -74
  83. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
  84. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +73 -74
  85. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  86. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +84 -85
  87. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  88. package/dist/astro/routes/api/admin/plugins/index.mjs +74 -75
  89. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  90. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +6 -6
  91. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +73 -74
  92. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  93. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +83 -84
  94. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  95. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +73 -74
  96. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  97. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +73 -74
  98. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  99. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +85 -86
  100. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  101. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +8 -8
  102. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +75 -76
  103. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  104. package/dist/astro/routes/api/admin/plugins/registry/publisher-handle.mjs +6 -6
  105. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +74 -75
  106. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs.map +1 -1
  107. package/dist/astro/routes/api/admin/plugins/updates.mjs +73 -74
  108. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  109. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs +5 -5
  110. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +73 -74
  111. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  112. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +6 -6
  113. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +73 -74
  114. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  115. package/dist/astro/routes/api/admin/transfer/_...path_.mjs +3 -3
  116. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs +40 -41
  117. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs.map +1 -1
  118. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs +40 -41
  119. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs.map +1 -1
  120. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs +42 -43
  121. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs.map +1 -1
  122. package/dist/astro/routes/api/admin/transfer/capabilities.mjs +42 -43
  123. package/dist/astro/routes/api/admin/transfer/capabilities.mjs.map +1 -1
  124. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs +42 -43
  125. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs.map +1 -1
  126. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs +43 -44
  127. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs.map +1 -1
  128. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs +43 -44
  129. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs.map +1 -1
  130. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs +42 -43
  131. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs.map +1 -1
  132. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs +43 -44
  133. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs.map +1 -1
  134. package/dist/astro/routes/api/admin/transfer/exports/index.mjs +44 -45
  135. package/dist/astro/routes/api/admin/transfer/exports/index.mjs.map +1 -1
  136. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs +42 -43
  137. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs.map +1 -1
  138. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs +42 -43
  139. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs.map +1 -1
  140. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs +44 -45
  141. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs.map +1 -1
  142. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs +42 -43
  143. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs.map +1 -1
  144. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs +44 -45
  145. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs.map +1 -1
  146. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs +42 -43
  147. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs.map +1 -1
  148. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs +42 -43
  149. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs.map +1 -1
  150. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs +44 -45
  151. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs.map +1 -1
  152. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs +42 -43
  153. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs.map +1 -1
  154. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs +42 -43
  155. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs.map +1 -1
  156. package/dist/astro/routes/api/admin/transfer/imports/index.mjs +44 -45
  157. package/dist/astro/routes/api/admin/transfer/imports/index.mjs.map +1 -1
  158. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +3 -3
  159. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +3 -3
  160. package/dist/astro/routes/api/admin/users/_id_/index.mjs +13 -13
  161. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +5 -5
  162. package/dist/astro/routes/api/admin/users/index.mjs +13 -13
  163. package/dist/astro/routes/api/auth/dev-bypass.mjs +5 -5
  164. package/dist/astro/routes/api/auth/handover.mjs +6 -6
  165. package/dist/astro/routes/api/auth/invite/accept.mjs +3 -3
  166. package/dist/astro/routes/api/auth/invite/complete.mjs +19 -19
  167. package/dist/astro/routes/api/auth/invite/index.mjs +15 -15
  168. package/dist/astro/routes/api/auth/invite/register-options.mjs +16 -16
  169. package/dist/astro/routes/api/auth/logout.mjs +4 -4
  170. package/dist/astro/routes/api/auth/magic-link/send.mjs +18 -18
  171. package/dist/astro/routes/api/auth/magic-link/verify.mjs +15 -15
  172. package/dist/astro/routes/api/auth/me.mjs +14 -14
  173. package/dist/astro/routes/api/auth/mode.mjs +4 -4
  174. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +9 -9
  175. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  176. package/dist/astro/routes/api/auth/passkey/_id_.mjs +13 -13
  177. package/dist/astro/routes/api/auth/passkey/index.mjs +3 -3
  178. package/dist/astro/routes/api/auth/passkey/options.mjs +19 -19
  179. package/dist/astro/routes/api/auth/passkey/register/options.mjs +16 -16
  180. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +17 -17
  181. package/dist/astro/routes/api/auth/passkey/verify.mjs +19 -19
  182. package/dist/astro/routes/api/auth/signup/complete.mjs +19 -19
  183. package/dist/astro/routes/api/auth/signup/request.mjs +17 -17
  184. package/dist/astro/routes/api/auth/signup/verify.mjs +3 -3
  185. package/dist/astro/routes/api/calendar.mjs +14 -14
  186. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +14 -14
  187. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +20 -20
  188. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +4 -4
  189. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +18 -18
  190. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +4 -4
  191. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +17 -17
  192. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +5 -5
  193. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs +10 -10
  194. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +33 -33
  195. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +18 -18
  196. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +35 -35
  197. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +35 -35
  198. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +5 -5
  199. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +4 -4
  200. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +18 -18
  201. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +26 -26
  202. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +4 -4
  203. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +18 -18
  204. package/dist/astro/routes/api/content/_collection_/_id_.mjs +18 -18
  205. package/dist/astro/routes/api/content/_collection_/authors.mjs +4 -4
  206. package/dist/astro/routes/api/content/_collection_/index.mjs +14 -14
  207. package/dist/astro/routes/api/content/_collection_/trash.mjs +14 -14
  208. package/dist/astro/routes/api/dashboard.mjs +11 -11
  209. package/dist/astro/routes/api/dev/emails.mjs +4 -4
  210. package/dist/astro/routes/api/dev/scheduled-tasks.mjs +112 -112
  211. package/dist/astro/routes/api/health.mjs +5 -5
  212. package/dist/astro/routes/api/import/probe.d.mts +3 -2
  213. package/dist/astro/routes/api/import/probe.d.mts.map +1 -1
  214. package/dist/astro/routes/api/import/probe.mjs +28 -28
  215. package/dist/astro/routes/api/import/wordpress/analyze.d.mts +4 -3
  216. package/dist/astro/routes/api/import/wordpress/analyze.d.mts.map +1 -1
  217. package/dist/astro/routes/api/import/wordpress/analyze.mjs +6 -28
  218. package/dist/astro/routes/api/import/wordpress/analyze.mjs.map +1 -1
  219. package/dist/astro/routes/api/import/wordpress/execute.d.mts +12 -11
  220. package/dist/astro/routes/api/import/wordpress/execute.d.mts.map +1 -1
  221. package/dist/astro/routes/api/import/wordpress/execute.mjs +26 -27
  222. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  223. package/dist/astro/routes/api/import/wordpress/media.d.mts +12 -11
  224. package/dist/astro/routes/api/import/wordpress/media.d.mts.map +1 -1
  225. package/dist/astro/routes/api/import/wordpress/media.mjs +18 -18
  226. package/dist/astro/routes/api/import/wordpress/prepare.mjs +19 -19
  227. package/dist/astro/routes/api/import/wordpress/prepare.mjs.map +1 -1
  228. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +13 -12
  229. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts.map +1 -1
  230. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +29 -29
  231. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +28 -28
  232. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +12 -11
  233. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts.map +1 -1
  234. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +38 -39
  235. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  236. package/dist/astro/routes/api/manifest.mjs +5 -5
  237. package/dist/astro/routes/api/mcp.mjs +96 -97
  238. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  239. package/dist/astro/routes/api/media/_id_/confirm.mjs +19 -19
  240. package/dist/astro/routes/api/media/_id_/replace.mjs +15 -15
  241. package/dist/astro/routes/api/media/_id_/upload.mjs +8 -8
  242. package/dist/astro/routes/api/media/_id_/usage.mjs +32 -32
  243. package/dist/astro/routes/api/media/_id_.mjs +30 -30
  244. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs +5 -5
  245. package/dist/astro/routes/api/media/file/_...key_.d.mts.map +1 -1
  246. package/dist/astro/routes/api/media/file/_...key_.mjs +57 -11
  247. package/dist/astro/routes/api/media/file/_...key_.mjs.map +1 -1
  248. package/dist/astro/routes/api/media/folders/_id_.mjs +15 -15
  249. package/dist/astro/routes/api/media/folders/index.mjs +15 -15
  250. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +4 -4
  251. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +4 -4
  252. package/dist/astro/routes/api/media/providers/index.mjs +4 -4
  253. package/dist/astro/routes/api/media/upload-url.mjs +17 -17
  254. package/dist/astro/routes/api/media.mjs +34 -34
  255. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +20 -19
  256. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  257. package/dist/astro/routes/api/menus/_name_/items.mjs +20 -19
  258. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  259. package/dist/astro/routes/api/menus/_name_/reorder.mjs +20 -19
  260. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  261. package/dist/astro/routes/api/menus/_name_/translations.mjs +20 -19
  262. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  263. package/dist/astro/routes/api/menus/_name_.mjs +20 -19
  264. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  265. package/dist/astro/routes/api/menus/index.mjs +20 -19
  266. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  267. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  268. package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -7
  269. package/dist/astro/routes/api/oauth/device/code.mjs +11 -11
  270. package/dist/astro/routes/api/oauth/device/token.mjs +10 -10
  271. package/dist/astro/routes/api/oauth/register.mjs +7 -7
  272. package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -7
  273. package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -7
  274. package/dist/astro/routes/api/oauth/token.d.mts.map +1 -1
  275. package/dist/astro/routes/api/oauth/token.mjs +8 -8
  276. package/dist/astro/routes/api/oauth/token.mjs.map +1 -1
  277. package/dist/astro/routes/api/openapi.json.mjs +20 -20
  278. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +10 -10
  279. package/dist/astro/routes/api/redirects/404s/index.mjs +21 -21
  280. package/dist/astro/routes/api/redirects/404s/summary.mjs +21 -21
  281. package/dist/astro/routes/api/redirects/_id_.mjs +22 -22
  282. package/dist/astro/routes/api/redirects/index.mjs +22 -22
  283. package/dist/astro/routes/api/relations/_id_/index.mjs +35 -35
  284. package/dist/astro/routes/api/relations/index.mjs +35 -35
  285. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +4 -4
  286. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +17 -17
  287. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs +73 -74
  288. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs.map +1 -1
  289. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs +73 -74
  290. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs.map +1 -1
  291. package/dist/astro/routes/api/schema/block-types/index.mjs +73 -74
  292. package/dist/astro/routes/api/schema/block-types/index.mjs.map +1 -1
  293. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +73 -74
  294. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  295. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +73 -74
  296. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  297. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +73 -74
  298. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  299. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +73 -74
  300. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  301. package/dist/astro/routes/api/schema/collections/index.mjs +73 -74
  302. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  303. package/dist/astro/routes/api/schema/collections/reorder.mjs +73 -74
  304. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  305. package/dist/astro/routes/api/schema/index.mjs +17 -17
  306. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +73 -74
  307. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  308. package/dist/astro/routes/api/schema/orphans/index.mjs +73 -74
  309. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  310. package/dist/astro/routes/api/search/enable.mjs +20 -19
  311. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  312. package/dist/astro/routes/api/search/index.mjs +19 -18
  313. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  314. package/dist/astro/routes/api/search/rebuild.mjs +20 -19
  315. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  316. package/dist/astro/routes/api/search/stats.mjs +10 -9
  317. package/dist/astro/routes/api/search/stats.mjs.map +1 -1
  318. package/dist/astro/routes/api/search/suggest.mjs +19 -18
  319. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  320. package/dist/astro/routes/api/sections/_slug_.mjs +19 -18
  321. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  322. package/dist/astro/routes/api/sections/index.mjs +19 -18
  323. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  324. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +7 -7
  325. package/dist/astro/routes/api/settings/backups/archives/index.mjs +7 -7
  326. package/dist/astro/routes/api/settings/backups/export.mjs +7 -7
  327. package/dist/astro/routes/api/settings/backups/index.mjs +8 -8
  328. package/dist/astro/routes/api/settings/domain-notify.mjs +9 -9
  329. package/dist/astro/routes/api/settings/domain.mjs +21 -21
  330. package/dist/astro/routes/api/settings/email.mjs +5 -5
  331. package/dist/astro/routes/api/settings.mjs +27 -27
  332. package/dist/astro/routes/api/setup/admin-verify.mjs +22 -22
  333. package/dist/astro/routes/api/setup/admin.mjs +17 -17
  334. package/dist/astro/routes/api/setup/dev-bypass.mjs +45 -46
  335. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  336. package/dist/astro/routes/api/setup/dev-reset.mjs +3 -3
  337. package/dist/astro/routes/api/setup/index.mjs +51 -52
  338. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  339. package/dist/astro/routes/api/setup/status.mjs +5 -5
  340. package/dist/astro/routes/api/site/domain-proof.mjs +15 -15
  341. package/dist/astro/routes/api/snapshot.mjs +10 -10
  342. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +25 -25
  343. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +25 -25
  344. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +25 -25
  345. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +25 -25
  346. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +23 -23
  347. package/dist/astro/routes/api/taxonomies/_name_.mjs +25 -25
  348. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs +36 -36
  349. package/dist/astro/routes/api/taxonomies/index.mjs +25 -25
  350. package/dist/astro/routes/api/themes/preview.mjs +7 -7
  351. package/dist/astro/routes/api/typegen.mjs +5 -5
  352. package/dist/astro/routes/api/visual-editing/action-token.mjs +7 -7
  353. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs +21 -21
  354. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs +3 -3
  355. package/dist/astro/routes/api/well-known/auth.mjs +1 -1
  356. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  357. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  358. package/dist/astro/routes/api/widget-areas/_name_/reorder.d.mts.map +1 -1
  359. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +28 -17
  360. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs.map +1 -1
  361. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.d.mts.map +1 -1
  362. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +24 -20
  363. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs.map +1 -1
  364. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +23 -20
  365. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs.map +1 -1
  366. package/dist/astro/routes/api/widget-areas/_name_.mjs +13 -10
  367. package/dist/astro/routes/api/widget-areas/_name_.mjs.map +1 -1
  368. package/dist/astro/routes/api/widget-areas/index.mjs +23 -20
  369. package/dist/astro/routes/api/widget-areas/index.mjs.map +1 -1
  370. package/dist/astro/routes/api/widget-components.mjs +4 -4
  371. package/dist/astro/routes/robots.txt.mjs +14 -14
  372. package/dist/astro/routes/sitemap-_collection_.xml.mjs +17 -17
  373. package/dist/astro/routes/sitemap.xml.mjs +15 -15
  374. package/dist/astro/types.d.mts +21 -19
  375. package/dist/astro/types.d.mts.map +1 -1
  376. package/dist/auth/providers/github.d.mts +1 -1
  377. package/dist/auth/providers/google.d.mts +1 -1
  378. package/dist/auth/providers/microsoft.d.mts +1 -1
  379. package/dist/authoritative-records-CQlB3JzE.mjs +5183 -0
  380. package/dist/authoritative-records-CQlB3JzE.mjs.map +1 -0
  381. package/dist/authorize-NJgp8kLI.mjs +74 -0
  382. package/dist/authorize-NJgp8kLI.mjs.map +1 -0
  383. package/dist/backup-8rPSJ28a.mjs +246 -0
  384. package/dist/backup-8rPSJ28a.mjs.map +1 -0
  385. package/dist/block-types-BbOrfnWs.mjs +132 -0
  386. package/dist/block-types-BbOrfnWs.mjs.map +1 -0
  387. package/dist/block-values-Dg0-8PPS.mjs +215 -0
  388. package/dist/block-values-Dg0-8PPS.mjs.map +1 -0
  389. package/dist/byline-DHJS-GGb.mjs +994 -0
  390. package/dist/byline-DHJS-GGb.mjs.map +1 -0
  391. package/dist/byline-fields-CiR8FvvF.mjs +280 -0
  392. package/dist/byline-fields-CiR8FvvF.mjs.map +1 -0
  393. package/dist/byline-fields-D6KYsEa7.mjs +123 -0
  394. package/dist/byline-fields-D6KYsEa7.mjs.map +1 -0
  395. package/dist/bylines-Bsg5cH4S.mjs +234 -0
  396. package/dist/bylines-Bsg5cH4S.mjs.map +1 -0
  397. package/dist/bylines-f_ZEc6Sn.mjs +150 -0
  398. package/dist/bylines-f_ZEc6Sn.mjs.map +1 -0
  399. package/dist/cache-5DHbpEWu.mjs +151 -0
  400. package/dist/cache-5DHbpEWu.mjs.map +1 -0
  401. package/dist/canonical-BudtH-Fx.mjs +174 -0
  402. package/dist/canonical-BudtH-Fx.mjs.map +1 -0
  403. package/dist/capture-triggers-BezAvWcB.mjs +362 -0
  404. package/dist/capture-triggers-BezAvWcB.mjs.map +1 -0
  405. package/dist/challenge-store-B1C0V4b3.mjs +51 -0
  406. package/dist/challenge-store-B1C0V4b3.mjs.map +1 -0
  407. package/dist/checksum-CEqvfxGX.mjs +162 -0
  408. package/dist/checksum-CEqvfxGX.mjs.map +1 -0
  409. package/dist/chrome-tags-BIKBMZYO.mjs +24 -0
  410. package/dist/chrome-tags-BIKBMZYO.mjs.map +1 -0
  411. package/dist/chunks-DiW8VMwz.mjs +25 -0
  412. package/dist/chunks-DiW8VMwz.mjs.map +1 -0
  413. package/dist/cli/index.mjs +52 -53
  414. package/dist/cli/index.mjs.map +1 -1
  415. package/dist/client/index.d.mts +46 -46
  416. package/dist/client/index.mjs +2 -2
  417. package/dist/collection-slugs-cache-DIrLjqH-.mjs +91 -0
  418. package/dist/collection-slugs-cache-DIrLjqH-.mjs.map +1 -0
  419. package/dist/comment-DB74Zpa4.mjs +335 -0
  420. package/dist/comment-DB74Zpa4.mjs.map +1 -0
  421. package/dist/comment-reaction-BScxIWUn.mjs +85 -0
  422. package/dist/comment-reaction-BScxIWUn.mjs.map +1 -0
  423. package/dist/comments-Cor_zKml.mjs +195 -0
  424. package/dist/comments-Cor_zKml.mjs.map +1 -0
  425. package/dist/comments-yiRFx3w5.mjs +99 -0
  426. package/dist/comments-yiRFx3w5.mjs.map +1 -0
  427. package/dist/components-Brp__9xo.mjs +112 -0
  428. package/dist/components-Brp__9xo.mjs.map +1 -0
  429. package/dist/config-D44_8G9J.d.mts +41 -0
  430. package/dist/config-D44_8G9J.d.mts.map +1 -0
  431. package/dist/config-DBU6iUQB.mjs +228 -0
  432. package/dist/config-DBU6iUQB.mjs.map +1 -0
  433. package/dist/config-sDhZvkLR.d.mts +6835 -0
  434. package/dist/config-sDhZvkLR.d.mts.map +1 -0
  435. package/dist/connection-BtEN_lP9.mjs +36 -0
  436. package/dist/connection-BtEN_lP9.mjs.map +1 -0
  437. package/dist/content-BKHUVsE5.mjs +2112 -0
  438. package/dist/content-BKHUVsE5.mjs.map +1 -0
  439. package/dist/content-list-query-ByP4jRpZ.d.mts +26 -0
  440. package/dist/content-list-query-ByP4jRpZ.d.mts.map +1 -0
  441. package/dist/content-policy-BmE0MPZY.mjs +46 -0
  442. package/dist/content-policy-BmE0MPZY.mjs.map +1 -0
  443. package/dist/content-repair-Ukdxoq-R.mjs +442 -0
  444. package/dist/content-repair-Ukdxoq-R.mjs.map +1 -0
  445. package/dist/context-CzjejcsE.mjs +2089 -0
  446. package/dist/context-CzjejcsE.mjs.map +1 -0
  447. package/dist/credits-BKREepht.mjs +110 -0
  448. package/dist/credits-BKREepht.mjs.map +1 -0
  449. package/dist/cron-D7obTIfk.mjs +306 -0
  450. package/dist/cron-D7obTIfk.mjs.map +1 -0
  451. package/dist/dashboard-ynr1qJWM.mjs +168 -0
  452. package/dist/dashboard-ynr1qJWM.mjs.map +1 -0
  453. package/dist/db/index.d.mts +3 -3
  454. package/dist/db/index.mjs +2 -2
  455. package/dist/db/libsql-migrations.d.mts +1 -1
  456. package/dist/db/libsql-migrations.mjs +5 -5
  457. package/dist/db/libsql.d.mts +1 -1
  458. package/dist/db/postgres-migrations.d.mts +1 -1
  459. package/dist/db/postgres-migrations.mjs +5 -5
  460. package/dist/db/postgres.d.mts +1 -1
  461. package/dist/db/sqlite-migrations.d.mts +1 -1
  462. package/dist/db/sqlite-migrations.mjs +5 -5
  463. package/dist/db/sqlite.d.mts +1 -1
  464. package/dist/db/sqlite.mjs +1 -1
  465. package/dist/default-C0W-PhAp.mjs +81 -0
  466. package/dist/default-C0W-PhAp.mjs.map +1 -0
  467. package/dist/deferred-tasks-wlMFJL95.d.mts +10 -0
  468. package/dist/deferred-tasks-wlMFJL95.d.mts.map +1 -0
  469. package/dist/dev-typegen-EBni_pOQ.mjs +29 -0
  470. package/dist/dev-typegen-EBni_pOQ.mjs.map +1 -0
  471. package/dist/device-flow-D1U392GC.mjs +519 -0
  472. package/dist/device-flow-D1U392GC.mjs.map +1 -0
  473. package/dist/dialect-helpers-B1XN2HGB.mjs +314 -0
  474. package/dist/dialect-helpers-B1XN2HGB.mjs.map +1 -0
  475. package/dist/digest-DJ1tHCgy.mjs +194 -0
  476. package/dist/digest-DJ1tHCgy.mjs.map +1 -0
  477. package/dist/direct-executor-Bs2g0ake.mjs +117 -0
  478. package/dist/direct-executor-Bs2g0ake.mjs.map +1 -0
  479. package/dist/dist-BUmWMTbN.mjs +810 -0
  480. package/dist/dist-BUmWMTbN.mjs.map +1 -0
  481. package/dist/email-console-FFVJWb9N.mjs +50 -0
  482. package/dist/email-console-FFVJWb9N.mjs.map +1 -0
  483. package/dist/email-locale-Bs3HFdnq.mjs +25 -0
  484. package/dist/email-locale-Bs3HFdnq.mjs.map +1 -0
  485. package/dist/emdash-runtime-C8T-pZpS.mjs +4425 -0
  486. package/dist/emdash-runtime-C8T-pZpS.mjs.map +1 -0
  487. package/dist/enrich-DFlfnd3u.mjs +194 -0
  488. package/dist/enrich-DFlfnd3u.mjs.map +1 -0
  489. package/dist/entry-lock-BulbgPBX.d.mts +4568 -0
  490. package/dist/entry-lock-BulbgPBX.d.mts.map +1 -0
  491. package/dist/entry-lock-CRVmruM0.mjs +1211 -0
  492. package/dist/entry-lock-CRVmruM0.mjs.map +1 -0
  493. package/dist/entry-lock-D-zJQ4q6.mjs +163 -0
  494. package/dist/entry-lock-D-zJQ4q6.mjs.map +1 -0
  495. package/dist/entry-locks-CJ9uhqg1.mjs +167 -0
  496. package/dist/entry-locks-CJ9uhqg1.mjs.map +1 -0
  497. package/dist/env-types-BE3bCvfP.mjs +38 -0
  498. package/dist/env-types-BE3bCvfP.mjs.map +1 -0
  499. package/dist/error-BCMgPxdn.mjs +90 -0
  500. package/dist/error-BCMgPxdn.mjs.map +1 -0
  501. package/dist/errors-8gJqv-XV.mjs +492 -0
  502. package/dist/errors-8gJqv-XV.mjs.map +1 -0
  503. package/dist/errors-B4f4It-2.mjs +120 -0
  504. package/dist/errors-B4f4It-2.mjs.map +1 -0
  505. package/dist/escape-lsNq38PP.mjs +9 -0
  506. package/dist/escape-lsNq38PP.mjs.map +1 -0
  507. package/dist/fence-Dagicj14.mjs +162 -0
  508. package/dist/fence-Dagicj14.mjs.map +1 -0
  509. package/dist/field-map-BSXdNGt5.mjs +84 -0
  510. package/dist/field-map-BSXdNGt5.mjs.map +1 -0
  511. package/dist/fts-manager-6861qcwk.mjs +489 -0
  512. package/dist/fts-manager-6861qcwk.mjs.map +1 -0
  513. package/dist/gc-CNkXB3mE.mjs +75 -0
  514. package/dist/gc-CNkXB3mE.mjs.map +1 -0
  515. package/dist/hash-BJaeek87.mjs +37 -0
  516. package/dist/hash-BJaeek87.mjs.map +1 -0
  517. package/dist/hreflang-8dUOJAPJ.d.mts +50 -0
  518. package/dist/hreflang-8dUOJAPJ.d.mts.map +1 -0
  519. package/dist/hreflang-BW5A4FLK.mjs +105 -0
  520. package/dist/hreflang-BW5A4FLK.mjs.map +1 -0
  521. package/dist/http-route-dispatch-rXKvTNm9.mjs +342 -0
  522. package/dist/http-route-dispatch-rXKvTNm9.mjs.map +1 -0
  523. package/dist/identity-CPRRSovU.mjs +35 -0
  524. package/dist/identity-CPRRSovU.mjs.map +1 -0
  525. package/dist/import-yVbfPyfd.mjs +2126 -0
  526. package/dist/import-yVbfPyfd.mjs.map +1 -0
  527. package/dist/index-VM7Fzxwe.d.mts +260 -0
  528. package/dist/index-VM7Fzxwe.d.mts.map +1 -0
  529. package/dist/index.d.mts +23 -22
  530. package/dist/index.mjs +104 -105
  531. package/dist/install-finalization-RU6VrHOX.mjs +58 -0
  532. package/dist/install-finalization-RU6VrHOX.mjs.map +1 -0
  533. package/dist/json-recordset-D0WhN2UA.mjs +12 -0
  534. package/dist/json-recordset-D0WhN2UA.mjs.map +1 -0
  535. package/dist/json-schema-v_D_pPNG.mjs +15 -0
  536. package/dist/json-schema-v_D_pPNG.mjs.map +1 -0
  537. package/dist/keys-CifIkT0N.mjs +61 -0
  538. package/dist/keys-CifIkT0N.mjs.map +1 -0
  539. package/dist/kinds-B_Qcl5pz.mjs +974 -0
  540. package/dist/kinds-B_Qcl5pz.mjs.map +1 -0
  541. package/dist/lifecycle-B8d7Rdqx.mjs +25 -0
  542. package/dist/lifecycle-B8d7Rdqx.mjs.map +1 -0
  543. package/dist/load-D4xtzm6h.mjs +28 -0
  544. package/dist/load-D4xtzm6h.mjs.map +1 -0
  545. package/dist/loader-DhnedqY4.mjs +1478 -0
  546. package/dist/loader-DhnedqY4.mjs.map +1 -0
  547. package/dist/loops-B2YS-Zzr.mjs +205 -0
  548. package/dist/loops-B2YS-Zzr.mjs.map +1 -0
  549. package/dist/manifest-builder-g1FLviel.mjs +196 -0
  550. package/dist/manifest-builder-g1FLviel.mjs.map +1 -0
  551. package/dist/manifest-schema-DNb4XmTS.mjs +497 -0
  552. package/dist/manifest-schema-DNb4XmTS.mjs.map +1 -0
  553. package/dist/marketplace-CqbgeIa7.mjs +257 -0
  554. package/dist/marketplace-CqbgeIa7.mjs.map +1 -0
  555. package/dist/media/image-endpoint.mjs +1 -1
  556. package/dist/media/index.d.mts +1 -1
  557. package/dist/media/index.mjs +3 -3
  558. package/dist/media/local-runtime.d.mts +14 -13
  559. package/dist/media/local-runtime.d.mts.map +1 -1
  560. package/dist/media/local-runtime.mjs +14 -14
  561. package/dist/media-BR4_t-Wd.mjs +416 -0
  562. package/dist/media-BR4_t-Wd.mjs.map +1 -0
  563. package/dist/media-CikS-q6E.mjs +294 -0
  564. package/dist/media-CikS-q6E.mjs.map +1 -0
  565. package/dist/media-DepNLhPq.mjs +383 -0
  566. package/dist/media-DepNLhPq.mjs.map +1 -0
  567. package/dist/media-allowlist-BMBLqyWh.mjs +45 -0
  568. package/dist/media-allowlist-BMBLqyWh.mjs.map +1 -0
  569. package/dist/media-folders-CI0Wydfo.mjs +210 -0
  570. package/dist/media-folders-CI0Wydfo.mjs.map +1 -0
  571. package/dist/media-url-BQgKvpQ5.mjs +43 -0
  572. package/dist/media-url-BQgKvpQ5.mjs.map +1 -0
  573. package/dist/media-usage-X1_20MY-.mjs +282 -0
  574. package/dist/media-usage-X1_20MY-.mjs.map +1 -0
  575. package/dist/media-usage-activation-bWusy3M2.mjs +78 -0
  576. package/dist/media-usage-activation-bWusy3M2.mjs.map +1 -0
  577. package/dist/media-usage-work-B2RaoJIa.mjs +151 -0
  578. package/dist/media-usage-work-B2RaoJIa.mjs.map +1 -0
  579. package/dist/media-usage-work-BCK2J-v_.mjs +1036 -0
  580. package/dist/media-usage-work-BCK2J-v_.mjs.map +1 -0
  581. package/dist/menus-B0Qqv_cS.mjs +837 -0
  582. package/dist/menus-B0Qqv_cS.mjs.map +1 -0
  583. package/dist/menus-oypxT1pI.mjs +3802 -0
  584. package/dist/menus-oypxT1pI.mjs.map +1 -0
  585. package/dist/menus-uEAxWAm1.mjs +92 -0
  586. package/dist/menus-uEAxWAm1.mjs.map +1 -0
  587. package/dist/migrations/index.d.mts +1 -1
  588. package/dist/migrations/index.mjs +4 -4
  589. package/dist/mime-D1We9jUx.mjs +81 -0
  590. package/dist/mime-D1We9jUx.mjs.map +1 -0
  591. package/dist/mode-C-D3qICy.mjs +23 -0
  592. package/dist/mode-C-D3qICy.mjs.map +1 -0
  593. package/dist/node-sqlite-compat-CrKzRr0J.mjs +63 -0
  594. package/dist/node-sqlite-compat-CrKzRr0J.mjs.map +1 -0
  595. package/dist/normalize-Cx-bNwhP.mjs +220 -0
  596. package/dist/normalize-Cx-bNwhP.mjs.map +1 -0
  597. package/dist/oauth-authorization-CPLgBrdo.mjs +287 -0
  598. package/dist/oauth-authorization-CPLgBrdo.mjs.map +1 -0
  599. package/dist/oauth-clients-BT0Pg-MO.mjs +266 -0
  600. package/dist/oauth-clients-BT0Pg-MO.mjs.map +1 -0
  601. package/dist/oauth-state-store-BndCfRum.mjs +50 -0
  602. package/dist/oauth-state-store-BndCfRum.mjs.map +1 -0
  603. package/dist/oauth-user-lookup-BDgF6IVG.mjs +26 -0
  604. package/dist/oauth-user-lookup-BDgF6IVG.mjs.map +1 -0
  605. package/dist/object-cache/memory.d.mts +1 -1
  606. package/dist/object-cache-DmKr09La.mjs +603 -0
  607. package/dist/object-cache-DmKr09La.mjs.map +1 -0
  608. package/dist/options-BUUgroHg.d.mts +81 -0
  609. package/dist/options-BUUgroHg.d.mts.map +1 -0
  610. package/dist/ownership-MiyA7qKO.mjs +12 -0
  611. package/dist/ownership-MiyA7qKO.mjs.map +1 -0
  612. package/dist/page/index.d.mts +2 -2
  613. package/dist/page/index.mjs +13 -13
  614. package/dist/parse-B_b6gZxG.mjs +81 -0
  615. package/dist/parse-B_b6gZxG.mjs.map +1 -0
  616. package/dist/parse-Dndx1QmN.d.mts +176 -0
  617. package/dist/parse-Dndx1QmN.d.mts.map +1 -0
  618. package/dist/passkey-config-D2Lua5__.mjs +46 -0
  619. package/dist/passkey-config-D2Lua5__.mjs.map +1 -0
  620. package/dist/paths-biDzFTY2.mjs +77 -0
  621. package/dist/paths-biDzFTY2.mjs.map +1 -0
  622. package/dist/placeholder-CSKu5OkD.d.mts +314 -0
  623. package/dist/placeholder-CSKu5OkD.d.mts.map +1 -0
  624. package/dist/plan-CCoqxNoU.mjs +135 -0
  625. package/dist/plan-CCoqxNoU.mjs.map +1 -0
  626. package/dist/plugin-test-runtime.d.mts +16 -14
  627. package/dist/plugin-test-runtime.d.mts.map +1 -1
  628. package/dist/plugin-test-runtime.mjs +114 -115
  629. package/dist/plugin-tool-name-DDUgN_0p.mjs +27 -0
  630. package/dist/plugin-tool-name-DDUgN_0p.mjs.map +1 -0
  631. package/dist/plugin-types.d.mts +1 -1
  632. package/dist/plugin-utils.d.mts +12 -11
  633. package/dist/plugin-utils.d.mts.map +1 -1
  634. package/dist/plugins/adapt-sandbox-entry.d.mts +12 -11
  635. package/dist/plugins/adapt-sandbox-entry.d.mts.map +1 -1
  636. package/dist/plugins/adapt-sandbox-entry.mjs +4 -4
  637. package/dist/plugins/host.d.mts +5 -5
  638. package/dist/plugins/host.mjs +50 -51
  639. package/dist/plugins-COJ2L49n.mjs +261 -0
  640. package/dist/plugins-COJ2L49n.mjs.map +1 -0
  641. package/dist/policy-BPugqmeV.mjs +53 -0
  642. package/dist/policy-BPugqmeV.mjs.map +1 -0
  643. package/dist/portable-text-BH4zgkSm.mjs +311 -0
  644. package/dist/portable-text-BH4zgkSm.mjs.map +1 -0
  645. package/dist/preview-DLexxwp3.mjs +107 -0
  646. package/dist/preview-DLexxwp3.mjs.map +1 -0
  647. package/dist/protocol-PoAfD_9W.d.mts +65 -0
  648. package/dist/protocol-PoAfD_9W.d.mts.map +1 -0
  649. package/dist/public-plugin-api-routes-CMljrTby.mjs +316 -0
  650. package/dist/public-plugin-api-routes-CMljrTby.mjs.map +1 -0
  651. package/dist/public-submission-ayqoyee4.mjs +251 -0
  652. package/dist/public-submission-ayqoyee4.mjs.map +1 -0
  653. package/dist/public-url-Bt98vysr.mjs +101 -0
  654. package/dist/public-url-Bt98vysr.mjs.map +1 -0
  655. package/dist/query-D62NntCZ.mjs +1146 -0
  656. package/dist/query-D62NntCZ.mjs.map +1 -0
  657. package/dist/query-LmPY2y0C.mjs +41 -0
  658. package/dist/query-LmPY2y0C.mjs.map +1 -0
  659. package/dist/range-CYfeXgGK.mjs +51 -0
  660. package/dist/range-CYfeXgGK.mjs.map +1 -0
  661. package/dist/rate-limit-C04Llsoc.mjs +127 -0
  662. package/dist/rate-limit-C04Llsoc.mjs.map +1 -0
  663. package/dist/receipt-BUsQCOeM.mjs +43 -0
  664. package/dist/receipt-BUsQCOeM.mjs.map +1 -0
  665. package/dist/redirect-CQAV7mCo.mjs +19 -0
  666. package/dist/redirect-CQAV7mCo.mjs.map +1 -0
  667. package/dist/redirect-DjLdw427.mjs +423 -0
  668. package/dist/redirect-DjLdw427.mjs.map +1 -0
  669. package/dist/redirect-paths-DOaVBp6E.mjs +36 -0
  670. package/dist/redirect-paths-DOaVBp6E.mjs.map +1 -0
  671. package/dist/redirects-Cpq1catN.mjs +446 -0
  672. package/dist/redirects-Cpq1catN.mjs.map +1 -0
  673. package/dist/redirects-CyvvZrCJ.mjs +148 -0
  674. package/dist/redirects-CyvvZrCJ.mjs.map +1 -0
  675. package/dist/registry/testing.mjs +3 -3
  676. package/dist/registry-B0-O575m.mjs +8374 -0
  677. package/dist/registry-B0-O575m.mjs.map +1 -0
  678. package/dist/relations-WIOojTL4.mjs +789 -0
  679. package/dist/relations-WIOojTL4.mjs.map +1 -0
  680. package/dist/request-context.d.mts +2 -2
  681. package/dist/request-meta-bwZ_NsvU.mjs +141 -0
  682. package/dist/request-meta-bwZ_NsvU.mjs.map +1 -0
  683. package/dist/resolve-BNnm8EkB.mjs +102 -0
  684. package/dist/resolve-BNnm8EkB.mjs.map +1 -0
  685. package/dist/route-cache-QSOyDEw0.mjs +20 -0
  686. package/dist/route-cache-QSOyDEw0.mjs.map +1 -0
  687. package/dist/route-wire-Ca_HWCZ5.mjs +197 -0
  688. package/dist/route-wire-Ca_HWCZ5.mjs.map +1 -0
  689. package/dist/routes-avqgc-8r.mjs +272 -0
  690. package/dist/routes-avqgc-8r.mjs.map +1 -0
  691. package/dist/runner-Bkkfk4O8.mjs +6669 -0
  692. package/dist/runner-Bkkfk4O8.mjs.map +1 -0
  693. package/dist/runner-Dfgp6-S_.d.mts +73 -0
  694. package/dist/runner-Dfgp6-S_.d.mts.map +1 -0
  695. package/dist/runtime.d.mts +13 -12
  696. package/dist/runtime.d.mts.map +1 -1
  697. package/dist/runtime.mjs +4 -3
  698. package/dist/runtime.mjs.map +1 -1
  699. package/dist/schema/project-env-types.mjs +42 -43
  700. package/dist/schema/project-env-types.mjs.map +1 -1
  701. package/dist/schema-B-3rntlX.mjs +815 -0
  702. package/dist/schema-B-3rntlX.mjs.map +1 -0
  703. package/dist/schema-BqBlUZtb.mjs +13 -0
  704. package/dist/schema-BqBlUZtb.mjs.map +1 -0
  705. package/dist/scopes-DNaY7Ey0.mjs +34 -0
  706. package/dist/scopes-DNaY7Ey0.mjs.map +1 -0
  707. package/dist/search-BPWTnpnD.mjs +450 -0
  708. package/dist/search-BPWTnpnD.mjs.map +1 -0
  709. package/dist/secrets-Dswzrz3k.mjs +369 -0
  710. package/dist/secrets-Dswzrz3k.mjs.map +1 -0
  711. package/dist/sections-rSao6rBG.mjs +346 -0
  712. package/dist/sections-rSao6rBG.mjs.map +1 -0
  713. package/dist/seed/index.d.mts +2 -2
  714. package/dist/seed/index.mjs +40 -41
  715. package/dist/seo/index.d.mts +3 -3
  716. package/dist/seo/index.mjs +27 -27
  717. package/dist/seo-B_H_pqOd.mjs +133 -0
  718. package/dist/seo-B_H_pqOd.mjs.map +1 -0
  719. package/dist/seo-ClB-dw9w.mjs +188 -0
  720. package/dist/seo-ClB-dw9w.mjs.map +1 -0
  721. package/dist/service-DpiUQVpp.mjs +150 -0
  722. package/dist/service-DpiUQVpp.mjs.map +1 -0
  723. package/dist/session-user-DiE4JKPP.mjs +61 -0
  724. package/dist/session-user-DiE4JKPP.mjs.map +1 -0
  725. package/dist/settings--XlUdUaI.mjs +66 -0
  726. package/dist/settings--XlUdUaI.mjs.map +1 -0
  727. package/dist/settings-D932YP2-.mjs +519 -0
  728. package/dist/settings-D932YP2-.mjs.map +1 -0
  729. package/dist/settings-Dd1uivmQ.mjs +73 -0
  730. package/dist/settings-Dd1uivmQ.mjs.map +1 -0
  731. package/dist/setup-complete-qsJYWutC.mjs +65 -0
  732. package/dist/setup-complete-qsJYWutC.mjs.map +1 -0
  733. package/dist/setup-nonce-CBFgUFXw.mjs +25 -0
  734. package/dist/setup-nonce-CBFgUFXw.mjs.map +1 -0
  735. package/dist/site-domain-oRGS_JfA.mjs +131 -0
  736. package/dist/site-domain-oRGS_JfA.mjs.map +1 -0
  737. package/dist/site-settings-DRHfX7bq.mjs +50 -0
  738. package/dist/site-settings-DRHfX7bq.mjs.map +1 -0
  739. package/dist/site-url-MB685I5X.mjs +45 -0
  740. package/dist/site-url-MB685I5X.mjs.map +1 -0
  741. package/dist/sitemap-name-B8QP8wud.mjs +26 -0
  742. package/dist/sitemap-name-B8QP8wud.mjs.map +1 -0
  743. package/dist/slug-aVnUV4SL.mjs +16 -0
  744. package/dist/slug-aVnUV4SL.mjs.map +1 -0
  745. package/dist/snapshot-BjaXDZQ5.mjs +414 -0
  746. package/dist/snapshot-BjaXDZQ5.mjs.map +1 -0
  747. package/dist/ssrf-BcYjyM4M.mjs +406 -0
  748. package/dist/ssrf-BcYjyM4M.mjs.map +1 -0
  749. package/dist/stage-CZQnXM_G.mjs +662 -0
  750. package/dist/stage-CZQnXM_G.mjs.map +1 -0
  751. package/dist/staged-ByBmPFtX.mjs +686 -0
  752. package/dist/staged-ByBmPFtX.mjs.map +1 -0
  753. package/dist/state-CFbGZziM.mjs +178 -0
  754. package/dist/state-CFbGZziM.mjs.map +1 -0
  755. package/dist/status-BFNdxzKc.mjs +30 -0
  756. package/dist/status-BFNdxzKc.mjs.map +1 -0
  757. package/dist/storage/local.d.mts +1 -1
  758. package/dist/storage/local.mjs +2 -2
  759. package/dist/storage/s3.d.mts +1 -1
  760. package/dist/storage/s3.mjs +1 -1
  761. package/dist/storage-query-BFp06Y0s.d.mts +1627 -0
  762. package/dist/storage-query-BFp06Y0s.d.mts.map +1 -0
  763. package/dist/tar-DFjExb9X.mjs +449 -0
  764. package/dist/tar-DFjExb9X.mjs.map +1 -0
  765. package/dist/target-CWZs2-o6.mjs +27 -0
  766. package/dist/target-CWZs2-o6.mjs.map +1 -0
  767. package/dist/taxonomies-5SR76j11.mjs +937 -0
  768. package/dist/taxonomies-5SR76j11.mjs.map +1 -0
  769. package/dist/taxonomies-B__VmCKQ.mjs +703 -0
  770. package/dist/taxonomies-B__VmCKQ.mjs.map +1 -0
  771. package/dist/taxonomy-CMI5fczd.mjs +563 -0
  772. package/dist/taxonomy-CMI5fczd.mjs.map +1 -0
  773. package/dist/tokens-BnhSnGwJ.mjs +171 -0
  774. package/dist/tokens-BnhSnGwJ.mjs.map +1 -0
  775. package/dist/transfer-BbKfufJ4.mjs +166 -0
  776. package/dist/transfer-BbKfufJ4.mjs.map +1 -0
  777. package/dist/transfer-DTGblAj2.mjs +8910 -0
  778. package/dist/transfer-DTGblAj2.mjs.map +1 -0
  779. package/dist/transfer-download-D9LQEDX0.mjs +33 -0
  780. package/dist/transfer-download-D9LQEDX0.mjs.map +1 -0
  781. package/dist/transformations-Bx4lYY0Y.mjs +196 -0
  782. package/dist/transformations-Bx4lYY0Y.mjs.map +1 -0
  783. package/dist/transport-Dzpn5b3i.mjs +137 -0
  784. package/dist/transport-Dzpn5b3i.mjs.map +1 -0
  785. package/dist/trusted-proxy-BU3Nx9g1.mjs +51 -0
  786. package/dist/trusted-proxy-BU3Nx9g1.mjs.map +1 -0
  787. package/dist/turnstile-Cs2wfkJG.mjs +58 -0
  788. package/dist/turnstile-Cs2wfkJG.mjs.map +1 -0
  789. package/dist/types-BAsCk5KU.d.mts +87 -0
  790. package/dist/types-BAsCk5KU.d.mts.map +1 -0
  791. package/dist/types-BuvSwT9Y.d.mts +375 -0
  792. package/dist/types-BuvSwT9Y.d.mts.map +1 -0
  793. package/dist/types-C4KT3Md2.d.mts +293 -0
  794. package/dist/types-C4KT3Md2.d.mts.map +1 -0
  795. package/dist/types-CVXHwIBB.d.mts +125 -0
  796. package/dist/types-CVXHwIBB.d.mts.map +1 -0
  797. package/dist/types-C_asjp1J.mjs.map +1 -1
  798. package/dist/types-CgfFGfO5.mjs +16 -0
  799. package/dist/types-CgfFGfO5.mjs.map +1 -0
  800. package/dist/types-Cj0_yZkn.mjs +18 -0
  801. package/dist/types-Cj0_yZkn.mjs.map +1 -0
  802. package/dist/types-CjftrmZR.d.mts +1741 -0
  803. package/dist/types-CjftrmZR.d.mts.map +1 -0
  804. package/dist/types-DKwRUA-x.d.mts +916 -0
  805. package/dist/types-DKwRUA-x.d.mts.map +1 -0
  806. package/dist/types-DwhEvIVb.mjs.map +1 -1
  807. package/dist/types-GwAyS5SH.d.mts +227 -0
  808. package/dist/types-GwAyS5SH.d.mts.map +1 -0
  809. package/dist/types-qHVygneX.mjs +77 -0
  810. package/dist/types-qHVygneX.mjs.map +1 -0
  811. package/dist/types-sUHaH7lC.mjs +37 -0
  812. package/dist/types-sUHaH7lC.mjs.map +1 -0
  813. package/dist/types-uU2YNYSt.d.mts +209 -0
  814. package/dist/types-uU2YNYSt.d.mts.map +1 -0
  815. package/dist/update-check-ABBJgg6M.mjs +161 -0
  816. package/dist/update-check-ABBJgg6M.mjs.map +1 -0
  817. package/dist/upload-attempts-DPFC4COv.mjs +32 -0
  818. package/dist/upload-attempts-DPFC4COv.mjs.map +1 -0
  819. package/dist/url-pattern-QATUE_rv.mjs +41 -0
  820. package/dist/url-pattern-QATUE_rv.mjs.map +1 -0
  821. package/dist/user-By8SzQxS.mjs +171 -0
  822. package/dist/user-By8SzQxS.mjs.map +1 -0
  823. package/dist/utils-D5uOi6WS.mjs +450 -0
  824. package/dist/utils-D5uOi6WS.mjs.map +1 -0
  825. package/dist/utils-Szp4iBQB.d.mts +376 -0
  826. package/dist/utils-Szp4iBQB.d.mts.map +1 -0
  827. package/dist/validate-DDvxy6qG.d.mts +468 -0
  828. package/dist/validate-DDvxy6qG.d.mts.map +1 -0
  829. package/dist/validate-Dz-TIOFB.mjs +524 -0
  830. package/dist/validate-Dz-TIOFB.mjs.map +1 -0
  831. package/dist/validation-Fc9ZSUS_.mjs +221 -0
  832. package/dist/validation-Fc9ZSUS_.mjs.map +1 -0
  833. package/dist/version-BZj18Q7G.mjs +9 -0
  834. package/dist/version-BZj18Q7G.mjs.map +1 -0
  835. package/dist/version-Bu6Nlbb5.mjs +7 -0
  836. package/dist/version-Bu6Nlbb5.mjs.map +1 -0
  837. package/dist/version-DqB7LIO7.mjs +49 -0
  838. package/dist/version-DqB7LIO7.mjs.map +1 -0
  839. package/dist/video-DytCnw3L.mjs +54 -0
  840. package/dist/video-DytCnw3L.mjs.map +1 -0
  841. package/dist/virtual-modules-DO954n7P.mjs +515 -0
  842. package/dist/virtual-modules-DO954n7P.mjs.map +1 -0
  843. package/dist/widgets-BUx_Mf2q.mjs +134 -0
  844. package/dist/widgets-BUx_Mf2q.mjs.map +1 -0
  845. package/dist/wxr-taxonomies-DbJtWrWM.mjs +454 -0
  846. package/dist/wxr-taxonomies-DbJtWrWM.mjs.map +1 -0
  847. package/dist/zod-generator--nlM0930.mjs +425 -0
  848. package/dist/zod-generator--nlM0930.mjs.map +1 -0
  849. package/package.json +5 -5
  850. package/src/api/handlers/content.ts +49 -18
  851. package/src/api/handlers/device-flow.ts +1 -3
  852. package/src/api/handlers/menus.ts +3 -3
  853. package/src/api/handlers/oauth-authorization.ts +1 -3
  854. package/src/astro/integration/admin-nav.ts +52 -0
  855. package/src/astro/integration/index.ts +7 -0
  856. package/src/astro/integration/runtime.ts +14 -0
  857. package/src/astro/integration/shims/use-sync-external-store-with-selector.js +2 -0
  858. package/src/astro/integration/shims/use-sync-external-store.js +4 -1
  859. package/src/astro/middleware/auth.ts +9 -2
  860. package/src/astro/routes/api/import/wordpress/analyze.ts +5 -29
  861. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +3 -3
  862. package/src/astro/routes/api/media/file/[...key].ts +18 -4
  863. package/src/astro/routes/api/oauth/token.ts +5 -1
  864. package/src/astro/routes/api/widget-areas/[name]/reorder.ts +7 -1
  865. package/src/astro/routes/api/widget-areas/[name]/widgets/[id].ts +3 -1
  866. package/src/astro/routes/api/widget-areas/[name]/widgets.ts +2 -1
  867. package/src/astro/routes/api/widget-areas/[name].ts +2 -1
  868. package/src/astro/routes/api/widget-areas/index.ts +2 -1
  869. package/src/astro/types.ts +4 -3
  870. package/src/auth/api-tokens.ts +3 -0
  871. package/src/cleanup.ts +44 -0
  872. package/src/components/inline-bubble-menu.tsx +109 -95
  873. package/src/components/inline-image.tsx +54 -48
  874. package/src/database/dialect-helpers.ts +10 -3
  875. package/src/database/repositories/byline.ts +22 -14
  876. package/src/database/repositories/content.ts +17 -4
  877. package/src/database/repositories/media.ts +17 -0
  878. package/src/database/repositories/menu.ts +163 -132
  879. package/src/database/repositories/types.ts +3 -3
  880. package/src/database/types.ts +1 -1
  881. package/src/emdash-runtime.ts +23 -7
  882. package/src/import/utils.ts +15 -2
  883. package/src/index.ts +1 -0
  884. package/src/loader.ts +106 -95
  885. package/src/media/content-disposition.ts +56 -0
  886. package/src/media/normalize.ts +2 -0
  887. package/src/media/usage/content-fields.ts +2 -1
  888. package/src/menus/index.ts +137 -25
  889. package/src/object-cache/index.ts +22 -0
  890. package/src/plugin-test-runtime.ts +1 -0
  891. package/src/query.ts +44 -40
  892. package/src/schema/types.ts +7 -6
  893. package/src/search/fts-manager.ts +5 -3
  894. package/src/seed/apply.ts +52 -44
  895. package/src/seed/types.ts +3 -3
  896. package/src/taxonomies/index.ts +22 -51
  897. package/src/transfer/import/advance.ts +12 -1
  898. package/src/transfer/import/scaffold.ts +7 -1
  899. package/src/transfer/import/stages.ts +53 -2
  900. package/src/utils/revalidating-cache.ts +85 -0
  901. package/src/visual-editing/toolbar.ts +7 -2
  902. package/src/widgets/index.ts +27 -13
  903. package/dist/action-token-B1ds4laA.mjs +0 -26
  904. package/dist/action-token-B1ds4laA.mjs.map +0 -1
  905. package/dist/activation-sGF9br3X.mjs +0 -387
  906. package/dist/activation-sGF9br3X.mjs.map +0 -1
  907. package/dist/adapters-BOMSX9PU.d.mts +0 -173
  908. package/dist/adapters-BOMSX9PU.d.mts.map +0 -1
  909. package/dist/after-PcEvMY_6.mjs +0 -96
  910. package/dist/after-PcEvMY_6.mjs.map +0 -1
  911. package/dist/allowed-origins-CovsTkm3.mjs +0 -116
  912. package/dist/allowed-origins-CovsTkm3.mjs.map +0 -1
  913. package/dist/api-C_LxFnOm.mjs +0 -5077
  914. package/dist/api-C_LxFnOm.mjs.map +0 -1
  915. package/dist/api-tokens-C7l0GUAF.mjs +0 -3
  916. package/dist/api-tokens-DQ9Ee-vP.mjs +0 -173
  917. package/dist/api-tokens-DQ9Ee-vP.mjs.map +0 -1
  918. package/dist/apply-CLjfxvyH.mjs +0 -1758
  919. package/dist/apply-CLjfxvyH.mjs.map +0 -1
  920. package/dist/approvals-ocK89i4H.mjs +0 -460
  921. package/dist/approvals-ocK89i4H.mjs.map +0 -1
  922. package/dist/artifact-fetch-CgvvpoWQ.mjs +0 -659
  923. package/dist/artifact-fetch-CgvvpoWQ.mjs.map +0 -1
  924. package/dist/artifacts-DwOYYBQm.mjs +0 -323
  925. package/dist/artifacts-DwOYYBQm.mjs.map +0 -1
  926. package/dist/authoritative-records-LPtrIGOY.mjs +0 -5183
  927. package/dist/authoritative-records-LPtrIGOY.mjs.map +0 -1
  928. package/dist/authorize-CoDsRRp5.mjs +0 -74
  929. package/dist/authorize-CoDsRRp5.mjs.map +0 -1
  930. package/dist/backup-2Wj-hTCN.mjs +0 -246
  931. package/dist/backup-2Wj-hTCN.mjs.map +0 -1
  932. package/dist/block-types-C3gJEe7l.mjs +0 -132
  933. package/dist/block-types-C3gJEe7l.mjs.map +0 -1
  934. package/dist/block-values-CgbMtSGU.mjs +0 -215
  935. package/dist/block-values-CgbMtSGU.mjs.map +0 -1
  936. package/dist/byline-CzGZC2Zs.mjs +0 -922
  937. package/dist/byline-CzGZC2Zs.mjs.map +0 -1
  938. package/dist/byline-fields-B1qHvRps.mjs +0 -280
  939. package/dist/byline-fields-B1qHvRps.mjs.map +0 -1
  940. package/dist/byline-fields-vYd_4Q1e.mjs +0 -123
  941. package/dist/byline-fields-vYd_4Q1e.mjs.map +0 -1
  942. package/dist/bylines-BF555iIz.mjs +0 -150
  943. package/dist/bylines-BF555iIz.mjs.map +0 -1
  944. package/dist/bylines-DJx6IWWi.mjs +0 -234
  945. package/dist/bylines-DJx6IWWi.mjs.map +0 -1
  946. package/dist/cache-BWzswWB-.mjs +0 -151
  947. package/dist/cache-BWzswWB-.mjs.map +0 -1
  948. package/dist/canonical-DjF_z6GI.mjs +0 -174
  949. package/dist/canonical-DjF_z6GI.mjs.map +0 -1
  950. package/dist/capture-triggers-D7g3fOZj.mjs +0 -362
  951. package/dist/capture-triggers-D7g3fOZj.mjs.map +0 -1
  952. package/dist/challenge-store-Cfjdvw86.mjs +0 -51
  953. package/dist/challenge-store-Cfjdvw86.mjs.map +0 -1
  954. package/dist/checksum-BF4acJwn.mjs +0 -162
  955. package/dist/checksum-BF4acJwn.mjs.map +0 -1
  956. package/dist/chrome-tags-BDs29G3g.mjs +0 -24
  957. package/dist/chrome-tags-BDs29G3g.mjs.map +0 -1
  958. package/dist/chunks-CYBOL-zn.mjs +0 -25
  959. package/dist/chunks-CYBOL-zn.mjs.map +0 -1
  960. package/dist/collection-slugs-cache-B2J5aESO.mjs +0 -91
  961. package/dist/collection-slugs-cache-B2J5aESO.mjs.map +0 -1
  962. package/dist/comment-DV7dybcs.mjs +0 -335
  963. package/dist/comment-DV7dybcs.mjs.map +0 -1
  964. package/dist/comment-reaction-CWwqiT6x.mjs +0 -85
  965. package/dist/comment-reaction-CWwqiT6x.mjs.map +0 -1
  966. package/dist/comments-DVjWJm8X.mjs +0 -99
  967. package/dist/comments-DVjWJm8X.mjs.map +0 -1
  968. package/dist/comments-Q-ILHCEI.mjs +0 -195
  969. package/dist/comments-Q-ILHCEI.mjs.map +0 -1
  970. package/dist/components-DnOmvvgg.mjs +0 -112
  971. package/dist/components-DnOmvvgg.mjs.map +0 -1
  972. package/dist/config-9IzA83_U.d.mts +0 -6811
  973. package/dist/config-9IzA83_U.d.mts.map +0 -1
  974. package/dist/config-BdQzFtmR.mjs +0 -228
  975. package/dist/config-BdQzFtmR.mjs.map +0 -1
  976. package/dist/config-Cs2RBkJ6.d.mts +0 -41
  977. package/dist/config-Cs2RBkJ6.d.mts.map +0 -1
  978. package/dist/connection-CiXgZyCY.mjs +0 -36
  979. package/dist/connection-CiXgZyCY.mjs.map +0 -1
  980. package/dist/content-Dt0Os_WQ.mjs +0 -2109
  981. package/dist/content-Dt0Os_WQ.mjs.map +0 -1
  982. package/dist/content-list-query-BK26u9Ly.d.mts +0 -26
  983. package/dist/content-list-query-BK26u9Ly.d.mts.map +0 -1
  984. package/dist/content-policy-BLDbNJOb.mjs +0 -46
  985. package/dist/content-policy-BLDbNJOb.mjs.map +0 -1
  986. package/dist/content-repair-CjwbLy4m.mjs +0 -442
  987. package/dist/content-repair-CjwbLy4m.mjs.map +0 -1
  988. package/dist/context-ErV7UdQY.mjs +0 -2089
  989. package/dist/context-ErV7UdQY.mjs.map +0 -1
  990. package/dist/credits-BRyjafiF.mjs +0 -110
  991. package/dist/credits-BRyjafiF.mjs.map +0 -1
  992. package/dist/cron-Bm5xa7tv.mjs +0 -306
  993. package/dist/cron-Bm5xa7tv.mjs.map +0 -1
  994. package/dist/dashboard-DVxQ5XiI.mjs +0 -168
  995. package/dist/dashboard-DVxQ5XiI.mjs.map +0 -1
  996. package/dist/default-B9Tf2n94.mjs +0 -81
  997. package/dist/default-B9Tf2n94.mjs.map +0 -1
  998. package/dist/deferred-tasks-CpPEqsga.d.mts +0 -9
  999. package/dist/deferred-tasks-CpPEqsga.d.mts.map +0 -1
  1000. package/dist/dev-typegen-ZeWYV8Jp.mjs +0 -29
  1001. package/dist/dev-typegen-ZeWYV8Jp.mjs.map +0 -1
  1002. package/dist/device-flow-BbYNZ9Xi.mjs +0 -521
  1003. package/dist/device-flow-BbYNZ9Xi.mjs.map +0 -1
  1004. package/dist/dialect-helpers-7_IqPdh9.mjs +0 -307
  1005. package/dist/dialect-helpers-7_IqPdh9.mjs.map +0 -1
  1006. package/dist/digest-DlBa7kJl.mjs +0 -194
  1007. package/dist/digest-DlBa7kJl.mjs.map +0 -1
  1008. package/dist/direct-executor-5T8gkhvA.mjs +0 -117
  1009. package/dist/direct-executor-5T8gkhvA.mjs.map +0 -1
  1010. package/dist/dist-DY0aOmAP.mjs +0 -810
  1011. package/dist/dist-DY0aOmAP.mjs.map +0 -1
  1012. package/dist/email-console-v3OM8It-.mjs +0 -50
  1013. package/dist/email-console-v3OM8It-.mjs.map +0 -1
  1014. package/dist/email-locale-CoZo-oZx.mjs +0 -25
  1015. package/dist/email-locale-CoZo-oZx.mjs.map +0 -1
  1016. package/dist/emdash-runtime-DwezbIqQ.mjs +0 -4392
  1017. package/dist/emdash-runtime-DwezbIqQ.mjs.map +0 -1
  1018. package/dist/enrich-C3XIJi0O.mjs +0 -194
  1019. package/dist/enrich-C3XIJi0O.mjs.map +0 -1
  1020. package/dist/entry-lock-CY7XpdSw.d.mts +0 -4568
  1021. package/dist/entry-lock-CY7XpdSw.d.mts.map +0 -1
  1022. package/dist/entry-lock-DDuWaAiP.mjs +0 -1211
  1023. package/dist/entry-lock-DDuWaAiP.mjs.map +0 -1
  1024. package/dist/entry-lock-D_Og9Gy3.mjs +0 -163
  1025. package/dist/entry-lock-D_Og9Gy3.mjs.map +0 -1
  1026. package/dist/entry-locks-Cp8_BcQQ.mjs +0 -167
  1027. package/dist/entry-locks-Cp8_BcQQ.mjs.map +0 -1
  1028. package/dist/env-types-Br8uywYA.mjs +0 -38
  1029. package/dist/env-types-Br8uywYA.mjs.map +0 -1
  1030. package/dist/error-CT2SsX5S.mjs +0 -90
  1031. package/dist/error-CT2SsX5S.mjs.map +0 -1
  1032. package/dist/errors-BMaCpLeS.mjs +0 -479
  1033. package/dist/errors-BMaCpLeS.mjs.map +0 -1
  1034. package/dist/errors-DlJwot7q.mjs +0 -120
  1035. package/dist/errors-DlJwot7q.mjs.map +0 -1
  1036. package/dist/escape-BfbDyuQ-.mjs +0 -9
  1037. package/dist/escape-BfbDyuQ-.mjs.map +0 -1
  1038. package/dist/fence-BOD3SxZG.mjs +0 -162
  1039. package/dist/fence-BOD3SxZG.mjs.map +0 -1
  1040. package/dist/field-defs-cache-C7sR7ZeU.mjs +0 -77
  1041. package/dist/field-defs-cache-C7sR7ZeU.mjs.map +0 -1
  1042. package/dist/field-map-C_rDXfdJ.mjs +0 -84
  1043. package/dist/field-map-C_rDXfdJ.mjs.map +0 -1
  1044. package/dist/fts-manager-BzFo0xx6.mjs +0 -483
  1045. package/dist/fts-manager-BzFo0xx6.mjs.map +0 -1
  1046. package/dist/gc-B_c3DPpi.mjs +0 -75
  1047. package/dist/gc-B_c3DPpi.mjs.map +0 -1
  1048. package/dist/hash-A-o2ZX8O.mjs +0 -37
  1049. package/dist/hash-A-o2ZX8O.mjs.map +0 -1
  1050. package/dist/hreflang-BpUK9Lcu.mjs +0 -105
  1051. package/dist/hreflang-BpUK9Lcu.mjs.map +0 -1
  1052. package/dist/hreflang-D07R-RbI.d.mts +0 -50
  1053. package/dist/hreflang-D07R-RbI.d.mts.map +0 -1
  1054. package/dist/http-route-dispatch-C2Ep2Uf6.mjs +0 -342
  1055. package/dist/http-route-dispatch-C2Ep2Uf6.mjs.map +0 -1
  1056. package/dist/identity-BivQ8wkV.mjs +0 -35
  1057. package/dist/identity-BivQ8wkV.mjs.map +0 -1
  1058. package/dist/import-B4UvHNJz.mjs +0 -2126
  1059. package/dist/import-B4UvHNJz.mjs.map +0 -1
  1060. package/dist/index-C37Ty40w.d.mts +0 -623
  1061. package/dist/index-C37Ty40w.d.mts.map +0 -1
  1062. package/dist/install-finalization-BbYaB4wj.mjs +0 -58
  1063. package/dist/install-finalization-BbYaB4wj.mjs.map +0 -1
  1064. package/dist/json-recordset-BjYIWFkV.mjs +0 -12
  1065. package/dist/json-recordset-BjYIWFkV.mjs.map +0 -1
  1066. package/dist/json-schema-Cde7le0s.mjs +0 -15
  1067. package/dist/json-schema-Cde7le0s.mjs.map +0 -1
  1068. package/dist/keys-CusTXpw-.mjs +0 -61
  1069. package/dist/keys-CusTXpw-.mjs.map +0 -1
  1070. package/dist/kinds-DogmNB6n.mjs +0 -974
  1071. package/dist/kinds-DogmNB6n.mjs.map +0 -1
  1072. package/dist/lifecycle-BLCoCz4T.mjs +0 -25
  1073. package/dist/lifecycle-BLCoCz4T.mjs.map +0 -1
  1074. package/dist/load-Dds3KhXr.mjs +0 -28
  1075. package/dist/load-Dds3KhXr.mjs.map +0 -1
  1076. package/dist/loader-D4w4XE7q.mjs +0 -1420
  1077. package/dist/loader-D4w4XE7q.mjs.map +0 -1
  1078. package/dist/loops-IYgzQdQu.mjs +0 -205
  1079. package/dist/loops-IYgzQdQu.mjs.map +0 -1
  1080. package/dist/manifest-builder-CGF5kujD.mjs +0 -196
  1081. package/dist/manifest-builder-CGF5kujD.mjs.map +0 -1
  1082. package/dist/manifest-schema-B0BxPSjB.mjs +0 -497
  1083. package/dist/manifest-schema-B0BxPSjB.mjs.map +0 -1
  1084. package/dist/marketplace-DNvEGLqU.mjs +0 -257
  1085. package/dist/marketplace-DNvEGLqU.mjs.map +0 -1
  1086. package/dist/media-BL9MRrSG.mjs +0 -294
  1087. package/dist/media-BL9MRrSG.mjs.map +0 -1
  1088. package/dist/media-B_x5B9EA.mjs +0 -373
  1089. package/dist/media-B_x5B9EA.mjs.map +0 -1
  1090. package/dist/media-allowlist-CpmqBbIQ.mjs +0 -45
  1091. package/dist/media-allowlist-CpmqBbIQ.mjs.map +0 -1
  1092. package/dist/media-folders-CNs_A_B-.mjs +0 -210
  1093. package/dist/media-folders-CNs_A_B-.mjs.map +0 -1
  1094. package/dist/media-qTTHVkls.mjs +0 -416
  1095. package/dist/media-qTTHVkls.mjs.map +0 -1
  1096. package/dist/media-url-GJboA1fl.mjs +0 -43
  1097. package/dist/media-url-GJboA1fl.mjs.map +0 -1
  1098. package/dist/media-usage-ClWgrX0d.mjs +0 -282
  1099. package/dist/media-usage-ClWgrX0d.mjs.map +0 -1
  1100. package/dist/media-usage-activation-B8Fjtq0h.mjs +0 -78
  1101. package/dist/media-usage-activation-B8Fjtq0h.mjs.map +0 -1
  1102. package/dist/media-usage-work-L8-Au4j-.mjs +0 -1036
  1103. package/dist/media-usage-work-L8-Au4j-.mjs.map +0 -1
  1104. package/dist/media-usage-work-LXgze5j9.mjs +0 -151
  1105. package/dist/media-usage-work-LXgze5j9.mjs.map +0 -1
  1106. package/dist/menus-BAxcbsbv.mjs +0 -818
  1107. package/dist/menus-BAxcbsbv.mjs.map +0 -1
  1108. package/dist/menus-BI6oBXco.mjs +0 -92
  1109. package/dist/menus-BI6oBXco.mjs.map +0 -1
  1110. package/dist/menus-fvGFd4m6.mjs +0 -3725
  1111. package/dist/menus-fvGFd4m6.mjs.map +0 -1
  1112. package/dist/mime-DwhtRyUt.mjs +0 -81
  1113. package/dist/mime-DwhtRyUt.mjs.map +0 -1
  1114. package/dist/mode-DIDSUwuN.mjs +0 -23
  1115. package/dist/mode-DIDSUwuN.mjs.map +0 -1
  1116. package/dist/node-sqlite-compat-Ddr_mlR9.mjs +0 -63
  1117. package/dist/node-sqlite-compat-Ddr_mlR9.mjs.map +0 -1
  1118. package/dist/normalize-Ip_hFAm8.mjs +0 -216
  1119. package/dist/normalize-Ip_hFAm8.mjs.map +0 -1
  1120. package/dist/oauth-authorization-CcMgeT8R.mjs +0 -274
  1121. package/dist/oauth-authorization-CcMgeT8R.mjs.map +0 -1
  1122. package/dist/oauth-clients-C_osi0PU.mjs +0 -266
  1123. package/dist/oauth-clients-C_osi0PU.mjs.map +0 -1
  1124. package/dist/oauth-state-store-DGLP-6CK.mjs +0 -50
  1125. package/dist/oauth-state-store-DGLP-6CK.mjs.map +0 -1
  1126. package/dist/oauth-user-lookup-z77Ee0Hm.mjs +0 -26
  1127. package/dist/oauth-user-lookup-z77Ee0Hm.mjs.map +0 -1
  1128. package/dist/object-cache-EjasjtoQ.mjs +0 -586
  1129. package/dist/object-cache-EjasjtoQ.mjs.map +0 -1
  1130. package/dist/options-CmUpkyKW.d.mts +0 -81
  1131. package/dist/options-CmUpkyKW.d.mts.map +0 -1
  1132. package/dist/ownership-DCk5NutQ.mjs +0 -12
  1133. package/dist/ownership-DCk5NutQ.mjs.map +0 -1
  1134. package/dist/parse-2W-E2f7w.mjs +0 -81
  1135. package/dist/parse-2W-E2f7w.mjs.map +0 -1
  1136. package/dist/parse-6pN8Xqg5.d.mts +0 -176
  1137. package/dist/parse-6pN8Xqg5.d.mts.map +0 -1
  1138. package/dist/passkey-config-DTTZB6EI.mjs +0 -46
  1139. package/dist/passkey-config-DTTZB6EI.mjs.map +0 -1
  1140. package/dist/paths-CQA62503.mjs +0 -77
  1141. package/dist/paths-CQA62503.mjs.map +0 -1
  1142. package/dist/placeholder-BlfXkucE.d.mts +0 -313
  1143. package/dist/placeholder-BlfXkucE.d.mts.map +0 -1
  1144. package/dist/plan-B95eiwnF.mjs +0 -135
  1145. package/dist/plan-B95eiwnF.mjs.map +0 -1
  1146. package/dist/plugin-tool-name-BDA7m4Xa.mjs +0 -27
  1147. package/dist/plugin-tool-name-BDA7m4Xa.mjs.map +0 -1
  1148. package/dist/plugins-BhxLJ008.mjs +0 -261
  1149. package/dist/plugins-BhxLJ008.mjs.map +0 -1
  1150. package/dist/policy-DOJ2sPqB.mjs +0 -53
  1151. package/dist/policy-DOJ2sPqB.mjs.map +0 -1
  1152. package/dist/portable-text-RCMpCj47.mjs +0 -311
  1153. package/dist/portable-text-RCMpCj47.mjs.map +0 -1
  1154. package/dist/preview-DFwL5APO.mjs +0 -107
  1155. package/dist/preview-DFwL5APO.mjs.map +0 -1
  1156. package/dist/protocol-B-ztxp_y.d.mts +0 -65
  1157. package/dist/protocol-B-ztxp_y.d.mts.map +0 -1
  1158. package/dist/public-plugin-api-routes-ik4fPZMv.mjs +0 -316
  1159. package/dist/public-plugin-api-routes-ik4fPZMv.mjs.map +0 -1
  1160. package/dist/public-submission-C5JZIykp.mjs +0 -251
  1161. package/dist/public-submission-C5JZIykp.mjs.map +0 -1
  1162. package/dist/public-url-CQwzRljH.mjs +0 -101
  1163. package/dist/public-url-CQwzRljH.mjs.map +0 -1
  1164. package/dist/query-DuwyFr5Z.mjs +0 -41
  1165. package/dist/query-DuwyFr5Z.mjs.map +0 -1
  1166. package/dist/query-eR_Nz70M.mjs +0 -1157
  1167. package/dist/query-eR_Nz70M.mjs.map +0 -1
  1168. package/dist/range-BQWPjWgQ.mjs +0 -51
  1169. package/dist/range-BQWPjWgQ.mjs.map +0 -1
  1170. package/dist/rate-limit-mPKeQ3sm.mjs +0 -127
  1171. package/dist/rate-limit-mPKeQ3sm.mjs.map +0 -1
  1172. package/dist/receipt-CmUpyuW5.mjs +0 -43
  1173. package/dist/receipt-CmUpyuW5.mjs.map +0 -1
  1174. package/dist/redirect-BtiMkehU.mjs +0 -19
  1175. package/dist/redirect-BtiMkehU.mjs.map +0 -1
  1176. package/dist/redirect-DcmNMvOs.mjs +0 -423
  1177. package/dist/redirect-DcmNMvOs.mjs.map +0 -1
  1178. package/dist/redirect-paths-K5i3xYfR.mjs +0 -36
  1179. package/dist/redirect-paths-K5i3xYfR.mjs.map +0 -1
  1180. package/dist/redirects-BA_TvtuH.mjs +0 -148
  1181. package/dist/redirects-BA_TvtuH.mjs.map +0 -1
  1182. package/dist/redirects-BIrRvgn4.mjs +0 -446
  1183. package/dist/redirects-BIrRvgn4.mjs.map +0 -1
  1184. package/dist/registry-DymfZkAN.mjs +0 -8374
  1185. package/dist/registry-DymfZkAN.mjs.map +0 -1
  1186. package/dist/relations-DrEs3Sc1.mjs +0 -789
  1187. package/dist/relations-DrEs3Sc1.mjs.map +0 -1
  1188. package/dist/request-meta-o8RIf9pa.mjs +0 -141
  1189. package/dist/request-meta-o8RIf9pa.mjs.map +0 -1
  1190. package/dist/resolve-CVy9xgy_.mjs +0 -102
  1191. package/dist/resolve-CVy9xgy_.mjs.map +0 -1
  1192. package/dist/route-cache-DAG5dPhh.mjs +0 -20
  1193. package/dist/route-cache-DAG5dPhh.mjs.map +0 -1
  1194. package/dist/route-wire-Xbsu8Vih.mjs +0 -197
  1195. package/dist/route-wire-Xbsu8Vih.mjs.map +0 -1
  1196. package/dist/routes-YQkSOsws.mjs +0 -272
  1197. package/dist/routes-YQkSOsws.mjs.map +0 -1
  1198. package/dist/runner-CLorw5vo.mjs +0 -6669
  1199. package/dist/runner-CLorw5vo.mjs.map +0 -1
  1200. package/dist/runner-g1A9P-wD.d.mts +0 -73
  1201. package/dist/runner-g1A9P-wD.d.mts.map +0 -1
  1202. package/dist/schema-Bss8qImF.mjs +0 -13
  1203. package/dist/schema-Bss8qImF.mjs.map +0 -1
  1204. package/dist/schema-C036pqEw.mjs +0 -815
  1205. package/dist/schema-C036pqEw.mjs.map +0 -1
  1206. package/dist/scopes-C_SoYl9x.mjs +0 -34
  1207. package/dist/scopes-C_SoYl9x.mjs.map +0 -1
  1208. package/dist/search-uNqCgePJ.mjs +0 -450
  1209. package/dist/search-uNqCgePJ.mjs.map +0 -1
  1210. package/dist/secrets-Cc_O3Kp-.mjs +0 -369
  1211. package/dist/secrets-Cc_O3Kp-.mjs.map +0 -1
  1212. package/dist/sections-BLusMa96.mjs +0 -346
  1213. package/dist/sections-BLusMa96.mjs.map +0 -1
  1214. package/dist/seo-BodxIpws.mjs +0 -188
  1215. package/dist/seo-BodxIpws.mjs.map +0 -1
  1216. package/dist/seo-DaMYIQY8.mjs +0 -133
  1217. package/dist/seo-DaMYIQY8.mjs.map +0 -1
  1218. package/dist/service-BuM1BRsA.mjs +0 -150
  1219. package/dist/service-BuM1BRsA.mjs.map +0 -1
  1220. package/dist/session-user-2DpQDMKw.mjs +0 -61
  1221. package/dist/session-user-2DpQDMKw.mjs.map +0 -1
  1222. package/dist/settings-B3ZmPF_8.mjs +0 -73
  1223. package/dist/settings-B3ZmPF_8.mjs.map +0 -1
  1224. package/dist/settings-P5hwPX6_.mjs +0 -66
  1225. package/dist/settings-P5hwPX6_.mjs.map +0 -1
  1226. package/dist/settings-yIqoN-Ok.mjs +0 -519
  1227. package/dist/settings-yIqoN-Ok.mjs.map +0 -1
  1228. package/dist/setup-complete-eu6MUQnt.mjs +0 -65
  1229. package/dist/setup-complete-eu6MUQnt.mjs.map +0 -1
  1230. package/dist/setup-nonce-CyPOapqY.mjs +0 -25
  1231. package/dist/setup-nonce-CyPOapqY.mjs.map +0 -1
  1232. package/dist/site-domain-8lEJl_0U.mjs +0 -131
  1233. package/dist/site-domain-8lEJl_0U.mjs.map +0 -1
  1234. package/dist/site-settings-uPkW0e6o.mjs +0 -50
  1235. package/dist/site-settings-uPkW0e6o.mjs.map +0 -1
  1236. package/dist/site-url-25SGVXwL.mjs +0 -45
  1237. package/dist/site-url-25SGVXwL.mjs.map +0 -1
  1238. package/dist/sitemap-name-DTK7CYnY.mjs +0 -26
  1239. package/dist/sitemap-name-DTK7CYnY.mjs.map +0 -1
  1240. package/dist/slug-BEDl2IJY.mjs +0 -16
  1241. package/dist/slug-BEDl2IJY.mjs.map +0 -1
  1242. package/dist/snapshot-CvkIBRLY.mjs +0 -414
  1243. package/dist/snapshot-CvkIBRLY.mjs.map +0 -1
  1244. package/dist/ssrf-mcCKMH6B.mjs +0 -406
  1245. package/dist/ssrf-mcCKMH6B.mjs.map +0 -1
  1246. package/dist/stage-BQfGzGOy.mjs +0 -662
  1247. package/dist/stage-BQfGzGOy.mjs.map +0 -1
  1248. package/dist/staged-B5vQGeSf.mjs +0 -686
  1249. package/dist/staged-B5vQGeSf.mjs.map +0 -1
  1250. package/dist/state-dO6t6OxV.mjs +0 -178
  1251. package/dist/state-dO6t6OxV.mjs.map +0 -1
  1252. package/dist/status-DSURZwKS.mjs +0 -30
  1253. package/dist/status-DSURZwKS.mjs.map +0 -1
  1254. package/dist/storage-query-Cy0SZ8iG.d.mts +0 -1619
  1255. package/dist/storage-query-Cy0SZ8iG.d.mts.map +0 -1
  1256. package/dist/tar-DWzcUZ_Q.mjs +0 -449
  1257. package/dist/tar-DWzcUZ_Q.mjs.map +0 -1
  1258. package/dist/target-C9htUbrT.mjs +0 -27
  1259. package/dist/target-C9htUbrT.mjs.map +0 -1
  1260. package/dist/taxonomies-By2aGvq2.mjs +0 -729
  1261. package/dist/taxonomies-By2aGvq2.mjs.map +0 -1
  1262. package/dist/taxonomies-CVRd_jz0.mjs +0 -937
  1263. package/dist/taxonomies-CVRd_jz0.mjs.map +0 -1
  1264. package/dist/taxonomy-BG_xu2Qf.mjs +0 -563
  1265. package/dist/taxonomy-BG_xu2Qf.mjs.map +0 -1
  1266. package/dist/tokens-U5vzgSrM.mjs +0 -171
  1267. package/dist/tokens-U5vzgSrM.mjs.map +0 -1
  1268. package/dist/transfer-DA0OSfaT.mjs +0 -8873
  1269. package/dist/transfer-DA0OSfaT.mjs.map +0 -1
  1270. package/dist/transfer-Pyf3d7ka.mjs +0 -166
  1271. package/dist/transfer-Pyf3d7ka.mjs.map +0 -1
  1272. package/dist/transfer-download-cX7SuWEy.mjs +0 -33
  1273. package/dist/transfer-download-cX7SuWEy.mjs.map +0 -1
  1274. package/dist/transformations-DczubD4j.mjs +0 -196
  1275. package/dist/transformations-DczubD4j.mjs.map +0 -1
  1276. package/dist/transport-DtIrjEFO.mjs +0 -137
  1277. package/dist/transport-DtIrjEFO.mjs.map +0 -1
  1278. package/dist/trusted-proxy-CDRd5Kmw.mjs +0 -51
  1279. package/dist/trusted-proxy-CDRd5Kmw.mjs.map +0 -1
  1280. package/dist/turnstile-Ct5YuFNY.mjs +0 -58
  1281. package/dist/turnstile-Ct5YuFNY.mjs.map +0 -1
  1282. package/dist/types-Bgujop4S.d.mts +0 -374
  1283. package/dist/types-Bgujop4S.d.mts.map +0 -1
  1284. package/dist/types-BirHUEXt.mjs +0 -18
  1285. package/dist/types-BirHUEXt.mjs.map +0 -1
  1286. package/dist/types-BqJgTL_y.d.mts +0 -293
  1287. package/dist/types-BqJgTL_y.d.mts.map +0 -1
  1288. package/dist/types-C-lrOt9T.d.mts +0 -87
  1289. package/dist/types-C-lrOt9T.d.mts.map +0 -1
  1290. package/dist/types-CCEHAhOv.d.mts +0 -916
  1291. package/dist/types-CCEHAhOv.d.mts.map +0 -1
  1292. package/dist/types-CLVwYRBr.d.mts +0 -227
  1293. package/dist/types-CLVwYRBr.d.mts.map +0 -1
  1294. package/dist/types-DVbTb4Hk.mjs +0 -77
  1295. package/dist/types-DVbTb4Hk.mjs.map +0 -1
  1296. package/dist/types-Ddku19Zw.d.mts +0 -209
  1297. package/dist/types-Ddku19Zw.d.mts.map +0 -1
  1298. package/dist/types-FIiGQ3PE.mjs +0 -16
  1299. package/dist/types-FIiGQ3PE.mjs.map +0 -1
  1300. package/dist/types-OauzCOY0.mjs +0 -37
  1301. package/dist/types-OauzCOY0.mjs.map +0 -1
  1302. package/dist/types-mQGTpP-4.d.mts +0 -1741
  1303. package/dist/types-mQGTpP-4.d.mts.map +0 -1
  1304. package/dist/types-nbjz3Mgm.d.mts +0 -125
  1305. package/dist/types-nbjz3Mgm.d.mts.map +0 -1
  1306. package/dist/update-check-hW32-0pf.mjs +0 -161
  1307. package/dist/update-check-hW32-0pf.mjs.map +0 -1
  1308. package/dist/upload-attempts-Bpik1TLF.mjs +0 -32
  1309. package/dist/upload-attempts-Bpik1TLF.mjs.map +0 -1
  1310. package/dist/url-pattern-CJeCyNij.mjs +0 -41
  1311. package/dist/url-pattern-CJeCyNij.mjs.map +0 -1
  1312. package/dist/user-nQInBZbE.mjs +0 -171
  1313. package/dist/user-nQInBZbE.mjs.map +0 -1
  1314. package/dist/utils-govudc_U.mjs +0 -442
  1315. package/dist/utils-govudc_U.mjs.map +0 -1
  1316. package/dist/validate-BxLvcDYh.mjs +0 -524
  1317. package/dist/validate-BxLvcDYh.mjs.map +0 -1
  1318. package/dist/validate-mnoVfASU.d.mts +0 -468
  1319. package/dist/validate-mnoVfASU.d.mts.map +0 -1
  1320. package/dist/validation-DQDEvh87.mjs +0 -221
  1321. package/dist/validation-DQDEvh87.mjs.map +0 -1
  1322. package/dist/version-BOFfLiVT.mjs +0 -49
  1323. package/dist/version-BOFfLiVT.mjs.map +0 -1
  1324. package/dist/version-Dcvx_C9g.mjs +0 -7
  1325. package/dist/version-Dcvx_C9g.mjs.map +0 -1
  1326. package/dist/version-DzTJ3gD7.mjs +0 -9
  1327. package/dist/version-DzTJ3gD7.mjs.map +0 -1
  1328. package/dist/video-BX7AI5nJ.mjs +0 -54
  1329. package/dist/video-BX7AI5nJ.mjs.map +0 -1
  1330. package/dist/virtual-modules-CU29aip9.mjs +0 -515
  1331. package/dist/virtual-modules-CU29aip9.mjs.map +0 -1
  1332. package/dist/widgets-HIeFmZxt.mjs +0 -121
  1333. package/dist/widgets-HIeFmZxt.mjs.map +0 -1
  1334. package/dist/wxr-taxonomies-DyOGhl8W.mjs +0 -454
  1335. package/dist/wxr-taxonomies-DyOGhl8W.mjs.map +0 -1
  1336. package/dist/zod-generator-VxCPVDpo.mjs +0 -425
  1337. package/dist/zod-generator-VxCPVDpo.mjs.map +0 -1
  1338. /package/dist/{ssrf-BBXcxG-f.mjs → ssrf-DM0E-D_8.mjs} +0 -0
@@ -0,0 +1,2112 @@
1
+ import { f as __exportAll } from "./runner-Bkkfk4O8.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-B1XN2HGB.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-BFHjCzSh.mjs";
8
+ import { u as invalidateCollectionCache } from "./object-cache-DmKr09La.mjs";
9
+ import { f as isIndexableFieldType, m as isStoragelessFieldRow } from "./types-C_asjp1J.mjs";
10
+ import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-DiW8VMwz.mjs";
11
+ import { n as slugify } from "./slugify-BDEG9pLk.mjs";
12
+ 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-DwhEvIVb.mjs";
13
+ import { i as ContentDatetimeNormalizer, n as createRevisionId, t as RevisionRepository } from "./revision-Dx7Uth1X.mjs";
14
+ import { t as withTransaction } from "./transaction-CkoQ5wqQ.mjs";
15
+ import { sql } from "kysely";
16
+ import { ulid } from "ulidx";
17
+
18
+ //#region src/content/known-fields.ts
19
+ /**
20
+ * Reconcile an entry's keys with the fields its collection currently declares.
21
+ *
22
+ * A draft revision stores the whole `data` as JSON, so deleting a field leaves the old
23
+ * value inside the revision. Every content-write surface needs the same two rules to keep
24
+ * that from stranding the entry, so they live here rather than in one caller.
25
+ */
26
+ /** Keys EmDash reserves (`_slug` and the like). No field declares them. */
27
+ function isReservedKey(key) {
28
+ return key.startsWith("_");
29
+ }
30
+ /**
31
+ * The entry data without the keys the collection has no field for.
32
+ *
33
+ * Reserved keys are kept.
34
+ */
35
+ function keepKnownFields(data, knownFieldSlugs) {
36
+ const result = {};
37
+ for (const [key, value] of Object.entries(data)) if (isReservedKey(key) || knownFieldSlugs.has(key)) result[key] = value;
38
+ return result;
39
+ }
40
+ /**
41
+ * Incoming keys with no matching field that the entry already stores.
42
+ *
43
+ * Dropping these lets a read-then-write save succeed after the field was deleted. A key the
44
+ * entry has never stored is not returned, so a genuinely unknown field is still reported.
45
+ */
46
+ function staleStoredKeys(data, stored, knownFieldSlugs) {
47
+ return Object.keys(data).filter((key) => !isReservedKey(key) && !knownFieldSlugs.has(key) && Object.hasOwn(stored, key));
48
+ }
49
+
50
+ //#endregion
51
+ //#region src/search/match.ts
52
+ /**
53
+ * FTS5 match-expression builder for structured (non-user-syntax) queries.
54
+ *
55
+ * Unlike `escapeQuery` in `query.ts` (which powers the public search API and
56
+ * deliberately passes through FTS5 operators like AND/OR/NOT), this builder
57
+ * treats the input as plain words: every term is double-quoted with interior
58
+ * quotes escaped, so the result can never produce an FTS5 syntax error. Used
59
+ * by the admin content-list filter, where the input is a filter box, not a
60
+ * search-syntax field.
61
+ */
62
+ const WHITESPACE_RE = /\s+/;
63
+ const DOUBLE_QUOTE_RE = /"/g;
64
+ const GLOB_SPECIAL_RE = /[[\]*?]/g;
65
+ /**
66
+ * Build a prefix-matching FTS5 MATCH expression from free-form input.
67
+ *
68
+ * `hello wor` becomes `"hello"* "wor"*` — implicit AND with per-term prefix
69
+ * matching. Returns `""` when the input contains no usable terms; callers
70
+ * must fall back to their non-FTS path in that case.
71
+ */
72
+ function buildFtsPrefixMatch(input) {
73
+ const terms = input.trim().split(WHITESPACE_RE).map((term) => term.replace(DOUBLE_QUOTE_RE, "\"\"")).filter((term) => term.length > 0);
74
+ if (terms.length === 0) return "";
75
+ return terms.map((term) => `"${term}"*`).join(" ");
76
+ }
77
+ /**
78
+ * Build a GLOB prefix pattern from free-form input, treating GLOB
79
+ * metacharacters (`* ? [ ]`) literally by wrapping each in a character
80
+ * class (GLOB has no ESCAPE clause).
81
+ *
82
+ * GLOB (unlike default LIKE) is case-sensitive, so with a lowercased
83
+ * pattern it matches slugs (lowercase by construction) while staying
84
+ * servable by the ordinary BINARY-collated slug index — SQLite's GLOB
85
+ * optimization turns a `prefix*` pattern into an index range scan.
86
+ */
87
+ function buildSlugGlobPrefix(input) {
88
+ return `${input.trim().toLowerCase().replace(GLOB_SPECIAL_RE, (c) => `[${c}]`)}*`;
89
+ }
90
+
91
+ //#endregion
92
+ //#region src/database/repositories/content.ts
93
+ var content_exports = /* @__PURE__ */ __exportAll({
94
+ ContentRepository: () => ContentRepository,
95
+ isConfirmedStatementFailure: () => isConfirmedStatementFailure,
96
+ isSystemOrderField: () => isSystemOrderField
97
+ });
98
+ const ULID_PATTERN = /^[0-9A-Z]{26}$/;
99
+ const SQLSTATE_PATTERN = /^[0-9A-Z]{5}$/;
100
+ const MAX_DRAFT_STAGE_ATTEMPTS = 32;
101
+ const LIKE_WILDCARD_RE = /[\\%_]/g;
102
+ const MAX_INDEXED_FIELD_FILTERS = 20;
103
+ const MAX_IN_FILTER_VALUES = SQL_BATCH_SIZE;
104
+ const MAX_FILTER_STRING_LENGTH = 2048;
105
+ function assertRevisionPrecondition(item, expected) {
106
+ if (expected && (item.version !== expected.version || item.updatedAt !== expected.updatedAt)) throw new ContentMutationConflictError();
107
+ }
108
+ function nullableColumnMatch(column, value) {
109
+ validateIdentifier(column, "content column");
110
+ return value === null ? sql`${sql.ref(column)} IS NULL` : sql`${sql.ref(column)} = ${value}`;
111
+ }
112
+ function sameStoredValue(left, right) {
113
+ return Object.is(serializeValue(left), serializeValue(right));
114
+ }
115
+ function matchesPublication(observed, existing, revisionData, revisionId, slug, publishedAt, updatedAt) {
116
+ 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;
117
+ return Object.entries(revisionData).every(([key, value]) => SYSTEM_COLUMNS.has(key) || key.startsWith("_") || sameStoredValue(observed.data[key], value));
118
+ }
119
+ function matchesLifecyclePublication(observed, existing, liveRevisionId, publishedAt, updatedAt) {
120
+ 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;
121
+ return Object.entries(existing.data).every(([key, value]) => sameStoredValue(observed.data[key], value));
122
+ }
123
+ function matchesPublicationFence(observed, existing) {
124
+ return observed.version === existing.version && observed.status === existing.status && observed.liveRevisionId === existing.liveRevisionId && observed.draftRevisionId === existing.draftRevisionId && observed.scheduledAt === existing.scheduledAt;
125
+ }
126
+ function isConfirmedStatementFailure(error) {
127
+ if (typeof error !== "object" || error === null || !("code" in error)) return false;
128
+ const code = error.code;
129
+ return typeof code === "string" && (code === "ERR_SQLITE_ERROR" || code.startsWith("SQLITE_") || SQLSTATE_PATTERN.test(code));
130
+ }
131
+ function encodeNullableOrderCursor(field, value, id) {
132
+ const payload = {
133
+ version: 1,
134
+ field,
135
+ value
136
+ };
137
+ return encodeCursor(JSON.stringify(payload), id);
138
+ }
139
+ /**
140
+ * `acceptPlain` also accepts the plain `{ orderValue, id }` cursor that
141
+ * built-in and collection sort fields were paged with before, which wrote a
142
+ * NULL as "".
143
+ */
144
+ function decodeNullableOrderCursor(cursor, field, { acceptPlain = false } = {}) {
145
+ const { orderValue, id } = decodeCursor(cursor);
146
+ let payload;
147
+ try {
148
+ payload = JSON.parse(orderValue);
149
+ } catch {
150
+ payload = void 0;
151
+ }
152
+ if (payload === null || typeof payload !== "object") {
153
+ if (acceptPlain) return {
154
+ value: orderValue === "" ? null : orderValue,
155
+ id
156
+ };
157
+ throw new InvalidCursorError(cursor);
158
+ }
159
+ const candidate = payload;
160
+ const validValue = candidate.value === null || typeof candidate.value === "string" || typeof candidate.value === "number";
161
+ if (candidate.version !== 1 || candidate.field !== field || !validValue) throw new InvalidCursorError(cursor);
162
+ return {
163
+ value: candidate.value,
164
+ id
165
+ };
166
+ }
167
+ /**
168
+ * Keyset condition for the rows after (`value`, `cursorId`) in a sort by the
169
+ * nullable `column`, then `id`. The ORDER BY keeps each dialect's own NULL
170
+ * position, lowest on SQLite and highest on Postgres, so the condition follows
171
+ * it.
172
+ */
173
+ function nullableOrderCondition(db, column, direction, value, cursorId) {
174
+ const sort = sql.ref(column);
175
+ const id = sql.ref("id");
176
+ const cmp = direction === "ASC" ? sql.raw(">") : sql.raw("<");
177
+ const nullsFirst = direction === "ASC" !== isPostgres(db);
178
+ if (value === null) return nullsFirst ? sql`(${sort} IS NOT NULL OR ${id} ${cmp} ${cursorId})` : sql`(${sort} IS NULL AND ${id} ${cmp} ${cursorId})`;
179
+ const past = sql`(${sort}, ${id}) ${cmp} (${value}, ${cursorId})`;
180
+ return nullsFirst ? past : sql`(${past} OR ${sort} IS NULL)`;
181
+ }
182
+ /**
183
+ * Whitelist mapping a public date-filter field to its physical column. Keeping
184
+ * this separate from `mapOrderField` makes the filterable set explicit and
185
+ * prevents filtering on arbitrary columns.
186
+ */
187
+ const DATE_FILTER_COLUMNS = {
188
+ createdAt: "created_at",
189
+ updatedAt: "updated_at",
190
+ publishedAt: "published_at"
191
+ };
192
+ /**
193
+ * Built-in sort fields → their physical columns. A closed set that blocks
194
+ * sorting by arbitrary columns; per-collection fields are allowed
195
+ * separately via `mapOrderField`'s `sortableExtras`.
196
+ */
197
+ const ORDER_FIELD_COLUMNS = {
198
+ createdAt: "created_at",
199
+ updatedAt: "updated_at",
200
+ publishedAt: "published_at",
201
+ scheduledAt: "scheduled_at",
202
+ deletedAt: "deleted_at",
203
+ title: "title",
204
+ name: "name",
205
+ slug: "slug",
206
+ status: "status",
207
+ locale: "locale"
208
+ };
209
+ /**
210
+ * Order columns every row has a value for. Their cursors keep the plain
211
+ * `{ orderValue, id }` shape; a cursor for any other order column records a
212
+ * NULL explicitly.
213
+ */
214
+ const NON_NULL_ORDER_COLUMNS = new Set([
215
+ "created_at",
216
+ "updated_at",
217
+ "status",
218
+ "locale"
219
+ ]);
220
+ /** True when `field` maps to a system column and needs no per-collection resolution. */
221
+ function isSystemOrderField(field) {
222
+ return field in ORDER_FIELD_COLUMNS;
223
+ }
224
+ /**
225
+ * System columns that exist in every ec_* table
226
+ */
227
+ const SYSTEM_COLUMNS = new Set([
228
+ "id",
229
+ "slug",
230
+ "status",
231
+ "author_id",
232
+ "primary_byline_id",
233
+ "created_at",
234
+ "updated_at",
235
+ "published_at",
236
+ "scheduled_at",
237
+ "deleted_at",
238
+ "version",
239
+ "live_revision_id",
240
+ "draft_revision_id",
241
+ "locale",
242
+ "translation_group"
243
+ ]);
244
+ /**
245
+ * Get the table name for a collection type
246
+ */
247
+ function getTableName(type) {
248
+ validateIdentifier(type, "collection type");
249
+ return `ec_${type}`;
250
+ }
251
+ function assertPageOffset(offset, cursor) {
252
+ if (offset === void 0) return;
253
+ if (cursor !== void 0) throw new EmDashValidationError("cursor and offset cannot be used together");
254
+ if (!Number.isSafeInteger(offset) || offset < 0) throw new EmDashValidationError("offset must be a non-negative integer");
255
+ }
256
+ /**
257
+ * Serialize a value for database storage
258
+ * Objects/arrays are JSON-stringified
259
+ * Booleans are converted to 0/1 for SQLite
260
+ */
261
+ function serializeValue(value) {
262
+ if (value === null || value === void 0) return null;
263
+ if (typeof value === "boolean") return value ? 1 : 0;
264
+ if (typeof value === "object") return JSON.stringify(value);
265
+ return value;
266
+ }
267
+ function writableContentData(data) {
268
+ const writable = {};
269
+ for (const [key, value] of Object.entries(data)) {
270
+ if (SYSTEM_COLUMNS.has(key)) continue;
271
+ validateIdentifier(key, "content field name");
272
+ writable[key] = value;
273
+ }
274
+ return writable;
275
+ }
276
+ /**
277
+ * Deserialize a value from database storage
278
+ * Attempts to parse JSON strings that look like objects/arrays
279
+ */
280
+ function deserializeValue(value) {
281
+ if (typeof value === "string") {
282
+ if (value.startsWith("{") || value.startsWith("[")) try {
283
+ return JSON.parse(value);
284
+ } catch {
285
+ return value;
286
+ }
287
+ }
288
+ return value;
289
+ }
290
+ /** Pattern for escaping special regex characters */
291
+ const REGEX_ESCAPE_PATTERN = /[.*+?^${}()|[\]\\]/g;
292
+ /**
293
+ * Escape special regex characters in a string for use in `new RegExp()`
294
+ */
295
+ function escapeRegExp(s) {
296
+ return s.replace(REGEX_ESCAPE_PATTERN, "\\$&");
297
+ }
298
+ /**
299
+ * Repository for content CRUD operations
300
+ *
301
+ * Content is stored in per-collection tables (ec_posts, ec_pages, etc.)
302
+ * Each field becomes a real column in the table.
303
+ */
304
+ var ContentRepository = class {
305
+ datetimes;
306
+ constructor(db, datetimeContexts) {
307
+ this.db = db;
308
+ this.datetimeContexts = datetimeContexts;
309
+ this.datetimes = new ContentDatetimeNormalizer(db, datetimeContexts);
310
+ }
311
+ async assertAliasAwareSlugAvailable(type, slug, locale, excludeId) {
312
+ if (!slug || !locale || getLocaleCandidates(locale).length <= 1) return;
313
+ const tableName = getTableName(type);
314
+ if ((await sql`
315
+ SELECT id FROM ${sql.ref(tableName)}
316
+ WHERE slug = ${slug}
317
+ AND ${localeMatches("locale", locale)}
318
+ ${excludeId === void 0 ? sql`` : sql`AND id <> ${excludeId}
319
+ AND coalesce((SELECT existing_row.slug FROM ${sql.ref(tableName)} AS existing_row WHERE existing_row.id = ${excludeId}), '') <> ${slug}`}
320
+ LIMIT 1
321
+ `.execute(this.db)).rows.length > 0) throw new ContentSlugConflictError();
322
+ }
323
+ /**
324
+ * Create a new content item
325
+ */
326
+ async create(input) {
327
+ const id = input.id ?? ulid();
328
+ const now = (/* @__PURE__ */ new Date()).toISOString();
329
+ const { type, slug, data: inputData, status = "draft", authorId, primaryBylineId, locale, translationOf, inheritFields = [], publishedAt, createdAt } = input;
330
+ const data = await this.datetimes.normalizeInput(type, inputData);
331
+ const normalizedCreatedAt = createdAt ? await this.datetimes.normalizeValue(type, createdAt) : now;
332
+ const normalizedPublishedAt = publishedAt ? await this.datetimes.normalizeValue(type, publishedAt) : null;
333
+ if (!type) throw new EmDashValidationError("Content type is required");
334
+ const tableName = getTableName(type);
335
+ if (translationOf && getLocaleCandidates(locale ?? "en").length > 1) {
336
+ if ((await sql`
337
+ SELECT sibling.id FROM ${sql.ref(tableName)} AS sibling
338
+ INNER JOIN ${sql.ref(tableName)} AS source
339
+ ON coalesce(source.translation_group, source.id) = sibling.translation_group
340
+ WHERE source.id = ${translationOf} AND source.deleted_at IS NULL
341
+ AND sibling.deleted_at IS NULL AND ${localeMatches("sibling.locale", locale ?? "en")}
342
+ LIMIT 1
343
+ `.execute(this.db)).rows.length > 0) throw new ContentMutationConflictError(`Translation already exists in locale "${locale ?? "en"}" for this content item`);
344
+ }
345
+ await this.assertAliasAwareSlugAvailable(type, slug, locale);
346
+ const columns = [
347
+ "id",
348
+ "slug",
349
+ "status",
350
+ "author_id",
351
+ "primary_byline_id",
352
+ "created_at",
353
+ "updated_at",
354
+ "published_at",
355
+ "version",
356
+ "locale",
357
+ "translation_group"
358
+ ];
359
+ const values = [
360
+ id,
361
+ slug || null,
362
+ status,
363
+ authorId || null,
364
+ primaryBylineId ?? null,
365
+ normalizedCreatedAt,
366
+ now,
367
+ normalizedPublishedAt,
368
+ 1,
369
+ locale || "en",
370
+ id
371
+ ];
372
+ const inherited = new Set(inheritFields);
373
+ for (const field of inherited) {
374
+ validateIdentifier(field, "inherited content field name");
375
+ if (!SYSTEM_COLUMNS.has(field) && !Object.hasOwn(data, field)) {
376
+ columns.push(field);
377
+ values.push(null);
378
+ }
379
+ }
380
+ if (data && typeof data === "object") {
381
+ for (const [key, value] of Object.entries(data)) if (!SYSTEM_COLUMNS.has(key)) {
382
+ validateIdentifier(key, "content field name");
383
+ columns.push(key);
384
+ values.push(serializeValue(value));
385
+ }
386
+ }
387
+ const columnRefs = columns.map((c) => sql.ref(c));
388
+ const valuePlaceholders = values.map((value, index) => {
389
+ const column = columns[index];
390
+ if (translationOf && column === "translation_group") return sql`COALESCE(${sql.ref("translation_source.translation_group")}, ${sql.ref("translation_source.id")})`;
391
+ if (translationOf && inherited.has(column)) return sql.ref(`translation_source.${column}`);
392
+ return value === null ? sql`NULL` : sql`${value}`;
393
+ });
394
+ if (translationOf) await sql`
395
+ INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
396
+ SELECT ${sql.join(valuePlaceholders, sql`, `)}
397
+ FROM ${sql.ref(tableName)} AS translation_source
398
+ WHERE translation_source.id = ${translationOf}
399
+ AND translation_source.deleted_at IS NULL
400
+ `.execute(this.db);
401
+ else await sql`
402
+ INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
403
+ VALUES (${sql.join(valuePlaceholders, sql`, `)})
404
+ `.execute(this.db);
405
+ invalidateCollectionCache(type);
406
+ const item = await this.findById(type, id);
407
+ if (!item) {
408
+ if (translationOf) throw new EmDashValidationError("Translation source content not found");
409
+ throw new Error("Failed to create content");
410
+ }
411
+ return item;
412
+ }
413
+ /**
414
+ * Generate a unique slug for a content item within a collection.
415
+ *
416
+ * Checks the collection table for existing slugs that match `baseSlug`
417
+ * (optionally scoped to a locale) and appends a numeric suffix (`-1`,
418
+ * `-2`, etc.) on collision to guarantee uniqueness.
419
+ *
420
+ * Returns null when slug normalization cannot produce a value.
421
+ */
422
+ async generateUniqueSlug(type, text, locale) {
423
+ const baseSlug = slugify(text);
424
+ if (!baseSlug) return null;
425
+ const tableName = getTableName(type);
426
+ if ((locale ? await sql`
427
+ SELECT slug FROM ${sql.ref(tableName)}
428
+ WHERE slug = ${baseSlug}
429
+ AND ${localeMatches("locale", locale)}
430
+ LIMIT 1
431
+ `.execute(this.db) : await sql`
432
+ SELECT slug FROM ${sql.ref(tableName)}
433
+ WHERE slug = ${baseSlug}
434
+ LIMIT 1
435
+ `.execute(this.db)).rows.length === 0) return baseSlug;
436
+ const pattern = `${baseSlug}-%`;
437
+ const candidates = locale ? await sql`
438
+ SELECT slug FROM ${sql.ref(tableName)}
439
+ WHERE (slug = ${baseSlug} OR slug LIKE ${pattern})
440
+ AND ${localeMatches("locale", locale)}
441
+ `.execute(this.db) : await sql`
442
+ SELECT slug FROM ${sql.ref(tableName)}
443
+ WHERE slug = ${baseSlug} OR slug LIKE ${pattern}
444
+ `.execute(this.db);
445
+ let maxSuffix = 0;
446
+ const suffixPattern = new RegExp(`^${escapeRegExp(baseSlug)}-(\\d+)$`);
447
+ for (const row of candidates.rows) {
448
+ const match = suffixPattern.exec(row.slug);
449
+ if (match) {
450
+ const n = parseInt(match[1], 10);
451
+ if (n > maxSuffix) maxSuffix = n;
452
+ }
453
+ }
454
+ return `${baseSlug}-${maxSuffix + 1}`;
455
+ }
456
+ /**
457
+ * Duplicate a content item
458
+ * Creates a new draft copy with "(Copy)" appended to the title.
459
+ * A slug is auto-generated from the new title by the handler layer.
460
+ */
461
+ async duplicate(type, id, authorId) {
462
+ const original = await this.findById(type, id);
463
+ if (!original) throw new EmDashValidationError("Content item not found");
464
+ const newData = { ...original.data };
465
+ if (typeof newData.title === "string") newData.title = `${newData.title} (Copy)`;
466
+ else if (typeof newData.name === "string") newData.name = `${newData.name} (Copy)`;
467
+ const slugSource = typeof newData.title === "string" ? newData.title : typeof newData.name === "string" ? newData.name : null;
468
+ const slug = slugSource ? await this.generateUniqueSlug(type, slugSource, original.locale ?? void 0) : null;
469
+ return this.create({
470
+ type,
471
+ slug,
472
+ data: newData,
473
+ status: "draft",
474
+ authorId: authorId || original.authorId || void 0,
475
+ locale: original.locale ?? void 0
476
+ });
477
+ }
478
+ /**
479
+ * Find content by ID
480
+ */
481
+ async findById(type, id) {
482
+ const tableName = getTableName(type);
483
+ const row = (await sql`
484
+ SELECT * FROM ${sql.ref(tableName)}
485
+ WHERE id = ${id}
486
+ AND deleted_at IS NULL
487
+ `.execute(this.db)).rows[0];
488
+ if (!row) return null;
489
+ return this.mapRow(type, row);
490
+ }
491
+ async findManyByIds(type, ids, options = {}) {
492
+ const items = /* @__PURE__ */ new Map();
493
+ if (ids.length === 0) return items;
494
+ const tableName = getTableName(type);
495
+ const deletedFilter = options.includeTrashed ? sql`` : sql`AND deleted_at IS NULL`;
496
+ for (const batch of chunks([...new Set(ids)], SQL_BATCH_SIZE)) {
497
+ const result = await sql`
498
+ SELECT * FROM ${sql.ref(tableName)}
499
+ WHERE id IN (${sql.join(batch)}) ${deletedFilter}
500
+ `.execute(this.db);
501
+ for (const row of result.rows) {
502
+ const item = this.mapRow(type, row);
503
+ items.set(item.id, item);
504
+ }
505
+ }
506
+ return items;
507
+ }
508
+ async findManyBySlugsInLocale(type, slugs, locale, options = {}) {
509
+ const items = /* @__PURE__ */ new Map();
510
+ if (slugs.length === 0) return items;
511
+ const tableName = getTableName(type);
512
+ const deletedFilter = options.includeTrashed ? sql`` : sql`AND deleted_at IS NULL`;
513
+ const statusFilter = options.publishedOnly ? sql`AND status = ${"published"}` : sql``;
514
+ for (const batch of chunks([...new Set(slugs)], SQL_BATCH_SIZE)) {
515
+ const result = await sql`
516
+ SELECT * FROM ${sql.ref(tableName)}
517
+ WHERE slug IN (${sql.join(batch)}) AND ${localeMatches("locale", locale)} ${deletedFilter} ${statusFilter}
518
+ ORDER BY ${localeOrder("locale", locale)}, id ASC
519
+ `.execute(this.db);
520
+ for (const row of result.rows) {
521
+ const item = this.mapRow(type, row);
522
+ if (item.slug !== null && !items.has(item.slug)) items.set(item.slug, item);
523
+ }
524
+ }
525
+ return items;
526
+ }
527
+ /**
528
+ * Find content by id, including trashed (soft-deleted) items.
529
+ * Used by restore endpoint for ownership checks.
530
+ *
531
+ * `deletedAt` rides along because the row is already in hand: a caller that
532
+ * has to know whether the row is trashed before touching anything else would
533
+ * otherwise pay a second read for a column this row already carries.
534
+ */
535
+ async findByIdIncludingTrashed(type, id) {
536
+ const tableName = getTableName(type);
537
+ const row = (await sql`
538
+ SELECT * FROM ${sql.ref(tableName)}
539
+ WHERE id = ${id}
540
+ `.execute(this.db)).rows[0];
541
+ if (!row) return null;
542
+ return {
543
+ ...this.mapRow(type, row),
544
+ deletedAt: typeof row.deleted_at === "string" ? row.deleted_at : null
545
+ };
546
+ }
547
+ /**
548
+ * Find content by ID or slug. Tries ID first if it looks like a ULID,
549
+ * otherwise tries slug. Falls back to the other if the first lookup misses.
550
+ */
551
+ async findByIdOrSlug(type, identifier, locale) {
552
+ return this._findByIdOrSlug(type, identifier, false, locale);
553
+ }
554
+ /**
555
+ * Find content by ID or slug, including trashed (soft-deleted) items.
556
+ * Used by restore/permanent-delete endpoints.
557
+ */
558
+ async findByIdOrSlugIncludingTrashed(type, identifier, locale) {
559
+ return this._findByIdOrSlug(type, identifier, true, locale);
560
+ }
561
+ async isTrashed(type, id) {
562
+ const tableName = getTableName(type);
563
+ return await this.db.selectFrom(tableName).select("id").where("id", "=", id).where("deleted_at", "is not", null).executeTakeFirst() !== void 0;
564
+ }
565
+ async _findByIdOrSlug(type, identifier, includeTrashed, locale) {
566
+ const looksLikeUlid = ULID_PATTERN.test(identifier);
567
+ const findById = includeTrashed ? (t, id) => this.findByIdIncludingTrashed(t, id) : (t, id) => this.findById(t, id);
568
+ const findBySlug = includeTrashed ? (t, s) => this.findBySlugIncludingTrashed(t, s, locale) : (t, s) => this.findBySlug(t, s, locale);
569
+ try {
570
+ if (looksLikeUlid) {
571
+ const byId = await findById(type, identifier);
572
+ if (byId) return byId;
573
+ return await findBySlug(type, identifier);
574
+ }
575
+ const bySlug = await findBySlug(type, identifier);
576
+ if (bySlug) return bySlug;
577
+ return await findById(type, identifier);
578
+ } catch (error) {
579
+ if (isMissingTableError(error)) return null;
580
+ throw error;
581
+ }
582
+ }
583
+ /**
584
+ * Find content by slug
585
+ */
586
+ async findBySlug(type, slug, locale) {
587
+ const tableName = getTableName(type);
588
+ const row = (locale ? await sql`
589
+ SELECT * FROM ${sql.ref(tableName)}
590
+ WHERE slug = ${slug}
591
+ AND ${localeMatches("locale", locale)}
592
+ AND deleted_at IS NULL
593
+ ORDER BY ${localeOrder("locale", locale)}, id ASC
594
+ `.execute(this.db) : await sql`
595
+ SELECT * FROM ${sql.ref(tableName)}
596
+ WHERE slug = ${slug}
597
+ AND deleted_at IS NULL
598
+ ORDER BY locale ASC
599
+ LIMIT 1
600
+ `.execute(this.db)).rows[0];
601
+ if (!row) return null;
602
+ return this.mapRow(type, row);
603
+ }
604
+ /**
605
+ * Find content by slug, including trashed (soft-deleted) items.
606
+ * Used by restore/permanent-delete endpoints.
607
+ */
608
+ async findBySlugIncludingTrashed(type, slug, locale) {
609
+ const tableName = getTableName(type);
610
+ const row = (locale ? await sql`
611
+ SELECT * FROM ${sql.ref(tableName)}
612
+ WHERE slug = ${slug}
613
+ AND ${localeMatches("locale", locale)}
614
+ ORDER BY ${localeOrder("locale", locale)}, id ASC
615
+ `.execute(this.db) : await sql`
616
+ SELECT * FROM ${sql.ref(tableName)}
617
+ WHERE slug = ${slug}
618
+ ORDER BY locale ASC
619
+ LIMIT 1
620
+ `.execute(this.db)).rows[0];
621
+ if (!row) return null;
622
+ return this.mapRow(type, row);
623
+ }
624
+ /**
625
+ * Find many content items with filtering and pagination
626
+ */
627
+ async findMany(type, options = {}) {
628
+ const tableName = getTableName(type);
629
+ const limit = Math.max(1, Math.min(options.limit || 50, 100));
630
+ assertPageOffset(options.offset, options.cursor);
631
+ const orderField = options.orderBy?.field || "createdAt";
632
+ const orderDirection = options.orderBy?.direction || "desc";
633
+ const resolvedOrderField = await this.resolveOrderField(type, orderField, options.sortableExtras);
634
+ const dbField = resolvedOrderField.column;
635
+ const nullableOrder = resolvedOrderField.indexedCustomField || !NON_NULL_ORDER_COLUMNS.has(dbField);
636
+ const resolvedFieldFilters = await this.resolveFieldFilters(type, options.where?.fieldFilters);
637
+ const safeOrderDirection = orderDirection.toLowerCase() === "asc" ? "ASC" : "DESC";
638
+ let query = this.db.selectFrom(tableName).selectAll().where("deleted_at", "is", null);
639
+ if (options.where?.status) query = query.where("status", "=", options.where.status);
640
+ if (options.where?.authorId) query = query.where("author_id", "=", options.where.authorId);
641
+ if (options.where?.locale) query = query.where(localeMatches("locale", options.where.locale));
642
+ query = this.applySearchFilter(query, options.where, type);
643
+ query = this.applyDateFilter(query, options.where);
644
+ query = this.applyBylineFilter(query, options.where, type);
645
+ query = this.applyFieldFilters(query, resolvedFieldFilters);
646
+ if (options.cursor) if (resolvedOrderField.indexedCustomField) {
647
+ const { value, id: cursorId } = decodeNullableOrderCursor(options.cursor, orderField);
648
+ const isPresent = sql`${sql.ref(dbField)} IS NOT NULL`;
649
+ const falseLiteral = sql`FALSE`;
650
+ const trueLiteral = sql`TRUE`;
651
+ if (safeOrderDirection === "ASC" && value === null) query = query.where(sql`(
652
+ (${isPresent}) > ${falseLiteral}
653
+ OR ((${isPresent}) = ${falseLiteral} AND ${sql.ref("id")} > ${cursorId})
654
+ )`);
655
+ else if (safeOrderDirection === "DESC" && value === null) query = query.where(sql`
656
+ (${isPresent}) = ${falseLiteral} AND ${sql.ref("id")} < ${cursorId}
657
+ `);
658
+ else if (safeOrderDirection === "ASC") query = query.where(sql`
659
+ (${isPresent}, ${sql.ref(dbField)}, ${sql.ref("id")})
660
+ > (${trueLiteral}, ${value}, ${cursorId})
661
+ `);
662
+ else query = query.where(sql`
663
+ (${isPresent}, ${sql.ref(dbField)}, ${sql.ref("id")})
664
+ < (${trueLiteral}, ${value}, ${cursorId})
665
+ `);
666
+ } else if (nullableOrder) {
667
+ const { value, id: cursorId } = decodeNullableOrderCursor(options.cursor, orderField, { acceptPlain: true });
668
+ query = query.where(nullableOrderCondition(this.db, dbField, safeOrderDirection, value, cursorId));
669
+ } else {
670
+ const { orderValue, id: cursorId } = decodeCursor(options.cursor);
671
+ if (safeOrderDirection === "DESC") query = query.where((eb) => eb.or([eb(dbField, "<", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", "<", cursorId)])]));
672
+ else query = query.where((eb) => eb.or([eb(dbField, ">", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", ">", cursorId)])]));
673
+ }
674
+ const indexedOrderFilter = resolvedOrderField.indexedCustomField ? resolvedFieldFilters.find((filter) => filter.column === dbField) : void 0;
675
+ if (resolvedOrderField.indexedCustomField && !indexedOrderFilter) query = query.orderBy(sql`${sql.ref(dbField)} IS NOT NULL`, safeOrderDirection === "ASC" ? "asc" : "desc");
676
+ if (indexedOrderFilter?.kind !== "null") query = query.orderBy(dbField, safeOrderDirection === "ASC" ? "asc" : "desc");
677
+ query = query.orderBy("id", safeOrderDirection === "ASC" ? "asc" : "desc");
678
+ query = options.offset === void 0 ? query.limit(limit + 1) : query.limit(limit).offset(options.offset);
679
+ const [rowsResult, countResult] = await Promise.allSettled([query.execute(), this.countWithResolvedFilters(type, options.where, resolvedFieldFilters)]);
680
+ if (rowsResult.status === "rejected") throw rowsResult.reason;
681
+ if (countResult.status === "rejected") throw countResult.reason;
682
+ const rows = rowsResult.value;
683
+ const total = countResult.value;
684
+ const hasMore = rows.length > limit;
685
+ const items = rows.slice(0, limit);
686
+ const mappedResult = {
687
+ items: items.map((row) => this.mapRow(type, row)),
688
+ total
689
+ };
690
+ if (hasMore && items.length > 0) {
691
+ const lastRow = items.at(-1);
692
+ const lastOrderValue = lastRow[dbField];
693
+ if (nullableOrder) {
694
+ if (lastOrderValue !== null && typeof lastOrderValue !== "string" && typeof lastOrderValue !== "number") throw new EmDashValidationError(`Invalid value for order field: ${orderField}`);
695
+ mappedResult.nextCursor = encodeNullableOrderCursor(orderField, lastOrderValue, String(lastRow.id));
696
+ } else mappedResult.nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
697
+ }
698
+ return mappedResult;
699
+ }
700
+ /**
701
+ * Update content
702
+ */
703
+ async update(type, id, input, expectedRevision) {
704
+ const tableName = getTableName(type);
705
+ const now = (/* @__PURE__ */ new Date()).toISOString();
706
+ await this.assertAliasAwareSlugAvailable(type, input.slug, input.locale, id);
707
+ const updates = {};
708
+ if (input.status !== void 0) updates.status = input.status;
709
+ if (input.slug !== void 0) updates.slug = input.slug;
710
+ if (input.publishedAt !== void 0) updates.published_at = input.publishedAt === null ? null : await this.datetimes.normalizeValue(type, input.publishedAt);
711
+ if (input.scheduledAt !== void 0) updates.scheduled_at = input.scheduledAt === null ? null : await this.datetimes.normalizeValue(type, input.scheduledAt);
712
+ if (input.authorId !== void 0) updates.author_id = input.authorId;
713
+ if (input.primaryBylineId !== void 0) updates.primary_byline_id = input.primaryBylineId;
714
+ if (input.data !== void 0 && typeof input.data === "object") {
715
+ const data = await this.datetimes.normalizeInput(type, writableContentData(input.data));
716
+ for (const [key, value] of Object.entries(data)) updates[key] = serializeValue(value);
717
+ }
718
+ const hasColumnWrites = Object.keys(updates).length > 0;
719
+ if (hasColumnWrites) updates.updated_at = now;
720
+ if (input.draftRevisionId === null) updates.draft_revision_id = null;
721
+ updates.version = sql`version + 1`;
722
+ let query = this.db.updateTable(tableName).set(updates).where("id", "=", id).where("deleted_at", "is", null);
723
+ if (expectedRevision) query = query.where(sql`version = ${expectedRevision.version}`).where(sql`updated_at = ${expectedRevision.updatedAt}`);
724
+ const result = await query.executeTakeFirst();
725
+ if (expectedRevision && result.numUpdatedRows === 0n) throw new ContentMutationConflictError();
726
+ if (hasColumnWrites) invalidateCollectionCache(type);
727
+ const updated = await this.findById(type, id);
728
+ if (!updated) throw new Error("Content not found");
729
+ return updated;
730
+ }
731
+ async restoreRevision(type, id, revisionData, authorId) {
732
+ const tableName = getTableName(type);
733
+ const existing = await this.findById(type, id);
734
+ if (!existing) throw new EmDashValidationError("Content item not found");
735
+ const normalizedSnapshot = await this.datetimes.normalizeData(type, revisionData);
736
+ const { _slug } = normalizedSnapshot;
737
+ const snapshotFields = {};
738
+ for (const [key, value] of Object.entries(normalizedSnapshot)) if (!key.startsWith("_")) snapshotFields[key] = value;
739
+ const fieldData = writableContentData(snapshotFields);
740
+ const revisionId = createRevisionId();
741
+ const now = (/* @__PURE__ */ new Date()).toISOString();
742
+ const assignments = [];
743
+ if (typeof _slug === "string") assignments.push(sql`slug = ${_slug}`);
744
+ for (const [field, value] of Object.entries(fieldData)) {
745
+ validateIdentifier(field, "content field name");
746
+ assignments.push(sql`${sql.ref(field)} = ${serializeValue(value)}`);
747
+ }
748
+ assignments.push(sql`draft_revision_id = ${revisionId}`, sql`updated_at = ${now}`, sql`version = version + 1`);
749
+ const buildQueries = () => {
750
+ return [
751
+ sql`
752
+ INSERT INTO revisions (id, collection, entry_id, data, author_id)
753
+ VALUES (${revisionId}, ${type}, ${id}, ${JSON.stringify(normalizedSnapshot)}, ${authorId})
754
+ RETURNING id
755
+ `,
756
+ sql`
757
+ UPDATE ${sql.ref(tableName)}
758
+ SET ${sql.join(assignments, sql`, `)}
759
+ WHERE id = ${id}
760
+ AND deleted_at IS NULL
761
+ AND version = ${existing.version}
762
+ AND updated_at = ${existing.updatedAt}
763
+ AND status = ${existing.status}
764
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
765
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
766
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
767
+ RETURNING id
768
+ `,
769
+ sql`
770
+ DELETE FROM revisions
771
+ WHERE id = ${revisionId}
772
+ AND NOT EXISTS (
773
+ SELECT 1 FROM ${sql.ref(tableName)}
774
+ WHERE id = ${id}
775
+ AND draft_revision_id = ${revisionId}
776
+ AND version = ${existing.version + 1}
777
+ )
778
+ `,
779
+ sql`
780
+ UPDATE ${sql.ref(tableName)}
781
+ SET draft_revision_id = ${existing.draftRevisionId}
782
+ WHERE id = ${id}
783
+ AND draft_revision_id = ${revisionId}
784
+ AND version = ${existing.version + 1}
785
+ RETURNING id
786
+ `
787
+ ];
788
+ };
789
+ const batched = await executeAtomicBatchIfSupported(this.db, buildQueries());
790
+ if (batched) {
791
+ if (batched[0]?.rows.length !== 1 || batched[1]?.rows.length !== 1 || batched[3]?.rows.length !== 1) throw new ContentMutationConflictError();
792
+ } else await withTransaction(this.db, async (trx) => {
793
+ const [audit, update, removeUnappliedAudit, releaseMarker] = buildQueries();
794
+ if ((await audit.execute(trx)).rows.length !== 1) throw new ContentMutationConflictError();
795
+ const updateResult = await update.execute(trx);
796
+ await removeUnappliedAudit.execute(trx);
797
+ const releaseResult = await releaseMarker.execute(trx);
798
+ if (updateResult.rows.length !== 1 || releaseResult.rows.length !== 1) throw new ContentMutationConflictError();
799
+ });
800
+ invalidateCollectionCache(type);
801
+ const item = await this.findById(type, id);
802
+ if (!item) throw new Error("Content not found");
803
+ await new RevisionRepository(this.db, this.datetimeContexts).queuePruning(type, id, revisionId);
804
+ return {
805
+ item,
806
+ revisionId
807
+ };
808
+ }
809
+ async restoreDraftRevision(type, id, revisionData, authorId) {
810
+ const tableName = getTableName(type);
811
+ const existing = await this.findById(type, id);
812
+ if (!existing) return null;
813
+ const normalizedSnapshot = await this.datetimes.normalizeData(type, revisionData);
814
+ const revisionId = createRevisionId();
815
+ const buildQueries = () => {
816
+ return [
817
+ sql`
818
+ INSERT INTO revisions (id, collection, entry_id, data, author_id)
819
+ VALUES (${revisionId}, ${type}, ${id}, ${JSON.stringify(normalizedSnapshot)}, ${authorId})
820
+ RETURNING id
821
+ `,
822
+ sql`
823
+ UPDATE ${sql.ref(tableName)}
824
+ SET draft_revision_id = ${revisionId},
825
+ version = version + 1
826
+ WHERE id = ${id}
827
+ AND deleted_at IS NULL
828
+ AND version = ${existing.version}
829
+ AND updated_at = ${existing.updatedAt}
830
+ AND status = ${existing.status}
831
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
832
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
833
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
834
+ RETURNING id
835
+ `,
836
+ sql`
837
+ DELETE FROM revisions
838
+ WHERE id = ${revisionId}
839
+ AND NOT EXISTS (
840
+ SELECT 1 FROM ${sql.ref(tableName)}
841
+ WHERE id = ${id}
842
+ AND draft_revision_id = ${revisionId}
843
+ AND version = ${existing.version + 1}
844
+ )
845
+ `
846
+ ];
847
+ };
848
+ const batched = await executeAtomicBatchIfSupported(this.db, buildQueries());
849
+ if (batched) {
850
+ if (batched[0]?.rows.length !== 1 || batched[1]?.rows.length !== 1) throw new ContentMutationConflictError();
851
+ } else await withTransaction(this.db, async (trx) => {
852
+ const [audit, stage, removeUnstagedAudit] = buildQueries();
853
+ if ((await audit.execute(trx)).rows.length !== 1) throw new ContentMutationConflictError();
854
+ const stageResult = await stage.execute(trx);
855
+ await removeUnstagedAudit.execute(trx);
856
+ if (stageResult.rows.length !== 1) throw new ContentMutationConflictError();
857
+ });
858
+ invalidateCollectionCache(type);
859
+ await new RevisionRepository(this.db, this.datetimeContexts).queuePruning(type, id, revisionId);
860
+ return revisionId;
861
+ }
862
+ /**
863
+ * Update plugin-authored fields without letting content columns diverge
864
+ * from the revision pointers that publication promotes.
865
+ */
866
+ async updateDraftAware(type, id, input) {
867
+ const data = input.data ? await this.datetimes.normalizeInput(type, writableContentData(input.data)) : {};
868
+ const stagedSlug = typeof input.slug === "string" ? input.slug : void 0;
869
+ if (!(Object.keys(data).length > 0 || stagedSlug !== void 0)) return this.update(type, id, {
870
+ ...input,
871
+ data
872
+ });
873
+ 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();
874
+ const supportsRaw = collectionRows[0]?.supports;
875
+ const supports = supportsRaw ? JSON.parse(supportsRaw) : [];
876
+ if (!Array.isArray(supports) || !supports.includes("revisions")) return this.update(type, id, {
877
+ ...input,
878
+ data,
879
+ draftRevisionId: null
880
+ });
881
+ const fieldSlugs = new Set(collectionRows.map((row) => row.fieldSlug).filter((slug) => Boolean(slug)));
882
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
883
+ let existing = await this.findById(type, id);
884
+ let incoming = data;
885
+ if (existing) {
886
+ let stored = existing.data ?? {};
887
+ if (existing.draftRevisionId) {
888
+ const draft = await revisionRepo.findById(existing.draftRevisionId);
889
+ if (draft?.data) stored = {
890
+ ...stored,
891
+ ...draft.data
892
+ };
893
+ }
894
+ const stale = staleStoredKeys(data, stored, fieldSlugs);
895
+ if (stale.length > 0) {
896
+ incoming = { ...data };
897
+ for (const key of stale) delete incoming[key];
898
+ }
899
+ }
900
+ for (const field of Object.keys(incoming)) if (!fieldSlugs.has(field)) throw new EmDashValidationError(`Unknown field '${field}' in collection '${type}'`);
901
+ for (let attempt = 0; existing && attempt < MAX_DRAFT_STAGE_ATTEMPTS; attempt++) {
902
+ let baseData = existing.data;
903
+ if (existing.draftRevisionId) {
904
+ const draft = await revisionRepo.findById(existing.draftRevisionId);
905
+ if (draft) baseData = draft.data;
906
+ }
907
+ const mergedData = keepKnownFields({
908
+ ...baseData,
909
+ ...incoming
910
+ }, fieldSlugs);
911
+ if (stagedSlug !== void 0) mergedData._slug = stagedSlug;
912
+ const revision = await revisionRepo.create({
913
+ collection: type,
914
+ entryId: id,
915
+ data: mergedData,
916
+ ...input.revisionAuthorId ? { authorId: input.revisionAuthorId } : {}
917
+ });
918
+ let staged;
919
+ try {
920
+ staged = await this.replaceDraftRevisionForUpdate(type, id, revision.id, existing, input);
921
+ } catch (error) {
922
+ await this.deleteUnstagedRevision(revisionRepo, type, id, revision.id);
923
+ throw error;
924
+ }
925
+ if (staged) {
926
+ const updated = await this.findById(type, id);
927
+ if (!updated) throw new Error("Content not found");
928
+ const draftData = {};
929
+ for (const [key, value] of Object.entries(mergedData)) if (!key.startsWith("_")) draftData[key] = value;
930
+ return {
931
+ ...updated,
932
+ data: {
933
+ ...updated.data,
934
+ ...draftData
935
+ }
936
+ };
937
+ }
938
+ await this.deleteUnstagedRevision(revisionRepo, type, id, revision.id);
939
+ existing = await this.findById(type, id);
940
+ }
941
+ if (!existing) throw new Error("Content not found");
942
+ throw new ContentMutationConflictError();
943
+ }
944
+ async deleteUnstagedRevision(revisionRepo, type, id, revisionId) {
945
+ try {
946
+ await revisionRepo.deleteIfUnreferenced(type, id, revisionId);
947
+ } catch (error) {
948
+ console.error(`[content] Failed to clean up unstaged revision ${revisionId}:`, error);
949
+ }
950
+ }
951
+ async replaceDraftRevisionForUpdate(type, id, revisionId, expected, input) {
952
+ const tableName = getTableName(type);
953
+ const assignments = [sql`draft_revision_id = ${revisionId}`];
954
+ let liveMetadataChanged = false;
955
+ if (input.status !== void 0) {
956
+ assignments.push(sql`status = ${input.status}`);
957
+ liveMetadataChanged = true;
958
+ }
959
+ if (input.slug === null) {
960
+ assignments.push(sql`slug = NULL`);
961
+ liveMetadataChanged = true;
962
+ }
963
+ if (input.publishedAt !== void 0) {
964
+ const publishedAt = input.publishedAt === null ? null : await this.datetimes.normalizeValue(type, input.publishedAt);
965
+ assignments.push(sql`published_at = ${publishedAt}`);
966
+ liveMetadataChanged = true;
967
+ }
968
+ if (input.scheduledAt !== void 0) {
969
+ const scheduledAt = input.scheduledAt === null ? null : await this.datetimes.normalizeValue(type, input.scheduledAt);
970
+ assignments.push(sql`scheduled_at = ${scheduledAt}`);
971
+ liveMetadataChanged = true;
972
+ }
973
+ if (input.authorId !== void 0) {
974
+ assignments.push(sql`author_id = ${input.authorId}`);
975
+ liveMetadataChanged = true;
976
+ }
977
+ if (input.primaryBylineId !== void 0) {
978
+ assignments.push(sql`primary_byline_id = ${input.primaryBylineId}`);
979
+ liveMetadataChanged = true;
980
+ }
981
+ if (liveMetadataChanged) assignments.push(sql`updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}`);
982
+ assignments.push(sql`version = version + 1`);
983
+ const changed = ((await sql`
984
+ UPDATE ${sql.ref(tableName)}
985
+ SET ${sql.join(assignments, sql`, `)}
986
+ WHERE id = ${id}
987
+ AND deleted_at IS NULL
988
+ AND version = ${expected.version}
989
+ AND ${nullableColumnMatch("live_revision_id", expected.liveRevisionId)}
990
+ AND ${nullableColumnMatch("draft_revision_id", expected.draftRevisionId)}
991
+ AND EXISTS (
992
+ SELECT 1 FROM revisions
993
+ WHERE revisions.id = ${revisionId}
994
+ AND revisions.collection = ${type}
995
+ AND revisions.entry_id = ${id}
996
+ )
997
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
998
+ if (changed && liveMetadataChanged) invalidateCollectionCache(type);
999
+ return changed;
1000
+ }
1001
+ /**
1002
+ * Copy non-translatable field values to every other entry in the
1003
+ * translation group, trashed entries included.
1004
+ *
1005
+ * Only the fields present in `data` are copied. With `previous`, `data` is
1006
+ * the entry's complete new state and only the fields whose value differs
1007
+ * from `previous` are copied, an absent field as null. An entry that already
1008
+ * holds every copied value is left untouched, so its `updated_at` does not
1009
+ * move.
1010
+ *
1011
+ * On collections with revisions a changed entry also gets a new live
1012
+ * revision, because republishing and unpublishing read that revision rather
1013
+ * than the columns. A pending draft takes a value only where it still holds
1014
+ * the entry's previous value, so an unpublished edit to the field survives.
1015
+ */
1016
+ async syncNonTranslatableFields(type, sourceId, translationGroup, data, options = {}) {
1017
+ const tableName = getTableName(type);
1018
+ 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();
1019
+ const { previous } = options;
1020
+ const values = {};
1021
+ for (const { fieldSlug } of collectionRows) {
1022
+ if (!fieldSlug) continue;
1023
+ if (previous) {
1024
+ if (!sameStoredValue(previous[fieldSlug], data[fieldSlug])) values[fieldSlug] = data[fieldSlug] ?? null;
1025
+ } else if (fieldSlug in data) values[fieldSlug] = data[fieldSlug];
1026
+ }
1027
+ if (Object.keys(values).length === 0) return;
1028
+ const normalizedValues = await this.datetimes.normalizeData(type, values);
1029
+ const supportsRaw = collectionRows[0]?.supports;
1030
+ const supports = supportsRaw ? JSON.parse(supportsRaw) : [];
1031
+ const usesRevisions = Array.isArray(supports) && supports.includes("revisions");
1032
+ const siblings = await sql`
1033
+ SELECT * FROM ${sql.ref(tableName)}
1034
+ WHERE translation_group = ${translationGroup}
1035
+ AND id != ${sourceId}
1036
+ `.execute(this.db);
1037
+ let changed = false;
1038
+ for (const row of siblings.rows) if (await this.syncSiblingValues(type, this.mapRow(type, row), normalizedValues, usesRevisions)) changed = true;
1039
+ if (changed) invalidateCollectionCache(type);
1040
+ }
1041
+ async syncSiblingValues(type, initial, values, usesRevisions) {
1042
+ const tableName = getTableName(type);
1043
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1044
+ let sibling = initial;
1045
+ for (let attempt = 0; sibling && attempt < MAX_DRAFT_STAGE_ATTEMPTS; attempt++) {
1046
+ const current = sibling;
1047
+ const changed = {};
1048
+ for (const [field, value] of Object.entries(values)) if (!sameStoredValue(current.data[field], value)) changed[field] = value;
1049
+ if (Object.keys(changed).length === 0) return false;
1050
+ const assignments = [];
1051
+ for (const [field, value] of Object.entries(changed)) {
1052
+ validateIdentifier(field, "content field name");
1053
+ assignments.push(sql`${sql.ref(field)} = ${serializeValue(value)}`);
1054
+ }
1055
+ const createdRevisionIds = [];
1056
+ const cleanUp = async () => {
1057
+ for (const revisionId of createdRevisionIds) await this.deleteUnstagedRevision(revisionRepo, type, current.id, revisionId);
1058
+ };
1059
+ let synced;
1060
+ try {
1061
+ const live = usesRevisions && current.liveRevisionId ? await revisionRepo.findById(current.liveRevisionId) : null;
1062
+ if (live) {
1063
+ const revision = await revisionRepo.create({
1064
+ collection: type,
1065
+ entryId: current.id,
1066
+ data: {
1067
+ ...live.data,
1068
+ ...changed
1069
+ }
1070
+ });
1071
+ createdRevisionIds.push(revision.id);
1072
+ assignments.push(sql`live_revision_id = ${revision.id}`);
1073
+ }
1074
+ const draft = usesRevisions && current.draftRevisionId ? await revisionRepo.findById(current.draftRevisionId) : null;
1075
+ const carried = {};
1076
+ for (const [field, value] of Object.entries(changed)) if (draft && sameStoredValue(draft.data[field], current.data[field])) carried[field] = value;
1077
+ if (draft && Object.keys(carried).length > 0) {
1078
+ const revision = await revisionRepo.create({
1079
+ collection: type,
1080
+ entryId: current.id,
1081
+ data: {
1082
+ ...draft.data,
1083
+ ...carried
1084
+ }
1085
+ });
1086
+ createdRevisionIds.push(revision.id);
1087
+ assignments.push(sql`draft_revision_id = ${revision.id}`);
1088
+ }
1089
+ assignments.push(sql`updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}`, sql`version = version + 1`);
1090
+ synced = ((await sql`
1091
+ UPDATE ${sql.ref(tableName)}
1092
+ SET ${sql.join(assignments, sql`, `)}
1093
+ WHERE id = ${current.id}
1094
+ AND version = ${current.version}
1095
+ AND ${nullableColumnMatch("live_revision_id", current.liveRevisionId)}
1096
+ AND ${nullableColumnMatch("draft_revision_id", current.draftRevisionId)}
1097
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1098
+ } catch (error) {
1099
+ await cleanUp();
1100
+ throw error;
1101
+ }
1102
+ if (synced) return true;
1103
+ await cleanUp();
1104
+ sibling = await this.findByIdIncludingTrashed(type, current.id);
1105
+ }
1106
+ if (!sibling) return false;
1107
+ throw new ContentMutationConflictError();
1108
+ }
1109
+ /**
1110
+ * Delete content (soft delete - moves to trash)
1111
+ */
1112
+ async delete(type, id) {
1113
+ const tableName = getTableName(type);
1114
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1115
+ const changed = ((await sql`
1116
+ UPDATE ${sql.ref(tableName)}
1117
+ SET deleted_at = ${now}
1118
+ WHERE id = ${id}
1119
+ AND deleted_at IS NULL
1120
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1121
+ if (changed) invalidateCollectionCache(type);
1122
+ return changed;
1123
+ }
1124
+ /**
1125
+ * Restore content from trash
1126
+ *
1127
+ * The entry comes back as a draft with no schedule. The live version is not
1128
+ * copied into a draft revision: collections without revisions save to the
1129
+ * columns, and a draft revision would hide those saves.
1130
+ */
1131
+ async restore(type, id, expectedRevision) {
1132
+ const tableName = getTableName(type);
1133
+ const existing = await this.findByIdOrSlugIncludingTrashed(type, id);
1134
+ if (!existing) return null;
1135
+ assertRevisionPrecondition(existing, expectedRevision);
1136
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1137
+ const restored = (await sql`
1138
+ UPDATE ${sql.ref(tableName)}
1139
+ SET deleted_at = NULL,
1140
+ live_revision_id = NULL,
1141
+ status = 'draft',
1142
+ scheduled_at = NULL,
1143
+ updated_at = ${now},
1144
+ version = ${existing.version + 1}
1145
+ WHERE id = ${existing.id}
1146
+ AND deleted_at IS NOT NULL
1147
+ AND version = ${existing.version}
1148
+ AND updated_at = ${existing.updatedAt}
1149
+ RETURNING *
1150
+ `.execute(this.db)).rows[0];
1151
+ if (!restored) throw new ContentMutationConflictError("Content changed while restoring");
1152
+ invalidateCollectionCache(type);
1153
+ return this.mapRow(type, restored);
1154
+ }
1155
+ /**
1156
+ * Permanently delete content (cannot be undone)
1157
+ */
1158
+ /**
1159
+ * Permanently delete a soft-deleted content row.
1160
+ *
1161
+ * Returns `true` only when a soft-deleted (trashed) row was removed.
1162
+ * Returns `false` when no row exists OR when the row exists but is live —
1163
+ * the caller is responsible for distinguishing these cases (typically via
1164
+ * a follow-up `findByIdOrSlugIncludingTrashed` to surface NOT_FOUND vs
1165
+ * NOT_TRASHED). The `AND deleted_at IS NOT NULL` clause is the safety net
1166
+ * that prevents permanent delete from bypassing the trash workflow.
1167
+ */
1168
+ async permanentDelete(type, id) {
1169
+ const tableName = getTableName(type);
1170
+ const changed = ((await sql`
1171
+ DELETE FROM ${sql.ref(tableName)}
1172
+ WHERE id = ${id}
1173
+ AND deleted_at IS NOT NULL
1174
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1175
+ if (changed) invalidateCollectionCache(type);
1176
+ return changed;
1177
+ }
1178
+ /**
1179
+ * Find trashed content items
1180
+ */
1181
+ async findTrashed(type, options = {}) {
1182
+ const tableName = getTableName(type);
1183
+ const limit = Math.max(1, Math.min(options.limit || 50, 100));
1184
+ assertPageOffset(options.offset, options.cursor);
1185
+ const orderField = options.orderBy?.field || "deletedAt";
1186
+ const orderDirection = options.orderBy?.direction || "desc";
1187
+ const dbField = this.mapOrderField(orderField);
1188
+ const safeOrderDirection = orderDirection.toLowerCase() === "asc" ? "ASC" : "DESC";
1189
+ let query = this.db.selectFrom(tableName).selectAll().where("deleted_at", "is not", null);
1190
+ if (options.where?.locale) query = query.where(localeMatches("locale", options.where.locale));
1191
+ if (options.cursor) {
1192
+ const { orderValue, id: cursorId } = decodeCursor(options.cursor);
1193
+ if (safeOrderDirection === "DESC") query = query.where((eb) => eb.or([eb(dbField, "<", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", "<", cursorId)])]));
1194
+ else query = query.where((eb) => eb.or([eb(dbField, ">", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", ">", cursorId)])]));
1195
+ }
1196
+ query = query.orderBy(dbField, safeOrderDirection === "ASC" ? "asc" : "desc").orderBy("id", safeOrderDirection === "ASC" ? "asc" : "desc");
1197
+ query = options.offset === void 0 ? query.limit(limit + 1) : query.limit(limit).offset(options.offset);
1198
+ const rows = await query.execute();
1199
+ const hasMore = rows.length > limit;
1200
+ const items = rows.slice(0, limit);
1201
+ const mappedResult = { items: items.map((row) => {
1202
+ const record = row;
1203
+ return {
1204
+ ...this.mapRow(type, record),
1205
+ deletedAt: typeof record.deleted_at === "string" ? record.deleted_at : ""
1206
+ };
1207
+ }) };
1208
+ if (hasMore && items.length > 0) {
1209
+ const lastRow = items.at(-1);
1210
+ const lastOrderValue = lastRow[dbField];
1211
+ mappedResult.nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
1212
+ }
1213
+ return mappedResult;
1214
+ }
1215
+ /**
1216
+ * Count trashed content items
1217
+ */
1218
+ async countTrashed(type, options = {}) {
1219
+ const tableName = getTableName(type);
1220
+ let query = this.db.selectFrom(tableName).select((eb) => eb.fn.count("id").as("count")).where("deleted_at", "is not", null);
1221
+ if (options.locale) query = query.where(localeMatches("locale", options.locale));
1222
+ const result = await query.executeTakeFirst();
1223
+ return Number(result?.count || 0);
1224
+ }
1225
+ /**
1226
+ * Apply the optional `q` filter.
1227
+ *
1228
+ * When the handler sets `useFts` (collection has a healthy FTS5 index
1229
+ * covering the display columns; SQLite only), the filter is served from
1230
+ * the index: a token-prefix MATCH against `_emdash_fts_<slug>` OR'd with
1231
+ * an index-served `slug GLOB 'term*'` prefix (the slug is not in the FTS
1232
+ * index). Both sides are index-backed, so SQLite's OR optimization avoids
1233
+ * the full-table scan the LIKE fallback needs (#1517). The trade-off is
1234
+ * search semantics: token-prefix matching instead of arbitrary substring.
1235
+ *
1236
+ * Fallback (Postgres, search disabled, or no usable terms): case-
1237
+ * insensitive substring LIKE across the handler-resolved `searchColumns`
1238
+ * (OR'd). User input is treated literally (LIKE wildcards escaped) and
1239
+ * `lower()` is applied on both sides for SQLite/Postgres parity.
1240
+ */
1241
+ applySearchFilter(query, where, type) {
1242
+ const term = where?.q?.trim();
1243
+ const columns = where?.searchColumns;
1244
+ if (!term || !columns || columns.length === 0) return query;
1245
+ if (where.useFts) {
1246
+ const match = buildFtsPrefixMatch(term);
1247
+ if (match) {
1248
+ validateIdentifier(type, "collection slug");
1249
+ const ftsTable = `_emdash_fts_${type}`;
1250
+ const slugPrefix = buildSlugGlobPrefix(term);
1251
+ 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}`]));
1252
+ }
1253
+ }
1254
+ const pattern = `%${term.replace(LIKE_WILDCARD_RE, (c) => `\\${c}`)}%`;
1255
+ return query.where((eb) => eb.or(columns.map((col) => {
1256
+ validateIdentifier(col, "search column");
1257
+ return sql`lower(CAST(${sql.ref(col)} AS TEXT)) LIKE lower(${pattern}) ESCAPE '\\'`;
1258
+ })));
1259
+ }
1260
+ /**
1261
+ * Apply the optional inclusive date-range filter. The field is mapped
1262
+ * through `DATE_FILTER_COLUMNS` (a closed whitelist), and bounds compare
1263
+ * lexicographically against the stored ISO 8601 timestamps. A `publishedAt`
1264
+ * range naturally excludes never-published rows (their column is NULL).
1265
+ */
1266
+ applyDateFilter(query, where) {
1267
+ const filter = where?.dateFilter;
1268
+ if (!filter) return query;
1269
+ const column = DATE_FILTER_COLUMNS[filter.field];
1270
+ if (!column) throw new EmDashValidationError(`Invalid date filter field: ${filter.field}`);
1271
+ const { from, to } = filter;
1272
+ if (!from && !to) return query;
1273
+ let next = query;
1274
+ if (from) next = next.where((eb) => eb(column, ">=", from));
1275
+ if (to) next = next.where((eb) => eb(column, "<=", to));
1276
+ return next;
1277
+ }
1278
+ /**
1279
+ * Apply the optional byline filter as a correlated (NOT) EXISTS against
1280
+ * `_emdash_content_bylines`.
1281
+ *
1282
+ * Correlating from the content table preserves the outer sort index so
1283
+ * `LIMIT` can short-circuit. `mode: "none"` tests the junction rather than
1284
+ * `primary_byline_id` because the two are written in the same call but
1285
+ * are not atomically consistent, so the junction is authoritative.
1286
+ *
1287
+ * Whether a credit *renders* is locale-scoped; whether one *exists* is
1288
+ * not. Both are needed: the first decides what the filter matches, the
1289
+ * second decides whether the author fallback applies at all.
1290
+ */
1291
+ applyBylineFilter(query, where, type) {
1292
+ const filter = where?.bylineFilter;
1293
+ if (!filter) return query;
1294
+ const tableName = getTableName(type);
1295
+ const idColumn = `${tableName}.id`;
1296
+ const authorColumn = `${tableName}.author_id`;
1297
+ const localeColumn = `${tableName}.locale`;
1298
+ const creditRenders = (eb, bylineIds) => {
1299
+ 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);
1300
+ sub = filter.locale ? sub.where(localeMatches("b.locale", filter.locale)) : sub.where(sql`${canonicalLocaleColumn("b.locale")} = ${canonicalLocaleColumn(localeColumn)}`);
1301
+ if (bylineIds) sub = sub.where("cb.byline_id", "in", bylineIds);
1302
+ return eb.exists(sub);
1303
+ };
1304
+ 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));
1305
+ const authorHasByline = (eb, bylineIds) => {
1306
+ let sub = eb.selectFrom("_emdash_bylines as b").select("b.id").whereRef("b.user_id", "=", authorColumn);
1307
+ sub = filter.locale ? sub.where(localeMatches("b.locale", filter.locale)) : sub.where(sql`${canonicalLocaleColumn("b.locale")} = ${canonicalLocaleColumn(localeColumn)}`);
1308
+ if (bylineIds) sub = sub.where("b.translation_group", "in", bylineIds);
1309
+ return eb.exists(sub);
1310
+ };
1311
+ if (filter.mode === "none") return query.where((eb) => {
1312
+ const uncredited = eb.not(creditRenders(eb));
1313
+ return filter.includeInferred ? eb.and([uncredited, eb.or([hasExplicitCredit(eb), eb.not(authorHasByline(eb))])]) : uncredited;
1314
+ });
1315
+ const bylineIds = filter.bylineIds ?? [];
1316
+ if (bylineIds.length === 0) return query.where(() => sql`1 = 0`);
1317
+ return query.where((eb) => {
1318
+ if (!filter.includeInferred) return creditRenders(eb, bylineIds);
1319
+ return eb.or([creditRenders(eb, bylineIds), eb.and([eb.not(hasExplicitCredit(eb)), authorHasByline(eb, bylineIds)])]);
1320
+ });
1321
+ }
1322
+ /**
1323
+ * Count content items
1324
+ */
1325
+ async count(type, where) {
1326
+ const resolvedFieldFilters = await this.resolveFieldFilters(type, where?.fieldFilters);
1327
+ return this.countWithResolvedFilters(type, where, resolvedFieldFilters);
1328
+ }
1329
+ async countWithResolvedFilters(type, where, resolvedFieldFilters) {
1330
+ const tableName = getTableName(type);
1331
+ let query = this.db.selectFrom(tableName).select((eb) => eb.fn.count("id").as("count")).where("deleted_at", "is", null);
1332
+ if (where?.status) query = query.where("status", "=", where.status);
1333
+ if (where?.authorId) query = query.where("author_id", "=", where.authorId);
1334
+ if (where?.locale) query = query.where(localeMatches("locale", where.locale));
1335
+ query = this.applySearchFilter(query, where, type);
1336
+ query = this.applyDateFilter(query, where);
1337
+ query = this.applyBylineFilter(query, where, type);
1338
+ query = this.applyFieldFilters(query, resolvedFieldFilters);
1339
+ const result = await query.executeTakeFirst();
1340
+ return Number(result?.count || 0);
1341
+ }
1342
+ /**
1343
+ * Distinct, non-null `author_id` values across the collection's live
1344
+ * (non-trashed) content. Used to populate the admin author filter with
1345
+ * only the users who have actually authored entries, rather than the
1346
+ * full user directory (which requires admin privileges to read).
1347
+ */
1348
+ async findDistinctAuthorIds(type) {
1349
+ const tableName = getTableName(type);
1350
+ 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);
1351
+ }
1352
+ async getStats(type, now = /* @__PURE__ */ new Date()) {
1353
+ const tableName = getTableName(type);
1354
+ const nowIso = now.toISOString();
1355
+ const result = await this.db.selectFrom(tableName).select((eb) => [
1356
+ eb.fn.count("id").as("total"),
1357
+ eb.fn.sum(eb.case().when("status", "=", "published").then(1).else(0).end()).as("published"),
1358
+ eb.fn.sum(eb.case().when("status", "=", "draft").then(1).else(0).end()).as("draft"),
1359
+ sql`SUM(CASE WHEN scheduled_at IS NOT NULL THEN 1 ELSE 0 END)`.as("scheduled"),
1360
+ sql`SUM(CASE WHEN scheduled_at IS NOT NULL AND scheduled_at <= ${nowIso} THEN 1 ELSE 0 END)`.as("overdue_scheduled")
1361
+ ]).where("deleted_at", "is", null).executeTakeFirst();
1362
+ return {
1363
+ total: Number(result?.total || 0),
1364
+ published: Number(result?.published || 0),
1365
+ draft: Number(result?.draft || 0),
1366
+ scheduled: Number(result?.scheduled || 0),
1367
+ overdueScheduled: Number(result?.overdue_scheduled || 0)
1368
+ };
1369
+ }
1370
+ /**
1371
+ * Schedule content for future publishing
1372
+ *
1373
+ * Sets status to 'scheduled' and stores the scheduled publish time.
1374
+ * The content will be auto-published when the scheduled time is reached.
1375
+ */
1376
+ async schedule(type, id, scheduledAt, currentTime = /* @__PURE__ */ new Date(), expectedRevision) {
1377
+ const tableName = getTableName(type);
1378
+ const now = currentTime.toISOString();
1379
+ const normalizedScheduledAt = await this.datetimes.normalizeValue(type, scheduledAt);
1380
+ if (new Date(normalizedScheduledAt) <= currentTime) throw new EmDashValidationError("Scheduled date must be in the future");
1381
+ const existing = await this.findById(type, id);
1382
+ if (!existing) throw new EmDashValidationError("Content item not found");
1383
+ assertRevisionPrecondition(existing, expectedRevision);
1384
+ const newStatus = existing.status === "published" ? "published" : "scheduled";
1385
+ if (((await sql`
1386
+ UPDATE ${sql.ref(tableName)}
1387
+ SET status = ${newStatus},
1388
+ scheduled_at = ${normalizedScheduledAt},
1389
+ updated_at = ${now}
1390
+ WHERE id = ${id}
1391
+ AND deleted_at IS NULL
1392
+ AND version = ${existing.version}
1393
+ AND updated_at = ${existing.updatedAt}
1394
+ AND status = ${existing.status}
1395
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1396
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError("Content changed while scheduling");
1397
+ invalidateCollectionCache(type);
1398
+ const updated = await this.findById(type, id);
1399
+ if (!updated) throw new Error("Content not found");
1400
+ return updated;
1401
+ }
1402
+ /**
1403
+ * Unschedule content
1404
+ *
1405
+ * Clears the scheduled time. Published posts stay published;
1406
+ * draft/scheduled posts revert to 'draft'.
1407
+ */
1408
+ async unschedule(type, id, expectedRevision) {
1409
+ const tableName = getTableName(type);
1410
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1411
+ const existing = await this.findById(type, id);
1412
+ if (!existing) throw new EmDashValidationError("Content item not found");
1413
+ assertRevisionPrecondition(existing, expectedRevision);
1414
+ const newStatus = existing.status === "published" ? "published" : "draft";
1415
+ const result = await sql`
1416
+ UPDATE ${sql.ref(tableName)}
1417
+ SET status = ${newStatus},
1418
+ scheduled_at = NULL,
1419
+ updated_at = ${now}
1420
+ WHERE id = ${id}
1421
+ AND scheduled_at IS NOT NULL
1422
+ AND deleted_at IS NULL
1423
+ AND version = ${existing.version}
1424
+ AND updated_at = ${existing.updatedAt}
1425
+ AND status = ${existing.status}
1426
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1427
+ `.execute(this.db);
1428
+ if (existing.scheduledAt !== null && (result.numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError("Content changed while unscheduling");
1429
+ invalidateCollectionCache(type);
1430
+ const updated = await this.findById(type, id);
1431
+ if (!updated) throw new Error("Content not found");
1432
+ return updated;
1433
+ }
1434
+ /**
1435
+ * Find content that is ready to be published
1436
+ *
1437
+ * Returns all content where scheduled_at <= now, regardless of status.
1438
+ * This covers both draft-scheduled posts (status='scheduled') and
1439
+ * published posts with scheduled draft changes (status='published').
1440
+ *
1441
+ * `limit` (optional) caps how many due rows are returned, oldest-due first.
1442
+ * The scheduled-publishing sweep passes a limit so a large backlog can't
1443
+ * fan out unbounded publish/webhook work in a single tick (and blow a Worker
1444
+ * invocation's CPU/subrequest budget); the remainder drains on later ticks.
1445
+ */
1446
+ async findReadyToPublish(type, limit, currentTime = /* @__PURE__ */ new Date(), after) {
1447
+ const tableName = getTableName(type);
1448
+ const now = currentTime.toISOString();
1449
+ const limitClause = typeof limit === "number" && Number.isInteger(limit) && limit > 0 ? sql`LIMIT ${limit}` : sql``;
1450
+ const afterClause = after ? sql`AND (scheduled_at > ${after.scheduledAt} OR (scheduled_at = ${after.scheduledAt} AND id > ${after.id}))` : sql``;
1451
+ return (await sql`
1452
+ SELECT * FROM ${sql.ref(tableName)}
1453
+ WHERE scheduled_at IS NOT NULL
1454
+ AND scheduled_at <= ${now}
1455
+ AND deleted_at IS NULL
1456
+ ${afterClause}
1457
+ ORDER BY scheduled_at ASC, id ASC
1458
+ ${limitClause}
1459
+ `.execute(this.db)).rows.map((row) => this.mapRow(type, row));
1460
+ }
1461
+ async findTranslationIds(type, translationGroup) {
1462
+ const tableName = getTableName(type);
1463
+ return (await sql`
1464
+ SELECT id FROM ${sql.ref(tableName)}
1465
+ WHERE translation_group = ${translationGroup}
1466
+ AND deleted_at IS NULL
1467
+ `.execute(this.db)).rows.map((row) => row.id);
1468
+ }
1469
+ async findTranslationIdsForGroups(type, translationGroups) {
1470
+ const ids = /* @__PURE__ */ new Map();
1471
+ if (translationGroups.length === 0) return ids;
1472
+ const tableName = getTableName(type);
1473
+ for (const batch of chunks([...new Set(translationGroups)], SQL_BATCH_SIZE)) {
1474
+ const result = await sql`
1475
+ SELECT id, translation_group FROM ${sql.ref(tableName)}
1476
+ WHERE translation_group IN (${sql.join(batch)}) AND deleted_at IS NULL
1477
+ `.execute(this.db);
1478
+ for (const row of result.rows) {
1479
+ const group = ids.get(row.translation_group) ?? [];
1480
+ group.push(row.id);
1481
+ ids.set(row.translation_group, group);
1482
+ }
1483
+ }
1484
+ return ids;
1485
+ }
1486
+ /**
1487
+ * Find all translations in a translation group
1488
+ */
1489
+ async findTranslations(type, translationGroup) {
1490
+ const tableName = getTableName(type);
1491
+ return (await sql`
1492
+ SELECT * FROM ${sql.ref(tableName)}
1493
+ WHERE translation_group = ${translationGroup}
1494
+ AND deleted_at IS NULL
1495
+ ORDER BY locale ASC
1496
+ `.execute(this.db)).rows.map((row) => this.mapRow(type, row));
1497
+ }
1498
+ /**
1499
+ * Whether any row still shares `translationGroup`, trashed rows included.
1500
+ * Group-keyed satellite data (term assignments, reference edges) is owned by
1501
+ * the group, not by a single locale row, so a purge may only cascade to it
1502
+ * once nothing is left to own it — and a trashed sibling is still restorable.
1503
+ */
1504
+ async hasTranslationsIncludingTrashed(type, translationGroup, options = {}) {
1505
+ const tableName = getTableName(type);
1506
+ const exclusion = options.excludeId ? sql`AND id != ${options.excludeId}` : sql``;
1507
+ return (await sql`
1508
+ SELECT id FROM ${sql.ref(tableName)}
1509
+ WHERE translation_group = ${translationGroup}
1510
+ ${exclusion}
1511
+ LIMIT 1
1512
+ `.execute(this.db)).rows.length > 0;
1513
+ }
1514
+ /**
1515
+ * Batch variant of {@link findTranslations}: every (non-deleted) locale
1516
+ * variant for any of `translationGroups`, in one `WHERE translation_group IN
1517
+ * (...)` query chunked at `SQL_BATCH_SIZE` for D1's bind-parameter limit.
1518
+ * Lets callers resolve many edge groups without an N+1 per group. The caller
1519
+ * groups the flat result by `translationGroup` itself.
1520
+ *
1521
+ * `translation_group` leads the sort so the ordering follows
1522
+ * `idx_{table}_del_tg_locale` past its `deleted_at` equality; callers group by
1523
+ * `translationGroup`, so the per-group locale order they rely on is preserved.
1524
+ *
1525
+ * `publishedOnly` restricts the result to `status = 'published'` — reference
1526
+ * reads pass this for callers without `content:read_drafts` so draft/scheduled
1527
+ * entries never leak through an edge traversal.
1528
+ *
1529
+ * A reference edge stores only a collection slug (no SQL FK), so the table may
1530
+ * have been dropped since the edge was written. That is a tolerated dangling
1531
+ * state, not an error: a missing table resolves to no rows, mirroring how the
1532
+ * content read handlers treat `isMissingTableError`.
1533
+ */
1534
+ async findTranslationsForGroups(type, translationGroups, options = {}) {
1535
+ if (translationGroups.length === 0) return [];
1536
+ const tableName = getTableName(type);
1537
+ const publishedFilter = options.publishedOnly ? sql`AND status = 'published'` : sql``;
1538
+ const items = [];
1539
+ try {
1540
+ for (const chunk of chunks(translationGroups, SQL_BATCH_SIZE)) {
1541
+ const result = await sql`
1542
+ SELECT * FROM ${sql.ref(tableName)}
1543
+ WHERE translation_group IN (${sql.join(chunk)})
1544
+ AND deleted_at IS NULL
1545
+ ${publishedFilter}
1546
+ ORDER BY translation_group ASC, locale ASC
1547
+ `.execute(this.db);
1548
+ for (const row of result.rows) items.push(this.mapRow(type, row));
1549
+ }
1550
+ } catch (error) {
1551
+ if (isMissingTableError(error)) return [];
1552
+ throw error;
1553
+ }
1554
+ return items;
1555
+ }
1556
+ /**
1557
+ * Batch variant of {@link findByIdOrSlug}: resolve many identifiers (each an
1558
+ * id OR a slug) within `type` in a constant number of queries — one `WHERE id
1559
+ * IN (...)` and one `WHERE slug IN (...)`, each chunked at `SQL_BATCH_SIZE`.
1560
+ * Returns a map from the input identifier to its resolved item; identifiers
1561
+ * that match nothing are absent. Used on write paths that accept a list of
1562
+ * references, so a single request doesn't fan out to an N+1 of point lookups.
1563
+ *
1564
+ * Resolution mirrors {@link findByIdOrSlug}: a ULID-shaped identifier prefers
1565
+ * the id match and falls back to slug; anything else prefers the slug match
1566
+ * and falls back to id. Slug matches collapse to the lowest-locale variant
1567
+ * (`ORDER BY locale ASC`), matching the slug-without-locale lookup.
1568
+ */
1569
+ async findManyByIdOrSlug(type, identifiers) {
1570
+ const resolved = /* @__PURE__ */ new Map();
1571
+ const unique = [...new Set(identifiers)];
1572
+ if (unique.length === 0) return resolved;
1573
+ const tableName = getTableName(type);
1574
+ const byId = /* @__PURE__ */ new Map();
1575
+ const bySlug = /* @__PURE__ */ new Map();
1576
+ try {
1577
+ for (const chunk of chunks(unique, SQL_BATCH_SIZE)) {
1578
+ const idRows = await sql`
1579
+ SELECT * FROM ${sql.ref(tableName)}
1580
+ WHERE id IN (${sql.join(chunk)})
1581
+ AND deleted_at IS NULL
1582
+ `.execute(this.db);
1583
+ for (const row of idRows.rows) {
1584
+ const item = this.mapRow(type, row);
1585
+ byId.set(item.id, item);
1586
+ }
1587
+ const slugRows = await sql`
1588
+ SELECT * FROM ${sql.ref(tableName)}
1589
+ WHERE slug IN (${sql.join(chunk)})
1590
+ AND deleted_at IS NULL
1591
+ ORDER BY locale ASC
1592
+ `.execute(this.db);
1593
+ for (const row of slugRows.rows) {
1594
+ const item = this.mapRow(type, row);
1595
+ if (item.slug != null && !bySlug.has(item.slug)) bySlug.set(item.slug, item);
1596
+ }
1597
+ }
1598
+ } catch (error) {
1599
+ if (isMissingTableError(error)) return resolved;
1600
+ throw error;
1601
+ }
1602
+ for (const identifier of unique) {
1603
+ const item = ULID_PATTERN.test(identifier) ? byId.get(identifier) ?? bySlug.get(identifier) : bySlug.get(identifier) ?? byId.get(identifier);
1604
+ if (item) resolved.set(identifier, item);
1605
+ }
1606
+ return resolved;
1607
+ }
1608
+ /**
1609
+ * Publish the current draft
1610
+ *
1611
+ * Promotes draft_revision_id to live_revision_id and clears draft pointer.
1612
+ * Syncs the draft revision's data into the content table columns so the
1613
+ * content table always reflects the published version.
1614
+ * If no draft revision exists, creates one from current data and publishes it.
1615
+ * When `promoteRevision` is false, publishes the current content-table data
1616
+ * by changing lifecycle metadata only.
1617
+ *
1618
+ * `publishedAt` (optional) overrides the publication timestamp. If omitted,
1619
+ * the existing `published_at` is preserved (idempotent re-publish keeps the
1620
+ * original date) and falls back to the current time on first publish. Pass
1621
+ * an explicit value to backdate a publish (e.g. when migrating content from
1622
+ * another CMS).
1623
+ *
1624
+ * `requireDue` gates the final update on the row still being due.
1625
+ * `expectedScheduledAt` additionally fences changes made after a sweep
1626
+ * selected the row but before publication preparation began.
1627
+ */
1628
+ async publish(type, id, publishedAt, requireDue = false, expectedScheduledAt, promoteRevision = true, requireSlug = true, expectedRevision, currentTime = /* @__PURE__ */ new Date()) {
1629
+ const tableName = getTableName(type);
1630
+ const now = currentTime.toISOString();
1631
+ const existing = await this.findById(type, id);
1632
+ if (!existing) throw new EmDashValidationError("Content item not found");
1633
+ assertRevisionPrecondition(existing, expectedRevision);
1634
+ const requestedPublishedAt = publishedAt ? await this.datetimes.normalizeValue(type, publishedAt) : void 0;
1635
+ const currentPublishedAt = existing.publishedAt ? await this.datetimes.normalizeValue(type, existing.publishedAt) : null;
1636
+ if (requireDue && expectedScheduledAt !== void 0 && existing.scheduledAt !== expectedScheduledAt) throw new ScheduledNotDueError();
1637
+ if (!promoteRevision && requireSlug && !existing.slug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
1638
+ if (!promoteRevision) {
1639
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1640
+ let provisionalRevisionId = null;
1641
+ try {
1642
+ let liveRevisionId = existing.liveRevisionId;
1643
+ if (!liveRevisionId) {
1644
+ const revision = await revisionRepo.create({
1645
+ collection: type,
1646
+ entryId: id,
1647
+ data: existing.data
1648
+ });
1649
+ liveRevisionId = revision.id;
1650
+ provisionalRevisionId = revision.id;
1651
+ }
1652
+ const intendedPublishedAt = requestedPublishedAt ?? currentPublishedAt ?? now;
1653
+ const duePredicate = requireDue ? sql`AND scheduled_at IS NOT NULL AND scheduled_at <= ${now}` : sql``;
1654
+ let published = false;
1655
+ try {
1656
+ published = ((await sql`
1657
+ UPDATE ${sql.ref(tableName)}
1658
+ SET live_revision_id = ${liveRevisionId},
1659
+ draft_revision_id = NULL,
1660
+ status = 'published',
1661
+ scheduled_at = NULL,
1662
+ published_at = ${intendedPublishedAt},
1663
+ updated_at = ${now},
1664
+ version = version + 1
1665
+ WHERE id = ${id}
1666
+ AND deleted_at IS NULL
1667
+ AND version = ${existing.version}
1668
+ AND updated_at = ${existing.updatedAt}
1669
+ AND status = ${existing.status}
1670
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1671
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1672
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1673
+ ${duePredicate}
1674
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1675
+ } catch (error) {
1676
+ if (isConfirmedStatementFailure(error)) throw error;
1677
+ let observed;
1678
+ try {
1679
+ observed = await this.findById(type, id);
1680
+ } catch (reconciliationError) {
1681
+ throw new Error("Unable to confirm whether content publication completed", { cause: reconciliationError });
1682
+ }
1683
+ if (!observed) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1684
+ published = matchesLifecyclePublication(observed, existing, liveRevisionId, intendedPublishedAt, now);
1685
+ if (!published && matchesPublicationFence(observed, existing)) throw error;
1686
+ if (!published) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1687
+ }
1688
+ if (!published) throw requireDue ? new ScheduledNotDueError() : new ContentMutationConflictError();
1689
+ invalidateCollectionCache(type);
1690
+ const updated = await this.findById(type, id);
1691
+ if (!updated) throw new Error("Content not found");
1692
+ return updated;
1693
+ } catch (error) {
1694
+ if (provisionalRevisionId) try {
1695
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1696
+ } catch (cleanupError) {
1697
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1698
+ }
1699
+ throw error;
1700
+ }
1701
+ }
1702
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1703
+ let provisionalRevisionId = null;
1704
+ try {
1705
+ let revisionToPublish = existing.draftRevisionId || existing.liveRevisionId;
1706
+ if (!revisionToPublish) {
1707
+ const revision = await revisionRepo.create({
1708
+ collection: type,
1709
+ entryId: id,
1710
+ data: existing.data
1711
+ });
1712
+ revisionToPublish = revision.id;
1713
+ provisionalRevisionId = revision.id;
1714
+ }
1715
+ const revision = await revisionRepo.findById(revisionToPublish);
1716
+ if (!revision || revision.collection !== type || revision.entryId !== id) throw new EmDashValidationError("Revision does not belong to the specified content item");
1717
+ const writableFieldSlugs = await this.datetimes.writableFieldSlugs(type);
1718
+ const revisionData = keepKnownFields(revision.data, writableFieldSlugs);
1719
+ const stagedSlug = typeof revision.data._slug === "string" ? revision.data._slug : null;
1720
+ const intendedSlug = stagedSlug ?? existing.slug;
1721
+ if (requireSlug && !intendedSlug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
1722
+ const intendedPublishedAt = requestedPublishedAt ?? currentPublishedAt ?? now;
1723
+ if (stagedSlug !== null && stagedSlug !== existing.slug && existing.locale !== null) {
1724
+ const conflict = await this.findBySlugIncludingTrashed(type, stagedSlug, existing.locale);
1725
+ 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" });
1726
+ }
1727
+ const assignments = [];
1728
+ if (stagedSlug !== null) assignments.push(sql`slug = ${stagedSlug}`);
1729
+ for (const [key, value] of Object.entries(revisionData)) {
1730
+ if (SYSTEM_COLUMNS.has(key) || key.startsWith("_")) continue;
1731
+ validateIdentifier(key, "content field name");
1732
+ assignments.push(sql`${sql.ref(key)} = ${serializeValue(value)}`);
1733
+ }
1734
+ 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`);
1735
+ const duePredicate = requireDue ? sql`AND scheduled_at IS NOT NULL AND scheduled_at <= ${now}` : sql``;
1736
+ let promoted = false;
1737
+ try {
1738
+ promoted = ((await sql`
1739
+ UPDATE ${sql.ref(tableName)}
1740
+ SET ${sql.join(assignments, sql`, `)}
1741
+ WHERE id = ${id}
1742
+ AND deleted_at IS NULL
1743
+ AND version = ${existing.version}
1744
+ AND updated_at = ${existing.updatedAt}
1745
+ AND status = ${existing.status}
1746
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1747
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1748
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1749
+ ${duePredicate}
1750
+ AND EXISTS (
1751
+ SELECT 1 FROM revisions
1752
+ WHERE revisions.id = ${revisionToPublish}
1753
+ AND revisions.collection = ${type}
1754
+ AND revisions.entry_id = ${id}
1755
+ )
1756
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1757
+ } catch (error) {
1758
+ if (isConfirmedStatementFailure(error)) throw error;
1759
+ let observed;
1760
+ try {
1761
+ observed = await this.findById(type, id);
1762
+ } catch (reconciliationError) {
1763
+ throw new Error("Unable to confirm whether content publication completed", { cause: reconciliationError });
1764
+ }
1765
+ if (!observed) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1766
+ promoted = matchesPublication(observed, existing, revisionData, revisionToPublish, intendedSlug, intendedPublishedAt, now);
1767
+ if (!promoted && matchesPublicationFence(observed, existing)) throw error;
1768
+ if (!promoted) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1769
+ }
1770
+ if (!promoted) throw requireDue ? new ScheduledNotDueError() : new ContentMutationConflictError();
1771
+ invalidateCollectionCache(type);
1772
+ const updated = await this.findById(type, id);
1773
+ if (!updated) throw new Error("Content not found");
1774
+ return updated;
1775
+ } catch (error) {
1776
+ if (provisionalRevisionId) try {
1777
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1778
+ } catch (cleanupError) {
1779
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1780
+ }
1781
+ throw error;
1782
+ }
1783
+ }
1784
+ /**
1785
+ * Unpublish content
1786
+ *
1787
+ * Removes live pointer and cancels any pending schedule, but preserves the
1788
+ * draft and publication date. If no draft exists and `draftFromLive` is set,
1789
+ * creates one from the live version so the content isn't lost. Collections
1790
+ * without revisions save to the columns, and a draft revision would hide
1791
+ * those saves.
1792
+ */
1793
+ async unpublish(type, id, expectedRevision, draftFromLive = true) {
1794
+ const tableName = getTableName(type);
1795
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1796
+ const existing = await this.findById(type, id);
1797
+ if (!existing) throw new EmDashValidationError("Content item not found");
1798
+ assertRevisionPrecondition(existing, expectedRevision);
1799
+ if (existing.status === "draft" && !existing.liveRevisionId && !existing.scheduledAt) return existing;
1800
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1801
+ let provisionalRevisionId = null;
1802
+ try {
1803
+ let draftRevisionId = existing.draftRevisionId;
1804
+ if (draftFromLive && !draftRevisionId && existing.liveRevisionId) {
1805
+ const liveRevision = await revisionRepo.findById(existing.liveRevisionId);
1806
+ if (liveRevision) {
1807
+ const draft = await revisionRepo.create({
1808
+ collection: type,
1809
+ entryId: id,
1810
+ data: liveRevision.data
1811
+ });
1812
+ draftRevisionId = draft.id;
1813
+ provisionalRevisionId = draft.id;
1814
+ }
1815
+ }
1816
+ if (((await sql`
1817
+ UPDATE ${sql.ref(tableName)}
1818
+ SET live_revision_id = NULL,
1819
+ draft_revision_id = ${draftRevisionId},
1820
+ status = 'draft',
1821
+ scheduled_at = NULL,
1822
+ updated_at = ${now},
1823
+ version = version + 1
1824
+ WHERE id = ${id}
1825
+ AND deleted_at IS NULL
1826
+ AND version = ${existing.version}
1827
+ AND updated_at = ${existing.updatedAt}
1828
+ AND status = ${existing.status}
1829
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1830
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1831
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1832
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError();
1833
+ invalidateCollectionCache(type);
1834
+ const updated = await this.findById(type, id);
1835
+ if (!updated) throw new Error("Content not found");
1836
+ return updated;
1837
+ } catch (error) {
1838
+ if (provisionalRevisionId) try {
1839
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1840
+ } catch (cleanupError) {
1841
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1842
+ }
1843
+ throw error;
1844
+ }
1845
+ }
1846
+ /**
1847
+ * Set the draft revision pointer for a content item.
1848
+ *
1849
+ * Used by seed/import paths that stage a new revision's data before
1850
+ * promoting it to live via `publish()`.
1851
+ *
1852
+ * Validates that the content item exists and is not soft-deleted, that
1853
+ * the revision exists, and that the revision belongs to the same
1854
+ * collection and entry. Without these checks, a caller could leave the
1855
+ * content row pointing at a missing or unrelated revision.
1856
+ */
1857
+ async setDraftRevision(type, id, revisionId) {
1858
+ const existing = await this.findById(type, id);
1859
+ if (!existing) throw new EmDashValidationError("Content item not found");
1860
+ const revision = await new RevisionRepository(this.db, this.datetimeContexts).findById(revisionId);
1861
+ if (!revision) throw new EmDashValidationError("Revision not found");
1862
+ if (revision.collection !== type || revision.entryId !== id) throw new EmDashValidationError("Revision does not belong to the specified content item");
1863
+ if (!await this.replaceDraftRevision(type, id, revisionId, existing)) throw new ContentMutationConflictError();
1864
+ }
1865
+ async replaceDraftRevision(type, id, revisionId, expected) {
1866
+ const tableName = getTableName(type);
1867
+ return ((await sql`
1868
+ UPDATE ${sql.ref(tableName)}
1869
+ SET draft_revision_id = ${revisionId},
1870
+ version = version + 1
1871
+ WHERE id = ${id}
1872
+ AND deleted_at IS NULL
1873
+ AND version = ${expected.version}
1874
+ AND ${nullableColumnMatch("live_revision_id", expected.liveRevisionId)}
1875
+ AND ${nullableColumnMatch("draft_revision_id", expected.draftRevisionId)}
1876
+ AND EXISTS (
1877
+ SELECT 1 FROM revisions
1878
+ WHERE revisions.id = ${revisionId}
1879
+ AND revisions.collection = ${type}
1880
+ AND revisions.entry_id = ${id}
1881
+ )
1882
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1883
+ }
1884
+ /**
1885
+ * Discard pending draft changes
1886
+ *
1887
+ * Clears draft_revision_id. The content table columns already hold the
1888
+ * published version, so no data sync is needed.
1889
+ */
1890
+ async discardDraft(type, id, expectedRevision) {
1891
+ const tableName = getTableName(type);
1892
+ const existing = await this.findById(type, id);
1893
+ if (!existing) throw new EmDashValidationError("Content item not found");
1894
+ assertRevisionPrecondition(existing, expectedRevision);
1895
+ if (!existing.draftRevisionId) return existing;
1896
+ if (((await sql`
1897
+ UPDATE ${sql.ref(tableName)}
1898
+ SET draft_revision_id = NULL,
1899
+ version = version + 1
1900
+ WHERE id = ${id}
1901
+ AND deleted_at IS NULL
1902
+ AND version = ${existing.version}
1903
+ AND updated_at = ${existing.updatedAt}
1904
+ AND status = ${existing.status}
1905
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1906
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1907
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1908
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError();
1909
+ const updated = await this.findById(type, id);
1910
+ if (!updated) throw new Error("Content not found");
1911
+ return updated;
1912
+ }
1913
+ /**
1914
+ * Count content items with a pending schedule.
1915
+ * Includes both draft-scheduled (status='scheduled') and published
1916
+ * posts with scheduled draft changes (status='published', scheduled_at set).
1917
+ */
1918
+ async countScheduled(type) {
1919
+ const tableName = getTableName(type);
1920
+ const result = await sql`
1921
+ SELECT COUNT(id) as count FROM ${sql.ref(tableName)}
1922
+ WHERE scheduled_at IS NOT NULL
1923
+ AND deleted_at IS NULL
1924
+ `.execute(this.db);
1925
+ return Number(result.rows[0]?.count || 0);
1926
+ }
1927
+ /**
1928
+ * Map database row to ContentItem
1929
+ * Extracts system columns and puts content fields in data
1930
+ * Excludes null values from data to match input semantics
1931
+ */
1932
+ mapRow(type, row) {
1933
+ const data = {};
1934
+ for (const [key, value] of Object.entries(row)) if (!SYSTEM_COLUMNS.has(key) && value !== null) data[key] = deserializeValue(value);
1935
+ return {
1936
+ id: row.id,
1937
+ type,
1938
+ slug: row.slug,
1939
+ status: row.status,
1940
+ data,
1941
+ authorId: row.author_id,
1942
+ primaryBylineId: row.primary_byline_id ?? null,
1943
+ createdAt: row.created_at,
1944
+ updatedAt: row.updated_at,
1945
+ publishedAt: row.published_at,
1946
+ scheduledAt: row.scheduled_at,
1947
+ liveRevisionId: row.live_revision_id ?? null,
1948
+ draftRevisionId: row.draft_revision_id ?? null,
1949
+ version: typeof row.version === "number" ? row.version : 1,
1950
+ locale: row.locale ?? null,
1951
+ translationGroup: row.translation_group ?? null
1952
+ };
1953
+ }
1954
+ normalizeFilterScalar(field, type, value) {
1955
+ if (type === "number" || type === "integer") {
1956
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new EmDashValidationError(`Filter for field "${field}" must use a finite number`);
1957
+ if (type === "integer" && !Number.isInteger(value)) throw new EmDashValidationError(`Filter for field "${field}" must use an integer`);
1958
+ return value;
1959
+ }
1960
+ if (type === "boolean") {
1961
+ if (typeof value !== "boolean") throw new EmDashValidationError(`Filter for field "${field}" must use a boolean`);
1962
+ return value ? 1 : 0;
1963
+ }
1964
+ if (typeof value !== "string") throw new EmDashValidationError(`Filter for field "${field}" must use a string`);
1965
+ if (value.length > MAX_FILTER_STRING_LENGTH) throw new EmDashValidationError(`Filter value for field "${field}" exceeds ${MAX_FILTER_STRING_LENGTH} characters`);
1966
+ if (type === "datetime") try {
1967
+ return normalizeExplicitDatetime(value);
1968
+ } catch {
1969
+ throw new EmDashValidationError(`Filter for datetime field "${field}" must use an ISO 8601 datetime with Z or an explicit offset`);
1970
+ }
1971
+ return value;
1972
+ }
1973
+ normalizeFieldFilter(field, type, value) {
1974
+ if (value === null) return {
1975
+ column: field,
1976
+ kind: "null"
1977
+ };
1978
+ if (typeof value !== "object") return {
1979
+ column: field,
1980
+ kind: "exact",
1981
+ value: this.normalizeFilterScalar(field, type, value)
1982
+ };
1983
+ if (Array.isArray(value)) throw new EmDashValidationError(`Invalid filter for field "${field}"`);
1984
+ const record = value;
1985
+ const keys = Object.keys(record);
1986
+ if (keys.length === 1 && keys[0] === "in") {
1987
+ if (!Array.isArray(record.in) || record.in.length === 0) throw new EmDashValidationError(`IN filter for field "${field}" must not be empty`);
1988
+ if (record.in.length > MAX_IN_FILTER_VALUES) throw new EmDashValidationError(`IN filter for field "${field}" exceeds ${MAX_IN_FILTER_VALUES} values`);
1989
+ return {
1990
+ column: field,
1991
+ kind: "in",
1992
+ values: record.in.map((entry) => this.normalizeFilterScalar(field, type, entry))
1993
+ };
1994
+ }
1995
+ const rangeKeys = new Set([
1996
+ "gt",
1997
+ "gte",
1998
+ "lt",
1999
+ "lte"
2000
+ ]);
2001
+ if (keys.length === 0 || keys.some((key) => !rangeKeys.has(key))) throw new EmDashValidationError(`Invalid filter operator for field "${field}"`);
2002
+ if (type === "boolean") throw new EmDashValidationError(`Boolean field "${field}" does not support range filters`);
2003
+ const bounds = {};
2004
+ for (const key of keys) {
2005
+ if (record[key] === void 0) continue;
2006
+ bounds[key] = this.normalizeFilterScalar(field, type, record[key]);
2007
+ }
2008
+ if (Object.keys(bounds).length === 0) throw new EmDashValidationError(`Range filter for field "${field}" has no bounds`);
2009
+ return {
2010
+ column: field,
2011
+ kind: "range",
2012
+ bounds
2013
+ };
2014
+ }
2015
+ async collectionExists(type) {
2016
+ return await this.db.selectFrom("_emdash_collections").where("slug", "=", type).select("id").executeTakeFirst() !== void 0;
2017
+ }
2018
+ async resolveFieldFilters(type, filters) {
2019
+ const resolvedFilters = filters ?? {};
2020
+ const fields = Object.keys(resolvedFilters);
2021
+ if (fields.length === 0) return [];
2022
+ if (fields.length > MAX_INDEXED_FIELD_FILTERS) {
2023
+ if (!await this.collectionExists(type)) return [];
2024
+ throw new EmDashValidationError(`Content list queries support at most ${MAX_INDEXED_FIELD_FILTERS} indexed field filters`);
2025
+ }
2026
+ 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([
2027
+ "field.slug",
2028
+ "field.type",
2029
+ "field.validation"
2030
+ ]).execute();
2031
+ const metadata = new Map(rows.filter((row) => !isStoragelessFieldRow(row)).map((row) => [row.slug, row.type]));
2032
+ if (metadata.size === 0 && !await this.collectionExists(type)) return [];
2033
+ for (const field of fields) try {
2034
+ validateIdentifier(field, "content filter field");
2035
+ } catch {
2036
+ throw new EmDashValidationError(`Invalid content filter field: ${field}`);
2037
+ }
2038
+ const normalized = fields.map((field) => {
2039
+ const fieldType = metadata.get(field);
2040
+ if (!fieldType || !isIndexableFieldType(fieldType)) throw new EmDashValidationError(`Cannot filter by field "${field}". Custom fields must be indexed before filtering.`);
2041
+ return this.normalizeFieldFilter(field, fieldType, resolvedFilters[field]);
2042
+ });
2043
+ if (normalized.reduce((total, filter) => {
2044
+ if (filter.kind === "null") return total;
2045
+ if (filter.kind === "exact") return total + 1;
2046
+ if (filter.kind === "in") return total + filter.values.length;
2047
+ return total + Object.keys(filter.bounds).length;
2048
+ }, 0) > SQL_BATCH_SIZE) throw new EmDashValidationError(`Indexed field filters have a total operand budget of ${SQL_BATCH_SIZE}`);
2049
+ return normalized;
2050
+ }
2051
+ applyFieldFilters(query, filters) {
2052
+ let next = query;
2053
+ for (const filter of filters) {
2054
+ const column = sql.ref(filter.column);
2055
+ const isPresent = sql`${column} IS NOT NULL`;
2056
+ if (filter.kind === "null") {
2057
+ next = next.where(() => sql`(${isPresent}) = FALSE AND ${column} IS NULL`);
2058
+ continue;
2059
+ }
2060
+ if (filter.kind === "exact") {
2061
+ next = next.where(() => sql`(${isPresent}) = TRUE AND ${column} = ${filter.value}`);
2062
+ continue;
2063
+ }
2064
+ if (filter.kind === "in") {
2065
+ const values = sql.join(filter.values.map((value) => sql`${value}`), sql`, `);
2066
+ next = next.where(() => sql`(${isPresent}) = TRUE AND ${column} IN (${values})`);
2067
+ continue;
2068
+ }
2069
+ next = next.where(() => sql`(${isPresent}) = TRUE`);
2070
+ if (filter.bounds.gt !== void 0) next = next.where(() => sql`${column} > ${filter.bounds.gt}`);
2071
+ if (filter.bounds.gte !== void 0) next = next.where(() => sql`${column} >= ${filter.bounds.gte}`);
2072
+ if (filter.bounds.lt !== void 0) next = next.where(() => sql`${column} < ${filter.bounds.lt}`);
2073
+ if (filter.bounds.lte !== void 0) next = next.where(() => sql`${column} <= ${filter.bounds.lte}`);
2074
+ }
2075
+ return next;
2076
+ }
2077
+ /**
2078
+ * Map order field names to database columns.
2079
+ * Only allows known fields to prevent column enumeration via crafted orderBy values.
2080
+ */
2081
+ mapOrderField(field, sortableExtras = []) {
2082
+ const mapped = ORDER_FIELD_COLUMNS[field];
2083
+ if (mapped) return mapped;
2084
+ if (sortableExtras.includes(field)) {
2085
+ validateIdentifier(field, "order field");
2086
+ return field;
2087
+ }
2088
+ throw new EmDashValidationError(`Invalid order field: ${field}`);
2089
+ }
2090
+ async resolveOrderField(type, field, sortableExtras = []) {
2091
+ try {
2092
+ return {
2093
+ column: this.mapOrderField(field, sortableExtras),
2094
+ indexedCustomField: false
2095
+ };
2096
+ } catch (error) {
2097
+ if (!(error instanceof EmDashValidationError)) throw error;
2098
+ }
2099
+ 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();
2100
+ if (!customField) throw new ContentCollectionNotFoundError(type);
2101
+ if (!customField.fieldSlug) throw new EmDashValidationError(`Invalid order field: ${field}. Custom fields must be indexed before sorting.`);
2102
+ validateIdentifier(customField.fieldSlug, "content order field");
2103
+ return {
2104
+ column: customField.fieldSlug,
2105
+ indexedCustomField: true
2106
+ };
2107
+ }
2108
+ };
2109
+
2110
+ //#endregion
2111
+ export { staleStoredKeys as a, keepKnownFields as i, content_exports as n, isSystemOrderField as r, ContentRepository as t };
2112
+ //# sourceMappingURL=content-BKHUVsE5.mjs.map