emdash 0.31.1 → 0.33.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 (746) hide show
  1. package/dist/{adapters-C0ONzkUP.d.mts → adapters-BMyNSSZi.d.mts} +9 -1
  2. package/dist/adapters-BMyNSSZi.d.mts.map +1 -0
  3. package/dist/after-CBU2vkoO.mjs +96 -0
  4. package/dist/after-CBU2vkoO.mjs.map +1 -0
  5. package/dist/{allowed-origins-CCEi9bPI.mjs → allowed-origins-CG1pACtS.mjs} +2 -2
  6. package/dist/{allowed-origins-CCEi9bPI.mjs.map → allowed-origins-CG1pACtS.mjs.map} +1 -1
  7. package/dist/api/route-utils.d.mts +3 -4
  8. package/dist/api/route-utils.d.mts.map +1 -1
  9. package/dist/api/route-utils.mjs +23 -21
  10. package/dist/api/route-utils.mjs.map +1 -1
  11. package/dist/api/schemas/index.d.mts +2 -2
  12. package/dist/api/schemas/index.mjs +5 -5
  13. package/dist/{api-BkqFzIu4.mjs → api-D2hunekQ.mjs} +254 -48
  14. package/dist/api-D2hunekQ.mjs.map +1 -0
  15. package/dist/{api-tokens-uPt8UDpx.mjs → api-tokens-CSND0i1z.mjs} +2 -2
  16. package/dist/{api-tokens-uPt8UDpx.mjs.map → api-tokens-CSND0i1z.mjs.map} +1 -1
  17. package/dist/{apply-DuXsqll7.mjs → apply-kwNEJW2l.mjs} +36 -23
  18. package/dist/apply-kwNEJW2l.mjs.map +1 -0
  19. package/dist/astro/index.d.mts +12 -12
  20. package/dist/astro/index.mjs +17 -3
  21. package/dist/astro/index.mjs.map +1 -1
  22. package/dist/astro/middleware/auth.d.mts +10 -10
  23. package/dist/astro/middleware/auth.mjs +8 -8
  24. package/dist/astro/middleware/redirect.d.mts.map +1 -1
  25. package/dist/astro/middleware/redirect.mjs +8 -8
  26. package/dist/astro/middleware/redirect.mjs.map +1 -1
  27. package/dist/astro/middleware/request-context.mjs +4 -4
  28. package/dist/astro/middleware/setup.mjs +1 -1
  29. package/dist/astro/middleware.d.mts +10 -10
  30. package/dist/astro/middleware.d.mts.map +1 -1
  31. package/dist/astro/middleware.mjs +370 -171
  32. package/dist/astro/middleware.mjs.map +1 -1
  33. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +7 -7
  34. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +7 -7
  35. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +4 -4
  36. package/dist/astro/routes/api/admin/api-tokens/index.mjs +5 -5
  37. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +5 -5
  38. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +10 -10
  39. package/dist/astro/routes/api/admin/byline-fields/index.mjs +10 -10
  40. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +10 -10
  41. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +19 -18
  42. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs.map +1 -1
  43. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +19 -18
  44. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs.map +1 -1
  45. package/dist/astro/routes/api/admin/bylines/index.mjs +19 -19
  46. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +16 -16
  47. package/dist/astro/routes/api/admin/comments/_id_/status.mjs.map +1 -1
  48. package/dist/astro/routes/api/admin/comments/_id_.mjs +7 -7
  49. package/dist/astro/routes/api/admin/comments/bulk.mjs +12 -12
  50. package/dist/astro/routes/api/admin/comments/counts.mjs +7 -7
  51. package/dist/astro/routes/api/admin/comments/index.mjs +12 -12
  52. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +5 -5
  53. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +4 -4
  54. package/dist/astro/routes/api/admin/media-usage/repair.mjs +13 -11
  55. package/dist/astro/routes/api/admin/media-usage/repair.mjs.map +1 -1
  56. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +4 -4
  57. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +4 -4
  58. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +47 -44
  59. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
  60. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +47 -44
  61. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
  62. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +46 -43
  63. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  64. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +5 -5
  65. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +46 -43
  66. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
  67. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +46 -43
  68. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  69. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +46 -43
  70. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  71. package/dist/astro/routes/api/admin/plugins/index.mjs +46 -43
  72. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  73. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +3 -3
  74. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +46 -43
  75. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  76. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +46 -43
  77. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  78. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +46 -43
  79. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  80. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +46 -43
  81. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  82. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +47 -44
  83. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  84. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +46 -43
  85. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
  86. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +47 -44
  87. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  88. package/dist/astro/routes/api/admin/plugins/updates.mjs +46 -43
  89. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  90. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +46 -43
  91. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  92. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +3 -3
  93. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +46 -43
  94. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  95. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +3 -3
  96. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +2 -2
  97. package/dist/astro/routes/api/admin/users/_id_/index.mjs +8 -8
  98. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +5 -5
  99. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs.map +1 -1
  100. package/dist/astro/routes/api/admin/users/index.mjs +7 -7
  101. package/dist/astro/routes/api/auth/dev-bypass.mjs +7 -6
  102. package/dist/astro/routes/api/auth/dev-bypass.mjs.map +1 -1
  103. package/dist/astro/routes/api/auth/invite/accept.mjs +2 -2
  104. package/dist/astro/routes/api/auth/invite/complete.mjs +12 -12
  105. package/dist/astro/routes/api/auth/invite/index.mjs +10 -10
  106. package/dist/astro/routes/api/auth/invite/index.mjs.map +1 -1
  107. package/dist/astro/routes/api/auth/invite/register-options.mjs +11 -11
  108. package/dist/astro/routes/api/auth/logout.mjs +3 -3
  109. package/dist/astro/routes/api/auth/magic-link/send.mjs +12 -12
  110. package/dist/astro/routes/api/auth/magic-link/send.mjs.map +1 -1
  111. package/dist/astro/routes/api/auth/magic-link/verify.mjs +3 -3
  112. package/dist/astro/routes/api/auth/me.mjs +8 -8
  113. package/dist/astro/routes/api/auth/mode.mjs +3 -3
  114. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +4 -4
  115. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  116. package/dist/astro/routes/api/auth/passkey/_id_.mjs +7 -7
  117. package/dist/astro/routes/api/auth/passkey/index.mjs +2 -2
  118. package/dist/astro/routes/api/auth/passkey/options.mjs +13 -13
  119. package/dist/astro/routes/api/auth/passkey/register/options.mjs +11 -11
  120. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +12 -12
  121. package/dist/astro/routes/api/auth/passkey/verify.mjs +12 -12
  122. package/dist/astro/routes/api/auth/signup/complete.mjs +12 -12
  123. package/dist/astro/routes/api/auth/signup/request.mjs +12 -12
  124. package/dist/astro/routes/api/auth/signup/request.mjs.map +1 -1
  125. package/dist/astro/routes/api/auth/signup/verify.mjs +2 -2
  126. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +18 -18
  127. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs.map +1 -1
  128. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +15 -15
  129. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +3 -3
  130. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +4 -4
  131. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +4 -4
  132. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +3 -3
  133. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +14 -14
  134. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +9 -9
  135. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +19 -17
  136. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
  137. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +19 -17
  138. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
  139. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +4 -4
  140. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +3 -3
  141. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +9 -9
  142. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +17 -16
  143. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  144. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +3 -3
  145. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +4 -4
  146. package/dist/astro/routes/api/content/_collection_/_id_.d.mts.map +1 -1
  147. package/dist/astro/routes/api/content/_collection_/_id_.mjs +10 -10
  148. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  149. package/dist/astro/routes/api/content/_collection_/authors.mjs +3 -3
  150. package/dist/astro/routes/api/content/_collection_/index.mjs +9 -9
  151. package/dist/astro/routes/api/content/_collection_/trash.mjs +8 -8
  152. package/dist/astro/routes/api/dashboard.mjs +9 -9
  153. package/dist/astro/routes/api/dev/emails.mjs +3 -3
  154. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  155. package/dist/astro/routes/api/import/probe.mjs +19 -19
  156. package/dist/astro/routes/api/import/wordpress/analyze.mjs +4 -4
  157. package/dist/astro/routes/api/import/wordpress/execute.d.mts +11 -11
  158. package/dist/astro/routes/api/import/wordpress/execute.mjs +16 -15
  159. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  160. package/dist/astro/routes/api/import/wordpress/media.d.mts +10 -10
  161. package/dist/astro/routes/api/import/wordpress/media.mjs +10 -10
  162. package/dist/astro/routes/api/import/wordpress/prepare.mjs +11 -11
  163. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +11 -11
  164. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +13 -11
  165. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs.map +1 -1
  166. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  167. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +19 -19
  168. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +11 -11
  169. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +28 -27
  170. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  171. package/dist/astro/routes/api/manifest.mjs +5 -5
  172. package/dist/astro/routes/api/mcp.mjs +42 -42
  173. package/dist/astro/routes/api/media/_id_/confirm.d.mts.map +1 -1
  174. package/dist/astro/routes/api/media/_id_/confirm.mjs +106 -37
  175. package/dist/astro/routes/api/media/_id_/confirm.mjs.map +1 -1
  176. package/dist/astro/routes/api/media/_id_/upload.d.mts +8 -0
  177. package/dist/astro/routes/api/media/_id_/upload.d.mts.map +1 -0
  178. package/dist/astro/routes/api/media/_id_/upload.mjs +168 -0
  179. package/dist/astro/routes/api/media/_id_/upload.mjs.map +1 -0
  180. package/dist/astro/routes/api/media/_id_/usage.mjs +15 -13
  181. package/dist/astro/routes/api/media/_id_/usage.mjs.map +1 -1
  182. package/dist/astro/routes/api/media/_id_.d.mts.map +1 -1
  183. package/dist/astro/routes/api/media/_id_.mjs +22 -15
  184. package/dist/astro/routes/api/media/_id_.mjs.map +1 -1
  185. package/dist/astro/routes/api/media/file/_...key_.mjs +2 -2
  186. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +3 -3
  187. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +3 -3
  188. package/dist/astro/routes/api/media/providers/index.mjs +3 -3
  189. package/dist/astro/routes/api/media/upload-url.d.mts.map +1 -1
  190. package/dist/astro/routes/api/media/upload-url.mjs +35 -24
  191. package/dist/astro/routes/api/media/upload-url.mjs.map +1 -1
  192. package/dist/astro/routes/api/media.mjs +14 -13
  193. package/dist/astro/routes/api/media.mjs.map +1 -1
  194. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +12 -11
  195. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs.map +1 -1
  196. package/dist/astro/routes/api/menus/_name_/items.mjs +12 -11
  197. package/dist/astro/routes/api/menus/_name_/items.mjs.map +1 -1
  198. package/dist/astro/routes/api/menus/_name_/reorder.mjs +12 -11
  199. package/dist/astro/routes/api/menus/_name_/reorder.mjs.map +1 -1
  200. package/dist/astro/routes/api/menus/_name_/translations.mjs +12 -11
  201. package/dist/astro/routes/api/menus/_name_/translations.mjs.map +1 -1
  202. package/dist/astro/routes/api/menus/_name_.mjs +12 -11
  203. package/dist/astro/routes/api/menus/_name_.mjs.map +1 -1
  204. package/dist/astro/routes/api/menus/index.mjs +12 -11
  205. package/dist/astro/routes/api/menus/index.mjs.map +1 -1
  206. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  207. package/dist/astro/routes/api/oauth/device/authorize.mjs +6 -6
  208. package/dist/astro/routes/api/oauth/device/code.mjs +9 -9
  209. package/dist/astro/routes/api/oauth/device/token.mjs +8 -8
  210. package/dist/astro/routes/api/oauth/register.mjs +3 -3
  211. package/dist/astro/routes/api/oauth/token/refresh.mjs +6 -6
  212. package/dist/astro/routes/api/oauth/token/revoke.mjs +6 -6
  213. package/dist/astro/routes/api/oauth/token.mjs +6 -6
  214. package/dist/astro/routes/api/openapi.json.mjs +62 -9
  215. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  216. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +5 -5
  217. package/dist/astro/routes/api/redirects/404s/index.mjs +12 -12
  218. package/dist/astro/routes/api/redirects/404s/summary.mjs +12 -12
  219. package/dist/astro/routes/api/redirects/_id_.mjs +14 -13
  220. package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
  221. package/dist/astro/routes/api/redirects/index.mjs +14 -13
  222. package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
  223. package/dist/astro/routes/api/relations/_id_/index.mjs +19 -17
  224. package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
  225. package/dist/astro/routes/api/relations/_id_/translations.mjs +14 -12
  226. package/dist/astro/routes/api/relations/_id_/translations.mjs.map +1 -1
  227. package/dist/astro/routes/api/relations/index.mjs +19 -17
  228. package/dist/astro/routes/api/relations/index.mjs.map +1 -1
  229. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +3 -3
  230. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +4 -4
  231. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +46 -43
  232. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  233. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +46 -43
  234. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  235. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +46 -43
  236. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  237. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +46 -43
  238. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  239. package/dist/astro/routes/api/schema/collections/index.mjs +46 -43
  240. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  241. package/dist/astro/routes/api/schema/collections/reorder.d.mts +8 -0
  242. package/dist/astro/routes/api/schema/collections/reorder.d.mts.map +1 -0
  243. package/dist/astro/routes/api/schema/collections/reorder.mjs +66 -0
  244. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -0
  245. package/dist/astro/routes/api/schema/index.mjs +12 -8
  246. package/dist/astro/routes/api/schema/index.mjs.map +1 -1
  247. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +46 -43
  248. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  249. package/dist/astro/routes/api/schema/orphans/index.mjs +46 -43
  250. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  251. package/dist/astro/routes/api/search/enable.d.mts +1 -0
  252. package/dist/astro/routes/api/search/enable.d.mts.map +1 -1
  253. package/dist/astro/routes/api/search/enable.mjs +18 -13
  254. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  255. package/dist/astro/routes/api/search/index.mjs +12 -11
  256. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  257. package/dist/astro/routes/api/search/rebuild.mjs +14 -13
  258. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  259. package/dist/astro/routes/api/search/stats.mjs +8 -7
  260. package/dist/astro/routes/api/search/stats.mjs.map +1 -1
  261. package/dist/astro/routes/api/search/suggest.mjs +12 -11
  262. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  263. package/dist/astro/routes/api/sections/_slug_.mjs +11 -11
  264. package/dist/astro/routes/api/sections/index.mjs +11 -11
  265. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +7 -7
  266. package/dist/astro/routes/api/settings/backups/archives/index.mjs +6 -6
  267. package/dist/astro/routes/api/settings/backups/export.mjs +7 -7
  268. package/dist/astro/routes/api/settings/backups/index.mjs +8 -8
  269. package/dist/astro/routes/api/settings/email.mjs +5 -5
  270. package/dist/astro/routes/api/settings.mjs +16 -16
  271. package/dist/astro/routes/api/setup/admin-verify.mjs +13 -13
  272. package/dist/astro/routes/api/setup/admin.mjs +12 -12
  273. package/dist/astro/routes/api/setup/dev-bypass.mjs +31 -29
  274. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  275. package/dist/astro/routes/api/setup/dev-reset.mjs +3 -3
  276. package/dist/astro/routes/api/setup/index.mjs +33 -31
  277. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  278. package/dist/astro/routes/api/setup/status.mjs +4 -4
  279. package/dist/astro/routes/api/snapshot.mjs +9 -9
  280. package/dist/astro/routes/api/taxonomies/_name_/reorder.d.mts +8 -0
  281. package/dist/astro/routes/api/taxonomies/_name_/reorder.d.mts.map +1 -0
  282. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +43 -0
  283. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -0
  284. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +17 -16
  285. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
  286. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +17 -16
  287. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
  288. package/dist/astro/routes/api/taxonomies/_name_/terms/index.d.mts.map +1 -1
  289. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +22 -18
  290. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
  291. package/dist/astro/routes/api/taxonomies/index.mjs +17 -16
  292. package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
  293. package/dist/astro/routes/api/themes/preview.mjs +7 -7
  294. package/dist/astro/routes/api/typegen.mjs +5 -5
  295. package/dist/astro/routes/api/well-known/auth.mjs +2 -2
  296. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  297. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  298. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +8 -8
  299. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +11 -11
  300. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +11 -11
  301. package/dist/astro/routes/api/widget-areas/_name_.mjs +6 -6
  302. package/dist/astro/routes/api/widget-areas/index.mjs +11 -11
  303. package/dist/astro/routes/api/widget-components.mjs +3 -3
  304. package/dist/astro/routes/robots.txt.mjs +9 -9
  305. package/dist/astro/routes/sitemap-_collection_.xml.mjs +13 -13
  306. package/dist/astro/routes/sitemap.xml.mjs +10 -10
  307. package/dist/astro/types.d.mts +20 -13
  308. package/dist/astro/types.d.mts.map +1 -1
  309. package/dist/auth/providers/github.d.mts +1 -1
  310. package/dist/auth/providers/google.d.mts +1 -1
  311. package/dist/{authorize-6WPZa1xZ.mjs → authorize-qRhWQnel.mjs} +2 -2
  312. package/dist/{authorize-6WPZa1xZ.mjs.map → authorize-qRhWQnel.mjs.map} +1 -1
  313. package/dist/{backup-DoW-H0r4.mjs → backup-CtA6LDNw.mjs} +5 -5
  314. package/dist/{backup-DoW-H0r4.mjs.map → backup-CtA6LDNw.mjs.map} +1 -1
  315. package/dist/{byline-BTOxUlFF.mjs → byline-Cp6csL84.mjs} +9 -9
  316. package/dist/{byline-BTOxUlFF.mjs.map → byline-Cp6csL84.mjs.map} +1 -1
  317. package/dist/{byline-fields-CdU_LTF1.mjs → byline-fields-CNc0Yq5i.mjs} +2 -2
  318. package/dist/{byline-fields-CdU_LTF1.mjs.map → byline-fields-CNc0Yq5i.mjs.map} +1 -1
  319. package/dist/{byline-registry-BCuOp4UF.mjs → byline-registry-ZkPKqEwC.mjs} +4 -4
  320. package/dist/{byline-registry-BCuOp4UF.mjs.map → byline-registry-ZkPKqEwC.mjs.map} +1 -1
  321. package/dist/{bylines-Bc-3xtpz.mjs → bylines-CEj5CdT4.mjs} +7 -7
  322. package/dist/{bylines-Bc-3xtpz.mjs.map → bylines-CEj5CdT4.mjs.map} +1 -1
  323. package/dist/{bylines-oVN0iPwX.mjs → bylines-cf-C9lmF.mjs} +5 -5
  324. package/dist/{bylines-oVN0iPwX.mjs.map → bylines-cf-C9lmF.mjs.map} +1 -1
  325. package/dist/cache-C9FptTFR.mjs +108 -0
  326. package/dist/cache-C9FptTFR.mjs.map +1 -0
  327. package/dist/{challenge-store-BFzgFRog.mjs → challenge-store-D9VNKELo.mjs} +1 -1
  328. package/dist/{challenge-store-BFzgFRog.mjs.map → challenge-store-D9VNKELo.mjs.map} +1 -1
  329. package/dist/{chunks-Bq-5DPrD.mjs → chunks-DbYzib_k.mjs} +2 -2
  330. package/dist/{chunks-Bq-5DPrD.mjs.map → chunks-DbYzib_k.mjs.map} +1 -1
  331. package/dist/cli/index.mjs +41 -32
  332. package/dist/cli/index.mjs.map +1 -1
  333. package/dist/client/cf-access.d.mts +1 -1
  334. package/dist/client/index.d.mts +1 -1
  335. package/dist/client/index.mjs +2 -2
  336. package/dist/{comment-B9cUud8H.mjs → comment-BIkJ6Fil.mjs} +3 -3
  337. package/dist/{comment-B9cUud8H.mjs.map → comment-BIkJ6Fil.mjs.map} +1 -1
  338. package/dist/{comment-reaction-VUXO981F.mjs → comment-reaction-D-laEceb.mjs} +2 -2
  339. package/dist/{comment-reaction-VUXO981F.mjs.map → comment-reaction-D-laEceb.mjs.map} +1 -1
  340. package/dist/{comments-PXj1E9Si.mjs → comments-0_w6KChA.mjs} +3 -3
  341. package/dist/{comments-PXj1E9Si.mjs.map → comments-0_w6KChA.mjs.map} +1 -1
  342. package/dist/{components-DZkL4Fx0.mjs → components-BPxrRjpE.mjs} +1 -1
  343. package/dist/{components-DZkL4Fx0.mjs.map → components-BPxrRjpE.mjs.map} +1 -1
  344. package/dist/{config-B6b_BobR.mjs → config-DyF3OKg_.mjs} +15 -10
  345. package/dist/config-DyF3OKg_.mjs.map +1 -0
  346. package/dist/{content-BC43pICM.mjs → content-CJ94NEx5.mjs} +170 -117
  347. package/dist/content-CJ94NEx5.mjs.map +1 -0
  348. package/dist/{content-refresh-CPMSauD3.mjs → content-refresh-Xw7aKmou.mjs} +7 -7
  349. package/dist/{content-refresh-CPMSauD3.mjs.map → content-refresh-Xw7aKmou.mjs.map} +1 -1
  350. package/dist/{context-DOurRIrb.mjs → context-C_1nrqnW.mjs} +14 -14
  351. package/dist/{context-DOurRIrb.mjs.map → context-C_1nrqnW.mjs.map} +1 -1
  352. package/dist/{cron-BlKIMD_e.mjs → cron-DRV-UC4K.mjs} +1 -1
  353. package/dist/{cron-BlKIMD_e.mjs.map → cron-DRV-UC4K.mjs.map} +1 -1
  354. package/dist/{dashboard-CBm4zhc3.mjs → dashboard-DINnNVVU.mjs} +5 -5
  355. package/dist/{dashboard-CBm4zhc3.mjs.map → dashboard-DINnNVVU.mjs.map} +1 -1
  356. package/dist/db/index.d.mts +3 -3
  357. package/dist/db/index.mjs +3 -2
  358. package/dist/db/index.mjs.map +1 -1
  359. package/dist/db/libsql.d.mts +1 -1
  360. package/dist/db/postgres.d.mts +1 -1
  361. package/dist/db/sqlite.d.mts +1 -1
  362. package/dist/{default-C4v9KP56.mjs → default-BD2FG0xV.mjs} +1 -1
  363. package/dist/{default-C4v9KP56.mjs.map → default-BD2FG0xV.mjs.map} +1 -1
  364. package/dist/deferred-tasks-C-WRCcKo.d.mts +9 -0
  365. package/dist/deferred-tasks-C-WRCcKo.d.mts.map +1 -0
  366. package/dist/{device-flow-BeA6lUS1.mjs → device-flow-CTqd8mud.mjs} +5 -5
  367. package/dist/{device-flow-BeA6lUS1.mjs.map → device-flow-CTqd8mud.mjs.map} +1 -1
  368. package/dist/{dialect-helpers-BtOwo2us.mjs → dialect-helpers-BSbfaO3F.mjs} +43 -16
  369. package/dist/dialect-helpers-BSbfaO3F.mjs.map +1 -0
  370. package/dist/{email-console-C-9Ng8DM.mjs → email-console-C6WdcWbL.mjs} +1 -1
  371. package/dist/{email-console-C-9Ng8DM.mjs.map → email-console-C6WdcWbL.mjs.map} +1 -1
  372. package/dist/{error-DJ98TRbQ.mjs → error-oh_9i6bR.mjs} +3 -3
  373. package/dist/{error-DJ98TRbQ.mjs.map → error-oh_9i6bR.mjs.map} +1 -1
  374. package/dist/{errors-DtEXIQQV.mjs → errors-BucQ8VYz.mjs} +2 -1
  375. package/dist/errors-BucQ8VYz.mjs.map +1 -0
  376. package/dist/{escape-CFedIB1C.mjs → escape-CXps5F_v.mjs} +1 -1
  377. package/dist/{escape-CFedIB1C.mjs.map → escape-CXps5F_v.mjs.map} +1 -1
  378. package/dist/{field-defs-cache-KfNJ_qLQ.mjs → field-defs-cache-WD82dMQq.mjs} +4 -4
  379. package/dist/{field-defs-cache-KfNJ_qLQ.mjs.map → field-defs-cache-WD82dMQq.mjs.map} +1 -1
  380. package/dist/{fts-manager-hyCU9OOp.mjs → fts-manager-BITakW_R.mjs} +37 -13
  381. package/dist/fts-manager-BITakW_R.mjs.map +1 -0
  382. package/dist/{hash-DFFrkivP.mjs → hash-Cg0TXJPV.mjs} +8 -4
  383. package/dist/hash-Cg0TXJPV.mjs.map +1 -0
  384. package/dist/{hreflang-CIxH_LKz.d.mts → hreflang-BaLCNcDx.d.mts} +2 -2
  385. package/dist/{hreflang-CIxH_LKz.d.mts.map → hreflang-BaLCNcDx.d.mts.map} +1 -1
  386. package/dist/{hreflang-CbYeCzl9.mjs → hreflang-BdZuVBhL.mjs} +7 -7
  387. package/dist/{hreflang-CbYeCzl9.mjs.map → hreflang-BdZuVBhL.mjs.map} +1 -1
  388. package/dist/{import-oDYCgNYQ.mjs → import-C-9uqyT3.mjs} +6 -6
  389. package/dist/{import-oDYCgNYQ.mjs.map → import-C-9uqyT3.mjs.map} +1 -1
  390. package/dist/{index-BZJ_5FOX.d.mts → index-M37iz29I.d.mts} +112 -37
  391. package/dist/index-M37iz29I.d.mts.map +1 -0
  392. package/dist/{index-BEui-cRd.d.mts → index-MGw47uWq.d.mts} +3 -3
  393. package/dist/{index-BEui-cRd.d.mts.map → index-MGw47uWq.d.mts.map} +1 -1
  394. package/dist/index.d.mts +19 -19
  395. package/dist/index.mjs +69 -67
  396. package/dist/{load-Dg5gtWma.mjs → load-DV1DZuUJ.mjs} +2 -2
  397. package/dist/{load-Dg5gtWma.mjs.map → load-DV1DZuUJ.mjs.map} +1 -1
  398. package/dist/{loader-D4rigvjR.mjs → loader-CGugY7Zl.mjs} +29 -15
  399. package/dist/loader-CGugY7Zl.mjs.map +1 -0
  400. package/dist/{manifest-schema-bCq54i7F.mjs → manifest-schema-Da7kj23y.mjs} +1 -1
  401. package/dist/{manifest-schema-bCq54i7F.mjs.map → manifest-schema-Da7kj23y.mjs.map} +1 -1
  402. package/dist/media/index.d.mts +1 -1
  403. package/dist/media/local-runtime.d.mts +12 -12
  404. package/dist/media/local-runtime.mjs +8 -8
  405. package/dist/{media-its1WLYv.mjs → media-BP7S-nHT.mjs} +60 -15
  406. package/dist/media-BP7S-nHT.mjs.map +1 -0
  407. package/dist/{media-BJ6SRY3g.mjs → media-OhYL-7Io.mjs} +8 -4
  408. package/dist/{media-BJ6SRY3g.mjs.map → media-OhYL-7Io.mjs.map} +1 -1
  409. package/dist/{media-allowlist-jUppPWFy.mjs → media-allowlist-D-peH1H5.mjs} +1 -1
  410. package/dist/{media-allowlist-jUppPWFy.mjs.map → media-allowlist-D-peH1H5.mjs.map} +1 -1
  411. package/dist/{media-upload-DNu3QySc.mjs → media-upload-DtrwU2B0.mjs} +7 -7
  412. package/dist/{media-upload-DNu3QySc.mjs.map → media-upload-DtrwU2B0.mjs.map} +1 -1
  413. package/dist/{media-url-BCm5vBn6.mjs → media-url-DYs_YLOx.mjs} +1 -1
  414. package/dist/{media-url-BCm5vBn6.mjs.map → media-url-DYs_YLOx.mjs.map} +1 -1
  415. package/dist/{media-usage-DPQ3K4xB.mjs → media-usage-BlxfTkN0.mjs} +8 -8
  416. package/dist/{media-usage-DPQ3K4xB.mjs.map → media-usage-BlxfTkN0.mjs.map} +1 -1
  417. package/dist/{menus-BMGzWyWH.mjs → menus-BcQWxeXu.mjs} +5 -5
  418. package/dist/{menus-BMGzWyWH.mjs.map → menus-BcQWxeXu.mjs.map} +1 -1
  419. package/dist/{menus-CPf_SW7u.mjs → menus-Y54RDPIN.mjs} +215 -38
  420. package/dist/menus-Y54RDPIN.mjs.map +1 -0
  421. package/dist/{mode-fiXRMfeA.mjs → mode-BWyTBe3I.mjs} +1 -1
  422. package/dist/{mode-fiXRMfeA.mjs.map → mode-BWyTBe3I.mjs.map} +1 -1
  423. package/dist/{oauth-authorization-oqfbBuMH.mjs → oauth-authorization-ClvktmrL.mjs} +5 -5
  424. package/dist/{oauth-authorization-oqfbBuMH.mjs.map → oauth-authorization-ClvktmrL.mjs.map} +1 -1
  425. package/dist/{oauth-clients-BlrUHAsf.mjs → oauth-clients-8ao-U66l.mjs} +1 -1
  426. package/dist/{oauth-clients-BlrUHAsf.mjs.map → oauth-clients-8ao-U66l.mjs.map} +1 -1
  427. package/dist/{oauth-state-store-DnvjRMy6.mjs → oauth-state-store-B1ofdTiQ.mjs} +1 -1
  428. package/dist/{oauth-state-store-DnvjRMy6.mjs.map → oauth-state-store-B1ofdTiQ.mjs.map} +1 -1
  429. package/dist/{oauth-user-lookup-oUllxvAv.mjs → oauth-user-lookup-CscEuIiR.mjs} +1 -1
  430. package/dist/{oauth-user-lookup-oUllxvAv.mjs.map → oauth-user-lookup-CscEuIiR.mjs.map} +1 -1
  431. package/dist/object-cache/memory.d.mts +1 -1
  432. package/dist/{object-cache-Bok5j2ae.mjs → object-cache-71tPfV4A.mjs} +106 -5
  433. package/dist/object-cache-71tPfV4A.mjs.map +1 -0
  434. package/dist/{options-BqMkWfYa.d.mts → options-CA4eVX6P.d.mts} +3 -3
  435. package/dist/{options-BqMkWfYa.d.mts.map → options-CA4eVX6P.d.mts.map} +1 -1
  436. package/dist/{options-BlmBHTvX.mjs → options-CBXIHUoT.mjs} +1 -1
  437. package/dist/{options-BlmBHTvX.mjs.map → options-CBXIHUoT.mjs.map} +1 -1
  438. package/dist/page/index.d.mts +2 -2
  439. package/dist/{parse-53zyxlpv.mjs → parse-CJKNuewM.mjs} +2 -2
  440. package/dist/{parse-53zyxlpv.mjs.map → parse-CJKNuewM.mjs.map} +1 -1
  441. package/dist/{passkey-config-C-SKpc0-.mjs → passkey-config-D-zrzMJI.mjs} +1 -1
  442. package/dist/{passkey-config-C-SKpc0-.mjs.map → passkey-config-D-zrzMJI.mjs.map} +1 -1
  443. package/dist/{placeholder-Dop47JMM.d.mts → placeholder-DaeNS-VG.d.mts} +1 -1
  444. package/dist/{placeholder-Dop47JMM.d.mts.map → placeholder-DaeNS-VG.d.mts.map} +1 -1
  445. package/dist/plugin-types.d.mts +1 -1
  446. package/dist/plugin-utils.d.mts +10 -10
  447. package/dist/plugins/adapt-sandbox-entry.d.mts +10 -10
  448. package/dist/plugins/adapt-sandbox-entry.mjs +2 -2
  449. package/dist/{portable-text-sDj92Kxv.mjs → portable-text-B_kqBmXB.mjs} +1 -1
  450. package/dist/{portable-text-sDj92Kxv.mjs.map → portable-text-B_kqBmXB.mjs.map} +1 -1
  451. package/dist/{preview-D4Jnbfx7.mjs → preview-BU6PaLpM.mjs} +2 -2
  452. package/dist/{preview-D4Jnbfx7.mjs.map → preview-BU6PaLpM.mjs.map} +1 -1
  453. package/dist/{public-url-DSGTnJFw.mjs → public-url-Ox9oOlgp.mjs} +14 -3
  454. package/dist/public-url-Ox9oOlgp.mjs.map +1 -0
  455. package/dist/{query-Bz9bWZfm.mjs → query-C5w7PsRQ.mjs} +43 -44
  456. package/dist/query-C5w7PsRQ.mjs.map +1 -0
  457. package/dist/{query-DdFGHzQF.mjs → query-rC9HKv1N.mjs} +4 -4
  458. package/dist/{query-DdFGHzQF.mjs.map → query-rC9HKv1N.mjs.map} +1 -1
  459. package/dist/{rate-limit-D3IEiUi2.mjs → rate-limit-kug6q99V.mjs} +2 -2
  460. package/dist/{rate-limit-D3IEiUi2.mjs.map → rate-limit-kug6q99V.mjs.map} +1 -1
  461. package/dist/{redirect-BoUac4NT.mjs → redirect-DIJxXKOG.mjs} +3 -3
  462. package/dist/{redirect-BoUac4NT.mjs.map → redirect-DIJxXKOG.mjs.map} +1 -1
  463. package/dist/{redirect-Botom7X6.mjs → redirect-Egf2R9yP.mjs} +1 -1
  464. package/dist/{redirect-Botom7X6.mjs.map → redirect-Egf2R9yP.mjs.map} +1 -1
  465. package/dist/{redirects-ChbpqKiS.mjs → redirects-Bzm812bY.mjs} +5 -5
  466. package/dist/{redirects-ChbpqKiS.mjs.map → redirects-Bzm812bY.mjs.map} +1 -1
  467. package/dist/{redirects-D457qwt0.mjs → redirects-G8wAhWAf.mjs} +25 -7
  468. package/dist/redirects-G8wAhWAf.mjs.map +1 -0
  469. package/dist/{registry-y21kjhfG.mjs → registry-Dbodb4Uo.mjs} +59 -14
  470. package/dist/registry-Dbodb4Uo.mjs.map +1 -0
  471. package/dist/{relation-Du0r04E0.mjs → relation-Cbe3Sd3m.mjs} +3 -3
  472. package/dist/{relation-Du0r04E0.mjs.map → relation-Cbe3Sd3m.mjs.map} +1 -1
  473. package/dist/{relations-CZMpBqEd.mjs → relations-Bw_E1TXo.mjs} +3 -3
  474. package/dist/{relations-CZMpBqEd.mjs.map → relations-Bw_E1TXo.mjs.map} +1 -1
  475. package/dist/{relations-qKmSj9KM.d.mts → relations-G2ta7GIl.d.mts} +50 -12
  476. package/dist/relations-G2ta7GIl.d.mts.map +1 -0
  477. package/dist/{relations-DtX1UMBH.mjs → relations-qHwpUe66.mjs} +6 -6
  478. package/dist/{relations-DtX1UMBH.mjs.map → relations-qHwpUe66.mjs.map} +1 -1
  479. package/dist/request-context.d.mts +3 -0
  480. package/dist/request-context.d.mts.map +1 -1
  481. package/dist/request-context.mjs.map +1 -1
  482. package/dist/{request-meta-DzXYYI-n.mjs → request-meta-Df-jFbAd.mjs} +2 -2
  483. package/dist/{request-meta-DzXYYI-n.mjs.map → request-meta-Df-jFbAd.mjs.map} +1 -1
  484. package/dist/{resolve-DFr4kq72.mjs → resolve-DZzG4HqM.mjs} +2 -2
  485. package/dist/{resolve-DFr4kq72.mjs.map → resolve-DZzG4HqM.mjs.map} +1 -1
  486. package/dist/{runner-BdeLEgad.mjs → runner-BFTrkYhu.mjs} +497 -213
  487. package/dist/runner-BFTrkYhu.mjs.map +1 -0
  488. package/dist/{runner-Dd8m8k9F.d.mts → runner-BaADli8l.d.mts} +2 -2
  489. package/dist/{runner-Dd8m8k9F.d.mts.map → runner-BaADli8l.d.mts.map} +1 -1
  490. package/dist/runtime.d.mts +11 -11
  491. package/dist/runtime.mjs +3 -3
  492. package/dist/{schema-BH8P8vaC.mjs → schema-CiQXr6_F.mjs} +3 -3
  493. package/dist/{schema-BH8P8vaC.mjs.map → schema-CiQXr6_F.mjs.map} +1 -1
  494. package/dist/{scopes-DTIkIaGA.mjs → scopes-CNJVT5i5.mjs} +3 -3
  495. package/dist/{scopes-DTIkIaGA.mjs.map → scopes-CNJVT5i5.mjs.map} +1 -1
  496. package/dist/{search-D-Yhpmvs.mjs → search-FZhx5dDU.mjs} +7 -7
  497. package/dist/{search-D-Yhpmvs.mjs.map → search-FZhx5dDU.mjs.map} +1 -1
  498. package/dist/{secrets-CQ-69kF9.mjs → secrets-DLd8RXee.mjs} +4 -4
  499. package/dist/{secrets-CQ-69kF9.mjs.map → secrets-DLd8RXee.mjs.map} +1 -1
  500. package/dist/{sections-CzVBAKjw.mjs → sections-BrIrMUCn.mjs} +3 -3
  501. package/dist/{sections-CzVBAKjw.mjs.map → sections-BrIrMUCn.mjs.map} +1 -1
  502. package/dist/seed/index.d.mts +2 -2
  503. package/dist/seed/index.mjs +25 -23
  504. package/dist/seo/index.d.mts +3 -3
  505. package/dist/seo/index.mjs +18 -16
  506. package/dist/seo/index.mjs.map +1 -1
  507. package/dist/{seo-C3GDfT0V.mjs → seo-CobNfOvb.mjs} +2 -2
  508. package/dist/{seo-C3GDfT0V.mjs.map → seo-CobNfOvb.mjs.map} +1 -1
  509. package/dist/{seo-kJzVAmmu.mjs → seo-DTHRntNC.mjs} +3 -3
  510. package/dist/{seo-kJzVAmmu.mjs.map → seo-DTHRntNC.mjs.map} +1 -1
  511. package/dist/{service-CQnc276a.mjs → service-B-pYGPgR.mjs} +4 -4
  512. package/dist/{service-CQnc276a.mjs.map → service-B-pYGPgR.mjs.map} +1 -1
  513. package/dist/{session-user-DbHqKDKe.mjs → session-user-BvM9-zNl.mjs} +2 -2
  514. package/dist/{session-user-DbHqKDKe.mjs.map → session-user-BvM9-zNl.mjs.map} +1 -1
  515. package/dist/{settings-Dtc0DU31.mjs → settings-DPHau-WH.mjs} +3 -3
  516. package/dist/{settings-Dtc0DU31.mjs.map → settings-DPHau-WH.mjs.map} +1 -1
  517. package/dist/{settings-C2PaBS49.mjs → settings-kJhGiQ4z.mjs} +7 -7
  518. package/dist/{settings-C2PaBS49.mjs.map → settings-kJhGiQ4z.mjs.map} +1 -1
  519. package/dist/{setup-complete-CdIlqloh.mjs → setup-complete-u50Qm8rY.mjs} +2 -2
  520. package/dist/{setup-complete-CdIlqloh.mjs.map → setup-complete-u50Qm8rY.mjs.map} +1 -1
  521. package/dist/{setup-nonce-DqiIPr-J.mjs → setup-nonce-DCjiiOD2.mjs} +1 -1
  522. package/dist/{setup-nonce-DqiIPr-J.mjs.map → setup-nonce-DCjiiOD2.mjs.map} +1 -1
  523. package/dist/{single-flight-cache-C2exrGAi.mjs → single-flight-cache-DW3w11Pu.mjs} +1 -1
  524. package/dist/{single-flight-cache-C2exrGAi.mjs.map → single-flight-cache-DW3w11Pu.mjs.map} +1 -1
  525. package/dist/site-url-I-lJ5kma.mjs +16 -0
  526. package/dist/site-url-I-lJ5kma.mjs.map +1 -0
  527. package/dist/{snapshot-BdpUJKD-.mjs → snapshot-I_fjLDaD.mjs} +2 -2
  528. package/dist/{snapshot-BdpUJKD-.mjs.map → snapshot-I_fjLDaD.mjs.map} +1 -1
  529. package/dist/{ssrf-CviKqWmq.mjs → ssrf-CTa6v21i.mjs} +1 -1
  530. package/dist/{ssrf-CviKqWmq.mjs.map → ssrf-CTa6v21i.mjs.map} +1 -1
  531. package/dist/{state-xxv6ZTMv.mjs → state-CQvoefYP.mjs} +1 -1
  532. package/dist/{state-xxv6ZTMv.mjs.map → state-CQvoefYP.mjs.map} +1 -1
  533. package/dist/{status-COfycGIU.mjs → status-CIsmlC1E.mjs} +1 -1
  534. package/dist/{status-COfycGIU.mjs.map → status-CIsmlC1E.mjs.map} +1 -1
  535. package/dist/storage/local.d.mts +1 -1
  536. package/dist/storage/local.mjs +1 -1
  537. package/dist/storage/s3.d.mts +1 -1
  538. package/dist/storage/s3.mjs +2 -2
  539. package/dist/storage/s3.mjs.map +1 -1
  540. package/dist/{taxonomies-BN6M9Nrv.mjs → taxonomies-CKuaZER5.mjs} +90 -9
  541. package/dist/taxonomies-CKuaZER5.mjs.map +1 -0
  542. package/dist/{taxonomies-r7pqLBCn.mjs → taxonomies-CLN1N92E.mjs} +57 -32
  543. package/dist/taxonomies-CLN1N92E.mjs.map +1 -0
  544. package/dist/{taxonomy-0mCI25HN.mjs → taxonomy-pOrB2kZe.mjs} +142 -15
  545. package/dist/taxonomy-pOrB2kZe.mjs.map +1 -0
  546. package/dist/{tokens-DVltpO2D.mjs → tokens-DagaJGK8.mjs} +1 -1
  547. package/dist/{tokens-DVltpO2D.mjs.map → tokens-DagaJGK8.mjs.map} +1 -1
  548. package/dist/{transaction-D0FOsb3X.mjs → transaction-NQj4VJ7Z.mjs} +1 -1
  549. package/dist/{transaction-D0FOsb3X.mjs.map → transaction-NQj4VJ7Z.mjs.map} +1 -1
  550. package/dist/{transport-Vd7VdqHv.d.mts → transport-CAwTaTp_.d.mts} +1 -1
  551. package/dist/{transport-Vd7VdqHv.d.mts.map → transport-CAwTaTp_.d.mts.map} +1 -1
  552. package/dist/{transport-CKrlqSpD.mjs → transport-DVsa5YYo.mjs} +1 -1
  553. package/dist/{transport-CKrlqSpD.mjs.map → transport-DVsa5YYo.mjs.map} +1 -1
  554. package/dist/{trusted-proxy-CwjQj0YG.mjs → trusted-proxy-D20_7fyX.mjs} +1 -1
  555. package/dist/{trusted-proxy-CwjQj0YG.mjs.map → trusted-proxy-D20_7fyX.mjs.map} +1 -1
  556. package/dist/{types-BfYUPJdP.d.mts → types-BGWPMiBO.d.mts} +2 -2
  557. package/dist/{types-BfYUPJdP.d.mts.map → types-BGWPMiBO.d.mts.map} +1 -1
  558. package/dist/{types-iVeZ5g6N.d.mts → types-BK6U01Ro.d.mts} +1 -1
  559. package/dist/{types-iVeZ5g6N.d.mts.map → types-BK6U01Ro.d.mts.map} +1 -1
  560. package/dist/{types-BD40g7zz.mjs → types-BjxTKxrZ.mjs} +1 -1
  561. package/dist/{types-BD40g7zz.mjs.map → types-BjxTKxrZ.mjs.map} +1 -1
  562. package/dist/{types-Kmaxdarz.d.mts → types-BnFP1M3J.d.mts} +22 -1
  563. package/dist/types-BnFP1M3J.d.mts.map +1 -0
  564. package/dist/{types-C7U0HlEr.d.mts → types-C8oz_ayJ.d.mts} +1 -1
  565. package/dist/{types-C7U0HlEr.d.mts.map → types-C8oz_ayJ.d.mts.map} +1 -1
  566. package/dist/{types-B4vm81VH.d.mts → types-CbUcuxxc.d.mts} +1 -1
  567. package/dist/{types-B4vm81VH.d.mts.map → types-CbUcuxxc.d.mts.map} +1 -1
  568. package/dist/{types-CrRUFdej.mjs → types-Cd8iuS1J.mjs} +10 -3
  569. package/dist/{types-CrRUFdej.mjs.map → types-Cd8iuS1J.mjs.map} +1 -1
  570. package/dist/types-CtzytVXn.mjs +18 -0
  571. package/dist/types-CtzytVXn.mjs.map +1 -0
  572. package/dist/{types-BvB7gDOD.d.mts → types-Cz8hNch2.d.mts} +5 -5
  573. package/dist/{types-BvB7gDOD.d.mts.map → types-Cz8hNch2.d.mts.map} +1 -1
  574. package/dist/{types-B97jg3aW.d.mts → types-DLG4IFEQ.d.mts} +1 -1
  575. package/dist/{types-B97jg3aW.d.mts.map → types-DLG4IFEQ.d.mts.map} +1 -1
  576. package/dist/{types-DPKhI5ib.d.mts → types-Dc4ntQjQ.d.mts} +18 -1
  577. package/dist/types-Dc4ntQjQ.d.mts.map +1 -0
  578. package/dist/{types-BNfPHfay.d.mts → types-LoagAGzH.d.mts} +1 -1
  579. package/dist/{types-BNfPHfay.d.mts.map → types-LoagAGzH.d.mts.map} +1 -1
  580. package/dist/{types-o7xo7VgH.mjs → types-NBI3rF-_.mjs} +3 -2
  581. package/dist/types-NBI3rF-_.mjs.map +1 -0
  582. package/dist/upload-attempts-D8QAFLUJ.mjs +27 -0
  583. package/dist/upload-attempts-D8QAFLUJ.mjs.map +1 -0
  584. package/dist/{user-aTXqmXBz.mjs → user-DBrq4UVq.mjs} +3 -3
  585. package/dist/{user-aTXqmXBz.mjs.map → user-DBrq4UVq.mjs.map} +1 -1
  586. package/dist/{utils-BbUgmeZG.mjs → utils-hLzi_2Fn.mjs} +2 -2
  587. package/dist/{utils-BbUgmeZG.mjs.map → utils-hLzi_2Fn.mjs.map} +1 -1
  588. package/dist/{validate-VPnKoIzW.mjs → validate-BpwoDOgt.mjs} +25 -2
  589. package/dist/validate-BpwoDOgt.mjs.map +1 -0
  590. package/dist/{validate-DULfgpJP.d.mts → validate-C3oSmA7F.d.mts} +15 -5
  591. package/dist/validate-C3oSmA7F.d.mts.map +1 -0
  592. package/dist/{validate-CDT1jl6_.mjs → validate-mKo3RxBM.mjs} +4 -4
  593. package/dist/{validate-CDT1jl6_.mjs.map → validate-mKo3RxBM.mjs.map} +1 -1
  594. package/dist/{validation-DlD0E35W.mjs → validation-BgpucsvF.mjs} +11 -9
  595. package/dist/{validation-DlD0E35W.mjs.map → validation-BgpucsvF.mjs.map} +1 -1
  596. package/dist/version-C4PnpmoV.mjs +7 -0
  597. package/dist/{version-BRMngh9I.mjs.map → version-C4PnpmoV.mjs.map} +1 -1
  598. package/dist/{widgets-5fipNkMT.mjs → widgets-CJJtkiKh.mjs} +3 -3
  599. package/dist/{widgets-5fipNkMT.mjs.map → widgets-CJJtkiKh.mjs.map} +1 -1
  600. package/dist/{wxr-taxonomies-DrihupaC.mjs → wxr-taxonomies-9PPSy8X6.mjs} +4 -4
  601. package/dist/{wxr-taxonomies-DrihupaC.mjs.map → wxr-taxonomies-9PPSy8X6.mjs.map} +1 -1
  602. package/dist/{wxr-taxonomies-B4tMuN5T.d.mts → wxr-taxonomies-Bkpp_2tK.d.mts} +1 -1
  603. package/dist/{wxr-taxonomies-B4tMuN5T.d.mts.map → wxr-taxonomies-Bkpp_2tK.d.mts.map} +1 -1
  604. package/dist/{zod-generator-CwkHWz4f.mjs → zod-generator-CG64Hnbh.mjs} +3 -3
  605. package/dist/{zod-generator-CwkHWz4f.mjs.map → zod-generator-CG64Hnbh.mjs.map} +1 -1
  606. package/package.json +12 -8
  607. package/src/after.ts +6 -1
  608. package/src/api/errors.ts +1 -0
  609. package/src/api/handlers/content.ts +45 -4
  610. package/src/api/handlers/marketplace.ts +14 -0
  611. package/src/api/handlers/media.ts +4 -4
  612. package/src/api/handlers/registry.ts +14 -0
  613. package/src/api/handlers/revision.ts +19 -5
  614. package/src/api/handlers/schema.ts +37 -0
  615. package/src/api/handlers/snapshot.ts +1 -1
  616. package/src/api/handlers/taxonomies.ts +111 -10
  617. package/src/api/openapi/document.ts +84 -3
  618. package/src/api/public-url.ts +14 -2
  619. package/src/api/schemas/media.ts +9 -2
  620. package/src/api/schemas/schema.ts +13 -0
  621. package/src/api/schemas/search.ts +2 -0
  622. package/src/api/schemas/taxonomies.ts +34 -1
  623. package/src/api/site-url.ts +16 -6
  624. package/src/astro/integration/routes.ts +19 -0
  625. package/src/astro/integration/runtime.ts +13 -0
  626. package/src/astro/integration/virtual-modules.ts +2 -0
  627. package/src/astro/middleware/redirect.ts +2 -10
  628. package/src/astro/middleware/scoped-db.ts +35 -4
  629. package/src/astro/middleware.ts +56 -22
  630. package/src/astro/routes/api/admin/comments/[id]/status.ts +1 -1
  631. package/src/astro/routes/api/admin/users/[id]/send-recovery.ts +2 -2
  632. package/src/astro/routes/api/auth/invite/index.ts +2 -2
  633. package/src/astro/routes/api/auth/magic-link/send.ts +2 -2
  634. package/src/astro/routes/api/auth/signup/request.ts +2 -2
  635. package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +1 -1
  636. package/src/astro/routes/api/content/[collection]/[id].ts +3 -1
  637. package/src/astro/routes/api/media/[id]/confirm.ts +148 -59
  638. package/src/astro/routes/api/media/[id]/upload.ts +262 -0
  639. package/src/astro/routes/api/media/[id].ts +19 -10
  640. package/src/astro/routes/api/media/upload-url.ts +28 -31
  641. package/src/astro/routes/api/schema/collections/reorder.ts +31 -0
  642. package/src/astro/routes/api/schema/index.ts +2 -0
  643. package/src/astro/routes/api/search/enable.ts +5 -1
  644. package/src/astro/routes/api/search/rebuild.ts +6 -1
  645. package/src/astro/routes/api/taxonomies/[name]/reorder.ts +41 -0
  646. package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +6 -3
  647. package/src/astro/types.ts +7 -0
  648. package/src/cleanup.ts +54 -26
  649. package/src/cli/commands/dev.ts +13 -3
  650. package/src/cli/commands/export-seed.ts +2 -0
  651. package/src/cli/index.ts +1 -1
  652. package/src/components/CommentForm.astro +1 -1
  653. package/src/components/Comments.astro +1 -1
  654. package/src/components/InlinePortableTextEditor.tsx +175 -31
  655. package/src/components/OrderedList.astro +14 -0
  656. package/src/components/PortableText.astro +26 -4
  657. package/src/components/code-mark.ts +11 -0
  658. package/src/components/index.ts +12 -1
  659. package/src/components/ordered-list.ts +549 -0
  660. package/src/content/converters/numbered-list.ts +148 -0
  661. package/src/content/converters/portable-text-to-prosemirror.ts +59 -9
  662. package/src/content/converters/prosemirror-to-portable-text.ts +23 -12
  663. package/src/content/converters/types.ts +2 -0
  664. package/src/content/portable-text-lists.ts +205 -0
  665. package/src/database/dialect-helpers.ts +41 -22
  666. package/src/database/migrations/054_media_upload_attempts.ts +41 -0
  667. package/src/database/migrations/055_content_translation_group_locale_index.ts +67 -0
  668. package/src/database/migrations/056_taxonomy_term_sort_order.ts +189 -0
  669. package/src/database/migrations/057_collection_hidden.ts +24 -0
  670. package/src/database/migrations/058_collection_sort_order.ts +20 -0
  671. package/src/database/migrations/059_revision_prune_queue.ts +36 -0
  672. package/src/database/migrations/runner.ts +12 -0
  673. package/src/database/repositories/content.ts +193 -183
  674. package/src/database/repositories/media.ts +158 -28
  675. package/src/database/repositories/revision.ts +82 -17
  676. package/src/database/repositories/taxonomy.ts +202 -7
  677. package/src/database/repositories/types.ts +7 -0
  678. package/src/database/types.ts +23 -1
  679. package/src/database/validate.ts +39 -0
  680. package/src/db/adapters.ts +8 -0
  681. package/src/deferred-tasks.ts +71 -0
  682. package/src/emdash-runtime.ts +277 -88
  683. package/src/i18n/config.ts +17 -10
  684. package/src/index.ts +3 -0
  685. package/src/loader.ts +46 -24
  686. package/src/media/upload-attempts.ts +33 -0
  687. package/src/media/usage/gc.ts +50 -0
  688. package/src/object-cache/index.ts +160 -3
  689. package/src/plugins/routes.ts +34 -0
  690. package/src/plugins/storage-indexes.ts +50 -11
  691. package/src/query.ts +50 -44
  692. package/src/redirects/cache.ts +79 -19
  693. package/src/request-context.ts +3 -0
  694. package/src/scheduled-publish.ts +6 -1
  695. package/src/schema/registry.ts +95 -3
  696. package/src/schema/types.ts +24 -0
  697. package/src/search/fts-manager.ts +50 -10
  698. package/src/search/index.ts +2 -0
  699. package/src/search/types.ts +6 -0
  700. package/src/seed/apply.ts +22 -2
  701. package/src/seed/types.ts +10 -0
  702. package/src/storage/s3.ts +1 -1
  703. package/src/taxonomies/index.ts +11 -7
  704. package/src/taxonomies/term-counts.ts +56 -28
  705. package/src/ui-comments.ts +19 -0
  706. package/src/ui.ts +11 -3
  707. package/src/utils/hash.ts +14 -3
  708. package/src/virtual-modules.d.ts +8 -0
  709. package/dist/adapters-C0ONzkUP.d.mts.map +0 -1
  710. package/dist/after-B1IIdH3Y.mjs +0 -29
  711. package/dist/after-B1IIdH3Y.mjs.map +0 -1
  712. package/dist/api-BkqFzIu4.mjs.map +0 -1
  713. package/dist/apply-DuXsqll7.mjs.map +0 -1
  714. package/dist/cache-DDwy3JDW.mjs +0 -65
  715. package/dist/cache-DDwy3JDW.mjs.map +0 -1
  716. package/dist/config-B6b_BobR.mjs.map +0 -1
  717. package/dist/content-BC43pICM.mjs.map +0 -1
  718. package/dist/dialect-helpers-BtOwo2us.mjs.map +0 -1
  719. package/dist/errors-DtEXIQQV.mjs.map +0 -1
  720. package/dist/fts-manager-hyCU9OOp.mjs.map +0 -1
  721. package/dist/hash-DFFrkivP.mjs.map +0 -1
  722. package/dist/index-BZJ_5FOX.d.mts.map +0 -1
  723. package/dist/loader-D4rigvjR.mjs.map +0 -1
  724. package/dist/media-its1WLYv.mjs.map +0 -1
  725. package/dist/menus-CPf_SW7u.mjs.map +0 -1
  726. package/dist/object-cache-Bok5j2ae.mjs.map +0 -1
  727. package/dist/public-url-DSGTnJFw.mjs.map +0 -1
  728. package/dist/query-Bz9bWZfm.mjs.map +0 -1
  729. package/dist/redirects-D457qwt0.mjs.map +0 -1
  730. package/dist/registry-y21kjhfG.mjs.map +0 -1
  731. package/dist/relations-qKmSj9KM.d.mts.map +0 -1
  732. package/dist/runner-BdeLEgad.mjs.map +0 -1
  733. package/dist/site-url-NGJT6NTU.mjs +0 -13
  734. package/dist/site-url-NGJT6NTU.mjs.map +0 -1
  735. package/dist/taxonomies-BN6M9Nrv.mjs.map +0 -1
  736. package/dist/taxonomies-r7pqLBCn.mjs.map +0 -1
  737. package/dist/taxonomy-0mCI25HN.mjs.map +0 -1
  738. package/dist/types-DPKhI5ib.d.mts.map +0 -1
  739. package/dist/types-Kmaxdarz.d.mts.map +0 -1
  740. package/dist/types-o7xo7VgH.mjs.map +0 -1
  741. package/dist/validate-DULfgpJP.d.mts.map +0 -1
  742. package/dist/validate-VPnKoIzW.mjs.map +0 -1
  743. package/dist/version-BRMngh9I.mjs +0 -7
  744. /package/dist/{api-tokens-Cvmixds7.mjs → api-tokens-Dai9dND0.mjs} +0 -0
  745. /package/dist/{ssrf-BB__xfNM.mjs → ssrf-Cj568Dgs.mjs} +0 -0
  746. /package/dist/{types-CK0LxPUQ.mjs → types-DKuWPYV5.mjs} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"_taxonomy_.mjs","names":[],"sources":["../../../../../../../../src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts"],"sourcesContent":["/**\n * Content-taxonomy association endpoint\n *\n * GET /_emdash/api/content/:collection/:id/terms/:taxonomy - Get terms for an entry\n * POST /_emdash/api/content/:collection/:id/terms/:taxonomy - Set terms for an entry\n */\n\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm, requireOwnerPerm } from \"#api/authorize.js\";\nimport { apiError, apiSuccess, handleError, requireDb } from \"#api/error.js\";\nimport { parseBody, isParseError } from \"#api/parse.js\";\nimport { contentTermsBody } from \"#api/schemas.js\";\nimport { ContentRepository } from \"#db/repositories/content.js\";\nimport { TaxonomyRepository } from \"#db/repositories/taxonomy.js\";\nimport { invalidateTermCache } from \"#taxonomies/index.js\";\n\nexport const prerender = false;\n\n/**\n * Get terms assigned to an entry\n */\nexport const GET: APIRoute = async ({ params, locals }) => {\n\tconst { emdash, user } = locals;\n\tconst { collection, id, taxonomy } = params;\n\n\tconst dbErr = requireDb(emdash?.db);\n\tif (dbErr) return dbErr;\n\tconst denied = requirePerm(user, \"content:read\");\n\tif (denied) return denied;\n\n\tif (!collection || !id || !taxonomy) {\n\t\treturn apiError(\"VALIDATION_ERROR\", \"Collection, id, and taxonomy required\", 400);\n\t}\n\n\ttry {\n\t\t// Terms are stored against the per-locale entry row but their\n\t\t// translation_group spans every locale. Resolve the entry's own locale\n\t\t// server-side (deterministic, not client-spoofable) so only the matching\n\t\t// term variant is returned — see issue #1218.\n\t\tconst entry = await new ContentRepository(emdash.db).findByIdOrSlug(collection, id);\n\t\tif (!entry) return apiError(\"NOT_FOUND\", \"Content not found\", 404);\n\t\tconst locale = entry.locale ?? undefined;\n\n\t\tconst repo = new TaxonomyRepository(emdash.db);\n\t\tconst terms = await repo.getTermsForEntry(collection, entry.id, taxonomy, locale);\n\n\t\treturn apiSuccess({\n\t\t\tterms: terms.map((t) => ({\n\t\t\t\tid: t.id,\n\t\t\t\tname: t.name,\n\t\t\t\tslug: t.slug,\n\t\t\t\tlabel: t.label,\n\t\t\t\tparentId: t.parentId,\n\t\t\t})),\n\t\t});\n\t} catch (error) {\n\t\treturn handleError(error, \"Failed to get entry terms\", \"TERMS_GET_ERROR\");\n\t}\n};\n\n/**\n * Set terms for an entry (replaces existing)\n */\nexport const POST: APIRoute = async ({ params, request, locals }) => {\n\tconst { emdash, user } = locals;\n\tconst { collection, id, taxonomy } = params;\n\n\tif (!collection || !id || !taxonomy) {\n\t\treturn apiError(\"VALIDATION_ERROR\", \"Collection, id, and taxonomy required\", 400);\n\t}\n\n\tconst dbErr = requireDb(emdash?.db);\n\tif (dbErr) return dbErr;\n\tconst denied = requirePerm(user, \"content:edit_own\");\n\tif (denied) return denied;\n\n\tif (!emdash.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\t// Verify the content exists before modifying its terms\n\tconst existing = await emdash.handleContentGet(collection, id);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"NOT_FOUND\",\n\t\t\texisting.error?.message ?? \"Content not found\",\n\t\t\texisting.error?.code === \"NOT_FOUND\" ? 404 : 500,\n\t\t);\n\t}\n\n\t// Check ownership for edit permission\n\tconst existingData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership check\n\tconst existingItem =\n\t\texistingData?.item && typeof existingData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(existingData.item as Record<string, unknown>)\n\t\t\t: existingData;\n\tconst authorId = typeof existingItem?.authorId === \"string\" ? existingItem.authorId : \"\";\n\tconst editDenied = requireOwnerPerm(user, authorId, \"content:edit_own\", \"content:edit_any\");\n\tif (editDenied) return editDenied;\n\n\t// Resolve the canonical content ID from the handler result.\n\t// The URL `id` param may be a slug; we must use the real ID for term storage.\n\tconst canonicalId = typeof existingItem?.id === \"string\" ? existingItem.id : id;\n\t// The entry is per-locale; scope the term read to its locale so only the\n\t// matching translation variant is returned in the response — see #1218.\n\tconst entryLocale = typeof existingItem?.locale === \"string\" ? existingItem.locale : undefined;\n\n\ttry {\n\t\tconst body = await parseBody(request, contentTermsBody);\n\t\tif (isParseError(body)) return body;\n\t\tconst { termIds } = body;\n\n\t\tconst repo = new TaxonomyRepository(emdash.db);\n\n\t\t// Verify all term IDs exist and belong to the correct taxonomy\n\t\tfor (const termId of termIds) {\n\t\t\tconst term = await repo.findById(termId);\n\t\t\tif (!term) {\n\t\t\t\treturn apiError(\"NOT_FOUND\", `Term ID '${termId}' not found`, 404);\n\t\t\t}\n\t\t\tif (term.name !== taxonomy) {\n\t\t\t\treturn apiError(\n\t\t\t\t\t\"VALIDATION_ERROR\",\n\t\t\t\t\t`Term ID '${termId}' does not belong to taxonomy '${taxonomy}'`,\n\t\t\t\t\t400,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Set the terms (replaces existing) using the canonical ID\n\t\tawait repo.setTermsForEntry(collection, canonicalId, taxonomy, termIds);\n\n\t\t// Term assignments changed — invalidate the hasAnyTermAssignments cache\n\t\t// so hydration on subsequent reads issues a fresh query.\n\t\tinvalidateTermCache();\n\n\t\t// Get the updated terms using the canonical ID, scoped to the entry locale\n\t\tconst terms = await repo.getTermsForEntry(collection, canonicalId, taxonomy, entryLocale);\n\n\t\treturn apiSuccess({\n\t\t\tterms: terms.map((t) => ({\n\t\t\t\tid: t.id,\n\t\t\t\tname: t.name,\n\t\t\t\tslug: t.slug,\n\t\t\t\tlabel: t.label,\n\t\t\t\tparentId: t.parentId,\n\t\t\t})),\n\t\t});\n\t} catch (error) {\n\t\treturn handleError(error, \"Failed to set entry terms\", \"TERMS_SET_ERROR\");\n\t}\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,YAAY;;;;AAKzB,MAAa,MAAgB,OAAO,EAAE,QAAQ,aAAa;CAC1D,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,YAAY,IAAI,aAAa;CAErC,MAAM,QAAQ,UAAU,QAAQ,GAAG;AACnC,KAAI,MAAO,QAAO;CAClB,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,QAAO;AAEnB,KAAI,CAAC,cAAc,CAAC,MAAM,CAAC,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M,aAAa,iBAAiB,MADnB,OAAO,cAAc,aAAa,WAAW,aAAa,WAAW,IAClC,oBAAoB,mBAAmB;AAC3F,KAAI,WAAY,QAAO;CAIvB,MAAM,cAAc,OAAO,cAAc,OAAO,WAAW,aAAa,KAAK;CAG7E,MAAM,cAAc,OAAO,cAAc,WAAW,WAAW,aAAa,SAAS;AAErF,KAAI;EACH,MAAM,OAAO,MAAM,UAAU,SAAS,iBAAiB;AACvD,MAAI,aAAa,KAAK,CAAE,QAAO;EAC/B,MAAM,EAAE,YAAY;EAEpB,MAAM,OAAO,IAAI,mBAAmB,OAAO,GAAG;AAG9C,OAAK,MAAM,UAAU,SAAS;GAC7B,MAAM,OAAO,MAAM,KAAK,SAAS,OAAO;AACxC,OAAI,CAAC,KACJ,QAAO,SAAS,aAAa,YAAY,OAAO,cAAc,IAAI;AAEnE,OAAI,KAAK,SAAS,SACjB,QAAO,SACN,oBACA,YAAY,OAAO,iCAAiC,SAAS,IAC7D,IACA;;AAKH,QAAM,KAAK,iBAAiB,YAAY,aAAa,UAAU,QAAQ;AAIvE,uBAAqB;AAKrB,SAAO,WAAW,EACjB,QAHa,MAAM,KAAK,iBAAiB,YAAY,aAAa,UAAU,YAAY,EAG3E,KAAK,OAAO;GACxB,IAAI,EAAE;GACN,MAAM,EAAE;GACR,MAAM,EAAE;GACR,OAAO,EAAE;GACT,UAAU,EAAE;GACZ,EAAE,EACH,CAAC;UACM,OAAO;AACf,SAAO,YAAY,OAAO,6BAA6B,kBAAkB"}
1
+ {"version":3,"file":"_taxonomy_.mjs","names":[],"sources":["../../../../../../../../src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts"],"sourcesContent":["/**\n * Content-taxonomy association endpoint\n *\n * GET /_emdash/api/content/:collection/:id/terms/:taxonomy - Get terms for an entry\n * POST /_emdash/api/content/:collection/:id/terms/:taxonomy - Set terms for an entry\n */\n\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm, requireOwnerPerm } from \"#api/authorize.js\";\nimport { apiError, apiSuccess, handleError, requireDb } from \"#api/error.js\";\nimport { parseBody, isParseError } from \"#api/parse.js\";\nimport { contentTermsBody } from \"#api/schemas.js\";\nimport { ContentRepository } from \"#db/repositories/content.js\";\nimport { TaxonomyRepository } from \"#db/repositories/taxonomy.js\";\nimport { invalidateTermCache } from \"#taxonomies/index.js\";\n\nexport const prerender = false;\n\n/**\n * Get terms assigned to an entry\n */\nexport const GET: APIRoute = async ({ params, locals }) => {\n\tconst { emdash, user } = locals;\n\tconst { collection, id, taxonomy } = params;\n\n\tconst dbErr = requireDb(emdash?.db);\n\tif (dbErr) return dbErr;\n\tconst denied = requirePerm(user, \"content:read\");\n\tif (denied) return denied;\n\n\tif (!collection || !id || !taxonomy) {\n\t\treturn apiError(\"VALIDATION_ERROR\", \"Collection, id, and taxonomy required\", 400);\n\t}\n\n\ttry {\n\t\t// Terms are stored against the per-locale entry row but their\n\t\t// translation_group spans every locale. Resolve the entry's own locale\n\t\t// server-side (deterministic, not client-spoofable) so only the matching\n\t\t// term variant is returned — see issue #1218.\n\t\tconst entry = await new ContentRepository(emdash.db).findByIdOrSlug(collection, id);\n\t\tif (!entry) return apiError(\"NOT_FOUND\", \"Content not found\", 404);\n\t\tconst locale = entry.locale ?? undefined;\n\n\t\tconst repo = new TaxonomyRepository(emdash.db);\n\t\tconst terms = await repo.getTermsForEntry(collection, entry.id, taxonomy, locale);\n\n\t\treturn apiSuccess({\n\t\t\tterms: terms.map((t) => ({\n\t\t\t\tid: t.id,\n\t\t\t\tname: t.name,\n\t\t\t\tslug: t.slug,\n\t\t\t\tlabel: t.label,\n\t\t\t\tparentId: t.parentId,\n\t\t\t})),\n\t\t});\n\t} catch (error) {\n\t\treturn handleError(error, \"Failed to get entry terms\", \"TERMS_GET_ERROR\");\n\t}\n};\n\n/**\n * Set terms for an entry (replaces existing)\n */\nexport const POST: APIRoute = async ({ params, request, locals }) => {\n\tconst { emdash, user } = locals;\n\tconst { collection, id, taxonomy } = params;\n\n\tif (!collection || !id || !taxonomy) {\n\t\treturn apiError(\"VALIDATION_ERROR\", \"Collection, id, and taxonomy required\", 400);\n\t}\n\n\tconst dbErr = requireDb(emdash?.db);\n\tif (dbErr) return dbErr;\n\tconst denied = requirePerm(user, \"content:edit_own\");\n\tif (denied) return denied;\n\n\tif (!emdash.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\t// Verify the content exists before modifying its terms\n\tconst existing = await emdash.handleContentGet(collection, id);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"NOT_FOUND\",\n\t\t\texisting.error?.message ?? \"Content not found\",\n\t\t\texisting.error?.code === \"NOT_FOUND\" ? 404 : 500,\n\t\t);\n\t}\n\n\t// Check ownership for edit permission\n\tconst existingData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership check\n\tconst existingItem =\n\t\texistingData?.item && typeof existingData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(existingData.item as Record<string, unknown>)\n\t\t\t: existingData;\n\tconst authorId = typeof existingItem?.authorId === \"string\" ? existingItem.authorId : \"\";\n\tconst editDenied = requireOwnerPerm(user, authorId, \"content:edit_own\", \"content:edit_any\");\n\tif (editDenied) return editDenied;\n\n\t// Resolve the canonical content ID from the handler result.\n\t// The URL `id` param may be a slug; we must use the real ID for term storage.\n\tconst canonicalId = typeof existingItem?.id === \"string\" ? existingItem.id : id;\n\t// The entry is per-locale; scope the term read to its locale so only the\n\t// matching translation variant is returned in the response — see #1218.\n\tconst entryLocale = typeof existingItem?.locale === \"string\" ? existingItem.locale : undefined;\n\n\ttry {\n\t\tconst body = await parseBody(request, contentTermsBody);\n\t\tif (isParseError(body)) return body;\n\t\tconst { termIds } = body;\n\n\t\tconst repo = new TaxonomyRepository(emdash.db);\n\n\t\t// Verify all term IDs exist and belong to the correct taxonomy\n\t\tfor (const termId of termIds) {\n\t\t\tconst term = await repo.findById(termId);\n\t\t\tif (!term) {\n\t\t\t\treturn apiError(\"NOT_FOUND\", `Term ID '${termId}' not found`, 404);\n\t\t\t}\n\t\t\tif (term.name !== taxonomy) {\n\t\t\t\treturn apiError(\n\t\t\t\t\t\"VALIDATION_ERROR\",\n\t\t\t\t\t`Term ID '${termId}' does not belong to taxonomy '${taxonomy}'`,\n\t\t\t\t\t400,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Set the terms (replaces existing) using the canonical ID\n\t\tawait repo.setTermsForEntry(collection, canonicalId, taxonomy, termIds);\n\n\t\t// Term assignments changed — invalidate the hasAnyTermAssignments cache\n\t\t// so hydration on subsequent reads issues a fresh query.\n\t\tinvalidateTermCache();\n\n\t\t// Get the updated terms using the canonical ID, scoped to the entry locale\n\t\tconst terms = await repo.getTermsForEntry(collection, canonicalId, taxonomy, entryLocale);\n\n\t\treturn apiSuccess({\n\t\t\tterms: terms.map((t) => ({\n\t\t\t\tid: t.id,\n\t\t\t\tname: t.name,\n\t\t\t\tslug: t.slug,\n\t\t\t\tlabel: t.label,\n\t\t\t\tparentId: t.parentId,\n\t\t\t})),\n\t\t});\n\t} catch (error) {\n\t\treturn handleError(error, \"Failed to set entry terms\", \"TERMS_SET_ERROR\");\n\t}\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAa,YAAY;;;;AAKzB,MAAa,MAAgB,OAAO,EAAE,QAAQ,aAAa;CAC1D,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,YAAY,IAAI,aAAa;CAErC,MAAM,QAAQ,UAAU,QAAQ,GAAG;AACnC,KAAI,MAAO,QAAO;CAClB,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,Q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,OAAO,aAAa,SAAS,WAEhD,aAAa,OACb;CAEJ,MAAM,aAAa,iBAAiB,MADnB,OAAO,cAAc,aAAa,WAAW,aAAa,WAAW,IAClC,oBAAoB,mBAAmB;AAC3F,KAAI,WAAY,QAAO;CAIvB,MAAM,cAAc,OAAO,cAAc,OAAO,WAAW,aAAa,KAAK;CAG7E,MAAM,cAAc,OAAO,cAAc,WAAW,WAAW,aAAa,SAAS;AAErF,KAAI;EACH,MAAM,OAAO,MAAM,UAAU,SAAS,iBAAiB;AACvD,MAAI,aAAa,KAAK,CAAE,QAAO;EAC/B,MAAM,EAAE,YAAY;EAEpB,MAAM,OAAO,IAAI,mBAAmB,OAAO,GAAG;AAG9C,OAAK,MAAM,UAAU,SAAS;GAC7B,MAAM,OAAO,MAAM,KAAK,SAAS,OAAO;AACxC,OAAI,CAAC,KACJ,QAAO,SAAS,aAAa,YAAY,OAAO,cAAc,IAAI;AAEnE,OAAI,KAAK,SAAS,SACjB,QAAO,SACN,oBACA,YAAY,OAAO,iCAAiC,SAAS,IAC7D,IACA;;AAKH,QAAM,KAAK,iBAAiB,YAAY,aAAa,UAAU,QAAQ;AAIvE,uBAAqB;AAKrB,SAAO,WAAW,EACjB,QAHa,MAAM,KAAK,iBAAiB,YAAY,aAAa,UAAU,YAAY,EAG3E,KAAK,OAAO;GACxB,IAAI,EAAE;GACN,MAAM,EAAE;GACR,MAAM,EAAE;GACR,OAAO,EAAE;GACT,UAAU,EAAE;GACZ,EAAE,EACH,CAAC;UACM,OAAO;AACf,SAAO,YAAY,OAAO,6BAA6B,kBAAkB"}
@@ -1,7 +1,7 @@
1
1
  import "../../../../../../base64-B-PsqheR.mjs";
2
- import "../../../../../../types-CrRUFdej.mjs";
3
- import { a as unwrapResult, t as apiError } from "../../../../../../error-DJ98TRbQ.mjs";
4
- import { r as requirePerm } from "../../../../../../authorize-6WPZa1xZ.mjs";
2
+ import "../../../../../../types-Cd8iuS1J.mjs";
3
+ import { a as unwrapResult, t as apiError } from "../../../../../../error-oh_9i6bR.mjs";
4
+ import { r as requirePerm } from "../../../../../../authorize-qRhWQnel.mjs";
5
5
  import { hasPermission } from "@emdash-cms/auth";
6
6
 
7
7
  //#region src/astro/routes/api/content/[collection]/[id]/translations.ts
@@ -1,8 +1,8 @@
1
1
  import "../../../../../../base64-B-PsqheR.mjs";
2
- import "../../../../../../types-CrRUFdej.mjs";
3
- import { n as mapErrorStatus } from "../../../../../../errors-DtEXIQQV.mjs";
4
- import { a as unwrapResult, t as apiError } from "../../../../../../error-DJ98TRbQ.mjs";
5
- import { n as requireOwnerPerm } from "../../../../../../authorize-6WPZa1xZ.mjs";
2
+ import "../../../../../../types-Cd8iuS1J.mjs";
3
+ import { n as mapErrorStatus } from "../../../../../../errors-BucQ8VYz.mjs";
4
+ import { a as unwrapResult, t as apiError } from "../../../../../../error-oh_9i6bR.mjs";
5
+ import { n as requireOwnerPerm } from "../../../../../../authorize-qRhWQnel.mjs";
6
6
 
7
7
  //#region src/astro/routes/api/content/[collection]/[id]/unpublish.ts
8
8
  const prerender = false;
@@ -1 +1 @@
1
- {"version":3,"file":"_id_.d.mts","names":[],"sources":["../../../../../../src/astro/routes/api/content/[collection]/[id].ts"],"mappings":";;;cAgBa,SAAA;AAAA,cAEA,GAAA,EAAK,QAAA;AAAA,cA+CL,GAAA,EAAK,QAAA;AAAA,cAoEL,MAAA,EAAQ,QAAA"}
1
+ {"version":3,"file":"_id_.d.mts","names":[],"sources":["../../../../../../src/astro/routes/api/content/[collection]/[id].ts"],"mappings":";;;cAgBa,SAAA;AAAA,cAEA,GAAA,EAAK,QAAA;AAAA,cA+CL,GAAA,EAAK,QAAA;AAAA,cAsEL,MAAA,EAAQ,QAAA"}
@@ -1,14 +1,14 @@
1
1
  import "../../../../../base64-B-PsqheR.mjs";
2
- import "../../../../../types-CrRUFdej.mjs";
3
- import { n as mapErrorStatus } from "../../../../../errors-DtEXIQQV.mjs";
4
- import { a as unwrapResult, t as apiError } from "../../../../../error-DJ98TRbQ.mjs";
5
- import { n as parseBody, t as isParseError } from "../../../../../parse-53zyxlpv.mjs";
6
- import "../../../../../media-BJ6SRY3g.mjs";
7
- import { rn as contentUpdateBody } from "../../../../../redirects-D457qwt0.mjs";
8
- import "../../../../../relations-CZMpBqEd.mjs";
9
- import "../../../../../status-COfycGIU.mjs";
2
+ import "../../../../../types-Cd8iuS1J.mjs";
3
+ import { n as mapErrorStatus } from "../../../../../errors-BucQ8VYz.mjs";
4
+ import { a as unwrapResult, t as apiError } from "../../../../../error-oh_9i6bR.mjs";
5
+ import { n as parseBody, t as isParseError } from "../../../../../parse-CJKNuewM.mjs";
6
+ import "../../../../../media-OhYL-7Io.mjs";
7
+ import { sn as contentUpdateBody } from "../../../../../redirects-G8wAhWAf.mjs";
8
+ import "../../../../../relations-Bw_E1TXo.mjs";
9
+ import "../../../../../status-CIsmlC1E.mjs";
10
10
  import "../../../../../api/schemas/index.mjs";
11
- import { n as requireOwnerPerm, r as requirePerm } from "../../../../../authorize-6WPZa1xZ.mjs";
11
+ import { n as requireOwnerPerm, r as requirePerm } from "../../../../../authorize-qRhWQnel.mjs";
12
12
  import { hasPermission } from "@emdash-cms/auth";
13
13
 
14
14
  //#region src/astro/routes/api/content/[collection]/[id].ts
@@ -67,7 +67,7 @@ const PUT = async ({ params, request, locals, cache }) => {
67
67
  _rev: body._rev
68
68
  });
69
69
  if (!result.success) return unwrapResult(result);
70
- if (cache?.enabled) await cache.invalidate({ tags: [collection, resolvedId] });
70
+ if (cache?.enabled && result.liveContentChanged !== false) await cache.invalidate({ tags: [collection, resolvedId] });
71
71
  return unwrapResult(result);
72
72
  };
73
73
  const DELETE = async ({ params, locals, url, cache }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"_id_.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/content/[collection]/[id].ts"],"sourcesContent":["/**\n * Single content item endpoints - injected by EmDash integration\n *\n * GET /_emdash/api/content/{collection}/{id} - Get content\n * PUT /_emdash/api/content/{collection}/{id} - Update content\n * DELETE /_emdash/api/content/{collection}/{id} - Delete content\n */\n\nimport { hasPermission } from \"@emdash-cms/auth\";\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm, requireOwnerPerm } from \"#api/authorize.js\";\nimport { apiError, mapErrorStatus, unwrapResult } from \"#api/error.js\";\nimport { parseBody, isParseError } from \"#api/parse.js\";\nimport { contentUpdateBody } from \"#api/schemas.js\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ params, url, locals }) => {\n\tconst { emdash, user } = locals;\n\tif (!emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\tconst denied = requirePerm(user, \"content:read\");\n\tif (denied) return denied;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\tconst locale = url.searchParams.get(\"locale\") || undefined;\n\n\tconst result = await emdash.handleContentGet(collection, id, locale);\n\n\t// Hide non-published items from users without content:read_drafts. Return\n\t// 404 (not 403) so subscribers can't enumerate draft IDs by status code.\n\tif (result.success && !hasPermission(user, \"content:read_drafts\")) {\n\t\tconst data =\n\t\t\tresult.data && typeof result.data === \"object\"\n\t\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check\n\t\t\t\t\t(result.data as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tconst item =\n\t\t\tdata?.item && typeof data.item === \"object\"\n\t\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check\n\t\t\t\t\t(data.item as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tconst status = typeof item?.status === \"string\" ? item.status : null;\n\t\tif (status !== \"published\") {\n\t\t\treturn apiError(\"NOT_FOUND\", `Content item not found: ${id}`, 404);\n\t\t}\n\n\t\t// Strip draft hydration data from response for users without read_drafts.\n\t\t// handleContentGet overlays draft revision data onto item.data and exposes\n\t\t// the published values in item.liveData. Without this, subscribers see\n\t\t// unpublished edits in the data field.\n\t\tif (item) {\n\t\t\tif (item.liveData && typeof item.liveData === \"object\") {\n\t\t\t\titem.data = item.liveData;\n\t\t\t}\n\t\t\tdelete item.liveData;\n\t\t\tdelete item.draftRevisionId;\n\t\t}\n\t}\n\n\treturn unwrapResult(result);\n};\n\nexport const PUT: APIRoute = async ({ params, request, locals, cache }) => {\n\tconst { emdash, user } = locals;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\tconst locale = new URL(request.url).searchParams.get(\"locale\") || undefined;\n\tconst body = await parseBody(request, contentUpdateBody);\n\tif (isParseError(body)) return body;\n\n\tif (!emdash?.handleContentUpdate || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\t// Fetch item to check ownership\n\tconst existing = await emdash.handleContentGet(collection, id, locale);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"UNKNOWN_ERROR\",\n\t\t\texisting.error?.message ?? \"Unknown error\",\n\t\t\tmapErrorStatus(existing.error?.code),\n\t\t);\n\t}\n\n\tconst existingData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership and ID resolution\n\tconst existingItem =\n\t\texistingData?.item && typeof existingData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(existingData.item as Record<string, unknown>)\n\t\t\t: existingData;\n\tconst authorId = typeof existingItem?.authorId === \"string\" ? existingItem.authorId : \"\";\n\tconst editDenied = requireOwnerPerm(user, authorId, \"content:edit_own\", \"content:edit_any\");\n\tif (editDenied) return editDenied;\n\n\t// Only EDITOR+ can write publishedAt directly — incl. clearing to null.\n\tif (body.publishedAt !== undefined && !hasPermission(user, \"content:publish_any\")) {\n\t\treturn apiError(\n\t\t\t\"FORBIDDEN\",\n\t\t\t\"Writing publishedAt requires content:publish_any permission\",\n\t\t\t403,\n\t\t);\n\t}\n\n\t// Use the resolved ID (handles slug → ID resolution)\n\tconst resolvedId = typeof existingItem?.id === \"string\" ? existingItem.id : id;\n\n\t// Only allow authorId changes if user has content:edit_any permission (editor+)\n\tconst canChangeAuthor =\n\t\tbody.authorId !== undefined && user && hasPermission(user, \"content:edit_any\");\n\tconst updateBody = canChangeAuthor ? body : { ...body, authorId: undefined };\n\n\t// Pass _rev through for optimistic concurrency validation\n\tconst result = await emdash.handleContentUpdate(collection, resolvedId, {\n\t\t...updateBody,\n\t\tlocale,\n\t\t_rev: body._rev,\n\t});\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled) await cache.invalidate({ tags: [collection, resolvedId] });\n\n\treturn unwrapResult(result);\n};\n\nexport const DELETE: APIRoute = async ({ params, locals, url, cache }) => {\n\tconst { emdash, user } = locals;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\n\tif (!emdash?.handleContentDelete || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\tconst locale = url.searchParams.get(\"locale\") || undefined;\n\n\t// Fetch item to check ownership\n\tconst existing = await emdash.handleContentGet(collection, id, locale);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"UNKNOWN_ERROR\",\n\t\t\texisting.error?.message ?? \"Unknown error\",\n\t\t\tmapErrorStatus(existing.error?.code),\n\t\t);\n\t}\n\n\tconst deleteData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership and ID resolution\n\tconst deleteItem =\n\t\tdeleteData?.item && typeof deleteData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(deleteData.item as Record<string, unknown>)\n\t\t\t: deleteData;\n\tconst authorId = typeof deleteItem?.authorId === \"string\" ? deleteItem.authorId : \"\";\n\tconst deleteDenied = requireOwnerPerm(user, authorId, \"content:delete_own\", \"content:delete_any\");\n\tif (deleteDenied) return deleteDenied;\n\n\t// Use the resolved ID (handles slug → ID resolution)\n\tconst resolvedId = typeof deleteItem?.id === \"string\" ? deleteItem.id : id;\n\n\tconst result = await emdash.handleContentDelete(collection, resolvedId);\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled) await cache.invalidate({ tags: [collection, resolvedId] });\n\n\treturn unwrapResult(result);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,QAAQ,KAAK,aAAa;CAC/D,MAAM,EAAE,QAAQ,SAAS;AACzB,KAAI,CAAC,QAAQ,iBACZ,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAEpE,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,QAAO;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,KAAK,OAAO;CAClB,MAAM,SAAS,IAAI,aAAa,IAAI,SAAS,IAAI;CAEjD,MAAM,SAAS,MAAM,OAAO,iBAAiB,YAAY,IAAI,OAAO;AAIpE,KAAI,OAAO,WAAW,CAAC,cAAc,MAAM,sBAAsB,EAAE;EAClE,MAAM,OACL,OAAO,QAAQ,OAAO,OAAO,SAAS,WAEnC,OAAO,OACP;EACJ,MAAM,OACL,MAAM,QAAQ,OAAO,KAAK,SAAS,WAEhC,KAAK,OACL;AAEJ,OADe,OAAO,MAAM,WAAW,WAAW,KAAK,SAAS,UACjD,YACd,QAAO,SAAS,aAAa,2BAA2B,MAAM,IAAI;AAOnE,MAAI,MAAM;AACT,OAAI,KAAK,YAAY,OAAO,KAAK,aAAa,SAC7C,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ourcesContent":["/**\n * Single content item endpoints - injected by EmDash integration\n *\n * GET /_emdash/api/content/{collection}/{id} - Get content\n * PUT /_emdash/api/content/{collection}/{id} - Update content\n * DELETE /_emdash/api/content/{collection}/{id} - Delete content\n */\n\nimport { hasPermission } from \"@emdash-cms/auth\";\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm, requireOwnerPerm } from \"#api/authorize.js\";\nimport { apiError, mapErrorStatus, unwrapResult } from \"#api/error.js\";\nimport { parseBody, isParseError } from \"#api/parse.js\";\nimport { contentUpdateBody } from \"#api/schemas.js\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ params, url, locals }) => {\n\tconst { emdash, user } = locals;\n\tif (!emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\tconst denied = requirePerm(user, \"content:read\");\n\tif (denied) return denied;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\tconst locale = url.searchParams.get(\"locale\") || undefined;\n\n\tconst result = await emdash.handleContentGet(collection, id, locale);\n\n\t// Hide non-published items from users without content:read_drafts. Return\n\t// 404 (not 403) so subscribers can't enumerate draft IDs by status code.\n\tif (result.success && !hasPermission(user, \"content:read_drafts\")) {\n\t\tconst data =\n\t\t\tresult.data && typeof result.data === \"object\"\n\t\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check\n\t\t\t\t\t(result.data as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tconst item =\n\t\t\tdata?.item && typeof data.item === \"object\"\n\t\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check\n\t\t\t\t\t(data.item as Record<string, unknown>)\n\t\t\t\t: undefined;\n\t\tconst status = typeof item?.status === \"string\" ? item.status : null;\n\t\tif (status !== \"published\") {\n\t\t\treturn apiError(\"NOT_FOUND\", `Content item not found: ${id}`, 404);\n\t\t}\n\n\t\t// Strip draft hydration data from response for users without read_drafts.\n\t\t// handleContentGet overlays draft revision data onto item.data and exposes\n\t\t// the published values in item.liveData. Without this, subscribers see\n\t\t// unpublished edits in the data field.\n\t\tif (item) {\n\t\t\tif (item.liveData && typeof item.liveData === \"object\") {\n\t\t\t\titem.data = item.liveData;\n\t\t\t}\n\t\t\tdelete item.liveData;\n\t\t\tdelete item.draftRevisionId;\n\t\t}\n\t}\n\n\treturn unwrapResult(result);\n};\n\nexport const PUT: APIRoute = async ({ params, request, locals, cache }) => {\n\tconst { emdash, user } = locals;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\tconst locale = new URL(request.url).searchParams.get(\"locale\") || undefined;\n\tconst body = await parseBody(request, contentUpdateBody);\n\tif (isParseError(body)) return body;\n\n\tif (!emdash?.handleContentUpdate || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\t// Fetch item to check ownership\n\tconst existing = await emdash.handleContentGet(collection, id, locale);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"UNKNOWN_ERROR\",\n\t\t\texisting.error?.message ?? \"Unknown error\",\n\t\t\tmapErrorStatus(existing.error?.code),\n\t\t);\n\t}\n\n\tconst existingData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership and ID resolution\n\tconst existingItem =\n\t\texistingData?.item && typeof existingData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(existingData.item as Record<string, unknown>)\n\t\t\t: existingData;\n\tconst authorId = typeof existingItem?.authorId === \"string\" ? existingItem.authorId : \"\";\n\tconst editDenied = requireOwnerPerm(user, authorId, \"content:edit_own\", \"content:edit_any\");\n\tif (editDenied) return editDenied;\n\n\t// Only EDITOR+ can write publishedAt directly — incl. clearing to null.\n\tif (body.publishedAt !== undefined && !hasPermission(user, \"content:publish_any\")) {\n\t\treturn apiError(\n\t\t\t\"FORBIDDEN\",\n\t\t\t\"Writing publishedAt requires content:publish_any permission\",\n\t\t\t403,\n\t\t);\n\t}\n\n\t// Use the resolved ID (handles slug → ID resolution)\n\tconst resolvedId = typeof existingItem?.id === \"string\" ? existingItem.id : id;\n\n\t// Only allow authorId changes if user has content:edit_any permission (editor+)\n\tconst canChangeAuthor =\n\t\tbody.authorId !== undefined && user && hasPermission(user, \"content:edit_any\");\n\tconst updateBody = canChangeAuthor ? body : { ...body, authorId: undefined };\n\n\t// Pass _rev through for optimistic concurrency validation\n\tconst result = await emdash.handleContentUpdate(collection, resolvedId, {\n\t\t...updateBody,\n\t\tlocale,\n\t\t_rev: body._rev,\n\t});\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled && result.liveContentChanged !== false) {\n\t\tawait cache.invalidate({ tags: [collection, resolvedId] });\n\t}\n\n\treturn unwrapResult(result);\n};\n\nexport const DELETE: APIRoute = async ({ params, locals, url, cache }) => {\n\tconst { emdash, user } = locals;\n\tconst collection = params.collection!;\n\tconst id = params.id!;\n\n\tif (!emdash?.handleContentDelete || !emdash?.handleContentGet) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\tconst locale = url.searchParams.get(\"locale\") || undefined;\n\n\t// Fetch item to check ownership\n\tconst existing = await emdash.handleContentGet(collection, id, locale);\n\tif (!existing.success) {\n\t\treturn apiError(\n\t\t\texisting.error?.code ?? \"UNKNOWN_ERROR\",\n\t\t\texisting.error?.message ?? \"Unknown error\",\n\t\t\tmapErrorStatus(existing.error?.code),\n\t\t);\n\t}\n\n\tconst deleteData =\n\t\texisting.data && typeof existing.data === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler returns unknown data; narrowed by typeof check above\n\t\t\t\t(existing.data as Record<string, unknown>)\n\t\t\t: undefined;\n\t// Handler returns { item, _rev } — extract the item for ownership and ID resolution\n\tconst deleteItem =\n\t\tdeleteData?.item && typeof deleteData.item === \"object\"\n\t\t\t? // eslint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed by typeof check above\n\t\t\t\t(deleteData.item as Record<string, unknown>)\n\t\t\t: deleteData;\n\tconst authorId = typeof deleteItem?.authorId === \"string\" ? deleteItem.authorId : \"\";\n\tconst deleteDenied = requireOwnerPerm(user, authorId, \"content:delete_own\", \"content:delete_any\");\n\tif (deleteDenied) return deleteDenied;\n\n\t// Use the resolved ID (handles slug → ID resolution)\n\tconst resolvedId = typeof deleteItem?.id === \"string\" ? deleteItem.id : id;\n\n\tconst result = await emdash.handleContentDelete(collection, resolvedId);\n\n\tif (!result.success) return unwrapResult(result);\n\n\tif (cache?.enabled) await cache.invalidate({ tags: [collection, resolvedId] });\n\n\treturn unwrapResult(result);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,QAAQ,KAAK,aAAa;CAC/D,MAAM,EAAE,QAAQ,SAAS;AACzB,KAAI,CAAC,QAAQ,iBACZ,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAEpE,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,QAAO;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,KAAK,OAAO;CAClB,MAAM,SAAS,IAAI,aAAa,IAAI,SAAS,IAAI;CAEjD,MAAM,SAAS,MAAM,OAAO,iBAAiB,YAAY,IAAI,OAAO;AAIpE,KAAI,OAAO,WAAW,CAAC,cAAc,MAAM,sBAAsB,EAAE;EAClE,MAAM,OACL,OAAO,QAAQ,OAAO,OAAO,SAAS,WAEnC,OAAO,OACP;EACJ,MAAM,OACL,MAAM,QAAQ,OAAO,KAAK,SAAS,WAEhC,KAAK,OACL;AAEJ,OADe,OAAO,MAAM,WAAW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AAM,WAAW,EAAE,MAAM,CAAC,YAAY,WAAW,EAAE,CAAC;AAE9E,QAAO,aAAa,OAAO"}
@@ -1,7 +1,7 @@
1
1
  import "../../../../../base64-B-PsqheR.mjs";
2
- import "../../../../../types-CrRUFdej.mjs";
3
- import { a as unwrapResult, t as apiError } from "../../../../../error-DJ98TRbQ.mjs";
4
- import { r as requirePerm } from "../../../../../authorize-6WPZa1xZ.mjs";
2
+ import "../../../../../types-Cd8iuS1J.mjs";
3
+ import { a as unwrapResult, t as apiError } from "../../../../../error-oh_9i6bR.mjs";
4
+ import { r as requirePerm } from "../../../../../authorize-qRhWQnel.mjs";
5
5
 
6
6
  //#region src/astro/routes/api/content/[collection]/authors.ts
7
7
  const prerender = false;
@@ -1,14 +1,14 @@
1
1
  import "../../../../../base64-B-PsqheR.mjs";
2
- import "../../../../../types-CrRUFdej.mjs";
3
- import { n as mapErrorStatus } from "../../../../../errors-DtEXIQQV.mjs";
4
- import { a as unwrapResult, t as apiError } from "../../../../../error-DJ98TRbQ.mjs";
5
- import { i as parseQuery, n as parseBody, t as isParseError } from "../../../../../parse-53zyxlpv.mjs";
6
- import "../../../../../media-BJ6SRY3g.mjs";
7
- import { Gt as contentListQuery, Ut as contentCreateBody } from "../../../../../redirects-D457qwt0.mjs";
8
- import "../../../../../relations-CZMpBqEd.mjs";
9
- import "../../../../../status-COfycGIU.mjs";
2
+ import "../../../../../types-Cd8iuS1J.mjs";
3
+ import { n as mapErrorStatus } from "../../../../../errors-BucQ8VYz.mjs";
4
+ import { a as unwrapResult, t as apiError } from "../../../../../error-oh_9i6bR.mjs";
5
+ import { i as parseQuery, n as parseBody, t as isParseError } from "../../../../../parse-CJKNuewM.mjs";
6
+ import "../../../../../media-OhYL-7Io.mjs";
7
+ import { Yt as contentListQuery, qt as contentCreateBody } from "../../../../../redirects-G8wAhWAf.mjs";
8
+ import "../../../../../relations-Bw_E1TXo.mjs";
9
+ import "../../../../../status-CIsmlC1E.mjs";
10
10
  import "../../../../../api/schemas/index.mjs";
11
- import { n as requireOwnerPerm, r as requirePerm } from "../../../../../authorize-6WPZa1xZ.mjs";
11
+ import { n as requireOwnerPerm, r as requirePerm } from "../../../../../authorize-qRhWQnel.mjs";
12
12
  import { hasPermission } from "@emdash-cms/auth";
13
13
 
14
14
  //#region src/astro/routes/api/content/[collection]/index.ts
@@ -1,13 +1,13 @@
1
1
  import "../../../../../base64-B-PsqheR.mjs";
2
- import "../../../../../types-CrRUFdej.mjs";
3
- import { a as unwrapResult, t as apiError } from "../../../../../error-DJ98TRbQ.mjs";
4
- import { i as parseQuery, t as isParseError } from "../../../../../parse-53zyxlpv.mjs";
5
- import "../../../../../media-BJ6SRY3g.mjs";
6
- import { nn as contentTrashQuery } from "../../../../../redirects-D457qwt0.mjs";
7
- import "../../../../../relations-CZMpBqEd.mjs";
8
- import "../../../../../status-COfycGIU.mjs";
2
+ import "../../../../../types-Cd8iuS1J.mjs";
3
+ import { a as unwrapResult, t as apiError } from "../../../../../error-oh_9i6bR.mjs";
4
+ import { i as parseQuery, t as isParseError } from "../../../../../parse-CJKNuewM.mjs";
5
+ import "../../../../../media-OhYL-7Io.mjs";
6
+ import { on as contentTrashQuery } from "../../../../../redirects-G8wAhWAf.mjs";
7
+ import "../../../../../relations-Bw_E1TXo.mjs";
8
+ import "../../../../../status-CIsmlC1E.mjs";
9
9
  import "../../../../../api/schemas/index.mjs";
10
- import { r as requirePerm } from "../../../../../authorize-6WPZa1xZ.mjs";
10
+ import { r as requirePerm } from "../../../../../authorize-qRhWQnel.mjs";
11
11
 
12
12
  //#region src/astro/routes/api/content/[collection]/trash.ts
13
13
  const prerender = false;
@@ -1,13 +1,13 @@
1
- import "../../../after-B1IIdH3Y.mjs";
2
- import "../../../object-cache-Bok5j2ae.mjs";
3
- import "../../../content-BC43pICM.mjs";
1
+ import "../../../after-CBU2vkoO.mjs";
2
+ import "../../../object-cache-71tPfV4A.mjs";
3
+ import "../../../content-CJ94NEx5.mjs";
4
4
  import "../../../base64-B-PsqheR.mjs";
5
- import "../../../types-CrRUFdej.mjs";
6
- import "../../../media-its1WLYv.mjs";
7
- import "../../../user-aTXqmXBz.mjs";
8
- import { t as handleDashboardStats } from "../../../dashboard-CBm4zhc3.mjs";
9
- import { a as unwrapResult, r as handleError, t as apiError } from "../../../error-DJ98TRbQ.mjs";
10
- import { r as requirePerm } from "../../../authorize-6WPZa1xZ.mjs";
5
+ import "../../../types-Cd8iuS1J.mjs";
6
+ import "../../../media-BP7S-nHT.mjs";
7
+ import "../../../user-DBrq4UVq.mjs";
8
+ import { t as handleDashboardStats } from "../../../dashboard-DINnNVVU.mjs";
9
+ import { a as unwrapResult, r as handleError, t as apiError } from "../../../error-oh_9i6bR.mjs";
10
+ import { r as requirePerm } from "../../../authorize-qRhWQnel.mjs";
11
11
 
12
12
  //#region src/astro/routes/api/dashboard.ts
13
13
  const prerender = false;
@@ -1,7 +1,7 @@
1
1
  import "../../../../base64-B-PsqheR.mjs";
2
- import "../../../../types-CrRUFdej.mjs";
3
- import { n as apiSuccess, t as apiError } from "../../../../error-DJ98TRbQ.mjs";
4
- import { i as getDevEmails, n as clearDevEmails } from "../../../../email-console-C-9Ng8DM.mjs";
2
+ import "../../../../types-Cd8iuS1J.mjs";
3
+ import { n as apiSuccess, t as apiError } from "../../../../error-oh_9i6bR.mjs";
4
+ import { i as getDevEmails, n as clearDevEmails } from "../../../../email-console-C6WdcWbL.mjs";
5
5
 
6
6
  //#region src/astro/routes/api/dev/emails.ts
7
7
  const prerender = false;
@@ -1,6 +1,6 @@
1
- import "../../../../types-DPKhI5ib.mjs";
2
- import "../../../../index-BEui-cRd.mjs";
3
- import { g as ProbeResult } from "../../../../types-C7U0HlEr.mjs";
1
+ import "../../../../types-Dc4ntQjQ.mjs";
2
+ import "../../../../index-MGw47uWq.mjs";
3
+ import { g as ProbeResult } from "../../../../types-C8oz_ayJ.mjs";
4
4
  import { APIRoute } from "astro";
5
5
 
6
6
  //#region src/astro/routes/api/import/probe.d.ts
@@ -1,25 +1,25 @@
1
- import "../../../../dialect-helpers-BtOwo2us.mjs";
2
- import "../../../../after-B1IIdH3Y.mjs";
3
- import "../../../../object-cache-Bok5j2ae.mjs";
1
+ import "../../../../dialect-helpers-BSbfaO3F.mjs";
2
+ import "../../../../after-CBU2vkoO.mjs";
3
+ import "../../../../object-cache-71tPfV4A.mjs";
4
4
  import "../../../../base64-B-PsqheR.mjs";
5
- import "../../../../types-CrRUFdej.mjs";
6
- import "../../../../media-its1WLYv.mjs";
7
- import "../../../../options-BlmBHTvX.mjs";
5
+ import "../../../../types-Cd8iuS1J.mjs";
6
+ import "../../../../media-BP7S-nHT.mjs";
7
+ import "../../../../options-CBXIHUoT.mjs";
8
8
  import "../../../../request-cache-BSUptuJR.mjs";
9
- import "../../../../loader-D4rigvjR.mjs";
10
- import "../../../../settings-C2PaBS49.mjs";
11
- import { t as SsrfError } from "../../../../ssrf-CviKqWmq.mjs";
12
- import { n as apiSuccess, r as handleError, t as apiError } from "../../../../error-DJ98TRbQ.mjs";
13
- import { n as parseBody, t as isParseError } from "../../../../parse-53zyxlpv.mjs";
14
- import "../../../../media-BJ6SRY3g.mjs";
15
- import "../../../../redirects-D457qwt0.mjs";
16
- import { S as importProbeBody } from "../../../../relations-CZMpBqEd.mjs";
17
- import "../../../../status-COfycGIU.mjs";
9
+ import "../../../../loader-CGugY7Zl.mjs";
10
+ import "../../../../settings-kJhGiQ4z.mjs";
11
+ import { t as SsrfError } from "../../../../ssrf-CTa6v21i.mjs";
12
+ import { n as apiSuccess, r as handleError, t as apiError } from "../../../../error-oh_9i6bR.mjs";
13
+ import { n as parseBody, t as isParseError } from "../../../../parse-CJKNuewM.mjs";
14
+ import "../../../../media-OhYL-7Io.mjs";
15
+ import "../../../../redirects-G8wAhWAf.mjs";
16
+ import { S as importProbeBody } from "../../../../relations-Bw_E1TXo.mjs";
17
+ import "../../../../status-CIsmlC1E.mjs";
18
18
  import "../../../../api/schemas/index.mjs";
19
- import { h as probeUrl } from "../../../../import-oDYCgNYQ.mjs";
20
- import "../../../../ssrf-BB__xfNM.mjs";
21
- import "../../../../utils-BbUgmeZG.mjs";
22
- import { r as requirePerm } from "../../../../authorize-6WPZa1xZ.mjs";
19
+ import { h as probeUrl } from "../../../../import-C-9uqyT3.mjs";
20
+ import "../../../../ssrf-Cj568Dgs.mjs";
21
+ import "../../../../utils-hLzi_2Fn.mjs";
22
+ import { r as requirePerm } from "../../../../authorize-qRhWQnel.mjs";
23
23
 
24
24
  //#region src/astro/routes/api/import/probe.ts
25
25
  const prerender = false;
@@ -1,8 +1,8 @@
1
1
  import "../../../../../base64-B-PsqheR.mjs";
2
- import "../../../../../types-CrRUFdej.mjs";
3
- import { a as RESERVED_COLLECTION_SLUGS } from "../../../../../types-o7xo7VgH.mjs";
4
- import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-DJ98TRbQ.mjs";
5
- import { r as requirePerm } from "../../../../../authorize-6WPZa1xZ.mjs";
2
+ import "../../../../../types-Cd8iuS1J.mjs";
3
+ import { a as RESERVED_COLLECTION_SLUGS } from "../../../../../types-NBI3rF-_.mjs";
4
+ import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-oh_9i6bR.mjs";
5
+ import { r as requirePerm } from "../../../../../authorize-qRhWQnel.mjs";
6
6
  import mime from "mime/lite";
7
7
  import { SchemaRegistry, parseWxrString } from "emdash";
8
8
 
@@ -1,15 +1,15 @@
1
- import "../../../../../options-BqMkWfYa.mjs";
2
- import "../../../../../types-DPKhI5ib.mjs";
3
- import "../../../../../types-BvB7gDOD.mjs";
4
- import "../../../../../relations-qKmSj9KM.mjs";
5
- import "../../../../../index-BZJ_5FOX.mjs";
6
- import "../../../../../runner-Dd8m8k9F.mjs";
7
- import "../../../../../index-BEui-cRd.mjs";
8
- import "../../../../../types-C7U0HlEr.mjs";
9
- import "../../../../../hreflang-CIxH_LKz.mjs";
10
- import "../../../../../validate-DULfgpJP.mjs";
1
+ import "../../../../../options-CA4eVX6P.mjs";
2
+ import "../../../../../types-Dc4ntQjQ.mjs";
3
+ import "../../../../../types-Cz8hNch2.mjs";
4
+ import "../../../../../relations-G2ta7GIl.mjs";
5
+ import "../../../../../index-M37iz29I.mjs";
6
+ import "../../../../../runner-BaADli8l.mjs";
7
+ import "../../../../../index-MGw47uWq.mjs";
8
+ import "../../../../../types-C8oz_ayJ.mjs";
9
+ import "../../../../../hreflang-BaLCNcDx.mjs";
10
+ import "../../../../../validate-C3oSmA7F.mjs";
11
11
  import { EmDashHandlers, EmDashManifest } from "../../../../types.mjs";
12
- import { t as TaxonomyImportPlan } from "../../../../../wxr-taxonomies-B4tMuN5T.mjs";
12
+ import { t as TaxonomyImportPlan } from "../../../../../wxr-taxonomies-Bkpp_2tK.mjs";
13
13
  import { WxrPost } from "emdash";
14
14
  import { APIRoute } from "astro";
15
15
 
@@ -1,22 +1,23 @@
1
- import "../../../../../dialect-helpers-BtOwo2us.mjs";
2
- import "../../../../../after-B1IIdH3Y.mjs";
3
- import "../../../../../object-cache-Bok5j2ae.mjs";
1
+ import "../../../../../dialect-helpers-BSbfaO3F.mjs";
2
+ import "../../../../../config-DyF3OKg_.mjs";
3
+ import "../../../../../after-CBU2vkoO.mjs";
4
+ import "../../../../../object-cache-71tPfV4A.mjs";
4
5
  import { n as slugify } from "../../../../../slugify-C_tqlU4G.mjs";
5
6
  import "../../../../../base64-B-PsqheR.mjs";
6
- import "../../../../../types-CrRUFdej.mjs";
7
- import "../../../../../taxonomy-0mCI25HN.mjs";
7
+ import "../../../../../types-Cd8iuS1J.mjs";
8
+ import "../../../../../taxonomy-pOrB2kZe.mjs";
8
9
  import "../../../../../request-cache-BSUptuJR.mjs";
9
- import "../../../../../byline-registry-BCuOp4UF.mjs";
10
- import "../../../../../field-defs-cache-KfNJ_qLQ.mjs";
11
- import { t as BylineRepository } from "../../../../../byline-BTOxUlFF.mjs";
12
- import "../../../../../resolve-DFr4kq72.mjs";
13
- import "../../../../../loader-D4rigvjR.mjs";
14
- import "../../../../../taxonomies-r7pqLBCn.mjs";
15
- import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-DJ98TRbQ.mjs";
16
- import { g as resolveImportByline } from "../../../../../utils-BbUgmeZG.mjs";
17
- import { r as requirePerm } from "../../../../../authorize-6WPZa1xZ.mjs";
10
+ import "../../../../../byline-registry-ZkPKqEwC.mjs";
11
+ import "../../../../../field-defs-cache-WD82dMQq.mjs";
12
+ import { t as BylineRepository } from "../../../../../byline-Cp6csL84.mjs";
13
+ import "../../../../../resolve-DZzG4HqM.mjs";
14
+ import "../../../../../loader-CGugY7Zl.mjs";
15
+ import "../../../../../taxonomies-CLN1N92E.mjs";
16
+ import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-oh_9i6bR.mjs";
17
+ import { g as resolveImportByline } from "../../../../../utils-hLzi_2Fn.mjs";
18
+ import { r as requirePerm } from "../../../../../authorize-qRhWQnel.mjs";
18
19
  import { sanitizeSlug } from "./analyze.mjs";
19
- import { a as preImportWxrTaxonomies, i as mirrorTermsToLocales, n as isWxrTaxonomyConflictError, o as setPostTermAssignmentsReplacing, t as attachPostTaxonomies } from "../../../../../wxr-taxonomies-DrihupaC.mjs";
20
+ import { a as preImportWxrTaxonomies, i as mirrorTermsToLocales, n as isWxrTaxonomyConflictError, o as setPostTermAssignmentsReplacing, t as attachPostTaxonomies } from "../../../../../wxr-taxonomies-9PPSy8X6.mjs";
20
21
  import { gutenbergToPortableText } from "@emdash-cms/gutenberg-to-portable-text";
21
22
  import { ContentRepository, importReusableBlocksAsSections, parseWxrDate, parseWxrString } from "emdash";
22
23
 
@@ -1 +1 @@
1
- {"version":3,"file":"execute.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/import/wordpress/execute.ts"],"sourcesContent":["/**\n * WordPress WXR execute import endpoint\n *\n * POST /_emdash/api/import/wordpress/execute\n *\n * Accepts WXR file and import configuration, imports content into the database.\n */\n\nimport { gutenbergToPortableText } from \"@emdash-cms/gutenberg-to-portable-text\";\nimport type { APIRoute } from \"astro\";\nimport {\n\tparseWxrString,\n\tContentRepository,\n\timportReusableBlocksAsSections,\n\ttype WxrPost,\n\tparseWxrDate,\n} from \"emdash\";\n\nimport { requirePerm } from \"#api/authorize.js\";\nimport { apiError, apiSuccess, handleError } from \"#api/error.js\";\nimport { BylineRepository } from \"#db/repositories/byline.js\";\nimport { resolveImportByline } from \"#import/utils.js\";\nimport {\n\tattachPostTaxonomies,\n\tisWxrTaxonomyConflictError,\n\tmirrorTermsToLocales,\n\tpreImportWxrTaxonomies,\n\tsetPostTermAssignmentsReplacing,\n\ttype TaxonomyImportPlan,\n} from \"#import/wxr-taxonomies.js\";\nimport type { EmDashHandlers, EmDashManifest } from \"#types\";\nimport { slugify } from \"#utils/slugify.js\";\n\nimport { sanitizeSlug } from \"./analyze.js\";\n\nexport const prerender = false;\n\nexport interface ImportConfig {\n\t/** Map WordPress post types to EmDash collections */\n\tpostTypeMappings: Record<\n\t\tstring,\n\t\t{\n\t\t\tcollection: string;\n\t\t\tenabled: boolean;\n\t\t}\n\t>;\n\t/** Whether to skip items that already exist (by slug) */\n\tskipExisting: boolean;\n\t/** Whether to import reusable blocks (wp_block) as sections */\n\timportSections?: boolean;\n\t/** Author mappings (WP author login -> EmDash user ID) */\n\tauthorMappings?: Record<string, string | null>;\n\t/** BCP 47 locale for all imported items. When omitted, defaults to defaultLocale. */\n\tlocale?: string;\n}\n\nexport interface ImportResult {\n\tsuccess: boolean;\n\timported: number;\n\tskipped: number;\n\terrors: Array<{ title: string; error: string }>;\n\tbyCollection: Record<string, number>;\n\t/** Sections import results (if enabled) */\n\tsections?: {\n\t\tcreated: number;\n\t\tskipped: number;\n\t};\n\t/** Taxonomy import results (categories, tags, custom taxonomies). */\n\ttaxonomies?: {\n\t\t/** Terms newly created during this import, keyed by taxonomy name. */\n\t\ttermsCreated: Record<string, number>;\n\t\t/** Existing terms that were re-used, keyed by taxonomy name. */\n\t\ttermsReused: Record<string, number>;\n\t\t/** Total pivot rows (post <-> term) written to `content_taxonomies`. */\n\t\tassignments: number;\n\t\t/**\n\t\t * Custom taxonomy names from the WXR file that had no matching EmDash\n\t\t * definition and were therefore skipped. Lets the admin UI surface a\n\t\t * \"create taxonomy X first\" hint without re-running the import.\n\t\t */\n\t\tmissingTaxonomies: string[];\n\t};\n}\n\nexport const POST: APIRoute = async ({ request, locals }) => {\n\tconst { emdash, user } = locals;\n\n\tconst denied = requirePerm(user, \"import:execute\");\n\tif (denied) return denied;\n\n\tif (!emdash?.handleContentCreate) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash not configured\", 500);\n\t}\n\n\ttry {\n\t\tconst emdashManifest = await emdash.getManifest();\n\n\t\tconst formData = await request.formData();\n\t\tconst fileEntry = formData.get(\"file\");\n\t\tconst file = fileEntry instanceof File ? fileEntry : null;\n\t\tconst configEntry = formData.get(\"config\");\n\t\tconst configJson = typeof configEntry === \"string\" ? configEntry : null;\n\n\t\tif (!file) {\n\t\t\treturn apiError(\"VALIDATION_ERROR\", \"No file provided\", 400);\n\t\t}\n\n\t\tif (!configJson) {\n\t\t\treturn apiError(\"VALIDATION_ERROR\", \"No config provided\", 400);\n\t\t}\n\n\t\tconst config: ImportConfig = JSON.parse(configJson);\n\n\t\t// Parse WXR\n\t\tconst text = await file.text();\n\t\tconst wxr = await parseWxrString(text);\n\n\t\t// Build attachment ID -> URL map for featured images\n\t\tconst attachmentMap = new Map<string, string>();\n\t\tfor (const att of wxr.attachments) {\n\t\t\tif (att.id && att.url) {\n\t\t\t\tattachmentMap.set(String(att.id), att.url);\n\t\t\t}\n\t\t}\n\n\t\t// Build author login -> display name map\n\t\tconst authorDisplayNames = new Map<string, string>();\n\t\tfor (const author of wxr.authors) {\n\t\t\tif (!author.login) continue;\n\t\t\tauthorDisplayNames.set(author.login, author.displayName || author.login);\n\t\t}\n\n\t\t// Pre-create taxonomy terms (categories, tags, custom taxonomies) so\n\t\t// per-post assignments can resolve to existing rows. Done before any\n\t\t// content insert because WXR exports list terms at the top of the\n\t\t// file but per-item assignments only reference them by slug.\n\t\tconst taxonomyPlan = await preImportWxrTaxonomies(\n\t\t\temdash.db,\n\t\t\twxr.posts,\n\t\t\twxr.categories,\n\t\t\twxr.tags,\n\t\t\twxr.terms,\n\t\t\tconfig.locale,\n\t\t);\n\n\t\t// Multilingual imports (WPML / Polylang -- see #1080) need a term\n\t\t// row at each per-post locale, all sharing the canonical term's\n\t\t// `translation_group`. Without this, `getTermsForEntry(..., locale)`\n\t\t// on non-canonical translations comes back empty.\n\t\t//\n\t\t// The mirror raises `WxrTaxonomyConflictError` with an operator-\n\t\t// actionable message when an existing locale row has an\n\t\t// incompatible group. Surface its `publicMessage` directly so the\n\t\t// admin UI can tell the user which (taxonomy, slug, locale) needs\n\t\t// reconciliation. Other errors (DB connectivity, unexpected\n\t\t// repository failures) re-throw to the outer catch where\n\t\t// `handleError` masks them with the generic \"Failed to import\n\t\t// content\" -- exposing raw DB errors to clients would leak schema\n\t\t// names and bypass the AGENTS.md \"never expose error.message\" rule.\n\t\tconst postLocales = new Set<string>();\n\t\tfor (const post of wxr.posts) {\n\t\t\tif (post.locale) postLocales.add(post.locale);\n\t\t}\n\t\tif (postLocales.size > 0) {\n\t\t\ttry {\n\t\t\t\tawait mirrorTermsToLocales(emdash.db, taxonomyPlan, postLocales, config.locale);\n\t\t\t} catch (mirrorError) {\n\t\t\t\tif (isWxrTaxonomyConflictError(mirrorError)) {\n\t\t\t\t\tconsole.error(\"[WXR_IMPORT_TAXONOMY_CONFLICT]\", mirrorError);\n\t\t\t\t\treturn apiError(\"WXR_IMPORT_TAXONOMY_CONFLICT\", mirrorError.publicMessage, 409);\n\t\t\t\t}\n\t\t\t\tthrow mirrorError;\n\t\t\t}\n\t\t}\n\n\t\t// Import content (locale from config scopes all items)\n\t\tconst result = await importContent(\n\t\t\twxr.posts,\n\t\t\tconfig,\n\t\t\temdash,\n\t\t\temdashManifest,\n\t\t\tattachmentMap,\n\t\t\tconfig.locale,\n\t\t\tauthorDisplayNames,\n\t\t\ttaxonomyPlan,\n\t\t);\n\n\t\t// Import reusable blocks as sections (if enabled)\n\t\tif (config.importSections !== false) {\n\t\t\tconst sectionsResult = await importReusableBlocksAsSections(wxr.posts, emdash.db);\n\t\t\tresult.sections = {\n\t\t\t\tcreated: sectionsResult.sectionsCreated,\n\t\t\t\tskipped: sectionsResult.sectionsSkipped,\n\t\t\t};\n\t\t\t// Add section errors to main errors array\n\t\t\tresult.errors.push(...sectionsResult.errors);\n\t\t\tif (sectionsResult.errors.length > 0) {\n\t\t\t\tresult.success = false;\n\t\t\t}\n\t\t}\n\n\t\treturn apiSuccess(result);\n\t} catch (error) {\n\t\treturn handleError(error, \"Failed to import content\", \"WXR_IMPORT_ERROR\");\n\t}\n};\n\nexport async function importContent(\n\tposts: WxrPost[],\n\tconfig: ImportConfig,\n\temdash: EmDashHandlers,\n\tmanifest: EmDashManifest,\n\tattachmentMap: Map<string, string>,\n\tlocale: string | undefined,\n\tauthorDisplayNames: Map<string, string> | undefined,\n\ttaxonomyPlan: TaxonomyImportPlan,\n): Promise<ImportResult> {\n\tconst result: ImportResult = {\n\t\tsuccess: true,\n\t\timported: 0,\n\t\tskipped: 0,\n\t\terrors: [],\n\t\tbyCollection: {},\n\t\ttaxonomies: {\n\t\t\ttermsCreated: taxonomyPlan.termsCreated,\n\t\t\ttermsReused: taxonomyPlan.termsReused,\n\t\t\tassignments: 0,\n\t\t\tmissingTaxonomies: taxonomyPlan.missingTaxonomies,\n\t\t},\n\t};\n\n\t// Create content repository for checking existing items\n\tconst contentRepo = new ContentRepository(emdash.db);\n\tconst bylineRepo = new BylineRepository(emdash.db);\n\tconst bylineCache = new Map<string, string>();\n\n\t// Source-side translation group ID -> the EmDash ID of the first post we\n\t// imported for that group. Subsequent translations are linked via\n\t// `translationOf` so they share a `translation_group` on the EmDash side.\n\tconst translationGroupMap = new Map<string, string>();\n\n\tfor (const post of posts) {\n\t\tconst postType = post.postType || \"post\";\n\t\tconst mapping = config.postTypeMappings[postType];\n\n\t\t// Skip if not mapped or disabled\n\t\tif (!mapping || !mapping.enabled) {\n\t\t\tresult.skipped++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Defensive: mapping.collection is already sanitized by prepare, but the user\n\t\t// could manually edit the import config between prepare and execute.\n\t\tconst collection = sanitizeSlug(mapping.collection);\n\n\t\t// Check if collection exists in manifest\n\t\tif (!manifest?.collections[collection]) {\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\terror: `Collection \"${collection}\" does not exist`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert content to Portable Text\n\t\t\tconst content = post.content ? gutenbergToPortableText(post.content) : [];\n\n\t\t\t// Generate slug from post name or title\n\t\t\tconst slug = post.postName || slugify(post.title || `post-${post.id || Date.now()}`);\n\n\t\t\t// Per-post locale: prefer the value extracted from WPML/Polylang\n\t\t\t// metadata; fall back to the upload-wide locale. Two translations\n\t\t\t// sharing `post_name` (e.g. /en/hello + /ar/hello) collide on the\n\t\t\t// `UNIQUE(slug, locale)` constraint when they share a locale, so\n\t\t\t// honouring the per-post value is what makes multilingual imports\n\t\t\t// land correctly. See issue #1080.\n\t\t\tconst postLocale = post.locale ?? locale;\n\n\t\t\t// Check if already exists (idempotency). Match against the\n\t\t\t// per-post locale so the same slug in different locales doesn't\n\t\t\t// false-positive as duplicate.\n\t\t\tif (config.skipExisting) {\n\t\t\t\tconst existing = await contentRepo.findBySlug(collection, slug, postLocale);\n\t\t\t\tif (existing) {\n\t\t\t\t\t// Record the translation group mapping so later\n\t\t\t\t\t// translations in this WXR can link to the existing\n\t\t\t\t\t// item. We deliberately trust the WXR's grouping over\n\t\t\t\t\t// the existing row's `translation_group`: a singleton\n\t\t\t\t\t// existing row gets folded into the WXR's group when\n\t\t\t\t\t// `handleContentCreate` resolves the new translation's\n\t\t\t\t\t// `translationOf`. Pre-existing translations that\n\t\t\t\t\t// already belong to a different group are left alone --\n\t\t\t\t\t// the user is responsible for reconciling those through\n\t\t\t\t\t// the admin if they don't match the WXR.\n\t\t\t\t\tif (post.translationGroup) {\n\t\t\t\t\t\ttranslationGroupMap.set(post.translationGroup, existing.id);\n\t\t\t\t\t}\n\t\t\t\t\tresult.skipped++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Resolve translation group: if this post belongs to a group and\n\t\t\t// we've already imported one of its translations, link to it.\n\t\t\tlet translationOf: string | undefined;\n\t\t\tif (post.translationGroup) {\n\t\t\t\ttranslationOf = translationGroupMap.get(post.translationGroup);\n\t\t\t}\n\n\t\t\t// Map WordPress status to EmDash status\n\t\t\tconst status = mapStatus(post.status);\n\n\t\t\t// Build data object with required fields\n\t\t\tconst data: Record<string, unknown> = {\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\tcontent,\n\t\t\t\texcerpt: post.excerpt || undefined,\n\t\t\t};\n\n\t\t\t// Only add featured_image if the collection has this field and we have a value\n\t\t\tconst collectionSchema = manifest.collections[collection];\n\t\t\tconst hasFeaturedImageField = collectionSchema?.fields\n\t\t\t\t? \"featured_image\" in collectionSchema.fields\n\t\t\t\t: false;\n\t\t\tif (hasFeaturedImageField) {\n\t\t\t\tconst thumbnailId = post.meta.get(\"_thumbnail_id\");\n\t\t\t\tconst featuredImage = thumbnailId ? attachmentMap.get(String(thumbnailId)) : undefined;\n\t\t\t\tif (featuredImage) {\n\t\t\t\t\tdata.featured_image = featuredImage;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Resolve author ID from mappings\n\t\t\tlet authorId: string | undefined;\n\t\t\tif (config.authorMappings && post.creator) {\n\t\t\t\tconst mappedUserId = config.authorMappings[post.creator];\n\t\t\t\tif (mappedUserId !== undefined && mappedUserId !== null) {\n\t\t\t\t\tauthorId = mappedUserId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst bylineId = await resolveImportByline(\n\t\t\t\tpost.creator,\n\t\t\t\tauthorDisplayNames?.get(post.creator ?? \"\") ?? post.creator,\n\t\t\t\tauthorId,\n\t\t\t\tbylineRepo,\n\t\t\t\tbylineCache,\n\t\t\t);\n\n\t\t\t// Preserve original WordPress dates using the shared WXR date parser.\n\t\t\t// Fallback chain: postDateGmt (UTC) → pubDate (RFC 2822) → postDate (site-local).\n\t\t\tconst parsedDate = parseWxrDate(post.postDateGmt, post.pubDate, post.postDate);\n\t\t\tconst createdAt = parsedDate ? parsedDate.toISOString() : undefined;\n\t\t\tconst publishedAt = status === \"published\" && createdAt ? createdAt : undefined;\n\n\t\t\t// Create the content item\n\t\t\tconst createResult = await emdash.handleContentCreate(collection, {\n\t\t\t\tdata,\n\t\t\t\tslug,\n\t\t\t\tstatus,\n\t\t\t\tauthorId,\n\t\t\t\tbylines: bylineId ? [{ bylineId }] : undefined,\n\t\t\t\tlocale: postLocale,\n\t\t\t\ttranslationOf,\n\t\t\t\tcreatedAt,\n\t\t\t\tpublishedAt,\n\t\t\t});\n\n\t\t\tif (createResult.success) {\n\t\t\t\tresult.imported++;\n\t\t\t\tresult.byCollection[collection] = (result.byCollection[collection] || 0) + 1;\n\n\t\t\t\t// `handleContentCreate` returns `data: { item, _rev? }` on\n\t\t\t\t// success (see `ApiResult<ContentResponse>` in\n\t\t\t\t// `api/handlers/content.ts`). `HandlerResponse.data` is\n\t\t\t\t// typed as `unknown` to avoid coupling the route surface to\n\t\t\t\t// internal handler types, so we narrow here.\n\t\t\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler contract documented at handleContentCreate\n\t\t\t\tconst createdItem = (createResult.data as { item: { id: string } } | undefined)?.item;\n\n\t\t\t\t// Track translation group: the first imported post in a group\n\t\t\t\t// becomes the anchor that later translations link to.\n\t\t\t\tif (\n\t\t\t\t\tcreatedItem &&\n\t\t\t\t\tpost.translationGroup &&\n\t\t\t\t\t!translationGroupMap.has(post.translationGroup)\n\t\t\t\t) {\n\t\t\t\t\ttranslationGroupMap.set(post.translationGroup, createdItem.id);\n\t\t\t\t}\n\n\t\t\t\t// Attach taxonomy assignments parsed from the WXR's per-item\n\t\t\t\t// <category> elements.\n\t\t\t\t//\n\t\t\t\t// Anchors (no `translationOf`) get an additive attach -- the\n\t\t\t\t// row is fresh, no inherited pivots to consider.\n\t\t\t\t//\n\t\t\t\t// Translations get per-taxonomy replace semantics. WPML's\n\t\t\t\t// \"Translate Independently\" mode is per-taxonomy, not per-\n\t\t\t\t// post: a translation that overrides `category` shouldn't\n\t\t\t\t// lose its inherited `tag` or `genre`. The replace path\n\t\t\t\t// only touches taxonomies the translation actually carries\n\t\t\t\t// AND that resolve to at least one term that survives the\n\t\t\t\t// def's `collections` filter; taxonomies with no resolved\n\t\t\t\t// terms (missing-def, dropped by filter, or just absent\n\t\t\t\t// from the WXR) fall through with the inherited set intact\n\t\t\t\t// from `copyEntryTerms`.\n\t\t\t\tif (createdItem) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst written = translationOf\n\t\t\t\t\t\t\t? await setPostTermAssignmentsReplacing(\n\t\t\t\t\t\t\t\t\temdash.db,\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tcreatedItem.id,\n\t\t\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t\t\ttaxonomyPlan,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: await attachPostTaxonomies(\n\t\t\t\t\t\t\t\t\temdash.db,\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tcreatedItem.id,\n\t\t\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t\t\ttaxonomyPlan,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\tif (result.taxonomies) {\n\t\t\t\t\t\t\tresult.taxonomies.assignments += written;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (taxError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`Failed to attach taxonomies for \"${post.title || \"Untitled\"}\":`,\n\t\t\t\t\t\t\ttaxError,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult.errors.push({\n\t\t\t\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\ttaxError instanceof Error && taxError.message\n\t\t\t\t\t\t\t\t\t? `Imported but failed to attach taxonomies: ${taxError.message}`\n\t\t\t\t\t\t\t\t\t: \"Imported but failed to attach taxonomies\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult.errors.push({\n\t\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\t\terror:\n\t\t\t\t\t\ttypeof createResult.error === \"object\" && createResult.error !== null\n\t\t\t\t\t\t\t? (createResult.error as { message?: string }).message || \"Unknown error\"\n\t\t\t\t\t\t\t: String(createResult.error),\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(`Import error for \"${post.title || \"Untitled\"}\":`, error);\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\terror: error instanceof Error && error.message ? error.message : \"Failed to import item\",\n\t\t\t});\n\t\t}\n\t}\n\n\tresult.success = result.errors.length === 0;\n\treturn result;\n}\n\nfunction mapStatus(wpStatus: string | undefined): string {\n\tswitch (wpStatus) {\n\t\tcase \"publish\":\n\t\t\treturn \"published\";\n\t\tcase \"draft\":\n\t\t\treturn \"draft\";\n\t\tcase \"pending\":\n\t\t\treturn \"draft\";\n\t\tcase \"private\":\n\t\t\treturn \"draft\";\n\t\tdefault:\n\t\t\treturn \"draft\";\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,YAAY;AAiDzB,MAAa,OAAiB,OAAO,EAAE,SAAS,aAAa;CAC5D,MAAM,EAAE,QAAQ,SAAS;CAEzB,MAAM,SAAS,YAAY,MAAM,iBAAiB;AAClD,KAAI,OAAQ,QAAO;AAEnB,KAAI,CAAC,QAAQ,oBACZ,QAAO,SA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IACA;IACA,CAAC;AAEF,OAAI,aAAa,SAAS;AACzB,WAAO;AACP,WAAO,aAAa,eAAe,OAAO,aAAa,eAAe,KAAK;IAQ3E,MAAM,cAAe,aAAa,MAA+C;AAIjF,QACC,eACA,KAAK,oBACL,CAAC,oBAAoB,IAAI,KAAK,iBAAiB,CAE/C,qBAAoB,IAAI,KAAK,kBAAkB,YAAY,GAAG;AAmB/D,QAAI,YACH,KAAI;KACH,MAAM,UAAU,gBACb,MAAM,gCACN,OAAO,IACP,YACA,YAAY,IACZ,MACA,aACA,GACA,MAAM,qBACN,OAAO,IACP,YACA,YAAY,IACZ,MACA,aACA;AACH,SAAI,OAAO,WACV,QAAO,WAAW,eAAe;aAE1B,UAAU;AAClB,aAAQ,MACP,oCAAoC,KAAK,SAAS,WAAW,KAC7D,SACA;AACD,YAAO,OAAO,KAAK;MAClB,OAAO,KAAK,SAAS;MACrB,OACC,oBAAoB,SAAS,SAAS,UACnC,6CAA6C,SAAS,YACtD;MACJ,CAAC;;SAIJ,QAAO,OAAO,KAAK;IAClB,OAAO,KAAK,SAAS;IACrB,OACC,OAAO,aAAa,UAAU,YAAY,aAAa,UAAU,OAC7D,aAAa,MAA+B,WAAW,kBACxD,OAAO,aAAa,MAAM;IAC9B,CAAC;WAEK,OAAO;AACf,WAAQ,MAAM,qBAAqB,KAAK,SAAS,WAAW,KAAK,MAAM;AACvE,UAAO,OAAO,KAAK;IAClB,OAAO,KAAK,SAAS;IACrB,OAAO,iBAAiB,SAAS,MAAM,UAAU,MAAM,UAAU;IACjE,CAAC;;;AAIJ,QAAO,UAAU,OAAO,OAAO,WAAW;AAC1C,QAAO;;AAGR,SAAS,UAAU,UAAsC;AACxD,SAAQ,UAAR;EACC,KAAK,UACJ,QAAO;EACR,KAAK,QACJ,QAAO;EACR,KAAK,UACJ,QAAO;EACR,KAAK,UACJ,QAAO;EACR,QACC,QAAO"}
1
+ {"version":3,"file":"execute.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/import/wordpress/execute.ts"],"sourcesContent":["/**\n * WordPress WXR execute import endpoint\n *\n * POST /_emdash/api/import/wordpress/execute\n *\n * Accepts WXR file and import configuration, imports content into the database.\n */\n\nimport { gutenbergToPortableText } from \"@emdash-cms/gutenberg-to-portable-text\";\nimport type { APIRoute } from \"astro\";\nimport {\n\tparseWxrString,\n\tContentRepository,\n\timportReusableBlocksAsSections,\n\ttype WxrPost,\n\tparseWxrDate,\n} from \"emdash\";\n\nimport { requirePerm } from \"#api/authorize.js\";\nimport { apiError, apiSuccess, handleError } from \"#api/error.js\";\nimport { BylineRepository } from \"#db/repositories/byline.js\";\nimport { resolveImportByline } from \"#import/utils.js\";\nimport {\n\tattachPostTaxonomies,\n\tisWxrTaxonomyConflictError,\n\tmirrorTermsToLocales,\n\tpreImportWxrTaxonomies,\n\tsetPostTermAssignmentsReplacing,\n\ttype TaxonomyImportPlan,\n} from \"#import/wxr-taxonomies.js\";\nimport type { EmDashHandlers, EmDashManifest } from \"#types\";\nimport { slugify } from \"#utils/slugify.js\";\n\nimport { sanitizeSlug } from \"./analyze.js\";\n\nexport const prerender = false;\n\nexport interface ImportConfig {\n\t/** Map WordPress post types to EmDash collections */\n\tpostTypeMappings: Record<\n\t\tstring,\n\t\t{\n\t\t\tcollection: string;\n\t\t\tenabled: boolean;\n\t\t}\n\t>;\n\t/** Whether to skip items that already exist (by slug) */\n\tskipExisting: boolean;\n\t/** Whether to import reusable blocks (wp_block) as sections */\n\timportSections?: boolean;\n\t/** Author mappings (WP author login -> EmDash user ID) */\n\tauthorMappings?: Record<string, string | null>;\n\t/** BCP 47 locale for all imported items. When omitted, defaults to defaultLocale. */\n\tlocale?: string;\n}\n\nexport interface ImportResult {\n\tsuccess: boolean;\n\timported: number;\n\tskipped: number;\n\terrors: Array<{ title: string; error: string }>;\n\tbyCollection: Record<string, number>;\n\t/** Sections import results (if enabled) */\n\tsections?: {\n\t\tcreated: number;\n\t\tskipped: number;\n\t};\n\t/** Taxonomy import results (categories, tags, custom taxonomies). */\n\ttaxonomies?: {\n\t\t/** Terms newly created during this import, keyed by taxonomy name. */\n\t\ttermsCreated: Record<string, number>;\n\t\t/** Existing terms that were re-used, keyed by taxonomy name. */\n\t\ttermsReused: Record<string, number>;\n\t\t/** Total pivot rows (post <-> term) written to `content_taxonomies`. */\n\t\tassignments: number;\n\t\t/**\n\t\t * Custom taxonomy names from the WXR file that had no matching EmDash\n\t\t * definition and were therefore skipped. Lets the admin UI surface a\n\t\t * \"create taxonomy X first\" hint without re-running the import.\n\t\t */\n\t\tmissingTaxonomies: string[];\n\t};\n}\n\nexport const POST: APIRoute = async ({ request, locals }) => {\n\tconst { emdash, user } = locals;\n\n\tconst denied = requirePerm(user, \"import:execute\");\n\tif (denied) return denied;\n\n\tif (!emdash?.handleContentCreate) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash not configured\", 500);\n\t}\n\n\ttry {\n\t\tconst emdashManifest = await emdash.getManifest();\n\n\t\tconst formData = await request.formData();\n\t\tconst fileEntry = formData.get(\"file\");\n\t\tconst file = fileEntry instanceof File ? fileEntry : null;\n\t\tconst configEntry = formData.get(\"config\");\n\t\tconst configJson = typeof configEntry === \"string\" ? configEntry : null;\n\n\t\tif (!file) {\n\t\t\treturn apiError(\"VALIDATION_ERROR\", \"No file provided\", 400);\n\t\t}\n\n\t\tif (!configJson) {\n\t\t\treturn apiError(\"VALIDATION_ERROR\", \"No config provided\", 400);\n\t\t}\n\n\t\tconst config: ImportConfig = JSON.parse(configJson);\n\n\t\t// Parse WXR\n\t\tconst text = await file.text();\n\t\tconst wxr = await parseWxrString(text);\n\n\t\t// Build attachment ID -> URL map for featured images\n\t\tconst attachmentMap = new Map<string, string>();\n\t\tfor (const att of wxr.attachments) {\n\t\t\tif (att.id && att.url) {\n\t\t\t\tattachmentMap.set(String(att.id), att.url);\n\t\t\t}\n\t\t}\n\n\t\t// Build author login -> display name map\n\t\tconst authorDisplayNames = new Map<string, string>();\n\t\tfor (const author of wxr.authors) {\n\t\t\tif (!author.login) continue;\n\t\t\tauthorDisplayNames.set(author.login, author.displayName || author.login);\n\t\t}\n\n\t\t// Pre-create taxonomy terms (categories, tags, custom taxonomies) so\n\t\t// per-post assignments can resolve to existing rows. Done before any\n\t\t// content insert because WXR exports list terms at the top of the\n\t\t// file but per-item assignments only reference them by slug.\n\t\tconst taxonomyPlan = await preImportWxrTaxonomies(\n\t\t\temdash.db,\n\t\t\twxr.posts,\n\t\t\twxr.categories,\n\t\t\twxr.tags,\n\t\t\twxr.terms,\n\t\t\tconfig.locale,\n\t\t);\n\n\t\t// Multilingual imports (WPML / Polylang -- see #1080) need a term\n\t\t// row at each per-post locale, all sharing the canonical term's\n\t\t// `translation_group`. Without this, `getTermsForEntry(..., locale)`\n\t\t// on non-canonical translations comes back empty.\n\t\t//\n\t\t// The mirror raises `WxrTaxonomyConflictError` with an operator-\n\t\t// actionable message when an existing locale row has an\n\t\t// incompatible group. Surface its `publicMessage` directly so the\n\t\t// admin UI can tell the user which (taxonomy, slug, locale) needs\n\t\t// reconciliation. Other errors (DB connectivity, unexpected\n\t\t// repository failures) re-throw to the outer catch where\n\t\t// `handleError` masks them with the generic \"Failed to import\n\t\t// content\" -- exposing raw DB errors to clients would leak schema\n\t\t// names and bypass the AGENTS.md \"never expose error.message\" rule.\n\t\tconst postLocales = new Set<string>();\n\t\tfor (const post of wxr.posts) {\n\t\t\tif (post.locale) postLocales.add(post.locale);\n\t\t}\n\t\tif (postLocales.size > 0) {\n\t\t\ttry {\n\t\t\t\tawait mirrorTermsToLocales(emdash.db, taxonomyPlan, postLocales, config.locale);\n\t\t\t} catch (mirrorError) {\n\t\t\t\tif (isWxrTaxonomyConflictError(mirrorError)) {\n\t\t\t\t\tconsole.error(\"[WXR_IMPORT_TAXONOMY_CONFLICT]\", mirrorError);\n\t\t\t\t\treturn apiError(\"WXR_IMPORT_TAXONOMY_CONFLICT\", mirrorError.publicMessage, 409);\n\t\t\t\t}\n\t\t\t\tthrow mirrorError;\n\t\t\t}\n\t\t}\n\n\t\t// Import content (locale from config scopes all items)\n\t\tconst result = await importContent(\n\t\t\twxr.posts,\n\t\t\tconfig,\n\t\t\temdash,\n\t\t\temdashManifest,\n\t\t\tattachmentMap,\n\t\t\tconfig.locale,\n\t\t\tauthorDisplayNames,\n\t\t\ttaxonomyPlan,\n\t\t);\n\n\t\t// Import reusable blocks as sections (if enabled)\n\t\tif (config.importSections !== false) {\n\t\t\tconst sectionsResult = await importReusableBlocksAsSections(wxr.posts, emdash.db);\n\t\t\tresult.sections = {\n\t\t\t\tcreated: sectionsResult.sectionsCreated,\n\t\t\t\tskipped: sectionsResult.sectionsSkipped,\n\t\t\t};\n\t\t\t// Add section errors to main errors array\n\t\t\tresult.errors.push(...sectionsResult.errors);\n\t\t\tif (sectionsResult.errors.length > 0) {\n\t\t\t\tresult.success = false;\n\t\t\t}\n\t\t}\n\n\t\treturn apiSuccess(result);\n\t} catch (error) {\n\t\treturn handleError(error, \"Failed to import content\", \"WXR_IMPORT_ERROR\");\n\t}\n};\n\nexport async function importContent(\n\tposts: WxrPost[],\n\tconfig: ImportConfig,\n\temdash: EmDashHandlers,\n\tmanifest: EmDashManifest,\n\tattachmentMap: Map<string, string>,\n\tlocale: string | undefined,\n\tauthorDisplayNames: Map<string, string> | undefined,\n\ttaxonomyPlan: TaxonomyImportPlan,\n): Promise<ImportResult> {\n\tconst result: ImportResult = {\n\t\tsuccess: true,\n\t\timported: 0,\n\t\tskipped: 0,\n\t\terrors: [],\n\t\tbyCollection: {},\n\t\ttaxonomies: {\n\t\t\ttermsCreated: taxonomyPlan.termsCreated,\n\t\t\ttermsReused: taxonomyPlan.termsReused,\n\t\t\tassignments: 0,\n\t\t\tmissingTaxonomies: taxonomyPlan.missingTaxonomies,\n\t\t},\n\t};\n\n\t// Create content repository for checking existing items\n\tconst contentRepo = new ContentRepository(emdash.db);\n\tconst bylineRepo = new BylineRepository(emdash.db);\n\tconst bylineCache = new Map<string, string>();\n\n\t// Source-side translation group ID -> the EmDash ID of the first post we\n\t// imported for that group. Subsequent translations are linked via\n\t// `translationOf` so they share a `translation_group` on the EmDash side.\n\tconst translationGroupMap = new Map<string, string>();\n\n\tfor (const post of posts) {\n\t\tconst postType = post.postType || \"post\";\n\t\tconst mapping = config.postTypeMappings[postType];\n\n\t\t// Skip if not mapped or disabled\n\t\tif (!mapping || !mapping.enabled) {\n\t\t\tresult.skipped++;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Defensive: mapping.collection is already sanitized by prepare, but the user\n\t\t// could manually edit the import config between prepare and execute.\n\t\tconst collection = sanitizeSlug(mapping.collection);\n\n\t\t// Check if collection exists in manifest\n\t\tif (!manifest?.collections[collection]) {\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\terror: `Collection \"${collection}\" does not exist`,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert content to Portable Text\n\t\t\tconst content = post.content ? gutenbergToPortableText(post.content) : [];\n\n\t\t\t// Generate slug from post name or title\n\t\t\tconst slug = post.postName || slugify(post.title || `post-${post.id || Date.now()}`);\n\n\t\t\t// Per-post locale: prefer the value extracted from WPML/Polylang\n\t\t\t// metadata; fall back to the upload-wide locale. Two translations\n\t\t\t// sharing `post_name` (e.g. /en/hello + /ar/hello) collide on the\n\t\t\t// `UNIQUE(slug, locale)` constraint when they share a locale, so\n\t\t\t// honouring the per-post value is what makes multilingual imports\n\t\t\t// land correctly. See issue #1080.\n\t\t\tconst postLocale = post.locale ?? locale;\n\n\t\t\t// Check if already exists (idempotency). Match against the\n\t\t\t// per-post locale so the same slug in different locales doesn't\n\t\t\t// false-positive as duplicate.\n\t\t\tif (config.skipExisting) {\n\t\t\t\tconst existing = await contentRepo.findBySlug(collection, slug, postLocale);\n\t\t\t\tif (existing) {\n\t\t\t\t\t// Record the translation group mapping so later\n\t\t\t\t\t// translations in this WXR can link to the existing\n\t\t\t\t\t// item. We deliberately trust the WXR's grouping over\n\t\t\t\t\t// the existing row's `translation_group`: a singleton\n\t\t\t\t\t// existing row gets folded into the WXR's group when\n\t\t\t\t\t// `handleContentCreate` resolves the new translation's\n\t\t\t\t\t// `translationOf`. Pre-existing translations that\n\t\t\t\t\t// already belong to a different group are left alone --\n\t\t\t\t\t// the user is responsible for reconciling those through\n\t\t\t\t\t// the admin if they don't match the WXR.\n\t\t\t\t\tif (post.translationGroup) {\n\t\t\t\t\t\ttranslationGroupMap.set(post.translationGroup, existing.id);\n\t\t\t\t\t}\n\t\t\t\t\tresult.skipped++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Resolve translation group: if this post belongs to a group and\n\t\t\t// we've already imported one of its translations, link to it.\n\t\t\tlet translationOf: string | undefined;\n\t\t\tif (post.translationGroup) {\n\t\t\t\ttranslationOf = translationGroupMap.get(post.translationGroup);\n\t\t\t}\n\n\t\t\t// Map WordPress status to EmDash status\n\t\t\tconst status = mapStatus(post.status);\n\n\t\t\t// Build data object with required fields\n\t\t\tconst data: Record<string, unknown> = {\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\tcontent,\n\t\t\t\texcerpt: post.excerpt || undefined,\n\t\t\t};\n\n\t\t\t// Only add featured_image if the collection has this field and we have a value\n\t\t\tconst collectionSchema = manifest.collections[collection];\n\t\t\tconst hasFeaturedImageField = collectionSchema?.fields\n\t\t\t\t? \"featured_image\" in collectionSchema.fields\n\t\t\t\t: false;\n\t\t\tif (hasFeaturedImageField) {\n\t\t\t\tconst thumbnailId = post.meta.get(\"_thumbnail_id\");\n\t\t\t\tconst featuredImage = thumbnailId ? attachmentMap.get(String(thumbnailId)) : undefined;\n\t\t\t\tif (featuredImage) {\n\t\t\t\t\tdata.featured_image = featuredImage;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Resolve author ID from mappings\n\t\t\tlet authorId: string | undefined;\n\t\t\tif (config.authorMappings && post.creator) {\n\t\t\t\tconst mappedUserId = config.authorMappings[post.creator];\n\t\t\t\tif (mappedUserId !== undefined && mappedUserId !== null) {\n\t\t\t\t\tauthorId = mappedUserId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst bylineId = await resolveImportByline(\n\t\t\t\tpost.creator,\n\t\t\t\tauthorDisplayNames?.get(post.creator ?? \"\") ?? post.creator,\n\t\t\t\tauthorId,\n\t\t\t\tbylineRepo,\n\t\t\t\tbylineCache,\n\t\t\t);\n\n\t\t\t// Preserve original WordPress dates using the shared WXR date parser.\n\t\t\t// Fallback chain: postDateGmt (UTC) → pubDate (RFC 2822) → postDate (site-local).\n\t\t\tconst parsedDate = parseWxrDate(post.postDateGmt, post.pubDate, post.postDate);\n\t\t\tconst createdAt = parsedDate ? parsedDate.toISOString() : undefined;\n\t\t\tconst publishedAt = status === \"published\" && createdAt ? createdAt : undefined;\n\n\t\t\t// Create the content item\n\t\t\tconst createResult = await emdash.handleContentCreate(collection, {\n\t\t\t\tdata,\n\t\t\t\tslug,\n\t\t\t\tstatus,\n\t\t\t\tauthorId,\n\t\t\t\tbylines: bylineId ? [{ bylineId }] : undefined,\n\t\t\t\tlocale: postLocale,\n\t\t\t\ttranslationOf,\n\t\t\t\tcreatedAt,\n\t\t\t\tpublishedAt,\n\t\t\t});\n\n\t\t\tif (createResult.success) {\n\t\t\t\tresult.imported++;\n\t\t\t\tresult.byCollection[collection] = (result.byCollection[collection] || 0) + 1;\n\n\t\t\t\t// `handleContentCreate` returns `data: { item, _rev? }` on\n\t\t\t\t// success (see `ApiResult<ContentResponse>` in\n\t\t\t\t// `api/handlers/content.ts`). `HandlerResponse.data` is\n\t\t\t\t// typed as `unknown` to avoid coupling the route surface to\n\t\t\t\t// internal handler types, so we narrow here.\n\t\t\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- handler contract documented at handleContentCreate\n\t\t\t\tconst createdItem = (createResult.data as { item: { id: string } } | undefined)?.item;\n\n\t\t\t\t// Track translation group: the first imported post in a group\n\t\t\t\t// becomes the anchor that later translations link to.\n\t\t\t\tif (\n\t\t\t\t\tcreatedItem &&\n\t\t\t\t\tpost.translationGroup &&\n\t\t\t\t\t!translationGroupMap.has(post.translationGroup)\n\t\t\t\t) {\n\t\t\t\t\ttranslationGroupMap.set(post.translationGroup, createdItem.id);\n\t\t\t\t}\n\n\t\t\t\t// Attach taxonomy assignments parsed from the WXR's per-item\n\t\t\t\t// <category> elements.\n\t\t\t\t//\n\t\t\t\t// Anchors (no `translationOf`) get an additive attach -- the\n\t\t\t\t// row is fresh, no inherited pivots to consider.\n\t\t\t\t//\n\t\t\t\t// Translations get per-taxonomy replace semantics. WPML's\n\t\t\t\t// \"Translate Independently\" mode is per-taxonomy, not per-\n\t\t\t\t// post: a translation that overrides `category` shouldn't\n\t\t\t\t// lose its inherited `tag` or `genre`. The replace path\n\t\t\t\t// only touches taxonomies the translation actually carries\n\t\t\t\t// AND that resolve to at least one term that survives the\n\t\t\t\t// def's `collections` filter; taxonomies with no resolved\n\t\t\t\t// terms (missing-def, dropped by filter, or just absent\n\t\t\t\t// from the WXR) fall through with the inherited set intact\n\t\t\t\t// from `copyEntryTerms`.\n\t\t\t\tif (createdItem) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst written = translationOf\n\t\t\t\t\t\t\t? await setPostTermAssignmentsReplacing(\n\t\t\t\t\t\t\t\t\temdash.db,\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tcreatedItem.id,\n\t\t\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t\t\ttaxonomyPlan,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: await attachPostTaxonomies(\n\t\t\t\t\t\t\t\t\temdash.db,\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tcreatedItem.id,\n\t\t\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t\t\ttaxonomyPlan,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\tif (result.taxonomies) {\n\t\t\t\t\t\t\tresult.taxonomies.assignments += written;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (taxError) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`Failed to attach taxonomies for \"${post.title || \"Untitled\"}\":`,\n\t\t\t\t\t\t\ttaxError,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult.errors.push({\n\t\t\t\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\ttaxError instanceof Error && taxError.message\n\t\t\t\t\t\t\t\t\t? `Imported but failed to attach taxonomies: ${taxError.message}`\n\t\t\t\t\t\t\t\t\t: \"Imported but failed to attach taxonomies\",\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult.errors.push({\n\t\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\t\terror:\n\t\t\t\t\t\ttypeof createResult.error === \"object\" && createResult.error !== null\n\t\t\t\t\t\t\t? (createResult.error as { message?: string }).message || \"Unknown error\"\n\t\t\t\t\t\t\t: String(createResult.error),\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(`Import error for \"${post.title || \"Untitled\"}\":`, error);\n\t\t\tresult.errors.push({\n\t\t\t\ttitle: post.title || \"Untitled\",\n\t\t\t\terror: error instanceof Error && error.message ? error.message : \"Failed to import item\",\n\t\t\t});\n\t\t}\n\t}\n\n\tresult.success = result.errors.length === 0;\n\treturn result;\n}\n\nfunction mapStatus(wpStatus: string | undefined): string {\n\tswitch (wpStatus) {\n\t\tcase \"publish\":\n\t\t\treturn \"published\";\n\t\tcase \"draft\":\n\t\t\treturn \"draft\";\n\t\tcase \"pending\":\n\t\t\treturn \"draft\";\n\t\tcase \"private\":\n\t\t\treturn \"draft\";\n\t\tdefault:\n\t\t\treturn \"draft\";\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,YAAY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xD,SAAQ,UAAR;EACC,KAAK,UACJ,QAAO;EACR,KAAK,QACJ,QAAO;EACR,KAAK,UACJ,QAAO;EACR,KAAK,UACJ,QAAO;EACR,QACC,QAAO"}
@@ -1,13 +1,13 @@
1
- import "../../../../../options-BqMkWfYa.mjs";
2
- import "../../../../../types-DPKhI5ib.mjs";
3
- import "../../../../../types-BvB7gDOD.mjs";
4
- import "../../../../../relations-qKmSj9KM.mjs";
5
- import "../../../../../index-BZJ_5FOX.mjs";
6
- import "../../../../../runner-Dd8m8k9F.mjs";
7
- import "../../../../../index-BEui-cRd.mjs";
8
- import "../../../../../types-C7U0HlEr.mjs";
9
- import "../../../../../hreflang-CIxH_LKz.mjs";
10
- import "../../../../../validate-DULfgpJP.mjs";
1
+ import "../../../../../options-CA4eVX6P.mjs";
2
+ import "../../../../../types-Dc4ntQjQ.mjs";
3
+ import "../../../../../types-Cz8hNch2.mjs";
4
+ import "../../../../../relations-G2ta7GIl.mjs";
5
+ import "../../../../../index-M37iz29I.mjs";
6
+ import "../../../../../runner-BaADli8l.mjs";
7
+ import "../../../../../index-MGw47uWq.mjs";
8
+ import "../../../../../types-C8oz_ayJ.mjs";
9
+ import "../../../../../hreflang-BaLCNcDx.mjs";
10
+ import "../../../../../validate-C3oSmA7F.mjs";
11
11
  import { EmDashHandlers } from "../../../../types.mjs";
12
12
  import { AttachmentInfo } from "./analyze.mjs";
13
13
  import { APIRoute } from "astro";
@@ -1,16 +1,16 @@
1
1
  import "../../../../../base64-B-PsqheR.mjs";
2
- import "../../../../../types-CrRUFdej.mjs";
2
+ import "../../../../../types-Cd8iuS1J.mjs";
3
3
  import { t as enrichImageMetadata } from "../../../../../enrich-CFJJgxs_.mjs";
4
- import { a as validateExternalUrl, r as ssrfSafeFetch, t as SsrfError } from "../../../../../ssrf-CviKqWmq.mjs";
5
- import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-DJ98TRbQ.mjs";
6
- import { n as parseBody, t as isParseError } from "../../../../../parse-53zyxlpv.mjs";
7
- import "../../../../../media-BJ6SRY3g.mjs";
8
- import "../../../../../redirects-D457qwt0.mjs";
9
- import { C as wpMediaImportBody } from "../../../../../relations-CZMpBqEd.mjs";
10
- import "../../../../../status-COfycGIU.mjs";
4
+ import { a as validateExternalUrl, r as ssrfSafeFetch, t as SsrfError } from "../../../../../ssrf-CTa6v21i.mjs";
5
+ import { n as apiSuccess, r as handleError, t as apiError } from "../../../../../error-oh_9i6bR.mjs";
6
+ import { n as parseBody, t as isParseError } from "../../../../../parse-CJKNuewM.mjs";
7
+ import "../../../../../media-OhYL-7Io.mjs";
8
+ import "../../../../../redirects-G8wAhWAf.mjs";
9
+ import { C as wpMediaImportBody } from "../../../../../relations-Bw_E1TXo.mjs";
10
+ import "../../../../../status-CIsmlC1E.mjs";
11
11
  import "../../../../../api/schemas/index.mjs";
12
- import "../../../../../ssrf-BB__xfNM.mjs";
13
- import { r as requirePerm } from "../../../../../authorize-6WPZa1xZ.mjs";
12
+ import "../../../../../ssrf-Cj568Dgs.mjs";
13
+ import { r as requirePerm } from "../../../../../authorize-qRhWQnel.mjs";
14
14
  import { ulid } from "ulidx";
15
15
  import mime from "mime/lite";
16
16
  import * as path from "node:path";