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
@@ -1,2063 +0,0 @@
1
- import { u as __exportAll } from "./runner-CskI4Hmq.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-zlGB5IQP.mjs";
9
- import { n as slugify } from "./slugify-T5GHH42D.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
- /**
250
- * Serialize a value for database storage
251
- * Objects/arrays are JSON-stringified
252
- * Booleans are converted to 0/1 for SQLite
253
- */
254
- function serializeValue(value) {
255
- if (value === null || value === void 0) return null;
256
- if (typeof value === "boolean") return value ? 1 : 0;
257
- if (typeof value === "object") return JSON.stringify(value);
258
- return value;
259
- }
260
- function writableContentData(data) {
261
- const writable = {};
262
- for (const [key, value] of Object.entries(data)) {
263
- if (SYSTEM_COLUMNS.has(key)) continue;
264
- validateIdentifier(key, "content field name");
265
- writable[key] = value;
266
- }
267
- return writable;
268
- }
269
- /**
270
- * Deserialize a value from database storage
271
- * Attempts to parse JSON strings that look like objects/arrays
272
- */
273
- function deserializeValue(value) {
274
- if (typeof value === "string") {
275
- if (value.startsWith("{") || value.startsWith("[")) try {
276
- return JSON.parse(value);
277
- } catch {
278
- return value;
279
- }
280
- }
281
- return value;
282
- }
283
- /** Pattern for escaping special regex characters */
284
- const REGEX_ESCAPE_PATTERN = /[.*+?^${}()|[\]\\]/g;
285
- /**
286
- * Escape special regex characters in a string for use in `new RegExp()`
287
- */
288
- function escapeRegExp(s) {
289
- return s.replace(REGEX_ESCAPE_PATTERN, "\\$&");
290
- }
291
- /**
292
- * Repository for content CRUD operations
293
- *
294
- * Content is stored in per-collection tables (ec_posts, ec_pages, etc.)
295
- * Each field becomes a real column in the table.
296
- */
297
- var ContentRepository = class {
298
- datetimes;
299
- constructor(db, datetimeContexts) {
300
- this.db = db;
301
- this.datetimeContexts = datetimeContexts;
302
- this.datetimes = new ContentDatetimeNormalizer(db, datetimeContexts);
303
- }
304
- /**
305
- * Create a new content item
306
- */
307
- async create(input) {
308
- const id = input.id ?? ulid();
309
- const now = (/* @__PURE__ */ new Date()).toISOString();
310
- const { type, slug, data: inputData, status = "draft", authorId, primaryBylineId, locale, translationOf, inheritFields = [], publishedAt, createdAt } = input;
311
- const data = await this.datetimes.normalizeInput(type, inputData);
312
- const normalizedCreatedAt = createdAt ? await this.datetimes.normalizeValue(type, createdAt) : now;
313
- const normalizedPublishedAt = publishedAt ? await this.datetimes.normalizeValue(type, publishedAt) : null;
314
- if (!type) throw new EmDashValidationError("Content type is required");
315
- const tableName = getTableName(type);
316
- const columns = [
317
- "id",
318
- "slug",
319
- "status",
320
- "author_id",
321
- "primary_byline_id",
322
- "created_at",
323
- "updated_at",
324
- "published_at",
325
- "version",
326
- "locale",
327
- "translation_group"
328
- ];
329
- const values = [
330
- id,
331
- slug || null,
332
- status,
333
- authorId || null,
334
- primaryBylineId ?? null,
335
- normalizedCreatedAt,
336
- now,
337
- normalizedPublishedAt,
338
- 1,
339
- locale || "en",
340
- id
341
- ];
342
- const inherited = new Set(inheritFields);
343
- for (const field of inherited) {
344
- validateIdentifier(field, "inherited content field name");
345
- if (!SYSTEM_COLUMNS.has(field) && !Object.hasOwn(data, field)) {
346
- columns.push(field);
347
- values.push(null);
348
- }
349
- }
350
- if (data && typeof data === "object") {
351
- for (const [key, value] of Object.entries(data)) if (!SYSTEM_COLUMNS.has(key)) {
352
- validateIdentifier(key, "content field name");
353
- columns.push(key);
354
- values.push(serializeValue(value));
355
- }
356
- }
357
- const columnRefs = columns.map((c) => sql.ref(c));
358
- const valuePlaceholders = values.map((value, index) => {
359
- const column = columns[index];
360
- if (translationOf && column === "translation_group") return sql`COALESCE(${sql.ref("translation_source.translation_group")}, ${sql.ref("translation_source.id")})`;
361
- if (translationOf && inherited.has(column)) return sql.ref(`translation_source.${column}`);
362
- return value === null ? sql`NULL` : sql`${value}`;
363
- });
364
- if (translationOf) await sql`
365
- INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
366
- SELECT ${sql.join(valuePlaceholders, sql`, `)}
367
- FROM ${sql.ref(tableName)} AS translation_source
368
- WHERE translation_source.id = ${translationOf}
369
- AND translation_source.deleted_at IS NULL
370
- `.execute(this.db);
371
- else await sql`
372
- INSERT INTO ${sql.ref(tableName)} (${sql.join(columnRefs, sql`, `)})
373
- VALUES (${sql.join(valuePlaceholders, sql`, `)})
374
- `.execute(this.db);
375
- invalidateCollectionCache(type);
376
- const item = await this.findById(type, id);
377
- if (!item) {
378
- if (translationOf) throw new EmDashValidationError("Translation source content not found");
379
- throw new Error("Failed to create content");
380
- }
381
- return item;
382
- }
383
- /**
384
- * Generate a unique slug for a content item within a collection.
385
- *
386
- * Checks the collection table for existing slugs that match `baseSlug`
387
- * (optionally scoped to a locale) and appends a numeric suffix (`-1`,
388
- * `-2`, etc.) on collision to guarantee uniqueness.
389
- *
390
- * Returns null when slug normalization cannot produce a value.
391
- */
392
- async generateUniqueSlug(type, text, locale) {
393
- const baseSlug = slugify(text);
394
- if (!baseSlug) return null;
395
- const tableName = getTableName(type);
396
- if ((locale ? await sql`
397
- SELECT slug FROM ${sql.ref(tableName)}
398
- WHERE slug = ${baseSlug}
399
- AND locale = ${locale}
400
- LIMIT 1
401
- `.execute(this.db) : await sql`
402
- SELECT slug FROM ${sql.ref(tableName)}
403
- WHERE slug = ${baseSlug}
404
- LIMIT 1
405
- `.execute(this.db)).rows.length === 0) return baseSlug;
406
- const pattern = `${baseSlug}-%`;
407
- const candidates = locale ? await sql`
408
- SELECT slug FROM ${sql.ref(tableName)}
409
- WHERE (slug = ${baseSlug} OR slug LIKE ${pattern})
410
- AND locale = ${locale}
411
- `.execute(this.db) : await sql`
412
- SELECT slug FROM ${sql.ref(tableName)}
413
- WHERE slug = ${baseSlug} OR slug LIKE ${pattern}
414
- `.execute(this.db);
415
- let maxSuffix = 0;
416
- const suffixPattern = new RegExp(`^${escapeRegExp(baseSlug)}-(\\d+)$`);
417
- for (const row of candidates.rows) {
418
- const match = suffixPattern.exec(row.slug);
419
- if (match) {
420
- const n = parseInt(match[1], 10);
421
- if (n > maxSuffix) maxSuffix = n;
422
- }
423
- }
424
- return `${baseSlug}-${maxSuffix + 1}`;
425
- }
426
- /**
427
- * Duplicate a content item
428
- * Creates a new draft copy with "(Copy)" appended to the title.
429
- * A slug is auto-generated from the new title by the handler layer.
430
- */
431
- async duplicate(type, id, authorId) {
432
- const original = await this.findById(type, id);
433
- if (!original) throw new EmDashValidationError("Content item not found");
434
- const newData = { ...original.data };
435
- if (typeof newData.title === "string") newData.title = `${newData.title} (Copy)`;
436
- else if (typeof newData.name === "string") newData.name = `${newData.name} (Copy)`;
437
- const slugSource = typeof newData.title === "string" ? newData.title : typeof newData.name === "string" ? newData.name : null;
438
- const slug = slugSource ? await this.generateUniqueSlug(type, slugSource, original.locale ?? void 0) : null;
439
- return this.create({
440
- type,
441
- slug,
442
- data: newData,
443
- status: "draft",
444
- authorId: authorId || original.authorId || void 0,
445
- locale: original.locale ?? void 0
446
- });
447
- }
448
- /**
449
- * Find content by ID
450
- */
451
- async findById(type, id) {
452
- const tableName = getTableName(type);
453
- const row = (await sql`
454
- SELECT * FROM ${sql.ref(tableName)}
455
- WHERE id = ${id}
456
- AND deleted_at IS NULL
457
- `.execute(this.db)).rows[0];
458
- if (!row) return null;
459
- return this.mapRow(type, row);
460
- }
461
- async findManyByIds(type, ids, options = {}) {
462
- const items = /* @__PURE__ */ new Map();
463
- if (ids.length === 0) return items;
464
- const tableName = getTableName(type);
465
- const deletedFilter = options.includeTrashed ? sql`` : sql`AND deleted_at IS NULL`;
466
- for (const batch of chunks([...new Set(ids)], SQL_BATCH_SIZE)) {
467
- const result = await sql`
468
- SELECT * FROM ${sql.ref(tableName)}
469
- WHERE id IN (${sql.join(batch)}) ${deletedFilter}
470
- `.execute(this.db);
471
- for (const row of result.rows) {
472
- const item = this.mapRow(type, row);
473
- items.set(item.id, item);
474
- }
475
- }
476
- return items;
477
- }
478
- async findManyBySlugsInLocale(type, slugs, locale, options = {}) {
479
- const items = /* @__PURE__ */ new Map();
480
- if (slugs.length === 0) return items;
481
- const tableName = getTableName(type);
482
- const deletedFilter = options.includeTrashed ? sql`` : sql`AND deleted_at IS NULL`;
483
- for (const batch of chunks([...new Set(slugs)], SQL_BATCH_SIZE)) {
484
- const result = await sql`
485
- SELECT * FROM ${sql.ref(tableName)}
486
- WHERE slug IN (${sql.join(batch)}) AND locale = ${locale} ${deletedFilter}
487
- `.execute(this.db);
488
- for (const row of result.rows) {
489
- const item = this.mapRow(type, row);
490
- if (item.slug !== null) items.set(item.slug, item);
491
- }
492
- }
493
- return items;
494
- }
495
- /**
496
- * Find content by id, including trashed (soft-deleted) items.
497
- * Used by restore endpoint for ownership checks.
498
- *
499
- * `deletedAt` rides along because the row is already in hand: a caller that
500
- * has to know whether the row is trashed before touching anything else would
501
- * otherwise pay a second read for a column this row already carries.
502
- */
503
- async findByIdIncludingTrashed(type, id) {
504
- const tableName = getTableName(type);
505
- const row = (await sql`
506
- SELECT * FROM ${sql.ref(tableName)}
507
- WHERE id = ${id}
508
- `.execute(this.db)).rows[0];
509
- if (!row) return null;
510
- return {
511
- ...this.mapRow(type, row),
512
- deletedAt: typeof row.deleted_at === "string" ? row.deleted_at : null
513
- };
514
- }
515
- /**
516
- * Find content by ID or slug. Tries ID first if it looks like a ULID,
517
- * otherwise tries slug. Falls back to the other if the first lookup misses.
518
- */
519
- async findByIdOrSlug(type, identifier, locale) {
520
- return this._findByIdOrSlug(type, identifier, false, locale);
521
- }
522
- /**
523
- * Find content by ID or slug, including trashed (soft-deleted) items.
524
- * Used by restore/permanent-delete endpoints.
525
- */
526
- async findByIdOrSlugIncludingTrashed(type, identifier, locale) {
527
- return this._findByIdOrSlug(type, identifier, true, locale);
528
- }
529
- async isTrashed(type, id) {
530
- const tableName = getTableName(type);
531
- return await this.db.selectFrom(tableName).select("id").where("id", "=", id).where("deleted_at", "is not", null).executeTakeFirst() !== void 0;
532
- }
533
- async _findByIdOrSlug(type, identifier, includeTrashed, locale) {
534
- const looksLikeUlid = ULID_PATTERN.test(identifier);
535
- const findById = includeTrashed ? (t, id) => this.findByIdIncludingTrashed(t, id) : (t, id) => this.findById(t, id);
536
- const findBySlug = includeTrashed ? (t, s) => this.findBySlugIncludingTrashed(t, s, locale) : (t, s) => this.findBySlug(t, s, locale);
537
- try {
538
- if (looksLikeUlid) {
539
- const byId = await findById(type, identifier);
540
- if (byId) return byId;
541
- return await findBySlug(type, identifier);
542
- }
543
- const bySlug = await findBySlug(type, identifier);
544
- if (bySlug) return bySlug;
545
- return await findById(type, identifier);
546
- } catch (error) {
547
- if (isMissingTableError(error)) return null;
548
- throw error;
549
- }
550
- }
551
- /**
552
- * Find content by slug
553
- */
554
- async findBySlug(type, slug, locale) {
555
- const tableName = getTableName(type);
556
- const row = (locale ? await sql`
557
- SELECT * FROM ${sql.ref(tableName)}
558
- WHERE slug = ${slug}
559
- AND locale = ${locale}
560
- AND deleted_at IS NULL
561
- `.execute(this.db) : await sql`
562
- SELECT * FROM ${sql.ref(tableName)}
563
- WHERE slug = ${slug}
564
- AND deleted_at IS NULL
565
- ORDER BY locale ASC
566
- LIMIT 1
567
- `.execute(this.db)).rows[0];
568
- if (!row) return null;
569
- return this.mapRow(type, row);
570
- }
571
- /**
572
- * Find content by slug, including trashed (soft-deleted) items.
573
- * Used by restore/permanent-delete endpoints.
574
- */
575
- async findBySlugIncludingTrashed(type, slug, locale) {
576
- const tableName = getTableName(type);
577
- const row = (locale ? await sql`
578
- SELECT * FROM ${sql.ref(tableName)}
579
- WHERE slug = ${slug}
580
- AND locale = ${locale}
581
- `.execute(this.db) : await sql`
582
- SELECT * FROM ${sql.ref(tableName)}
583
- WHERE slug = ${slug}
584
- ORDER BY locale ASC
585
- LIMIT 1
586
- `.execute(this.db)).rows[0];
587
- if (!row) return null;
588
- return this.mapRow(type, row);
589
- }
590
- /**
591
- * Find many content items with filtering and pagination
592
- */
593
- async findMany(type, options = {}) {
594
- const tableName = getTableName(type);
595
- const limit = Math.max(1, Math.min(options.limit || 50, 100));
596
- const orderField = options.orderBy?.field || "createdAt";
597
- const orderDirection = options.orderBy?.direction || "desc";
598
- const resolvedOrderField = await this.resolveOrderField(type, orderField, options.sortableExtras);
599
- const dbField = resolvedOrderField.column;
600
- const nullableOrder = resolvedOrderField.indexedCustomField || !NON_NULL_ORDER_COLUMNS.has(dbField);
601
- const resolvedFieldFilters = await this.resolveFieldFilters(type, options.where?.fieldFilters);
602
- const safeOrderDirection = orderDirection.toLowerCase() === "asc" ? "ASC" : "DESC";
603
- let query = this.db.selectFrom(tableName).selectAll().where("deleted_at", "is", null);
604
- if (options.where?.status) query = query.where("status", "=", options.where.status);
605
- if (options.where?.authorId) query = query.where("author_id", "=", options.where.authorId);
606
- if (options.where?.locale) query = query.where("locale", "=", options.where.locale);
607
- query = this.applySearchFilter(query, options.where, type);
608
- query = this.applyDateFilter(query, options.where);
609
- query = this.applyBylineFilter(query, options.where, type);
610
- query = this.applyFieldFilters(query, resolvedFieldFilters);
611
- if (options.cursor) if (resolvedOrderField.indexedCustomField) {
612
- const { value, id: cursorId } = decodeNullableOrderCursor(options.cursor, orderField);
613
- const isPresent = sql`${sql.ref(dbField)} IS NOT NULL`;
614
- const falseLiteral = sql`FALSE`;
615
- const trueLiteral = sql`TRUE`;
616
- if (safeOrderDirection === "ASC" && value === null) query = query.where(sql`(
617
- (${isPresent}) > ${falseLiteral}
618
- OR ((${isPresent}) = ${falseLiteral} AND ${sql.ref("id")} > ${cursorId})
619
- )`);
620
- else if (safeOrderDirection === "DESC" && value === null) query = query.where(sql`
621
- (${isPresent}) = ${falseLiteral} AND ${sql.ref("id")} < ${cursorId}
622
- `);
623
- else if (safeOrderDirection === "ASC") query = query.where(sql`
624
- (${isPresent}, ${sql.ref(dbField)}, ${sql.ref("id")})
625
- > (${trueLiteral}, ${value}, ${cursorId})
626
- `);
627
- else query = query.where(sql`
628
- (${isPresent}, ${sql.ref(dbField)}, ${sql.ref("id")})
629
- < (${trueLiteral}, ${value}, ${cursorId})
630
- `);
631
- } else if (nullableOrder) {
632
- const { value, id: cursorId } = decodeNullableOrderCursor(options.cursor, orderField, { acceptPlain: true });
633
- query = query.where(nullableOrderCondition(this.db, dbField, safeOrderDirection, value, cursorId));
634
- } else {
635
- const { orderValue, id: cursorId } = decodeCursor(options.cursor);
636
- if (safeOrderDirection === "DESC") query = query.where((eb) => eb.or([eb(dbField, "<", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", "<", cursorId)])]));
637
- else query = query.where((eb) => eb.or([eb(dbField, ">", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", ">", cursorId)])]));
638
- }
639
- const indexedOrderFilter = resolvedOrderField.indexedCustomField ? resolvedFieldFilters.find((filter) => filter.column === dbField) : void 0;
640
- if (resolvedOrderField.indexedCustomField && !indexedOrderFilter) query = query.orderBy(sql`${sql.ref(dbField)} IS NOT NULL`, safeOrderDirection === "ASC" ? "asc" : "desc");
641
- if (indexedOrderFilter?.kind !== "null") query = query.orderBy(dbField, safeOrderDirection === "ASC" ? "asc" : "desc");
642
- query = query.orderBy("id", safeOrderDirection === "ASC" ? "asc" : "desc").limit(limit + 1);
643
- const [rowsResult, countResult] = await Promise.allSettled([query.execute(), this.countWithResolvedFilters(type, options.where, resolvedFieldFilters)]);
644
- if (rowsResult.status === "rejected") throw rowsResult.reason;
645
- if (countResult.status === "rejected") throw countResult.reason;
646
- const rows = rowsResult.value;
647
- const total = countResult.value;
648
- const hasMore = rows.length > limit;
649
- const items = rows.slice(0, limit);
650
- const mappedResult = {
651
- items: items.map((row) => this.mapRow(type, row)),
652
- total
653
- };
654
- if (hasMore && items.length > 0) {
655
- const lastRow = items.at(-1);
656
- const lastOrderValue = lastRow[dbField];
657
- if (nullableOrder) {
658
- if (lastOrderValue !== null && typeof lastOrderValue !== "string" && typeof lastOrderValue !== "number") throw new EmDashValidationError(`Invalid value for order field: ${orderField}`);
659
- mappedResult.nextCursor = encodeNullableOrderCursor(orderField, lastOrderValue, String(lastRow.id));
660
- } else mappedResult.nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
661
- }
662
- return mappedResult;
663
- }
664
- /**
665
- * Update content
666
- */
667
- async update(type, id, input) {
668
- const tableName = getTableName(type);
669
- const now = (/* @__PURE__ */ new Date()).toISOString();
670
- const updates = {};
671
- if (input.status !== void 0) updates.status = input.status;
672
- if (input.slug !== void 0) updates.slug = input.slug;
673
- if (input.publishedAt !== void 0) updates.published_at = input.publishedAt === null ? null : await this.datetimes.normalizeValue(type, input.publishedAt);
674
- if (input.scheduledAt !== void 0) updates.scheduled_at = input.scheduledAt === null ? null : await this.datetimes.normalizeValue(type, input.scheduledAt);
675
- if (input.authorId !== void 0) updates.author_id = input.authorId;
676
- if (input.primaryBylineId !== void 0) updates.primary_byline_id = input.primaryBylineId;
677
- if (input.data !== void 0 && typeof input.data === "object") {
678
- const data = await this.datetimes.normalizeInput(type, writableContentData(input.data));
679
- for (const [key, value] of Object.entries(data)) updates[key] = serializeValue(value);
680
- }
681
- const hasColumnWrites = Object.keys(updates).length > 0;
682
- if (hasColumnWrites) updates.updated_at = now;
683
- updates.version = sql`version + 1`;
684
- await this.db.updateTable(tableName).set(updates).where("id", "=", id).where("deleted_at", "is", null).execute();
685
- if (hasColumnWrites) invalidateCollectionCache(type);
686
- const updated = await this.findById(type, id);
687
- if (!updated) throw new Error("Content not found");
688
- return updated;
689
- }
690
- async restoreRevision(type, id, revisionData, authorId) {
691
- const tableName = getTableName(type);
692
- const existing = await this.findById(type, id);
693
- if (!existing) throw new EmDashValidationError("Content item not found");
694
- const normalizedSnapshot = await this.datetimes.normalizeData(type, revisionData);
695
- const { _slug } = normalizedSnapshot;
696
- const snapshotFields = {};
697
- for (const [key, value] of Object.entries(normalizedSnapshot)) if (!key.startsWith("_")) snapshotFields[key] = value;
698
- const fieldData = writableContentData(snapshotFields);
699
- const revisionId = createRevisionId();
700
- const now = (/* @__PURE__ */ new Date()).toISOString();
701
- const assignments = [];
702
- if (typeof _slug === "string") assignments.push(sql`slug = ${_slug}`);
703
- for (const [field, value] of Object.entries(fieldData)) {
704
- validateIdentifier(field, "content field name");
705
- assignments.push(sql`${sql.ref(field)} = ${serializeValue(value)}`);
706
- }
707
- assignments.push(sql`draft_revision_id = ${revisionId}`, sql`updated_at = ${now}`, sql`version = version + 1`);
708
- const buildQueries = () => {
709
- return [
710
- sql`
711
- INSERT INTO revisions (id, collection, entry_id, data, author_id)
712
- VALUES (${revisionId}, ${type}, ${id}, ${JSON.stringify(normalizedSnapshot)}, ${authorId})
713
- RETURNING id
714
- `,
715
- sql`
716
- UPDATE ${sql.ref(tableName)}
717
- SET ${sql.join(assignments, sql`, `)}
718
- WHERE id = ${id}
719
- AND deleted_at IS NULL
720
- AND version = ${existing.version}
721
- AND updated_at = ${existing.updatedAt}
722
- AND status = ${existing.status}
723
- AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
724
- AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
725
- AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
726
- RETURNING id
727
- `,
728
- sql`
729
- DELETE FROM revisions
730
- WHERE id = ${revisionId}
731
- AND NOT EXISTS (
732
- SELECT 1 FROM ${sql.ref(tableName)}
733
- WHERE id = ${id}
734
- AND draft_revision_id = ${revisionId}
735
- AND version = ${existing.version + 1}
736
- )
737
- `,
738
- sql`
739
- UPDATE ${sql.ref(tableName)}
740
- SET draft_revision_id = ${existing.draftRevisionId}
741
- WHERE id = ${id}
742
- AND draft_revision_id = ${revisionId}
743
- AND version = ${existing.version + 1}
744
- RETURNING id
745
- `
746
- ];
747
- };
748
- const batched = await executeAtomicBatchIfSupported(this.db, buildQueries());
749
- if (batched) {
750
- if (batched[0]?.rows.length !== 1 || batched[1]?.rows.length !== 1 || batched[3]?.rows.length !== 1) throw new ContentMutationConflictError();
751
- } else await withTransaction(this.db, async (trx) => {
752
- const [audit, update, removeUnappliedAudit, releaseMarker] = buildQueries();
753
- if ((await audit.execute(trx)).rows.length !== 1) throw new ContentMutationConflictError();
754
- const updateResult = await update.execute(trx);
755
- await removeUnappliedAudit.execute(trx);
756
- const releaseResult = await releaseMarker.execute(trx);
757
- if (updateResult.rows.length !== 1 || releaseResult.rows.length !== 1) throw new ContentMutationConflictError();
758
- });
759
- invalidateCollectionCache(type);
760
- const item = await this.findById(type, id);
761
- if (!item) throw new Error("Content not found");
762
- await new RevisionRepository(this.db, this.datetimeContexts).queuePruning(type, id, revisionId);
763
- return {
764
- item,
765
- revisionId
766
- };
767
- }
768
- async restoreDraftRevision(type, id, revisionData, authorId) {
769
- const tableName = getTableName(type);
770
- const existing = await this.findById(type, id);
771
- if (!existing) return null;
772
- const normalizedSnapshot = await this.datetimes.normalizeData(type, revisionData);
773
- const revisionId = createRevisionId();
774
- const buildQueries = () => {
775
- return [
776
- sql`
777
- INSERT INTO revisions (id, collection, entry_id, data, author_id)
778
- VALUES (${revisionId}, ${type}, ${id}, ${JSON.stringify(normalizedSnapshot)}, ${authorId})
779
- RETURNING id
780
- `,
781
- sql`
782
- UPDATE ${sql.ref(tableName)}
783
- SET draft_revision_id = ${revisionId},
784
- version = version + 1
785
- WHERE id = ${id}
786
- AND deleted_at IS NULL
787
- AND version = ${existing.version}
788
- AND updated_at = ${existing.updatedAt}
789
- AND status = ${existing.status}
790
- AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
791
- AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
792
- AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
793
- RETURNING id
794
- `,
795
- sql`
796
- DELETE FROM revisions
797
- WHERE id = ${revisionId}
798
- AND NOT EXISTS (
799
- SELECT 1 FROM ${sql.ref(tableName)}
800
- WHERE id = ${id}
801
- AND draft_revision_id = ${revisionId}
802
- AND version = ${existing.version + 1}
803
- )
804
- `
805
- ];
806
- };
807
- const batched = await executeAtomicBatchIfSupported(this.db, buildQueries());
808
- if (batched) {
809
- if (batched[0]?.rows.length !== 1 || batched[1]?.rows.length !== 1) throw new ContentMutationConflictError();
810
- } else await withTransaction(this.db, async (trx) => {
811
- const [audit, stage, removeUnstagedAudit] = buildQueries();
812
- if ((await audit.execute(trx)).rows.length !== 1) throw new ContentMutationConflictError();
813
- const stageResult = await stage.execute(trx);
814
- await removeUnstagedAudit.execute(trx);
815
- if (stageResult.rows.length !== 1) throw new ContentMutationConflictError();
816
- });
817
- invalidateCollectionCache(type);
818
- await new RevisionRepository(this.db, this.datetimeContexts).queuePruning(type, id, revisionId);
819
- return revisionId;
820
- }
821
- /**
822
- * Update plugin-authored fields without letting content columns diverge
823
- * from the revision pointers that publication promotes.
824
- */
825
- async updateDraftAware(type, id, input) {
826
- const data = input.data ? await this.datetimes.normalizeInput(type, writableContentData(input.data)) : {};
827
- const stagedSlug = typeof input.slug === "string" ? input.slug : void 0;
828
- if (!(Object.keys(data).length > 0 || stagedSlug !== void 0)) return this.update(type, id, {
829
- ...input,
830
- data
831
- });
832
- 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();
833
- const supportsRaw = collectionRows[0]?.supports;
834
- const supports = supportsRaw ? JSON.parse(supportsRaw) : [];
835
- if (!Array.isArray(supports) || !supports.includes("revisions")) return this.update(type, id, {
836
- ...input,
837
- data
838
- });
839
- const fieldSlugs = new Set(collectionRows.map((row) => row.fieldSlug).filter((slug) => Boolean(slug)));
840
- const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
841
- let existing = await this.findById(type, id);
842
- let incoming = data;
843
- if (existing) {
844
- let stored = existing.data ?? {};
845
- if (existing.draftRevisionId) {
846
- const draft = await revisionRepo.findById(existing.draftRevisionId);
847
- if (draft?.data) stored = draft.data;
848
- }
849
- const stale = staleStoredKeys(data, stored, fieldSlugs);
850
- if (stale.length > 0) {
851
- incoming = { ...data };
852
- for (const key of stale) delete incoming[key];
853
- }
854
- }
855
- for (const field of Object.keys(incoming)) if (!fieldSlugs.has(field)) throw new EmDashValidationError(`Unknown field '${field}' in collection '${type}'`);
856
- for (let attempt = 0; existing && attempt < MAX_DRAFT_STAGE_ATTEMPTS; attempt++) {
857
- let baseData = existing.data;
858
- if (existing.draftRevisionId) {
859
- const draft = await revisionRepo.findById(existing.draftRevisionId);
860
- if (draft) baseData = draft.data;
861
- }
862
- const mergedData = keepKnownFields({
863
- ...baseData,
864
- ...incoming
865
- }, fieldSlugs);
866
- if (stagedSlug !== void 0) mergedData._slug = stagedSlug;
867
- const revision = await revisionRepo.create({
868
- collection: type,
869
- entryId: id,
870
- data: mergedData,
871
- ...input.revisionAuthorId ? { authorId: input.revisionAuthorId } : {}
872
- });
873
- let staged;
874
- try {
875
- staged = await this.replaceDraftRevisionForUpdate(type, id, revision.id, existing, input);
876
- } catch (error) {
877
- await this.deleteUnstagedRevision(revisionRepo, type, id, revision.id);
878
- throw error;
879
- }
880
- if (staged) {
881
- const updated = await this.findById(type, id);
882
- if (!updated) throw new Error("Content not found");
883
- const draftData = {};
884
- for (const [key, value] of Object.entries(mergedData)) if (!key.startsWith("_")) draftData[key] = value;
885
- return {
886
- ...updated,
887
- data: {
888
- ...updated.data,
889
- ...draftData
890
- }
891
- };
892
- }
893
- await this.deleteUnstagedRevision(revisionRepo, type, id, revision.id);
894
- existing = await this.findById(type, id);
895
- }
896
- if (!existing) throw new Error("Content not found");
897
- throw new ContentMutationConflictError();
898
- }
899
- async deleteUnstagedRevision(revisionRepo, type, id, revisionId) {
900
- try {
901
- await revisionRepo.deleteIfUnreferenced(type, id, revisionId);
902
- } catch (error) {
903
- console.error(`[content] Failed to clean up unstaged revision ${revisionId}:`, error);
904
- }
905
- }
906
- async replaceDraftRevisionForUpdate(type, id, revisionId, expected, input) {
907
- const tableName = getTableName(type);
908
- const assignments = [sql`draft_revision_id = ${revisionId}`];
909
- let liveMetadataChanged = false;
910
- if (input.status !== void 0) {
911
- assignments.push(sql`status = ${input.status}`);
912
- liveMetadataChanged = true;
913
- }
914
- if (input.slug === null) {
915
- assignments.push(sql`slug = NULL`);
916
- liveMetadataChanged = true;
917
- }
918
- if (input.publishedAt !== void 0) {
919
- const publishedAt = input.publishedAt === null ? null : await this.datetimes.normalizeValue(type, input.publishedAt);
920
- assignments.push(sql`published_at = ${publishedAt}`);
921
- liveMetadataChanged = true;
922
- }
923
- if (input.scheduledAt !== void 0) {
924
- const scheduledAt = input.scheduledAt === null ? null : await this.datetimes.normalizeValue(type, input.scheduledAt);
925
- assignments.push(sql`scheduled_at = ${scheduledAt}`);
926
- liveMetadataChanged = true;
927
- }
928
- if (input.authorId !== void 0) {
929
- assignments.push(sql`author_id = ${input.authorId}`);
930
- liveMetadataChanged = true;
931
- }
932
- if (input.primaryBylineId !== void 0) {
933
- assignments.push(sql`primary_byline_id = ${input.primaryBylineId}`);
934
- liveMetadataChanged = true;
935
- }
936
- if (liveMetadataChanged) assignments.push(sql`updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}`);
937
- assignments.push(sql`version = version + 1`);
938
- const changed = ((await sql`
939
- UPDATE ${sql.ref(tableName)}
940
- SET ${sql.join(assignments, sql`, `)}
941
- WHERE id = ${id}
942
- AND deleted_at IS NULL
943
- AND version = ${expected.version}
944
- AND ${nullableColumnMatch("live_revision_id", expected.liveRevisionId)}
945
- AND ${nullableColumnMatch("draft_revision_id", expected.draftRevisionId)}
946
- AND EXISTS (
947
- SELECT 1 FROM revisions
948
- WHERE revisions.id = ${revisionId}
949
- AND revisions.collection = ${type}
950
- AND revisions.entry_id = ${id}
951
- )
952
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
953
- if (changed && liveMetadataChanged) invalidateCollectionCache(type);
954
- return changed;
955
- }
956
- /**
957
- * Copy non-translatable field values to every other entry in the
958
- * translation group, trashed entries included.
959
- *
960
- * Only the fields present in `data` are copied. With `previous`, `data` is
961
- * the entry's complete new state and only the fields whose value differs
962
- * from `previous` are copied, an absent field as null. An entry that already
963
- * holds every copied value is left untouched, so its `updated_at` does not
964
- * move.
965
- *
966
- * On collections with revisions a changed entry also gets a new live
967
- * revision, because republishing and unpublishing read that revision rather
968
- * than the columns. A pending draft takes a value only where it still holds
969
- * the entry's previous value, so an unpublished edit to the field survives.
970
- */
971
- async syncNonTranslatableFields(type, sourceId, translationGroup, data, options = {}) {
972
- const tableName = getTableName(type);
973
- 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();
974
- const { previous } = options;
975
- const values = {};
976
- for (const { fieldSlug } of collectionRows) {
977
- if (!fieldSlug) continue;
978
- if (previous) {
979
- if (!sameStoredValue(previous[fieldSlug], data[fieldSlug])) values[fieldSlug] = data[fieldSlug] ?? null;
980
- } else if (fieldSlug in data) values[fieldSlug] = data[fieldSlug];
981
- }
982
- if (Object.keys(values).length === 0) return;
983
- const normalizedValues = await this.datetimes.normalizeData(type, values);
984
- const supportsRaw = collectionRows[0]?.supports;
985
- const supports = supportsRaw ? JSON.parse(supportsRaw) : [];
986
- const usesRevisions = Array.isArray(supports) && supports.includes("revisions");
987
- const siblings = await sql`
988
- SELECT * FROM ${sql.ref(tableName)}
989
- WHERE translation_group = ${translationGroup}
990
- AND id != ${sourceId}
991
- `.execute(this.db);
992
- let changed = false;
993
- for (const row of siblings.rows) if (await this.syncSiblingValues(type, this.mapRow(type, row), normalizedValues, usesRevisions)) changed = true;
994
- if (changed) invalidateCollectionCache(type);
995
- }
996
- async syncSiblingValues(type, initial, values, usesRevisions) {
997
- const tableName = getTableName(type);
998
- const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
999
- let sibling = initial;
1000
- for (let attempt = 0; sibling && attempt < MAX_DRAFT_STAGE_ATTEMPTS; attempt++) {
1001
- const current = sibling;
1002
- const changed = {};
1003
- for (const [field, value] of Object.entries(values)) if (!sameStoredValue(current.data[field], value)) changed[field] = value;
1004
- if (Object.keys(changed).length === 0) return false;
1005
- const assignments = [];
1006
- for (const [field, value] of Object.entries(changed)) {
1007
- validateIdentifier(field, "content field name");
1008
- assignments.push(sql`${sql.ref(field)} = ${serializeValue(value)}`);
1009
- }
1010
- const createdRevisionIds = [];
1011
- const cleanUp = async () => {
1012
- for (const revisionId of createdRevisionIds) await this.deleteUnstagedRevision(revisionRepo, type, current.id, revisionId);
1013
- };
1014
- let synced;
1015
- try {
1016
- const live = usesRevisions && current.liveRevisionId ? await revisionRepo.findById(current.liveRevisionId) : null;
1017
- if (live) {
1018
- const revision = await revisionRepo.create({
1019
- collection: type,
1020
- entryId: current.id,
1021
- data: {
1022
- ...live.data,
1023
- ...changed
1024
- }
1025
- });
1026
- createdRevisionIds.push(revision.id);
1027
- assignments.push(sql`live_revision_id = ${revision.id}`);
1028
- }
1029
- const draft = usesRevisions && current.draftRevisionId ? await revisionRepo.findById(current.draftRevisionId) : null;
1030
- const carried = {};
1031
- for (const [field, value] of Object.entries(changed)) if (draft && sameStoredValue(draft.data[field], current.data[field])) carried[field] = value;
1032
- if (draft && Object.keys(carried).length > 0) {
1033
- const revision = await revisionRepo.create({
1034
- collection: type,
1035
- entryId: current.id,
1036
- data: {
1037
- ...draft.data,
1038
- ...carried
1039
- }
1040
- });
1041
- createdRevisionIds.push(revision.id);
1042
- assignments.push(sql`draft_revision_id = ${revision.id}`);
1043
- }
1044
- assignments.push(sql`updated_at = ${(/* @__PURE__ */ new Date()).toISOString()}`, sql`version = version + 1`);
1045
- synced = ((await sql`
1046
- UPDATE ${sql.ref(tableName)}
1047
- SET ${sql.join(assignments, sql`, `)}
1048
- WHERE id = ${current.id}
1049
- AND version = ${current.version}
1050
- AND ${nullableColumnMatch("live_revision_id", current.liveRevisionId)}
1051
- AND ${nullableColumnMatch("draft_revision_id", current.draftRevisionId)}
1052
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1053
- } catch (error) {
1054
- await cleanUp();
1055
- throw error;
1056
- }
1057
- if (synced) return true;
1058
- await cleanUp();
1059
- sibling = await this.findByIdIncludingTrashed(type, current.id);
1060
- }
1061
- if (!sibling) return false;
1062
- throw new ContentMutationConflictError();
1063
- }
1064
- /**
1065
- * Delete content (soft delete - moves to trash)
1066
- */
1067
- async delete(type, id) {
1068
- const tableName = getTableName(type);
1069
- const now = (/* @__PURE__ */ new Date()).toISOString();
1070
- const changed = ((await sql`
1071
- UPDATE ${sql.ref(tableName)}
1072
- SET deleted_at = ${now}
1073
- WHERE id = ${id}
1074
- AND deleted_at IS NULL
1075
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1076
- if (changed) invalidateCollectionCache(type);
1077
- return changed;
1078
- }
1079
- /**
1080
- * Restore content from trash
1081
- *
1082
- * The entry comes back as a draft with no schedule. The live version is not
1083
- * copied into a draft revision: collections without revisions save to the
1084
- * columns, and a draft revision would hide those saves.
1085
- */
1086
- async restore(type, id, expectedRevision) {
1087
- const tableName = getTableName(type);
1088
- const existing = await this.findByIdOrSlugIncludingTrashed(type, id);
1089
- if (!existing) return null;
1090
- assertRevisionPrecondition(existing, expectedRevision);
1091
- const now = (/* @__PURE__ */ new Date()).toISOString();
1092
- const restored = (await sql`
1093
- UPDATE ${sql.ref(tableName)}
1094
- SET deleted_at = NULL,
1095
- live_revision_id = NULL,
1096
- status = 'draft',
1097
- scheduled_at = NULL,
1098
- updated_at = ${now},
1099
- version = ${existing.version + 1}
1100
- WHERE id = ${existing.id}
1101
- AND deleted_at IS NOT NULL
1102
- AND version = ${existing.version}
1103
- AND updated_at = ${existing.updatedAt}
1104
- RETURNING *
1105
- `.execute(this.db)).rows[0];
1106
- if (!restored) throw new ContentMutationConflictError("Content changed while restoring");
1107
- invalidateCollectionCache(type);
1108
- return this.mapRow(type, restored);
1109
- }
1110
- /**
1111
- * Permanently delete content (cannot be undone)
1112
- */
1113
- /**
1114
- * Permanently delete a soft-deleted content row.
1115
- *
1116
- * Returns `true` only when a soft-deleted (trashed) row was removed.
1117
- * Returns `false` when no row exists OR when the row exists but is live —
1118
- * the caller is responsible for distinguishing these cases (typically via
1119
- * a follow-up `findByIdOrSlugIncludingTrashed` to surface NOT_FOUND vs
1120
- * NOT_TRASHED). The `AND deleted_at IS NOT NULL` clause is the safety net
1121
- * that prevents permanent delete from bypassing the trash workflow.
1122
- */
1123
- async permanentDelete(type, id) {
1124
- const tableName = getTableName(type);
1125
- const changed = ((await sql`
1126
- DELETE FROM ${sql.ref(tableName)}
1127
- WHERE id = ${id}
1128
- AND deleted_at IS NOT NULL
1129
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1130
- if (changed) invalidateCollectionCache(type);
1131
- return changed;
1132
- }
1133
- /**
1134
- * Find trashed content items
1135
- */
1136
- async findTrashed(type, options = {}) {
1137
- const tableName = getTableName(type);
1138
- const limit = Math.max(1, Math.min(options.limit || 50, 100));
1139
- const orderField = options.orderBy?.field || "deletedAt";
1140
- const orderDirection = options.orderBy?.direction || "desc";
1141
- const dbField = this.mapOrderField(orderField);
1142
- const safeOrderDirection = orderDirection.toLowerCase() === "asc" ? "ASC" : "DESC";
1143
- let query = this.db.selectFrom(tableName).selectAll().where("deleted_at", "is not", null);
1144
- if (options.where?.locale) query = query.where("locale", "=", options.where.locale);
1145
- if (options.cursor) {
1146
- const { orderValue, id: cursorId } = decodeCursor(options.cursor);
1147
- if (safeOrderDirection === "DESC") query = query.where((eb) => eb.or([eb(dbField, "<", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", "<", cursorId)])]));
1148
- else query = query.where((eb) => eb.or([eb(dbField, ">", orderValue), eb.and([eb(dbField, "=", orderValue), eb("id", ">", cursorId)])]));
1149
- }
1150
- query = query.orderBy(dbField, safeOrderDirection === "ASC" ? "asc" : "desc").orderBy("id", safeOrderDirection === "ASC" ? "asc" : "desc").limit(limit + 1);
1151
- const rows = await query.execute();
1152
- const hasMore = rows.length > limit;
1153
- const items = rows.slice(0, limit);
1154
- const mappedResult = { items: items.map((row) => {
1155
- const record = row;
1156
- return {
1157
- ...this.mapRow(type, record),
1158
- deletedAt: typeof record.deleted_at === "string" ? record.deleted_at : ""
1159
- };
1160
- }) };
1161
- if (hasMore && items.length > 0) {
1162
- const lastRow = items.at(-1);
1163
- const lastOrderValue = lastRow[dbField];
1164
- mappedResult.nextCursor = encodeCursor(typeof lastOrderValue === "string" || typeof lastOrderValue === "number" ? String(lastOrderValue) : "", String(lastRow.id));
1165
- }
1166
- return mappedResult;
1167
- }
1168
- /**
1169
- * Count trashed content items
1170
- */
1171
- async countTrashed(type, options = {}) {
1172
- const tableName = getTableName(type);
1173
- let query = this.db.selectFrom(tableName).select((eb) => eb.fn.count("id").as("count")).where("deleted_at", "is not", null);
1174
- if (options.locale) query = query.where("locale", "=", options.locale);
1175
- const result = await query.executeTakeFirst();
1176
- return Number(result?.count || 0);
1177
- }
1178
- /**
1179
- * Apply the optional `q` filter.
1180
- *
1181
- * When the handler sets `useFts` (collection has a healthy FTS5 index
1182
- * covering the display columns; SQLite only), the filter is served from
1183
- * the index: a token-prefix MATCH against `_emdash_fts_<slug>` OR'd with
1184
- * an index-served `slug GLOB 'term*'` prefix (the slug is not in the FTS
1185
- * index). Both sides are index-backed, so SQLite's OR optimization avoids
1186
- * the full-table scan the LIKE fallback needs (#1517). The trade-off is
1187
- * search semantics: token-prefix matching instead of arbitrary substring.
1188
- *
1189
- * Fallback (Postgres, search disabled, or no usable terms): case-
1190
- * insensitive substring LIKE across the handler-resolved `searchColumns`
1191
- * (OR'd). User input is treated literally (LIKE wildcards escaped) and
1192
- * `lower()` is applied on both sides for SQLite/Postgres parity.
1193
- */
1194
- applySearchFilter(query, where, type) {
1195
- const term = where?.q?.trim();
1196
- const columns = where?.searchColumns;
1197
- if (!term || !columns || columns.length === 0) return query;
1198
- if (where.useFts) {
1199
- const match = buildFtsPrefixMatch(term);
1200
- if (match) {
1201
- validateIdentifier(type, "collection slug");
1202
- const ftsTable = `_emdash_fts_${type}`;
1203
- const slugPrefix = buildSlugGlobPrefix(term);
1204
- 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}`]));
1205
- }
1206
- }
1207
- const pattern = `%${term.replace(LIKE_WILDCARD_RE, (c) => `\\${c}`)}%`;
1208
- return query.where((eb) => eb.or(columns.map((col) => {
1209
- validateIdentifier(col, "search column");
1210
- return sql`lower(CAST(${sql.ref(col)} AS TEXT)) LIKE lower(${pattern}) ESCAPE '\\'`;
1211
- })));
1212
- }
1213
- /**
1214
- * Apply the optional inclusive date-range filter. The field is mapped
1215
- * through `DATE_FILTER_COLUMNS` (a closed whitelist), and bounds compare
1216
- * lexicographically against the stored ISO 8601 timestamps. A `publishedAt`
1217
- * range naturally excludes never-published rows (their column is NULL).
1218
- */
1219
- applyDateFilter(query, where) {
1220
- const filter = where?.dateFilter;
1221
- if (!filter) return query;
1222
- const column = DATE_FILTER_COLUMNS[filter.field];
1223
- if (!column) throw new EmDashValidationError(`Invalid date filter field: ${filter.field}`);
1224
- const { from, to } = filter;
1225
- if (!from && !to) return query;
1226
- let next = query;
1227
- if (from) next = next.where((eb) => eb(column, ">=", from));
1228
- if (to) next = next.where((eb) => eb(column, "<=", to));
1229
- return next;
1230
- }
1231
- /**
1232
- * Apply the optional byline filter as a correlated (NOT) EXISTS against
1233
- * `_emdash_content_bylines`.
1234
- *
1235
- * Correlating from the content table preserves the outer sort index so
1236
- * `LIMIT` can short-circuit. `mode: "none"` tests the junction rather than
1237
- * `primary_byline_id` because the two are written in the same call but
1238
- * are not atomically consistent, so the junction is authoritative.
1239
- *
1240
- * Whether a credit *renders* is locale-scoped; whether one *exists* is
1241
- * not. Both are needed: the first decides what the filter matches, the
1242
- * second decides whether the author fallback applies at all.
1243
- */
1244
- applyBylineFilter(query, where, type) {
1245
- const filter = where?.bylineFilter;
1246
- if (!filter) return query;
1247
- const tableName = getTableName(type);
1248
- const idColumn = `${tableName}.id`;
1249
- const authorColumn = `${tableName}.author_id`;
1250
- const localeColumn = `${tableName}.locale`;
1251
- const creditRenders = (eb, bylineIds) => {
1252
- 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);
1253
- sub = filter.locale ? sub.where("b.locale", "=", filter.locale) : sub.whereRef("b.locale", "=", localeColumn);
1254
- if (bylineIds) sub = sub.where("cb.byline_id", "in", bylineIds);
1255
- return eb.exists(sub);
1256
- };
1257
- 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));
1258
- const authorHasByline = (eb, bylineIds) => {
1259
- let sub = eb.selectFrom("_emdash_bylines as b").select("b.id").whereRef("b.user_id", "=", authorColumn);
1260
- sub = filter.locale ? sub.where("b.locale", "=", filter.locale) : sub.whereRef("b.locale", "=", localeColumn);
1261
- if (bylineIds) sub = sub.where("b.translation_group", "in", bylineIds);
1262
- return eb.exists(sub);
1263
- };
1264
- if (filter.mode === "none") return query.where((eb) => {
1265
- const uncredited = eb.not(creditRenders(eb));
1266
- return filter.includeInferred ? eb.and([uncredited, eb.or([hasExplicitCredit(eb), eb.not(authorHasByline(eb))])]) : uncredited;
1267
- });
1268
- const bylineIds = filter.bylineIds ?? [];
1269
- if (bylineIds.length === 0) return query.where(() => sql`1 = 0`);
1270
- return query.where((eb) => {
1271
- if (!filter.includeInferred) return creditRenders(eb, bylineIds);
1272
- return eb.or([creditRenders(eb, bylineIds), eb.and([eb.not(hasExplicitCredit(eb)), authorHasByline(eb, bylineIds)])]);
1273
- });
1274
- }
1275
- /**
1276
- * Count content items
1277
- */
1278
- async count(type, where) {
1279
- const resolvedFieldFilters = await this.resolveFieldFilters(type, where?.fieldFilters);
1280
- return this.countWithResolvedFilters(type, where, resolvedFieldFilters);
1281
- }
1282
- async countWithResolvedFilters(type, where, resolvedFieldFilters) {
1283
- const tableName = getTableName(type);
1284
- let query = this.db.selectFrom(tableName).select((eb) => eb.fn.count("id").as("count")).where("deleted_at", "is", null);
1285
- if (where?.status) query = query.where("status", "=", where.status);
1286
- if (where?.authorId) query = query.where("author_id", "=", where.authorId);
1287
- if (where?.locale) query = query.where("locale", "=", where.locale);
1288
- query = this.applySearchFilter(query, where, type);
1289
- query = this.applyDateFilter(query, where);
1290
- query = this.applyBylineFilter(query, where, type);
1291
- query = this.applyFieldFilters(query, resolvedFieldFilters);
1292
- const result = await query.executeTakeFirst();
1293
- return Number(result?.count || 0);
1294
- }
1295
- /**
1296
- * Distinct, non-null `author_id` values across the collection's live
1297
- * (non-trashed) content. Used to populate the admin author filter with
1298
- * only the users who have actually authored entries, rather than the
1299
- * full user directory (which requires admin privileges to read).
1300
- */
1301
- async findDistinctAuthorIds(type) {
1302
- const tableName = getTableName(type);
1303
- 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);
1304
- }
1305
- async getStats(type, now = /* @__PURE__ */ new Date()) {
1306
- const tableName = getTableName(type);
1307
- const nowIso = now.toISOString();
1308
- const result = await this.db.selectFrom(tableName).select((eb) => [
1309
- eb.fn.count("id").as("total"),
1310
- eb.fn.sum(eb.case().when("status", "=", "published").then(1).else(0).end()).as("published"),
1311
- eb.fn.sum(eb.case().when("status", "=", "draft").then(1).else(0).end()).as("draft"),
1312
- sql`SUM(CASE WHEN scheduled_at IS NOT NULL THEN 1 ELSE 0 END)`.as("scheduled"),
1313
- sql`SUM(CASE WHEN scheduled_at IS NOT NULL AND scheduled_at <= ${nowIso} THEN 1 ELSE 0 END)`.as("overdue_scheduled")
1314
- ]).where("deleted_at", "is", null).executeTakeFirst();
1315
- return {
1316
- total: Number(result?.total || 0),
1317
- published: Number(result?.published || 0),
1318
- draft: Number(result?.draft || 0),
1319
- scheduled: Number(result?.scheduled || 0),
1320
- overdueScheduled: Number(result?.overdue_scheduled || 0)
1321
- };
1322
- }
1323
- /**
1324
- * Schedule content for future publishing
1325
- *
1326
- * Sets status to 'scheduled' and stores the scheduled publish time.
1327
- * The content will be auto-published when the scheduled time is reached.
1328
- */
1329
- async schedule(type, id, scheduledAt, currentTime = /* @__PURE__ */ new Date(), expectedRevision) {
1330
- const tableName = getTableName(type);
1331
- const now = currentTime.toISOString();
1332
- const normalizedScheduledAt = await this.datetimes.normalizeValue(type, scheduledAt);
1333
- if (new Date(normalizedScheduledAt) <= currentTime) throw new EmDashValidationError("Scheduled date must be in the future");
1334
- const existing = await this.findById(type, id);
1335
- if (!existing) throw new EmDashValidationError("Content item not found");
1336
- assertRevisionPrecondition(existing, expectedRevision);
1337
- const newStatus = existing.status === "published" ? "published" : "scheduled";
1338
- if (((await sql`
1339
- UPDATE ${sql.ref(tableName)}
1340
- SET status = ${newStatus},
1341
- scheduled_at = ${normalizedScheduledAt},
1342
- updated_at = ${now}
1343
- WHERE id = ${id}
1344
- AND deleted_at IS NULL
1345
- AND version = ${existing.version}
1346
- AND updated_at = ${existing.updatedAt}
1347
- AND status = ${existing.status}
1348
- AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1349
- `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError("Content changed while scheduling");
1350
- invalidateCollectionCache(type);
1351
- const updated = await this.findById(type, id);
1352
- if (!updated) throw new Error("Content not found");
1353
- return updated;
1354
- }
1355
- /**
1356
- * Unschedule content
1357
- *
1358
- * Clears the scheduled time. Published posts stay published;
1359
- * draft/scheduled posts revert to 'draft'.
1360
- */
1361
- async unschedule(type, id, expectedRevision) {
1362
- const tableName = getTableName(type);
1363
- const now = (/* @__PURE__ */ new Date()).toISOString();
1364
- const existing = await this.findById(type, id);
1365
- if (!existing) throw new EmDashValidationError("Content item not found");
1366
- assertRevisionPrecondition(existing, expectedRevision);
1367
- const newStatus = existing.status === "published" ? "published" : "draft";
1368
- const result = await sql`
1369
- UPDATE ${sql.ref(tableName)}
1370
- SET status = ${newStatus},
1371
- scheduled_at = NULL,
1372
- updated_at = ${now}
1373
- WHERE id = ${id}
1374
- AND scheduled_at IS NOT NULL
1375
- AND deleted_at IS NULL
1376
- AND version = ${existing.version}
1377
- AND updated_at = ${existing.updatedAt}
1378
- AND status = ${existing.status}
1379
- AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1380
- `.execute(this.db);
1381
- if (existing.scheduledAt !== null && (result.numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError("Content changed while unscheduling");
1382
- invalidateCollectionCache(type);
1383
- const updated = await this.findById(type, id);
1384
- if (!updated) throw new Error("Content not found");
1385
- return updated;
1386
- }
1387
- /**
1388
- * Find content that is ready to be published
1389
- *
1390
- * Returns all content where scheduled_at <= now, regardless of status.
1391
- * This covers both draft-scheduled posts (status='scheduled') and
1392
- * published posts with scheduled draft changes (status='published').
1393
- *
1394
- * `limit` (optional) caps how many due rows are returned, oldest-due first.
1395
- * The scheduled-publishing sweep passes a limit so a large backlog can't
1396
- * fan out unbounded publish/webhook work in a single tick (and blow a Worker
1397
- * invocation's CPU/subrequest budget); the remainder drains on later ticks.
1398
- */
1399
- async findReadyToPublish(type, limit, currentTime = /* @__PURE__ */ new Date(), after) {
1400
- const tableName = getTableName(type);
1401
- const now = currentTime.toISOString();
1402
- const limitClause = typeof limit === "number" && Number.isInteger(limit) && limit > 0 ? sql`LIMIT ${limit}` : sql``;
1403
- const afterClause = after ? sql`AND (scheduled_at > ${after.scheduledAt} OR (scheduled_at = ${after.scheduledAt} AND id > ${after.id}))` : sql``;
1404
- return (await sql`
1405
- SELECT * FROM ${sql.ref(tableName)}
1406
- WHERE scheduled_at IS NOT NULL
1407
- AND scheduled_at <= ${now}
1408
- AND deleted_at IS NULL
1409
- ${afterClause}
1410
- ORDER BY scheduled_at ASC, id ASC
1411
- ${limitClause}
1412
- `.execute(this.db)).rows.map((row) => this.mapRow(type, row));
1413
- }
1414
- async findTranslationIds(type, translationGroup) {
1415
- const tableName = getTableName(type);
1416
- return (await sql`
1417
- SELECT id FROM ${sql.ref(tableName)}
1418
- WHERE translation_group = ${translationGroup}
1419
- AND deleted_at IS NULL
1420
- `.execute(this.db)).rows.map((row) => row.id);
1421
- }
1422
- async findTranslationIdsForGroups(type, translationGroups) {
1423
- const ids = /* @__PURE__ */ new Map();
1424
- if (translationGroups.length === 0) return ids;
1425
- const tableName = getTableName(type);
1426
- for (const batch of chunks([...new Set(translationGroups)], SQL_BATCH_SIZE)) {
1427
- const result = await sql`
1428
- SELECT id, translation_group FROM ${sql.ref(tableName)}
1429
- WHERE translation_group IN (${sql.join(batch)}) AND deleted_at IS NULL
1430
- `.execute(this.db);
1431
- for (const row of result.rows) {
1432
- const group = ids.get(row.translation_group) ?? [];
1433
- group.push(row.id);
1434
- ids.set(row.translation_group, group);
1435
- }
1436
- }
1437
- return ids;
1438
- }
1439
- /**
1440
- * Find all translations in a translation group
1441
- */
1442
- async findTranslations(type, translationGroup) {
1443
- const tableName = getTableName(type);
1444
- return (await sql`
1445
- SELECT * FROM ${sql.ref(tableName)}
1446
- WHERE translation_group = ${translationGroup}
1447
- AND deleted_at IS NULL
1448
- ORDER BY locale ASC
1449
- `.execute(this.db)).rows.map((row) => this.mapRow(type, row));
1450
- }
1451
- /**
1452
- * Whether any row still shares `translationGroup`, trashed rows included.
1453
- * Group-keyed satellite data (term assignments, reference edges) is owned by
1454
- * the group, not by a single locale row, so a purge may only cascade to it
1455
- * once nothing is left to own it — and a trashed sibling is still restorable.
1456
- */
1457
- async hasTranslationsIncludingTrashed(type, translationGroup, options = {}) {
1458
- const tableName = getTableName(type);
1459
- const exclusion = options.excludeId ? sql`AND id != ${options.excludeId}` : sql``;
1460
- return (await sql`
1461
- SELECT id FROM ${sql.ref(tableName)}
1462
- WHERE translation_group = ${translationGroup}
1463
- ${exclusion}
1464
- LIMIT 1
1465
- `.execute(this.db)).rows.length > 0;
1466
- }
1467
- /**
1468
- * Batch variant of {@link findTranslations}: every (non-deleted) locale
1469
- * variant for any of `translationGroups`, in one `WHERE translation_group IN
1470
- * (...)` query chunked at `SQL_BATCH_SIZE` for D1's bind-parameter limit.
1471
- * Lets callers resolve many edge groups without an N+1 per group. The caller
1472
- * groups the flat result by `translationGroup` itself.
1473
- *
1474
- * `translation_group` leads the sort so the ordering follows
1475
- * `idx_{table}_del_tg_locale` past its `deleted_at` equality; callers group by
1476
- * `translationGroup`, so the per-group locale order they rely on is preserved.
1477
- *
1478
- * `publishedOnly` restricts the result to `status = 'published'` — reference
1479
- * reads pass this for callers without `content:read_drafts` so draft/scheduled
1480
- * entries never leak through an edge traversal.
1481
- *
1482
- * A reference edge stores only a collection slug (no SQL FK), so the table may
1483
- * have been dropped since the edge was written. That is a tolerated dangling
1484
- * state, not an error: a missing table resolves to no rows, mirroring how the
1485
- * content read handlers treat `isMissingTableError`.
1486
- */
1487
- async findTranslationsForGroups(type, translationGroups, options = {}) {
1488
- if (translationGroups.length === 0) return [];
1489
- const tableName = getTableName(type);
1490
- const publishedFilter = options.publishedOnly ? sql`AND status = 'published'` : sql``;
1491
- const items = [];
1492
- try {
1493
- for (const chunk of chunks(translationGroups, SQL_BATCH_SIZE)) {
1494
- const result = await sql`
1495
- SELECT * FROM ${sql.ref(tableName)}
1496
- WHERE translation_group IN (${sql.join(chunk)})
1497
- AND deleted_at IS NULL
1498
- ${publishedFilter}
1499
- ORDER BY translation_group ASC, locale ASC
1500
- `.execute(this.db);
1501
- for (const row of result.rows) items.push(this.mapRow(type, row));
1502
- }
1503
- } catch (error) {
1504
- if (isMissingTableError(error)) return [];
1505
- throw error;
1506
- }
1507
- return items;
1508
- }
1509
- /**
1510
- * Batch variant of {@link findByIdOrSlug}: resolve many identifiers (each an
1511
- * id OR a slug) within `type` in a constant number of queries — one `WHERE id
1512
- * IN (...)` and one `WHERE slug IN (...)`, each chunked at `SQL_BATCH_SIZE`.
1513
- * Returns a map from the input identifier to its resolved item; identifiers
1514
- * that match nothing are absent. Used on write paths that accept a list of
1515
- * references, so a single request doesn't fan out to an N+1 of point lookups.
1516
- *
1517
- * Resolution mirrors {@link findByIdOrSlug}: a ULID-shaped identifier prefers
1518
- * the id match and falls back to slug; anything else prefers the slug match
1519
- * and falls back to id. Slug matches collapse to the lowest-locale variant
1520
- * (`ORDER BY locale ASC`), matching the slug-without-locale lookup.
1521
- */
1522
- async findManyByIdOrSlug(type, identifiers) {
1523
- const resolved = /* @__PURE__ */ new Map();
1524
- const unique = [...new Set(identifiers)];
1525
- if (unique.length === 0) return resolved;
1526
- const tableName = getTableName(type);
1527
- const byId = /* @__PURE__ */ new Map();
1528
- const bySlug = /* @__PURE__ */ new Map();
1529
- try {
1530
- for (const chunk of chunks(unique, SQL_BATCH_SIZE)) {
1531
- const idRows = await sql`
1532
- SELECT * FROM ${sql.ref(tableName)}
1533
- WHERE id IN (${sql.join(chunk)})
1534
- AND deleted_at IS NULL
1535
- `.execute(this.db);
1536
- for (const row of idRows.rows) {
1537
- const item = this.mapRow(type, row);
1538
- byId.set(item.id, item);
1539
- }
1540
- const slugRows = await sql`
1541
- SELECT * FROM ${sql.ref(tableName)}
1542
- WHERE slug IN (${sql.join(chunk)})
1543
- AND deleted_at IS NULL
1544
- ORDER BY locale ASC
1545
- `.execute(this.db);
1546
- for (const row of slugRows.rows) {
1547
- const item = this.mapRow(type, row);
1548
- if (item.slug != null && !bySlug.has(item.slug)) bySlug.set(item.slug, item);
1549
- }
1550
- }
1551
- } catch (error) {
1552
- if (isMissingTableError(error)) return resolved;
1553
- throw error;
1554
- }
1555
- for (const identifier of unique) {
1556
- const item = ULID_PATTERN.test(identifier) ? byId.get(identifier) ?? bySlug.get(identifier) : bySlug.get(identifier) ?? byId.get(identifier);
1557
- if (item) resolved.set(identifier, item);
1558
- }
1559
- return resolved;
1560
- }
1561
- /**
1562
- * Publish the current draft
1563
- *
1564
- * Promotes draft_revision_id to live_revision_id and clears draft pointer.
1565
- * Syncs the draft revision's data into the content table columns so the
1566
- * content table always reflects the published version.
1567
- * If no draft revision exists, creates one from current data and publishes it.
1568
- * When `promoteRevision` is false, publishes the current content-table data
1569
- * by changing lifecycle metadata only.
1570
- *
1571
- * `publishedAt` (optional) overrides the publication timestamp. If omitted,
1572
- * the existing `published_at` is preserved (idempotent re-publish keeps the
1573
- * original date) and falls back to the current time on first publish. Pass
1574
- * an explicit value to backdate a publish (e.g. when migrating content from
1575
- * another CMS).
1576
- *
1577
- * `requireDue` gates the final update on the row still being due.
1578
- * `expectedScheduledAt` additionally fences changes made after a sweep
1579
- * selected the row but before publication preparation began.
1580
- */
1581
- async publish(type, id, publishedAt, requireDue = false, expectedScheduledAt, promoteRevision = true, requireSlug = true, expectedRevision, currentTime = /* @__PURE__ */ new Date()) {
1582
- const tableName = getTableName(type);
1583
- const now = currentTime.toISOString();
1584
- const existing = await this.findById(type, id);
1585
- if (!existing) throw new EmDashValidationError("Content item not found");
1586
- assertRevisionPrecondition(existing, expectedRevision);
1587
- const requestedPublishedAt = publishedAt ? await this.datetimes.normalizeValue(type, publishedAt) : void 0;
1588
- const currentPublishedAt = existing.publishedAt ? await this.datetimes.normalizeValue(type, existing.publishedAt) : null;
1589
- if (requireDue && expectedScheduledAt !== void 0 && existing.scheduledAt !== expectedScheduledAt) throw new ScheduledNotDueError();
1590
- if (!promoteRevision && requireSlug && !existing.slug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
1591
- if (!promoteRevision) {
1592
- const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1593
- let provisionalRevisionId = null;
1594
- try {
1595
- let liveRevisionId = existing.liveRevisionId;
1596
- if (!liveRevisionId) {
1597
- const revision = await revisionRepo.create({
1598
- collection: type,
1599
- entryId: id,
1600
- data: existing.data
1601
- });
1602
- liveRevisionId = revision.id;
1603
- provisionalRevisionId = revision.id;
1604
- }
1605
- const intendedPublishedAt = requestedPublishedAt ?? currentPublishedAt ?? now;
1606
- const duePredicate = requireDue ? sql`AND scheduled_at IS NOT NULL AND scheduled_at <= ${now}` : sql``;
1607
- let published = false;
1608
- try {
1609
- published = ((await sql`
1610
- UPDATE ${sql.ref(tableName)}
1611
- SET live_revision_id = ${liveRevisionId},
1612
- draft_revision_id = NULL,
1613
- status = 'published',
1614
- scheduled_at = NULL,
1615
- published_at = ${intendedPublishedAt},
1616
- updated_at = ${now},
1617
- version = version + 1
1618
- WHERE id = ${id}
1619
- AND deleted_at IS NULL
1620
- AND version = ${existing.version}
1621
- AND updated_at = ${existing.updatedAt}
1622
- AND status = ${existing.status}
1623
- AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1624
- AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1625
- AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1626
- ${duePredicate}
1627
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1628
- } catch (error) {
1629
- if (isConfirmedStatementFailure(error)) throw error;
1630
- let observed;
1631
- try {
1632
- observed = await this.findById(type, id);
1633
- } catch (reconciliationError) {
1634
- throw new Error("Unable to confirm whether content publication completed", { cause: reconciliationError });
1635
- }
1636
- if (!observed) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1637
- published = matchesLifecyclePublication(observed, existing, liveRevisionId, intendedPublishedAt, now);
1638
- if (!published && matchesPublicationFence(observed, existing)) throw error;
1639
- if (!published) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1640
- }
1641
- if (!published) throw requireDue ? new ScheduledNotDueError() : new ContentMutationConflictError();
1642
- invalidateCollectionCache(type);
1643
- const updated = await this.findById(type, id);
1644
- if (!updated) throw new Error("Content not found");
1645
- return updated;
1646
- } catch (error) {
1647
- if (provisionalRevisionId) try {
1648
- await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1649
- } catch (cleanupError) {
1650
- console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1651
- }
1652
- throw error;
1653
- }
1654
- }
1655
- const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1656
- let provisionalRevisionId = null;
1657
- try {
1658
- let revisionToPublish = existing.draftRevisionId || existing.liveRevisionId;
1659
- if (!revisionToPublish) {
1660
- const revision = await revisionRepo.create({
1661
- collection: type,
1662
- entryId: id,
1663
- data: existing.data
1664
- });
1665
- revisionToPublish = revision.id;
1666
- provisionalRevisionId = revision.id;
1667
- }
1668
- const revision = await revisionRepo.findById(revisionToPublish);
1669
- if (!revision || revision.collection !== type || revision.entryId !== id) throw new EmDashValidationError("Revision does not belong to the specified content item");
1670
- const writableFieldSlugs = await this.datetimes.writableFieldSlugs(type);
1671
- const revisionData = keepKnownFields(revision.data, writableFieldSlugs);
1672
- const stagedSlug = typeof revision.data._slug === "string" ? revision.data._slug : null;
1673
- const intendedSlug = stagedSlug ?? existing.slug;
1674
- if (requireSlug && !intendedSlug?.trim()) throw new EmDashValidationError("Cannot publish routable content without a slug");
1675
- const intendedPublishedAt = requestedPublishedAt ?? currentPublishedAt ?? now;
1676
- if (stagedSlug !== null && stagedSlug !== existing.slug && existing.locale !== null) {
1677
- const conflict = await this.findBySlugIncludingTrashed(type, stagedSlug, existing.locale);
1678
- 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" });
1679
- }
1680
- const assignments = [];
1681
- if (stagedSlug !== null) assignments.push(sql`slug = ${stagedSlug}`);
1682
- for (const [key, value] of Object.entries(revisionData)) {
1683
- if (SYSTEM_COLUMNS.has(key) || key.startsWith("_")) continue;
1684
- validateIdentifier(key, "content field name");
1685
- assignments.push(sql`${sql.ref(key)} = ${serializeValue(value)}`);
1686
- }
1687
- 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`);
1688
- const duePredicate = requireDue ? sql`AND scheduled_at IS NOT NULL AND scheduled_at <= ${now}` : sql``;
1689
- let promoted = false;
1690
- try {
1691
- promoted = ((await sql`
1692
- UPDATE ${sql.ref(tableName)}
1693
- SET ${sql.join(assignments, sql`, `)}
1694
- WHERE id = ${id}
1695
- AND deleted_at IS NULL
1696
- AND version = ${existing.version}
1697
- AND updated_at = ${existing.updatedAt}
1698
- AND status = ${existing.status}
1699
- AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1700
- AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1701
- AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1702
- ${duePredicate}
1703
- AND EXISTS (
1704
- SELECT 1 FROM revisions
1705
- WHERE revisions.id = ${revisionToPublish}
1706
- AND revisions.collection = ${type}
1707
- AND revisions.entry_id = ${id}
1708
- )
1709
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1710
- } catch (error) {
1711
- if (isConfirmedStatementFailure(error)) throw error;
1712
- let observed;
1713
- try {
1714
- observed = await this.findById(type, id);
1715
- } catch (reconciliationError) {
1716
- throw new Error("Unable to confirm whether content publication completed", { cause: reconciliationError });
1717
- }
1718
- if (!observed) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1719
- promoted = matchesPublication(observed, existing, revisionData, revisionToPublish, intendedSlug, intendedPublishedAt, now);
1720
- if (!promoted && matchesPublicationFence(observed, existing)) throw error;
1721
- if (!promoted) throw new Error("Unable to confirm whether content publication completed", { cause: error });
1722
- }
1723
- if (!promoted) throw requireDue ? new ScheduledNotDueError() : new ContentMutationConflictError();
1724
- invalidateCollectionCache(type);
1725
- const updated = await this.findById(type, id);
1726
- if (!updated) throw new Error("Content not found");
1727
- return updated;
1728
- } catch (error) {
1729
- if (provisionalRevisionId) try {
1730
- await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1731
- } catch (cleanupError) {
1732
- console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1733
- }
1734
- throw error;
1735
- }
1736
- }
1737
- /**
1738
- * Unpublish content
1739
- *
1740
- * Removes live pointer and cancels any pending schedule, but preserves the
1741
- * draft and publication date. If no draft exists, creates one from the live
1742
- * version so the content isn't lost.
1743
- */
1744
- async unpublish(type, id, expectedRevision) {
1745
- const tableName = getTableName(type);
1746
- const now = (/* @__PURE__ */ new Date()).toISOString();
1747
- const existing = await this.findById(type, id);
1748
- if (!existing) throw new EmDashValidationError("Content item not found");
1749
- assertRevisionPrecondition(existing, expectedRevision);
1750
- if (existing.status === "draft" && !existing.liveRevisionId && !existing.scheduledAt) return existing;
1751
- const revisionRepo = new RevisionRepository(this.db, this.datetimeContexts);
1752
- let provisionalRevisionId = null;
1753
- try {
1754
- let draftRevisionId = existing.draftRevisionId;
1755
- if (!draftRevisionId && existing.liveRevisionId) {
1756
- const liveRevision = await revisionRepo.findById(existing.liveRevisionId);
1757
- if (liveRevision) {
1758
- const draft = await revisionRepo.create({
1759
- collection: type,
1760
- entryId: id,
1761
- data: liveRevision.data
1762
- });
1763
- draftRevisionId = draft.id;
1764
- provisionalRevisionId = draft.id;
1765
- }
1766
- }
1767
- if (((await sql`
1768
- UPDATE ${sql.ref(tableName)}
1769
- SET live_revision_id = NULL,
1770
- draft_revision_id = ${draftRevisionId},
1771
- status = 'draft',
1772
- scheduled_at = NULL,
1773
- updated_at = ${now},
1774
- version = version + 1
1775
- WHERE id = ${id}
1776
- AND deleted_at IS NULL
1777
- AND version = ${existing.version}
1778
- AND updated_at = ${existing.updatedAt}
1779
- AND status = ${existing.status}
1780
- AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1781
- AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1782
- AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1783
- `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError();
1784
- invalidateCollectionCache(type);
1785
- const updated = await this.findById(type, id);
1786
- if (!updated) throw new Error("Content not found");
1787
- return updated;
1788
- } catch (error) {
1789
- if (provisionalRevisionId) try {
1790
- await revisionRepo.deleteIfUnreferenced(type, id, provisionalRevisionId);
1791
- } catch (cleanupError) {
1792
- console.error(`[content] Failed to clean up provisional revision ${provisionalRevisionId}:`, cleanupError);
1793
- }
1794
- throw error;
1795
- }
1796
- }
1797
- /**
1798
- * Set the draft revision pointer for a content item.
1799
- *
1800
- * Used by seed/import paths that stage a new revision's data before
1801
- * promoting it to live via `publish()`.
1802
- *
1803
- * Validates that the content item exists and is not soft-deleted, that
1804
- * the revision exists, and that the revision belongs to the same
1805
- * collection and entry. Without these checks, a caller could leave the
1806
- * content row pointing at a missing or unrelated revision.
1807
- */
1808
- async setDraftRevision(type, id, revisionId) {
1809
- const existing = await this.findById(type, id);
1810
- if (!existing) throw new EmDashValidationError("Content item not found");
1811
- const revision = await new RevisionRepository(this.db, this.datetimeContexts).findById(revisionId);
1812
- if (!revision) throw new EmDashValidationError("Revision not found");
1813
- if (revision.collection !== type || revision.entryId !== id) throw new EmDashValidationError("Revision does not belong to the specified content item");
1814
- if (!await this.replaceDraftRevision(type, id, revisionId, existing)) throw new ContentMutationConflictError();
1815
- }
1816
- async replaceDraftRevision(type, id, revisionId, expected) {
1817
- const tableName = getTableName(type);
1818
- return ((await sql`
1819
- UPDATE ${sql.ref(tableName)}
1820
- SET draft_revision_id = ${revisionId},
1821
- version = version + 1
1822
- WHERE id = ${id}
1823
- AND deleted_at IS NULL
1824
- AND version = ${expected.version}
1825
- AND ${nullableColumnMatch("live_revision_id", expected.liveRevisionId)}
1826
- AND ${nullableColumnMatch("draft_revision_id", expected.draftRevisionId)}
1827
- AND EXISTS (
1828
- SELECT 1 FROM revisions
1829
- WHERE revisions.id = ${revisionId}
1830
- AND revisions.collection = ${type}
1831
- AND revisions.entry_id = ${id}
1832
- )
1833
- `.execute(this.db)).numAffectedRows ?? 0n) > 0n;
1834
- }
1835
- /**
1836
- * Discard pending draft changes
1837
- *
1838
- * Clears draft_revision_id. The content table columns already hold the
1839
- * published version, so no data sync is needed.
1840
- */
1841
- async discardDraft(type, id, expectedRevision) {
1842
- const tableName = getTableName(type);
1843
- const existing = await this.findById(type, id);
1844
- if (!existing) throw new EmDashValidationError("Content item not found");
1845
- assertRevisionPrecondition(existing, expectedRevision);
1846
- if (!existing.draftRevisionId) return existing;
1847
- if (((await sql`
1848
- UPDATE ${sql.ref(tableName)}
1849
- SET draft_revision_id = NULL,
1850
- version = version + 1
1851
- WHERE id = ${id}
1852
- AND deleted_at IS NULL
1853
- AND version = ${existing.version}
1854
- AND updated_at = ${existing.updatedAt}
1855
- AND status = ${existing.status}
1856
- AND ${nullableColumnMatch("live_revision_id", existing.liveRevisionId)}
1857
- AND ${nullableColumnMatch("draft_revision_id", existing.draftRevisionId)}
1858
- AND ${nullableColumnMatch("scheduled_at", existing.scheduledAt)}
1859
- `.execute(this.db)).numAffectedRows ?? 0n) === 0n) throw new ContentMutationConflictError();
1860
- const updated = await this.findById(type, id);
1861
- if (!updated) throw new Error("Content not found");
1862
- return updated;
1863
- }
1864
- /**
1865
- * Count content items with a pending schedule.
1866
- * Includes both draft-scheduled (status='scheduled') and published
1867
- * posts with scheduled draft changes (status='published', scheduled_at set).
1868
- */
1869
- async countScheduled(type) {
1870
- const tableName = getTableName(type);
1871
- const result = await sql`
1872
- SELECT COUNT(id) as count FROM ${sql.ref(tableName)}
1873
- WHERE scheduled_at IS NOT NULL
1874
- AND deleted_at IS NULL
1875
- `.execute(this.db);
1876
- return Number(result.rows[0]?.count || 0);
1877
- }
1878
- /**
1879
- * Map database row to ContentItem
1880
- * Extracts system columns and puts content fields in data
1881
- * Excludes null values from data to match input semantics
1882
- */
1883
- mapRow(type, row) {
1884
- const data = {};
1885
- for (const [key, value] of Object.entries(row)) if (!SYSTEM_COLUMNS.has(key) && value !== null) data[key] = deserializeValue(value);
1886
- return {
1887
- id: row.id,
1888
- type,
1889
- slug: row.slug,
1890
- status: row.status,
1891
- data,
1892
- authorId: row.author_id,
1893
- primaryBylineId: row.primary_byline_id ?? null,
1894
- createdAt: row.created_at,
1895
- updatedAt: row.updated_at,
1896
- publishedAt: row.published_at,
1897
- scheduledAt: row.scheduled_at,
1898
- liveRevisionId: row.live_revision_id ?? null,
1899
- draftRevisionId: row.draft_revision_id ?? null,
1900
- version: typeof row.version === "number" ? row.version : 1,
1901
- locale: row.locale ?? null,
1902
- translationGroup: row.translation_group ?? null
1903
- };
1904
- }
1905
- normalizeFilterScalar(field, type, value) {
1906
- if (type === "number" || type === "integer") {
1907
- if (typeof value !== "number" || !Number.isFinite(value)) throw new EmDashValidationError(`Filter for field "${field}" must use a finite number`);
1908
- if (type === "integer" && !Number.isInteger(value)) throw new EmDashValidationError(`Filter for field "${field}" must use an integer`);
1909
- return value;
1910
- }
1911
- if (type === "boolean") {
1912
- if (typeof value !== "boolean") throw new EmDashValidationError(`Filter for field "${field}" must use a boolean`);
1913
- return value ? 1 : 0;
1914
- }
1915
- if (typeof value !== "string") throw new EmDashValidationError(`Filter for field "${field}" must use a string`);
1916
- if (value.length > MAX_FILTER_STRING_LENGTH) throw new EmDashValidationError(`Filter value for field "${field}" exceeds ${MAX_FILTER_STRING_LENGTH} characters`);
1917
- if (type === "datetime") try {
1918
- return normalizeExplicitDatetime(value);
1919
- } catch {
1920
- throw new EmDashValidationError(`Filter for datetime field "${field}" must use an ISO 8601 datetime with Z or an explicit offset`);
1921
- }
1922
- return value;
1923
- }
1924
- normalizeFieldFilter(field, type, value) {
1925
- if (value === null) return {
1926
- column: field,
1927
- kind: "null"
1928
- };
1929
- if (typeof value !== "object") return {
1930
- column: field,
1931
- kind: "exact",
1932
- value: this.normalizeFilterScalar(field, type, value)
1933
- };
1934
- if (Array.isArray(value)) throw new EmDashValidationError(`Invalid filter for field "${field}"`);
1935
- const record = value;
1936
- const keys = Object.keys(record);
1937
- if (keys.length === 1 && keys[0] === "in") {
1938
- if (!Array.isArray(record.in) || record.in.length === 0) throw new EmDashValidationError(`IN filter for field "${field}" must not be empty`);
1939
- if (record.in.length > MAX_IN_FILTER_VALUES) throw new EmDashValidationError(`IN filter for field "${field}" exceeds ${MAX_IN_FILTER_VALUES} values`);
1940
- return {
1941
- column: field,
1942
- kind: "in",
1943
- values: record.in.map((entry) => this.normalizeFilterScalar(field, type, entry))
1944
- };
1945
- }
1946
- const rangeKeys = new Set([
1947
- "gt",
1948
- "gte",
1949
- "lt",
1950
- "lte"
1951
- ]);
1952
- if (keys.length === 0 || keys.some((key) => !rangeKeys.has(key))) throw new EmDashValidationError(`Invalid filter operator for field "${field}"`);
1953
- if (type === "boolean") throw new EmDashValidationError(`Boolean field "${field}" does not support range filters`);
1954
- const bounds = {};
1955
- for (const key of keys) {
1956
- if (record[key] === void 0) continue;
1957
- bounds[key] = this.normalizeFilterScalar(field, type, record[key]);
1958
- }
1959
- if (Object.keys(bounds).length === 0) throw new EmDashValidationError(`Range filter for field "${field}" has no bounds`);
1960
- return {
1961
- column: field,
1962
- kind: "range",
1963
- bounds
1964
- };
1965
- }
1966
- async collectionExists(type) {
1967
- return await this.db.selectFrom("_emdash_collections").where("slug", "=", type).select("id").executeTakeFirst() !== void 0;
1968
- }
1969
- async resolveFieldFilters(type, filters) {
1970
- const resolvedFilters = filters ?? {};
1971
- const fields = Object.keys(resolvedFilters);
1972
- if (fields.length === 0) return [];
1973
- if (fields.length > MAX_INDEXED_FIELD_FILTERS) {
1974
- if (!await this.collectionExists(type)) return [];
1975
- throw new EmDashValidationError(`Content list queries support at most ${MAX_INDEXED_FIELD_FILTERS} indexed field filters`);
1976
- }
1977
- 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([
1978
- "field.slug",
1979
- "field.type",
1980
- "field.validation"
1981
- ]).execute();
1982
- const metadata = new Map(rows.filter((row) => !isStoragelessFieldRow(row)).map((row) => [row.slug, row.type]));
1983
- if (metadata.size === 0 && !await this.collectionExists(type)) return [];
1984
- for (const field of fields) try {
1985
- validateIdentifier(field, "content filter field");
1986
- } catch {
1987
- throw new EmDashValidationError(`Invalid content filter field: ${field}`);
1988
- }
1989
- const normalized = fields.map((field) => {
1990
- const fieldType = metadata.get(field);
1991
- if (!fieldType || !isIndexableFieldType(fieldType)) throw new EmDashValidationError(`Cannot filter by field "${field}". Custom fields must be indexed before filtering.`);
1992
- return this.normalizeFieldFilter(field, fieldType, resolvedFilters[field]);
1993
- });
1994
- if (normalized.reduce((total, filter) => {
1995
- if (filter.kind === "null") return total;
1996
- if (filter.kind === "exact") return total + 1;
1997
- if (filter.kind === "in") return total + filter.values.length;
1998
- return total + Object.keys(filter.bounds).length;
1999
- }, 0) > SQL_BATCH_SIZE) throw new EmDashValidationError(`Indexed field filters have a total operand budget of ${SQL_BATCH_SIZE}`);
2000
- return normalized;
2001
- }
2002
- applyFieldFilters(query, filters) {
2003
- let next = query;
2004
- for (const filter of filters) {
2005
- const column = sql.ref(filter.column);
2006
- const isPresent = sql`${column} IS NOT NULL`;
2007
- if (filter.kind === "null") {
2008
- next = next.where(() => sql`(${isPresent}) = FALSE AND ${column} IS NULL`);
2009
- continue;
2010
- }
2011
- if (filter.kind === "exact") {
2012
- next = next.where(() => sql`(${isPresent}) = TRUE AND ${column} = ${filter.value}`);
2013
- continue;
2014
- }
2015
- if (filter.kind === "in") {
2016
- const values = sql.join(filter.values.map((value) => sql`${value}`), sql`, `);
2017
- next = next.where(() => sql`(${isPresent}) = TRUE AND ${column} IN (${values})`);
2018
- continue;
2019
- }
2020
- next = next.where(() => sql`(${isPresent}) = TRUE`);
2021
- if (filter.bounds.gt !== void 0) next = next.where(() => sql`${column} > ${filter.bounds.gt}`);
2022
- if (filter.bounds.gte !== void 0) next = next.where(() => sql`${column} >= ${filter.bounds.gte}`);
2023
- if (filter.bounds.lt !== void 0) next = next.where(() => sql`${column} < ${filter.bounds.lt}`);
2024
- if (filter.bounds.lte !== void 0) next = next.where(() => sql`${column} <= ${filter.bounds.lte}`);
2025
- }
2026
- return next;
2027
- }
2028
- /**
2029
- * Map order field names to database columns.
2030
- * Only allows known fields to prevent column enumeration via crafted orderBy values.
2031
- */
2032
- mapOrderField(field, sortableExtras = []) {
2033
- const mapped = ORDER_FIELD_COLUMNS[field];
2034
- if (mapped) return mapped;
2035
- if (sortableExtras.includes(field)) {
2036
- validateIdentifier(field, "order field");
2037
- return field;
2038
- }
2039
- throw new EmDashValidationError(`Invalid order field: ${field}`);
2040
- }
2041
- async resolveOrderField(type, field, sortableExtras = []) {
2042
- try {
2043
- return {
2044
- column: this.mapOrderField(field, sortableExtras),
2045
- indexedCustomField: false
2046
- };
2047
- } catch (error) {
2048
- if (!(error instanceof EmDashValidationError)) throw error;
2049
- }
2050
- 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();
2051
- if (!customField) throw new ContentCollectionNotFoundError(type);
2052
- if (!customField.fieldSlug) throw new EmDashValidationError(`Invalid order field: ${field}. Custom fields must be indexed before sorting.`);
2053
- validateIdentifier(customField.fieldSlug, "content order field");
2054
- return {
2055
- column: customField.fieldSlug,
2056
- indexedCustomField: true
2057
- };
2058
- }
2059
- };
2060
-
2061
- //#endregion
2062
- export { staleStoredKeys as a, keepKnownFields as i, content_exports as n, isSystemOrderField as r, ContentRepository as t };
2063
- //# sourceMappingURL=content-Dji9vEiW.mjs.map