emdash 1.1.0 → 1.2.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 (1283) hide show
  1. package/dist/action-token-BdWad2YG.mjs +26 -0
  2. package/dist/action-token-BdWad2YG.mjs.map +1 -0
  3. package/dist/adapters-B4-nbElt.d.mts +173 -0
  4. package/dist/adapters-B4-nbElt.d.mts.map +1 -0
  5. package/dist/allowed-origins-CLpHGGlc.mjs +116 -0
  6. package/dist/allowed-origins-CLpHGGlc.mjs.map +1 -0
  7. package/dist/api/route-utils.d.mts +4 -4
  8. package/dist/api/route-utils.d.mts.map +1 -1
  9. package/dist/api/route-utils.mjs +39 -39
  10. package/dist/api/schemas/index.d.mts +2 -2
  11. package/dist/api/schemas/index.mjs +10 -10
  12. package/dist/api-DBw_IWoi.mjs +5024 -0
  13. package/dist/api-DBw_IWoi.mjs.map +1 -0
  14. package/dist/api-tokens-B0ZipcZ-.mjs +173 -0
  15. package/dist/api-tokens-B0ZipcZ-.mjs.map +1 -0
  16. package/dist/apply-Cx48saFC.mjs +1680 -0
  17. package/dist/apply-Cx48saFC.mjs.map +1 -0
  18. package/dist/approvals-BXgtXA2s.mjs +460 -0
  19. package/dist/approvals-BXgtXA2s.mjs.map +1 -0
  20. package/dist/artifact-fetch-DsRczRGG.mjs +659 -0
  21. package/dist/artifact-fetch-DsRczRGG.mjs.map +1 -0
  22. package/dist/artifacts-D-O-qj9C.mjs +307 -0
  23. package/dist/artifacts-D-O-qj9C.mjs.map +1 -0
  24. package/dist/astro/image-endpoint.d.mts.map +1 -1
  25. package/dist/astro/image-endpoint.mjs +26 -6
  26. package/dist/astro/image-endpoint.mjs.map +1 -1
  27. package/dist/astro/index.d.mts +14 -14
  28. package/dist/astro/index.d.mts.map +1 -1
  29. package/dist/astro/index.mjs +225 -15
  30. package/dist/astro/index.mjs.map +1 -1
  31. package/dist/astro/middleware/auth.d.mts +12 -12
  32. package/dist/astro/middleware/auth.d.mts.map +1 -1
  33. package/dist/astro/middleware/auth.mjs +15 -11
  34. package/dist/astro/middleware/auth.mjs.map +1 -1
  35. package/dist/astro/middleware/media-usage-write-fence.mjs +4 -4
  36. package/dist/astro/middleware/redirect.d.mts.map +1 -1
  37. package/dist/astro/middleware/redirect.mjs +30 -15
  38. package/dist/astro/middleware/redirect.mjs.map +1 -1
  39. package/dist/astro/middleware/request-context.d.mts.map +1 -1
  40. package/dist/astro/middleware/request-context.mjs +71 -44
  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 -12
  44. package/dist/astro/middleware.d.mts.map +1 -1
  45. package/dist/astro/middleware.mjs +129 -107
  46. package/dist/astro/middleware.mjs.map +1 -1
  47. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +13 -13
  48. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +13 -13
  49. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +6 -5
  50. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs.map +1 -1
  51. package/dist/astro/routes/api/admin/api-tokens/index.mjs +7 -6
  52. package/dist/astro/routes/api/admin/api-tokens/index.mjs.map +1 -1
  53. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +5 -5
  54. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +15 -15
  55. package/dist/astro/routes/api/admin/byline-fields/index.mjs +15 -15
  56. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +15 -15
  57. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +20 -20
  58. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +20 -20
  59. package/dist/astro/routes/api/admin/bylines/index.mjs +20 -20
  60. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +17 -17
  61. package/dist/astro/routes/api/admin/comments/_id_.mjs +6 -6
  62. package/dist/astro/routes/api/admin/comments/bulk.mjs +16 -16
  63. package/dist/astro/routes/api/admin/comments/counts.mjs +6 -6
  64. package/dist/astro/routes/api/admin/comments/index.mjs +16 -16
  65. package/dist/astro/routes/api/admin/core-update.mjs +6 -6
  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 +17 -17
  69. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +19 -19
  70. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +19 -19
  71. package/dist/astro/routes/api/admin/media-usage/progress.mjs +16 -16
  72. package/dist/astro/routes/api/admin/media-usage/repair.mjs +22 -22
  73. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +19 -19
  74. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +19 -19
  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 +7 -7
  78. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +7 -7
  79. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +63 -63
  80. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +6 -6
  81. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +62 -62
  82. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +63 -63
  83. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +72 -72
  84. package/dist/astro/routes/api/admin/plugins/index.mjs +63 -63
  85. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +6 -6
  86. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +62 -62
  87. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +71 -71
  88. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +62 -62
  89. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +63 -63
  90. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +73 -73
  91. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +8 -8
  92. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +65 -65
  93. package/dist/astro/routes/api/admin/plugins/registry/publisher-handle.mjs +6 -6
  94. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +63 -63
  95. package/dist/astro/routes/api/admin/plugins/updates.mjs +62 -62
  96. package/dist/astro/routes/api/admin/scheduled-policy-rejections/_collection_/_id_.mjs +4 -4
  97. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +62 -62
  98. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +6 -6
  99. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +62 -62
  100. package/dist/astro/routes/api/admin/transfer/_...path_.mjs +3 -3
  101. package/dist/astro/routes/api/admin/transfer/approvals/_id_/approve.mjs +30 -30
  102. package/dist/astro/routes/api/admin/transfer/approvals/_id_/deny.mjs +30 -30
  103. package/dist/astro/routes/api/admin/transfer/approvals/index.mjs +32 -32
  104. package/dist/astro/routes/api/admin/transfer/capabilities.mjs +32 -32
  105. package/dist/astro/routes/api/admin/transfer/exports/_id_/advance.mjs +32 -32
  106. package/dist/astro/routes/api/admin/transfer/exports/_id_/archive.mjs +33 -33
  107. package/dist/astro/routes/api/admin/transfer/exports/_id_/files/_...path_.mjs +33 -33
  108. package/dist/astro/routes/api/admin/transfer/exports/_id_/index.mjs +32 -32
  109. package/dist/astro/routes/api/admin/transfer/exports/_id_/manifest.mjs +33 -33
  110. package/dist/astro/routes/api/admin/transfer/exports/index.mjs +34 -34
  111. package/dist/astro/routes/api/admin/transfer/imports/_id_/abandon.mjs +32 -32
  112. package/dist/astro/routes/api/admin/transfer/imports/_id_/advance.mjs +32 -32
  113. package/dist/astro/routes/api/admin/transfer/imports/_id_/analyze.mjs +34 -34
  114. package/dist/astro/routes/api/admin/transfer/imports/_id_/cancel.mjs +32 -32
  115. package/dist/astro/routes/api/admin/transfer/imports/_id_/execute.mjs +34 -34
  116. package/dist/astro/routes/api/admin/transfer/imports/_id_/files/_...path_.mjs +32 -32
  117. package/dist/astro/routes/api/admin/transfer/imports/_id_/index.mjs +32 -32
  118. package/dist/astro/routes/api/admin/transfer/imports/_id_/missing.mjs +34 -34
  119. package/dist/astro/routes/api/admin/transfer/imports/_id_/plan.mjs +32 -32
  120. package/dist/astro/routes/api/admin/transfer/imports/_id_/receipt.mjs +32 -32
  121. package/dist/astro/routes/api/admin/transfer/imports/index.mjs +34 -34
  122. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +3 -3
  123. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +3 -3
  124. package/dist/astro/routes/api/admin/users/_id_/index.mjs +13 -13
  125. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +5 -5
  126. package/dist/astro/routes/api/admin/users/index.mjs +13 -13
  127. package/dist/astro/routes/api/auth/dev-bypass.mjs +5 -5
  128. package/dist/astro/routes/api/auth/handover.d.mts +8 -0
  129. package/dist/astro/routes/api/auth/handover.d.mts.map +1 -0
  130. package/dist/astro/routes/api/auth/handover.mjs +49 -0
  131. package/dist/astro/routes/api/auth/handover.mjs.map +1 -0
  132. package/dist/astro/routes/api/auth/invite/accept.mjs +3 -3
  133. package/dist/astro/routes/api/auth/invite/complete.mjs +18 -18
  134. package/dist/astro/routes/api/auth/invite/index.mjs +15 -15
  135. package/dist/astro/routes/api/auth/invite/register-options.mjs +16 -16
  136. package/dist/astro/routes/api/auth/logout.mjs +4 -4
  137. package/dist/astro/routes/api/auth/magic-link/send.mjs +18 -17
  138. package/dist/astro/routes/api/auth/magic-link/send.mjs.map +1 -1
  139. package/dist/astro/routes/api/auth/magic-link/verify.d.mts.map +1 -1
  140. package/dist/astro/routes/api/auth/magic-link/verify.mjs +22 -16
  141. package/dist/astro/routes/api/auth/magic-link/verify.mjs.map +1 -1
  142. package/dist/astro/routes/api/auth/me.mjs +14 -14
  143. package/dist/astro/routes/api/auth/mode.mjs +4 -4
  144. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +7 -7
  145. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  146. package/dist/astro/routes/api/auth/passkey/_id_.mjs +13 -13
  147. package/dist/astro/routes/api/auth/passkey/index.mjs +3 -3
  148. package/dist/astro/routes/api/auth/passkey/options.d.mts.map +1 -1
  149. package/dist/astro/routes/api/auth/passkey/options.mjs +26 -19
  150. package/dist/astro/routes/api/auth/passkey/options.mjs.map +1 -1
  151. package/dist/astro/routes/api/auth/passkey/register/options.mjs +16 -16
  152. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +17 -17
  153. package/dist/astro/routes/api/auth/passkey/verify.mjs +18 -18
  154. package/dist/astro/routes/api/auth/signup/complete.mjs +18 -18
  155. package/dist/astro/routes/api/auth/signup/request.mjs +17 -16
  156. package/dist/astro/routes/api/auth/signup/request.mjs.map +1 -1
  157. package/dist/astro/routes/api/auth/signup/verify.mjs +3 -3
  158. package/dist/astro/routes/api/calendar.mjs +14 -14
  159. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +11 -11
  160. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +17 -17
  161. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +4 -4
  162. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +15 -15
  163. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +4 -4
  164. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +15 -15
  165. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +4 -4
  166. package/dist/astro/routes/api/content/_collection_/_id_/plugin-extensions/_pluginId_/_kind_/_extensionId_.mjs +8 -8
  167. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +23 -23
  168. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +15 -15
  169. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +27 -27
  170. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +27 -27
  171. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +4 -4
  172. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +4 -4
  173. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +15 -15
  174. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +20 -20
  175. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +4 -4
  176. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +15 -15
  177. package/dist/astro/routes/api/content/_collection_/_id_.mjs +15 -15
  178. package/dist/astro/routes/api/content/_collection_/authors.mjs +4 -4
  179. package/dist/astro/routes/api/content/_collection_/index.mjs +14 -14
  180. package/dist/astro/routes/api/content/_collection_/trash.mjs +14 -14
  181. package/dist/astro/routes/api/dashboard.mjs +9 -9
  182. package/dist/astro/routes/api/dev/emails.mjs +4 -4
  183. package/dist/astro/routes/api/health.mjs +5 -5
  184. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  185. package/dist/astro/routes/api/import/probe.mjs +22 -22
  186. package/dist/astro/routes/api/import/wordpress/analyze.mjs +4 -4
  187. package/dist/astro/routes/api/import/wordpress/execute.d.mts +13 -13
  188. package/dist/astro/routes/api/import/wordpress/execute.mjs +28 -21
  189. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  190. package/dist/astro/routes/api/import/wordpress/media.d.mts +12 -12
  191. package/dist/astro/routes/api/import/wordpress/media.mjs +16 -16
  192. package/dist/astro/routes/api/import/wordpress/prepare.mjs +16 -16
  193. package/dist/astro/routes/api/import/wordpress/rewrite-url-helpers.d.mts +8 -0
  194. package/dist/astro/routes/api/import/wordpress/rewrite-url-helpers.d.mts.map +1 -1
  195. package/dist/astro/routes/api/import/wordpress/rewrite-url-helpers.mjs +67 -31
  196. package/dist/astro/routes/api/import/wordpress/rewrite-url-helpers.mjs.map +1 -1
  197. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +13 -13
  198. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +20 -20
  199. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  200. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +22 -22
  201. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +13 -13
  202. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +35 -28
  203. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  204. package/dist/astro/routes/api/manifest.mjs +8 -5
  205. package/dist/astro/routes/api/manifest.mjs.map +1 -1
  206. package/dist/astro/routes/api/mcp.mjs +81 -81
  207. package/dist/astro/routes/api/media/_id_/confirm.d.mts.map +1 -1
  208. package/dist/astro/routes/api/media/_id_/confirm.mjs +32 -16
  209. package/dist/astro/routes/api/media/_id_/confirm.mjs.map +1 -1
  210. package/dist/astro/routes/api/media/_id_/replace.mjs +13 -13
  211. package/dist/astro/routes/api/media/_id_/upload.mjs +6 -6
  212. package/dist/astro/routes/api/media/_id_/usage.mjs +24 -24
  213. package/dist/astro/routes/api/media/_id_.mjs +22 -22
  214. package/dist/astro/routes/api/media/asset/_id_/_filename_.mjs +5 -5
  215. package/dist/astro/routes/api/media/file/_...key_.d.mts.map +1 -1
  216. package/dist/astro/routes/api/media/file/_...key_.mjs +44 -14
  217. package/dist/astro/routes/api/media/file/_...key_.mjs.map +1 -1
  218. package/dist/astro/routes/api/media/folders/_id_.mjs +15 -15
  219. package/dist/astro/routes/api/media/folders/index.mjs +15 -15
  220. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +4 -4
  221. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +4 -4
  222. package/dist/astro/routes/api/media/providers/index.mjs +4 -4
  223. package/dist/astro/routes/api/media/upload-url.mjs +39 -19
  224. package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
  225. package/dist/astro/routes/api/media.d.mts.map +1 -1
  226. package/dist/astro/routes/api/media.mjs +33 -23
  227. package/dist/astro/routes/api/media.mjs.map +1 -1
  228. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +15 -15
  229. package/dist/astro/routes/api/menus/_name_/items.mjs +15 -15
  230. package/dist/astro/routes/api/menus/_name_/reorder.mjs +15 -15
  231. package/dist/astro/routes/api/menus/_name_/translations.mjs +15 -15
  232. package/dist/astro/routes/api/menus/_name_.mjs +15 -15
  233. package/dist/astro/routes/api/menus/index.mjs +15 -15
  234. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  235. package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -7
  236. package/dist/astro/routes/api/oauth/device/code.mjs +11 -10
  237. package/dist/astro/routes/api/oauth/device/code.mjs.map +1 -1
  238. package/dist/astro/routes/api/oauth/device/token.mjs +10 -9
  239. package/dist/astro/routes/api/oauth/device/token.mjs.map +1 -1
  240. package/dist/astro/routes/api/oauth/register.mjs +7 -6
  241. package/dist/astro/routes/api/oauth/register.mjs.map +1 -1
  242. package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -7
  243. package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -7
  244. package/dist/astro/routes/api/oauth/token.mjs +7 -7
  245. package/dist/astro/routes/api/openapi.json.mjs +21 -21
  246. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  247. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +8 -8
  248. package/dist/astro/routes/api/redirects/404s/index.mjs +18 -18
  249. package/dist/astro/routes/api/redirects/404s/summary.mjs +18 -18
  250. package/dist/astro/routes/api/redirects/_id_.mjs +18 -18
  251. package/dist/astro/routes/api/redirects/index.mjs +18 -18
  252. package/dist/astro/routes/api/relations/_id_/index.mjs +27 -27
  253. package/dist/astro/routes/api/relations/index.mjs +27 -27
  254. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +4 -4
  255. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +15 -15
  256. package/dist/astro/routes/api/schema/block-types/_slug_/index.mjs +62 -62
  257. package/dist/astro/routes/api/schema/block-types/_slug_/versions/_version_/activate.mjs +62 -62
  258. package/dist/astro/routes/api/schema/block-types/index.mjs +62 -62
  259. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +62 -62
  260. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +62 -62
  261. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +62 -62
  262. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +62 -62
  263. package/dist/astro/routes/api/schema/collections/index.mjs +62 -62
  264. package/dist/astro/routes/api/schema/collections/reorder.mjs +62 -62
  265. package/dist/astro/routes/api/schema/index.mjs +10 -10
  266. package/dist/astro/routes/api/schema/index.mjs.map +1 -1
  267. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +62 -62
  268. package/dist/astro/routes/api/schema/orphans/index.mjs +62 -62
  269. package/dist/astro/routes/api/search/enable.mjs +17 -17
  270. package/dist/astro/routes/api/search/index.mjs +16 -16
  271. package/dist/astro/routes/api/search/rebuild.mjs +17 -17
  272. package/dist/astro/routes/api/search/stats.mjs +7 -7
  273. package/dist/astro/routes/api/search/suggest.mjs +16 -16
  274. package/dist/astro/routes/api/sections/_slug_.mjs +16 -16
  275. package/dist/astro/routes/api/sections/index.mjs +16 -16
  276. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +6 -6
  277. package/dist/astro/routes/api/settings/backups/archives/index.mjs +6 -6
  278. package/dist/astro/routes/api/settings/backups/export.mjs +6 -6
  279. package/dist/astro/routes/api/settings/backups/index.mjs +7 -7
  280. package/dist/astro/routes/api/settings/domain-notify.d.mts +8 -0
  281. package/dist/astro/routes/api/settings/domain-notify.d.mts.map +1 -0
  282. package/dist/astro/routes/api/settings/domain-notify.mjs +125 -0
  283. package/dist/astro/routes/api/settings/domain-notify.mjs.map +1 -0
  284. package/dist/astro/routes/api/settings/domain.d.mts +9 -0
  285. package/dist/astro/routes/api/settings/domain.d.mts.map +1 -0
  286. package/dist/astro/routes/api/settings/domain.mjs +61 -0
  287. package/dist/astro/routes/api/settings/domain.mjs.map +1 -0
  288. package/dist/astro/routes/api/settings/email.mjs +5 -5
  289. package/dist/astro/routes/api/settings.mjs +18 -18
  290. package/dist/astro/routes/api/setup/admin-verify.mjs +19 -19
  291. package/dist/astro/routes/api/setup/admin.mjs +17 -17
  292. package/dist/astro/routes/api/setup/dev-bypass.mjs +34 -34
  293. package/dist/astro/routes/api/setup/dev-reset.mjs +3 -3
  294. package/dist/astro/routes/api/setup/index.d.mts.map +1 -1
  295. package/dist/astro/routes/api/setup/index.mjs +44 -40
  296. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  297. package/dist/astro/routes/api/setup/status.mjs +5 -5
  298. package/dist/astro/routes/api/site/domain-proof.d.mts +8 -0
  299. package/dist/astro/routes/api/site/domain-proof.d.mts.map +1 -0
  300. package/dist/astro/routes/api/site/domain-proof.mjs +33 -0
  301. package/dist/astro/routes/api/site/domain-proof.mjs.map +1 -0
  302. package/dist/astro/routes/api/snapshot.mjs +7 -7
  303. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +19 -19
  304. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +19 -19
  305. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +19 -19
  306. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +19 -19
  307. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +19 -19
  308. package/dist/astro/routes/api/taxonomies/_name_.mjs +19 -19
  309. package/dist/astro/routes/api/taxonomies/bulk-tag.mjs +27 -27
  310. package/dist/astro/routes/api/taxonomies/index.mjs +19 -19
  311. package/dist/astro/routes/api/themes/preview.mjs +5 -5
  312. package/dist/astro/routes/api/typegen.mjs +5 -5
  313. package/dist/astro/routes/api/visual-editing/action-token.mjs +5 -5
  314. package/dist/astro/routes/api/visual-editing/content/_collection_/_id_/publish.mjs +17 -17
  315. package/dist/astro/routes/api/visual-editing/toolbar-labels.mjs +3 -3
  316. package/dist/astro/routes/api/well-known/auth.mjs +1 -1
  317. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  318. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  319. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +14 -14
  320. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +16 -16
  321. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +16 -16
  322. package/dist/astro/routes/api/widget-areas/_name_.mjs +6 -6
  323. package/dist/astro/routes/api/widget-areas/index.mjs +16 -16
  324. package/dist/astro/routes/api/widget-components.mjs +4 -4
  325. package/dist/astro/routes/robots.txt.mjs +4 -4
  326. package/dist/astro/routes/sitemap-_collection_.xml.d.mts.map +1 -1
  327. package/dist/astro/routes/sitemap-_collection_.xml.mjs +27 -10
  328. package/dist/astro/routes/sitemap-_collection_.xml.mjs.map +1 -1
  329. package/dist/astro/routes/sitemap.xml.d.mts.map +1 -1
  330. package/dist/astro/routes/sitemap.xml.mjs +11 -10
  331. package/dist/astro/routes/sitemap.xml.mjs.map +1 -1
  332. package/dist/astro/types.d.mts +30 -18
  333. package/dist/astro/types.d.mts.map +1 -1
  334. package/dist/auth/providers/github.d.mts +1 -1
  335. package/dist/auth/providers/google.d.mts +1 -1
  336. package/dist/auth/providers/microsoft.d.mts +1 -1
  337. package/dist/authoritative-records-Dcs7l2H5.mjs +5183 -0
  338. package/dist/authoritative-records-Dcs7l2H5.mjs.map +1 -0
  339. package/dist/authorize-TdIGpRSE.mjs +49 -0
  340. package/dist/authorize-TdIGpRSE.mjs.map +1 -0
  341. package/dist/backup-CZt5Mzwx.mjs +246 -0
  342. package/dist/backup-CZt5Mzwx.mjs.map +1 -0
  343. package/dist/block-types-DHnkzE6u.mjs +132 -0
  344. package/dist/block-types-DHnkzE6u.mjs.map +1 -0
  345. package/dist/block-values-C4N_F2-G.mjs +175 -0
  346. package/dist/block-values-C4N_F2-G.mjs.map +1 -0
  347. package/dist/byline-BmVKOQ8l.mjs +909 -0
  348. package/dist/byline-BmVKOQ8l.mjs.map +1 -0
  349. package/dist/byline-fields-B8SDs3M_.mjs +123 -0
  350. package/dist/byline-fields-B8SDs3M_.mjs.map +1 -0
  351. package/dist/byline-fields-Bze3ZdAw.mjs +280 -0
  352. package/dist/byline-fields-Bze3ZdAw.mjs.map +1 -0
  353. package/dist/bylines-CHhR28r9.mjs +150 -0
  354. package/dist/bylines-CHhR28r9.mjs.map +1 -0
  355. package/dist/bylines-DZS4OflA.mjs +234 -0
  356. package/dist/bylines-DZS4OflA.mjs.map +1 -0
  357. package/dist/cache-x0z8t_m9.mjs +133 -0
  358. package/dist/cache-x0z8t_m9.mjs.map +1 -0
  359. package/dist/canonical-BUcKRYpG.mjs +174 -0
  360. package/dist/canonical-BUcKRYpG.mjs.map +1 -0
  361. package/dist/challenge-store-BHgdPVze.mjs +51 -0
  362. package/dist/challenge-store-BHgdPVze.mjs.map +1 -0
  363. package/dist/checksum-BYR5i7qe.mjs +162 -0
  364. package/dist/checksum-BYR5i7qe.mjs.map +1 -0
  365. package/dist/chunks-Dr5Vr0zA.mjs +25 -0
  366. package/dist/chunks-Dr5Vr0zA.mjs.map +1 -0
  367. package/dist/cli/index.mjs +44 -42
  368. package/dist/cli/index.mjs.map +1 -1
  369. package/dist/client/cf-access.d.mts +1 -1
  370. package/dist/client/index.d.mts +107 -107
  371. package/dist/client/index.d.mts.map +1 -1
  372. package/dist/client/index.mjs +2 -2
  373. package/dist/client/index.mjs.map +1 -1
  374. package/dist/comment-CWla6OHV.mjs +325 -0
  375. package/dist/comment-CWla6OHV.mjs.map +1 -0
  376. package/dist/comment-reaction-RZrcs5cW.mjs +85 -0
  377. package/dist/comment-reaction-RZrcs5cW.mjs.map +1 -0
  378. package/dist/comments-BzmIKVb2.mjs +99 -0
  379. package/dist/comments-BzmIKVb2.mjs.map +1 -0
  380. package/dist/comments-Da_dI2O1.mjs +195 -0
  381. package/dist/comments-Da_dI2O1.mjs.map +1 -0
  382. package/dist/components-oFXumpf5.mjs +112 -0
  383. package/dist/components-oFXumpf5.mjs.map +1 -0
  384. package/dist/config--wamYxBW.d.mts +39 -0
  385. package/dist/config--wamYxBW.d.mts.map +1 -0
  386. package/dist/config-Bo4eOOdV.mjs +228 -0
  387. package/dist/config-Bo4eOOdV.mjs.map +1 -0
  388. package/dist/config-C4-UxIk7.d.mts +6790 -0
  389. package/dist/config-C4-UxIk7.d.mts.map +1 -0
  390. package/dist/connection-UpzYxtE2.mjs +36 -0
  391. package/dist/connection-UpzYxtE2.mjs.map +1 -0
  392. package/dist/content-CcHrqkgp.mjs +2072 -0
  393. package/dist/content-CcHrqkgp.mjs.map +1 -0
  394. package/dist/content-list-query-Bxxdd9fv.d.mts +26 -0
  395. package/dist/content-list-query-Bxxdd9fv.d.mts.map +1 -0
  396. package/dist/content-repair-havk1F0-.mjs +442 -0
  397. package/dist/content-repair-havk1F0-.mjs.map +1 -0
  398. package/dist/context-CvhgHgSH.mjs +2043 -0
  399. package/dist/context-CvhgHgSH.mjs.map +1 -0
  400. package/dist/credits-CygUrPOi.mjs +110 -0
  401. package/dist/credits-CygUrPOi.mjs.map +1 -0
  402. package/dist/cron-C6ytTOLw.mjs +306 -0
  403. package/dist/cron-C6ytTOLw.mjs.map +1 -0
  404. package/dist/dashboard-7_FYfafc.mjs +151 -0
  405. package/dist/dashboard-7_FYfafc.mjs.map +1 -0
  406. package/dist/db/index.d.mts +3 -3
  407. package/dist/db/index.mjs +1 -1
  408. package/dist/db/libsql-migrations.d.mts +1 -1
  409. package/dist/db/libsql-migrations.mjs +4 -4
  410. package/dist/db/libsql.d.mts +1 -1
  411. package/dist/db/postgres-migrations.d.mts +1 -1
  412. package/dist/db/postgres-migrations.mjs +4 -4
  413. package/dist/db/postgres.d.mts +1 -1
  414. package/dist/db/sqlite-migrations.d.mts +1 -1
  415. package/dist/db/sqlite-migrations.mjs +4 -4
  416. package/dist/db/sqlite.d.mts +1 -1
  417. package/dist/db/sqlite.mjs +1 -1
  418. package/dist/default-CHCUkV4Z.mjs +81 -0
  419. package/dist/default-CHCUkV4Z.mjs.map +1 -0
  420. package/dist/deferred-tasks-G0xhcJTl.d.mts +9 -0
  421. package/dist/deferred-tasks-G0xhcJTl.d.mts.map +1 -0
  422. package/dist/device-flow-CzDJmQ1q.mjs +521 -0
  423. package/dist/device-flow-CzDJmQ1q.mjs.map +1 -0
  424. package/dist/digest-xJmyPv2r.mjs +194 -0
  425. package/dist/digest-xJmyPv2r.mjs.map +1 -0
  426. package/dist/direct-executor-BXiYIVJ9.mjs +104 -0
  427. package/dist/direct-executor-BXiYIVJ9.mjs.map +1 -0
  428. package/dist/email-console-7ZPApLlm.mjs +50 -0
  429. package/dist/email-console-7ZPApLlm.mjs.map +1 -0
  430. package/dist/email-locale-DFdUA6UF.mjs +25 -0
  431. package/dist/email-locale-DFdUA6UF.mjs.map +1 -0
  432. package/dist/emdash-runtime-C4oFeVpN.mjs +4363 -0
  433. package/dist/emdash-runtime-C4oFeVpN.mjs.map +1 -0
  434. package/dist/entry-lock-B4n0HdQ_.mjs +163 -0
  435. package/dist/entry-lock-B4n0HdQ_.mjs.map +1 -0
  436. package/dist/entry-lock-BAAlKYrz.d.mts +4566 -0
  437. package/dist/entry-lock-BAAlKYrz.d.mts.map +1 -0
  438. package/dist/entry-lock-Cjz0h45X.mjs +1209 -0
  439. package/dist/entry-lock-Cjz0h45X.mjs.map +1 -0
  440. package/dist/env-types-4bkF6Bqg.mjs +38 -0
  441. package/dist/env-types-4bkF6Bqg.mjs.map +1 -0
  442. package/dist/error-DxgQdaZ_.mjs +90 -0
  443. package/dist/error-DxgQdaZ_.mjs.map +1 -0
  444. package/dist/errors-CjtE5aWF.mjs +120 -0
  445. package/dist/errors-CjtE5aWF.mjs.map +1 -0
  446. package/dist/errors-hskQ0C8G.mjs +479 -0
  447. package/dist/errors-hskQ0C8G.mjs.map +1 -0
  448. package/dist/escape-ESFhYzwG.mjs +9 -0
  449. package/dist/escape-ESFhYzwG.mjs.map +1 -0
  450. package/dist/fence-vc3aHgRA.mjs +162 -0
  451. package/dist/fence-vc3aHgRA.mjs.map +1 -0
  452. package/dist/field-defs-cache-zoow36nz.mjs +77 -0
  453. package/dist/field-defs-cache-zoow36nz.mjs.map +1 -0
  454. package/dist/field-map-JD1wG0Tq.mjs +83 -0
  455. package/dist/field-map-JD1wG0Tq.mjs.map +1 -0
  456. package/dist/fts-manager-WJCN8uU6.mjs +443 -0
  457. package/dist/fts-manager-WJCN8uU6.mjs.map +1 -0
  458. package/dist/gc-CsGZiKdH.mjs +75 -0
  459. package/dist/gc-CsGZiKdH.mjs.map +1 -0
  460. package/dist/hook-result-CXjtMk7Q.d.mts +31 -0
  461. package/dist/hook-result-CXjtMk7Q.d.mts.map +1 -0
  462. package/dist/hreflang-BAma7iRr.mjs +105 -0
  463. package/dist/hreflang-BAma7iRr.mjs.map +1 -0
  464. package/dist/hreflang-BsYo4x_M.d.mts +50 -0
  465. package/dist/hreflang-BsYo4x_M.d.mts.map +1 -0
  466. package/dist/http-route-dispatch-C8G7hAK6.mjs +342 -0
  467. package/dist/http-route-dispatch-C8G7hAK6.mjs.map +1 -0
  468. package/dist/identity-BwBKM1fH.mjs +35 -0
  469. package/dist/identity-BwBKM1fH.mjs.map +1 -0
  470. package/dist/import-DJ3Z2wxE.mjs +2021 -0
  471. package/dist/import-DJ3Z2wxE.mjs.map +1 -0
  472. package/dist/index-DYsn97dY.d.mts +623 -0
  473. package/dist/index-DYsn97dY.d.mts.map +1 -0
  474. package/dist/index.d.mts +24 -24
  475. package/dist/index.mjs +87 -87
  476. package/dist/install-finalization-DCFnFSHv.mjs +58 -0
  477. package/dist/install-finalization-DCFnFSHv.mjs.map +1 -0
  478. package/dist/keys-CGvAndSp.mjs +61 -0
  479. package/dist/keys-CGvAndSp.mjs.map +1 -0
  480. package/dist/kinds-DT1W4T4Y.mjs +974 -0
  481. package/dist/kinds-DT1W4T4Y.mjs.map +1 -0
  482. package/dist/lifecycle-BzglCSY0.mjs +25 -0
  483. package/dist/lifecycle-BzglCSY0.mjs.map +1 -0
  484. package/dist/load-DjUqmf3s.mjs +28 -0
  485. package/dist/load-DjUqmf3s.mjs.map +1 -0
  486. package/dist/loader-CetY659y.mjs +1355 -0
  487. package/dist/loader-CetY659y.mjs.map +1 -0
  488. package/dist/loops-DkT1zkPH.mjs +205 -0
  489. package/dist/loops-DkT1zkPH.mjs.map +1 -0
  490. package/dist/manifest-builder-BOFCd9rX.mjs +189 -0
  491. package/dist/manifest-builder-BOFCd9rX.mjs.map +1 -0
  492. package/dist/manifest-schema-BiFBPEsp.mjs +497 -0
  493. package/dist/manifest-schema-BiFBPEsp.mjs.map +1 -0
  494. package/dist/marketplace-CUlenvZm.mjs +257 -0
  495. package/dist/marketplace-CUlenvZm.mjs.map +1 -0
  496. package/dist/media/image-endpoint.d.mts +26 -2
  497. package/dist/media/image-endpoint.d.mts.map +1 -1
  498. package/dist/media/image-endpoint.mjs +73 -3
  499. package/dist/media/image-endpoint.mjs.map +1 -1
  500. package/dist/media/index.d.mts +1 -1
  501. package/dist/media/local-runtime.d.mts +14 -14
  502. package/dist/media/local-runtime.mjs +4 -4
  503. package/dist/media-CRKsKlfK.mjs +416 -0
  504. package/dist/media-CRKsKlfK.mjs.map +1 -0
  505. package/dist/media-C_z7sRuC.mjs +294 -0
  506. package/dist/media-C_z7sRuC.mjs.map +1 -0
  507. package/dist/media-IT8hQleU.mjs +373 -0
  508. package/dist/media-IT8hQleU.mjs.map +1 -0
  509. package/dist/media-allowlist-Ct6wvnT2.mjs +45 -0
  510. package/dist/media-allowlist-Ct6wvnT2.mjs.map +1 -0
  511. package/dist/media-folders-DtMt-vAA.mjs +210 -0
  512. package/dist/media-folders-DtMt-vAA.mjs.map +1 -0
  513. package/dist/media-url-BpXLqCmf.mjs +43 -0
  514. package/dist/media-url-BpXLqCmf.mjs.map +1 -0
  515. package/dist/media-usage-DEPHZZ9X.mjs +282 -0
  516. package/dist/media-usage-DEPHZZ9X.mjs.map +1 -0
  517. package/dist/media-usage-activation-V2Siabtw.mjs +78 -0
  518. package/dist/media-usage-activation-V2Siabtw.mjs.map +1 -0
  519. package/dist/media-usage-work-Cv1OE59F.mjs +151 -0
  520. package/dist/media-usage-work-Cv1OE59F.mjs.map +1 -0
  521. package/dist/media-usage-work-cgDYGvrt.mjs +1015 -0
  522. package/dist/media-usage-work-cgDYGvrt.mjs.map +1 -0
  523. package/dist/menus-CvVYfsuk.mjs +753 -0
  524. package/dist/menus-CvVYfsuk.mjs.map +1 -0
  525. package/dist/menus-D1HC8npj.mjs +92 -0
  526. package/dist/menus-D1HC8npj.mjs.map +1 -0
  527. package/dist/menus-DL8IPIcm.mjs +3721 -0
  528. package/dist/menus-DL8IPIcm.mjs.map +1 -0
  529. package/dist/migrations/index.d.mts +1 -1
  530. package/dist/migrations/index.mjs +3 -3
  531. package/dist/mode-eieqAWLe.mjs +23 -0
  532. package/dist/mode-eieqAWLe.mjs.map +1 -0
  533. package/dist/node-sqlite-compat-VuyzJw1b.mjs +63 -0
  534. package/dist/node-sqlite-compat-VuyzJw1b.mjs.map +1 -0
  535. package/dist/oauth-authorization-B6ZJbMd2.mjs +274 -0
  536. package/dist/oauth-authorization-B6ZJbMd2.mjs.map +1 -0
  537. package/dist/oauth-clients-DVjRc9v3.mjs +266 -0
  538. package/dist/oauth-clients-DVjRc9v3.mjs.map +1 -0
  539. package/dist/oauth-state-store-CnmYYsVQ.mjs +50 -0
  540. package/dist/oauth-state-store-CnmYYsVQ.mjs.map +1 -0
  541. package/dist/oauth-user-lookup-Dz1_R5vT.mjs +26 -0
  542. package/dist/oauth-user-lookup-Dz1_R5vT.mjs.map +1 -0
  543. package/dist/object-cache/memory.d.mts +1 -1
  544. package/dist/options-BR9XZl7h.d.mts +81 -0
  545. package/dist/options-BR9XZl7h.d.mts.map +1 -0
  546. package/dist/ownership-COPyVysP.mjs +12 -0
  547. package/dist/ownership-COPyVysP.mjs.map +1 -0
  548. package/dist/page/index.d.mts +2 -2
  549. package/dist/page/index.mjs +3 -3
  550. package/dist/parse-BOGhrwSq.d.mts +174 -0
  551. package/dist/parse-BOGhrwSq.d.mts.map +1 -0
  552. package/dist/parse-Cn5aSk1N.mjs +81 -0
  553. package/dist/parse-Cn5aSk1N.mjs.map +1 -0
  554. package/dist/passkey-config-mMFRQUCj.mjs +46 -0
  555. package/dist/passkey-config-mMFRQUCj.mjs.map +1 -0
  556. package/dist/paths-BmcAdBo9.mjs +77 -0
  557. package/dist/paths-BmcAdBo9.mjs.map +1 -0
  558. package/dist/patterns-CMNnYCgf.mjs +159 -0
  559. package/dist/patterns-CMNnYCgf.mjs.map +1 -0
  560. package/dist/placeholder-nOep3_Gn.d.mts +306 -0
  561. package/dist/placeholder-nOep3_Gn.d.mts.map +1 -0
  562. package/dist/plan-CDY4K8CH.mjs +135 -0
  563. package/dist/plan-CDY4K8CH.mjs.map +1 -0
  564. package/dist/plugin-test-runtime.d.mts +14 -14
  565. package/dist/plugin-test-runtime.d.mts.map +1 -1
  566. package/dist/plugin-test-runtime.mjs +100 -100
  567. package/dist/plugin-types.d.mts +2 -2
  568. package/dist/plugin-utils.d.mts +12 -12
  569. package/dist/plugin-utils.mjs +1 -1
  570. package/dist/plugin-utils.mjs.map +1 -1
  571. package/dist/plugins/adapt-sandbox-entry.d.mts +12 -12
  572. package/dist/plugins/adapt-sandbox-entry.mjs +3 -3
  573. package/dist/plugins/host.d.mts +5 -5
  574. package/dist/plugins/host.mjs +35 -35
  575. package/dist/plugins-DFBpfbO3.mjs +261 -0
  576. package/dist/plugins-DFBpfbO3.mjs.map +1 -0
  577. package/dist/policy-B_2qnHSy.mjs +45 -0
  578. package/dist/policy-B_2qnHSy.mjs.map +1 -0
  579. package/dist/portable-text-Dc2YAusw.mjs +307 -0
  580. package/dist/portable-text-Dc2YAusw.mjs.map +1 -0
  581. package/dist/preview-BtzikJ9O.mjs +107 -0
  582. package/dist/preview-BtzikJ9O.mjs.map +1 -0
  583. package/dist/protocol-M268ox8L.d.mts +61 -0
  584. package/dist/protocol-M268ox8L.d.mts.map +1 -0
  585. package/dist/public-submission-BQZavgZU.mjs +251 -0
  586. package/dist/public-submission-BQZavgZU.mjs.map +1 -0
  587. package/dist/public-url-uT1Ok2Tu.mjs +101 -0
  588. package/dist/public-url-uT1Ok2Tu.mjs.map +1 -0
  589. package/dist/query-BGG3sDEd.mjs +1127 -0
  590. package/dist/query-BGG3sDEd.mjs.map +1 -0
  591. package/dist/query-C_CWlifp.mjs +41 -0
  592. package/dist/query-C_CWlifp.mjs.map +1 -0
  593. package/dist/range-CXK_kDbI.mjs +51 -0
  594. package/dist/range-CXK_kDbI.mjs.map +1 -0
  595. package/dist/rate-limit-Dvamvay-.mjs +127 -0
  596. package/dist/rate-limit-Dvamvay-.mjs.map +1 -0
  597. package/dist/receipt-BmQGzquP.mjs +43 -0
  598. package/dist/receipt-BmQGzquP.mjs.map +1 -0
  599. package/dist/redirect-B39kTQ_0.mjs +423 -0
  600. package/dist/redirect-B39kTQ_0.mjs.map +1 -0
  601. package/dist/redirect-BguJ00Pv.mjs +19 -0
  602. package/dist/redirect-BguJ00Pv.mjs.map +1 -0
  603. package/dist/redirects-C8G4BsfP.mjs +446 -0
  604. package/dist/redirects-C8G4BsfP.mjs.map +1 -0
  605. package/dist/redirects-DFT7Wr-e.mjs +148 -0
  606. package/dist/redirects-DFT7Wr-e.mjs.map +1 -0
  607. package/dist/registry/testing.mjs +3 -3
  608. package/dist/registry-DeZ27gVi.mjs +8374 -0
  609. package/dist/registry-DeZ27gVi.mjs.map +1 -0
  610. package/dist/relations-DBB1bRJW.mjs +776 -0
  611. package/dist/relations-DBB1bRJW.mjs.map +1 -0
  612. package/dist/request-context.d.mts +1 -1
  613. package/dist/request-meta-BSvkhIBX.mjs +141 -0
  614. package/dist/request-meta-BSvkhIBX.mjs.map +1 -0
  615. package/dist/resolve-BxH64HN9.mjs +100 -0
  616. package/dist/resolve-BxH64HN9.mjs.map +1 -0
  617. package/dist/route-wire-CwbWB_6O.mjs +197 -0
  618. package/dist/route-wire-CwbWB_6O.mjs.map +1 -0
  619. package/dist/routes-BfIxc7ft.mjs +272 -0
  620. package/dist/routes-BfIxc7ft.mjs.map +1 -0
  621. package/dist/runner-DkeafPBA.d.mts +68 -0
  622. package/dist/runner-DkeafPBA.d.mts.map +1 -0
  623. package/dist/runner-wqt4BrIW.mjs +6383 -0
  624. package/dist/runner-wqt4BrIW.mjs.map +1 -0
  625. package/dist/runtime.d.mts +13 -13
  626. package/dist/runtime.mjs +1 -1
  627. package/dist/schema/project-env-types.mjs +29 -29
  628. package/dist/schema-BXIW-JHi.mjs +815 -0
  629. package/dist/schema-BXIW-JHi.mjs.map +1 -0
  630. package/dist/schema-I74JwYte.mjs +13 -0
  631. package/dist/schema-I74JwYte.mjs.map +1 -0
  632. package/dist/scopes-RWZ5ft_Z.mjs +34 -0
  633. package/dist/scopes-RWZ5ft_Z.mjs.map +1 -0
  634. package/dist/search-DxwagyWS.mjs +450 -0
  635. package/dist/search-DxwagyWS.mjs.map +1 -0
  636. package/dist/sections-Ccq9ZgyD.mjs +346 -0
  637. package/dist/sections-Ccq9ZgyD.mjs.map +1 -0
  638. package/dist/seed/index.d.mts +2 -2
  639. package/dist/seed/index.mjs +27 -27
  640. package/dist/seo/index.d.mts +3 -3
  641. package/dist/seo/index.mjs +14 -14
  642. package/dist/seo-CCnfPWAQ.mjs +133 -0
  643. package/dist/seo-CCnfPWAQ.mjs.map +1 -0
  644. package/dist/seo-QCtJ1jjV.mjs +188 -0
  645. package/dist/seo-QCtJ1jjV.mjs.map +1 -0
  646. package/dist/service-DX84s2rw.mjs +150 -0
  647. package/dist/service-DX84s2rw.mjs.map +1 -0
  648. package/dist/session-user-1dtJc2zv.mjs +61 -0
  649. package/dist/session-user-1dtJc2zv.mjs.map +1 -0
  650. package/dist/settings-B1jOxAIl.mjs +443 -0
  651. package/dist/settings-B1jOxAIl.mjs.map +1 -0
  652. package/dist/settings-Bc1IBl1t.mjs +66 -0
  653. package/dist/settings-Bc1IBl1t.mjs.map +1 -0
  654. package/dist/settings-GaZ5sVgg.mjs +73 -0
  655. package/dist/settings-GaZ5sVgg.mjs.map +1 -0
  656. package/dist/setup-complete-DidMAWJS.mjs +65 -0
  657. package/dist/setup-complete-DidMAWJS.mjs.map +1 -0
  658. package/dist/setup-nonce-DKl4S4c6.mjs +25 -0
  659. package/dist/setup-nonce-DKl4S4c6.mjs.map +1 -0
  660. package/dist/site-domain-CbI51Pc2.mjs +113 -0
  661. package/dist/site-domain-CbI51Pc2.mjs.map +1 -0
  662. package/dist/site-settings-CDdT4mVm.mjs +50 -0
  663. package/dist/site-settings-CDdT4mVm.mjs.map +1 -0
  664. package/dist/site-url-CrDZaAvo.mjs +45 -0
  665. package/dist/site-url-CrDZaAvo.mjs.map +1 -0
  666. package/dist/sitemap-name-W3BTor6X.mjs +26 -0
  667. package/dist/sitemap-name-W3BTor6X.mjs.map +1 -0
  668. package/dist/slug-BJhHKoOH.mjs +16 -0
  669. package/dist/slug-BJhHKoOH.mjs.map +1 -0
  670. package/dist/slugify-bu2-jKia.mjs +22 -0
  671. package/dist/slugify-bu2-jKia.mjs.map +1 -0
  672. package/dist/snapshot-BuI_2uDe.mjs +414 -0
  673. package/dist/snapshot-BuI_2uDe.mjs.map +1 -0
  674. package/dist/ssrf-LM_0wpGA.mjs +406 -0
  675. package/dist/ssrf-LM_0wpGA.mjs.map +1 -0
  676. package/dist/stage-DhzZuYaT.mjs +662 -0
  677. package/dist/stage-DhzZuYaT.mjs.map +1 -0
  678. package/dist/staged-DboEaWsV.mjs +686 -0
  679. package/dist/staged-DboEaWsV.mjs.map +1 -0
  680. package/dist/state-DCXDzjHq.mjs +178 -0
  681. package/dist/state-DCXDzjHq.mjs.map +1 -0
  682. package/dist/status-Dl85BK39.mjs +30 -0
  683. package/dist/status-Dl85BK39.mjs.map +1 -0
  684. package/dist/storage/local.d.mts +2 -2
  685. package/dist/storage/local.d.mts.map +1 -1
  686. package/dist/storage/local.mjs +11 -4
  687. package/dist/storage/local.mjs.map +1 -1
  688. package/dist/storage/s3.d.mts +4 -2
  689. package/dist/storage/s3.d.mts.map +1 -1
  690. package/dist/storage/s3.mjs +56 -9
  691. package/dist/storage/s3.mjs.map +1 -1
  692. package/dist/storage-query-BOBmeDMD.d.mts +1615 -0
  693. package/dist/storage-query-BOBmeDMD.d.mts.map +1 -0
  694. package/dist/tar-K40edFMt.mjs +449 -0
  695. package/dist/tar-K40edFMt.mjs.map +1 -0
  696. package/dist/target-BOighEY1.mjs +27 -0
  697. package/dist/target-BOighEY1.mjs.map +1 -0
  698. package/dist/taxonomies-DQSywBvX.mjs +697 -0
  699. package/dist/taxonomies-DQSywBvX.mjs.map +1 -0
  700. package/dist/taxonomies-Dj5eaobC.mjs +939 -0
  701. package/dist/taxonomies-Dj5eaobC.mjs.map +1 -0
  702. package/dist/taxonomy-QrNmTfIZ.mjs +550 -0
  703. package/dist/taxonomy-QrNmTfIZ.mjs.map +1 -0
  704. package/dist/tokens-j5L0as2H.mjs +171 -0
  705. package/dist/tokens-j5L0as2H.mjs.map +1 -0
  706. package/dist/transfer-CYEw8Tu4.mjs +8873 -0
  707. package/dist/transfer-CYEw8Tu4.mjs.map +1 -0
  708. package/dist/transfer-DDX10hkD.mjs +166 -0
  709. package/dist/transfer-DDX10hkD.mjs.map +1 -0
  710. package/dist/transfer-download-BAqq6GJv.mjs +33 -0
  711. package/dist/transfer-download-BAqq6GJv.mjs.map +1 -0
  712. package/dist/transformations-De44wqV_.mjs +196 -0
  713. package/dist/transformations-De44wqV_.mjs.map +1 -0
  714. package/dist/transport-1QjUhCRO.d.mts +42 -0
  715. package/dist/transport-1QjUhCRO.d.mts.map +1 -0
  716. package/dist/transport-Ds5pVX7p.mjs +136 -0
  717. package/dist/transport-Ds5pVX7p.mjs.map +1 -0
  718. package/dist/trusted-proxy-d4Tk6biT.mjs +51 -0
  719. package/dist/trusted-proxy-d4Tk6biT.mjs.map +1 -0
  720. package/dist/turnstile-DaFLtyrs.mjs +58 -0
  721. package/dist/turnstile-DaFLtyrs.mjs.map +1 -0
  722. package/dist/types-B4-1P2DK.d.mts +227 -0
  723. package/dist/types-B4-1P2DK.d.mts.map +1 -0
  724. package/dist/types-BKXA0f-c.mjs +16 -0
  725. package/dist/types-BKXA0f-c.mjs.map +1 -0
  726. package/dist/types-BiHcpUoO.d.mts +374 -0
  727. package/dist/types-BiHcpUoO.d.mts.map +1 -0
  728. package/dist/types-BihhvkyN.d.mts +85 -0
  729. package/dist/types-BihhvkyN.d.mts.map +1 -0
  730. package/dist/types-Bq9Wohd7.d.mts +363 -0
  731. package/dist/types-Bq9Wohd7.d.mts.map +1 -0
  732. package/dist/types-C-Xp0CcN.mjs.map +1 -1
  733. package/dist/types-C4P7F1Vq.d.mts +1741 -0
  734. package/dist/types-C4P7F1Vq.d.mts.map +1 -0
  735. package/dist/types-CGaqwHw4.mjs +37 -0
  736. package/dist/types-CGaqwHw4.mjs.map +1 -0
  737. package/dist/types-D4ECCE4X.mjs +77 -0
  738. package/dist/types-D4ECCE4X.mjs.map +1 -0
  739. package/dist/types-DcRJp0vS.d.mts +125 -0
  740. package/dist/types-DcRJp0vS.d.mts.map +1 -0
  741. package/dist/types-Ff85fTzU.d.mts +289 -0
  742. package/dist/types-Ff85fTzU.d.mts.map +1 -0
  743. package/dist/types-UKr5Sf4y.d.mts +916 -0
  744. package/dist/types-UKr5Sf4y.d.mts.map +1 -0
  745. package/dist/types-YpN8hZW7.d.mts +204 -0
  746. package/dist/types-YpN8hZW7.d.mts.map +1 -0
  747. package/dist/update-check-DrlsK-tt.mjs +161 -0
  748. package/dist/update-check-DrlsK-tt.mjs.map +1 -0
  749. package/dist/upload-attempts-D8CPPvRU.mjs +32 -0
  750. package/dist/upload-attempts-D8CPPvRU.mjs.map +1 -0
  751. package/dist/url-pattern-Di4Nn3vP.mjs +41 -0
  752. package/dist/url-pattern-Di4Nn3vP.mjs.map +1 -0
  753. package/dist/user-B-ZdGjhI.mjs +171 -0
  754. package/dist/user-B-ZdGjhI.mjs.map +1 -0
  755. package/dist/utils-D7wL3r6-.mjs +437 -0
  756. package/dist/utils-D7wL3r6-.mjs.map +1 -0
  757. package/dist/validate-BSZbSUDk.mjs +524 -0
  758. package/dist/validate-BSZbSUDk.mjs.map +1 -0
  759. package/dist/validate-Dfv0DpZi.d.mts +468 -0
  760. package/dist/validate-Dfv0DpZi.d.mts.map +1 -0
  761. package/dist/validation-DRyC_Vm5.mjs +219 -0
  762. package/dist/validation-DRyC_Vm5.mjs.map +1 -0
  763. package/dist/version-C4kz0PcO.mjs +7 -0
  764. package/dist/version-C4kz0PcO.mjs.map +1 -0
  765. package/dist/version-jhs2BRtl.mjs +9 -0
  766. package/dist/version-jhs2BRtl.mjs.map +1 -0
  767. package/dist/video-DReZ48Un.mjs +54 -0
  768. package/dist/video-DReZ48Un.mjs.map +1 -0
  769. package/dist/virtual-modules-D0e6VbEv.mjs +516 -0
  770. package/dist/virtual-modules-D0e6VbEv.mjs.map +1 -0
  771. package/dist/widgets-BkcMzKct.mjs +121 -0
  772. package/dist/widgets-BkcMzKct.mjs.map +1 -0
  773. package/dist/wxr-taxonomies-BxI0CbTg.mjs +453 -0
  774. package/dist/wxr-taxonomies-BxI0CbTg.mjs.map +1 -0
  775. package/dist/wxr-taxonomies-Dad33GJi.d.mts +34 -0
  776. package/dist/wxr-taxonomies-Dad33GJi.d.mts.map +1 -0
  777. package/package.json +13 -10
  778. package/src/api/errors.ts +9 -0
  779. package/src/api/handlers/api-tokens.ts +12 -6
  780. package/src/api/handlers/content.ts +57 -8
  781. package/src/api/handlers/domain-move-notice.ts +94 -0
  782. package/src/api/handlers/index.ts +2 -0
  783. package/src/api/handlers/manifest.ts +5 -0
  784. package/src/api/handlers/media-usage.ts +2 -1
  785. package/src/api/handlers/media.ts +1 -0
  786. package/src/api/handlers/seo.ts +155 -59
  787. package/src/api/handlers/settings.ts +31 -1
  788. package/src/api/handlers/site-domain.ts +143 -0
  789. package/src/api/openapi/document.ts +2 -2
  790. package/src/api/public-url.ts +1 -1
  791. package/src/api/schemas/content.ts +20 -0
  792. package/src/api/schemas/media-usage.ts +7 -1
  793. package/src/api/schemas/media.ts +12 -0
  794. package/src/api/site-url.ts +53 -5
  795. package/src/api/types.ts +2 -0
  796. package/src/astro/image-endpoint.ts +46 -4
  797. package/src/astro/integration/admin-locales.ts +168 -0
  798. package/src/astro/integration/dev-env.ts +84 -0
  799. package/src/astro/integration/index.ts +49 -9
  800. package/src/astro/integration/routes.ts +20 -0
  801. package/src/astro/integration/runtime.ts +15 -0
  802. package/src/astro/integration/vite-config.ts +18 -1
  803. package/src/astro/middleware/auth.ts +16 -3
  804. package/src/astro/middleware/csp.ts +1 -0
  805. package/src/astro/middleware/redirect.ts +27 -12
  806. package/src/astro/middleware/request-context.ts +12 -6
  807. package/src/astro/middleware.ts +53 -14
  808. package/src/astro/routes/api/auth/handover.ts +58 -0
  809. package/src/astro/routes/api/auth/magic-link/verify.ts +11 -3
  810. package/src/astro/routes/api/auth/passkey/options.ts +10 -2
  811. package/src/astro/routes/api/import/wordpress/execute.ts +19 -0
  812. package/src/astro/routes/api/import/wordpress/rewrite-url-helpers.ts +80 -42
  813. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +15 -0
  814. package/src/astro/routes/api/manifest.ts +10 -0
  815. package/src/astro/routes/api/media/[id]/confirm.ts +19 -0
  816. package/src/astro/routes/api/media/file/[...key].ts +60 -12
  817. package/src/astro/routes/api/media/upload-url.ts +28 -4
  818. package/src/astro/routes/api/media.ts +15 -0
  819. package/src/astro/routes/api/schema/index.ts +1 -1
  820. package/src/astro/routes/api/settings/domain-notify.ts +76 -0
  821. package/src/astro/routes/api/settings/domain.ts +63 -0
  822. package/src/astro/routes/api/setup/index.ts +7 -0
  823. package/src/astro/routes/api/site/domain-proof.ts +28 -0
  824. package/src/astro/routes/sitemap-[collection].xml.ts +31 -8
  825. package/src/astro/routes/sitemap.xml.ts +12 -10
  826. package/src/astro/types.ts +13 -1
  827. package/src/auth/rate-limit.ts +18 -13
  828. package/src/auth/types.ts +7 -0
  829. package/src/aws-sdk.d.ts +2 -1
  830. package/src/cleanup.ts +26 -0
  831. package/src/cli/commands/export-seed.ts +2 -0
  832. package/src/cli/commands/seed.ts +5 -4
  833. package/src/client/index.ts +6 -1
  834. package/src/comments/public-submission.ts +15 -8
  835. package/src/components/CommentForm.astro +48 -8
  836. package/src/components/Comments.astro +50 -28
  837. package/src/components/EmDashImage.astro +6 -4
  838. package/src/components/Gallery.astro +4 -3
  839. package/src/components/Image.astro +4 -3
  840. package/src/components/InlinePortableTextEditor.tsx +148 -26
  841. package/src/components/Video.astro +100 -0
  842. package/src/components/index.ts +4 -1
  843. package/src/components/inline-code-block.tsx +8 -0
  844. package/src/components/webmcp-search.ts +15 -19
  845. package/src/components/widgets/RecentPosts.astro +57 -17
  846. package/src/content/converters/mark-safety.ts +3 -3
  847. package/src/content/converters/portable-text-identity.ts +1 -0
  848. package/src/content/converters/portable-text-to-prosemirror.ts +7 -0
  849. package/src/content/converters/prosemirror-to-portable-text.ts +16 -0
  850. package/src/content/converters/types.ts +22 -0
  851. package/src/content/converters/video.ts +77 -0
  852. package/src/database/datetime-storage.ts +1 -1
  853. package/src/database/migrations/runner.ts +13 -1
  854. package/src/database/repositories/comment.ts +17 -3
  855. package/src/database/repositories/content.ts +22 -3
  856. package/src/database/repositories/plugin-storage.ts +28 -19
  857. package/src/database/repositories/redirect.ts +24 -2
  858. package/src/database/repositories/taxonomy.ts +61 -46
  859. package/src/database/repositories/types.ts +2 -0
  860. package/src/emdash-runtime.ts +217 -68
  861. package/src/import/sources/wordpress-plugin.ts +3 -2
  862. package/src/import/utils.ts +2 -3
  863. package/src/index.ts +3 -0
  864. package/src/loader.ts +134 -43
  865. package/src/media/image-endpoint.ts +101 -1
  866. package/src/media/responsive.ts +14 -7
  867. package/src/media/usage/extractor.ts +19 -2
  868. package/src/media/usage/types.ts +5 -1
  869. package/src/plugin-utils.ts +1 -1
  870. package/src/plugins/context.ts +3 -7
  871. package/src/plugins/hooks.ts +1 -1
  872. package/src/plugins/http-route-dispatch.ts +5 -1
  873. package/src/plugins/manifest-schema.ts +1 -0
  874. package/src/plugins/route-error.ts +14 -0
  875. package/src/plugins/routes.ts +2 -2
  876. package/src/plugins/state.ts +36 -0
  877. package/src/plugins/types.ts +6 -0
  878. package/src/query.ts +8 -0
  879. package/src/redirects/patterns.ts +26 -2
  880. package/src/schema/registry.ts +7 -4
  881. package/src/schema/slug.ts +19 -0
  882. package/src/search/text-extraction.ts +6 -1
  883. package/src/seed/validate.ts +31 -0
  884. package/src/seo/sitemap-name.ts +22 -0
  885. package/src/storage/index.ts +2 -0
  886. package/src/storage/local.ts +10 -2
  887. package/src/storage/range.ts +54 -0
  888. package/src/storage/s3.ts +52 -8
  889. package/src/storage/types.ts +30 -3
  890. package/src/ui.ts +1 -0
  891. package/src/utils/slugify.ts +6 -1
  892. package/src/visual-editing/toolbar.ts +80 -35
  893. package/src/widgets/components.ts +4 -0
  894. package/src/widgets/index.ts +74 -82
  895. package/src/widgets/recent-posts.ts +62 -0
  896. package/dist/action-token-AgOs1UWD.mjs +0 -26
  897. package/dist/action-token-AgOs1UWD.mjs.map +0 -1
  898. package/dist/adapters-DM1oyHIN.d.mts +0 -173
  899. package/dist/adapters-DM1oyHIN.d.mts.map +0 -1
  900. package/dist/allowed-origins-CFtudhyw.mjs +0 -116
  901. package/dist/allowed-origins-CFtudhyw.mjs.map +0 -1
  902. package/dist/api-CltsXhiX.mjs +0 -4980
  903. package/dist/api-CltsXhiX.mjs.map +0 -1
  904. package/dist/api-tokens-P3mAaQgr.mjs +0 -166
  905. package/dist/api-tokens-P3mAaQgr.mjs.map +0 -1
  906. package/dist/apply-Q7uvzBWW.mjs +0 -1680
  907. package/dist/apply-Q7uvzBWW.mjs.map +0 -1
  908. package/dist/approvals-DycwI6lZ.mjs +0 -460
  909. package/dist/approvals-DycwI6lZ.mjs.map +0 -1
  910. package/dist/artifact-fetch-CWxyELVI.mjs +0 -659
  911. package/dist/artifact-fetch-CWxyELVI.mjs.map +0 -1
  912. package/dist/artifacts-UzWbysb8.mjs +0 -307
  913. package/dist/artifacts-UzWbysb8.mjs.map +0 -1
  914. package/dist/authoritative-records-dSvXCfzb.mjs +0 -5172
  915. package/dist/authoritative-records-dSvXCfzb.mjs.map +0 -1
  916. package/dist/authorize-DeWfk--K.mjs +0 -49
  917. package/dist/authorize-DeWfk--K.mjs.map +0 -1
  918. package/dist/backup-CFnbdTSJ.mjs +0 -246
  919. package/dist/backup-CFnbdTSJ.mjs.map +0 -1
  920. package/dist/block-types-C0YFSfR7.mjs +0 -132
  921. package/dist/block-types-C0YFSfR7.mjs.map +0 -1
  922. package/dist/block-values-H4E0XwE8.mjs +0 -175
  923. package/dist/block-values-H4E0XwE8.mjs.map +0 -1
  924. package/dist/byline-BhVslYLz.mjs +0 -909
  925. package/dist/byline-BhVslYLz.mjs.map +0 -1
  926. package/dist/byline-fields-DHJs0Mja.mjs +0 -280
  927. package/dist/byline-fields-DHJs0Mja.mjs.map +0 -1
  928. package/dist/byline-fields-xdxE9kxZ.mjs +0 -123
  929. package/dist/byline-fields-xdxE9kxZ.mjs.map +0 -1
  930. package/dist/bylines-B_nN9liM.mjs +0 -234
  931. package/dist/bylines-B_nN9liM.mjs.map +0 -1
  932. package/dist/bylines-C71YACkL.mjs +0 -150
  933. package/dist/bylines-C71YACkL.mjs.map +0 -1
  934. package/dist/cache-aTYCL9nK.mjs +0 -133
  935. package/dist/cache-aTYCL9nK.mjs.map +0 -1
  936. package/dist/canonical-Y1dpjCnp.mjs +0 -174
  937. package/dist/canonical-Y1dpjCnp.mjs.map +0 -1
  938. package/dist/challenge-store-CxZxPqaw.mjs +0 -51
  939. package/dist/challenge-store-CxZxPqaw.mjs.map +0 -1
  940. package/dist/checksum-DtH6m5uk.mjs +0 -162
  941. package/dist/checksum-DtH6m5uk.mjs.map +0 -1
  942. package/dist/chunks-zlGB5IQP.mjs +0 -25
  943. package/dist/chunks-zlGB5IQP.mjs.map +0 -1
  944. package/dist/comment-Bu08Wvr3.mjs +0 -313
  945. package/dist/comment-Bu08Wvr3.mjs.map +0 -1
  946. package/dist/comment-reaction-B8SfT-yM.mjs +0 -85
  947. package/dist/comment-reaction-B8SfT-yM.mjs.map +0 -1
  948. package/dist/comments-BRtp992B.mjs +0 -99
  949. package/dist/comments-BRtp992B.mjs.map +0 -1
  950. package/dist/comments-DVUYqdyC.mjs +0 -195
  951. package/dist/comments-DVUYqdyC.mjs.map +0 -1
  952. package/dist/components-CQY-Sgm-.mjs +0 -108
  953. package/dist/components-CQY-Sgm-.mjs.map +0 -1
  954. package/dist/config-B-uePMLj.d.mts +0 -39
  955. package/dist/config-B-uePMLj.d.mts.map +0 -1
  956. package/dist/config-B6BDSsz2.d.mts +0 -6712
  957. package/dist/config-B6BDSsz2.d.mts.map +0 -1
  958. package/dist/config-BsJHiQxC.mjs +0 -228
  959. package/dist/config-BsJHiQxC.mjs.map +0 -1
  960. package/dist/connection-B9pIasFd.mjs +0 -36
  961. package/dist/connection-B9pIasFd.mjs.map +0 -1
  962. package/dist/content-Dji9vEiW.mjs +0 -2063
  963. package/dist/content-Dji9vEiW.mjs.map +0 -1
  964. package/dist/content-list-query-DiNwyKtd.d.mts +0 -26
  965. package/dist/content-list-query-DiNwyKtd.d.mts.map +0 -1
  966. package/dist/content-repair-B7wnbzhN.mjs +0 -442
  967. package/dist/content-repair-B7wnbzhN.mjs.map +0 -1
  968. package/dist/context-Ctcxc8Ia.mjs +0 -2026
  969. package/dist/context-Ctcxc8Ia.mjs.map +0 -1
  970. package/dist/credits-Bu7dlobo.mjs +0 -110
  971. package/dist/credits-Bu7dlobo.mjs.map +0 -1
  972. package/dist/cron-xe5XKqA-.mjs +0 -306
  973. package/dist/cron-xe5XKqA-.mjs.map +0 -1
  974. package/dist/dashboard-B5hVHOtf.mjs +0 -151
  975. package/dist/dashboard-B5hVHOtf.mjs.map +0 -1
  976. package/dist/default-DaoYyFRS.mjs +0 -81
  977. package/dist/default-DaoYyFRS.mjs.map +0 -1
  978. package/dist/deferred-tasks-BYcDx2o_.d.mts +0 -9
  979. package/dist/deferred-tasks-BYcDx2o_.d.mts.map +0 -1
  980. package/dist/device-flow-Ma5P5d2e.mjs +0 -521
  981. package/dist/device-flow-Ma5P5d2e.mjs.map +0 -1
  982. package/dist/digest-xIpR3o64.mjs +0 -194
  983. package/dist/digest-xIpR3o64.mjs.map +0 -1
  984. package/dist/direct-executor-DMWwCey3.mjs +0 -104
  985. package/dist/direct-executor-DMWwCey3.mjs.map +0 -1
  986. package/dist/email-console-DmqVF5J_.mjs +0 -50
  987. package/dist/email-console-DmqVF5J_.mjs.map +0 -1
  988. package/dist/email-locale-Cc5YSXfJ.mjs +0 -25
  989. package/dist/email-locale-Cc5YSXfJ.mjs.map +0 -1
  990. package/dist/emdash-runtime-BlybX9Ui.mjs +0 -4249
  991. package/dist/emdash-runtime-BlybX9Ui.mjs.map +0 -1
  992. package/dist/entry-lock-De1L8qUQ.mjs +0 -163
  993. package/dist/entry-lock-De1L8qUQ.mjs.map +0 -1
  994. package/dist/entry-lock-esmMbgI9.d.mts +0 -4551
  995. package/dist/entry-lock-esmMbgI9.d.mts.map +0 -1
  996. package/dist/entry-lock-sxz2PGAT.mjs +0 -1197
  997. package/dist/entry-lock-sxz2PGAT.mjs.map +0 -1
  998. package/dist/env-types-BkjCtN13.mjs +0 -38
  999. package/dist/env-types-BkjCtN13.mjs.map +0 -1
  1000. package/dist/error-B0rgPgsQ.mjs +0 -90
  1001. package/dist/error-B0rgPgsQ.mjs.map +0 -1
  1002. package/dist/errors-CuHQRiBW.mjs +0 -120
  1003. package/dist/errors-CuHQRiBW.mjs.map +0 -1
  1004. package/dist/errors-DTE6C3K_.mjs +0 -470
  1005. package/dist/errors-DTE6C3K_.mjs.map +0 -1
  1006. package/dist/escape-nJW7dR0s.mjs +0 -9
  1007. package/dist/escape-nJW7dR0s.mjs.map +0 -1
  1008. package/dist/fence-CGw57S4v.mjs +0 -162
  1009. package/dist/fence-CGw57S4v.mjs.map +0 -1
  1010. package/dist/field-defs-cache-Bw8w499w.mjs +0 -77
  1011. package/dist/field-defs-cache-Bw8w499w.mjs.map +0 -1
  1012. package/dist/field-map-hn-D-SyH.mjs +0 -83
  1013. package/dist/field-map-hn-D-SyH.mjs.map +0 -1
  1014. package/dist/fts-manager-DacCYIe4.mjs +0 -443
  1015. package/dist/fts-manager-DacCYIe4.mjs.map +0 -1
  1016. package/dist/gc-BBplHrv6.mjs +0 -75
  1017. package/dist/gc-BBplHrv6.mjs.map +0 -1
  1018. package/dist/hook-result-DSRRxu_-.d.mts +0 -31
  1019. package/dist/hook-result-DSRRxu_-.d.mts.map +0 -1
  1020. package/dist/hreflang-CKPunvU0.mjs +0 -105
  1021. package/dist/hreflang-CKPunvU0.mjs.map +0 -1
  1022. package/dist/hreflang-egumj6WF.d.mts +0 -50
  1023. package/dist/hreflang-egumj6WF.d.mts.map +0 -1
  1024. package/dist/http-route-dispatch-DjNFZcJ2.mjs +0 -339
  1025. package/dist/http-route-dispatch-DjNFZcJ2.mjs.map +0 -1
  1026. package/dist/identity-Dfrx2_Bc.mjs +0 -35
  1027. package/dist/identity-Dfrx2_Bc.mjs.map +0 -1
  1028. package/dist/import-ROBvhbNc.mjs +0 -2021
  1029. package/dist/import-ROBvhbNc.mjs.map +0 -1
  1030. package/dist/index-B4sIdCAT.d.mts +0 -623
  1031. package/dist/index-B4sIdCAT.d.mts.map +0 -1
  1032. package/dist/install-finalization-CPM7Gged.mjs +0 -58
  1033. package/dist/install-finalization-CPM7Gged.mjs.map +0 -1
  1034. package/dist/keys-DxqxcAD4.mjs +0 -61
  1035. package/dist/keys-DxqxcAD4.mjs.map +0 -1
  1036. package/dist/kinds-BQl5gN6e.mjs +0 -974
  1037. package/dist/kinds-BQl5gN6e.mjs.map +0 -1
  1038. package/dist/lifecycle-DGQI7itS.mjs +0 -25
  1039. package/dist/lifecycle-DGQI7itS.mjs.map +0 -1
  1040. package/dist/load-DMxRl4VK.mjs +0 -28
  1041. package/dist/load-DMxRl4VK.mjs.map +0 -1
  1042. package/dist/loader-1DMiOq5s.mjs +0 -1303
  1043. package/dist/loader-1DMiOq5s.mjs.map +0 -1
  1044. package/dist/loops-Dn1i16FP.mjs +0 -205
  1045. package/dist/loops-Dn1i16FP.mjs.map +0 -1
  1046. package/dist/manifest-builder-CTw4FmZk.mjs +0 -189
  1047. package/dist/manifest-builder-CTw4FmZk.mjs.map +0 -1
  1048. package/dist/manifest-schema-gy37bD_D.mjs +0 -496
  1049. package/dist/manifest-schema-gy37bD_D.mjs.map +0 -1
  1050. package/dist/marketplace-tHWSsCUo.mjs +0 -257
  1051. package/dist/marketplace-tHWSsCUo.mjs.map +0 -1
  1052. package/dist/media-Bw-Q65ve.mjs +0 -294
  1053. package/dist/media-Bw-Q65ve.mjs.map +0 -1
  1054. package/dist/media-BzUDu7nl.mjs +0 -373
  1055. package/dist/media-BzUDu7nl.mjs.map +0 -1
  1056. package/dist/media-aahnKHze.mjs +0 -408
  1057. package/dist/media-aahnKHze.mjs.map +0 -1
  1058. package/dist/media-allowlist-RMrjo8TU.mjs +0 -45
  1059. package/dist/media-allowlist-RMrjo8TU.mjs.map +0 -1
  1060. package/dist/media-folders-kabR1oJf.mjs +0 -210
  1061. package/dist/media-folders-kabR1oJf.mjs.map +0 -1
  1062. package/dist/media-url-DloW2xrP.mjs +0 -43
  1063. package/dist/media-url-DloW2xrP.mjs.map +0 -1
  1064. package/dist/media-usage-CHHpV7ee.mjs +0 -282
  1065. package/dist/media-usage-CHHpV7ee.mjs.map +0 -1
  1066. package/dist/media-usage-activation-BinYqC_r.mjs +0 -78
  1067. package/dist/media-usage-activation-BinYqC_r.mjs.map +0 -1
  1068. package/dist/media-usage-work-C734aq6s.mjs +0 -1015
  1069. package/dist/media-usage-work-C734aq6s.mjs.map +0 -1
  1070. package/dist/media-usage-work-lxvV0-UO.mjs +0 -151
  1071. package/dist/media-usage-work-lxvV0-UO.mjs.map +0 -1
  1072. package/dist/menus-6RHNq4ZK.mjs +0 -753
  1073. package/dist/menus-6RHNq4ZK.mjs.map +0 -1
  1074. package/dist/menus-AuCTaO9W.mjs +0 -3704
  1075. package/dist/menus-AuCTaO9W.mjs.map +0 -1
  1076. package/dist/menus-BQKqf0Up.mjs +0 -92
  1077. package/dist/menus-BQKqf0Up.mjs.map +0 -1
  1078. package/dist/mode-nh0ppSX5.mjs +0 -23
  1079. package/dist/mode-nh0ppSX5.mjs.map +0 -1
  1080. package/dist/node-sqlite-compat-CDOEcc97.mjs +0 -63
  1081. package/dist/node-sqlite-compat-CDOEcc97.mjs.map +0 -1
  1082. package/dist/oauth-authorization-BtYQ80uU.mjs +0 -274
  1083. package/dist/oauth-authorization-BtYQ80uU.mjs.map +0 -1
  1084. package/dist/oauth-clients-C1S4NQHh.mjs +0 -266
  1085. package/dist/oauth-clients-C1S4NQHh.mjs.map +0 -1
  1086. package/dist/oauth-state-store-CpGi2FZH.mjs +0 -50
  1087. package/dist/oauth-state-store-CpGi2FZH.mjs.map +0 -1
  1088. package/dist/oauth-user-lookup-BNp1aFAr.mjs +0 -26
  1089. package/dist/oauth-user-lookup-BNp1aFAr.mjs.map +0 -1
  1090. package/dist/options-B41aLm1I.d.mts +0 -81
  1091. package/dist/options-B41aLm1I.d.mts.map +0 -1
  1092. package/dist/ownership-DoeAIuTg.mjs +0 -12
  1093. package/dist/ownership-DoeAIuTg.mjs.map +0 -1
  1094. package/dist/parse-CmFDTGzp.mjs +0 -81
  1095. package/dist/parse-CmFDTGzp.mjs.map +0 -1
  1096. package/dist/parse-QVS0t5oR.d.mts +0 -172
  1097. package/dist/parse-QVS0t5oR.d.mts.map +0 -1
  1098. package/dist/passkey-config-C-MxsV22.mjs +0 -46
  1099. package/dist/passkey-config-C-MxsV22.mjs.map +0 -1
  1100. package/dist/paths-kr8hAMMI.mjs +0 -77
  1101. package/dist/paths-kr8hAMMI.mjs.map +0 -1
  1102. package/dist/patterns-DyZJ67I7.mjs +0 -140
  1103. package/dist/patterns-DyZJ67I7.mjs.map +0 -1
  1104. package/dist/placeholder-Dn7MMdWr.d.mts +0 -306
  1105. package/dist/placeholder-Dn7MMdWr.d.mts.map +0 -1
  1106. package/dist/plan-CuQOeU9g.mjs +0 -135
  1107. package/dist/plan-CuQOeU9g.mjs.map +0 -1
  1108. package/dist/plugins-CGb-G98c.mjs +0 -261
  1109. package/dist/plugins-CGb-G98c.mjs.map +0 -1
  1110. package/dist/policy-C5wrDXYV.mjs +0 -45
  1111. package/dist/policy-C5wrDXYV.mjs.map +0 -1
  1112. package/dist/portable-text-BnRuiR1-.mjs +0 -307
  1113. package/dist/portable-text-BnRuiR1-.mjs.map +0 -1
  1114. package/dist/preview-xWNSR1Li.mjs +0 -107
  1115. package/dist/preview-xWNSR1Li.mjs.map +0 -1
  1116. package/dist/protocol-ClxN-m1e.d.mts +0 -61
  1117. package/dist/protocol-ClxN-m1e.d.mts.map +0 -1
  1118. package/dist/public-submission-CkmT2SKv.mjs +0 -250
  1119. package/dist/public-submission-CkmT2SKv.mjs.map +0 -1
  1120. package/dist/public-url-B5a0QAh6.mjs +0 -101
  1121. package/dist/public-url-B5a0QAh6.mjs.map +0 -1
  1122. package/dist/query-DHqFiqqH.mjs +0 -41
  1123. package/dist/query-DHqFiqqH.mjs.map +0 -1
  1124. package/dist/query-DT85BehD.mjs +0 -1125
  1125. package/dist/query-DT85BehD.mjs.map +0 -1
  1126. package/dist/rate-limit-iMvcu3eu.mjs +0 -120
  1127. package/dist/rate-limit-iMvcu3eu.mjs.map +0 -1
  1128. package/dist/receipt-Dpp1uaX9.mjs +0 -43
  1129. package/dist/receipt-Dpp1uaX9.mjs.map +0 -1
  1130. package/dist/redirect-BRoLiWQE.mjs +0 -19
  1131. package/dist/redirect-BRoLiWQE.mjs.map +0 -1
  1132. package/dist/redirect-xZNpBoGp.mjs +0 -417
  1133. package/dist/redirect-xZNpBoGp.mjs.map +0 -1
  1134. package/dist/redirects-D4EWeXAo.mjs +0 -148
  1135. package/dist/redirects-D4EWeXAo.mjs.map +0 -1
  1136. package/dist/redirects-DCKqwiWp.mjs +0 -446
  1137. package/dist/redirects-DCKqwiWp.mjs.map +0 -1
  1138. package/dist/registry-DaXmUsD4.mjs +0 -8369
  1139. package/dist/registry-DaXmUsD4.mjs.map +0 -1
  1140. package/dist/relations-JvBP8nGP.mjs +0 -776
  1141. package/dist/relations-JvBP8nGP.mjs.map +0 -1
  1142. package/dist/request-meta-B6blULFY.mjs +0 -141
  1143. package/dist/request-meta-B6blULFY.mjs.map +0 -1
  1144. package/dist/resolve-DAhHi5tn.mjs +0 -100
  1145. package/dist/resolve-DAhHi5tn.mjs.map +0 -1
  1146. package/dist/route-wire-DK600v4u.mjs +0 -197
  1147. package/dist/route-wire-DK600v4u.mjs.map +0 -1
  1148. package/dist/routes-BeZyaCzv.mjs +0 -272
  1149. package/dist/routes-BeZyaCzv.mjs.map +0 -1
  1150. package/dist/runner-CskI4Hmq.mjs +0 -6372
  1151. package/dist/runner-CskI4Hmq.mjs.map +0 -1
  1152. package/dist/runner-J3Cj6DGk.d.mts +0 -68
  1153. package/dist/runner-J3Cj6DGk.d.mts.map +0 -1
  1154. package/dist/schema-CK0ihqMR.mjs +0 -815
  1155. package/dist/schema-CK0ihqMR.mjs.map +0 -1
  1156. package/dist/schema-VtaZSrC-.mjs +0 -13
  1157. package/dist/schema-VtaZSrC-.mjs.map +0 -1
  1158. package/dist/scopes-BRnGlL9t.mjs +0 -34
  1159. package/dist/scopes-BRnGlL9t.mjs.map +0 -1
  1160. package/dist/search-D6-XK1Sn.mjs +0 -448
  1161. package/dist/search-D6-XK1Sn.mjs.map +0 -1
  1162. package/dist/sections-CBDCf7qR.mjs +0 -346
  1163. package/dist/sections-CBDCf7qR.mjs.map +0 -1
  1164. package/dist/seo-BdeEPDNW.mjs +0 -133
  1165. package/dist/seo-BdeEPDNW.mjs.map +0 -1
  1166. package/dist/seo-C61bnPuV.mjs +0 -114
  1167. package/dist/seo-C61bnPuV.mjs.map +0 -1
  1168. package/dist/service-BuRKLMxa.mjs +0 -150
  1169. package/dist/service-BuRKLMxa.mjs.map +0 -1
  1170. package/dist/session-user-CqkPtrPL.mjs +0 -61
  1171. package/dist/session-user-CqkPtrPL.mjs.map +0 -1
  1172. package/dist/settings-0u0lTthS.mjs +0 -51
  1173. package/dist/settings-0u0lTthS.mjs.map +0 -1
  1174. package/dist/settings-WHr45II1.mjs +0 -61
  1175. package/dist/settings-WHr45II1.mjs.map +0 -1
  1176. package/dist/settings-m5tIYnF0.mjs +0 -443
  1177. package/dist/settings-m5tIYnF0.mjs.map +0 -1
  1178. package/dist/setup-complete-B2_dhZZz.mjs +0 -65
  1179. package/dist/setup-complete-B2_dhZZz.mjs.map +0 -1
  1180. package/dist/setup-nonce-CJV9ftSK.mjs +0 -25
  1181. package/dist/setup-nonce-CJV9ftSK.mjs.map +0 -1
  1182. package/dist/site-settings-KJOqJW6W.mjs +0 -50
  1183. package/dist/site-settings-KJOqJW6W.mjs.map +0 -1
  1184. package/dist/site-url-Ceq_AUK0.mjs +0 -16
  1185. package/dist/site-url-Ceq_AUK0.mjs.map +0 -1
  1186. package/dist/slugify-T5GHH42D.mjs +0 -17
  1187. package/dist/slugify-T5GHH42D.mjs.map +0 -1
  1188. package/dist/snapshot-Dzsn3NZa.mjs +0 -414
  1189. package/dist/snapshot-Dzsn3NZa.mjs.map +0 -1
  1190. package/dist/ssrf-DsmvZB80.mjs +0 -406
  1191. package/dist/ssrf-DsmvZB80.mjs.map +0 -1
  1192. package/dist/stage-Csnh_yEd.mjs +0 -662
  1193. package/dist/stage-Csnh_yEd.mjs.map +0 -1
  1194. package/dist/staged-Q7pnEVvI.mjs +0 -686
  1195. package/dist/staged-Q7pnEVvI.mjs.map +0 -1
  1196. package/dist/state-kGdOMQRY.mjs +0 -153
  1197. package/dist/state-kGdOMQRY.mjs.map +0 -1
  1198. package/dist/status-D39Fpy8R.mjs +0 -30
  1199. package/dist/status-D39Fpy8R.mjs.map +0 -1
  1200. package/dist/storage-query-C7iy6eUb.d.mts +0 -1615
  1201. package/dist/storage-query-C7iy6eUb.d.mts.map +0 -1
  1202. package/dist/tar-BWiraSUY.mjs +0 -449
  1203. package/dist/tar-BWiraSUY.mjs.map +0 -1
  1204. package/dist/target-DOFs5oUC.mjs +0 -27
  1205. package/dist/target-DOFs5oUC.mjs.map +0 -1
  1206. package/dist/taxonomies-BS40Wxvi.mjs +0 -939
  1207. package/dist/taxonomies-BS40Wxvi.mjs.map +0 -1
  1208. package/dist/taxonomies-DAZU9VDd.mjs +0 -697
  1209. package/dist/taxonomies-DAZU9VDd.mjs.map +0 -1
  1210. package/dist/taxonomy-XzLE95Vx.mjs +0 -525
  1211. package/dist/taxonomy-XzLE95Vx.mjs.map +0 -1
  1212. package/dist/tokens-DSQan4p7.mjs +0 -171
  1213. package/dist/tokens-DSQan4p7.mjs.map +0 -1
  1214. package/dist/transfer-BcCVxDgf.mjs +0 -166
  1215. package/dist/transfer-BcCVxDgf.mjs.map +0 -1
  1216. package/dist/transfer-OMrancOt.mjs +0 -8873
  1217. package/dist/transfer-OMrancOt.mjs.map +0 -1
  1218. package/dist/transfer-download-Dc-ltjZY.mjs +0 -33
  1219. package/dist/transfer-download-Dc-ltjZY.mjs.map +0 -1
  1220. package/dist/transformations-Ddx7UtrY.mjs +0 -196
  1221. package/dist/transformations-Ddx7UtrY.mjs.map +0 -1
  1222. package/dist/transport-flR-Zmds.d.mts +0 -42
  1223. package/dist/transport-flR-Zmds.d.mts.map +0 -1
  1224. package/dist/transport-umzEbgYO.mjs +0 -136
  1225. package/dist/transport-umzEbgYO.mjs.map +0 -1
  1226. package/dist/trusted-proxy-BqfQFs6a.mjs +0 -51
  1227. package/dist/trusted-proxy-BqfQFs6a.mjs.map +0 -1
  1228. package/dist/turnstile-Do60baId.mjs +0 -58
  1229. package/dist/turnstile-Do60baId.mjs.map +0 -1
  1230. package/dist/types-BT1p3uyb.d.mts +0 -1735
  1231. package/dist/types-BT1p3uyb.d.mts.map +0 -1
  1232. package/dist/types-BYaPWs_F.d.mts +0 -198
  1233. package/dist/types-BYaPWs_F.d.mts.map +0 -1
  1234. package/dist/types-CLTQ9b_r.d.mts +0 -374
  1235. package/dist/types-CLTQ9b_r.d.mts.map +0 -1
  1236. package/dist/types-CPkQw2T2.d.mts +0 -85
  1237. package/dist/types-CPkQw2T2.d.mts.map +0 -1
  1238. package/dist/types-CQLvuXoZ.d.mts +0 -198
  1239. package/dist/types-CQLvuXoZ.d.mts.map +0 -1
  1240. package/dist/types-CV5xszpF.d.mts +0 -363
  1241. package/dist/types-CV5xszpF.d.mts.map +0 -1
  1242. package/dist/types-CdEMurNh.mjs +0 -77
  1243. package/dist/types-CdEMurNh.mjs.map +0 -1
  1244. package/dist/types-CxwtnuSS.mjs +0 -37
  1245. package/dist/types-CxwtnuSS.mjs.map +0 -1
  1246. package/dist/types-DGw8KMX_.mjs +0 -16
  1247. package/dist/types-DGw8KMX_.mjs.map +0 -1
  1248. package/dist/types-DOfVMPoo.d.mts +0 -125
  1249. package/dist/types-DOfVMPoo.d.mts.map +0 -1
  1250. package/dist/types-LtS0SM4F.d.mts +0 -287
  1251. package/dist/types-LtS0SM4F.d.mts.map +0 -1
  1252. package/dist/types-ifgOkcBa.d.mts +0 -916
  1253. package/dist/types-ifgOkcBa.d.mts.map +0 -1
  1254. package/dist/update-check-DOc2aBIU.mjs +0 -161
  1255. package/dist/update-check-DOc2aBIU.mjs.map +0 -1
  1256. package/dist/upload-attempts-nzdc3cay.mjs +0 -32
  1257. package/dist/upload-attempts-nzdc3cay.mjs.map +0 -1
  1258. package/dist/url-pattern-hVbqpXs6.mjs +0 -41
  1259. package/dist/url-pattern-hVbqpXs6.mjs.map +0 -1
  1260. package/dist/user-Dnp53zTq.mjs +0 -171
  1261. package/dist/user-Dnp53zTq.mjs.map +0 -1
  1262. package/dist/utils-CoV-PYhg.mjs +0 -439
  1263. package/dist/utils-CoV-PYhg.mjs.map +0 -1
  1264. package/dist/validate-CfQ9_YlD.d.mts +0 -468
  1265. package/dist/validate-CfQ9_YlD.d.mts.map +0 -1
  1266. package/dist/validate-DBX3DKtL.mjs +0 -516
  1267. package/dist/validate-DBX3DKtL.mjs.map +0 -1
  1268. package/dist/validation-BJMiDhB1.mjs +0 -219
  1269. package/dist/validation-BJMiDhB1.mjs.map +0 -1
  1270. package/dist/version-BaT8yKIT.mjs +0 -7
  1271. package/dist/version-BaT8yKIT.mjs.map +0 -1
  1272. package/dist/version-BwEGkqkx.mjs +0 -9
  1273. package/dist/version-BwEGkqkx.mjs.map +0 -1
  1274. package/dist/virtual-modules-B6vJW15k.mjs +0 -516
  1275. package/dist/virtual-modules-B6vJW15k.mjs.map +0 -1
  1276. package/dist/widgets-BkxBAgZ_.mjs +0 -126
  1277. package/dist/widgets-BkxBAgZ_.mjs.map +0 -1
  1278. package/dist/wxr-taxonomies-D7gAJyOF.mjs +0 -453
  1279. package/dist/wxr-taxonomies-D7gAJyOF.mjs.map +0 -1
  1280. package/dist/wxr-taxonomies-DM5J9AsT.d.mts +0 -34
  1281. package/dist/wxr-taxonomies-DM5J9AsT.d.mts.map +0 -1
  1282. /package/dist/{api-tokens-BLz2MtQs.mjs → api-tokens-D2zgAIEt.mjs} +0 -0
  1283. /package/dist/{ssrf-tA45vIPX.mjs → ssrf-BvNItdxk.mjs} +0 -0
@@ -0,0 +1,2072 @@
1
+ import { d as __exportAll } from "./runner-wqt4BrIW.mjs";
2
+ import { n as isMissingTableError } from "./db-errors-CBD5yMro.mjs";
3
+ import { t as validateIdentifier } from "./validate-DANX1-Qi.mjs";
4
+ import { c as executeAtomicBatchIfSupported, u as isPostgres } from "./dialect-helpers-7_IqPdh9.mjs";
5
+ import { i as normalizeExplicitDatetime } from "./datetime-normalization-PeiEdcRY.mjs";
6
+ import { l as invalidateCollectionCache } from "./object-cache-Bo6DGaC9.mjs";
7
+ import { f as isIndexableFieldType, m as isStoragelessFieldRow } from "./types-BGmQ0uXs.mjs";
8
+ import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-Dr5Vr0zA.mjs";
9
+ import { n as slugify } from "./slugify-bu2-jKia.mjs";
10
+ import { c as encodeCursor, i as InvalidCursorError, n as ContentMutationConflictError, o as ScheduledNotDueError, r as EmDashValidationError, s as decodeCursor, t as ContentCollectionNotFoundError } from "./types-C-Xp0CcN.mjs";
11
+ import { i as ContentDatetimeNormalizer, n as createRevisionId, t as RevisionRepository } from "./revision-BWEH2qQB.mjs";
12
+ import { t as withTransaction } from "./transaction-BVYIo_yu.mjs";
13
+ import { sql } from "kysely";
14
+ import { ulid } from "ulidx";
15
+
16
+ //#region src/content/known-fields.ts
17
+ /**
18
+ * Reconcile an entry's keys with the fields its collection currently declares.
19
+ *
20
+ * A draft revision stores the whole `data` as JSON, so deleting a field leaves the old
21
+ * value inside the revision. Every content-write surface needs the same two rules to keep
22
+ * that from stranding the entry, so they live here rather than in one caller.
23
+ */
24
+ /** Keys EmDash reserves (`_slug` and the like). No field declares them. */
25
+ function isReservedKey(key) {
26
+ return key.startsWith("_");
27
+ }
28
+ /**
29
+ * The entry data without the keys the collection has no field for.
30
+ *
31
+ * Reserved keys are kept.
32
+ */
33
+ function keepKnownFields(data, knownFieldSlugs) {
34
+ const result = {};
35
+ for (const [key, value] of Object.entries(data)) if (isReservedKey(key) || knownFieldSlugs.has(key)) result[key] = value;
36
+ return result;
37
+ }
38
+ /**
39
+ * Incoming keys with no matching field that the entry already stores.
40
+ *
41
+ * Dropping these lets a read-then-write save succeed after the field was deleted. A key the
42
+ * entry has never stored is not returned, so a genuinely unknown field is still reported.
43
+ */
44
+ function staleStoredKeys(data, stored, knownFieldSlugs) {
45
+ return Object.keys(data).filter((key) => !isReservedKey(key) && !knownFieldSlugs.has(key) && Object.hasOwn(stored, key));
46
+ }
47
+
48
+ //#endregion
49
+ //#region src/search/match.ts
50
+ /**
51
+ * FTS5 match-expression builder for structured (non-user-syntax) queries.
52
+ *
53
+ * Unlike `escapeQuery` in `query.ts` (which powers the public search API and
54
+ * deliberately passes through FTS5 operators like AND/OR/NOT), this builder
55
+ * treats the input as plain words: every term is double-quoted with interior
56
+ * quotes escaped, so the result can never produce an FTS5 syntax error. Used
57
+ * by the admin content-list filter, where the input is a filter box, not a
58
+ * search-syntax field.
59
+ */
60
+ const WHITESPACE_RE = /\s+/;
61
+ const DOUBLE_QUOTE_RE = /"/g;
62
+ const GLOB_SPECIAL_RE = /[[\]*?]/g;
63
+ /**
64
+ * Build a prefix-matching FTS5 MATCH expression from free-form input.
65
+ *
66
+ * `hello wor` becomes `"hello"* "wor"*` — implicit AND with per-term prefix
67
+ * matching. Returns `""` when the input contains no usable terms; callers
68
+ * must fall back to their non-FTS path in that case.
69
+ */
70
+ function buildFtsPrefixMatch(input) {
71
+ const terms = input.trim().split(WHITESPACE_RE).map((term) => term.replace(DOUBLE_QUOTE_RE, "\"\"")).filter((term) => term.length > 0);
72
+ if (terms.length === 0) return "";
73
+ return terms.map((term) => `"${term}"*`).join(" ");
74
+ }
75
+ /**
76
+ * Build a GLOB prefix pattern from free-form input, treating GLOB
77
+ * metacharacters (`* ? [ ]`) literally by wrapping each in a character
78
+ * class (GLOB has no ESCAPE clause).
79
+ *
80
+ * GLOB (unlike default LIKE) is case-sensitive, so with a lowercased
81
+ * pattern it matches slugs (lowercase by construction) while staying
82
+ * servable by the ordinary BINARY-collated slug index — SQLite's GLOB
83
+ * optimization turns a `prefix*` pattern into an index range scan.
84
+ */
85
+ function buildSlugGlobPrefix(input) {
86
+ return `${input.trim().toLowerCase().replace(GLOB_SPECIAL_RE, (c) => `[${c}]`)}*`;
87
+ }
88
+
89
+ //#endregion
90
+ //#region src/database/repositories/content.ts
91
+ var content_exports = /* @__PURE__ */ __exportAll({
92
+ ContentRepository: () => ContentRepository,
93
+ isConfirmedStatementFailure: () => isConfirmedStatementFailure,
94
+ isSystemOrderField: () => isSystemOrderField
95
+ });
96
+ const ULID_PATTERN = /^[0-9A-Z]{26}$/;
97
+ const SQLSTATE_PATTERN = /^[0-9A-Z]{5}$/;
98
+ const MAX_DRAFT_STAGE_ATTEMPTS = 32;
99
+ const LIKE_WILDCARD_RE = /[\\%_]/g;
100
+ const MAX_INDEXED_FIELD_FILTERS = 20;
101
+ const MAX_IN_FILTER_VALUES = SQL_BATCH_SIZE;
102
+ const MAX_FILTER_STRING_LENGTH = 2048;
103
+ function assertRevisionPrecondition(item, expected) {
104
+ if (expected && (item.version !== expected.version || item.updatedAt !== expected.updatedAt)) throw new ContentMutationConflictError();
105
+ }
106
+ function nullableColumnMatch(column, value) {
107
+ validateIdentifier(column, "content column");
108
+ return value === null ? sql`${sql.ref(column)} IS NULL` : sql`${sql.ref(column)} = ${value}`;
109
+ }
110
+ function sameStoredValue(left, right) {
111
+ return Object.is(serializeValue(left), serializeValue(right));
112
+ }
113
+ function matchesPublication(observed, existing, revisionData, revisionId, slug, publishedAt, updatedAt) {
114
+ 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;
115
+ return Object.entries(revisionData).every(([key, value]) => SYSTEM_COLUMNS.has(key) || key.startsWith("_") || sameStoredValue(observed.data[key], value));
116
+ }
117
+ function matchesLifecyclePublication(observed, existing, liveRevisionId, publishedAt, updatedAt) {
118
+ 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;
119
+ return Object.entries(existing.data).every(([key, value]) => sameStoredValue(observed.data[key], value));
120
+ }
121
+ function matchesPublicationFence(observed, existing) {
122
+ return observed.version === existing.version && observed.status === existing.status && observed.liveRevisionId === existing.liveRevisionId && observed.draftRevisionId === existing.draftRevisionId && observed.scheduledAt === existing.scheduledAt;
123
+ }
124
+ function isConfirmedStatementFailure(error) {
125
+ if (typeof error !== "object" || error === null || !("code" in error)) return false;
126
+ const code = error.code;
127
+ return typeof code === "string" && (code === "ERR_SQLITE_ERROR" || code.startsWith("SQLITE_") || SQLSTATE_PATTERN.test(code));
128
+ }
129
+ function encodeNullableOrderCursor(field, value, id) {
130
+ const payload = {
131
+ version: 1,
132
+ field,
133
+ value
134
+ };
135
+ return encodeCursor(JSON.stringify(payload), id);
136
+ }
137
+ /**
138
+ * `acceptPlain` also accepts the plain `{ orderValue, id }` cursor that
139
+ * built-in and collection sort fields were paged with before, which wrote a
140
+ * NULL as "".
141
+ */
142
+ function decodeNullableOrderCursor(cursor, field, { acceptPlain = false } = {}) {
143
+ const { orderValue, id } = decodeCursor(cursor);
144
+ let payload;
145
+ try {
146
+ payload = JSON.parse(orderValue);
147
+ } catch {
148
+ payload = void 0;
149
+ }
150
+ if (payload === null || typeof payload !== "object") {
151
+ if (acceptPlain) return {
152
+ value: orderValue === "" ? null : orderValue,
153
+ id
154
+ };
155
+ throw new InvalidCursorError(cursor);
156
+ }
157
+ const candidate = payload;
158
+ const validValue = candidate.value === null || typeof candidate.value === "string" || typeof candidate.value === "number";
159
+ if (candidate.version !== 1 || candidate.field !== field || !validValue) throw new InvalidCursorError(cursor);
160
+ return {
161
+ value: candidate.value,
162
+ id
163
+ };
164
+ }
165
+ /**
166
+ * Keyset condition for the rows after (`value`, `cursorId`) in a sort by the
167
+ * nullable `column`, then `id`. The ORDER BY keeps each dialect's own NULL
168
+ * position, lowest on SQLite and highest on Postgres, so the condition follows
169
+ * it.
170
+ */
171
+ function nullableOrderCondition(db, column, direction, value, cursorId) {
172
+ const sort = sql.ref(column);
173
+ const id = sql.ref("id");
174
+ const cmp = direction === "ASC" ? sql.raw(">") : sql.raw("<");
175
+ const nullsFirst = direction === "ASC" !== isPostgres(db);
176
+ if (value === null) return nullsFirst ? sql`(${sort} IS NOT NULL OR ${id} ${cmp} ${cursorId})` : sql`(${sort} IS NULL AND ${id} ${cmp} ${cursorId})`;
177
+ const past = sql`(${sort}, ${id}) ${cmp} (${value}, ${cursorId})`;
178
+ return nullsFirst ? past : sql`(${past} OR ${sort} IS NULL)`;
179
+ }
180
+ /**
181
+ * Whitelist mapping a public date-filter field to its physical column. Keeping
182
+ * this separate from `mapOrderField` makes the filterable set explicit and
183
+ * prevents filtering on arbitrary columns.
184
+ */
185
+ const DATE_FILTER_COLUMNS = {
186
+ createdAt: "created_at",
187
+ updatedAt: "updated_at",
188
+ publishedAt: "published_at"
189
+ };
190
+ /**
191
+ * Built-in sort fields → their physical columns. A closed set that blocks
192
+ * sorting by arbitrary columns; per-collection fields are allowed
193
+ * separately via `mapOrderField`'s `sortableExtras`.
194
+ */
195
+ const ORDER_FIELD_COLUMNS = {
196
+ createdAt: "created_at",
197
+ updatedAt: "updated_at",
198
+ publishedAt: "published_at",
199
+ scheduledAt: "scheduled_at",
200
+ deletedAt: "deleted_at",
201
+ title: "title",
202
+ name: "name",
203
+ slug: "slug",
204
+ status: "status",
205
+ locale: "locale"
206
+ };
207
+ /**
208
+ * Order columns every row has a value for. Their cursors keep the plain
209
+ * `{ orderValue, id }` shape; a cursor for any other order column records a
210
+ * NULL explicitly.
211
+ */
212
+ const NON_NULL_ORDER_COLUMNS = new Set([
213
+ "created_at",
214
+ "updated_at",
215
+ "status",
216
+ "locale"
217
+ ]);
218
+ /** True when `field` maps to a system column and needs no per-collection resolution. */
219
+ function isSystemOrderField(field) {
220
+ return field in ORDER_FIELD_COLUMNS;
221
+ }
222
+ /**
223
+ * System columns that exist in every ec_* table
224
+ */
225
+ const SYSTEM_COLUMNS = new Set([
226
+ "id",
227
+ "slug",
228
+ "status",
229
+ "author_id",
230
+ "primary_byline_id",
231
+ "created_at",
232
+ "updated_at",
233
+ "published_at",
234
+ "scheduled_at",
235
+ "deleted_at",
236
+ "version",
237
+ "live_revision_id",
238
+ "draft_revision_id",
239
+ "locale",
240
+ "translation_group"
241
+ ]);
242
+ /**
243
+ * Get the table name for a collection type
244
+ */
245
+ function getTableName(type) {
246
+ validateIdentifier(type, "collection type");
247
+ return `ec_${type}`;
248
+ }
249
+ function assertPageOffset(offset, cursor) {
250
+ if (offset === void 0) return;
251
+ if (cursor !== void 0) throw new EmDashValidationError("cursor and offset cannot be used together");
252
+ if (!Number.isSafeInteger(offset) || offset < 0) throw new EmDashValidationError("offset must be a non-negative integer");
253
+ }
254
+ /**
255
+ * Serialize a value for database storage
256
+ * Objects/arrays are JSON-stringified
257
+ * Booleans are converted to 0/1 for SQLite
258
+ */
259
+ function serializeValue(value) {
260
+ if (value === null || value === void 0) return null;
261
+ if (typeof value === "boolean") return value ? 1 : 0;
262
+ if (typeof value === "object") return JSON.stringify(value);
263
+ return value;
264
+ }
265
+ function writableContentData(data) {
266
+ const writable = {};
267
+ for (const [key, value] of Object.entries(data)) {
268
+ if (SYSTEM_COLUMNS.has(key)) continue;
269
+ validateIdentifier(key, "content field name");
270
+ writable[key] = value;
271
+ }
272
+ return writable;
273
+ }
274
+ /**
275
+ * Deserialize a value from database storage
276
+ * Attempts to parse JSON strings that look like objects/arrays
277
+ */
278
+ function deserializeValue(value) {
279
+ if (typeof value === "string") {
280
+ if (value.startsWith("{") || value.startsWith("[")) try {
281
+ return JSON.parse(value);
282
+ } catch {
283
+ return value;
284
+ }
285
+ }
286
+ return value;
287
+ }
288
+ /** Pattern for escaping special regex characters */
289
+ const REGEX_ESCAPE_PATTERN = /[.*+?^${}()|[\]\\]/g;
290
+ /**
291
+ * Escape special regex characters in a string for use in `new RegExp()`
292
+ */
293
+ function escapeRegExp(s) {
294
+ return s.replace(REGEX_ESCAPE_PATTERN, "\\$&");
295
+ }
296
+ /**
297
+ * Repository for content CRUD operations
298
+ *
299
+ * Content is stored in per-collection tables (ec_posts, ec_pages, etc.)
300
+ * Each field becomes a real column in the table.
301
+ */
302
+ var ContentRepository = class {
303
+ datetimes;
304
+ constructor(db, datetimeContexts) {
305
+ this.db = db;
306
+ this.datetimeContexts = datetimeContexts;
307
+ this.datetimes = new ContentDatetimeNormalizer(db, datetimeContexts);
308
+ }
309
+ /**
310
+ * Create a new content item
311
+ */
312
+ async create(input) {
313
+ const id = input.id ?? ulid();
314
+ const now = (/* @__PURE__ */ new Date()).toISOString();
315
+ const { type, slug, data: inputData, status = "draft", authorId, primaryBylineId, locale, translationOf, inheritFields = [], publishedAt, createdAt } = input;
316
+ const data = await this.datetimes.normalizeInput(type, inputData);
317
+ const normalizedCreatedAt = createdAt ? await this.datetimes.normalizeValue(type, createdAt) : now;
318
+ const normalizedPublishedAt = publishedAt ? await this.datetimes.normalizeValue(type, publishedAt) : null;
319
+ if (!type) throw new EmDashValidationError("Content type is required");
320
+ const tableName = getTableName(type);
321
+ const columns = [
322
+ "id",
323
+ "slug",
324
+ "status",
325
+ "author_id",
326
+ "primary_byline_id",
327
+ "created_at",
328
+ "updated_at",
329
+ "published_at",
330
+ "version",
331
+ "locale",
332
+ "translation_group"
333
+ ];
334
+ const values = [
335
+ id,
336
+ slug || null,
337
+ status,
338
+ authorId || null,
339
+ primaryBylineId ?? null,
340
+ normalizedCreatedAt,
341
+ now,
342
+ normalizedPublishedAt,
343
+ 1,
344
+ locale || "en",
345
+ id
346
+ ];
347
+ const inherited = new Set(inheritFields);
348
+ for (const field of inherited) {
349
+ validateIdentifier(field, "inherited content field name");
350
+ if (!SYSTEM_COLUMNS.has(field) && !Object.hasOwn(data, field)) {
351
+ columns.push(field);
352
+ values.push(null);
353
+ }
354
+ }
355
+ if (data && typeof data === "object") {
356
+ for (const [key, value] of Object.entries(data)) if (!SYSTEM_COLUMNS.has(key)) {
357
+ validateIdentifier(key, "content field name");
358
+ columns.push(key);
359
+ values.push(serializeValue(value));
360
+ }
361
+ }
362
+ const columnRefs = columns.map((c) => sql.ref(c));
363
+ const valuePlaceholders = values.map((value, index) => {
364
+ const column = columns[index];
365
+ if (translationOf && column === "translation_group") return sql`COALESCE(${sql.ref("translation_source.translation_group")}, ${sql.ref("translation_source.id")})`;
366
+ if (translationOf && inherited.has(column)) return sql.ref(`translation_source.${column}`);
367
+ return value === null ? sql`NULL` : sql`${value}`;
368
+ });
369
+ if (translationOf) await sql`
370
+ INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
371
+ SELECT ${sql.join(valuePlaceholders, sql`, `)}
372
+ FROM ${sql.ref(tableName)} AS translation_source
373
+ WHERE translation_source.id = ${translationOf}
374
+ AND translation_source.deleted_at IS NULL
375
+ `.execute(this.db);
376
+ else await sql`
377
+ INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
378
+ VALUES (${sql.join(valuePlaceholders, sql`, `)})
379
+ `.execute(this.db);
380
+ invalidateCollectionCache(type);
381
+ const item = await this.findById(type, id);
382
+ if (!item) {
383
+ if (translationOf) throw new EmDashValidationError("Translation source content not found");
384
+ throw new Error("Failed to create content");
385
+ }
386
+ return item;
387
+ }
388
+ /**
389
+ * Generate a unique slug for a content item within a collection.
390
+ *
391
+ * Checks the collection table for existing slugs that match `baseSlug`
392
+ * (optionally scoped to a locale) and appends a numeric suffix (`-1`,
393
+ * `-2`, etc.) on collision to guarantee uniqueness.
394
+ *
395
+ * Returns null when slug normalization cannot produce a value.
396
+ */
397
+ async generateUniqueSlug(type, text, locale) {
398
+ const baseSlug = slugify(text);
399
+ if (!baseSlug) return null;
400
+ const tableName = getTableName(type);
401
+ if ((locale ? await sql`
402
+ SELECT slug FROM ${sql.ref(tableName)}
403
+ WHERE slug = ${baseSlug}
404
+ AND locale = ${locale}
405
+ LIMIT 1
406
+ `.execute(this.db) : await sql`
407
+ SELECT slug FROM ${sql.ref(tableName)}
408
+ WHERE slug = ${baseSlug}
409
+ LIMIT 1
410
+ `.execute(this.db)).rows.length === 0) return baseSlug;
411
+ const pattern = `${baseSlug}-%`;
412
+ const candidates = locale ? await sql`
413
+ SELECT slug FROM ${sql.ref(tableName)}
414
+ WHERE (slug = ${baseSlug} OR slug LIKE ${pattern})
415
+ AND locale = ${locale}
416
+ `.execute(this.db) : await sql`
417
+ SELECT slug FROM ${sql.ref(tableName)}
418
+ WHERE slug = ${baseSlug} OR slug LIKE ${pattern}
419
+ `.execute(this.db);
420
+ let maxSuffix = 0;
421
+ const suffixPattern = new RegExp(`^${escapeRegExp(baseSlug)}-(\\d+)$`);
422
+ for (const row of candidates.rows) {
423
+ const match = suffixPattern.exec(row.slug);
424
+ if (match) {
425
+ const n = parseInt(match[1], 10);
426
+ if (n > maxSuffix) maxSuffix = n;
427
+ }
428
+ }
429
+ return `${baseSlug}-${maxSuffix + 1}`;
430
+ }
431
+ /**
432
+ * Duplicate a content item
433
+ * Creates a new draft copy with "(Copy)" appended to the title.
434
+ * A slug is auto-generated from the new title by the handler layer.
435
+ */
436
+ async duplicate(type, id, authorId) {
437
+ const original = await this.findById(type, id);
438
+ if (!original) throw new EmDashValidationError("Content item not found");
439
+ const newData = { ...original.data };
440
+ if (typeof newData.title === "string") newData.title = `${newData.title} (Copy)`;
441
+ else if (typeof newData.name === "string") newData.name = `${newData.name} (Copy)`;
442
+ const slugSource = typeof newData.title === "string" ? newData.title : typeof newData.name === "string" ? newData.name : null;
443
+ const slug = slugSource ? await this.generateUniqueSlug(type, slugSource, original.locale ?? void 0) : null;
444
+ return this.create({
445
+ type,
446
+ slug,
447
+ data: newData,
448
+ status: "draft",
449
+ authorId: authorId || original.authorId || void 0,
450
+ locale: original.locale ?? void 0
451
+ });
452
+ }
453
+ /**
454
+ * Find content by ID
455
+ */
456
+ async findById(type, id) {
457
+ const tableName = getTableName(type);
458
+ const row = (await sql`
459
+ SELECT * FROM ${sql.ref(tableName)}
460
+ WHERE id = ${id}
461
+ AND deleted_at IS NULL
462
+ `.execute(this.db)).rows[0];
463
+ if (!row) return null;
464
+ return this.mapRow(type, row);
465
+ }
466
+ async findManyByIds(type, ids, options = {}) {
467
+ const items = /* @__PURE__ */ new Map();
468
+ if (ids.length === 0) return items;
469
+ const tableName = getTableName(type);
470
+ const deletedFilter = options.includeTrashed ? sql`` : sql`AND deleted_at IS NULL`;
471
+ for (const batch of chunks([...new Set(ids)], SQL_BATCH_SIZE)) {
472
+ const result = await sql`
473
+ SELECT * FROM ${sql.ref(tableName)}
474
+ WHERE id IN (${sql.join(batch)}) ${deletedFilter}
475
+ `.execute(this.db);
476
+ for (const row of result.rows) {
477
+ const item = this.mapRow(type, row);
478
+ items.set(item.id, item);
479
+ }
480
+ }
481
+ return items;
482
+ }
483
+ async findManyBySlugsInLocale(type, slugs, locale, options = {}) {
484
+ const items = /* @__PURE__ */ new Map();
485
+ if (slugs.length === 0) return items;
486
+ const tableName = getTableName(type);
487
+ const deletedFilter = options.includeTrashed ? sql`` : sql`AND deleted_at IS NULL`;
488
+ for (const batch of chunks([...new Set(slugs)], SQL_BATCH_SIZE)) {
489
+ const result = await sql`
490
+ SELECT * FROM ${sql.ref(tableName)}
491
+ WHERE slug IN (${sql.join(batch)}) AND locale = ${locale} ${deletedFilter}
492
+ `.execute(this.db);
493
+ for (const row of result.rows) {
494
+ const item = this.mapRow(type, row);
495
+ if (item.slug !== null) items.set(item.slug, item);
496
+ }
497
+ }
498
+ return items;
499
+ }
500
+ /**
501
+ * Find content by id, including trashed (soft-deleted) items.
502
+ * Used by restore endpoint for ownership checks.
503
+ *
504
+ * `deletedAt` rides along because the row is already in hand: a caller that
505
+ * has to know whether the row is trashed before touching anything else would
506
+ * otherwise pay a second read for a column this row already carries.
507
+ */
508
+ async findByIdIncludingTrashed(type, id) {
509
+ const tableName = getTableName(type);
510
+ const row = (await sql`
511
+ SELECT * FROM ${sql.ref(tableName)}
512
+ WHERE id = ${id}
513
+ `.execute(this.db)).rows[0];
514
+ if (!row) return null;
515
+ return {
516
+ ...this.mapRow(type, row),
517
+ deletedAt: typeof row.deleted_at === "string" ? row.deleted_at : null
518
+ };
519
+ }
520
+ /**
521
+ * Find content by ID or slug. Tries ID first if it looks like a ULID,
522
+ * otherwise tries slug. Falls back to the other if the first lookup misses.
523
+ */
524
+ async findByIdOrSlug(type, identifier, locale) {
525
+ return this._findByIdOrSlug(type, identifier, false, locale);
526
+ }
527
+ /**
528
+ * Find content by ID or slug, including trashed (soft-deleted) items.
529
+ * Used by restore/permanent-delete endpoints.
530
+ */
531
+ async findByIdOrSlugIncludingTrashed(type, identifier, locale) {
532
+ return this._findByIdOrSlug(type, identifier, true, locale);
533
+ }
534
+ async isTrashed(type, id) {
535
+ const tableName = getTableName(type);
536
+ return await this.db.selectFrom(tableName).select("id").where("id", "=", id).where("deleted_at", "is not", null).executeTakeFirst() !== void 0;
537
+ }
538
+ async _findByIdOrSlug(type, identifier, includeTrashed, locale) {
539
+ const looksLikeUlid = ULID_PATTERN.test(identifier);
540
+ const findById = includeTrashed ? (t, id) => this.findByIdIncludingTrashed(t, id) : (t, id) => this.findById(t, id);
541
+ const findBySlug = includeTrashed ? (t, s) => this.findBySlugIncludingTrashed(t, s, locale) : (t, s) => this.findBySlug(t, s, locale);
542
+ try {
543
+ if (looksLikeUlid) {
544
+ const byId = await findById(type, identifier);
545
+ if (byId) return byId;
546
+ return await findBySlug(type, identifier);
547
+ }
548
+ const bySlug = await findBySlug(type, identifier);
549
+ if (bySlug) return bySlug;
550
+ return await findById(type, identifier);
551
+ } catch (error) {
552
+ if (isMissingTableError(error)) return null;
553
+ throw error;
554
+ }
555
+ }
556
+ /**
557
+ * Find content by slug
558
+ */
559
+ async findBySlug(type, slug, locale) {
560
+ const tableName = getTableName(type);
561
+ const row = (locale ? await sql`
562
+ SELECT * FROM ${sql.ref(tableName)}
563
+ WHERE slug = ${slug}
564
+ AND locale = ${locale}
565
+ AND deleted_at IS NULL
566
+ `.execute(this.db) : await sql`
567
+ SELECT * FROM ${sql.ref(tableName)}
568
+ WHERE slug = ${slug}
569
+ AND deleted_at IS NULL
570
+ ORDER BY locale ASC
571
+ LIMIT 1
572
+ `.execute(this.db)).rows[0];
573
+ if (!row) return null;
574
+ return this.mapRow(type, row);
575
+ }
576
+ /**
577
+ * Find content by slug, including trashed (soft-deleted) items.
578
+ * Used by restore/permanent-delete endpoints.
579
+ */
580
+ async findBySlugIncludingTrashed(type, slug, locale) {
581
+ const tableName = getTableName(type);
582
+ const row = (locale ? await sql`
583
+ SELECT * FROM ${sql.ref(tableName)}
584
+ WHERE slug = ${slug}
585
+ AND locale = ${locale}
586
+ `.execute(this.db) : await sql`
587
+ SELECT * FROM ${sql.ref(tableName)}
588
+ WHERE slug = ${slug}
589
+ ORDER BY locale ASC
590
+ LIMIT 1
591
+ `.execute(this.db)).rows[0];
592
+ if (!row) return null;
593
+ return this.mapRow(type, row);
594
+ }
595
+ /**
596
+ * Find many content items with filtering and pagination
597
+ */
598
+ async findMany(type, options = {}) {
599
+ const tableName = getTableName(type);
600
+ const limit = Math.max(1, Math.min(options.limit || 50, 100));
601
+ assertPageOffset(options.offset, options.cursor);
602
+ const orderField = options.orderBy?.field || "createdAt";
603
+ const orderDirection = options.orderBy?.direction || "desc";
604
+ const resolvedOrderField = await this.resolveOrderField(type, orderField, options.sortableExtras);
605
+ const dbField = resolvedOrderField.column;
606
+ const nullableOrder = resolvedOrderField.indexedCustomField || !NON_NULL_ORDER_COLUMNS.has(dbField);
607
+ const resolvedFieldFilters = await this.resolveFieldFilters(type, options.where?.fieldFilters);
608
+ const safeOrderDirection = orderDirection.toLowerCase() === "asc" ? "ASC" : "DESC";
609
+ let query = this.db.selectFrom(tableName).selectAll().where("deleted_at", "is", null);
610
+ if (options.where?.status) query = query.where("status", "=", options.where.status);
611
+ if (options.where?.authorId) query = query.where("author_id", "=", options.where.authorId);
612
+ if (options.where?.locale) query = query.where("locale", "=", options.where.locale);
613
+ query = this.applySearchFilter(query, options.where, type);
614
+ query = this.applyDateFilter(query, options.where);
615
+ query = this.applyBylineFilter(query, options.where, type);
616
+ query = this.applyFieldFilters(query, resolvedFieldFilters);
617
+ if (options.cursor) if (resolvedOrderField.indexedCustomField) {
618
+ const { value, id: cursorId } = decodeNullableOrderCursor(options.cursor, orderField);
619
+ const isPresent = sql`${sql.ref(dbField)} IS NOT NULL`;
620
+ const falseLiteral = sql`FALSE`;
621
+ const trueLiteral = sql`TRUE`;
622
+ if (safeOrderDirection === "ASC" && value === null) query = query.where(sql`(
623
+ (${isPresent}) > ${falseLiteral}
624
+ OR ((${isPresent}) = ${falseLiteral} AND ${sql.ref("id")} > ${cursorId})
625
+ )`);
626
+ else if (safeOrderDirection === "DESC" && value === null) query = query.where(sql`
627
+ (${isPresent}) = ${falseLiteral} AND ${sql.ref("id")} < ${cursorId}
628
+ `);
629
+ else if (safeOrderDirection === "ASC") query = query.where(sql`
630
+ (${isPresent}, ${sql.ref(dbField)}, ${sql.ref("id")})
631
+ > (${trueLiteral}, ${value}, ${cursorId})
632
+ `);
633
+ else query = query.where(sql`
634
+ (${isPresent}, ${sql.ref(dbField)}, ${sql.ref("id")})
635
+ < (${trueLiteral}, ${value}, ${cursorId})
636
+ `);
637
+ } else if (nullableOrder) {
638
+ const { value, id: cursorId } = decodeNullableOrderCursor(options.cursor, orderField, { acceptPlain: true });
639
+ query = query.where(nullableOrderCondition(this.db, dbField, safeOrderDirection, value, cursorId));
640
+ } else {
641
+ const { orderValue, id: cursorId } = decodeCursor(options.cursor);
642
+ if (safeOrderDirection === "DESC") query = query.where((eb) => eb.or([eb(dbField, "<", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", "<", cursorId)])]));
643
+ else query = query.where((eb) => eb.or([eb(dbField, ">", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", ">", cursorId)])]));
644
+ }
645
+ const indexedOrderFilter = resolvedOrderField.indexedCustomField ? resolvedFieldFilters.find((filter) => filter.column === dbField) : void 0;
646
+ if (resolvedOrderField.indexedCustomField && !indexedOrderFilter) query = query.orderBy(sql`${sql.ref(dbField)} IS NOT NULL`, safeOrderDirection === "ASC" ? "asc" : "desc");
647
+ if (indexedOrderFilter?.kind !== "null") query = query.orderBy(dbField, safeOrderDirection === "ASC" ? "asc" : "desc");
648
+ query = query.orderBy("id", safeOrderDirection === "ASC" ? "asc" : "desc");
649
+ query = options.offset === void 0 ? query.limit(limit + 1) : query.limit(limit).offset(options.offset);
650
+ const [rowsResult, countResult] = await Promise.allSettled([query.execute(), this.countWithResolvedFilters(type, options.where, resolvedFieldFilters)]);
651
+ if (rowsResult.status === "rejected") throw rowsResult.reason;
652
+ if (countResult.status === "rejected") throw countResult.reason;
653
+ const rows = rowsResult.value;
654
+ const total = countResult.value;
655
+ const hasMore = rows.length > limit;
656
+ const items = rows.slice(0, limit);
657
+ const mappedResult = {
658
+ items: items.map((row) => this.mapRow(type, row)),
659
+ total
660
+ };
661
+ if (hasMore && items.length > 0) {
662
+ const lastRow = items.at(-1);
663
+ const lastOrderValue = lastRow[dbField];
664
+ if (nullableOrder) {
665
+ if (lastOrderValue !== null && typeof lastOrderValue !== "string" && typeof lastOrderValue !== "number") throw new EmDashValidationError(`Invalid value for order field: ${orderField}`);
666
+ mappedResult.nextCursor = encodeNullableOrderCursor(orderField, lastOrderValue, String(lastRow.id));
667
+ } else mappedResult.nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
668
+ }
669
+ return mappedResult;
670
+ }
671
+ /**
672
+ * Update content
673
+ */
674
+ async update(type, id, input) {
675
+ const tableName = getTableName(type);
676
+ const now = (/* @__PURE__ */ new Date()).toISOString();
677
+ const updates = {};
678
+ if (input.status !== void 0) updates.status = input.status;
679
+ if (input.slug !== void 0) updates.slug = input.slug;
680
+ if (input.publishedAt !== void 0) updates.published_at = input.publishedAt === null ? null : await this.datetimes.normalizeValue(type, input.publishedAt);
681
+ if (input.scheduledAt !== void 0) updates.scheduled_at = input.scheduledAt === null ? null : await this.datetimes.normalizeValue(type, input.scheduledAt);
682
+ if (input.authorId !== void 0) updates.author_id = input.authorId;
683
+ if (input.primaryBylineId !== void 0) updates.primary_byline_id = input.primaryBylineId;
684
+ if (input.data !== void 0 && typeof input.data === "object") {
685
+ const data = await this.datetimes.normalizeInput(type, writableContentData(input.data));
686
+ for (const [key, value] of Object.entries(data)) updates[key] = serializeValue(value);
687
+ }
688
+ const hasColumnWrites = Object.keys(updates).length > 0;
689
+ if (hasColumnWrites) updates.updated_at = now;
690
+ updates.version = sql`version + 1`;
691
+ await this.db.updateTable(tableName).set(updates).where("id", "=", id).where("deleted_at", "is", null).execute();
692
+ if (hasColumnWrites) invalidateCollectionCache(type);
693
+ const updated = await this.findById(type, id);
694
+ if (!updated) throw new Error("Content not found");
695
+ return updated;
696
+ }
697
+ async restoreRevision(type, id, revisionData, authorId) {
698
+ const tableName = getTableName(type);
699
+ const existing = await this.findById(type, id);
700
+ if (!existing) throw new EmDashValidationError("Content item not found");
701
+ const normalizedSnapshot = await this.datetimes.normalizeData(type, revisionData);
702
+ const { _slug } = normalizedSnapshot;
703
+ const snapshotFields = {};
704
+ for (const [key, value] of Object.entries(normalizedSnapshot)) if (!key.startsWith("_")) snapshotFields[key] = value;
705
+ const fieldData = writableContentData(snapshotFields);
706
+ const revisionId = createRevisionId();
707
+ const now = (/* @__PURE__ */ new Date()).toISOString();
708
+ const assignments = [];
709
+ if (typeof _slug === "string") assignments.push(sql`slug = ${_slug}`);
710
+ for (const [field, value] of Object.entries(fieldData)) {
711
+ validateIdentifier(field, "content field name");
712
+ assignments.push(sql`${sql.ref(field)} = ${serializeValue(value)}`);
713
+ }
714
+ assignments.push(sql`draft_revision_id = ${revisionId}`, sql`updated_at = ${now}`, sql`version = version + 1`);
715
+ const buildQueries = () => {
716
+ return [
717
+ sql`
718
+ INSERT INTO revisions (id, collection, entry_id, data, author_id)
719
+ VALUES (${revisionId}, ${type}, ${id}, ${JSON.stringify(normalizedSnapshot)}, ${authorId})
720
+ RETURNING id
721
+ `,
722
+ sql`
723
+ UPDATE ${sql.ref(tableName)}
724
+ SET ${sql.join(assignments, sql`, `)}
725
+ WHERE id = ${id}
726
+ AND deleted_at IS NULL
727
+ AND version = ${existing.version}
728
+ AND updated_at = ${existing.updatedAt}
729
+ AND status = ${existing.status}
730
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
731
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
732
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
733
+ RETURNING id
734
+ `,
735
+ sql`
736
+ DELETE FROM revisions
737
+ WHERE id = ${revisionId}
738
+ AND NOT EXISTS (
739
+ SELECT 1 FROM ${sql.ref(tableName)}
740
+ WHERE id = ${id}
741
+ AND draft_revision_id = ${revisionId}
742
+ AND version = ${existing.version + 1}
743
+ )
744
+ `,
745
+ sql`
746
+ UPDATE ${sql.ref(tableName)}
747
+ SET draft_revision_id = ${existing.draftRevisionId}
748
+ WHERE id = ${id}
749
+ AND draft_revision_id = ${revisionId}
750
+ AND version = ${existing.version + 1}
751
+ RETURNING id
752
+ `
753
+ ];
754
+ };
755
+ const batched = await executeAtomicBatchIfSupported(this.db, buildQueries());
756
+ if (batched) {
757
+ if (batched[0]?.rows.length !== 1 || batched[1]?.rows.length !== 1 || batched[3]?.rows.length !== 1) throw new ContentMutationConflictError();
758
+ } else await withTransaction(this.db, async (trx) => {
759
+ const [audit, update, removeUnappliedAudit, releaseMarker] = buildQueries();
760
+ if ((await audit.execute(trx)).rows.length !== 1) throw new ContentMutationConflictError();
761
+ const updateResult = await update.execute(trx);
762
+ await removeUnappliedAudit.execute(trx);
763
+ const releaseResult = await releaseMarker.execute(trx);
764
+ if (updateResult.rows.length !== 1 || releaseResult.rows.length !== 1) throw new ContentMutationConflictError();
765
+ });
766
+ invalidateCollectionCache(type);
767
+ const item = await this.findById(type, id);
768
+ if (!item) throw new Error("Content not found");
769
+ await new RevisionRepository(this.db, this.datetimeContexts).queuePruning(type, id, revisionId);
770
+ return {
771
+ item,
772
+ revisionId
773
+ };
774
+ }
775
+ async restoreDraftRevision(type, id, revisionData, authorId) {
776
+ const tableName = getTableName(type);
777
+ const existing = await this.findById(type, id);
778
+ if (!existing) return null;
779
+ const normalizedSnapshot = await this.datetimes.normalizeData(type, revisionData);
780
+ const revisionId = createRevisionId();
781
+ const buildQueries = () => {
782
+ return [
783
+ sql`
784
+ INSERT INTO revisions (id, collection, entry_id, data, author_id)
785
+ VALUES (${revisionId}, ${type}, ${id}, ${JSON.stringify(normalizedSnapshot)}, ${authorId})
786
+ RETURNING id
787
+ `,
788
+ sql`
789
+ UPDATE ${sql.ref(tableName)}
790
+ SET draft_revision_id = ${revisionId},
791
+ version = version + 1
792
+ WHERE id = ${id}
793
+ AND deleted_at IS NULL
794
+ AND version = ${existing.version}
795
+ AND updated_at = ${existing.updatedAt}
796
+ AND status = ${existing.status}
797
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
798
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
799
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
800
+ RETURNING id
801
+ `,
802
+ sql`
803
+ DELETE FROM revisions
804
+ WHERE id = ${revisionId}
805
+ AND NOT EXISTS (
806
+ SELECT 1 FROM ${sql.ref(tableName)}
807
+ WHERE id = ${id}
808
+ AND draft_revision_id = ${revisionId}
809
+ AND version = ${existing.version + 1}
810
+ )
811
+ `
812
+ ];
813
+ };
814
+ const batched = await executeAtomicBatchIfSupported(this.db, buildQueries());
815
+ if (batched) {
816
+ if (batched[0]?.rows.length !== 1 || batched[1]?.rows.length !== 1) throw new ContentMutationConflictError();
817
+ } else await withTransaction(this.db, async (trx) => {
818
+ const [audit, stage, removeUnstagedAudit] = buildQueries();
819
+ if ((await audit.execute(trx)).rows.length !== 1) throw new ContentMutationConflictError();
820
+ const stageResult = await stage.execute(trx);
821
+ await removeUnstagedAudit.execute(trx);
822
+ if (stageResult.rows.length !== 1) throw new ContentMutationConflictError();
823
+ });
824
+ invalidateCollectionCache(type);
825
+ await new RevisionRepository(this.db, this.datetimeContexts).queuePruning(type, id, revisionId);
826
+ return revisionId;
827
+ }
828
+ /**
829
+ * Update plugin-authored fields without letting content columns diverge
830
+ * from the revision pointers that publication promotes.
831
+ */
832
+ async updateDraftAware(type, id, input) {
833
+ const data = input.data ? await this.datetimes.normalizeInput(type, writableContentData(input.data)) : {};
834
+ const stagedSlug = typeof input.slug === "string" ? input.slug : void 0;
835
+ if (!(Object.keys(data).length > 0 || stagedSlug !== void 0)) return this.update(type, id, {
836
+ ...input,
837
+ data
838
+ });
839
+ 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();
840
+ const supportsRaw = collectionRows[0]?.supports;
841
+ const supports = supportsRaw ? JSON.parse(supportsRaw) : [];
842
+ if (!Array.isArray(supports) || !supports.includes("revisions")) return this.update(type, id, {
843
+ ...input,
844
+ data
845
+ });
846
+ const fieldSlugs = new Set(collectionRows.map((row) => row.fieldSlug).filter((slug) => Boolean(slug)));
847
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
848
+ let existing = await this.findById(type, id);
849
+ let incoming = data;
850
+ if (existing) {
851
+ let stored = existing.data ?? {};
852
+ if (existing.draftRevisionId) {
853
+ const draft = await revisionRepo.findById(existing.draftRevisionId);
854
+ if (draft?.data) stored = draft.data;
855
+ }
856
+ const stale = staleStoredKeys(data, stored, fieldSlugs);
857
+ if (stale.length > 0) {
858
+ incoming = { ...data };
859
+ for (const key of stale) delete incoming[key];
860
+ }
861
+ }
862
+ for (const field of Object.keys(incoming)) if (!fieldSlugs.has(field)) throw new EmDashValidationError(`Unknown field '${field}' in collection '${type}'`);
863
+ for (let attempt = 0; existing && attempt < MAX_DRAFT_STAGE_ATTEMPTS; attempt++) {
864
+ let baseData = existing.data;
865
+ if (existing.draftRevisionId) {
866
+ const draft = await revisionRepo.findById(existing.draftRevisionId);
867
+ if (draft) baseData = draft.data;
868
+ }
869
+ const mergedData = keepKnownFields({
870
+ ...baseData,
871
+ ...incoming
872
+ }, fieldSlugs);
873
+ if (stagedSlug !== void 0) mergedData._slug = stagedSlug;
874
+ const revision = await revisionRepo.create({
875
+ collection: type,
876
+ entryId: id,
877
+ data: mergedData,
878
+ ...input.revisionAuthorId ? { authorId: input.revisionAuthorId } : {}
879
+ });
880
+ let staged;
881
+ try {
882
+ staged = await this.replaceDraftRevisionForUpdate(type, id, revision.id, existing, input);
883
+ } catch (error) {
884
+ await this.deleteUnstagedRevision(revisionRepo, type, id, revision.id);
885
+ throw error;
886
+ }
887
+ if (staged) {
888
+ const updated = await this.findById(type, id);
889
+ if (!updated) throw new Error("Content not found");
890
+ const draftData = {};
891
+ for (const [key, value] of Object.entries(mergedData)) if (!key.startsWith("_")) draftData[key] = value;
892
+ return {
893
+ ...updated,
894
+ data: {
895
+ ...updated.data,
896
+ ...draftData
897
+ }
898
+ };
899
+ }
900
+ await this.deleteUnstagedRevision(revisionRepo, type, id, revision.id);
901
+ existing = await this.findById(type, id);
902
+ }
903
+ if (!existing) throw new Error("Content not found");
904
+ throw new ContentMutationConflictError();
905
+ }
906
+ async deleteUnstagedRevision(revisionRepo, type, id, revisionId) {
907
+ try {
908
+ await revisionRepo.deleteIfUnreferenced(type, id, revisionId);
909
+ } catch (error) {
910
+ console.error(`[content] Failed to clean up unstaged revision ${revisionId}:`, error);
911
+ }
912
+ }
913
+ async replaceDraftRevisionForUpdate(type, id, revisionId, expected, input) {
914
+ const tableName = getTableName(type);
915
+ const assignments = [sql`draft_revision_id = ${revisionId}`];
916
+ let liveMetadataChanged = false;
917
+ if (input.status !== void 0) {
918
+ assignments.push(sql`status = ${input.status}`);
919
+ liveMetadataChanged = true;
920
+ }
921
+ if (input.slug === null) {
922
+ assignments.push(sql`slug = NULL`);
923
+ liveMetadataChanged = true;
924
+ }
925
+ if (input.publishedAt !== void 0) {
926
+ const publishedAt = input.publishedAt === null ? null : await this.datetimes.normalizeValue(type, input.publishedAt);
927
+ assignments.push(sql`published_at = ${publishedAt}`);
928
+ liveMetadataChanged = true;
929
+ }
930
+ if (input.scheduledAt !== void 0) {
931
+ const scheduledAt = input.scheduledAt === null ? null : await this.datetimes.normalizeValue(type, input.scheduledAt);
932
+ assignments.push(sql`scheduled_at = ${scheduledAt}`);
933
+ liveMetadataChanged = true;
934
+ }
935
+ if (input.authorId !== void 0) {
936
+ assignments.push(sql`author_id = ${input.authorId}`);
937
+ liveMetadataChanged = true;
938
+ }
939
+ if (input.primaryBylineId !== void 0) {
940
+ assignments.push(sql`primary_byline_id = ${input.primaryBylineId}`);
941
+ liveMetadataChanged = true;
942
+ }
943
+ if (liveMetadataChanged) assignments.push(sql`updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}`);
944
+ assignments.push(sql`version = version + 1`);
945
+ const changed = ((await sql`
946
+ UPDATE ${sql.ref(tableName)}
947
+ SET ${sql.join(assignments, sql`, `)}
948
+ WHERE id = ${id}
949
+ AND deleted_at IS NULL
950
+ AND version = ${expected.version}
951
+ AND ${nullableColumnMatch("live_revision_id", expected.liveRevisionId)}
952
+ AND ${nullableColumnMatch("draft_revision_id", expected.draftRevisionId)}
953
+ AND EXISTS (
954
+ SELECT 1 FROM revisions
955
+ WHERE revisions.id = ${revisionId}
956
+ AND revisions.collection = ${type}
957
+ AND revisions.entry_id = ${id}
958
+ )
959
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
960
+ if (changed && liveMetadataChanged) invalidateCollectionCache(type);
961
+ return changed;
962
+ }
963
+ /**
964
+ * Copy non-translatable field values to every other entry in the
965
+ * translation group, trashed entries included.
966
+ *
967
+ * Only the fields present in `data` are copied. With `previous`, `data` is
968
+ * the entry's complete new state and only the fields whose value differs
969
+ * from `previous` are copied, an absent field as null. An entry that already
970
+ * holds every copied value is left untouched, so its `updated_at` does not
971
+ * move.
972
+ *
973
+ * On collections with revisions a changed entry also gets a new live
974
+ * revision, because republishing and unpublishing read that revision rather
975
+ * than the columns. A pending draft takes a value only where it still holds
976
+ * the entry's previous value, so an unpublished edit to the field survives.
977
+ */
978
+ async syncNonTranslatableFields(type, sourceId, translationGroup, data, options = {}) {
979
+ const tableName = getTableName(type);
980
+ 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();
981
+ const { previous } = options;
982
+ const values = {};
983
+ for (const { fieldSlug } of collectionRows) {
984
+ if (!fieldSlug) continue;
985
+ if (previous) {
986
+ if (!sameStoredValue(previous[fieldSlug], data[fieldSlug])) values[fieldSlug] = data[fieldSlug] ?? null;
987
+ } else if (fieldSlug in data) values[fieldSlug] = data[fieldSlug];
988
+ }
989
+ if (Object.keys(values).length === 0) return;
990
+ const normalizedValues = await this.datetimes.normalizeData(type, values);
991
+ const supportsRaw = collectionRows[0]?.supports;
992
+ const supports = supportsRaw ? JSON.parse(supportsRaw) : [];
993
+ const usesRevisions = Array.isArray(supports) && supports.includes("revisions");
994
+ const siblings = await sql`
995
+ SELECT * FROM ${sql.ref(tableName)}
996
+ WHERE translation_group = ${translationGroup}
997
+ AND id != ${sourceId}
998
+ `.execute(this.db);
999
+ let changed = false;
1000
+ for (const row of siblings.rows) if (await this.syncSiblingValues(type, this.mapRow(type, row), normalizedValues, usesRevisions)) changed = true;
1001
+ if (changed) invalidateCollectionCache(type);
1002
+ }
1003
+ async syncSiblingValues(type, initial, values, usesRevisions) {
1004
+ const tableName = getTableName(type);
1005
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1006
+ let sibling = initial;
1007
+ for (let attempt = 0; sibling && attempt < MAX_DRAFT_STAGE_ATTEMPTS; attempt++) {
1008
+ const current = sibling;
1009
+ const changed = {};
1010
+ for (const [field, value] of Object.entries(values)) if (!sameStoredValue(current.data[field], value)) changed[field] = value;
1011
+ if (Object.keys(changed).length === 0) return false;
1012
+ const assignments = [];
1013
+ for (const [field, value] of Object.entries(changed)) {
1014
+ validateIdentifier(field, "content field name");
1015
+ assignments.push(sql`${sql.ref(field)} = ${serializeValue(value)}`);
1016
+ }
1017
+ const createdRevisionIds = [];
1018
+ const cleanUp = async () => {
1019
+ for (const revisionId of createdRevisionIds) await this.deleteUnstagedRevision(revisionRepo, type, current.id, revisionId);
1020
+ };
1021
+ let synced;
1022
+ try {
1023
+ const live = usesRevisions && current.liveRevisionId ? await revisionRepo.findById(current.liveRevisionId) : null;
1024
+ if (live) {
1025
+ const revision = await revisionRepo.create({
1026
+ collection: type,
1027
+ entryId: current.id,
1028
+ data: {
1029
+ ...live.data,
1030
+ ...changed
1031
+ }
1032
+ });
1033
+ createdRevisionIds.push(revision.id);
1034
+ assignments.push(sql`live_revision_id = ${revision.id}`);
1035
+ }
1036
+ const draft = usesRevisions && current.draftRevisionId ? await revisionRepo.findById(current.draftRevisionId) : null;
1037
+ const carried = {};
1038
+ for (const [field, value] of Object.entries(changed)) if (draft && sameStoredValue(draft.data[field], current.data[field])) carried[field] = value;
1039
+ if (draft && Object.keys(carried).length > 0) {
1040
+ const revision = await revisionRepo.create({
1041
+ collection: type,
1042
+ entryId: current.id,
1043
+ data: {
1044
+ ...draft.data,
1045
+ ...carried
1046
+ }
1047
+ });
1048
+ createdRevisionIds.push(revision.id);
1049
+ assignments.push(sql`draft_revision_id = ${revision.id}`);
1050
+ }
1051
+ assignments.push(sql`updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}`, sql`version = version + 1`);
1052
+ synced = ((await sql`
1053
+ UPDATE ${sql.ref(tableName)}
1054
+ SET ${sql.join(assignments, sql`, `)}
1055
+ WHERE id = ${current.id}
1056
+ AND version = ${current.version}
1057
+ AND ${nullableColumnMatch("live_revision_id", current.liveRevisionId)}
1058
+ AND ${nullableColumnMatch("draft_revision_id", current.draftRevisionId)}
1059
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1060
+ } catch (error) {
1061
+ await cleanUp();
1062
+ throw error;
1063
+ }
1064
+ if (synced) return true;
1065
+ await cleanUp();
1066
+ sibling = await this.findByIdIncludingTrashed(type, current.id);
1067
+ }
1068
+ if (!sibling) return false;
1069
+ throw new ContentMutationConflictError();
1070
+ }
1071
+ /**
1072
+ * Delete content (soft delete - moves to trash)
1073
+ */
1074
+ async delete(type, id) {
1075
+ const tableName = getTableName(type);
1076
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1077
+ const changed = ((await sql`
1078
+ UPDATE ${sql.ref(tableName)}
1079
+ SET deleted_at = ${now}
1080
+ WHERE id = ${id}
1081
+ AND deleted_at IS NULL
1082
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1083
+ if (changed) invalidateCollectionCache(type);
1084
+ return changed;
1085
+ }
1086
+ /**
1087
+ * Restore content from trash
1088
+ *
1089
+ * The entry comes back as a draft with no schedule. The live version is not
1090
+ * copied into a draft revision: collections without revisions save to the
1091
+ * columns, and a draft revision would hide those saves.
1092
+ */
1093
+ async restore(type, id, expectedRevision) {
1094
+ const tableName = getTableName(type);
1095
+ const existing = await this.findByIdOrSlugIncludingTrashed(type, id);
1096
+ if (!existing) return null;
1097
+ assertRevisionPrecondition(existing, expectedRevision);
1098
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1099
+ const restored = (await sql`
1100
+ UPDATE ${sql.ref(tableName)}
1101
+ SET deleted_at = NULL,
1102
+ live_revision_id = NULL,
1103
+ status = 'draft',
1104
+ scheduled_at = NULL,
1105
+ updated_at = ${now},
1106
+ version = ${existing.version + 1}
1107
+ WHERE id = ${existing.id}
1108
+ AND deleted_at IS NOT NULL
1109
+ AND version = ${existing.version}
1110
+ AND updated_at = ${existing.updatedAt}
1111
+ RETURNING *
1112
+ `.execute(this.db)).rows[0];
1113
+ if (!restored) throw new ContentMutationConflictError("Content changed while restoring");
1114
+ invalidateCollectionCache(type);
1115
+ return this.mapRow(type, restored);
1116
+ }
1117
+ /**
1118
+ * Permanently delete content (cannot be undone)
1119
+ */
1120
+ /**
1121
+ * Permanently delete a soft-deleted content row.
1122
+ *
1123
+ * Returns `true` only when a soft-deleted (trashed) row was removed.
1124
+ * Returns `false` when no row exists OR when the row exists but is live —
1125
+ * the caller is responsible for distinguishing these cases (typically via
1126
+ * a follow-up `findByIdOrSlugIncludingTrashed` to surface NOT_FOUND vs
1127
+ * NOT_TRASHED). The `AND deleted_at IS NOT NULL` clause is the safety net
1128
+ * that prevents permanent delete from bypassing the trash workflow.
1129
+ */
1130
+ async permanentDelete(type, id) {
1131
+ const tableName = getTableName(type);
1132
+ const changed = ((await sql`
1133
+ DELETE FROM ${sql.ref(tableName)}
1134
+ WHERE id = ${id}
1135
+ AND deleted_at IS NOT NULL
1136
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1137
+ if (changed) invalidateCollectionCache(type);
1138
+ return changed;
1139
+ }
1140
+ /**
1141
+ * Find trashed content items
1142
+ */
1143
+ async findTrashed(type, options = {}) {
1144
+ const tableName = getTableName(type);
1145
+ const limit = Math.max(1, Math.min(options.limit || 50, 100));
1146
+ assertPageOffset(options.offset, options.cursor);
1147
+ const orderField = options.orderBy?.field || "deletedAt";
1148
+ const orderDirection = options.orderBy?.direction || "desc";
1149
+ const dbField = this.mapOrderField(orderField);
1150
+ const safeOrderDirection = orderDirection.toLowerCase() === "asc" ? "ASC" : "DESC";
1151
+ let query = this.db.selectFrom(tableName).selectAll().where("deleted_at", "is not", null);
1152
+ if (options.where?.locale) query = query.where("locale", "=", options.where.locale);
1153
+ if (options.cursor) {
1154
+ const { orderValue, id: cursorId } = decodeCursor(options.cursor);
1155
+ if (safeOrderDirection === "DESC") query = query.where((eb) => eb.or([eb(dbField, "<", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", "<", cursorId)])]));
1156
+ else query = query.where((eb) => eb.or([eb(dbField, ">", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", ">", cursorId)])]));
1157
+ }
1158
+ query = query.orderBy(dbField, safeOrderDirection === "ASC" ? "asc" : "desc").orderBy("id", safeOrderDirection === "ASC" ? "asc" : "desc");
1159
+ query = options.offset === void 0 ? query.limit(limit + 1) : query.limit(limit).offset(options.offset);
1160
+ const rows = await query.execute();
1161
+ const hasMore = rows.length > limit;
1162
+ const items = rows.slice(0, limit);
1163
+ const mappedResult = { items: items.map((row) => {
1164
+ const record = row;
1165
+ return {
1166
+ ...this.mapRow(type, record),
1167
+ deletedAt: typeof record.deleted_at === "string" ? record.deleted_at : ""
1168
+ };
1169
+ }) };
1170
+ if (hasMore && items.length > 0) {
1171
+ const lastRow = items.at(-1);
1172
+ const lastOrderValue = lastRow[dbField];
1173
+ mappedResult.nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
1174
+ }
1175
+ return mappedResult;
1176
+ }
1177
+ /**
1178
+ * Count trashed content items
1179
+ */
1180
+ async countTrashed(type, options = {}) {
1181
+ const tableName = getTableName(type);
1182
+ let query = this.db.selectFrom(tableName).select((eb) => eb.fn.count("id").as("count")).where("deleted_at", "is not", null);
1183
+ if (options.locale) query = query.where("locale", "=", options.locale);
1184
+ const result = await query.executeTakeFirst();
1185
+ return Number(result?.count || 0);
1186
+ }
1187
+ /**
1188
+ * Apply the optional `q` filter.
1189
+ *
1190
+ * When the handler sets `useFts` (collection has a healthy FTS5 index
1191
+ * covering the display columns; SQLite only), the filter is served from
1192
+ * the index: a token-prefix MATCH against `_emdash_fts_<slug>` OR'd with
1193
+ * an index-served `slug GLOB 'term*'` prefix (the slug is not in the FTS
1194
+ * index). Both sides are index-backed, so SQLite's OR optimization avoids
1195
+ * the full-table scan the LIKE fallback needs (#1517). The trade-off is
1196
+ * search semantics: token-prefix matching instead of arbitrary substring.
1197
+ *
1198
+ * Fallback (Postgres, search disabled, or no usable terms): case-
1199
+ * insensitive substring LIKE across the handler-resolved `searchColumns`
1200
+ * (OR'd). User input is treated literally (LIKE wildcards escaped) and
1201
+ * `lower()` is applied on both sides for SQLite/Postgres parity.
1202
+ */
1203
+ applySearchFilter(query, where, type) {
1204
+ const term = where?.q?.trim();
1205
+ const columns = where?.searchColumns;
1206
+ if (!term || !columns || columns.length === 0) return query;
1207
+ if (where.useFts) {
1208
+ const match = buildFtsPrefixMatch(term);
1209
+ if (match) {
1210
+ validateIdentifier(type, "collection slug");
1211
+ const ftsTable = `_emdash_fts_${type}`;
1212
+ const slugPrefix = buildSlugGlobPrefix(term);
1213
+ 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}`]));
1214
+ }
1215
+ }
1216
+ const pattern = `%${term.replace(LIKE_WILDCARD_RE, (c) => `\\${c}`)}%`;
1217
+ return query.where((eb) => eb.or(columns.map((col) => {
1218
+ validateIdentifier(col, "search column");
1219
+ return sql`lower(CAST(${sql.ref(col)} AS TEXT)) LIKE lower(${pattern}) ESCAPE '\\'`;
1220
+ })));
1221
+ }
1222
+ /**
1223
+ * Apply the optional inclusive date-range filter. The field is mapped
1224
+ * through `DATE_FILTER_COLUMNS` (a closed whitelist), and bounds compare
1225
+ * lexicographically against the stored ISO 8601 timestamps. A `publishedAt`
1226
+ * range naturally excludes never-published rows (their column is NULL).
1227
+ */
1228
+ applyDateFilter(query, where) {
1229
+ const filter = where?.dateFilter;
1230
+ if (!filter) return query;
1231
+ const column = DATE_FILTER_COLUMNS[filter.field];
1232
+ if (!column) throw new EmDashValidationError(`Invalid date filter field: ${filter.field}`);
1233
+ const { from, to } = filter;
1234
+ if (!from && !to) return query;
1235
+ let next = query;
1236
+ if (from) next = next.where((eb) => eb(column, ">=", from));
1237
+ if (to) next = next.where((eb) => eb(column, "<=", to));
1238
+ return next;
1239
+ }
1240
+ /**
1241
+ * Apply the optional byline filter as a correlated (NOT) EXISTS against
1242
+ * `_emdash_content_bylines`.
1243
+ *
1244
+ * Correlating from the content table preserves the outer sort index so
1245
+ * `LIMIT` can short-circuit. `mode: "none"` tests the junction rather than
1246
+ * `primary_byline_id` because the two are written in the same call but
1247
+ * are not atomically consistent, so the junction is authoritative.
1248
+ *
1249
+ * Whether a credit *renders* is locale-scoped; whether one *exists* is
1250
+ * not. Both are needed: the first decides what the filter matches, the
1251
+ * second decides whether the author fallback applies at all.
1252
+ */
1253
+ applyBylineFilter(query, where, type) {
1254
+ const filter = where?.bylineFilter;
1255
+ if (!filter) return query;
1256
+ const tableName = getTableName(type);
1257
+ const idColumn = `${tableName}.id`;
1258
+ const authorColumn = `${tableName}.author_id`;
1259
+ const localeColumn = `${tableName}.locale`;
1260
+ const creditRenders = (eb, bylineIds) => {
1261
+ 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);
1262
+ sub = filter.locale ? sub.where("b.locale", "=", filter.locale) : sub.whereRef("b.locale", "=", localeColumn);
1263
+ if (bylineIds) sub = sub.where("cb.byline_id", "in", bylineIds);
1264
+ return eb.exists(sub);
1265
+ };
1266
+ 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));
1267
+ const authorHasByline = (eb, bylineIds) => {
1268
+ let sub = eb.selectFrom("_emdash_bylines as b").select("b.id").whereRef("b.user_id", "=", authorColumn);
1269
+ sub = filter.locale ? sub.where("b.locale", "=", filter.locale) : sub.whereRef("b.locale", "=", localeColumn);
1270
+ if (bylineIds) sub = sub.where("b.translation_group", "in", bylineIds);
1271
+ return eb.exists(sub);
1272
+ };
1273
+ if (filter.mode === "none") return query.where((eb) => {
1274
+ const uncredited = eb.not(creditRenders(eb));
1275
+ return filter.includeInferred ? eb.and([uncredited, eb.or([hasExplicitCredit(eb), eb.not(authorHasByline(eb))])]) : uncredited;
1276
+ });
1277
+ const bylineIds = filter.bylineIds ?? [];
1278
+ if (bylineIds.length === 0) return query.where(() => sql`1 = 0`);
1279
+ return query.where((eb) => {
1280
+ if (!filter.includeInferred) return creditRenders(eb, bylineIds);
1281
+ return eb.or([creditRenders(eb, bylineIds), eb.and([eb.not(hasExplicitCredit(eb)), authorHasByline(eb, bylineIds)])]);
1282
+ });
1283
+ }
1284
+ /**
1285
+ * Count content items
1286
+ */
1287
+ async count(type, where) {
1288
+ const resolvedFieldFilters = await this.resolveFieldFilters(type, where?.fieldFilters);
1289
+ return this.countWithResolvedFilters(type, where, resolvedFieldFilters);
1290
+ }
1291
+ async countWithResolvedFilters(type, where, resolvedFieldFilters) {
1292
+ const tableName = getTableName(type);
1293
+ let query = this.db.selectFrom(tableName).select((eb) => eb.fn.count("id").as("count")).where("deleted_at", "is", null);
1294
+ if (where?.status) query = query.where("status", "=", where.status);
1295
+ if (where?.authorId) query = query.where("author_id", "=", where.authorId);
1296
+ if (where?.locale) query = query.where("locale", "=", where.locale);
1297
+ query = this.applySearchFilter(query, where, type);
1298
+ query = this.applyDateFilter(query, where);
1299
+ query = this.applyBylineFilter(query, where, type);
1300
+ query = this.applyFieldFilters(query, resolvedFieldFilters);
1301
+ const result = await query.executeTakeFirst();
1302
+ return Number(result?.count || 0);
1303
+ }
1304
+ /**
1305
+ * Distinct, non-null `author_id` values across the collection's live
1306
+ * (non-trashed) content. Used to populate the admin author filter with
1307
+ * only the users who have actually authored entries, rather than the
1308
+ * full user directory (which requires admin privileges to read).
1309
+ */
1310
+ async findDistinctAuthorIds(type) {
1311
+ const tableName = getTableName(type);
1312
+ 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);
1313
+ }
1314
+ async getStats(type, now = /* @__PURE__ */ new Date()) {
1315
+ const tableName = getTableName(type);
1316
+ const nowIso = now.toISOString();
1317
+ const result = await this.db.selectFrom(tableName).select((eb) => [
1318
+ eb.fn.count("id").as("total"),
1319
+ eb.fn.sum(eb.case().when("status", "=", "published").then(1).else(0).end()).as("published"),
1320
+ eb.fn.sum(eb.case().when("status", "=", "draft").then(1).else(0).end()).as("draft"),
1321
+ sql`SUM(CASE WHEN scheduled_at IS NOT NULL THEN 1 ELSE 0 END)`.as("scheduled"),
1322
+ sql`SUM(CASE WHEN scheduled_at IS NOT NULL AND scheduled_at <= ${nowIso} THEN 1 ELSE 0 END)`.as("overdue_scheduled")
1323
+ ]).where("deleted_at", "is", null).executeTakeFirst();
1324
+ return {
1325
+ total: Number(result?.total || 0),
1326
+ published: Number(result?.published || 0),
1327
+ draft: Number(result?.draft || 0),
1328
+ scheduled: Number(result?.scheduled || 0),
1329
+ overdueScheduled: Number(result?.overdue_scheduled || 0)
1330
+ };
1331
+ }
1332
+ /**
1333
+ * Schedule content for future publishing
1334
+ *
1335
+ * Sets status to 'scheduled' and stores the scheduled publish time.
1336
+ * The content will be auto-published when the scheduled time is reached.
1337
+ */
1338
+ async schedule(type, id, scheduledAt, currentTime = /* @__PURE__ */ new Date(), expectedRevision) {
1339
+ const tableName = getTableName(type);
1340
+ const now = currentTime.toISOString();
1341
+ const normalizedScheduledAt = await this.datetimes.normalizeValue(type, scheduledAt);
1342
+ if (new Date(normalizedScheduledAt) <= currentTime) throw new EmDashValidationError("Scheduled date must be in the future");
1343
+ const existing = await this.findById(type, id);
1344
+ if (!existing) throw new EmDashValidationError("Content item not found");
1345
+ assertRevisionPrecondition(existing, expectedRevision);
1346
+ const newStatus = existing.status === "published" ? "published" : "scheduled";
1347
+ if (((await sql`
1348
+ UPDATE ${sql.ref(tableName)}
1349
+ SET status = ${newStatus},
1350
+ scheduled_at = ${normalizedScheduledAt},
1351
+ updated_at = ${now}
1352
+ WHERE id = ${id}
1353
+ AND deleted_at IS NULL
1354
+ AND version = ${existing.version}
1355
+ AND updated_at = ${existing.updatedAt}
1356
+ AND status = ${existing.status}
1357
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1358
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError("Content changed while scheduling");
1359
+ invalidateCollectionCache(type);
1360
+ const updated = await this.findById(type, id);
1361
+ if (!updated) throw new Error("Content not found");
1362
+ return updated;
1363
+ }
1364
+ /**
1365
+ * Unschedule content
1366
+ *
1367
+ * Clears the scheduled time. Published posts stay published;
1368
+ * draft/scheduled posts revert to 'draft'.
1369
+ */
1370
+ async unschedule(type, id, expectedRevision) {
1371
+ const tableName = getTableName(type);
1372
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1373
+ const existing = await this.findById(type, id);
1374
+ if (!existing) throw new EmDashValidationError("Content item not found");
1375
+ assertRevisionPrecondition(existing, expectedRevision);
1376
+ const newStatus = existing.status === "published" ? "published" : "draft";
1377
+ const result = await sql`
1378
+ UPDATE ${sql.ref(tableName)}
1379
+ SET status = ${newStatus},
1380
+ scheduled_at = NULL,
1381
+ updated_at = ${now}
1382
+ WHERE id = ${id}
1383
+ AND scheduled_at IS NOT NULL
1384
+ AND deleted_at IS NULL
1385
+ AND version = ${existing.version}
1386
+ AND updated_at = ${existing.updatedAt}
1387
+ AND status = ${existing.status}
1388
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1389
+ `.execute(this.db);
1390
+ if (existing.scheduledAt !== null && (result.numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError("Content changed while unscheduling");
1391
+ invalidateCollectionCache(type);
1392
+ const updated = await this.findById(type, id);
1393
+ if (!updated) throw new Error("Content not found");
1394
+ return updated;
1395
+ }
1396
+ /**
1397
+ * Find content that is ready to be published
1398
+ *
1399
+ * Returns all content where scheduled_at <= now, regardless of status.
1400
+ * This covers both draft-scheduled posts (status='scheduled') and
1401
+ * published posts with scheduled draft changes (status='published').
1402
+ *
1403
+ * `limit` (optional) caps how many due rows are returned, oldest-due first.
1404
+ * The scheduled-publishing sweep passes a limit so a large backlog can't
1405
+ * fan out unbounded publish/webhook work in a single tick (and blow a Worker
1406
+ * invocation's CPU/subrequest budget); the remainder drains on later ticks.
1407
+ */
1408
+ async findReadyToPublish(type, limit, currentTime = /* @__PURE__ */ new Date(), after) {
1409
+ const tableName = getTableName(type);
1410
+ const now = currentTime.toISOString();
1411
+ const limitClause = typeof limit === "number" && Number.isInteger(limit) && limit > 0 ? sql`LIMIT ${limit}` : sql``;
1412
+ const afterClause = after ? sql`AND (scheduled_at > ${after.scheduledAt} OR (scheduled_at = ${after.scheduledAt} AND id > ${after.id}))` : sql``;
1413
+ return (await sql`
1414
+ SELECT * FROM ${sql.ref(tableName)}
1415
+ WHERE scheduled_at IS NOT NULL
1416
+ AND scheduled_at <= ${now}
1417
+ AND deleted_at IS NULL
1418
+ ${afterClause}
1419
+ ORDER BY scheduled_at ASC, id ASC
1420
+ ${limitClause}
1421
+ `.execute(this.db)).rows.map((row) => this.mapRow(type, row));
1422
+ }
1423
+ async findTranslationIds(type, translationGroup) {
1424
+ const tableName = getTableName(type);
1425
+ return (await sql`
1426
+ SELECT id FROM ${sql.ref(tableName)}
1427
+ WHERE translation_group = ${translationGroup}
1428
+ AND deleted_at IS NULL
1429
+ `.execute(this.db)).rows.map((row) => row.id);
1430
+ }
1431
+ async findTranslationIdsForGroups(type, translationGroups) {
1432
+ const ids = /* @__PURE__ */ new Map();
1433
+ if (translationGroups.length === 0) return ids;
1434
+ const tableName = getTableName(type);
1435
+ for (const batch of chunks([...new Set(translationGroups)], SQL_BATCH_SIZE)) {
1436
+ const result = await sql`
1437
+ SELECT id, translation_group FROM ${sql.ref(tableName)}
1438
+ WHERE translation_group IN (${sql.join(batch)}) AND deleted_at IS NULL
1439
+ `.execute(this.db);
1440
+ for (const row of result.rows) {
1441
+ const group = ids.get(row.translation_group) ?? [];
1442
+ group.push(row.id);
1443
+ ids.set(row.translation_group, group);
1444
+ }
1445
+ }
1446
+ return ids;
1447
+ }
1448
+ /**
1449
+ * Find all translations in a translation group
1450
+ */
1451
+ async findTranslations(type, translationGroup) {
1452
+ const tableName = getTableName(type);
1453
+ return (await sql`
1454
+ SELECT * FROM ${sql.ref(tableName)}
1455
+ WHERE translation_group = ${translationGroup}
1456
+ AND deleted_at IS NULL
1457
+ ORDER BY locale ASC
1458
+ `.execute(this.db)).rows.map((row) => this.mapRow(type, row));
1459
+ }
1460
+ /**
1461
+ * Whether any row still shares `translationGroup`, trashed rows included.
1462
+ * Group-keyed satellite data (term assignments, reference edges) is owned by
1463
+ * the group, not by a single locale row, so a purge may only cascade to it
1464
+ * once nothing is left to own it — and a trashed sibling is still restorable.
1465
+ */
1466
+ async hasTranslationsIncludingTrashed(type, translationGroup, options = {}) {
1467
+ const tableName = getTableName(type);
1468
+ const exclusion = options.excludeId ? sql`AND id != ${options.excludeId}` : sql``;
1469
+ return (await sql`
1470
+ SELECT id FROM ${sql.ref(tableName)}
1471
+ WHERE translation_group = ${translationGroup}
1472
+ ${exclusion}
1473
+ LIMIT 1
1474
+ `.execute(this.db)).rows.length > 0;
1475
+ }
1476
+ /**
1477
+ * Batch variant of {@link findTranslations}: every (non-deleted) locale
1478
+ * variant for any of `translationGroups`, in one `WHERE translation_group IN
1479
+ * (...)` query chunked at `SQL_BATCH_SIZE` for D1's bind-parameter limit.
1480
+ * Lets callers resolve many edge groups without an N+1 per group. The caller
1481
+ * groups the flat result by `translationGroup` itself.
1482
+ *
1483
+ * `translation_group` leads the sort so the ordering follows
1484
+ * `idx_{table}_del_tg_locale` past its `deleted_at` equality; callers group by
1485
+ * `translationGroup`, so the per-group locale order they rely on is preserved.
1486
+ *
1487
+ * `publishedOnly` restricts the result to `status = 'published'` — reference
1488
+ * reads pass this for callers without `content:read_drafts` so draft/scheduled
1489
+ * entries never leak through an edge traversal.
1490
+ *
1491
+ * A reference edge stores only a collection slug (no SQL FK), so the table may
1492
+ * have been dropped since the edge was written. That is a tolerated dangling
1493
+ * state, not an error: a missing table resolves to no rows, mirroring how the
1494
+ * content read handlers treat `isMissingTableError`.
1495
+ */
1496
+ async findTranslationsForGroups(type, translationGroups, options = {}) {
1497
+ if (translationGroups.length === 0) return [];
1498
+ const tableName = getTableName(type);
1499
+ const publishedFilter = options.publishedOnly ? sql`AND status = 'published'` : sql``;
1500
+ const items = [];
1501
+ try {
1502
+ for (const chunk of chunks(translationGroups, SQL_BATCH_SIZE)) {
1503
+ const result = await sql`
1504
+ SELECT * FROM ${sql.ref(tableName)}
1505
+ WHERE translation_group IN (${sql.join(chunk)})
1506
+ AND deleted_at IS NULL
1507
+ ${publishedFilter}
1508
+ ORDER BY translation_group ASC, locale ASC
1509
+ `.execute(this.db);
1510
+ for (const row of result.rows) items.push(this.mapRow(type, row));
1511
+ }
1512
+ } catch (error) {
1513
+ if (isMissingTableError(error)) return [];
1514
+ throw error;
1515
+ }
1516
+ return items;
1517
+ }
1518
+ /**
1519
+ * Batch variant of {@link findByIdOrSlug}: resolve many identifiers (each an
1520
+ * id OR a slug) within `type` in a constant number of queries — one `WHERE id
1521
+ * IN (...)` and one `WHERE slug IN (...)`, each chunked at `SQL_BATCH_SIZE`.
1522
+ * Returns a map from the input identifier to its resolved item; identifiers
1523
+ * that match nothing are absent. Used on write paths that accept a list of
1524
+ * references, so a single request doesn't fan out to an N+1 of point lookups.
1525
+ *
1526
+ * Resolution mirrors {@link findByIdOrSlug}: a ULID-shaped identifier prefers
1527
+ * the id match and falls back to slug; anything else prefers the slug match
1528
+ * and falls back to id. Slug matches collapse to the lowest-locale variant
1529
+ * (`ORDER BY locale ASC`), matching the slug-without-locale lookup.
1530
+ */
1531
+ async findManyByIdOrSlug(type, identifiers) {
1532
+ const resolved = /* @__PURE__ */ new Map();
1533
+ const unique = [...new Set(identifiers)];
1534
+ if (unique.length === 0) return resolved;
1535
+ const tableName = getTableName(type);
1536
+ const byId = /* @__PURE__ */ new Map();
1537
+ const bySlug = /* @__PURE__ */ new Map();
1538
+ try {
1539
+ for (const chunk of chunks(unique, SQL_BATCH_SIZE)) {
1540
+ const idRows = await sql`
1541
+ SELECT * FROM ${sql.ref(tableName)}
1542
+ WHERE id IN (${sql.join(chunk)})
1543
+ AND deleted_at IS NULL
1544
+ `.execute(this.db);
1545
+ for (const row of idRows.rows) {
1546
+ const item = this.mapRow(type, row);
1547
+ byId.set(item.id, item);
1548
+ }
1549
+ const slugRows = await sql`
1550
+ SELECT * FROM ${sql.ref(tableName)}
1551
+ WHERE slug IN (${sql.join(chunk)})
1552
+ AND deleted_at IS NULL
1553
+ ORDER BY locale ASC
1554
+ `.execute(this.db);
1555
+ for (const row of slugRows.rows) {
1556
+ const item = this.mapRow(type, row);
1557
+ if (item.slug != null && !bySlug.has(item.slug)) bySlug.set(item.slug, item);
1558
+ }
1559
+ }
1560
+ } catch (error) {
1561
+ if (isMissingTableError(error)) return resolved;
1562
+ throw error;
1563
+ }
1564
+ for (const identifier of unique) {
1565
+ const item = ULID_PATTERN.test(identifier) ? byId.get(identifier) ?? bySlug.get(identifier) : bySlug.get(identifier) ?? byId.get(identifier);
1566
+ if (item) resolved.set(identifier, item);
1567
+ }
1568
+ return resolved;
1569
+ }
1570
+ /**
1571
+ * Publish the current draft
1572
+ *
1573
+ * Promotes draft_revision_id to live_revision_id and clears draft pointer.
1574
+ * Syncs the draft revision's data into the content table columns so the
1575
+ * content table always reflects the published version.
1576
+ * If no draft revision exists, creates one from current data and publishes it.
1577
+ * When `promoteRevision` is false, publishes the current content-table data
1578
+ * by changing lifecycle metadata only.
1579
+ *
1580
+ * `publishedAt` (optional) overrides the publication timestamp. If omitted,
1581
+ * the existing `published_at` is preserved (idempotent re-publish keeps the
1582
+ * original date) and falls back to the current time on first publish. Pass
1583
+ * an explicit value to backdate a publish (e.g. when migrating content from
1584
+ * another CMS).
1585
+ *
1586
+ * `requireDue` gates the final update on the row still being due.
1587
+ * `expectedScheduledAt` additionally fences changes made after a sweep
1588
+ * selected the row but before publication preparation began.
1589
+ */
1590
+ async publish(type, id, publishedAt, requireDue = false, expectedScheduledAt, promoteRevision = true, requireSlug = true, expectedRevision, currentTime = /* @__PURE__ */ new Date()) {
1591
+ const tableName = getTableName(type);
1592
+ const now = currentTime.toISOString();
1593
+ const existing = await this.findById(type, id);
1594
+ if (!existing) throw new EmDashValidationError("Content item not found");
1595
+ assertRevisionPrecondition(existing, expectedRevision);
1596
+ const requestedPublishedAt = publishedAt ? await this.datetimes.normalizeValue(type, publishedAt) : void 0;
1597
+ const currentPublishedAt = existing.publishedAt ? await this.datetimes.normalizeValue(type, existing.publishedAt) : null;
1598
+ if (requireDue && expectedScheduledAt !== void 0 && existing.scheduledAt !== expectedScheduledAt) throw new ScheduledNotDueError();
1599
+ if (!promoteRevision && requireSlug && !existing.slug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
1600
+ if (!promoteRevision) {
1601
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1602
+ let provisionalRevisionId = null;
1603
+ try {
1604
+ let liveRevisionId = existing.liveRevisionId;
1605
+ if (!liveRevisionId) {
1606
+ const revision = await revisionRepo.create({
1607
+ collection: type,
1608
+ entryId: id,
1609
+ data: existing.data
1610
+ });
1611
+ liveRevisionId = revision.id;
1612
+ provisionalRevisionId = revision.id;
1613
+ }
1614
+ const intendedPublishedAt = requestedPublishedAt ?? currentPublishedAt ?? now;
1615
+ const duePredicate = requireDue ? sql`AND scheduled_at IS NOT NULL AND scheduled_at <= ${now}` : sql``;
1616
+ let published = false;
1617
+ try {
1618
+ published = ((await sql`
1619
+ UPDATE ${sql.ref(tableName)}
1620
+ SET live_revision_id = ${liveRevisionId},
1621
+ draft_revision_id = NULL,
1622
+ status = 'published',
1623
+ scheduled_at = NULL,
1624
+ published_at = ${intendedPublishedAt},
1625
+ updated_at = ${now},
1626
+ version = version + 1
1627
+ WHERE id = ${id}
1628
+ AND deleted_at IS NULL
1629
+ AND version = ${existing.version}
1630
+ AND updated_at = ${existing.updatedAt}
1631
+ AND status = ${existing.status}
1632
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1633
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1634
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1635
+ ${duePredicate}
1636
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1637
+ } catch (error) {
1638
+ if (isConfirmedStatementFailure(error)) throw error;
1639
+ let observed;
1640
+ try {
1641
+ observed = await this.findById(type, id);
1642
+ } catch (reconciliationError) {
1643
+ throw new Error("Unable to confirm whether content publication completed", { cause: reconciliationError });
1644
+ }
1645
+ if (!observed) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1646
+ published = matchesLifecyclePublication(observed, existing, liveRevisionId, intendedPublishedAt, now);
1647
+ if (!published && matchesPublicationFence(observed, existing)) throw error;
1648
+ if (!published) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1649
+ }
1650
+ if (!published) throw requireDue ? new ScheduledNotDueError() : new ContentMutationConflictError();
1651
+ invalidateCollectionCache(type);
1652
+ const updated = await this.findById(type, id);
1653
+ if (!updated) throw new Error("Content not found");
1654
+ return updated;
1655
+ } catch (error) {
1656
+ if (provisionalRevisionId) try {
1657
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1658
+ } catch (cleanupError) {
1659
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1660
+ }
1661
+ throw error;
1662
+ }
1663
+ }
1664
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1665
+ let provisionalRevisionId = null;
1666
+ try {
1667
+ let revisionToPublish = existing.draftRevisionId || existing.liveRevisionId;
1668
+ if (!revisionToPublish) {
1669
+ const revision = await revisionRepo.create({
1670
+ collection: type,
1671
+ entryId: id,
1672
+ data: existing.data
1673
+ });
1674
+ revisionToPublish = revision.id;
1675
+ provisionalRevisionId = revision.id;
1676
+ }
1677
+ const revision = await revisionRepo.findById(revisionToPublish);
1678
+ if (!revision || revision.collection !== type || revision.entryId !== id) throw new EmDashValidationError("Revision does not belong to the specified content item");
1679
+ const writableFieldSlugs = await this.datetimes.writableFieldSlugs(type);
1680
+ const revisionData = keepKnownFields(revision.data, writableFieldSlugs);
1681
+ const stagedSlug = typeof revision.data._slug === "string" ? revision.data._slug : null;
1682
+ const intendedSlug = stagedSlug ?? existing.slug;
1683
+ if (requireSlug && !intendedSlug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
1684
+ const intendedPublishedAt = requestedPublishedAt ?? currentPublishedAt ?? now;
1685
+ if (stagedSlug !== null && stagedSlug !== existing.slug && existing.locale !== null) {
1686
+ const conflict = await this.findBySlugIncludingTrashed(type, stagedSlug, existing.locale);
1687
+ 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" });
1688
+ }
1689
+ const assignments = [];
1690
+ if (stagedSlug !== null) assignments.push(sql`slug = ${stagedSlug}`);
1691
+ for (const [key, value] of Object.entries(revisionData)) {
1692
+ if (SYSTEM_COLUMNS.has(key) || key.startsWith("_")) continue;
1693
+ validateIdentifier(key, "content field name");
1694
+ assignments.push(sql`${sql.ref(key)} = ${serializeValue(value)}`);
1695
+ }
1696
+ 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`);
1697
+ const duePredicate = requireDue ? sql`AND scheduled_at IS NOT NULL AND scheduled_at <= ${now}` : sql``;
1698
+ let promoted = false;
1699
+ try {
1700
+ promoted = ((await sql`
1701
+ UPDATE ${sql.ref(tableName)}
1702
+ SET ${sql.join(assignments, sql`, `)}
1703
+ WHERE id = ${id}
1704
+ AND deleted_at IS NULL
1705
+ AND version = ${existing.version}
1706
+ AND updated_at = ${existing.updatedAt}
1707
+ AND status = ${existing.status}
1708
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1709
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1710
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1711
+ ${duePredicate}
1712
+ AND EXISTS (
1713
+ SELECT 1 FROM revisions
1714
+ WHERE revisions.id = ${revisionToPublish}
1715
+ AND revisions.collection = ${type}
1716
+ AND revisions.entry_id = ${id}
1717
+ )
1718
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1719
+ } catch (error) {
1720
+ if (isConfirmedStatementFailure(error)) throw error;
1721
+ let observed;
1722
+ try {
1723
+ observed = await this.findById(type, id);
1724
+ } catch (reconciliationError) {
1725
+ throw new Error("Unable to confirm whether content publication completed", { cause: reconciliationError });
1726
+ }
1727
+ if (!observed) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1728
+ promoted = matchesPublication(observed, existing, revisionData, revisionToPublish, intendedSlug, intendedPublishedAt, now);
1729
+ if (!promoted && matchesPublicationFence(observed, existing)) throw error;
1730
+ if (!promoted) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1731
+ }
1732
+ if (!promoted) throw requireDue ? new ScheduledNotDueError() : new ContentMutationConflictError();
1733
+ invalidateCollectionCache(type);
1734
+ const updated = await this.findById(type, id);
1735
+ if (!updated) throw new Error("Content not found");
1736
+ return updated;
1737
+ } catch (error) {
1738
+ if (provisionalRevisionId) try {
1739
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1740
+ } catch (cleanupError) {
1741
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1742
+ }
1743
+ throw error;
1744
+ }
1745
+ }
1746
+ /**
1747
+ * Unpublish content
1748
+ *
1749
+ * Removes live pointer and cancels any pending schedule, but preserves the
1750
+ * draft and publication date. If no draft exists, creates one from the live
1751
+ * version so the content isn't lost.
1752
+ */
1753
+ async unpublish(type, id, expectedRevision) {
1754
+ const tableName = getTableName(type);
1755
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1756
+ const existing = await this.findById(type, id);
1757
+ if (!existing) throw new EmDashValidationError("Content item not found");
1758
+ assertRevisionPrecondition(existing, expectedRevision);
1759
+ if (existing.status === "draft" && !existing.liveRevisionId && !existing.scheduledAt) return existing;
1760
+ const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1761
+ let provisionalRevisionId = null;
1762
+ try {
1763
+ let draftRevisionId = existing.draftRevisionId;
1764
+ if (!draftRevisionId && existing.liveRevisionId) {
1765
+ const liveRevision = await revisionRepo.findById(existing.liveRevisionId);
1766
+ if (liveRevision) {
1767
+ const draft = await revisionRepo.create({
1768
+ collection: type,
1769
+ entryId: id,
1770
+ data: liveRevision.data
1771
+ });
1772
+ draftRevisionId = draft.id;
1773
+ provisionalRevisionId = draft.id;
1774
+ }
1775
+ }
1776
+ if (((await sql`
1777
+ UPDATE ${sql.ref(tableName)}
1778
+ SET live_revision_id = NULL,
1779
+ draft_revision_id = ${draftRevisionId},
1780
+ status = 'draft',
1781
+ scheduled_at = NULL,
1782
+ updated_at = ${now},
1783
+ version = version + 1
1784
+ WHERE id = ${id}
1785
+ AND deleted_at IS NULL
1786
+ AND version = ${existing.version}
1787
+ AND updated_at = ${existing.updatedAt}
1788
+ AND status = ${existing.status}
1789
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1790
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1791
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1792
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError();
1793
+ invalidateCollectionCache(type);
1794
+ const updated = await this.findById(type, id);
1795
+ if (!updated) throw new Error("Content not found");
1796
+ return updated;
1797
+ } catch (error) {
1798
+ if (provisionalRevisionId) try {
1799
+ await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1800
+ } catch (cleanupError) {
1801
+ console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1802
+ }
1803
+ throw error;
1804
+ }
1805
+ }
1806
+ /**
1807
+ * Set the draft revision pointer for a content item.
1808
+ *
1809
+ * Used by seed/import paths that stage a new revision's data before
1810
+ * promoting it to live via `publish()`.
1811
+ *
1812
+ * Validates that the content item exists and is not soft-deleted, that
1813
+ * the revision exists, and that the revision belongs to the same
1814
+ * collection and entry. Without these checks, a caller could leave the
1815
+ * content row pointing at a missing or unrelated revision.
1816
+ */
1817
+ async setDraftRevision(type, id, revisionId) {
1818
+ const existing = await this.findById(type, id);
1819
+ if (!existing) throw new EmDashValidationError("Content item not found");
1820
+ const revision = await new RevisionRepository(this.db, this.datetimeContexts).findById(revisionId);
1821
+ if (!revision) throw new EmDashValidationError("Revision not found");
1822
+ if (revision.collection !== type || revision.entryId !== id) throw new EmDashValidationError("Revision does not belong to the specified content item");
1823
+ if (!await this.replaceDraftRevision(type, id, revisionId, existing)) throw new ContentMutationConflictError();
1824
+ }
1825
+ async replaceDraftRevision(type, id, revisionId, expected) {
1826
+ const tableName = getTableName(type);
1827
+ return ((await sql`
1828
+ UPDATE ${sql.ref(tableName)}
1829
+ SET draft_revision_id = ${revisionId},
1830
+ version = version + 1
1831
+ WHERE id = ${id}
1832
+ AND deleted_at IS NULL
1833
+ AND version = ${expected.version}
1834
+ AND ${nullableColumnMatch("live_revision_id", expected.liveRevisionId)}
1835
+ AND ${nullableColumnMatch("draft_revision_id", expected.draftRevisionId)}
1836
+ AND EXISTS (
1837
+ SELECT 1 FROM revisions
1838
+ WHERE revisions.id = ${revisionId}
1839
+ AND revisions.collection = ${type}
1840
+ AND revisions.entry_id = ${id}
1841
+ )
1842
+ `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1843
+ }
1844
+ /**
1845
+ * Discard pending draft changes
1846
+ *
1847
+ * Clears draft_revision_id. The content table columns already hold the
1848
+ * published version, so no data sync is needed.
1849
+ */
1850
+ async discardDraft(type, id, expectedRevision) {
1851
+ const tableName = getTableName(type);
1852
+ const existing = await this.findById(type, id);
1853
+ if (!existing) throw new EmDashValidationError("Content item not found");
1854
+ assertRevisionPrecondition(existing, expectedRevision);
1855
+ if (!existing.draftRevisionId) return existing;
1856
+ if (((await sql`
1857
+ UPDATE ${sql.ref(tableName)}
1858
+ SET draft_revision_id = NULL,
1859
+ version = version + 1
1860
+ WHERE id = ${id}
1861
+ AND deleted_at IS NULL
1862
+ AND version = ${existing.version}
1863
+ AND updated_at = ${existing.updatedAt}
1864
+ AND status = ${existing.status}
1865
+ AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1866
+ AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1867
+ AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1868
+ `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError();
1869
+ const updated = await this.findById(type, id);
1870
+ if (!updated) throw new Error("Content not found");
1871
+ return updated;
1872
+ }
1873
+ /**
1874
+ * Count content items with a pending schedule.
1875
+ * Includes both draft-scheduled (status='scheduled') and published
1876
+ * posts with scheduled draft changes (status='published', scheduled_at set).
1877
+ */
1878
+ async countScheduled(type) {
1879
+ const tableName = getTableName(type);
1880
+ const result = await sql`
1881
+ SELECT COUNT(id) as count FROM ${sql.ref(tableName)}
1882
+ WHERE scheduled_at IS NOT NULL
1883
+ AND deleted_at IS NULL
1884
+ `.execute(this.db);
1885
+ return Number(result.rows[0]?.count || 0);
1886
+ }
1887
+ /**
1888
+ * Map database row to ContentItem
1889
+ * Extracts system columns and puts content fields in data
1890
+ * Excludes null values from data to match input semantics
1891
+ */
1892
+ mapRow(type, row) {
1893
+ const data = {};
1894
+ for (const [key, value] of Object.entries(row)) if (!SYSTEM_COLUMNS.has(key) && value !== null) data[key] = deserializeValue(value);
1895
+ return {
1896
+ id: row.id,
1897
+ type,
1898
+ slug: row.slug,
1899
+ status: row.status,
1900
+ data,
1901
+ authorId: row.author_id,
1902
+ primaryBylineId: row.primary_byline_id ?? null,
1903
+ createdAt: row.created_at,
1904
+ updatedAt: row.updated_at,
1905
+ publishedAt: row.published_at,
1906
+ scheduledAt: row.scheduled_at,
1907
+ liveRevisionId: row.live_revision_id ?? null,
1908
+ draftRevisionId: row.draft_revision_id ?? null,
1909
+ version: typeof row.version === "number" ? row.version : 1,
1910
+ locale: row.locale ?? null,
1911
+ translationGroup: row.translation_group ?? null
1912
+ };
1913
+ }
1914
+ normalizeFilterScalar(field, type, value) {
1915
+ if (type === "number" || type === "integer") {
1916
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new EmDashValidationError(`Filter for field "${field}" must use a finite number`);
1917
+ if (type === "integer" && !Number.isInteger(value)) throw new EmDashValidationError(`Filter for field "${field}" must use an integer`);
1918
+ return value;
1919
+ }
1920
+ if (type === "boolean") {
1921
+ if (typeof value !== "boolean") throw new EmDashValidationError(`Filter for field "${field}" must use a boolean`);
1922
+ return value ? 1 : 0;
1923
+ }
1924
+ if (typeof value !== "string") throw new EmDashValidationError(`Filter for field "${field}" must use a string`);
1925
+ if (value.length > MAX_FILTER_STRING_LENGTH) throw new EmDashValidationError(`Filter value for field "${field}" exceeds ${MAX_FILTER_STRING_LENGTH} characters`);
1926
+ if (type === "datetime") try {
1927
+ return normalizeExplicitDatetime(value);
1928
+ } catch {
1929
+ throw new EmDashValidationError(`Filter for datetime field "${field}" must use an ISO 8601 datetime with Z or an explicit offset`);
1930
+ }
1931
+ return value;
1932
+ }
1933
+ normalizeFieldFilter(field, type, value) {
1934
+ if (value === null) return {
1935
+ column: field,
1936
+ kind: "null"
1937
+ };
1938
+ if (typeof value !== "object") return {
1939
+ column: field,
1940
+ kind: "exact",
1941
+ value: this.normalizeFilterScalar(field, type, value)
1942
+ };
1943
+ if (Array.isArray(value)) throw new EmDashValidationError(`Invalid filter for field "${field}"`);
1944
+ const record = value;
1945
+ const keys = Object.keys(record);
1946
+ if (keys.length === 1 && keys[0] === "in") {
1947
+ if (!Array.isArray(record.in) || record.in.length === 0) throw new EmDashValidationError(`IN filter for field "${field}" must not be empty`);
1948
+ if (record.in.length > MAX_IN_FILTER_VALUES) throw new EmDashValidationError(`IN filter for field "${field}" exceeds ${MAX_IN_FILTER_VALUES} values`);
1949
+ return {
1950
+ column: field,
1951
+ kind: "in",
1952
+ values: record.in.map((entry) => this.normalizeFilterScalar(field, type, entry))
1953
+ };
1954
+ }
1955
+ const rangeKeys = new Set([
1956
+ "gt",
1957
+ "gte",
1958
+ "lt",
1959
+ "lte"
1960
+ ]);
1961
+ if (keys.length === 0 || keys.some((key) => !rangeKeys.has(key))) throw new EmDashValidationError(`Invalid filter operator for field "${field}"`);
1962
+ if (type === "boolean") throw new EmDashValidationError(`Boolean field "${field}" does not support range filters`);
1963
+ const bounds = {};
1964
+ for (const key of keys) {
1965
+ if (record[key] === void 0) continue;
1966
+ bounds[key] = this.normalizeFilterScalar(field, type, record[key]);
1967
+ }
1968
+ if (Object.keys(bounds).length === 0) throw new EmDashValidationError(`Range filter for field "${field}" has no bounds`);
1969
+ return {
1970
+ column: field,
1971
+ kind: "range",
1972
+ bounds
1973
+ };
1974
+ }
1975
+ async collectionExists(type) {
1976
+ return await this.db.selectFrom("_emdash_collections").where("slug", "=", type).select("id").executeTakeFirst() !== void 0;
1977
+ }
1978
+ async resolveFieldFilters(type, filters) {
1979
+ const resolvedFilters = filters ?? {};
1980
+ const fields = Object.keys(resolvedFilters);
1981
+ if (fields.length === 0) return [];
1982
+ if (fields.length > MAX_INDEXED_FIELD_FILTERS) {
1983
+ if (!await this.collectionExists(type)) return [];
1984
+ throw new EmDashValidationError(`Content list queries support at most ${MAX_INDEXED_FIELD_FILTERS} indexed field filters`);
1985
+ }
1986
+ 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([
1987
+ "field.slug",
1988
+ "field.type",
1989
+ "field.validation"
1990
+ ]).execute();
1991
+ const metadata = new Map(rows.filter((row) => !isStoragelessFieldRow(row)).map((row) => [row.slug, row.type]));
1992
+ if (metadata.size === 0 && !await this.collectionExists(type)) return [];
1993
+ for (const field of fields) try {
1994
+ validateIdentifier(field, "content filter field");
1995
+ } catch {
1996
+ throw new EmDashValidationError(`Invalid content filter field: ${field}`);
1997
+ }
1998
+ const normalized = fields.map((field) => {
1999
+ const fieldType = metadata.get(field);
2000
+ if (!fieldType || !isIndexableFieldType(fieldType)) throw new EmDashValidationError(`Cannot filter by field "${field}". Custom fields must be indexed before filtering.`);
2001
+ return this.normalizeFieldFilter(field, fieldType, resolvedFilters[field]);
2002
+ });
2003
+ if (normalized.reduce((total, filter) => {
2004
+ if (filter.kind === "null") return total;
2005
+ if (filter.kind === "exact") return total + 1;
2006
+ if (filter.kind === "in") return total + filter.values.length;
2007
+ return total + Object.keys(filter.bounds).length;
2008
+ }, 0) > SQL_BATCH_SIZE) throw new EmDashValidationError(`Indexed field filters have a total operand budget of ${SQL_BATCH_SIZE}`);
2009
+ return normalized;
2010
+ }
2011
+ applyFieldFilters(query, filters) {
2012
+ let next = query;
2013
+ for (const filter of filters) {
2014
+ const column = sql.ref(filter.column);
2015
+ const isPresent = sql`${column} IS NOT NULL`;
2016
+ if (filter.kind === "null") {
2017
+ next = next.where(() => sql`(${isPresent}) = FALSE AND ${column} IS NULL`);
2018
+ continue;
2019
+ }
2020
+ if (filter.kind === "exact") {
2021
+ next = next.where(() => sql`(${isPresent}) = TRUE AND ${column} = ${filter.value}`);
2022
+ continue;
2023
+ }
2024
+ if (filter.kind === "in") {
2025
+ const values = sql.join(filter.values.map((value) => sql`${value}`), sql`, `);
2026
+ next = next.where(() => sql`(${isPresent}) = TRUE AND ${column} IN (${values})`);
2027
+ continue;
2028
+ }
2029
+ next = next.where(() => sql`(${isPresent}) = TRUE`);
2030
+ if (filter.bounds.gt !== void 0) next = next.where(() => sql`${column} > ${filter.bounds.gt}`);
2031
+ if (filter.bounds.gte !== void 0) next = next.where(() => sql`${column} >= ${filter.bounds.gte}`);
2032
+ if (filter.bounds.lt !== void 0) next = next.where(() => sql`${column} < ${filter.bounds.lt}`);
2033
+ if (filter.bounds.lte !== void 0) next = next.where(() => sql`${column} <= ${filter.bounds.lte}`);
2034
+ }
2035
+ return next;
2036
+ }
2037
+ /**
2038
+ * Map order field names to database columns.
2039
+ * Only allows known fields to prevent column enumeration via crafted orderBy values.
2040
+ */
2041
+ mapOrderField(field, sortableExtras = []) {
2042
+ const mapped = ORDER_FIELD_COLUMNS[field];
2043
+ if (mapped) return mapped;
2044
+ if (sortableExtras.includes(field)) {
2045
+ validateIdentifier(field, "order field");
2046
+ return field;
2047
+ }
2048
+ throw new EmDashValidationError(`Invalid order field: ${field}`);
2049
+ }
2050
+ async resolveOrderField(type, field, sortableExtras = []) {
2051
+ try {
2052
+ return {
2053
+ column: this.mapOrderField(field, sortableExtras),
2054
+ indexedCustomField: false
2055
+ };
2056
+ } catch (error) {
2057
+ if (!(error instanceof EmDashValidationError)) throw error;
2058
+ }
2059
+ 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();
2060
+ if (!customField) throw new ContentCollectionNotFoundError(type);
2061
+ if (!customField.fieldSlug) throw new EmDashValidationError(`Invalid order field: ${field}. Custom fields must be indexed before sorting.`);
2062
+ validateIdentifier(customField.fieldSlug, "content order field");
2063
+ return {
2064
+ column: customField.fieldSlug,
2065
+ indexedCustomField: true
2066
+ };
2067
+ }
2068
+ };
2069
+
2070
+ //#endregion
2071
+ export { staleStoredKeys as a, keepKnownFields as i, content_exports as n, isSystemOrderField as r, ContentRepository as t };
2072
+ //# sourceMappingURL=content-CcHrqkgp.mjs.map