emdash 0.37.0 → 0.38.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 (811) hide show
  1. package/dist/{activation-K0kGBWuJ.mjs → activation-DyNTe_Tl.mjs} +3 -3
  2. package/dist/{activation-K0kGBWuJ.mjs.map → activation-DyNTe_Tl.mjs.map} +1 -1
  3. package/dist/{adapters-BDQwg236.d.mts → adapters-DCEgOBXi.d.mts} +1 -1
  4. package/dist/{adapters-BDQwg236.d.mts.map → adapters-DCEgOBXi.d.mts.map} +1 -1
  5. package/dist/{allowed-origins-BGglilcs.mjs → allowed-origins-GFUVavRj.mjs} +2 -2
  6. package/dist/{allowed-origins-BGglilcs.mjs.map → allowed-origins-GFUVavRj.mjs.map} +1 -1
  7. package/dist/api/route-utils.d.mts +3 -3
  8. package/dist/api/route-utils.mjs +23 -22
  9. package/dist/api/route-utils.mjs.map +1 -1
  10. package/dist/api/schemas/index.d.mts +2 -2
  11. package/dist/api/schemas/index.mjs +5 -5
  12. package/dist/{api-Dz6rgoa3.mjs → api-BvxJmnFY.mjs} +141 -87
  13. package/dist/api-BvxJmnFY.mjs.map +1 -0
  14. package/dist/{api-tokens-BSsQACNe.mjs → api-tokens-xpGqMHrC.mjs} +2 -2
  15. package/dist/{api-tokens-BSsQACNe.mjs.map → api-tokens-xpGqMHrC.mjs.map} +1 -1
  16. package/dist/{apply-B4SIOxR1.mjs → apply-DLmM3R7f.mjs} +25 -21
  17. package/dist/apply-DLmM3R7f.mjs.map +1 -0
  18. package/dist/{config-it29yDLA.mjs → artifact-fetch-P2JXVwOq.mjs} +8 -199
  19. package/dist/artifact-fetch-P2JXVwOq.mjs.map +1 -0
  20. package/dist/astro/index.d.mts +12 -12
  21. package/dist/astro/index.d.mts.map +1 -1
  22. package/dist/astro/index.mjs +37 -11
  23. package/dist/astro/index.mjs.map +1 -1
  24. package/dist/astro/middleware/auth.d.mts +10 -10
  25. package/dist/astro/middleware/auth.mjs +6 -6
  26. package/dist/astro/middleware/media-usage-write-fence.mjs +3 -3
  27. package/dist/astro/middleware/redirect.mjs +7 -5
  28. package/dist/astro/middleware/redirect.mjs.map +1 -1
  29. package/dist/astro/middleware/request-context.mjs +3 -3
  30. package/dist/astro/middleware/setup.mjs +1 -1
  31. package/dist/astro/middleware.d.mts +10 -10
  32. package/dist/astro/middleware.d.mts.map +1 -1
  33. package/dist/astro/middleware.mjs +154 -125
  34. package/dist/astro/middleware.mjs.map +1 -1
  35. package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +6 -6
  36. package/dist/astro/routes/api/admin/allowed-domains/index.mjs +6 -6
  37. package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +3 -3
  38. package/dist/astro/routes/api/admin/api-tokens/index.mjs +4 -4
  39. package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -4
  40. package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +9 -9
  41. package/dist/astro/routes/api/admin/byline-fields/index.mjs +9 -9
  42. package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +9 -9
  43. package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +16 -16
  44. package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +16 -16
  45. package/dist/astro/routes/api/admin/bylines/index.mjs +16 -16
  46. package/dist/astro/routes/api/admin/comments/_id_/status.mjs +11 -11
  47. package/dist/astro/routes/api/admin/comments/_id_.mjs +3 -3
  48. package/dist/astro/routes/api/admin/comments/bulk.mjs +8 -8
  49. package/dist/astro/routes/api/admin/comments/counts.mjs +3 -3
  50. package/dist/astro/routes/api/admin/comments/index.mjs +8 -8
  51. package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +4 -4
  52. package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
  53. package/dist/astro/routes/api/admin/media-usage/activation.mjs +13 -13
  54. package/dist/astro/routes/api/admin/media-usage/collection-deletions/index.mjs +15 -15
  55. package/dist/astro/routes/api/admin/media-usage/collection-deletions/retry.mjs +15 -15
  56. package/dist/astro/routes/api/admin/media-usage/progress.mjs +13 -13
  57. package/dist/astro/routes/api/admin/media-usage/repair.mjs +16 -16
  58. package/dist/astro/routes/api/admin/media-usage/work/index.mjs +15 -15
  59. package/dist/astro/routes/api/admin/media-usage/work/retry.mjs +15 -15
  60. package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +3 -3
  61. package/dist/astro/routes/api/admin/oauth-clients/index.mjs +3 -3
  62. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +56 -53
  63. package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs.map +1 -1
  64. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +56 -53
  65. package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs.map +1 -1
  66. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +54 -51
  67. package/dist/astro/routes/api/admin/plugins/_id_/index.mjs.map +1 -1
  68. package/dist/astro/routes/api/admin/plugins/_id_/mcp.mjs +4 -4
  69. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs +54 -51
  70. package/dist/astro/routes/api/admin/plugins/_id_/settings.mjs.map +1 -1
  71. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +55 -52
  72. package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs.map +1 -1
  73. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +55 -52
  74. package/dist/astro/routes/api/admin/plugins/_id_/update.mjs.map +1 -1
  75. package/dist/astro/routes/api/admin/plugins/index.mjs +54 -51
  76. package/dist/astro/routes/api/admin/plugins/index.mjs.map +1 -1
  77. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
  78. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +54 -51
  79. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs.map +1 -1
  80. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +55 -52
  81. package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs.map +1 -1
  82. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +54 -51
  83. package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs.map +1 -1
  84. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs +55 -52
  85. package/dist/astro/routes/api/admin/plugins/registry/_id_/uninstall.mjs.map +1 -1
  86. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs +56 -53
  87. package/dist/astro/routes/api/admin/plugins/registry/_id_/update.mjs.map +1 -1
  88. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs +5 -4
  89. package/dist/astro/routes/api/admin/plugins/registry/artifact.mjs.map +1 -1
  90. package/dist/astro/routes/api/admin/plugins/registry/install.mjs +56 -53
  91. package/dist/astro/routes/api/admin/plugins/registry/install.mjs.map +1 -1
  92. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs +55 -52
  93. package/dist/astro/routes/api/admin/plugins/registry/verify.mjs.map +1 -1
  94. package/dist/astro/routes/api/admin/plugins/updates.mjs +54 -51
  95. package/dist/astro/routes/api/admin/plugins/updates.mjs.map +1 -1
  96. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +54 -51
  97. package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs.map +1 -1
  98. package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
  99. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +54 -51
  100. package/dist/astro/routes/api/admin/themes/marketplace/index.mjs.map +1 -1
  101. package/dist/astro/routes/api/admin/users/_id_/disable.mjs +1 -1
  102. package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
  103. package/dist/astro/routes/api/admin/users/_id_/index.mjs +6 -6
  104. package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +3 -3
  105. package/dist/astro/routes/api/admin/users/index.mjs +6 -6
  106. package/dist/astro/routes/api/auth/dev-bypass.mjs +3 -3
  107. package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
  108. package/dist/astro/routes/api/auth/invite/complete.mjs +11 -11
  109. package/dist/astro/routes/api/auth/invite/index.mjs +8 -8
  110. package/dist/astro/routes/api/auth/invite/register-options.mjs +10 -10
  111. package/dist/astro/routes/api/auth/logout.mjs +2 -2
  112. package/dist/astro/routes/api/auth/magic-link/send.mjs +10 -10
  113. package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
  114. package/dist/astro/routes/api/auth/me.mjs +7 -7
  115. package/dist/astro/routes/api/auth/mode.mjs +2 -2
  116. package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +4 -4
  117. package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
  118. package/dist/astro/routes/api/auth/passkey/_id_.mjs +6 -6
  119. package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
  120. package/dist/astro/routes/api/auth/passkey/options.mjs +12 -12
  121. package/dist/astro/routes/api/auth/passkey/register/options.mjs +10 -10
  122. package/dist/astro/routes/api/auth/passkey/register/verify.mjs +11 -11
  123. package/dist/astro/routes/api/auth/passkey/verify.mjs +11 -11
  124. package/dist/astro/routes/api/auth/signup/complete.mjs +11 -11
  125. package/dist/astro/routes/api/auth/signup/request.mjs +10 -10
  126. package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
  127. package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +12 -12
  128. package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +11 -11
  129. package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
  130. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.d.mts.map +1 -1
  131. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +13 -8
  132. package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs.map +1 -1
  133. package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +3 -3
  134. package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts +10 -0
  135. package/dist/astro/routes/api/content/_collection_/_id_/lock.d.mts.map +1 -0
  136. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs +66 -0
  137. package/dist/astro/routes/api/content/_collection_/_id_/lock.mjs.map +1 -0
  138. package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +2 -2
  139. package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +11 -11
  140. package/dist/astro/routes/api/content/_collection_/_id_/publish.d.mts.map +1 -1
  141. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +14 -9
  142. package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs.map +1 -1
  143. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs +19 -17
  144. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/children.mjs.map +1 -1
  145. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs +19 -17
  146. package/dist/astro/routes/api/content/_collection_/_id_/references/_relation_/parents.mjs.map +1 -1
  147. package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +3 -3
  148. package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
  149. package/dist/astro/routes/api/content/_collection_/_id_/schedule.d.mts.map +1 -1
  150. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +15 -8
  151. package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs.map +1 -1
  152. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +15 -14
  153. package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs.map +1 -1
  154. package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
  155. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.d.mts.map +1 -1
  156. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +13 -8
  157. package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs.map +1 -1
  158. package/dist/astro/routes/api/content/_collection_/_id_.d.mts.map +1 -1
  159. package/dist/astro/routes/api/content/_collection_/_id_.mjs +23 -11
  160. package/dist/astro/routes/api/content/_collection_/_id_.mjs.map +1 -1
  161. package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
  162. package/dist/astro/routes/api/content/_collection_/index.mjs +14 -9
  163. package/dist/astro/routes/api/content/_collection_/index.mjs.map +1 -1
  164. package/dist/astro/routes/api/content/_collection_/trash.mjs +7 -7
  165. package/dist/astro/routes/api/dashboard.mjs +6 -6
  166. package/dist/astro/routes/api/dev/emails.mjs +2 -2
  167. package/dist/astro/routes/api/import/probe.d.mts +3 -3
  168. package/dist/astro/routes/api/import/probe.mjs +16 -16
  169. package/dist/astro/routes/api/import/wordpress/analyze.mjs +3 -3
  170. package/dist/astro/routes/api/import/wordpress/execute.d.mts +11 -11
  171. package/dist/astro/routes/api/import/wordpress/execute.mjs +14 -13
  172. package/dist/astro/routes/api/import/wordpress/execute.mjs.map +1 -1
  173. package/dist/astro/routes/api/import/wordpress/media.d.mts +10 -10
  174. package/dist/astro/routes/api/import/wordpress/media.mjs +11 -11
  175. package/dist/astro/routes/api/import/wordpress/prepare.mjs +10 -10
  176. package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +11 -11
  177. package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +13 -13
  178. package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
  179. package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +16 -16
  180. package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +11 -11
  181. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +27 -26
  182. package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs.map +1 -1
  183. package/dist/astro/routes/api/manifest.mjs +4 -4
  184. package/dist/astro/routes/api/mcp.mjs +71 -55
  185. package/dist/astro/routes/api/mcp.mjs.map +1 -1
  186. package/dist/astro/routes/api/media/_id_/confirm.mjs +10 -10
  187. package/dist/astro/routes/api/media/_id_/replace.mjs +8 -8
  188. package/dist/astro/routes/api/media/_id_/upload.mjs +5 -5
  189. package/dist/astro/routes/api/media/_id_/usage.mjs +18 -18
  190. package/dist/astro/routes/api/media/_id_.mjs +17 -17
  191. package/dist/astro/routes/api/media/file/_...key_.mjs +1 -1
  192. package/dist/astro/routes/api/media/folders/_id_.mjs +8 -8
  193. package/dist/astro/routes/api/media/folders/index.mjs +8 -8
  194. package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
  195. package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
  196. package/dist/astro/routes/api/media/providers/index.mjs +2 -2
  197. package/dist/astro/routes/api/media/upload-url.mjs +9 -9
  198. package/dist/astro/routes/api/media.mjs +21 -21
  199. package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +9 -9
  200. package/dist/astro/routes/api/menus/_name_/items.mjs +9 -9
  201. package/dist/astro/routes/api/menus/_name_/reorder.mjs +9 -9
  202. package/dist/astro/routes/api/menus/_name_/translations.mjs +9 -9
  203. package/dist/astro/routes/api/menus/_name_.mjs +9 -9
  204. package/dist/astro/routes/api/menus/index.mjs +9 -9
  205. package/dist/astro/routes/api/oauth/authorize.mjs +6 -6
  206. package/dist/astro/routes/api/oauth/device/authorize.mjs +5 -5
  207. package/dist/astro/routes/api/oauth/device/code.mjs +8 -8
  208. package/dist/astro/routes/api/oauth/device/token.mjs +7 -7
  209. package/dist/astro/routes/api/oauth/register.mjs +2 -2
  210. package/dist/astro/routes/api/oauth/token/refresh.mjs +5 -5
  211. package/dist/astro/routes/api/oauth/token/revoke.mjs +5 -5
  212. package/dist/astro/routes/api/oauth/token.mjs +5 -5
  213. package/dist/astro/routes/api/openapi.json.mjs +84 -18
  214. package/dist/astro/routes/api/openapi.json.mjs.map +1 -1
  215. package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +4 -4
  216. package/dist/astro/routes/api/redirects/404s/index.mjs +12 -11
  217. package/dist/astro/routes/api/redirects/404s/index.mjs.map +1 -1
  218. package/dist/astro/routes/api/redirects/404s/summary.mjs +12 -11
  219. package/dist/astro/routes/api/redirects/404s/summary.mjs.map +1 -1
  220. package/dist/astro/routes/api/redirects/_id_.mjs +13 -12
  221. package/dist/astro/routes/api/redirects/_id_.mjs.map +1 -1
  222. package/dist/astro/routes/api/redirects/index.mjs +13 -12
  223. package/dist/astro/routes/api/redirects/index.mjs.map +1 -1
  224. package/dist/astro/routes/api/relations/_id_/index.mjs +19 -17
  225. package/dist/astro/routes/api/relations/_id_/index.mjs.map +1 -1
  226. package/dist/astro/routes/api/relations/_id_/translations.mjs +14 -12
  227. package/dist/astro/routes/api/relations/_id_/translations.mjs.map +1 -1
  228. package/dist/astro/routes/api/relations/index.mjs +19 -17
  229. package/dist/astro/routes/api/relations/index.mjs.map +1 -1
  230. package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
  231. package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +3 -3
  232. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +54 -51
  233. package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs.map +1 -1
  234. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +54 -51
  235. package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs.map +1 -1
  236. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +54 -51
  237. package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs.map +1 -1
  238. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +54 -51
  239. package/dist/astro/routes/api/schema/collections/_slug_/index.mjs.map +1 -1
  240. package/dist/astro/routes/api/schema/collections/index.mjs +54 -51
  241. package/dist/astro/routes/api/schema/collections/index.mjs.map +1 -1
  242. package/dist/astro/routes/api/schema/collections/reorder.mjs +54 -51
  243. package/dist/astro/routes/api/schema/collections/reorder.mjs.map +1 -1
  244. package/dist/astro/routes/api/schema/index.mjs +13 -11
  245. package/dist/astro/routes/api/schema/index.mjs.map +1 -1
  246. package/dist/astro/routes/api/schema/orphans/_slug_.mjs +54 -51
  247. package/dist/astro/routes/api/schema/orphans/_slug_.mjs.map +1 -1
  248. package/dist/astro/routes/api/schema/orphans/index.mjs +54 -51
  249. package/dist/astro/routes/api/schema/orphans/index.mjs.map +1 -1
  250. package/dist/astro/routes/api/search/enable.mjs +12 -11
  251. package/dist/astro/routes/api/search/enable.mjs.map +1 -1
  252. package/dist/astro/routes/api/search/index.mjs +11 -10
  253. package/dist/astro/routes/api/search/index.mjs.map +1 -1
  254. package/dist/astro/routes/api/search/rebuild.mjs +12 -11
  255. package/dist/astro/routes/api/search/rebuild.mjs.map +1 -1
  256. package/dist/astro/routes/api/search/stats.mjs +7 -6
  257. package/dist/astro/routes/api/search/stats.mjs.map +1 -1
  258. package/dist/astro/routes/api/search/suggest.mjs +11 -10
  259. package/dist/astro/routes/api/search/suggest.mjs.map +1 -1
  260. package/dist/astro/routes/api/sections/_slug_.mjs +11 -10
  261. package/dist/astro/routes/api/sections/_slug_.mjs.map +1 -1
  262. package/dist/astro/routes/api/sections/index.mjs +11 -10
  263. package/dist/astro/routes/api/sections/index.mjs.map +1 -1
  264. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs +7 -6
  265. package/dist/astro/routes/api/settings/backups/archives/_name_.mjs.map +1 -1
  266. package/dist/astro/routes/api/settings/backups/archives/index.mjs +6 -5
  267. package/dist/astro/routes/api/settings/backups/archives/index.mjs.map +1 -1
  268. package/dist/astro/routes/api/settings/backups/export.mjs +7 -6
  269. package/dist/astro/routes/api/settings/backups/export.mjs.map +1 -1
  270. package/dist/astro/routes/api/settings/backups/index.mjs +8 -7
  271. package/dist/astro/routes/api/settings/backups/index.mjs.map +1 -1
  272. package/dist/astro/routes/api/settings/email.mjs +4 -4
  273. package/dist/astro/routes/api/settings.mjs +14 -14
  274. package/dist/astro/routes/api/setup/admin-verify.mjs +12 -12
  275. package/dist/astro/routes/api/setup/admin.mjs +11 -11
  276. package/dist/astro/routes/api/setup/dev-bypass.mjs +33 -31
  277. package/dist/astro/routes/api/setup/dev-bypass.mjs.map +1 -1
  278. package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
  279. package/dist/astro/routes/api/setup/index.mjs +33 -31
  280. package/dist/astro/routes/api/setup/index.mjs.map +1 -1
  281. package/dist/astro/routes/api/setup/status.mjs +3 -3
  282. package/dist/astro/routes/api/snapshot.mjs +8 -7
  283. package/dist/astro/routes/api/snapshot.mjs.map +1 -1
  284. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs +16 -15
  285. package/dist/astro/routes/api/taxonomies/_name_/reorder.mjs.map +1 -1
  286. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +16 -15
  287. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs.map +1 -1
  288. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +16 -15
  289. package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs.map +1 -1
  290. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +16 -15
  291. package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs.map +1 -1
  292. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs +15 -14
  293. package/dist/astro/routes/api/taxonomies/_name_/translations.mjs.map +1 -1
  294. package/dist/astro/routes/api/taxonomies/_name_.mjs +16 -15
  295. package/dist/astro/routes/api/taxonomies/_name_.mjs.map +1 -1
  296. package/dist/astro/routes/api/taxonomies/index.mjs +16 -15
  297. package/dist/astro/routes/api/taxonomies/index.mjs.map +1 -1
  298. package/dist/astro/routes/api/themes/preview.mjs +5 -5
  299. package/dist/astro/routes/api/typegen.mjs +4 -4
  300. package/dist/astro/routes/api/well-known/auth.mjs +2 -2
  301. package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +2 -2
  302. package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +2 -2
  303. package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +8 -8
  304. package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +12 -12
  305. package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +12 -12
  306. package/dist/astro/routes/api/widget-areas/_name_.mjs +7 -7
  307. package/dist/astro/routes/api/widget-areas/index.mjs +12 -12
  308. package/dist/astro/routes/api/widget-components.mjs +2 -2
  309. package/dist/astro/routes/robots.txt.mjs +6 -6
  310. package/dist/astro/routes/sitemap-_collection_.xml.mjs +11 -10
  311. package/dist/astro/routes/sitemap-_collection_.xml.mjs.map +1 -1
  312. package/dist/astro/routes/sitemap.xml.mjs +7 -7
  313. package/dist/astro/types.d.mts +32 -17
  314. package/dist/astro/types.d.mts.map +1 -1
  315. package/dist/auth/providers/github.d.mts +1 -1
  316. package/dist/auth/providers/google.d.mts +1 -1
  317. package/dist/{authorize-Bkf_UHhD.mjs → authorize-C2QHlWSS.mjs} +2 -2
  318. package/dist/{authorize-Bkf_UHhD.mjs.map → authorize-C2QHlWSS.mjs.map} +1 -1
  319. package/dist/{backup-rwVAl9NI.mjs → backup-oS8ft5Cm.mjs} +5 -5
  320. package/dist/{backup-rwVAl9NI.mjs.map → backup-oS8ft5Cm.mjs.map} +1 -1
  321. package/dist/{bundle-C8S2Zl6U.mjs → bundle-CL0JjIPx.mjs} +4 -4
  322. package/dist/{bundle-C8S2Zl6U.mjs.map → bundle-CL0JjIPx.mjs.map} +1 -1
  323. package/dist/{byline-DuhF7NWl.mjs → byline-Vdi85CsZ.mjs} +6 -6
  324. package/dist/{byline-DuhF7NWl.mjs.map → byline-Vdi85CsZ.mjs.map} +1 -1
  325. package/dist/{byline-fields-BovY4KYM.mjs → byline-fields-DPVRFMz2.mjs} +2 -2
  326. package/dist/{byline-fields-BovY4KYM.mjs.map → byline-fields-DPVRFMz2.mjs.map} +1 -1
  327. package/dist/{byline-registry-Bpu9-MVs.mjs → byline-registry-BxDGIO0I.mjs} +2 -2
  328. package/dist/{byline-registry-Bpu9-MVs.mjs.map → byline-registry-BxDGIO0I.mjs.map} +1 -1
  329. package/dist/{bylines-CJ5nd6Lw.mjs → bylines-BX8QhcTk.mjs} +7 -7
  330. package/dist/{bylines-CJ5nd6Lw.mjs.map → bylines-BX8QhcTk.mjs.map} +1 -1
  331. package/dist/{bylines-RwBAeOF1.mjs → bylines-w-E1IEQd.mjs} +3 -3
  332. package/dist/{bylines-RwBAeOF1.mjs.map → bylines-w-E1IEQd.mjs.map} +1 -1
  333. package/dist/{cache-BF5Kvn59.mjs → cache--7HKu5Xm.mjs} +4 -4
  334. package/dist/{cache-BF5Kvn59.mjs.map → cache--7HKu5Xm.mjs.map} +1 -1
  335. package/dist/{capture-triggers-CNW1q3HK.mjs → capture-triggers-CeAsC76Z.mjs} +2 -2
  336. package/dist/{capture-triggers-CNW1q3HK.mjs.map → capture-triggers-CeAsC76Z.mjs.map} +1 -1
  337. package/dist/{challenge-store-DQN_Yrck.mjs → challenge-store-BIOak-tp.mjs} +1 -1
  338. package/dist/{challenge-store-DQN_Yrck.mjs.map → challenge-store-BIOak-tp.mjs.map} +1 -1
  339. package/dist/{chrome-tags-D8fiZG94.mjs → chrome-tags-DzDQBCjX.mjs} +1 -1
  340. package/dist/{chrome-tags-D8fiZG94.mjs.map → chrome-tags-DzDQBCjX.mjs.map} +1 -1
  341. package/dist/{chunks-C4szrD8o.mjs → chunks-VG_tyqnP.mjs} +2 -2
  342. package/dist/{chunks-C4szrD8o.mjs.map → chunks-VG_tyqnP.mjs.map} +1 -1
  343. package/dist/cli/index.mjs +66 -38
  344. package/dist/cli/index.mjs.map +1 -1
  345. package/dist/client/cf-access.d.mts +1 -1
  346. package/dist/client/index.d.mts +17 -7
  347. package/dist/client/index.d.mts.map +1 -1
  348. package/dist/client/index.mjs +17 -12
  349. package/dist/client/index.mjs.map +1 -1
  350. package/dist/{collection-deletion-Bj07NHbj.mjs → collection-deletion-BCwaWTDw.mjs} +4 -4
  351. package/dist/{collection-deletion-Bj07NHbj.mjs.map → collection-deletion-BCwaWTDw.mjs.map} +1 -1
  352. package/dist/collection-slugs-cache-7lTmNzeA.mjs +85 -0
  353. package/dist/collection-slugs-cache-7lTmNzeA.mjs.map +1 -0
  354. package/dist/{comment-reaction-BhrvSHml.mjs → comment-reaction-CDyvPQRj.mjs} +2 -2
  355. package/dist/{comment-reaction-BhrvSHml.mjs.map → comment-reaction-CDyvPQRj.mjs.map} +1 -1
  356. package/dist/{comments-Ct4ensnf.mjs → comments-VzmVLyaC.mjs} +1 -1
  357. package/dist/{comments-Ct4ensnf.mjs.map → comments-VzmVLyaC.mjs.map} +1 -1
  358. package/dist/{components-DJbo1z0S.mjs → components-CL6Wkdk-.mjs} +1 -1
  359. package/dist/{components-DJbo1z0S.mjs.map → components-CL6Wkdk-.mjs.map} +1 -1
  360. package/dist/config--eWjQJE5.mjs +217 -0
  361. package/dist/config--eWjQJE5.mjs.map +1 -0
  362. package/dist/{index-BJNMCWmu.d.mts → config-CGAhyOjP.d.mts} +138 -47
  363. package/dist/config-CGAhyOjP.d.mts.map +1 -0
  364. package/dist/{config-B9eZ340f.d.mts → config-ChFzshGd.d.mts} +1 -1
  365. package/dist/{config-B9eZ340f.d.mts.map → config-ChFzshGd.d.mts.map} +1 -1
  366. package/dist/{content-DjvM0T92.mjs → content-CNfMWuhY.mjs} +121 -5
  367. package/dist/content-CNfMWuhY.mjs.map +1 -0
  368. package/dist/{content-list-query-Btqd4uV2.d.mts → content-list-query-B8d4UQp9.d.mts} +1 -1
  369. package/dist/{content-list-query-Btqd4uV2.d.mts.map → content-list-query-B8d4UQp9.d.mts.map} +1 -1
  370. package/dist/{content-refresh-Bwp-8yGy.mjs → content-refresh-GTMyi2Xy.mjs} +8 -8
  371. package/dist/{content-refresh-Bwp-8yGy.mjs.map → content-refresh-GTMyi2Xy.mjs.map} +1 -1
  372. package/dist/{content-repair-Czdp7jz5.mjs → content-repair-CIMt5C0U.mjs} +4 -4
  373. package/dist/{content-repair-Czdp7jz5.mjs.map → content-repair-CIMt5C0U.mjs.map} +1 -1
  374. package/dist/{context-CX6gxOLW.mjs → context-C9PB8vGd.mjs} +265 -25
  375. package/dist/context-C9PB8vGd.mjs.map +1 -0
  376. package/dist/{cron-C6o7VppJ.mjs → cron-DHAy9oyq.mjs} +1 -1
  377. package/dist/{cron-C6o7VppJ.mjs.map → cron-DHAy9oyq.mjs.map} +1 -1
  378. package/dist/{dashboard-C2kTeeRI.mjs → dashboard-BNSvAN8A.mjs} +4 -4
  379. package/dist/{dashboard-C2kTeeRI.mjs.map → dashboard-BNSvAN8A.mjs.map} +1 -1
  380. package/dist/db/index.d.mts +3 -3
  381. package/dist/db/index.mjs +2 -2
  382. package/dist/db/libsql-migrations.d.mts +1 -1
  383. package/dist/db/libsql-migrations.mjs +5 -5
  384. package/dist/db/libsql.d.mts +1 -1
  385. package/dist/db/postgres-migrations.d.mts +1 -1
  386. package/dist/db/postgres-migrations.mjs +5 -5
  387. package/dist/db/postgres.d.mts +1 -1
  388. package/dist/db/sqlite-migrations.d.mts +1 -1
  389. package/dist/db/sqlite-migrations.mjs +5 -5
  390. package/dist/db/sqlite.d.mts +1 -1
  391. package/dist/db/sqlite.mjs +1 -1
  392. package/dist/{default-Clra32mw.mjs → default-ByZ0JqZo.mjs} +1 -1
  393. package/dist/{default-Clra32mw.mjs.map → default-ByZ0JqZo.mjs.map} +1 -1
  394. package/dist/{deferred-tasks-CvDETTJO.d.mts → deferred-tasks-Cu4NSJpa.d.mts} +1 -1
  395. package/dist/{deferred-tasks-CvDETTJO.d.mts.map → deferred-tasks-Cu4NSJpa.d.mts.map} +1 -1
  396. package/dist/{dev-typegen-DzOPfsNj.mjs → dev-typegen-DHT7lcMU.mjs} +1 -1
  397. package/dist/{dev-typegen-DzOPfsNj.mjs.map → dev-typegen-DHT7lcMU.mjs.map} +1 -1
  398. package/dist/{device-flow-D2oCWvLJ.mjs → device-flow-Cf6bhCCT.mjs} +4 -4
  399. package/dist/{device-flow-D2oCWvLJ.mjs.map → device-flow-Cf6bhCCT.mjs.map} +1 -1
  400. package/dist/{dialect-helpers-BSbfaO3F.mjs → dialect-helpers-BcQvkHgn.mjs} +83 -2
  401. package/dist/dialect-helpers-BcQvkHgn.mjs.map +1 -0
  402. package/dist/{direct-executor-Bfa5_ToE.mjs → direct-executor-yAyUGSqB.mjs} +3 -3
  403. package/dist/{direct-executor-Bfa5_ToE.mjs.map → direct-executor-yAyUGSqB.mjs.map} +1 -1
  404. package/dist/{dist-89xCrGqi.mjs → dist-BAsh8dbf.mjs} +1 -1
  405. package/dist/{dist-89xCrGqi.mjs.map → dist-BAsh8dbf.mjs.map} +1 -1
  406. package/dist/{email-console-Dzb6uGYa.mjs → email-console-DNup1Fku.mjs} +1 -1
  407. package/dist/{email-console-Dzb6uGYa.mjs.map → email-console-DNup1Fku.mjs.map} +1 -1
  408. package/dist/{enrich-BX0IDp4z.mjs → enrich-t2Xvjdqa.mjs} +3 -3
  409. package/dist/{enrich-BX0IDp4z.mjs.map → enrich-t2Xvjdqa.mjs.map} +1 -1
  410. package/dist/entry-lock-BEr8gDkG.mjs +163 -0
  411. package/dist/entry-lock-BEr8gDkG.mjs.map +1 -0
  412. package/dist/{relations-DnRK4YIT.d.mts → entry-lock-CGAtrwAR.d.mts} +92 -37
  413. package/dist/entry-lock-CGAtrwAR.d.mts.map +1 -0
  414. package/dist/{redirects-BLNOWQTn.mjs → entry-lock-DIYHAaSw.mjs} +57 -14
  415. package/dist/entry-lock-DIYHAaSw.mjs.map +1 -0
  416. package/dist/entry-locks-BEcX7ET0.mjs +167 -0
  417. package/dist/entry-locks-BEcX7ET0.mjs.map +1 -0
  418. package/dist/{error-DFrQjppn.mjs → error-BDcFyoRt.mjs} +2 -2
  419. package/dist/{error-DFrQjppn.mjs.map → error-BDcFyoRt.mjs.map} +1 -1
  420. package/dist/{errors-DsVoDUjJ.mjs → errors-DvMdNrgf.mjs} +8 -1
  421. package/dist/errors-DvMdNrgf.mjs.map +1 -0
  422. package/dist/{escape-HmHTC1Is.mjs → escape-B3asJC6W.mjs} +1 -1
  423. package/dist/{escape-HmHTC1Is.mjs.map → escape-B3asJC6W.mjs.map} +1 -1
  424. package/dist/{field-defs-cache-BM4SIRqH.mjs → field-defs-cache-Cf5FHK0M.mjs} +5 -5
  425. package/dist/{field-defs-cache-BM4SIRqH.mjs.map → field-defs-cache-Cf5FHK0M.mjs.map} +1 -1
  426. package/dist/{fts-manager-Do1BlW2r.mjs → fts-manager-iddym8cd.mjs} +4 -4
  427. package/dist/{fts-manager-Do1BlW2r.mjs.map → fts-manager-iddym8cd.mjs.map} +1 -1
  428. package/dist/{hash-3JJPlHF2.mjs → hash-BRweX6jz.mjs} +1 -1
  429. package/dist/{hash-3JJPlHF2.mjs.map → hash-BRweX6jz.mjs.map} +1 -1
  430. package/dist/{hook-result-DCh2WUpe.d.mts → hook-result-BrshYHLx.d.mts} +1 -1
  431. package/dist/{hook-result-DCh2WUpe.d.mts.map → hook-result-BrshYHLx.d.mts.map} +1 -1
  432. package/dist/{hreflang-B6hbAuuO.d.mts → hreflang-CQpu5bMy.d.mts} +2 -2
  433. package/dist/{hreflang-B6hbAuuO.d.mts.map → hreflang-CQpu5bMy.d.mts.map} +1 -1
  434. package/dist/{hreflang-DQbPZliA.mjs → hreflang-DshnweTC.mjs} +9 -8
  435. package/dist/{hreflang-DQbPZliA.mjs.map → hreflang-DshnweTC.mjs.map} +1 -1
  436. package/dist/{identity-DksvEazf.mjs → identity-CjGKDq8J.mjs} +3 -3
  437. package/dist/{identity-DksvEazf.mjs.map → identity-CjGKDq8J.mjs.map} +1 -1
  438. package/dist/{import-CJpaBBBT.mjs → import-D96g2otw.mjs} +5 -5
  439. package/dist/{import-CJpaBBBT.mjs.map → import-D96g2otw.mjs.map} +1 -1
  440. package/dist/{index-Du8K7bWa.d.mts → index-1ECYpfiF.d.mts} +3 -3
  441. package/dist/{index-Du8K7bWa.d.mts.map → index-1ECYpfiF.d.mts.map} +1 -1
  442. package/dist/index.d.mts +22 -22
  443. package/dist/index.mjs +81 -78
  444. package/dist/{init-lock-DJkX6Hto.mjs → init-lock-CFNBe_iH.mjs} +1 -1
  445. package/dist/{init-lock-DJkX6Hto.mjs.map → init-lock-CFNBe_iH.mjs.map} +1 -1
  446. package/dist/{load-CawHjTOH.mjs → load-DPtY9cZo.mjs} +2 -2
  447. package/dist/{load-CawHjTOH.mjs.map → load-DPtY9cZo.mjs.map} +1 -1
  448. package/dist/{loader-Z8vl7zTq.mjs → loader-WJi6GFRn.mjs} +46 -8
  449. package/dist/loader-WJi6GFRn.mjs.map +1 -0
  450. package/dist/{manifest-builder-COtzuca2.mjs → manifest-builder-BfNlGQIA.mjs} +2 -2
  451. package/dist/{manifest-builder-COtzuca2.mjs.map → manifest-builder-BfNlGQIA.mjs.map} +1 -1
  452. package/dist/{manifest-schema-BNWwR8Vd.mjs → manifest-schema-CILooI5J.mjs} +1 -1
  453. package/dist/{manifest-schema-BNWwR8Vd.mjs.map → manifest-schema-CILooI5J.mjs.map} +1 -1
  454. package/dist/media/image-endpoint.mjs +1 -1
  455. package/dist/media/index.d.mts +1 -1
  456. package/dist/media/index.mjs +3 -3
  457. package/dist/media/local-runtime.d.mts +12 -12
  458. package/dist/media/local-runtime.mjs +5 -5
  459. package/dist/{media-BHjus86Y.mjs → media-C1EIZKh1.mjs} +1 -1
  460. package/dist/{media-BHjus86Y.mjs.map → media-C1EIZKh1.mjs.map} +1 -1
  461. package/dist/{media-allowlist-CoTBWoDp.mjs → media-allowlist-elXJgb_K.mjs} +2 -2
  462. package/dist/{media-allowlist-CoTBWoDp.mjs.map → media-allowlist-elXJgb_K.mjs.map} +1 -1
  463. package/dist/{media-folders-BGkATs8n.mjs → media-folders-DASfX_DH.mjs} +1 -1
  464. package/dist/{media-folders-BGkATs8n.mjs.map → media-folders-DASfX_DH.mjs.map} +1 -1
  465. package/dist/{media-upload-BCidR-EY.mjs → media-upload-C7_AQJ5v.mjs} +8 -8
  466. package/dist/{media-upload-BCidR-EY.mjs.map → media-upload-C7_AQJ5v.mjs.map} +1 -1
  467. package/dist/{media-url-DHoPr0hq.mjs → media-url-8dVl1loq.mjs} +19 -2
  468. package/dist/media-url-8dVl1loq.mjs.map +1 -0
  469. package/dist/{media-usage-CdY5jhSR.mjs → media-usage-C1EswMTq.mjs} +9 -9
  470. package/dist/{media-usage-CdY5jhSR.mjs.map → media-usage-C1EswMTq.mjs.map} +1 -1
  471. package/dist/{media-usage-activation-BgeMtK5C.mjs → media-usage-activation-CrHNltlL.mjs} +3 -3
  472. package/dist/{media-usage-activation-BgeMtK5C.mjs.map → media-usage-activation-CrHNltlL.mjs.map} +1 -1
  473. package/dist/{media-usage-work-D6D9sMCA.mjs → media-usage-work-C5B1zT1c.mjs} +2 -2
  474. package/dist/{media-usage-work-D6D9sMCA.mjs.map → media-usage-work-C5B1zT1c.mjs.map} +1 -1
  475. package/dist/{media-usage-work-CnGCdHxx.mjs → media-usage-work-IkQx_Yz6.mjs} +4 -4
  476. package/dist/{media-usage-work-CnGCdHxx.mjs.map → media-usage-work-IkQx_Yz6.mjs.map} +1 -1
  477. package/dist/{media-usage-write-fence-hjeD4u7s.mjs → media-usage-write-fence-B9anjOSg.mjs} +3 -3
  478. package/dist/{media-usage-write-fence-hjeD4u7s.mjs.map → media-usage-write-fence-B9anjOSg.mjs.map} +1 -1
  479. package/dist/{menus-6qSwTNxG.mjs → menus-D8mC4eaN.mjs} +115 -136
  480. package/dist/menus-D8mC4eaN.mjs.map +1 -0
  481. package/dist/{menus-uvPLXMZf.mjs → menus-UdwjHZJC.mjs} +11 -3
  482. package/dist/{menus-uvPLXMZf.mjs.map → menus-UdwjHZJC.mjs.map} +1 -1
  483. package/dist/migrations/index.d.mts +1 -1
  484. package/dist/migrations/index.mjs +4 -4
  485. package/dist/{mime-CUIG6x84.mjs → mime-DYpsOAny.mjs} +1 -1
  486. package/dist/{mime-CUIG6x84.mjs.map → mime-DYpsOAny.mjs.map} +1 -1
  487. package/dist/{mode-DN_WneRx.mjs → mode-Dm4BHhRH.mjs} +1 -1
  488. package/dist/{mode-DN_WneRx.mjs.map → mode-Dm4BHhRH.mjs.map} +1 -1
  489. package/dist/{node-sqlite-compat-BuJXIeMz.mjs → node-sqlite-compat-2sezm-Zd.mjs} +1 -1
  490. package/dist/{node-sqlite-compat-BuJXIeMz.mjs.map → node-sqlite-compat-2sezm-Zd.mjs.map} +1 -1
  491. package/dist/{normalize-C2xNjTSG.mjs → normalize-4nkKGsuW.mjs} +1 -1
  492. package/dist/{normalize-C2xNjTSG.mjs.map → normalize-4nkKGsuW.mjs.map} +1 -1
  493. package/dist/{oauth-authorization-Dj6Kwc21.mjs → oauth-authorization-BxE_lURD.mjs} +4 -4
  494. package/dist/{oauth-authorization-Dj6Kwc21.mjs.map → oauth-authorization-BxE_lURD.mjs.map} +1 -1
  495. package/dist/{oauth-clients-FD7I0J8m.mjs → oauth-clients-DJIdOdq0.mjs} +1 -1
  496. package/dist/{oauth-clients-FD7I0J8m.mjs.map → oauth-clients-DJIdOdq0.mjs.map} +1 -1
  497. package/dist/{oauth-state-store-DkmDOmHs.mjs → oauth-state-store-CsdxP57n.mjs} +1 -1
  498. package/dist/{oauth-state-store-DkmDOmHs.mjs.map → oauth-state-store-CsdxP57n.mjs.map} +1 -1
  499. package/dist/{oauth-user-lookup-CvIwGpYd.mjs → oauth-user-lookup-HzzW-dkF.mjs} +1 -1
  500. package/dist/{oauth-user-lookup-CvIwGpYd.mjs.map → oauth-user-lookup-HzzW-dkF.mjs.map} +1 -1
  501. package/dist/object-cache/memory.d.mts +1 -1
  502. package/dist/{options-BHPeIbBd.mjs → options-D1FBiAv1.mjs} +60 -5
  503. package/dist/options-D1FBiAv1.mjs.map +1 -0
  504. package/dist/{options-CYb4y7hM.d.mts → options-D8Y0VHc7.d.mts} +9 -3
  505. package/dist/options-D8Y0VHc7.d.mts.map +1 -0
  506. package/dist/page/index.d.mts +2 -2
  507. package/dist/page/index.d.mts.map +1 -1
  508. package/dist/page/index.mjs +12 -0
  509. package/dist/page/index.mjs.map +1 -1
  510. package/dist/{parse-Ckpg-Qfp.mjs → parse-WRg5C3NX.mjs} +2 -2
  511. package/dist/{parse-Ckpg-Qfp.mjs.map → parse-WRg5C3NX.mjs.map} +1 -1
  512. package/dist/{passkey-config-O_lj3y0k.mjs → passkey-config-qIdO-wF6.mjs} +1 -1
  513. package/dist/{passkey-config-O_lj3y0k.mjs.map → passkey-config-qIdO-wF6.mjs.map} +1 -1
  514. package/dist/{patterns-D9iDO3j8.mjs → patterns-DC8CLptu.mjs} +1 -1
  515. package/dist/{patterns-D9iDO3j8.mjs.map → patterns-DC8CLptu.mjs.map} +1 -1
  516. package/dist/{placeholder-4X9BrRrp.d.mts → placeholder-COrvARyD.d.mts} +1 -1
  517. package/dist/{placeholder-4X9BrRrp.d.mts.map → placeholder-COrvARyD.d.mts.map} +1 -1
  518. package/dist/plugin-types.d.mts +3 -3
  519. package/dist/plugin-types.d.mts.map +1 -1
  520. package/dist/plugin-utils.d.mts +10 -10
  521. package/dist/plugins/adapt-sandbox-entry.d.mts +10 -10
  522. package/dist/plugins/adapt-sandbox-entry.mjs +2 -2
  523. package/dist/{policy-Dhtwntrt.mjs → policy-XCfb-IE9.mjs} +2 -2
  524. package/dist/{policy-Dhtwntrt.mjs.map → policy-XCfb-IE9.mjs.map} +1 -1
  525. package/dist/{portable-text-U85hOafW.mjs → portable-text-BS3d5n-0.mjs} +1 -1
  526. package/dist/{portable-text-U85hOafW.mjs.map → portable-text-BS3d5n-0.mjs.map} +1 -1
  527. package/dist/{preview-B_vJLvf8.mjs → preview-BxwsGgGp.mjs} +2 -2
  528. package/dist/{preview-B_vJLvf8.mjs.map → preview-BxwsGgGp.mjs.map} +1 -1
  529. package/dist/{protocol-JdD2YhY9.d.mts → protocol-CLn58-nw.d.mts} +2 -2
  530. package/dist/{protocol-JdD2YhY9.d.mts.map → protocol-CLn58-nw.d.mts.map} +1 -1
  531. package/dist/{public-url-CarhZJgf.mjs → public-url-FWWAvnre.mjs} +1 -1
  532. package/dist/{public-url-CarhZJgf.mjs.map → public-url-FWWAvnre.mjs.map} +1 -1
  533. package/dist/{query-BZKZcG5b.mjs → query-DygOte9M.mjs} +25 -16
  534. package/dist/query-DygOte9M.mjs.map +1 -0
  535. package/dist/{query-BndaFxxp.mjs → query-gtXT03Wc.mjs} +4 -4
  536. package/dist/{query-BndaFxxp.mjs.map → query-gtXT03Wc.mjs.map} +1 -1
  537. package/dist/{rate-limit-BZmATC6W.mjs → rate-limit-CQUPm0dh.mjs} +2 -2
  538. package/dist/{rate-limit-BZmATC6W.mjs.map → rate-limit-CQUPm0dh.mjs.map} +1 -1
  539. package/dist/{redirect-CzqnLxK-.mjs → redirect-D1cWafi6.mjs} +1 -1
  540. package/dist/{redirect-CzqnLxK-.mjs.map → redirect-D1cWafi6.mjs.map} +1 -1
  541. package/dist/{redirect-CZkbozu9.mjs → redirect-DId44BS1.mjs} +19 -6
  542. package/dist/redirect-DId44BS1.mjs.map +1 -0
  543. package/dist/{redirects-CqzNM0KM.mjs → redirects-DN-ZE33W.mjs} +5 -5
  544. package/dist/{redirects-CqzNM0KM.mjs.map → redirects-DN-ZE33W.mjs.map} +1 -1
  545. package/dist/{registry-AZAsRsor.mjs → registry-DTqaqxed.mjs} +26 -10
  546. package/dist/registry-DTqaqxed.mjs.map +1 -0
  547. package/dist/{relation-04DfKRTO.mjs → relation-DxgCHOBw.mjs} +2 -2
  548. package/dist/{relation-04DfKRTO.mjs.map → relation-DxgCHOBw.mjs.map} +1 -1
  549. package/dist/{relations-CcFwDJdJ.mjs → relations-KKDSLUwS.mjs} +4 -4
  550. package/dist/{relations-CcFwDJdJ.mjs.map → relations-KKDSLUwS.mjs.map} +1 -1
  551. package/dist/{relations-C4htk5sb.mjs → relations-rOmbndUJ.mjs} +3 -3
  552. package/dist/{relations-C4htk5sb.mjs.map → relations-rOmbndUJ.mjs.map} +1 -1
  553. package/dist/{request-cache-DH9zdCOD.mjs → request-cache-DAZZmesc.mjs} +1 -1
  554. package/dist/{request-cache-DH9zdCOD.mjs.map → request-cache-DAZZmesc.mjs.map} +1 -1
  555. package/dist/request-context.d.mts +1 -1
  556. package/dist/{request-meta-DYxLlnmz.mjs → request-meta-BgjUQLQ-.mjs} +2 -2
  557. package/dist/{request-meta-DYxLlnmz.mjs.map → request-meta-BgjUQLQ-.mjs.map} +1 -1
  558. package/dist/{resolve-prZ3mP7l.mjs → resolve-Cy0aWSRj.mjs} +37 -4
  559. package/dist/resolve-Cy0aWSRj.mjs.map +1 -0
  560. package/dist/{runner-YKfIMnaF.d.mts → runner-CfwysRM0.d.mts} +2 -2
  561. package/dist/{runner-YKfIMnaF.d.mts.map → runner-CfwysRM0.d.mts.map} +1 -1
  562. package/dist/{runner-BLIDKpmA.mjs → runner-nEzvnogG.mjs} +419 -295
  563. package/dist/runner-nEzvnogG.mjs.map +1 -0
  564. package/dist/runtime.d.mts +11 -11
  565. package/dist/runtime.mjs +3 -2
  566. package/dist/runtime.mjs.map +1 -1
  567. package/dist/{schema-CGnBeLiW.mjs → schema-CRu38Pr5.mjs} +3 -3
  568. package/dist/{schema-CGnBeLiW.mjs.map → schema-CRu38Pr5.mjs.map} +1 -1
  569. package/dist/{schema-DYr-Vd-L.mjs → schema-DifxndJx.mjs} +4 -4
  570. package/dist/{schema-DYr-Vd-L.mjs.map → schema-DifxndJx.mjs.map} +1 -1
  571. package/dist/{scopes-BhWvBavj.mjs → scopes-D5A1OZbq.mjs} +3 -3
  572. package/dist/{scopes-BhWvBavj.mjs.map → scopes-D5A1OZbq.mjs.map} +1 -1
  573. package/dist/{search-C-qDk4kx.mjs → search-DEPFSBFq.mjs} +4 -4
  574. package/dist/{search-C-qDk4kx.mjs.map → search-DEPFSBFq.mjs.map} +1 -1
  575. package/dist/{secrets-rEtHt-6z.mjs → secrets-CdfzLdoO.mjs} +3 -3
  576. package/dist/{secrets-rEtHt-6z.mjs.map → secrets-CdfzLdoO.mjs.map} +1 -1
  577. package/dist/{sections-B_nYvlwn.mjs → sections-3X52kmIR.mjs} +2 -2
  578. package/dist/{sections-B_nYvlwn.mjs.map → sections-3X52kmIR.mjs.map} +1 -1
  579. package/dist/seed/index.d.mts +2 -2
  580. package/dist/seed/index.mjs +26 -24
  581. package/dist/seo/index.d.mts +3 -3
  582. package/dist/seo/index.d.mts.map +1 -1
  583. package/dist/seo/index.mjs +18 -19
  584. package/dist/seo/index.mjs.map +1 -1
  585. package/dist/{seo-926NRIgt.mjs → seo-Bw68KxRc.mjs} +2 -2
  586. package/dist/{seo-926NRIgt.mjs.map → seo-Bw68KxRc.mjs.map} +1 -1
  587. package/dist/{seo-CVWkdv6x.mjs → seo-C4AmbsMU.mjs} +3 -2
  588. package/dist/seo-C4AmbsMU.mjs.map +1 -0
  589. package/dist/{service-CJl3ZAYs.mjs → service-J_-Vgo7R.mjs} +2 -2
  590. package/dist/{service-CJl3ZAYs.mjs.map → service-J_-Vgo7R.mjs.map} +1 -1
  591. package/dist/{session-user-BlMgqCHS.mjs → session-user-CbnMMwk6.mjs} +1 -1
  592. package/dist/{session-user-BlMgqCHS.mjs.map → session-user-CbnMMwk6.mjs.map} +1 -1
  593. package/dist/{settings-Cwm6o2jY.mjs → settings-AnEFYICn.mjs} +3 -3
  594. package/dist/{settings-Cwm6o2jY.mjs.map → settings-AnEFYICn.mjs.map} +1 -1
  595. package/dist/{settings--wobrkkC.mjs → settings-DcMjREe5.mjs} +6 -6
  596. package/dist/{settings--wobrkkC.mjs.map → settings-DcMjREe5.mjs.map} +1 -1
  597. package/dist/{setup-complete-DQbClIN2.mjs → setup-complete-BClXXTvr.mjs} +2 -2
  598. package/dist/{setup-complete-DQbClIN2.mjs.map → setup-complete-BClXXTvr.mjs.map} +1 -1
  599. package/dist/{setup-nonce-DZCFS2sn.mjs → setup-nonce-BheRa4RG.mjs} +1 -1
  600. package/dist/{setup-nonce-DZCFS2sn.mjs.map → setup-nonce-BheRa4RG.mjs.map} +1 -1
  601. package/dist/{single-flight-cache-BPuGPdcN.mjs → single-flight-cache-jaswDzmQ.mjs} +2 -2
  602. package/dist/{single-flight-cache-BPuGPdcN.mjs.map → single-flight-cache-jaswDzmQ.mjs.map} +1 -1
  603. package/dist/{site-url-BrxA_E9H.mjs → site-url-Bqf-ea3N.mjs} +3 -3
  604. package/dist/{site-url-BrxA_E9H.mjs.map → site-url-Bqf-ea3N.mjs.map} +1 -1
  605. package/dist/{snapshot--OCDTqdb.mjs → snapshot-C4CtXntb.mjs} +51 -35
  606. package/dist/snapshot-C4CtXntb.mjs.map +1 -0
  607. package/dist/{ssrf-5sIM5jzl.mjs → ssrf-gl4gFNhw.mjs} +148 -91
  608. package/dist/ssrf-gl4gFNhw.mjs.map +1 -0
  609. package/dist/{state-BpFVsJZB.mjs → state-1F6IOhdQ.mjs} +1 -1
  610. package/dist/{state-BpFVsJZB.mjs.map → state-1F6IOhdQ.mjs.map} +1 -1
  611. package/dist/{status-B777-dXz.mjs → status-Cenfk_r5.mjs} +1 -1
  612. package/dist/{status-B777-dXz.mjs.map → status-Cenfk_r5.mjs.map} +1 -1
  613. package/dist/storage/local.d.mts +1 -1
  614. package/dist/storage/local.mjs +1 -1
  615. package/dist/storage/s3.d.mts +1 -1
  616. package/dist/storage/s3.mjs +1 -1
  617. package/dist/{target-BmR0iTwz.mjs → target-CRzeTs8G.mjs} +1 -1
  618. package/dist/{target-BmR0iTwz.mjs.map → target-CRzeTs8G.mjs.map} +1 -1
  619. package/dist/{taxonomies-DkAkMupr.mjs → taxonomies-BOdxuZpV.mjs} +11 -4
  620. package/dist/taxonomies-BOdxuZpV.mjs.map +1 -0
  621. package/dist/{taxonomies-Wfy_Lg12.mjs → taxonomies-NcFDq5Gg.mjs} +23 -14
  622. package/dist/taxonomies-NcFDq5Gg.mjs.map +1 -0
  623. package/dist/{taxonomy-tJepplLL.mjs → taxonomy-DP1vny4K.mjs} +11 -3
  624. package/dist/{taxonomy-tJepplLL.mjs.map → taxonomy-DP1vny4K.mjs.map} +1 -1
  625. package/dist/{tokens-BCO1oruF.mjs → tokens-CDk8ox9p.mjs} +1 -1
  626. package/dist/{tokens-BCO1oruF.mjs.map → tokens-CDk8ox9p.mjs.map} +1 -1
  627. package/dist/{transport-xh6YKW2G.d.mts → transport-BVn4tVb9.d.mts} +1 -1
  628. package/dist/{transport-xh6YKW2G.d.mts.map → transport-BVn4tVb9.d.mts.map} +1 -1
  629. package/dist/{transport-Dr3qtwXC.mjs → transport-DP0JI-8i.mjs} +1 -1
  630. package/dist/{transport-Dr3qtwXC.mjs.map → transport-DP0JI-8i.mjs.map} +1 -1
  631. package/dist/{trusted-proxy-BR5F1Otp.mjs → trusted-proxy-BTM6UxqD.mjs} +1 -1
  632. package/dist/{trusted-proxy-BR5F1Otp.mjs.map → trusted-proxy-BTM6UxqD.mjs.map} +1 -1
  633. package/dist/{types-CXFkwEGC.d.mts → types-2n848aVW.d.mts} +1 -1
  634. package/dist/{types-CXFkwEGC.d.mts.map → types-2n848aVW.d.mts.map} +1 -1
  635. package/dist/{types-75KIqzL9.mjs → types-BMXnRIrX.mjs} +4 -2
  636. package/dist/types-BMXnRIrX.mjs.map +1 -0
  637. package/dist/{types-B6GrPic4.d.mts → types-BouXpOsa.d.mts} +115 -4
  638. package/dist/types-BouXpOsa.d.mts.map +1 -0
  639. package/dist/{types-3qNFPlci.mjs → types-ByG2coLw.mjs} +1 -1
  640. package/dist/{types-3qNFPlci.mjs.map → types-ByG2coLw.mjs.map} +1 -1
  641. package/dist/types-CQPWhPxE.mjs.map +1 -1
  642. package/dist/{types-CDtkNSFQ.d.mts → types-DEfNJ__A.d.mts} +1 -1
  643. package/dist/{types-CDtkNSFQ.d.mts.map → types-DEfNJ__A.d.mts.map} +1 -1
  644. package/dist/{types-xDMtUFnO.d.mts → types-DKcKSbtB.d.mts} +23 -7
  645. package/dist/types-DKcKSbtB.d.mts.map +1 -0
  646. package/dist/{types-C00oyCZp.d.mts → types-DRYs7uTL.d.mts} +1 -1
  647. package/dist/{types-C00oyCZp.d.mts.map → types-DRYs7uTL.d.mts.map} +1 -1
  648. package/dist/{types-DczELMop.d.mts → types-DaEg7KX2.d.mts} +1 -1
  649. package/dist/{types-DczELMop.d.mts.map → types-DaEg7KX2.d.mts.map} +1 -1
  650. package/dist/{types-BuHW4xDE.d.mts → types-LU8utpP_.d.mts} +6 -3
  651. package/dist/types-LU8utpP_.d.mts.map +1 -0
  652. package/dist/{types-CPeXo1wF.d.mts → types-VpYfPUxN.d.mts} +1 -1
  653. package/dist/{types-CPeXo1wF.d.mts.map → types-VpYfPUxN.d.mts.map} +1 -1
  654. package/dist/{types-DM3vioBY.mjs → types-c9GP7Dj5.mjs} +1 -1
  655. package/dist/{types-DM3vioBY.mjs.map → types-c9GP7Dj5.mjs.map} +1 -1
  656. package/dist/{types-FV23hEoW.d.mts → types-tJWDK__M.d.mts} +14 -1
  657. package/dist/types-tJWDK__M.d.mts.map +1 -0
  658. package/dist/{upload-attempts-BsqoQ1fn.mjs → upload-attempts-C6S2y-lp.mjs} +1 -1
  659. package/dist/{upload-attempts-BsqoQ1fn.mjs.map → upload-attempts-C6S2y-lp.mjs.map} +1 -1
  660. package/dist/{url-pattern-D4c2czpJ.mjs → url-pattern-UYtxVTuj.mjs} +1 -1
  661. package/dist/{url-pattern-D4c2czpJ.mjs.map → url-pattern-UYtxVTuj.mjs.map} +1 -1
  662. package/dist/{user-BTZ40aq6.mjs → user-DIsIXogT.mjs} +2 -2
  663. package/dist/{user-BTZ40aq6.mjs.map → user-DIsIXogT.mjs.map} +1 -1
  664. package/dist/{utils-BKvNjjhY.mjs → utils-BicP5Qbg.mjs} +2 -2
  665. package/dist/{utils-BKvNjjhY.mjs.map → utils-BicP5Qbg.mjs.map} +1 -1
  666. package/dist/{validate-DE_LRwo9.mjs → validate-D8VPn4Hv.mjs} +8 -3
  667. package/dist/validate-D8VPn4Hv.mjs.map +1 -0
  668. package/dist/{validate-DUP27OYD.d.mts → validate-Df6Dvwbw.d.mts} +12 -7
  669. package/dist/validate-Df6Dvwbw.d.mts.map +1 -0
  670. package/dist/{validation-BMImFJ11.mjs → validation-CzMJn9Ku.mjs} +13 -11
  671. package/dist/{validation-BMImFJ11.mjs.map → validation-CzMJn9Ku.mjs.map} +1 -1
  672. package/dist/version-CK67_SXX.mjs +7 -0
  673. package/dist/{version-Bii3suaO.mjs.map → version-CK67_SXX.mjs.map} +1 -1
  674. package/dist/{widgets-D3gJ10xU.mjs → widgets-RFVAxQl3.mjs} +5 -5
  675. package/dist/{widgets-D3gJ10xU.mjs.map → widgets-RFVAxQl3.mjs.map} +1 -1
  676. package/dist/{wxr-taxonomies-B2Og_6rU.d.mts → wxr-taxonomies-BX4yQL9s.d.mts} +1 -1
  677. package/dist/{wxr-taxonomies-B2Og_6rU.d.mts.map → wxr-taxonomies-BX4yQL9s.d.mts.map} +1 -1
  678. package/dist/{wxr-taxonomies-Cxngsjwo.mjs → wxr-taxonomies-Csdp7yde.mjs} +4 -4
  679. package/dist/{wxr-taxonomies-Cxngsjwo.mjs.map → wxr-taxonomies-Csdp7yde.mjs.map} +1 -1
  680. package/dist/{zod-generator-BuYSQJB7.mjs → zod-generator-CNRGdnBY.mjs} +3 -3
  681. package/dist/{zod-generator-BuYSQJB7.mjs.map → zod-generator-CNRGdnBY.mjs.map} +1 -1
  682. package/package.json +12 -10
  683. package/src/api/errors.ts +7 -0
  684. package/src/api/handlers/content.ts +66 -79
  685. package/src/api/handlers/entry-lock.ts +206 -0
  686. package/src/api/handlers/manifest.ts +1 -0
  687. package/src/api/handlers/marketplace.ts +28 -20
  688. package/src/api/handlers/menus.ts +9 -0
  689. package/src/api/handlers/registry.ts +13 -8
  690. package/src/api/handlers/revision.ts +2 -1
  691. package/src/api/handlers/seo.ts +10 -1
  692. package/src/api/handlers/snapshot.ts +84 -72
  693. package/src/api/handlers/taxonomies.ts +9 -0
  694. package/src/api/openapi/document.ts +111 -6
  695. package/src/api/schemas/content.ts +8 -0
  696. package/src/api/schemas/entry-lock.ts +48 -0
  697. package/src/api/schemas/index.ts +1 -0
  698. package/src/api/schemas/schema.ts +10 -1
  699. package/src/api/types.ts +2 -0
  700. package/src/astro/integration/index.ts +9 -6
  701. package/src/astro/integration/routes.ts +5 -0
  702. package/src/astro/integration/runtime.ts +13 -5
  703. package/src/astro/integration/vite-config.ts +30 -0
  704. package/src/astro/middleware.ts +16 -0
  705. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +10 -0
  706. package/src/astro/routes/api/content/[collection]/[id]/lock.ts +133 -0
  707. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +11 -1
  708. package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +20 -0
  709. package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +10 -0
  710. package/src/astro/routes/api/content/[collection]/[id].ts +27 -2
  711. package/src/astro/routes/api/content/[collection]/index.ts +3 -0
  712. package/src/astro/routes/sitemap-[collection].xml.ts +4 -0
  713. package/src/astro/types.ts +13 -3
  714. package/src/cli/commands/content.ts +31 -5
  715. package/src/cli/commands/export-seed.ts +2 -0
  716. package/src/client/index.ts +34 -7
  717. package/src/components/EmDashBodyEnd.astro +4 -1
  718. package/src/components/EmDashBodyStart.astro +4 -1
  719. package/src/components/EmDashHead.astro +35 -16
  720. package/src/components/Gallery.astro +18 -4
  721. package/src/components/InlineEditor.astro +3 -1
  722. package/src/components/InlinePortableTextEditor.tsx +106 -11
  723. package/src/components/PortableText.astro +4 -0
  724. package/src/components/Table.astro +147 -62
  725. package/src/config/errors.ts +13 -0
  726. package/src/content/converters/portable-text-to-prosemirror.ts +26 -2
  727. package/src/content/converters/prosemirror-to-portable-text.ts +35 -6
  728. package/src/content/converters/types.ts +10 -0
  729. package/src/database/dialect-helpers.ts +125 -0
  730. package/src/database/migrations/075_entry_edit_locks.ts +44 -0
  731. package/src/database/migrations/076_collection_nav_group.ts +22 -0
  732. package/src/database/migrations/077_plugin_storage_revisions.ts +89 -0
  733. package/src/database/migrations/runner.ts +6 -0
  734. package/src/database/repositories/content.ts +170 -1
  735. package/src/database/repositories/entry-locks.ts +257 -0
  736. package/src/database/repositories/options.ts +69 -5
  737. package/src/database/repositories/plugin-storage.ts +159 -0
  738. package/src/database/repositories/redirect.ts +17 -6
  739. package/src/database/repositories/taxonomy.ts +8 -0
  740. package/src/database/repositories/types.ts +3 -0
  741. package/src/database/types.ts +15 -1
  742. package/src/emdash-runtime.ts +117 -50
  743. package/src/i18n/resolve.ts +44 -4
  744. package/src/index.ts +14 -0
  745. package/src/loader.ts +35 -4
  746. package/src/mcp/server.ts +23 -5
  747. package/src/media/responsive.ts +23 -0
  748. package/src/media/usage/content-refresh.ts +2 -1
  749. package/src/menus/index.ts +17 -21
  750. package/src/page/seo-contributions.ts +78 -1
  751. package/src/page/seo-panel.ts +47 -0
  752. package/src/plugin-types.ts +9 -0
  753. package/src/plugins/conditional-storage.ts +30 -0
  754. package/src/plugins/context.ts +49 -17
  755. package/src/plugins/hooks.ts +7 -1
  756. package/src/plugins/index.ts +9 -0
  757. package/src/plugins/manager.ts +5 -2
  758. package/src/plugins/sandbox/types.ts +16 -2
  759. package/src/plugins/storage-query.ts +45 -0
  760. package/src/plugins/storage-update.ts +96 -0
  761. package/src/plugins/types.ts +114 -0
  762. package/src/query.ts +29 -3
  763. package/src/registry/config.ts +130 -27
  764. package/src/registry/types.ts +5 -6
  765. package/src/schema/collection-slugs-cache.ts +157 -0
  766. package/src/schema/registry.ts +19 -0
  767. package/src/schema/types.ts +25 -6
  768. package/src/security/ssrf.ts +167 -141
  769. package/src/seed/apply.ts +4 -0
  770. package/src/seed/types.ts +7 -2
  771. package/src/seed/validate.ts +18 -1
  772. package/src/seo/hreflang.ts +1 -0
  773. package/src/seo/index.ts +5 -10
  774. package/src/seo/media-url.ts +26 -0
  775. package/src/taxonomies/term-counts.ts +22 -5
  776. package/dist/api-Dz6rgoa3.mjs.map +0 -1
  777. package/dist/apply-B4SIOxR1.mjs.map +0 -1
  778. package/dist/config-it29yDLA.mjs.map +0 -1
  779. package/dist/content-DjvM0T92.mjs.map +0 -1
  780. package/dist/context-CX6gxOLW.mjs.map +0 -1
  781. package/dist/dialect-helpers-BSbfaO3F.mjs.map +0 -1
  782. package/dist/errors-DsVoDUjJ.mjs.map +0 -1
  783. package/dist/index-BJNMCWmu.d.mts.map +0 -1
  784. package/dist/loader-Z8vl7zTq.mjs.map +0 -1
  785. package/dist/media-url-DHoPr0hq.mjs.map +0 -1
  786. package/dist/menus-6qSwTNxG.mjs.map +0 -1
  787. package/dist/options-BHPeIbBd.mjs.map +0 -1
  788. package/dist/options-CYb4y7hM.d.mts.map +0 -1
  789. package/dist/query-BZKZcG5b.mjs.map +0 -1
  790. package/dist/redirect-CZkbozu9.mjs.map +0 -1
  791. package/dist/redirects-BLNOWQTn.mjs.map +0 -1
  792. package/dist/registry-AZAsRsor.mjs.map +0 -1
  793. package/dist/relations-DnRK4YIT.d.mts.map +0 -1
  794. package/dist/resolve-prZ3mP7l.mjs.map +0 -1
  795. package/dist/runner-BLIDKpmA.mjs.map +0 -1
  796. package/dist/seo-CVWkdv6x.mjs.map +0 -1
  797. package/dist/snapshot--OCDTqdb.mjs.map +0 -1
  798. package/dist/ssrf-5sIM5jzl.mjs.map +0 -1
  799. package/dist/taxonomies-DkAkMupr.mjs.map +0 -1
  800. package/dist/taxonomies-Wfy_Lg12.mjs.map +0 -1
  801. package/dist/types-75KIqzL9.mjs.map +0 -1
  802. package/dist/types-B6GrPic4.d.mts.map +0 -1
  803. package/dist/types-BuHW4xDE.d.mts.map +0 -1
  804. package/dist/types-FV23hEoW.d.mts.map +0 -1
  805. package/dist/types-xDMtUFnO.d.mts.map +0 -1
  806. package/dist/validate-DE_LRwo9.mjs.map +0 -1
  807. package/dist/validate-DUP27OYD.d.mts.map +0 -1
  808. package/dist/version-Bii3suaO.mjs +0 -7
  809. /package/dist/{api-tokens-BfYts-sq.mjs → api-tokens-B_lfpmH3.mjs} +0 -0
  810. /package/dist/{ssrf-Dg3cIT-b.mjs → ssrf-TQhaljuI.mjs} +0 -0
  811. /package/dist/{types-DfuTR6dL.mjs → types-A2cN6a4a.mjs} +0 -0
@@ -1,7 +1,7 @@
1
- import { r as requestCached } from "./request-cache-DH9zdCOD.mjs";
2
- import { i as widgetAreaTag } from "./chrome-tags-D8fiZG94.mjs";
3
- import { s as getDb } from "./loader-Z8vl7zTq.mjs";
4
- import { t as getWidgetComponents$1 } from "./components-DJbo1z0S.mjs";
1
+ import { r as requestCached } from "./request-cache-DAZZmesc.mjs";
2
+ import { i as widgetAreaTag } from "./chrome-tags-DzDQBCjX.mjs";
3
+ import { s as getDb } from "./loader-WJi6GFRn.mjs";
4
+ import { t as getWidgetComponents$1 } from "./components-CL6Wkdk-.mjs";
5
5
 
6
6
  //#region src/widgets/index.ts
7
7
  /**
@@ -119,4 +119,4 @@ function rowToWidget(row) {
119
119
 
120
120
  //#endregion
121
121
  export { rowToWidget as a, getWidgetComponents as i, getWidgetAreaWithCacheHint as n, getWidgetAreas as r, getWidgetArea as t };
122
- //# sourceMappingURL=widgets-D3gJ10xU.mjs.map
122
+ //# sourceMappingURL=widgets-RFVAxQl3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"widgets-D3gJ10xU.mjs","names":["getComponentRegistry"],"sources":["../src/widgets/index.ts"],"sourcesContent":["import { widgetAreaTag } from \"../cache/chrome-tags.js\";\nimport { getDb } from \"../loader.js\";\nimport type { CacheHint } from \"../query.js\";\nimport { requestCached } from \"../request-cache.js\";\nimport { getWidgetComponents as getComponentRegistry } from \"./components.js\";\nimport type { Widget, WidgetArea, WidgetRow, WidgetComponentDef } from \"./types.js\";\n\nexport type {\n\tWidget,\n\tWidgetArea,\n\tWidgetType,\n\tWidgetComponentDef,\n\tPropDef,\n\tCreateWidgetAreaInput,\n\tCreateWidgetInput,\n\tUpdateWidgetInput,\n\tReorderWidgetsInput,\n} from \"./types.js\";\n\n/**\n * Get a widget area by name, with all its widgets.\n *\n * Single query with a left join rather than area-then-widgets so the\n * common case costs one round-trip. An area with no widgets yields one\n * row with null widget columns, which we skip when mapping.\n */\nexport async function getWidgetArea(name: string): Promise<WidgetArea | null> {\n\treturn requestCached(`widget-area:${name}`, async () => {\n\t\tconst db = await getDb();\n\t\tconst rows = await db\n\t\t\t.selectFrom(\"_emdash_widget_areas as a\")\n\t\t\t.leftJoin(\"_emdash_widgets as w\", \"w.area_id\", \"a.id\")\n\t\t\t.select([\n\t\t\t\t\"a.id as a_id\",\n\t\t\t\t\"a.name as a_name\",\n\t\t\t\t\"a.label as a_label\",\n\t\t\t\t\"a.description as a_description\",\n\t\t\t\t\"w.id as w_id\",\n\t\t\t\t\"w.type as w_type\",\n\t\t\t\t\"w.title as w_title\",\n\t\t\t\t\"w.content as w_content\",\n\t\t\t\t\"w.menu_name as w_menu_name\",\n\t\t\t\t\"w.component_id as w_component_id\",\n\t\t\t\t\"w.component_props as w_component_props\",\n\t\t\t\t\"w.area_id as w_area_id\",\n\t\t\t\t\"w.sort_order as w_sort_order\",\n\t\t\t\t\"w.created_at as w_created_at\",\n\t\t\t])\n\t\t\t.where(\"a.name\", \"=\", name)\n\t\t\t.orderBy(\"w.sort_order\", \"asc\")\n\t\t\t.execute();\n\n\t\tconst first = rows[0];\n\t\tif (!first) return null;\n\t\tconst widgets: Widget[] = [];\n\t\tfor (const row of rows) {\n\t\t\tif (row.w_id === null) continue; // area has no widgets (left-join null row)\n\t\t\t// Left-join makes every w_* column nullable in the type; at runtime\n\t\t\t// they're all non-null once w_id is (we match on widgets.area_id, so\n\t\t\t// a widget row always has the not-null columns filled). Cast is the\n\t\t\t// price of that structural fact.\n\t\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- left-join row is non-null when w_id is set; see above\n\t\t\tconst widgetRow = {\n\t\t\t\tid: row.w_id,\n\t\t\t\ttype: row.w_type,\n\t\t\t\ttitle: row.w_title,\n\t\t\t\tcontent: row.w_content,\n\t\t\t\tmenu_name: row.w_menu_name,\n\t\t\t\tcomponent_id: row.w_component_id,\n\t\t\t\tcomponent_props: row.w_component_props,\n\t\t\t\tarea_id: row.w_area_id,\n\t\t\t\tsort_order: row.w_sort_order,\n\t\t\t\tcreated_at: row.w_created_at,\n\t\t\t} as WidgetRow;\n\t\t\twidgets.push(rowToWidget(widgetRow));\n\t\t}\n\n\t\treturn {\n\t\t\tid: first.a_id,\n\t\t\tname: first.a_name,\n\t\t\tlabel: first.a_label,\n\t\t\tdescription: first.a_description ?? undefined,\n\t\t\twidgets,\n\t\t};\n\t});\n}\n\n/**\n * Get a widget area by name with a Workers edge-cache hint.\n *\n * Use the returned `cacheHint` with `Astro.cache.set()` so pages that render\n * this widget area can be purged automatically when its widgets change.\n */\nexport async function getWidgetAreaWithCacheHint(name: string): Promise<{\n\tdata: WidgetArea | null;\n\tcacheHint: CacheHint;\n}> {\n\tconst data = await getWidgetArea(name);\n\treturn { data, cacheHint: { tags: [widgetAreaTag(name)] } };\n}\n\n/**\n * Get all widget areas with their widgets\n */\nexport async function getWidgetAreas(): Promise<WidgetArea[]> {\n\tconst db = await getDb();\n\t// Get all areas\n\tconst areaRows = await db.selectFrom(\"_emdash_widget_areas\").selectAll().execute();\n\n\t// Get all widgets\n\tconst widgetRows = await db\n\t\t.selectFrom(\"_emdash_widgets\")\n\t\t.selectAll()\n\t\t.$castTo<WidgetRow>()\n\t\t.orderBy(\"sort_order\", \"asc\")\n\t\t.execute();\n\n\t// Group widgets by area\n\tconst widgetsByArea = new Map<string, Widget[]>();\n\tfor (const row of widgetRows) {\n\t\tif (!widgetsByArea.has(row.area_id)) {\n\t\t\twidgetsByArea.set(row.area_id, []);\n\t\t}\n\t\twidgetsByArea.get(row.area_id)!.push(rowToWidget(row));\n\t}\n\n\t// Combine\n\treturn areaRows.map((areaRow) => ({\n\t\tid: areaRow.id,\n\t\tname: areaRow.name,\n\t\tlabel: areaRow.label,\n\t\tdescription: areaRow.description ?? undefined,\n\t\twidgets: widgetsByArea.get(areaRow.id) || [],\n\t}));\n}\n\n/**\n * Get available widget components (for admin UI)\n */\nexport function getWidgetComponents(): WidgetComponentDef[] {\n\treturn getComponentRegistry();\n}\n\n/**\n * Convert a widget row to the API type\n */\nexport function rowToWidget(row: WidgetRow): Widget {\n\tconst widget: Widget = {\n\t\tid: row.id,\n\t\ttype: row.type,\n\t\ttitle: row.title ?? undefined,\n\t};\n\n\t// Type-specific fields\n\tif (row.type === \"content\" && row.content) {\n\t\ttry {\n\t\t\twidget.content = JSON.parse(row.content);\n\t\t} catch {\n\t\t\t// Invalid JSON, ignore\n\t\t}\n\t}\n\n\tif (row.type === \"menu\" && row.menu_name) {\n\t\twidget.menuName = row.menu_name;\n\t}\n\n\tif (row.type === \"component\" && row.component_id) {\n\t\twidget.componentId = row.component_id;\n\t\tif (row.component_props) {\n\t\t\ttry {\n\t\t\t\twidget.componentProps = JSON.parse(row.component_props);\n\t\t\t} catch {\n\t\t\t\t// Invalid JSON, ignore\n\t\t\t}\n\t\t}\n\t}\n\n\treturn widget;\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,eAAsB,cAAc,MAA0C;AAC7E,QAAO,cAAc,eAAe,QAAQ,YAAY;EAEvD,MAAM,OAAO,OADF,MAAM,OAAO,EAEtB,WAAW,4BAA4B,CACvC,SAAS,wBAAwB,aAAa,OAAO,CACrD,OAAO;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,CAAC,CACD,MAAM,UAAU,KAAK,KAAK,CAC1B,QAAQ,gBAAgB,MAAM,CAC9B,SAAS;EAEX,MAAM,QAAQ,KAAK;AACnB,MAAI,CAAC,MAAO,QAAO;EACnB,MAAM,UAAoB,EAAE;AAC5B,OAAK,MAAM,OAAO,MAAM;AACvB,OAAI,IAAI,SAAS,KAAM;GAMvB,MAAM,YAAY;IACjB,IAAI,IAAI;IACR,MAAM,IAAI;IACV,OAAO,IAAI;IACX,SAAS,IAAI;IACb,WAAW,IAAI;IACf,cAAc,IAAI;IAClB,iBAAiB,IAAI;IACrB,SAAS,IAAI;IACb,YAAY,IAAI;IAChB,YAAY,IAAI;IAChB;AACD,WAAQ,KAAK,YAAY,UAAU,CAAC;;AAGrC,SAAO;G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O,cAAc,IAAI;AACzB,MAAI,IAAI,gBACP,KAAI;AACH,UAAO,iBAAiB,KAAK,MAAM,IAAI,gBAAgB;UAChD;;AAMV,QAAO"}
1
+ {"version":3,"file":"widgets-RFVAxQl3.mjs","names":["getComponentRegistry"],"sources":["../src/widgets/index.ts"],"sourcesContent":["import { widgetAreaTag } from \"../cache/chrome-tags.js\";\nimport { getDb } from \"../loader.js\";\nimport type { CacheHint } from \"../query.js\";\nimport { requestCached } from \"../request-cache.js\";\nimport { getWidgetComponents as getComponentRegistry } from \"./components.js\";\nimport type { Widget, WidgetArea, WidgetRow, WidgetComponentDef } from \"./types.js\";\n\nexport type {\n\tWidget,\n\tWidgetArea,\n\tWidgetType,\n\tWidgetComponentDef,\n\tPropDef,\n\tCreateWidgetAreaInput,\n\tCreateWidgetInput,\n\tUpdateWidgetInput,\n\tReorderWidgetsInput,\n} from \"./types.js\";\n\n/**\n * Get a widget area by name, with all its widgets.\n *\n * Single query with a left join rather than area-then-widgets so the\n * common case costs one round-trip. An area with no widgets yields one\n * row with null widget columns, which we skip when mapping.\n */\nexport async function getWidgetArea(name: string): Promise<WidgetArea | null> {\n\treturn requestCached(`widget-area:${name}`, async () => {\n\t\tconst db = await getDb();\n\t\tconst rows = await db\n\t\t\t.selectFrom(\"_emdash_widget_areas as a\")\n\t\t\t.leftJoin(\"_emdash_widgets as w\", \"w.area_id\", \"a.id\")\n\t\t\t.select([\n\t\t\t\t\"a.id as a_id\",\n\t\t\t\t\"a.name as a_name\",\n\t\t\t\t\"a.label as a_label\",\n\t\t\t\t\"a.description as a_description\",\n\t\t\t\t\"w.id as w_id\",\n\t\t\t\t\"w.type as w_type\",\n\t\t\t\t\"w.title as w_title\",\n\t\t\t\t\"w.content as w_content\",\n\t\t\t\t\"w.menu_name as w_menu_name\",\n\t\t\t\t\"w.component_id as w_component_id\",\n\t\t\t\t\"w.component_props as w_component_props\",\n\t\t\t\t\"w.area_id as w_area_id\",\n\t\t\t\t\"w.sort_order as w_sort_order\",\n\t\t\t\t\"w.created_at as w_created_at\",\n\t\t\t])\n\t\t\t.where(\"a.name\", \"=\", name)\n\t\t\t.orderBy(\"w.sort_order\", \"asc\")\n\t\t\t.execute();\n\n\t\tconst first = rows[0];\n\t\tif (!first) return null;\n\t\tconst widgets: Widget[] = [];\n\t\tfor (const row of rows) {\n\t\t\tif (row.w_id === null) continue; // area has no widgets (left-join null row)\n\t\t\t// Left-join makes every w_* column nullable in the type; at runtime\n\t\t\t// they're all non-null once w_id is (we match on widgets.area_id, so\n\t\t\t// a widget row always has the not-null columns filled). Cast is the\n\t\t\t// price of that structural fact.\n\t\t\t// eslint-disable-next-line typescript/no-unsafe-type-assertion -- left-join row is non-null when w_id is set; see above\n\t\t\tconst widgetRow = {\n\t\t\t\tid: row.w_id,\n\t\t\t\ttype: row.w_type,\n\t\t\t\ttitle: row.w_title,\n\t\t\t\tcontent: row.w_content,\n\t\t\t\tmenu_name: row.w_menu_name,\n\t\t\t\tcomponent_id: row.w_component_id,\n\t\t\t\tcomponent_props: row.w_component_props,\n\t\t\t\tarea_id: row.w_area_id,\n\t\t\t\tsort_order: row.w_sort_order,\n\t\t\t\tcreated_at: row.w_created_at,\n\t\t\t} as WidgetRow;\n\t\t\twidgets.push(rowToWidget(widgetRow));\n\t\t}\n\n\t\treturn {\n\t\t\tid: first.a_id,\n\t\t\tname: first.a_name,\n\t\t\tlabel: first.a_label,\n\t\t\tdescription: first.a_description ?? undefined,\n\t\t\twidgets,\n\t\t};\n\t});\n}\n\n/**\n * Get a widget area by name with a Workers edge-cache hint.\n *\n * Use the returned `cacheHint` with `Astro.cache.set()` so pages that render\n * this widget area can be purged automatically when its widgets change.\n */\nexport async function getWidgetAreaWithCacheHint(name: string): Promise<{\n\tdata: WidgetArea | null;\n\tcacheHint: CacheHint;\n}> {\n\tconst data = await getWidgetArea(name);\n\treturn { data, cacheHint: { tags: [widgetAreaTag(name)] } };\n}\n\n/**\n * Get all widget areas with their widgets\n */\nexport async function getWidgetAreas(): Promise<WidgetArea[]> {\n\tconst db = await getDb();\n\t// Get all areas\n\tconst areaRows = await db.selectFrom(\"_emdash_widget_areas\").selectAll().execute();\n\n\t// Get all widgets\n\tconst widgetRows = await db\n\t\t.selectFrom(\"_emdash_widgets\")\n\t\t.selectAll()\n\t\t.$castTo<WidgetRow>()\n\t\t.orderBy(\"sort_order\", \"asc\")\n\t\t.execute();\n\n\t// Group widgets by area\n\tconst widgetsByArea = new Map<string, Widget[]>();\n\tfor (const row of widgetRows) {\n\t\tif (!widgetsByArea.has(row.area_id)) {\n\t\t\twidgetsByArea.set(row.area_id, []);\n\t\t}\n\t\twidgetsByArea.get(row.area_id)!.push(rowToWidget(row));\n\t}\n\n\t// Combine\n\treturn areaRows.map((areaRow) => ({\n\t\tid: areaRow.id,\n\t\tname: areaRow.name,\n\t\tlabel: areaRow.label,\n\t\tdescription: areaRow.description ?? undefined,\n\t\twidgets: widgetsByArea.get(areaRow.id) || [],\n\t}));\n}\n\n/**\n * Get available widget components (for admin UI)\n */\nexport function getWidgetComponents(): WidgetComponentDef[] {\n\treturn getComponentRegistry();\n}\n\n/**\n * Convert a widget row to the API type\n */\nexport function rowToWidget(row: WidgetRow): Widget {\n\tconst widget: Widget = {\n\t\tid: row.id,\n\t\ttype: row.type,\n\t\ttitle: row.title ?? undefined,\n\t};\n\n\t// Type-specific fields\n\tif (row.type === \"content\" && row.content) {\n\t\ttry {\n\t\t\twidget.content = JSON.parse(row.content);\n\t\t} catch {\n\t\t\t// Invalid JSON, ignore\n\t\t}\n\t}\n\n\tif (row.type === \"menu\" && row.menu_name) {\n\t\twidget.menuName = row.menu_name;\n\t}\n\n\tif (row.type === \"component\" && row.component_id) {\n\t\twidget.componentId = row.component_id;\n\t\tif (row.component_props) {\n\t\t\ttry {\n\t\t\t\twidget.componentProps = JSON.parse(row.component_props);\n\t\t\t} catch {\n\t\t\t\t// Invalid JSON, ignore\n\t\t\t}\n\t\t}\n\t}\n\n\treturn widget;\n}\n"],"mappings":";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MAAK,MAAM,OAAO,YAAY;AAC7B,MAAI,CAAC,cAAc,IAAI,IAAI,QAAQ,CAClC,eAAc,IAAI,IAAI,SAAS,EAAE,CAAC;AAEnC,gBAAc,IAAI,IAAI,QAAQ,CAAE,KAAK,YAAY,IAAI,CAAC;;AAIvD,QAAO,SAAS,KAAK,aAAa;EACjC,IAAI,QAAQ;EACZ,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,aAAa,QAAQ,eAAe;EACpC,SAAS,cAAc,IAAI,QAAQ,GAAG,IAAI,EAAE;EAC5C,EAAE;;;;;AAMJ,SAAgB,sBAA4C;AAC3D,QAAOA,uBAAsB;;;;;AAM9B,SAAgB,YAAY,KAAwB;CACnD,MAAM,SAAiB;EACtB,IAAI,IAAI;EACR,MAAM,IAAI;EACV,OAAO,IAAI,SAAS;EACpB;AAGD,KAAI,IAAI,SAAS,aAAa,IAAI,QACjC,KAAI;AACH,SAAO,UAAU,KAAK,MAAM,IAAI,QAAQ;SACjC;AAKT,KAAI,IAAI,SAAS,UAAU,IAAI,UAC9B,QAAO,WAAW,IAAI;AAGvB,KAAI,IAAI,SAAS,eAAe,IAAI,cAAc;AACjD,SAAO,cAAc,IAAI;AACzB,MAAI,IAAI,gBACP,KAAI;AACH,UAAO,iBAAiB,KAAK,MAAM,IAAI,gBAAgB;UAChD;;AAMV,QAAO"}
@@ -31,4 +31,4 @@ interface TaxonomyImportPlan {
31
31
  }
32
32
  //#endregion
33
33
  export { TaxonomyImportPlan as t };
34
- //# sourceMappingURL=wxr-taxonomies-B2Og_6rU.d.mts.map
34
+ //# sourceMappingURL=wxr-taxonomies-BX4yQL9s.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wxr-taxonomies-B2Og_6rU.d.mts","names":[],"sources":["../src/import/wxr-taxonomies.ts"],"mappings":";;;;;;UA8DiB,kBAAA;;EAEhB,YAAA,EAAc,MAAA;;EAEd,WAAA,EAAa,MAAA;;EAEb,iBAAA;;;;;EAKA,mBAAA,EAAqB,GAAA,SAAY,GAAA;;;;;;EAMjC,qBAAA,EAAuB,GAAA,SAAY,GAAA;;;;;;EAMnC,wBAAA,EAA0B,GAAA;AAAA"}
1
+ {"version":3,"file":"wxr-taxonomies-BX4yQL9s.d.mts","names":[],"sources":["../src/import/wxr-taxonomies.ts"],"mappings":";;;;;;UA8DiB,kBAAA;;EAEhB,YAAA,EAAc,MAAA;;EAEd,WAAA,EAAa,MAAA;;EAEb,iBAAA;;;;;EAKA,mBAAA,EAAqB,GAAA,SAAY,GAAA;;;;;;EAMjC,qBAAA,EAAuB,GAAA,SAAY,GAAA;;;;;;EAMnC,wBAAA,EAA0B,GAAA;AAAA"}
@@ -1,6 +1,6 @@
1
- import { t as TaxonomyRepository } from "./taxonomy-tJepplLL.mjs";
2
- import { i as resolveLocaleChain } from "./resolve-prZ3mP7l.mjs";
3
- import { d as invalidateTermCache } from "./taxonomies-Wfy_Lg12.mjs";
1
+ import { t as TaxonomyRepository } from "./taxonomy-DP1vny4K.mjs";
2
+ import { i as resolveLocaleChain } from "./resolve-Cy0aWSRj.mjs";
3
+ import { d as invalidateTermCache } from "./taxonomies-NcFDq5Gg.mjs";
4
4
 
5
5
  //#region src/import/wxr-taxonomies.ts
6
6
  /**
@@ -403,4 +403,4 @@ async function mirrorTermsToLocales(db, plan, postLocales, canonicalLocale) {
403
403
 
404
404
  //#endregion
405
405
  export { preImportWxrTaxonomies as a, mirrorTermsToLocales as i, isWxrTaxonomyConflictError as n, setPostTermAssignmentsReplacing as o, loadTaxonomyPlanFromDb as r, attachPostTaxonomies as t };
406
- //# sourceMappingURL=wxr-taxonomies-Cxngsjwo.mjs.map
406
+ //# sourceMappingURL=wxr-taxonomies-Csdp7yde.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"wxr-taxonomies-Cxngsjwo.mjs","names":[],"sources":["../src/import/wxr-taxonomies.ts"],"sourcesContent":["/**\n * WXR taxonomy import helpers.\n *\n * Bridges parsed WordPress taxonomy data (`WxrCategory`, `WxrTag`, `WxrTerm`,\n * and per-item `WxrPost.categories` / `WxrPost.tags` / `WxrPost.customTaxonomies`)\n * onto EmDash's term + content_taxonomies tables.\n *\n * Why this isn't inline in `execute.ts`: pre-creating all terms before any\n * post is created lets us (a) build a lookup once for every (taxonomy, slug)\n * the import needs, and (b) keep the per-post attachment loop cheap. It also\n * makes the logic testable without spinning up an Astro request.\n *\n * Behaviour:\n * - `wp:category` -> EmDash `category` taxonomy (seeded by migration 006).\n * - `wp:tag` -> EmDash `tag` taxonomy.\n * - `wp:term` -> matching EmDash taxonomy by `name` (case-sensitive).\n * If no matching def exists in the target locale, the\n * term is skipped — we don't auto-create defs because\n * the user controls their schema through the admin.\n * - Terms are created idempotently by `(taxonomy, slug, locale)`. Existing\n * terms are reused.\n * - Assignments respect the def's `collections` array. If the post's target\n * collection isn't listed on the taxonomy def, the assignment is skipped\n * (matches admin UI behaviour: you can't tag a \"products\" post with a\n * \"category\" if `category.collections` only includes \"posts\").\n */\n\nimport type { Kysely } from \"kysely\";\n\nimport type { WxrCategory, WxrPost, WxrTag, WxrTerm } from \"../cli/wxr/parser.js\";\nimport { TaxonomyRepository } from \"../database/repositories/taxonomy.js\";\nimport type { Database } from \"../database/types.js\";\nimport { resolveLocaleChain } from \"../i18n/resolve.js\";\nimport { invalidateTermCache } from \"../taxonomies/index.js\";\n\n/**\n * Thrown by `mirrorTermsToLocales` when a pre-existing locale row at the\n * same `(taxonomy, slug)` belongs to a different `translation_group` than\n * the canonical term. Callers in the route layer surface\n * `publicMessage` to the operator (no internal data) while logging\n * `cause` server-side.\n *\n * Marker class so the route layer can distinguish \"operator-actionable\n * taxonomy conflict\" from any other DB / repository error that might\n * escape the helper.\n */\nexport class WxrTaxonomyConflictError extends Error {\n\treadonly publicMessage: string;\n\tconstructor(publicMessage: string, options?: { cause?: unknown }) {\n\t\tsuper(publicMessage, options);\n\t\tthis.name = \"WxrTaxonomyConflictError\";\n\t\tthis.publicMessage = publicMessage;\n\t}\n}\n\nexport function isWxrTaxonomyConflictError(error: unknown): error is WxrTaxonomyConflictError {\n\treturn error instanceof WxrTaxonomyConflictError;\n}\n\n/**\n * Result of pre-importing taxonomy terms from a WXR file.\n */\nexport interface TaxonomyImportPlan {\n\t/** terms created during this run (per taxonomy name) */\n\ttermsCreated: Record<string, number>;\n\t/** terms that already existed and were reused (per taxonomy name) */\n\ttermsReused: Record<string, number>;\n\t/** custom taxonomies (`wp:term`) skipped because no matching EmDash def exists */\n\tmissingTaxonomies: string[];\n\t/**\n\t * Lookup table: `taxonomy name` -> `term slug` -> term id.\n\t * Used by `attachPostTaxonomies` to translate WXR assignments into pivot rows.\n\t */\n\ttermIdByNameAndSlug: Map<string, Map<string, string>>;\n\t/**\n\t * Lookup table: `taxonomy name` -> set of collection slugs the def allows.\n\t * Empty (or missing) means \"any collection\" — we only enforce the filter\n\t * when the def explicitly lists collections.\n\t */\n\tcollectionsByTaxonomy: Map<string, Set<string>>;\n\t/**\n\t * Lookup table: `term id` -> the term's `translation_group` (or `null`\n\t * if the term doesn't exist any more). Populated lazily by helpers that\n\t * need to check pivot existence without repeating per-term DB reads.\n\t */\n\ttranslationGroupByTermId: Map<string, string | null>;\n}\n\n/**\n * Track running counts plus the lookup maps.\n */\ninterface TaxonomyImportState {\n\tplan: TaxonomyImportPlan;\n}\n\nfunction makeState(): TaxonomyImportState {\n\treturn {\n\t\tplan: {\n\t\t\ttermsCreated: {},\n\t\t\ttermsReused: {},\n\t\t\tmissingTaxonomies: [],\n\t\t\ttermIdByNameAndSlug: new Map(),\n\t\t\tcollectionsByTaxonomy: new Map(),\n\t\t\ttranslationGroupByTermId: new Map(),\n\t\t},\n\t};\n}\n\n/**\n * Record-keeping helpers — keep mutations centralised so the result object\n * stays consistent.\n */\nfunction bump(record: Record<string, number>, key: string): void {\n\trecord[key] = (record[key] ?? 0) + 1;\n}\n\nfunction rememberTerm(\n\tstate: TaxonomyImportState,\n\ttaxonomyName: string,\n\tslug: string,\n\ttermId: string,\n): void {\n\tlet bySlug = state.plan.termIdByNameAndSlug.get(taxonomyName);\n\tif (!bySlug) {\n\t\tbySlug = new Map();\n\t\tstate.plan.termIdByNameAndSlug.set(taxonomyName, bySlug);\n\t}\n\tbySlug.set(slug, termId);\n}\n\n/**\n * Look up an EmDash taxonomy def by name. Definitions are per-locale but\n * a def is conceptually site-wide -- the per-locale row carries only the\n * label translations.\n *\n * Match the runtime helper `getTaxonomyDef` (in `src/taxonomies/index.ts`):\n * walk `resolveLocaleChain(locale)` so the importer picks the same def the\n * runtime would later resolve to. When the chain is empty (i18n disabled)\n * or every locale in the chain misses, fall through to the lowest-locale\n * row so single-locale installs still see seeded defs that were inserted\n * at some non-empty locale value.\n *\n * Without this fallback, a user importing into a non-default locale would\n * see every category dropped as `missingTaxonomies` even though the seeded\n * defs exist (just at the site's default locale).\n */\nfunction parseDefCollections(raw: string | null): string[] {\n\tif (!raw) return [];\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(raw);\n\t\tif (Array.isArray(parsed)) {\n\t\t\treturn parsed.filter((c): c is string => typeof c === \"string\");\n\t\t}\n\t} catch {\n\t\t// malformed JSON in the def -- treat as \"no collection filter\"\n\t}\n\treturn [];\n}\n\nasync function findTaxonomyDef(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlocale: string | undefined,\n): Promise<{ id: string; collections: string[] } | null> {\n\tconst chain = resolveLocaleChain(locale);\n\n\tif (chain.length === 0) {\n\t\t// i18n disabled and no explicit locale. The runtime treats this\n\t\t// as \"no locale filter\" and picks the lowest-locale row. We do the\n\t\t// same so the importer agrees with how the runtime later reads\n\t\t// the def.\n\t\tconst row = await db\n\t\t\t.selectFrom(\"_emdash_taxonomy_defs\")\n\t\t\t.selectAll()\n\t\t\t.where(\"name\", \"=\", name)\n\t\t\t.orderBy(\"locale\", \"asc\")\n\t\t\t.executeTakeFirst();\n\t\treturn row ? { id: row.id, collections: parseDefCollections(row.collections) } : null;\n\t}\n\n\t// Non-empty chain: walk it in order, return null if every entry misses.\n\t// This matches `getTaxonomyDef` exactly. We deliberately do NOT fall\n\t// through to any-locale lookup: doing so would let the importer pick a\n\t// def at a locale the runtime would never resolve to, producing\n\t// content the user can't see in the admin or on the rendered site.\n\tfor (const tryLocale of chain) {\n\t\tconst row = await db\n\t\t\t.selectFrom(\"_emdash_taxonomy_defs\")\n\t\t\t.selectAll()\n\t\t\t.where(\"name\", \"=\", name)\n\t\t\t.where(\"locale\", \"=\", tryLocale)\n\t\t\t.executeTakeFirst();\n\t\tif (row) {\n\t\t\treturn { id: row.id, collections: parseDefCollections(row.collections) };\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Rebuild the taxonomy lookup maps from the database without creating\n * anything. The chunked WP import runs term creation once (first content\n * chunk); every later chunk only needs the maps to attach per-post\n * assignments, and two SELECTs are far cheaper than re-walking every term\n * through the ensure path.\n *\n * ponytail: first row wins per (name, slug), ordered by locale asc — the\n * same row `findBySlug` without a locale resolves to. Per-locale term\n * variants beyond that are the mirror pass's job, not the importer's.\n */\nexport async function loadTaxonomyPlanFromDb(db: Kysely<Database>): Promise<TaxonomyImportPlan> {\n\tconst state = makeState();\n\n\tconst defs = await db\n\t\t.selectFrom(\"_emdash_taxonomy_defs\")\n\t\t.select([\"name\", \"collections\"])\n\t\t.orderBy(\"locale\", \"asc\")\n\t\t.execute();\n\tfor (const def of defs) {\n\t\tif (!state.plan.collectionsByTaxonomy.has(def.name)) {\n\t\t\tstate.plan.collectionsByTaxonomy.set(def.name, new Set(parseDefCollections(def.collections)));\n\t\t}\n\t}\n\n\tconst terms = await db\n\t\t.selectFrom(\"taxonomies\")\n\t\t.select([\"name\", \"slug\", \"id\"])\n\t\t.orderBy(\"locale\", \"asc\")\n\t\t.execute();\n\tfor (const term of terms) {\n\t\tif (!state.plan.termIdByNameAndSlug.get(term.name)?.has(term.slug)) {\n\t\t\trememberTerm(state, term.name, term.slug, term.id);\n\t\t}\n\t}\n\n\treturn state.plan;\n}\n\n/**\n * Find or create a term in the given taxonomy. Returns the term id. Callers\n * must verify the taxonomy def exists before calling — this helper assumes\n * the def is present.\n *\n * Note: we don't resolve WordPress parent slugs into EmDash parent ids in\n * this pass. WXR exports list categories in arbitrary order, so a category's\n * parent may not exist yet when we first see it. Hierarchy is preserved at\n * the data level (the parent slug is on `WxrCategory.parent`) but flattens\n * in EmDash for now; restoring the tree is a follow-up improvement.\n */\nasync function ensureTerm(\n\trepo: TaxonomyRepository,\n\tstate: TaxonomyImportState,\n\ttaxonomyName: string,\n\tslug: string,\n\tlabel: string,\n\tdescription: string | undefined,\n\tlocale: string | undefined,\n): Promise<string> {\n\t// Already resolved in this run (e.g. seen in `wp:category` AND in a per-\n\t// item `<category>` element).\n\tconst cached = state.plan.termIdByNameAndSlug.get(taxonomyName)?.get(slug);\n\tif (cached) return cached;\n\n\tconst existing = await repo.findBySlug(taxonomyName, slug, locale);\n\tif (existing) {\n\t\tbump(state.plan.termsReused, taxonomyName);\n\t\trememberTerm(state, taxonomyName, slug, existing.id);\n\t\treturn existing.id;\n\t}\n\n\t// No row at the requested locale. Before creating, check whether a\n\t// `(name, slug)` row exists in some OTHER locale -- e.g. the admin\n\t// pre-created an Arabic translation, and now an `en` import wants the\n\t// canonical row. We need to mint the new row inside the existing row's\n\t// `translation_group` so per-locale lookups across the family work.\n\t// Without this, the mirror pass would later refuse to reconcile (it\n\t// sees pre-existing rows in a different group as a no-op) and pivots\n\t// would point at a group that has no row in the requested locale.\n\tconst anyLocale = await repo.findBySlug(taxonomyName, slug);\n\tconst translationOf = anyLocale?.id;\n\n\tconst created = await repo.create({\n\t\tname: taxonomyName,\n\t\tslug,\n\t\tlabel,\n\t\tdata: description ? { description } : undefined,\n\t\tlocale,\n\t\ttranslationOf,\n\t});\n\tbump(state.plan.termsCreated, taxonomyName);\n\trememberTerm(state, taxonomyName, slug, created.id);\n\treturn created.id;\n}\n\n/**\n * Retrieve the human label captured by the parser for a per-item\n * `<category>` text body, falling back to the slug when the parser didn't\n * see a label (e.g. self-closing tags or whitespace-only bodies).\n */\nfunction labelFor(post: WxrPost, taxonomy: string, slug: string): string {\n\tconst key = `${taxonomy}\\u0000${slug}`;\n\treturn post.taxonomyLabels?.get(key) ?? slug;\n}\n\n/**\n * Pre-import every term referenced by the WXR file.\n *\n * Pass 1: `wp:category` blocks. Each becomes a term in EmDash's seeded\n * `category` taxonomy.\n * Pass 2: `wp:tag` blocks. Each becomes a term in `tag`.\n * Pass 3: `wp:term` blocks (custom taxonomies). Skipped when no matching\n * EmDash def exists.\n * Pass 4: per-item `<category domain=\"…\" nicename=\"…\">` assignments. WXR\n * exports sometimes reference taxonomies/terms that weren't declared\n * at the top level (older exports especially), so we backfill terms\n * from per-item assignments. Categories and tags use the seeded defs\n * and pick up the assignment text as the label; custom domains fall\n * back to the same \"def must exist\" rule.\n */\nexport async function preImportWxrTaxonomies(\n\tdb: Kysely<Database>,\n\tposts: WxrPost[],\n\tcategories: WxrCategory[],\n\ttags: WxrTag[],\n\tterms: WxrTerm[],\n\tlocale: string | undefined,\n): Promise<TaxonomyImportPlan> {\n\tconst state = makeState();\n\tconst repo = new TaxonomyRepository(db);\n\n\t// Cache def lookups for the duration of the import. Keyed by name; value\n\t// is `null` when we've already determined the def is missing in this\n\t// locale (so we only report the \"missing\" warning once per taxonomy).\n\tconst defCache = new Map<string, { id: string; collections: string[] } | null>();\n\tconst lookupDef = async (name: string): Promise<{ id: string; collections: string[] } | null> => {\n\t\tif (defCache.has(name)) return defCache.get(name) ?? null;\n\t\tconst def = await findTaxonomyDef(db, name, locale);\n\t\tdefCache.set(name, def);\n\t\tif (def) {\n\t\t\tstate.plan.collectionsByTaxonomy.set(name, new Set(def.collections));\n\t\t}\n\t\treturn def;\n\t};\n\n\t// Pass 1: top-level <wp:category> blocks -> EmDash `category` taxonomy.\n\tconst categoryDef = await lookupDef(\"category\");\n\tif (categoryDef) {\n\t\tfor (const cat of categories) {\n\t\t\tconst slug = cat.nicename;\n\t\t\tconst label = cat.name;\n\t\t\tif (!slug || !label) continue;\n\t\t\tawait ensureTerm(repo, state, \"category\", slug, label, cat.description, locale);\n\t\t}\n\t} else if (categories.length > 0) {\n\t\t// Seeded `category` def was deleted by the user — record so the\n\t\t// import response can surface why none of the categories landed.\n\t\tstate.plan.missingTaxonomies.push(\"category\");\n\t}\n\n\t// Pass 2: top-level <wp:tag> blocks -> EmDash `tag` taxonomy.\n\tconst tagDef = await lookupDef(\"tag\");\n\tif (tagDef) {\n\t\tfor (const tag of tags) {\n\t\t\tconst slug = tag.slug;\n\t\t\tconst label = tag.name;\n\t\t\tif (!slug || !label) continue;\n\t\t\tawait ensureTerm(repo, state, \"tag\", slug, label, tag.description, locale);\n\t\t}\n\t} else if (tags.length > 0) {\n\t\tstate.plan.missingTaxonomies.push(\"tag\");\n\t}\n\n\t// Pass 3: <wp:term> blocks for custom taxonomies (genre, etc.). Skipped:\n\t// - `nav_menu`: menus are handled by `importMenusFromWxr`.\n\t// - `language`: Polylang's locale signal; promoted to `WxrPost.locale`\n\t// by the parser and not a content taxonomy in EmDash.\n\tfor (const term of terms) {\n\t\tif (term.taxonomy === \"nav_menu\" || term.taxonomy === \"language\") continue;\n\t\t// Normalize WordPress' `post_tag` synonym -> EmDash `tag`. WordPress\n\t\t// emits `<wp:tag>` for some exports and `<wp:term wp:term_taxonomy=\"post_tag\">`\n\t\t// for others; both must land in the same EmDash taxonomy.\n\t\tconst taxonomyName = term.taxonomy === \"post_tag\" ? \"tag\" : term.taxonomy;\n\t\tconst def = await lookupDef(taxonomyName);\n\t\tif (!def) {\n\t\t\tif (!state.plan.missingTaxonomies.includes(taxonomyName)) {\n\t\t\t\tstate.plan.missingTaxonomies.push(taxonomyName);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tawait ensureTerm(repo, state, taxonomyName, term.slug, term.name, term.description, locale);\n\t}\n\n\t// Pass 4: per-item assignments. Backfills terms missing from the top-\n\t// level blocks (rare, but observed in hand-edited or partial exports).\n\t// Labels come from the per-item `<category>` text body when the parser\n\t// captured one; otherwise we fall back to the slug. This is the path\n\t// for older exports that skip top-level `<wp:category>` definitions.\n\tlet recordedMissingCategoryFromPosts = false;\n\tlet recordedMissingTagFromPosts = false;\n\tfor (const post of posts) {\n\t\tfor (const slug of post.categories) {\n\t\t\tif (!categoryDef) {\n\t\t\t\tif (\n\t\t\t\t\t!recordedMissingCategoryFromPosts &&\n\t\t\t\t\t!state.plan.missingTaxonomies.includes(\"category\")\n\t\t\t\t) {\n\t\t\t\t\tstate.plan.missingTaxonomies.push(\"category\");\n\t\t\t\t\trecordedMissingCategoryFromPosts = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (state.plan.termIdByNameAndSlug.get(\"category\")?.has(slug)) continue;\n\t\t\tawait ensureTerm(\n\t\t\t\trepo,\n\t\t\t\tstate,\n\t\t\t\t\"category\",\n\t\t\t\tslug,\n\t\t\t\tlabelFor(post, \"category\", slug),\n\t\t\t\tundefined,\n\t\t\t\tlocale,\n\t\t\t);\n\t\t}\n\t\tfor (const slug of post.tags) {\n\t\t\tif (!tagDef) {\n\t\t\t\tif (!recordedMissingTagFromPosts && !state.plan.missingTaxonomies.includes(\"tag\")) {\n\t\t\t\t\tstate.plan.missingTaxonomies.push(\"tag\");\n\t\t\t\t\trecordedMissingTagFromPosts = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (state.plan.termIdByNameAndSlug.get(\"tag\")?.has(slug)) continue;\n\t\t\tawait ensureTerm(repo, state, \"tag\", slug, labelFor(post, \"tag\", slug), undefined, locale);\n\t\t}\n\t\tif (post.customTaxonomies) {\n\t\t\tfor (const [rawName, slugs] of post.customTaxonomies) {\n\t\t\t\t// `nav_menu` is handled by the menu importer; `language` is\n\t\t\t\t// Polylang's per-post locale signal, already promoted by the\n\t\t\t\t// parser.\n\t\t\t\tif (rawName === \"nav_menu\" || rawName === \"language\") continue;\n\t\t\t\tconst taxonomyName = rawName === \"post_tag\" ? \"tag\" : rawName;\n\t\t\t\tconst def = await lookupDef(taxonomyName);\n\t\t\t\tif (!def) {\n\t\t\t\t\tif (!state.plan.missingTaxonomies.includes(taxonomyName)) {\n\t\t\t\t\t\tstate.plan.missingTaxonomies.push(taxonomyName);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (const slug of slugs) {\n\t\t\t\t\tif (state.plan.termIdByNameAndSlug.get(taxonomyName)?.has(slug)) continue;\n\t\t\t\t\tawait ensureTerm(\n\t\t\t\t\t\trepo,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\ttaxonomyName,\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tlabelFor(post, taxonomyName, slug),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tlocale,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// `content_taxonomies` writes happen later in `attachPostTaxonomies`, but\n\t// term inserts above already invalidate the in-memory \"has any terms\" probe.\n\t// We flush once at the end of the pre-import to keep the runtime cache hot.\n\tinvalidateTermCache();\n\n\treturn state.plan;\n}\n\n/**\n * Walk a parsed WXR post's per-item taxonomy assignments and return only\n * the ones that resolve to a real EmDash term AND aren't filtered out by\n * the taxonomy def's `collections` allowlist. Grouped by EmDash taxonomy\n * name (so `post_tag` is already folded into `tag`). Deduplicated.\n *\n * This is the single source of truth for \"what will the importer try to\n * write for this post\". Both the anchor (additive `attachToEntry`) and\n * translation (per-taxonomy `setTermsForEntry`) paths drive from this map\n * so they agree on which taxonomies need touching. In particular, the\n * translation path uses the keys here -- not `postAssignedTaxonomies` --\n * to decide which inherited pivot rows to clear, so a translation whose\n * only assignment is filtered out by `collections` doesn't lose its\n * inherited terms (see #1087 review feedback).\n *\n * Skipped taxonomies: `nav_menu` (handled by the menu importer) and\n * `language` (Polylang's locale signal, already promoted to `post.locale`\n * by the parser).\n */\nexport function resolvePostTermAssignments(\n\tcollection: string,\n\tpost: WxrPost,\n\tplan: TaxonomyImportPlan,\n): Map<string, string[]> {\n\tconst result = new Map<string, string[]>();\n\tconst seen = new Set<string>();\n\n\tconst tryResolve = (taxonomyName: string, slug: string): void => {\n\t\tconst termId = plan.termIdByNameAndSlug.get(taxonomyName)?.get(slug);\n\t\tif (!termId) return;\n\t\tconst collectionFilter = plan.collectionsByTaxonomy.get(taxonomyName);\n\t\t// Empty set means \"no filter\" (def has no collections array). A\n\t\t// non-empty set is enforced: skip assignments to collections the\n\t\t// def doesn't list. Matches admin UI: a `category` term linked\n\t\t// only to `posts` shouldn't end up on a `products` row just\n\t\t// because the WXR happened to mention it.\n\t\tif (collectionFilter && collectionFilter.size > 0 && !collectionFilter.has(collection)) {\n\t\t\treturn;\n\t\t}\n\t\tconst dedupeKey = `${taxonomyName}\\u0000${termId}`;\n\t\tif (seen.has(dedupeKey)) return;\n\t\tseen.add(dedupeKey);\n\t\tconst existing = result.get(taxonomyName);\n\t\tif (existing) existing.push(termId);\n\t\telse result.set(taxonomyName, [termId]);\n\t};\n\n\tfor (const slug of post.categories) tryResolve(\"category\", slug);\n\tfor (const slug of post.tags) tryResolve(\"tag\", slug);\n\tif (post.customTaxonomies) {\n\t\tfor (const [rawName, slugs] of post.customTaxonomies) {\n\t\t\tif (rawName === \"nav_menu\" || rawName === \"language\") continue;\n\t\t\tconst taxonomyName = rawName === \"post_tag\" ? \"tag\" : rawName;\n\t\t\tfor (const slug of slugs) tryResolve(taxonomyName, slug);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Attach the taxonomy assignments parsed for a single WXR post to a freshly-\n * created EmDash content row. Additive (`attachToEntry` + `ON CONFLICT DO\n * NOTHING`). Used for anchors -- translations need replace-semantics per\n * taxonomy and should use `setPostTermAssignmentsReplacing` instead.\n *\n * Returns the number of pivot rows actually inserted (excludes rows that\n * already existed via the `ON CONFLICT DO NOTHING` path), so the caller can\n * roll them up into the import summary without over-counting on re-imports.\n */\nexport async function attachPostTaxonomies(\n\tdb: Kysely<Database>,\n\tcollection: string,\n\tentryId: string,\n\tpost: WxrPost,\n\tplan: TaxonomyImportPlan,\n): Promise<number> {\n\tconst repo = new TaxonomyRepository(db);\n\tconst resolved = resolvePostTermAssignments(collection, post, plan);\n\tconst groups = new Set<string>();\n\tfor (const [, termIds] of resolved) {\n\t\tfor (const termId of termIds) {\n\t\t\tconst group = await termTranslationGroup(repo, plan, termId);\n\t\t\tif (group) groups.add(group);\n\t\t}\n\t}\n\treturn repo.attachGroupsToEntry(collection, entryId, [...groups]);\n}\n\n/**\n * Replace assignments per-taxonomy from a parsed WXR post. Used for\n * translations. Assignments belong to the content translation_group, so a\n * translated item's explicit taxonomy replaces that taxonomy for every\n * locale. Taxonomies with no resolvable permitted terms are left unchanged.\n *\n * Returns the number of pivot rows after replacement (sum of `termIds`\n * lists across taxonomies actually touched). Note this counts logical\n * assignments, not the delta from the prior state; the import summary\n * treats this as an additive count for compatibility with `attachPost-\n * Taxonomies`.\n */\nexport async function setPostTermAssignmentsReplacing(\n\tdb: Kysely<Database>,\n\tcollection: string,\n\tentryId: string,\n\tpost: WxrPost,\n\tplan: TaxonomyImportPlan,\n): Promise<number> {\n\tconst repo = new TaxonomyRepository(db);\n\tconst resolved = resolvePostTermAssignments(collection, post, plan);\n\n\tlet attached = 0;\n\tfor (const [taxonomyName, termIds] of resolved) {\n\t\tawait repo.setTermsForEntry(collection, entryId, taxonomyName, termIds);\n\t\tattached += termIds.length;\n\t}\n\treturn attached;\n}\n\n/**\n * Resolve a term id to its `translation_group` (the value\n * `content_taxonomies` stores). Caches the result on the plan so\n * repeated attaches of the same term don't repeat the lookup.\n */\nasync function termTranslationGroup(\n\trepo: TaxonomyRepository,\n\tplan: TaxonomyImportPlan,\n\ttermId: string,\n): Promise<string | null> {\n\tconst cached = plan.translationGroupByTermId.get(termId);\n\tif (cached !== undefined) return cached;\n\tconst term = await repo.findById(termId);\n\tconst group = term?.translationGroup ?? null;\n\tplan.translationGroupByTermId.set(termId, group);\n\treturn group;\n}\n\n/**\n * Mirror every term in the plan into each additional locale used by the\n * incoming posts. New rows share the canonical term's `translation_group`\n * so per-locale lookups (`getTermsForEntry(..., locale)`) resolve correctly\n * for translations whose locale differs from the import-wide one.\n *\n * Without this pass, multilingual WXR imports (#1080) write all term rows\n * at the upload-wide locale; the `content_taxonomies` pivot is correct (it\n * stores `translation_group`, not `term id`), but\n * `getTermsForEntry(collection, arabicPostId, \"category\", \"ar\")` filters on\n * `taxonomies.locale = \"ar\"` and returns zero rows. Users see \"no tags\" on\n * every non-canonical translation.\n *\n * Idempotent: skips a locale when a row already exists at `(name, slug,\n * locale)`. Safe to call after `preImportWxrTaxonomies` on subsequent\n * imports.\n */\nexport async function mirrorTermsToLocales(\n\tdb: Kysely<Database>,\n\tplan: TaxonomyImportPlan,\n\tpostLocales: Iterable<string>,\n\tcanonicalLocale: string | undefined,\n): Promise<void> {\n\tconst localeSet = new Set<string>();\n\tfor (const locale of postLocales) {\n\t\tif (!locale || locale === canonicalLocale) continue;\n\t\tlocaleSet.add(locale);\n\t}\n\tif (localeSet.size === 0) return;\n\n\tconst repo = new TaxonomyRepository(db);\n\n\tfor (const [taxonomyName, bySlug] of plan.termIdByNameAndSlug) {\n\t\tfor (const [slug, canonicalTermId] of bySlug) {\n\t\t\t// Resolve the canonical's translation_group once; we'll compare\n\t\t\t// against any pre-existing rows we find at the target locales.\n\t\t\t// Cache on the plan so subsequent attaches (which also need\n\t\t\t// this resolution) don't repeat the lookup.\n\t\t\tconst cachedGroup = await termTranslationGroup(repo, plan, canonicalTermId);\n\t\t\tif (!cachedGroup) {\n\t\t\t\t// The canonical term id is in the plan but the row is no\n\t\t\t\t// longer in the DB. Shouldn't happen during a single\n\t\t\t\t// import run; skip rather than crash so the rest of the\n\t\t\t\t// import can complete.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst canonicalGroup = cachedGroup;\n\n\t\t\tfor (const locale of localeSet) {\n\t\t\t\tconst existing = await repo.findBySlug(taxonomyName, slug, locale);\n\t\t\t\tif (existing) {\n\t\t\t\t\t// `ensureTerm` resolves cross-locale grouping when it\n\t\t\t\t\t// creates the canonical row, so a pre-existing sibling\n\t\t\t\t\t// row at this locale should already share the\n\t\t\t\t\t// canonical's `translation_group`. If it doesn't, the\n\t\t\t\t\t// import would write pivots pointing at a group that\n\t\t\t\t\t// has no row in this locale -- a silent data-integrity\n\t\t\t\t\t// bug. Fail closed: throw so the operator reconciles\n\t\t\t\t\t// the existing rows in the admin before retrying. This\n\t\t\t\t\t// happens when the canonical row was created in an\n\t\t\t\t\t// earlier import and a sibling-locale row was added\n\t\t\t\t\t// manually afterwards (or vice versa) without linking\n\t\t\t\t\t// them via translationOf.\n\t\t\t\t\tif (existing.translationGroup !== canonicalGroup) {\n\t\t\t\t\t\tthrow new WxrTaxonomyConflictError(\n\t\t\t\t\t\t\t`Cannot import: term \"${taxonomyName}/${slug}\" already exists at locale \"${locale}\" in a different translation group than the canonical row at this import's locale. Reconcile the rows in the admin (re-link via translationOf, or delete one) and retry.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait repo.create({\n\t\t\t\t\t\tname: taxonomyName,\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tlabel: slug, // we don't have a per-locale label from the WXR\n\t\t\t\t\t\tlocale,\n\t\t\t\t\t\ttranslationOf: canonicalTermId,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// `findBySlug` + `create` is not atomic. A concurrent\n\t\t\t\t\t// import racing us into the same `(name, slug, locale)`\n\t\t\t\t\t// will trip the UNIQUE constraint. Re-read the row that\n\t\t\t\t\t// won the race and verify its `translation_group`\n\t\t\t\t\t// matches the canonical's; if not, the pivot will\n\t\t\t\t\t// resolve to a group that has no row in this locale\n\t\t\t\t\t// (silent data-integrity bug) so we surface that loudly\n\t\t\t\t\t// rather than continue.\n\t\t\t\t\t//\n\t\t\t\t\t// Other errors (validation, connectivity) re-throw so\n\t\t\t\t\t// the import fails closed rather than silently shipping\n\t\t\t\t\t// translations that resolve to empty taxonomy queries.\n\t\t\t\t\tconst message = error instanceof Error ? error.message.toLowerCase() : \"\";\n\t\t\t\t\tconst isUniqueRace =\n\t\t\t\t\t\tmessage.includes(\"unique constraint failed\") || message.includes(\"duplicate key\");\n\t\t\t\t\tif (!isUniqueRace) throw error;\n\n\t\t\t\t\tconst winner = await repo.findBySlug(taxonomyName, slug, locale);\n\t\t\t\t\tif (!winner) {\n\t\t\t\t\t\t// UNIQUE conflict but no row visible? Shouldn't\n\t\t\t\t\t\t// happen unless the racing transaction rolled back;\n\t\t\t\t\t\t// fail loudly so the operator can investigate.\n\t\t\t\t\t\tthrow new WxrTaxonomyConflictError(\n\t\t\t\t\t\t\t`Cannot import: term \"${taxonomyName}/${slug}\" raced UNIQUE at locale \"${locale}\" but no row is visible afterwards. The concurrent transaction may have rolled back; retry the import.`,\n\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (winner.translationGroup !== canonicalGroup) {\n\t\t\t\t\t\tthrow new WxrTaxonomyConflictError(\n\t\t\t\t\t\t\t`Cannot import: term \"${taxonomyName}/${slug}\" raced UNIQUE at locale \"${locale}\" with a different translation group. Reconcile the rows in the admin and retry.`,\n\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[WXR import] concurrent writer beat us to term \"${taxonomyName}/${slug}\" at locale \"${locale}\"; using existing row (same group).`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8CA,IAAa,2BAAb,cAA8C,MAAM;CACnD,AAAS;CACT,YAAY,eAAuB,SAA+B;AACjE,QAAM,eAAe,QAAQ;AAC7B,OAAK,OAAO;AACZ,OAAK,gBAAgB;;;AAIvB,SAAgB,2BAA2B,OAAm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IAAI,mBAAmB,GAAG;AAEvC,MAAK,MAAM,CAAC,cAAc,WAAW,KAAK,oBACzC,MAAK,MAAM,CAAC,MAAM,oBAAoB,QAAQ;EAK7C,MAAM,cAAc,MAAM,qBAAqB,MAAM,MAAM,gBAAgB;AAC3E,MAAI,CAAC,YAKJ;EAED,MAAM,iBAAiB;AAEvB,OAAK,MAAM,UAAU,WAAW;GAC/B,MAAM,WAAW,MAAM,KAAK,WAAW,cAAc,MAAM,OAAO;AAClE,OAAI,UAAU;AAab,QAAI,SAAS,qBAAqB,eACjC,OAAM,IAAI,yBACT,wBAAwB,aAAa,GAAG,KAAK,8BAA8B,OAAO,0KAClF;AAEF;;AAED,OAAI;AACH,UAAM,KAAK,OAAO;KACjB,MAAM;KACN;KACA,OAAO;KACP;KACA,eAAe;KACf,CAAC;YACM,OAAO;IAaf,MAAM,UAAU,iBAAiB,QAAQ,MAAM,QAAQ,aAAa,GAAG;AAGvE,QAAI,EADH,QAAQ,SAAS,2BAA2B,IAAI,QAAQ,SAAS,gBAAgB,EAC/D,OAAM;IAEzB,MAAM,SAAS,MAAM,KAAK,WAAW,cAAc,MAAM,OAAO;AAChE,QAAI,CAAC,OAIJ,OAAM,IAAI,yBACT,wBAAwB,aAAa,GAAG,KAAK,4BAA4B,OAAO,yGAChF,EAAE,OAAO,OAAO,CAChB;AAEF,QAAI,OAAO,qBAAqB,eAC/B,OAAM,IAAI,yBACT,wBAAwB,aAAa,GAAG,KAAK,4BAA4B,OAAO,mFAChF,EAAE,OAAO,OAAO,CAChB;AAEF,YAAQ,KACP,mDAAmD,aAAa,GAAG,KAAK,eAAe,OAAO,qCAC9F"}
1
+ {"version":3,"file":"wxr-taxonomies-Csdp7yde.mjs","names":[],"sources":["../src/import/wxr-taxonomies.ts"],"sourcesContent":["/**\n * WXR taxonomy import helpers.\n *\n * Bridges parsed WordPress taxonomy data (`WxrCategory`, `WxrTag`, `WxrTerm`,\n * and per-item `WxrPost.categories` / `WxrPost.tags` / `WxrPost.customTaxonomies`)\n * onto EmDash's term + content_taxonomies tables.\n *\n * Why this isn't inline in `execute.ts`: pre-creating all terms before any\n * post is created lets us (a) build a lookup once for every (taxonomy, slug)\n * the import needs, and (b) keep the per-post attachment loop cheap. It also\n * makes the logic testable without spinning up an Astro request.\n *\n * Behaviour:\n * - `wp:category` -> EmDash `category` taxonomy (seeded by migration 006).\n * - `wp:tag` -> EmDash `tag` taxonomy.\n * - `wp:term` -> matching EmDash taxonomy by `name` (case-sensitive).\n * If no matching def exists in the target locale, the\n * term is skipped — we don't auto-create defs because\n * the user controls their schema through the admin.\n * - Terms are created idempotently by `(taxonomy, slug, locale)`. Existing\n * terms are reused.\n * - Assignments respect the def's `collections` array. If the post's target\n * collection isn't listed on the taxonomy def, the assignment is skipped\n * (matches admin UI behaviour: you can't tag a \"products\" post with a\n * \"category\" if `category.collections` only includes \"posts\").\n */\n\nimport type { Kysely } from \"kysely\";\n\nimport type { WxrCategory, WxrPost, WxrTag, WxrTerm } from \"../cli/wxr/parser.js\";\nimport { TaxonomyRepository } from \"../database/repositories/taxonomy.js\";\nimport type { Database } from \"../database/types.js\";\nimport { resolveLocaleChain } from \"../i18n/resolve.js\";\nimport { invalidateTermCache } from \"../taxonomies/index.js\";\n\n/**\n * Thrown by `mirrorTermsToLocales` when a pre-existing locale row at the\n * same `(taxonomy, slug)` belongs to a different `translation_group` than\n * the canonical term. Callers in the route layer surface\n * `publicMessage` to the operator (no internal data) while logging\n * `cause` server-side.\n *\n * Marker class so the route layer can distinguish \"operator-actionable\n * taxonomy conflict\" from any other DB / repository error that might\n * escape the helper.\n */\nexport class WxrTaxonomyConflictError extends Error {\n\treadonly publicMessage: string;\n\tconstructor(publicMessage: string, options?: { cause?: unknown }) {\n\t\tsuper(publicMessage, options);\n\t\tthis.name = \"WxrTaxonomyConflictError\";\n\t\tthis.publicMessage = publicMessage;\n\t}\n}\n\nexport function isWxrTaxonomyConflictError(error: unknown): error is WxrTaxonomyConflictError {\n\treturn error instanceof WxrTaxonomyConflictError;\n}\n\n/**\n * Result of pre-importing taxonomy terms from a WXR file.\n */\nexport interface TaxonomyImportPlan {\n\t/** terms created during this run (per taxonomy name) */\n\ttermsCreated: Record<string, number>;\n\t/** terms that already existed and were reused (per taxonomy name) */\n\ttermsReused: Record<string, number>;\n\t/** custom taxonomies (`wp:term`) skipped because no matching EmDash def exists */\n\tmissingTaxonomies: string[];\n\t/**\n\t * Lookup table: `taxonomy name` -> `term slug` -> term id.\n\t * Used by `attachPostTaxonomies` to translate WXR assignments into pivot rows.\n\t */\n\ttermIdByNameAndSlug: Map<string, Map<string, string>>;\n\t/**\n\t * Lookup table: `taxonomy name` -> set of collection slugs the def allows.\n\t * Empty (or missing) means \"any collection\" — we only enforce the filter\n\t * when the def explicitly lists collections.\n\t */\n\tcollectionsByTaxonomy: Map<string, Set<string>>;\n\t/**\n\t * Lookup table: `term id` -> the term's `translation_group` (or `null`\n\t * if the term doesn't exist any more). Populated lazily by helpers that\n\t * need to check pivot existence without repeating per-term DB reads.\n\t */\n\ttranslationGroupByTermId: Map<string, string | null>;\n}\n\n/**\n * Track running counts plus the lookup maps.\n */\ninterface TaxonomyImportState {\n\tplan: TaxonomyImportPlan;\n}\n\nfunction makeState(): TaxonomyImportState {\n\treturn {\n\t\tplan: {\n\t\t\ttermsCreated: {},\n\t\t\ttermsReused: {},\n\t\t\tmissingTaxonomies: [],\n\t\t\ttermIdByNameAndSlug: new Map(),\n\t\t\tcollectionsByTaxonomy: new Map(),\n\t\t\ttranslationGroupByTermId: new Map(),\n\t\t},\n\t};\n}\n\n/**\n * Record-keeping helpers — keep mutations centralised so the result object\n * stays consistent.\n */\nfunction bump(record: Record<string, number>, key: string): void {\n\trecord[key] = (record[key] ?? 0) + 1;\n}\n\nfunction rememberTerm(\n\tstate: TaxonomyImportState,\n\ttaxonomyName: string,\n\tslug: string,\n\ttermId: string,\n): void {\n\tlet bySlug = state.plan.termIdByNameAndSlug.get(taxonomyName);\n\tif (!bySlug) {\n\t\tbySlug = new Map();\n\t\tstate.plan.termIdByNameAndSlug.set(taxonomyName, bySlug);\n\t}\n\tbySlug.set(slug, termId);\n}\n\n/**\n * Look up an EmDash taxonomy def by name. Definitions are per-locale but\n * a def is conceptually site-wide -- the per-locale row carries only the\n * label translations.\n *\n * Match the runtime helper `getTaxonomyDef` (in `src/taxonomies/index.ts`):\n * walk `resolveLocaleChain(locale)` so the importer picks the same def the\n * runtime would later resolve to. When the chain is empty (i18n disabled)\n * or every locale in the chain misses, fall through to the lowest-locale\n * row so single-locale installs still see seeded defs that were inserted\n * at some non-empty locale value.\n *\n * Without this fallback, a user importing into a non-default locale would\n * see every category dropped as `missingTaxonomies` even though the seeded\n * defs exist (just at the site's default locale).\n */\nfunction parseDefCollections(raw: string | null): string[] {\n\tif (!raw) return [];\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(raw);\n\t\tif (Array.isArray(parsed)) {\n\t\t\treturn parsed.filter((c): c is string => typeof c === \"string\");\n\t\t}\n\t} catch {\n\t\t// malformed JSON in the def -- treat as \"no collection filter\"\n\t}\n\treturn [];\n}\n\nasync function findTaxonomyDef(\n\tdb: Kysely<Database>,\n\tname: string,\n\tlocale: string | undefined,\n): Promise<{ id: string; collections: string[] } | null> {\n\tconst chain = resolveLocaleChain(locale);\n\n\tif (chain.length === 0) {\n\t\t// i18n disabled and no explicit locale. The runtime treats this\n\t\t// as \"no locale filter\" and picks the lowest-locale row. We do the\n\t\t// same so the importer agrees with how the runtime later reads\n\t\t// the def.\n\t\tconst row = await db\n\t\t\t.selectFrom(\"_emdash_taxonomy_defs\")\n\t\t\t.selectAll()\n\t\t\t.where(\"name\", \"=\", name)\n\t\t\t.orderBy(\"locale\", \"asc\")\n\t\t\t.executeTakeFirst();\n\t\treturn row ? { id: row.id, collections: parseDefCollections(row.collections) } : null;\n\t}\n\n\t// Non-empty chain: walk it in order, return null if every entry misses.\n\t// This matches `getTaxonomyDef` exactly. We deliberately do NOT fall\n\t// through to any-locale lookup: doing so would let the importer pick a\n\t// def at a locale the runtime would never resolve to, producing\n\t// content the user can't see in the admin or on the rendered site.\n\tfor (const tryLocale of chain) {\n\t\tconst row = await db\n\t\t\t.selectFrom(\"_emdash_taxonomy_defs\")\n\t\t\t.selectAll()\n\t\t\t.where(\"name\", \"=\", name)\n\t\t\t.where(\"locale\", \"=\", tryLocale)\n\t\t\t.executeTakeFirst();\n\t\tif (row) {\n\t\t\treturn { id: row.id, collections: parseDefCollections(row.collections) };\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Rebuild the taxonomy lookup maps from the database without creating\n * anything. The chunked WP import runs term creation once (first content\n * chunk); every later chunk only needs the maps to attach per-post\n * assignments, and two SELECTs are far cheaper than re-walking every term\n * through the ensure path.\n *\n * ponytail: first row wins per (name, slug), ordered by locale asc — the\n * same row `findBySlug` without a locale resolves to. Per-locale term\n * variants beyond that are the mirror pass's job, not the importer's.\n */\nexport async function loadTaxonomyPlanFromDb(db: Kysely<Database>): Promise<TaxonomyImportPlan> {\n\tconst state = makeState();\n\n\tconst defs = await db\n\t\t.selectFrom(\"_emdash_taxonomy_defs\")\n\t\t.select([\"name\", \"collections\"])\n\t\t.orderBy(\"locale\", \"asc\")\n\t\t.execute();\n\tfor (const def of defs) {\n\t\tif (!state.plan.collectionsByTaxonomy.has(def.name)) {\n\t\t\tstate.plan.collectionsByTaxonomy.set(def.name, new Set(parseDefCollections(def.collections)));\n\t\t}\n\t}\n\n\tconst terms = await db\n\t\t.selectFrom(\"taxonomies\")\n\t\t.select([\"name\", \"slug\", \"id\"])\n\t\t.orderBy(\"locale\", \"asc\")\n\t\t.execute();\n\tfor (const term of terms) {\n\t\tif (!state.plan.termIdByNameAndSlug.get(term.name)?.has(term.slug)) {\n\t\t\trememberTerm(state, term.name, term.slug, term.id);\n\t\t}\n\t}\n\n\treturn state.plan;\n}\n\n/**\n * Find or create a term in the given taxonomy. Returns the term id. Callers\n * must verify the taxonomy def exists before calling — this helper assumes\n * the def is present.\n *\n * Note: we don't resolve WordPress parent slugs into EmDash parent ids in\n * this pass. WXR exports list categories in arbitrary order, so a category's\n * parent may not exist yet when we first see it. Hierarchy is preserved at\n * the data level (the parent slug is on `WxrCategory.parent`) but flattens\n * in EmDash for now; restoring the tree is a follow-up improvement.\n */\nasync function ensureTerm(\n\trepo: TaxonomyRepository,\n\tstate: TaxonomyImportState,\n\ttaxonomyName: string,\n\tslug: string,\n\tlabel: string,\n\tdescription: string | undefined,\n\tlocale: string | undefined,\n): Promise<string> {\n\t// Already resolved in this run (e.g. seen in `wp:category` AND in a per-\n\t// item `<category>` element).\n\tconst cached = state.plan.termIdByNameAndSlug.get(taxonomyName)?.get(slug);\n\tif (cached) return cached;\n\n\tconst existing = await repo.findBySlug(taxonomyName, slug, locale);\n\tif (existing) {\n\t\tbump(state.plan.termsReused, taxonomyName);\n\t\trememberTerm(state, taxonomyName, slug, existing.id);\n\t\treturn existing.id;\n\t}\n\n\t// No row at the requested locale. Before creating, check whether a\n\t// `(name, slug)` row exists in some OTHER locale -- e.g. the admin\n\t// pre-created an Arabic translation, and now an `en` import wants the\n\t// canonical row. We need to mint the new row inside the existing row's\n\t// `translation_group` so per-locale lookups across the family work.\n\t// Without this, the mirror pass would later refuse to reconcile (it\n\t// sees pre-existing rows in a different group as a no-op) and pivots\n\t// would point at a group that has no row in the requested locale.\n\tconst anyLocale = await repo.findBySlug(taxonomyName, slug);\n\tconst translationOf = anyLocale?.id;\n\n\tconst created = await repo.create({\n\t\tname: taxonomyName,\n\t\tslug,\n\t\tlabel,\n\t\tdata: description ? { description } : undefined,\n\t\tlocale,\n\t\ttranslationOf,\n\t});\n\tbump(state.plan.termsCreated, taxonomyName);\n\trememberTerm(state, taxonomyName, slug, created.id);\n\treturn created.id;\n}\n\n/**\n * Retrieve the human label captured by the parser for a per-item\n * `<category>` text body, falling back to the slug when the parser didn't\n * see a label (e.g. self-closing tags or whitespace-only bodies).\n */\nfunction labelFor(post: WxrPost, taxonomy: string, slug: string): string {\n\tconst key = `${taxonomy}\\u0000${slug}`;\n\treturn post.taxonomyLabels?.get(key) ?? slug;\n}\n\n/**\n * Pre-import every term referenced by the WXR file.\n *\n * Pass 1: `wp:category` blocks. Each becomes a term in EmDash's seeded\n * `category` taxonomy.\n * Pass 2: `wp:tag` blocks. Each becomes a term in `tag`.\n * Pass 3: `wp:term` blocks (custom taxonomies). Skipped when no matching\n * EmDash def exists.\n * Pass 4: per-item `<category domain=\"…\" nicename=\"…\">` assignments. WXR\n * exports sometimes reference taxonomies/terms that weren't declared\n * at the top level (older exports especially), so we backfill terms\n * from per-item assignments. Categories and tags use the seeded defs\n * and pick up the assignment text as the label; custom domains fall\n * back to the same \"def must exist\" rule.\n */\nexport async function preImportWxrTaxonomies(\n\tdb: Kysely<Database>,\n\tposts: WxrPost[],\n\tcategories: WxrCategory[],\n\ttags: WxrTag[],\n\tterms: WxrTerm[],\n\tlocale: string | undefined,\n): Promise<TaxonomyImportPlan> {\n\tconst state = makeState();\n\tconst repo = new TaxonomyRepository(db);\n\n\t// Cache def lookups for the duration of the import. Keyed by name; value\n\t// is `null` when we've already determined the def is missing in this\n\t// locale (so we only report the \"missing\" warning once per taxonomy).\n\tconst defCache = new Map<string, { id: string; collections: string[] } | null>();\n\tconst lookupDef = async (name: string): Promise<{ id: string; collections: string[] } | null> => {\n\t\tif (defCache.has(name)) return defCache.get(name) ?? null;\n\t\tconst def = await findTaxonomyDef(db, name, locale);\n\t\tdefCache.set(name, def);\n\t\tif (def) {\n\t\t\tstate.plan.collectionsByTaxonomy.set(name, new Set(def.collections));\n\t\t}\n\t\treturn def;\n\t};\n\n\t// Pass 1: top-level <wp:category> blocks -> EmDash `category` taxonomy.\n\tconst categoryDef = await lookupDef(\"category\");\n\tif (categoryDef) {\n\t\tfor (const cat of categories) {\n\t\t\tconst slug = cat.nicename;\n\t\t\tconst label = cat.name;\n\t\t\tif (!slug || !label) continue;\n\t\t\tawait ensureTerm(repo, state, \"category\", slug, label, cat.description, locale);\n\t\t}\n\t} else if (categories.length > 0) {\n\t\t// Seeded `category` def was deleted by the user — record so the\n\t\t// import response can surface why none of the categories landed.\n\t\tstate.plan.missingTaxonomies.push(\"category\");\n\t}\n\n\t// Pass 2: top-level <wp:tag> blocks -> EmDash `tag` taxonomy.\n\tconst tagDef = await lookupDef(\"tag\");\n\tif (tagDef) {\n\t\tfor (const tag of tags) {\n\t\t\tconst slug = tag.slug;\n\t\t\tconst label = tag.name;\n\t\t\tif (!slug || !label) continue;\n\t\t\tawait ensureTerm(repo, state, \"tag\", slug, label, tag.description, locale);\n\t\t}\n\t} else if (tags.length > 0) {\n\t\tstate.plan.missingTaxonomies.push(\"tag\");\n\t}\n\n\t// Pass 3: <wp:term> blocks for custom taxonomies (genre, etc.). Skipped:\n\t// - `nav_menu`: menus are handled by `importMenusFromWxr`.\n\t// - `language`: Polylang's locale signal; promoted to `WxrPost.locale`\n\t// by the parser and not a content taxonomy in EmDash.\n\tfor (const term of terms) {\n\t\tif (term.taxonomy === \"nav_menu\" || term.taxonomy === \"language\") continue;\n\t\t// Normalize WordPress' `post_tag` synonym -> EmDash `tag`. WordPress\n\t\t// emits `<wp:tag>` for some exports and `<wp:term wp:term_taxonomy=\"post_tag\">`\n\t\t// for others; both must land in the same EmDash taxonomy.\n\t\tconst taxonomyName = term.taxonomy === \"post_tag\" ? \"tag\" : term.taxonomy;\n\t\tconst def = await lookupDef(taxonomyName);\n\t\tif (!def) {\n\t\t\tif (!state.plan.missingTaxonomies.includes(taxonomyName)) {\n\t\t\t\tstate.plan.missingTaxonomies.push(taxonomyName);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tawait ensureTerm(repo, state, taxonomyName, term.slug, term.name, term.description, locale);\n\t}\n\n\t// Pass 4: per-item assignments. Backfills terms missing from the top-\n\t// level blocks (rare, but observed in hand-edited or partial exports).\n\t// Labels come from the per-item `<category>` text body when the parser\n\t// captured one; otherwise we fall back to the slug. This is the path\n\t// for older exports that skip top-level `<wp:category>` definitions.\n\tlet recordedMissingCategoryFromPosts = false;\n\tlet recordedMissingTagFromPosts = false;\n\tfor (const post of posts) {\n\t\tfor (const slug of post.categories) {\n\t\t\tif (!categoryDef) {\n\t\t\t\tif (\n\t\t\t\t\t!recordedMissingCategoryFromPosts &&\n\t\t\t\t\t!state.plan.missingTaxonomies.includes(\"category\")\n\t\t\t\t) {\n\t\t\t\t\tstate.plan.missingTaxonomies.push(\"category\");\n\t\t\t\t\trecordedMissingCategoryFromPosts = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (state.plan.termIdByNameAndSlug.get(\"category\")?.has(slug)) continue;\n\t\t\tawait ensureTerm(\n\t\t\t\trepo,\n\t\t\t\tstate,\n\t\t\t\t\"category\",\n\t\t\t\tslug,\n\t\t\t\tlabelFor(post, \"category\", slug),\n\t\t\t\tundefined,\n\t\t\t\tlocale,\n\t\t\t);\n\t\t}\n\t\tfor (const slug of post.tags) {\n\t\t\tif (!tagDef) {\n\t\t\t\tif (!recordedMissingTagFromPosts && !state.plan.missingTaxonomies.includes(\"tag\")) {\n\t\t\t\t\tstate.plan.missingTaxonomies.push(\"tag\");\n\t\t\t\t\trecordedMissingTagFromPosts = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (state.plan.termIdByNameAndSlug.get(\"tag\")?.has(slug)) continue;\n\t\t\tawait ensureTerm(repo, state, \"tag\", slug, labelFor(post, \"tag\", slug), undefined, locale);\n\t\t}\n\t\tif (post.customTaxonomies) {\n\t\t\tfor (const [rawName, slugs] of post.customTaxonomies) {\n\t\t\t\t// `nav_menu` is handled by the menu importer; `language` is\n\t\t\t\t// Polylang's per-post locale signal, already promoted by the\n\t\t\t\t// parser.\n\t\t\t\tif (rawName === \"nav_menu\" || rawName === \"language\") continue;\n\t\t\t\tconst taxonomyName = rawName === \"post_tag\" ? \"tag\" : rawName;\n\t\t\t\tconst def = await lookupDef(taxonomyName);\n\t\t\t\tif (!def) {\n\t\t\t\t\tif (!state.plan.missingTaxonomies.includes(taxonomyName)) {\n\t\t\t\t\t\tstate.plan.missingTaxonomies.push(taxonomyName);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (const slug of slugs) {\n\t\t\t\t\tif (state.plan.termIdByNameAndSlug.get(taxonomyName)?.has(slug)) continue;\n\t\t\t\t\tawait ensureTerm(\n\t\t\t\t\t\trepo,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\ttaxonomyName,\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tlabelFor(post, taxonomyName, slug),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tlocale,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// `content_taxonomies` writes happen later in `attachPostTaxonomies`, but\n\t// term inserts above already invalidate the in-memory \"has any terms\" probe.\n\t// We flush once at the end of the pre-import to keep the runtime cache hot.\n\tinvalidateTermCache();\n\n\treturn state.plan;\n}\n\n/**\n * Walk a parsed WXR post's per-item taxonomy assignments and return only\n * the ones that resolve to a real EmDash term AND aren't filtered out by\n * the taxonomy def's `collections` allowlist. Grouped by EmDash taxonomy\n * name (so `post_tag` is already folded into `tag`). Deduplicated.\n *\n * This is the single source of truth for \"what will the importer try to\n * write for this post\". Both the anchor (additive `attachToEntry`) and\n * translation (per-taxonomy `setTermsForEntry`) paths drive from this map\n * so they agree on which taxonomies need touching. In particular, the\n * translation path uses the keys here -- not `postAssignedTaxonomies` --\n * to decide which inherited pivot rows to clear, so a translation whose\n * only assignment is filtered out by `collections` doesn't lose its\n * inherited terms (see #1087 review feedback).\n *\n * Skipped taxonomies: `nav_menu` (handled by the menu importer) and\n * `language` (Polylang's locale signal, already promoted to `post.locale`\n * by the parser).\n */\nexport function resolvePostTermAssignments(\n\tcollection: string,\n\tpost: WxrPost,\n\tplan: TaxonomyImportPlan,\n): Map<string, string[]> {\n\tconst result = new Map<string, string[]>();\n\tconst seen = new Set<string>();\n\n\tconst tryResolve = (taxonomyName: string, slug: string): void => {\n\t\tconst termId = plan.termIdByNameAndSlug.get(taxonomyName)?.get(slug);\n\t\tif (!termId) return;\n\t\tconst collectionFilter = plan.collectionsByTaxonomy.get(taxonomyName);\n\t\t// Empty set means \"no filter\" (def has no collections array). A\n\t\t// non-empty set is enforced: skip assignments to collections the\n\t\t// def doesn't list. Matches admin UI: a `category` term linked\n\t\t// only to `posts` shouldn't end up on a `products` row just\n\t\t// because the WXR happened to mention it.\n\t\tif (collectionFilter && collectionFilter.size > 0 && !collectionFilter.has(collection)) {\n\t\t\treturn;\n\t\t}\n\t\tconst dedupeKey = `${taxonomyName}\\u0000${termId}`;\n\t\tif (seen.has(dedupeKey)) return;\n\t\tseen.add(dedupeKey);\n\t\tconst existing = result.get(taxonomyName);\n\t\tif (existing) existing.push(termId);\n\t\telse result.set(taxonomyName, [termId]);\n\t};\n\n\tfor (const slug of post.categories) tryResolve(\"category\", slug);\n\tfor (const slug of post.tags) tryResolve(\"tag\", slug);\n\tif (post.customTaxonomies) {\n\t\tfor (const [rawName, slugs] of post.customTaxonomies) {\n\t\t\tif (rawName === \"nav_menu\" || rawName === \"language\") continue;\n\t\t\tconst taxonomyName = rawName === \"post_tag\" ? \"tag\" : rawName;\n\t\t\tfor (const slug of slugs) tryResolve(taxonomyName, slug);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Attach the taxonomy assignments parsed for a single WXR post to a freshly-\n * created EmDash content row. Additive (`attachToEntry` + `ON CONFLICT DO\n * NOTHING`). Used for anchors -- translations need replace-semantics per\n * taxonomy and should use `setPostTermAssignmentsReplacing` instead.\n *\n * Returns the number of pivot rows actually inserted (excludes rows that\n * already existed via the `ON CONFLICT DO NOTHING` path), so the caller can\n * roll them up into the import summary without over-counting on re-imports.\n */\nexport async function attachPostTaxonomies(\n\tdb: Kysely<Database>,\n\tcollection: string,\n\tentryId: string,\n\tpost: WxrPost,\n\tplan: TaxonomyImportPlan,\n): Promise<number> {\n\tconst repo = new TaxonomyRepository(db);\n\tconst resolved = resolvePostTermAssignments(collection, post, plan);\n\tconst groups = new Set<string>();\n\tfor (const [, termIds] of resolved) {\n\t\tfor (const termId of termIds) {\n\t\t\tconst group = await termTranslationGroup(repo, plan, termId);\n\t\t\tif (group) groups.add(group);\n\t\t}\n\t}\n\treturn repo.attachGroupsToEntry(collection, entryId, [...groups]);\n}\n\n/**\n * Replace assignments per-taxonomy from a parsed WXR post. Used for\n * translations. Assignments belong to the content translation_group, so a\n * translated item's explicit taxonomy replaces that taxonomy for every\n * locale. Taxonomies with no resolvable permitted terms are left unchanged.\n *\n * Returns the number of pivot rows after replacement (sum of `termIds`\n * lists across taxonomies actually touched). Note this counts logical\n * assignments, not the delta from the prior state; the import summary\n * treats this as an additive count for compatibility with `attachPost-\n * Taxonomies`.\n */\nexport async function setPostTermAssignmentsReplacing(\n\tdb: Kysely<Database>,\n\tcollection: string,\n\tentryId: string,\n\tpost: WxrPost,\n\tplan: TaxonomyImportPlan,\n): Promise<number> {\n\tconst repo = new TaxonomyRepository(db);\n\tconst resolved = resolvePostTermAssignments(collection, post, plan);\n\n\tlet attached = 0;\n\tfor (const [taxonomyName, termIds] of resolved) {\n\t\tawait repo.setTermsForEntry(collection, entryId, taxonomyName, termIds);\n\t\tattached += termIds.length;\n\t}\n\treturn attached;\n}\n\n/**\n * Resolve a term id to its `translation_group` (the value\n * `content_taxonomies` stores). Caches the result on the plan so\n * repeated attaches of the same term don't repeat the lookup.\n */\nasync function termTranslationGroup(\n\trepo: TaxonomyRepository,\n\tplan: TaxonomyImportPlan,\n\ttermId: string,\n): Promise<string | null> {\n\tconst cached = plan.translationGroupByTermId.get(termId);\n\tif (cached !== undefined) return cached;\n\tconst term = await repo.findById(termId);\n\tconst group = term?.translationGroup ?? null;\n\tplan.translationGroupByTermId.set(termId, group);\n\treturn group;\n}\n\n/**\n * Mirror every term in the plan into each additional locale used by the\n * incoming posts. New rows share the canonical term's `translation_group`\n * so per-locale lookups (`getTermsForEntry(..., locale)`) resolve correctly\n * for translations whose locale differs from the import-wide one.\n *\n * Without this pass, multilingual WXR imports (#1080) write all term rows\n * at the upload-wide locale; the `content_taxonomies` pivot is correct (it\n * stores `translation_group`, not `term id`), but\n * `getTermsForEntry(collection, arabicPostId, \"category\", \"ar\")` filters on\n * `taxonomies.locale = \"ar\"` and returns zero rows. Users see \"no tags\" on\n * every non-canonical translation.\n *\n * Idempotent: skips a locale when a row already exists at `(name, slug,\n * locale)`. Safe to call after `preImportWxrTaxonomies` on subsequent\n * imports.\n */\nexport async function mirrorTermsToLocales(\n\tdb: Kysely<Database>,\n\tplan: TaxonomyImportPlan,\n\tpostLocales: Iterable<string>,\n\tcanonicalLocale: string | undefined,\n): Promise<void> {\n\tconst localeSet = new Set<string>();\n\tfor (const locale of postLocales) {\n\t\tif (!locale || locale === canonicalLocale) continue;\n\t\tlocaleSet.add(locale);\n\t}\n\tif (localeSet.size === 0) return;\n\n\tconst repo = new TaxonomyRepository(db);\n\n\tfor (const [taxonomyName, bySlug] of plan.termIdByNameAndSlug) {\n\t\tfor (const [slug, canonicalTermId] of bySlug) {\n\t\t\t// Resolve the canonical's translation_group once; we'll compare\n\t\t\t// against any pre-existing rows we find at the target locales.\n\t\t\t// Cache on the plan so subsequent attaches (which also need\n\t\t\t// this resolution) don't repeat the lookup.\n\t\t\tconst cachedGroup = await termTranslationGroup(repo, plan, canonicalTermId);\n\t\t\tif (!cachedGroup) {\n\t\t\t\t// The canonical term id is in the plan but the row is no\n\t\t\t\t// longer in the DB. Shouldn't happen during a single\n\t\t\t\t// import run; skip rather than crash so the rest of the\n\t\t\t\t// import can complete.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst canonicalGroup = cachedGroup;\n\n\t\t\tfor (const locale of localeSet) {\n\t\t\t\tconst existing = await repo.findBySlug(taxonomyName, slug, locale);\n\t\t\t\tif (existing) {\n\t\t\t\t\t// `ensureTerm` resolves cross-locale grouping when it\n\t\t\t\t\t// creates the canonical row, so a pre-existing sibling\n\t\t\t\t\t// row at this locale should already share the\n\t\t\t\t\t// canonical's `translation_group`. If it doesn't, the\n\t\t\t\t\t// import would write pivots pointing at a group that\n\t\t\t\t\t// has no row in this locale -- a silent data-integrity\n\t\t\t\t\t// bug. Fail closed: throw so the operator reconciles\n\t\t\t\t\t// the existing rows in the admin before retrying. This\n\t\t\t\t\t// happens when the canonical row was created in an\n\t\t\t\t\t// earlier import and a sibling-locale row was added\n\t\t\t\t\t// manually afterwards (or vice versa) without linking\n\t\t\t\t\t// them via translationOf.\n\t\t\t\t\tif (existing.translationGroup !== canonicalGroup) {\n\t\t\t\t\t\tthrow new WxrTaxonomyConflictError(\n\t\t\t\t\t\t\t`Cannot import: term \"${taxonomyName}/${slug}\" already exists at locale \"${locale}\" in a different translation group than the canonical row at this import's locale. Reconcile the rows in the admin (re-link via translationOf, or delete one) and retry.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait repo.create({\n\t\t\t\t\t\tname: taxonomyName,\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tlabel: slug, // we don't have a per-locale label from the WXR\n\t\t\t\t\t\tlocale,\n\t\t\t\t\t\ttranslationOf: canonicalTermId,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// `findBySlug` + `create` is not atomic. A concurrent\n\t\t\t\t\t// import racing us into the same `(name, slug, locale)`\n\t\t\t\t\t// will trip the UNIQUE constraint. Re-read the row that\n\t\t\t\t\t// won the race and verify its `translation_group`\n\t\t\t\t\t// matches the canonical's; if not, the pivot will\n\t\t\t\t\t// resolve to a group that has no row in this locale\n\t\t\t\t\t// (silent data-integrity bug) so we surface that loudly\n\t\t\t\t\t// rather than continue.\n\t\t\t\t\t//\n\t\t\t\t\t// Other errors (validation, connectivity) re-throw so\n\t\t\t\t\t// the import fails closed rather than silently shipping\n\t\t\t\t\t// translations that resolve to empty taxonomy queries.\n\t\t\t\t\tconst message = error instanceof Error ? error.message.toLowerCase() : \"\";\n\t\t\t\t\tconst isUniqueRace =\n\t\t\t\t\t\tmessage.includes(\"unique constraint failed\") || message.includes(\"duplicate key\");\n\t\t\t\t\tif (!isUniqueRace) throw error;\n\n\t\t\t\t\tconst winner = await repo.findBySlug(taxonomyName, slug, locale);\n\t\t\t\t\tif (!winner) {\n\t\t\t\t\t\t// UNIQUE conflict but no row visible? Shouldn't\n\t\t\t\t\t\t// happen unless the racing transaction rolled back;\n\t\t\t\t\t\t// fail loudly so the operator can investigate.\n\t\t\t\t\t\tthrow new WxrTaxonomyConflictError(\n\t\t\t\t\t\t\t`Cannot import: term \"${taxonomyName}/${slug}\" raced UNIQUE at locale \"${locale}\" but no row is visible afterwards. The concurrent transaction may have rolled back; retry the import.`,\n\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (winner.translationGroup !== canonicalGroup) {\n\t\t\t\t\t\tthrow new WxrTaxonomyConflictError(\n\t\t\t\t\t\t\t`Cannot import: term \"${taxonomyName}/${slug}\" raced UNIQUE at locale \"${locale}\" with a different translation group. Reconcile the rows in the admin and retry.`,\n\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[WXR import] concurrent writer beat us to term \"${taxonomyName}/${slug}\" at locale \"${locale}\"; using existing row (same group).`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8CA,IAAa,2BAAb,cAA8C,MAAM;CACnD,AAAS;CACT,YAAY,eAAuB,SAA+B;AACjE,QAAM,eAAe,QAAQ;AAC7B,OAAK,OAAO;AACZ,OAAK,gBAAgB;;;AAIvB,SAAgB,2BAA2B,OAAmD;AAC7F,QAAO,iBAAiB;;AAuCzB,SAAS,YAAiC;AACzC,QAAO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KAAK,oBACzC,MAAK,MAAM,CAAC,MAAM,oBAAoB,QAAQ;EAK7C,MAAM,cAAc,MAAM,qBAAqB,MAAM,MAAM,gBAAgB;AAC3E,MAAI,CAAC,YAKJ;EAED,MAAM,iBAAiB;AAEvB,OAAK,MAAM,UAAU,WAAW;GAC/B,MAAM,WAAW,MAAM,KAAK,WAAW,cAAc,MAAM,OAAO;AAClE,OAAI,UAAU;AAab,QAAI,SAAS,qBAAqB,eACjC,OAAM,IAAI,yBACT,wBAAwB,aAAa,GAAG,KAAK,8BAA8B,OAAO,0KAClF;AAEF;;AAED,OAAI;AACH,UAAM,KAAK,OAAO;KACjB,MAAM;KACN;KACA,OAAO;KACP;KACA,eAAe;KACf,CAAC;YACM,OAAO;IAaf,MAAM,UAAU,iBAAiB,QAAQ,MAAM,QAAQ,aAAa,GAAG;AAGvE,QAAI,EADH,QAAQ,SAAS,2BAA2B,IAAI,QAAQ,SAAS,gBAAgB,EAC/D,OAAM;IAEzB,MAAM,SAAS,MAAM,KAAK,WAAW,cAAc,MAAM,OAAO;AAChE,QAAI,CAAC,OAIJ,OAAM,IAAI,yBACT,wBAAwB,aAAa,GAAG,KAAK,4BAA4B,OAAO,yGAChF,EAAE,OAAO,OAAO,CAChB;AAEF,QAAI,OAAO,qBAAqB,eAC/B,OAAM,IAAI,yBACT,wBAAwB,aAAa,GAAG,KAAK,4BAA4B,OAAO,mFAChF,EAAE,OAAO,OAAO,CAChB;AAEF,YAAQ,KACP,mDAAmD,aAAa,GAAG,KAAK,eAAe,OAAO,qCAC9F"}
@@ -1,5 +1,5 @@
1
- import { c as __exportAll } from "./runner-BLIDKpmA.mjs";
2
- import { r as hashString } from "./hash-3JJPlHF2.mjs";
1
+ import { c as __exportAll } from "./runner-nEzvnogG.mjs";
2
+ import { r as hashString } from "./hash-BRweX6jz.mjs";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/schema/zod-generator.ts
@@ -328,4 +328,4 @@ function uniqueInterfaceNames(collections) {
328
328
 
329
329
  //#endregion
330
330
  export { zod_generator_exports as a, uniqueInterfaceNames as i, generateZodSchema as n, invalidateSchemaCache as r, generateTypeScript as t };
331
- //# sourceMappingURL=zod-generator-BuYSQJB7.mjs.map
331
+ //# sourceMappingURL=zod-generator-CNRGdnBY.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"zod-generator-BuYSQJB7.mjs","names":[],"sources":["../src/schema/zod-generator.ts"],"sourcesContent":["import { z, type ZodType } from \"zod\";\n\nimport { hashString } from \"../utils/hash.js\";\nimport type { CollectionWithFields, Field, FieldType, RepeaterSubField } from \"./types.js\";\n\n/** Pattern to split on underscores, hyphens, and spaces for PascalCase conversion */\nconst PASCAL_CASE_SPLIT_PATTERN = /[_\\-\\s]+/;\n\n/**\n * Generate a Zod schema from a collection's field definitions\n *\n * This allows runtime validation of content based on dynamically\n * defined schemas stored in D1.\n */\nexport function generateZodSchema(\n\tcollection: CollectionWithFields,\n): z.ZodObject<Record<string, ZodType>> {\n\tconst shape: Record<string, ZodType> = {};\n\n\tfor (const field of collection.fields) {\n\t\tshape[field.slug] = generateFieldSchema(field);\n\t}\n\n\treturn z.object(shape);\n}\n\n/**\n * Generate Zod schema for a single field\n */\nexport function generateFieldSchema(field: Field): ZodType {\n\tlet schema = getBaseSchema(field.type, field);\n\n\t// Apply validation rules\n\tif (field.validation) {\n\t\tschema = applyValidation(schema, field);\n\t}\n\n\t// Apply required/optional. Non-required fields use `.nullish()` rather\n\t// than `.optional()` because the underlying SQLite columns are nullable\n\t// (see `SchemaRegistry.addFieldColumn` -- non-required fields are added\n\t// without `NOT NULL`). The admin re-sends what it loaded from the\n\t// server on autosave, so any field that's actually `null` in the DB\n\t// must round-trip cleanly through the validator. `.optional()` only\n\t// accepts `undefined`; `.nullish()` accepts both `undefined` and\n\t// `null`. (#867 — autosave failures on seeded entries.)\n\tif (!field.required) {\n\t\tschema = schema.nullish();\n\t}\n\n\t// Apply default value\n\tif (field.defaultValue !== undefined) {\n\t\tschema = schema.default(field.defaultValue);\n\t}\n\n\treturn schema;\n}\n\n/**\n * Get base Zod schema for a field type\n */\nfunction getBaseSchema(type: FieldType, field: Pick<Field, \"validation\">): ZodType {\n\tswitch (type) {\n\t\tcase \"url\":\n\t\t\treturn z.string().check(z.url());\n\n\t\tcase \"string\":\n\t\tcase \"text\":\n\t\tcase \"slug\":\n\t\t\treturn z.string();\n\n\t\tcase \"number\":\n\t\t\treturn z.number();\n\n\t\tcase \"integer\":\n\t\t\treturn z.number().int();\n\n\t\tcase \"boolean\":\n\t\t\t// Boolean fields map to `INTEGER` columns (`FIELD_TYPE_TO_COLUMN`\n\t\t\t// in `schema/types.ts`) and `serializeValue` in\n\t\t\t// `database/repositories/content.ts` writes booleans as 0/1.\n\t\t\t// `deserializeValue` never converts them back, so reads return\n\t\t\t// numbers. Coerce the stored 0/1 shape here so a GET → POST\n\t\t\t// round-trip on a boolean field passes validation. Other inputs\n\t\t\t// (strings, other numbers) fall through to `z.boolean()` and\n\t\t\t// produce its standard rejection.\n\t\t\treturn z.preprocess((v) => (v === 0 || v === 1 ? Boolean(v) : v), z.boolean());\n\n\t\tcase \"datetime\":\n\t\t\t// Accept every value that legitimately round-trips through the admin\n\t\t\t// and seeds: ISO with `Z`, ISO with a timezone offset, a naive\n\t\t\t// datetime (`YYYY-MM-DDTHH:mm[:ss]` -- what `<input type=\"datetime-local\">`\n\t\t\t// and many seeds produce), and a date-only value. The admin re-sends\n\t\t\t// every loaded field on autosave, so a stored naive datetime must\n\t\t\t// validate or the entry becomes unsavable through its own editor\n\t\t\t// (#1368; same class as #867). `z.iso.*` retains semantic validation,\n\t\t\t// so impossible dates are still rejected.\n\t\t\treturn z.iso\n\t\t\t\t.datetime({ offset: true, local: true })\n\t\t\t\t.or(z.iso.datetime({ offset: true, local: true, precision: -1 }))\n\t\t\t\t.or(z.iso.date());\n\n\t\tcase \"select\": {\n\t\t\tconst options = field.validation?.options;\n\t\t\tif (options && options.length > 0) {\n\t\t\t\tconst [first, ...rest] = options;\n\t\t\t\treturn z.enum([first, ...rest]);\n\t\t\t}\n\t\t\treturn z.string();\n\t\t}\n\n\t\tcase \"multiSelect\": {\n\t\t\tconst multiOptions = field.validation?.options;\n\t\t\tif (multiOptions && multiOptions.length > 0) {\n\t\t\t\tconst [first, ...rest] = multiOptions;\n\t\t\t\treturn z.array(z.enum([first, ...rest]));\n\t\t\t}\n\t\t\treturn z.array(z.string());\n\t\t}\n\n\t\tcase \"repeater\":\n\t\t\treturn z.array(generateRepeaterRowSchema(field.validation?.subFields ?? []));\n\n\t\tcase \"portableText\":\n\t\t\t// Portable Text is an array of blocks. We require `_type` because\n\t\t\t// renderers dispatch on it, but `_key` is intentionally optional:\n\t\t\t// it's a UI-layer concern that the editor regenerates on every\n\t\t\t// change (see `PortableTextEditor`), and the rest of this schema\n\t\t\t// uses `.loose()` for everything below the top level. Making\n\t\t\t// `_key` strictly required here was an accidentally tight invariant\n\t\t\t// that rejected any seed/import data not authored against the\n\t\t\t// editor (#867 — autosave failures on seeded template content).\n\t\t\treturn z.array(\n\t\t\t\tz\n\t\t\t\t\t.object({\n\t\t\t\t\t\t_type: z.string(),\n\t\t\t\t\t\t_key: z.string().optional(),\n\t\t\t\t\t})\n\t\t\t\t\t.loose(),\n\t\t\t);\n\n\t\tcase \"image\": {\n\t\t\tconst mediaSchema = z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tsrc: z.string().optional(),\n\t\t\t\talt: z.string().optional(),\n\t\t\t\twidth: z.number().optional(),\n\t\t\t\theight: z.number().optional(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\tmimeType: z.string().optional(),\n\t\t\t\tblurhash: z.string().optional(),\n\t\t\t\tdominantColor: z.string().optional(),\n\t\t\t\t/** Provider ID (e.g. \"local\", \"cloudflare-images\") */\n\t\t\t\tprovider: z.string().optional(),\n\t\t\t\t/** Admin-side preview URL for external providers (not persisted by plugins) */\n\t\t\t\tpreviewUrl: z.string().optional(),\n\t\t\t\t/** Provider-specific metadata; for local media this carries storageKey */\n\t\t\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t\t\t});\n\t\t\treturn mediaSchema.extend({\n\t\t\t\t/** Counterpart shown when the page renders in a dark color scheme */\n\t\t\t\tdarkVariant: mediaSchema.optional(),\n\t\t\t});\n\t\t}\n\n\t\tcase \"file\":\n\t\t\treturn z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\turl: z.string().optional(),\n\t\t\t\tsrc: z.string().optional(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\tmimeType: z.string().optional(),\n\t\t\t\tsize: z.number().optional(),\n\t\t\t\t/** Provider ID (e.g. \"local\", \"s3\") */\n\t\t\t\tprovider: z.string().optional(),\n\t\t\t\t/** Provider-specific metadata; for local media this carries storageKey */\n\t\t\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t\t\t});\n\n\t\tcase \"reference\":\n\t\t\treturn z.string(); // Reference ID\n\n\t\tcase \"json\":\n\t\t\treturn z.unknown();\n\n\t\tdefault:\n\t\t\treturn z.unknown();\n\t}\n}\n\nfunction generateRepeaterRowSchema(\n\tsubFields: readonly RepeaterSubField[],\n): z.ZodObject<Record<string, ZodType>> {\n\tconst shape: Record<string, ZodType> = {};\n\n\tfor (const subField of subFields) {\n\t\tlet schema = getBaseSchema(subField.type, {\n\t\t\tvalidation: subField.options ? { options: subField.options } : undefined,\n\t\t});\n\n\t\tif (subField.required && schema instanceof z.ZodString) {\n\t\t\tschema = schema.min(1, \"required (empty value not allowed)\");\n\t\t}\n\t\tif (!subField.required) {\n\t\t\tschema = schema.nullish();\n\t\t}\n\n\t\tshape[subField.slug] = schema;\n\t}\n\n\treturn z.object(shape).loose();\n}\n\n/**\n * Apply validation rules to a schema\n */\nfunction applyValidation(schema: ZodType, field: Field): ZodType {\n\tconst validation = field.validation;\n\tif (!validation) return schema;\n\n\t// String validations\n\tif (schema instanceof z.ZodString) {\n\t\tlet strSchema = schema;\n\t\tif (validation.minLength !== undefined) {\n\t\t\tstrSchema = strSchema.min(validation.minLength);\n\t\t}\n\t\tif (validation.maxLength !== undefined) {\n\t\t\tstrSchema = strSchema.max(validation.maxLength);\n\t\t}\n\t\tif (validation.pattern) {\n\t\t\tstrSchema = strSchema.regex(new RegExp(validation.pattern));\n\t\t}\n\t\treturn strSchema;\n\t}\n\n\t// Number validations\n\tif (schema instanceof z.ZodNumber) {\n\t\tlet numSchema = schema;\n\t\tif (validation.min !== undefined) {\n\t\t\tnumSchema = numSchema.min(validation.min);\n\t\t}\n\t\tif (validation.max !== undefined) {\n\t\t\tnumSchema = numSchema.max(validation.max);\n\t\t}\n\t\treturn numSchema;\n\t}\n\n\tif (field.type === \"repeater\" && schema instanceof z.ZodArray) {\n\t\tlet arraySchema = schema;\n\t\tif (validation.minItems !== undefined) {\n\t\t\tarraySchema = arraySchema.min(validation.minItems);\n\t\t}\n\t\tif (validation.maxItems !== undefined) {\n\t\t\tarraySchema = arraySchema.max(validation.maxItems);\n\t\t}\n\t\treturn arraySchema;\n\t}\n\n\treturn schema;\n}\n\n/**\n * Schema cache to avoid regenerating schemas on every request\n */\nconst schemaCache = new Map<string, { schema: z.ZodObject<any>; version: string }>();\n\n/**\n * Get or generate a cached schema for a collection\n */\nexport function getCachedSchema(\n\tcollection: CollectionWithFields,\n\tversion?: string,\n): z.ZodObject<any> {\n\tconst cacheKey = collection.slug;\n\tconst cached = schemaCache.get(cacheKey);\n\n\t// If version matches, return cached schema\n\tif (cached && (!version || cached.version === version)) {\n\t\treturn cached.schema;\n\t}\n\n\t// Generate new schema\n\tconst schema = generateZodSchema(collection);\n\n\t// Cache it\n\tschemaCache.set(cacheKey, {\n\t\tschema,\n\t\tversion: version || collection.updatedAt,\n\t});\n\n\treturn schema;\n}\n\n/**\n * Invalidate cached schema for a collection\n */\nexport function invalidateSchemaCache(slug: string): void {\n\tschemaCache.delete(slug);\n}\n\n/**\n * Clear all cached schemas\n */\nexport function clearSchemaCache(): void {\n\tschemaCache.clear();\n}\n\n/**\n * Validate data against a collection's schema\n */\nexport function validateContent(\n\tcollection: CollectionWithFields,\n\tdata: unknown,\n): { success: true; data: unknown } | { success: false; errors: z.ZodError } {\n\tconst schema = getCachedSchema(collection);\n\n\tconst result = schema.safeParse(data);\n\n\tif (result.success) {\n\t\treturn { success: true, data: result.data };\n\t}\n\n\treturn { success: false, errors: result.error };\n}\n\n/**\n * Generate TypeScript interface from field definitions\n * Used by CLI `emdash types` to generate types\n */\nexport function generateTypeScript(\n\tcollection: CollectionWithFields,\n\tinterfaceName: string = getInterfaceName(collection),\n): string {\n\tconst lines: string[] = [];\n\n\tlines.push(`export interface ${interfaceName} {`);\n\tlines.push(` id: string;`);\n\tlines.push(` slug: string | null;`);\n\tlines.push(` status: string;`);\n\n\tfor (const field of collection.fields) {\n\t\tconst tsType = fieldTypeToTypeScript(field);\n\t\tconst optional = field.required ? \"\" : \"?\";\n\t\tlines.push(` ${field.slug}${optional}: ${tsType};`);\n\t}\n\n\tlines.push(` createdAt: Date;`);\n\tlines.push(` updatedAt: Date;`);\n\tlines.push(` publishedAt: Date | null;`);\n\t// Bylines are eagerly loaded by getEmDashCollection/getEmDashEntry\n\tlines.push(` bylines?: ContentBylineCredit[];`);\n\t// Taxonomy terms are eagerly loaded by getEmDashCollection/getEmDashEntry,\n\t// keyed by taxonomy name (e.g. data.terms?.tag)\n\tlines.push(` terms?: Record<string, TaxonomyTerm[]>;`);\n\tlines.push(`}`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generate a complete types file with module augmentation\n * This produces emdash-env.d.ts content that provides typed query functions\n */\nexport function generateTypesFile(collections: CollectionWithFields[]): string {\n\tconst lines: string[] = [];\n\n\t// Header\n\tlines.push(`// Generated by EmDash on dev server start`);\n\tlines.push(`// Do not edit manually`);\n\tlines.push(``);\n\tlines.push(`/// <reference types=\"emdash/locals\" />`);\n\tlines.push(``);\n\n\t// Check if we need PortableTextBlock import\n\tconst needsPortableText = collections.some((c) =>\n\t\tc.fields.some((f) => f.type === \"portableText\"),\n\t);\n\n\t// Build imports - ContentBylineCredit and TaxonomyTerm are always needed\n\t// for the hydrated bylines/terms fields\n\tconst imports = [\"ContentBylineCredit\", \"TaxonomyTerm\"];\n\tif (needsPortableText) {\n\t\timports.push(\"PortableTextBlock\");\n\t}\n\tlines.push(`import type { ${imports.join(\", \")} } from \"emdash\";`);\n\tlines.push(``);\n\n\t// Singularizing the slug can map two distinct slugs to the same name\n\t// (e.g. `book` and `books` both -> `Book`), so resolve collisions up front\n\t// to keep every interface identifier unique within the file.\n\tconst interfaceNames = uniqueInterfaceNames(collections);\n\n\t// Generate individual interfaces\n\tfor (const collection of collections) {\n\t\tlines.push(generateTypeScript(collection, interfaceNames.get(collection.slug)));\n\t\tlines.push(``);\n\t}\n\n\t// Generate the Collections interface for module augmentation\n\tlines.push(`declare module \"emdash\" {`);\n\tlines.push(` interface EmDashCollections {`);\n\tfor (const collection of collections) {\n\t\tlines.push(` ${collection.slug}: ${interfaceNames.get(collection.slug)};`);\n\t}\n\tlines.push(` }`);\n\tlines.push(`}`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generate schema hash for cache invalidation\n */\nexport async function generateSchemaHash(collections: CollectionWithFields[]): Promise<string> {\n\tconst str = JSON.stringify(\n\t\tcollections.map((c) => ({\n\t\t\tslug: c.slug,\n\t\t\tfields: c.fields.map((f) => ({\n\t\t\t\tslug: f.slug,\n\t\t\t\ttype: f.type,\n\t\t\t\trequired: f.required,\n\t\t\t\tvalidation: f.validation,\n\t\t\t})),\n\t\t})),\n\t);\n\treturn hashString(str);\n}\n\n/**\n * Map field type to TypeScript type\n */\nfunction fieldTypeToTypeScript(field: {\n\ttype: Field[\"type\"];\n\tvalidation?: Field[\"validation\"];\n}): string {\n\tswitch (field.type) {\n\t\tcase \"string\":\n\t\tcase \"text\":\n\t\tcase \"slug\":\n\t\tcase \"url\":\n\t\tcase \"datetime\":\n\t\t\treturn \"string\";\n\n\t\tcase \"number\":\n\t\tcase \"integer\":\n\t\t\treturn \"number\";\n\n\t\tcase \"boolean\":\n\t\t\treturn \"boolean\";\n\n\t\tcase \"select\":\n\t\t\tconst options = field.validation?.options;\n\t\t\tif (options && options.length > 0) {\n\t\t\t\treturn options.map((o) => `\"${o}\"`).join(\" | \");\n\t\t\t}\n\t\t\treturn \"string\";\n\n\t\tcase \"multiSelect\":\n\t\t\tconst multiOptions = field.validation?.options;\n\t\t\tif (multiOptions && multiOptions.length > 0) {\n\t\t\t\treturn `(${multiOptions.map((o) => `\"${o}\"`).join(\" | \")})[]`;\n\t\t\t}\n\t\t\treturn \"string[]\";\n\n\t\tcase \"repeater\": {\n\t\t\tconst subFields = field.validation?.subFields;\n\t\t\t// `validation` is unvalidated JSON on the seed and registry paths.\n\t\t\tif (!Array.isArray(subFields) || subFields.length === 0) return \"unknown\";\n\n\t\t\t// A duplicated slug keeps its first position and last declaration, as\n\t\t\t// `generateRepeaterRowSchema`'s `shape[subField.slug]` does.\n\t\t\tconst members = new Map<string, string>();\n\n\t\t\tfor (const subField of subFields) {\n\t\t\t\tconst type = fieldTypeToTypeScript({\n\t\t\t\t\ttype: subField.type,\n\t\t\t\t\tvalidation: subField.options ? { options: subField.options } : undefined,\n\t\t\t\t});\n\t\t\t\t// A sub-field slug is not guaranteed to be a valid identifier, so it is\n\t\t\t\t// quoted rather than emitted bare.\n\t\t\t\tconst name = JSON.stringify(subField.slug);\n\t\t\t\t// A sub-field that is not required may be null at runtime.\n\t\t\t\tmembers.set(\n\t\t\t\t\tsubField.slug,\n\t\t\t\t\tsubField.required ? `${name}: ${type}` : `${name}?: ${type} | null`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn `{ ${[...members.values()].join(\"; \")} }[]`;\n\t\t}\n\n\t\tcase \"portableText\":\n\t\t\treturn \"PortableTextBlock[]\";\n\n\t\tcase \"image\": {\n\t\t\tconst media =\n\t\t\t\t\"{ id: string; src?: string; alt?: string; width?: number; height?: number; filename?: string; mimeType?: string; blurhash?: string; dominantColor?: string; provider?: string; previewUrl?: string; meta?: Record<string, unknown> }\";\n\t\t\treturn `${media.slice(0, -2)}; darkVariant?: ${media} }`;\n\t\t}\n\n\t\tcase \"file\":\n\t\t\treturn \"{ id: string; url?: string; src?: string; filename?: string; mimeType?: string; size?: number; provider?: string; meta?: Record<string, unknown> }\";\n\n\t\tcase \"reference\":\n\t\t\t// Could be enhanced to include the referenced collection type\n\t\t\treturn \"string\";\n\n\t\tcase \"json\":\n\t\t\treturn \"unknown\";\n\n\t\tdefault:\n\t\t\treturn \"unknown\";\n\t}\n}\n\n/**\n * Convert string to PascalCase (handles slugs, spaces, etc.)\n */\nfunction pascalCase(str: string): string {\n\treturn str\n\t\t.split(PASCAL_CASE_SPLIT_PATTERN)\n\t\t.filter(Boolean)\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\"\");\n}\n\n/**\n * Naive singularization for slug-derived interface names. Handles the common\n * English plural endings; intentionally simple, not a full inflector.\n */\nfunction singularize(str: string): string {\n\tif (str.endsWith(\"ies\")) {\n\t\treturn str.slice(0, -3) + \"y\";\n\t}\n\tif (\n\t\tstr.endsWith(\"es\") &&\n\t\t(str.endsWith(\"sses\") || str.endsWith(\"xes\") || str.endsWith(\"ches\") || str.endsWith(\"shes\"))\n\t) {\n\t\treturn str.slice(0, -2);\n\t}\n\tif (str.endsWith(\"s\") && !str.endsWith(\"ss\")) {\n\t\treturn str.slice(0, -1);\n\t}\n\treturn str;\n}\n\n/**\n * Get the interface name for a collection.\n *\n * Derived from the slug, not the human label. Slugs are constrained to\n * `/^[a-z][a-z0-9_]*$/`, so PascalCasing one always yields a valid TS\n * identifier; labels are arbitrary and user-controlled (punctuation, spaces,\n * duplicates across collections), which produced syntactically invalid or\n * duplicate interface names. The slug is singularized first because the\n * interface describes a single entry, not the collection (`posts` -> `Post`).\n *\n * Singularization can map two distinct slugs onto the same name, so callers\n * generating more than one interface must dedupe -- see `uniqueInterfaceNames`.\n */\nfunction getInterfaceName(collection: CollectionWithFields): string {\n\treturn pascalCase(singularize(collection.slug));\n}\n\n/**\n * Resolve interface names for a set of collections, guaranteeing each is\n * unique within the file. Collisions (from singularization or PascalCasing\n * collapsing distinct slugs) get a numeric suffix in collection order, so the\n * generated `.d.ts` never declares two interfaces with the same identifier.\n *\n * The suffix is chosen against the set of names already emitted, not a\n * per-base counter, so a generated name can't collide with another slug's\n * base name (e.g. slugs `book`, `books`, `book2`: `books` -> `Book2` would\n * clash with `book2`, so it advances to `Book3`).\n */\nexport function uniqueInterfaceNames(collections: CollectionWithFields[]): Map<string, string> {\n\tconst used = new Set<string>();\n\tconst names = new Map<string, string>();\n\tfor (const collection of collections) {\n\t\tconst base = getInterfaceName(collection);\n\t\tlet name = base;\n\t\tlet suffix = 2;\n\t\twhile (used.has(name)) {\n\t\t\tname = `${base}${suffix}`;\n\t\t\tsuffix++;\n\t\t}\n\t\tused.add(name);\n\t\tnames.set(collection.slug, name);\n\t}\n\treturn names;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAMA,MAAM,4BAA4B;;;;;;;AAQlC,SAAgB,kBACf,YACuC;CACvC,MAAM,QAAiC,EAAE;AAEzC,MAAK,MAAM,SAAS,WAAW,OAC9B,OAAM,MAAM,QAAQ,oBAAoB,MAAM;AAG/C,QAAO,EAAE,OAAO,MAAM;;;;;AAMvB,SAAgB,oBAAoB,OAAuB;CAC1D,IAAI,SAAS,cAAc,MAAM,MAAM,MAAM;AAG7C,KAAI,MAAM,WACT,UAAS,gBAAgB,QAAQ,MAAM;AAWxC,KAAI,CAAC,MAAM,SACV,UAAS,OAAO,SAAS;AAI1B,KAAI,MAAM,iBAAiB,OAC1B,UAAS,OAAO,QAAQ,MAAM,aAAa;AAG5C,QAAO;;;;;AAMR,SAAS,cAAc,MAAiB,OAA2C;AAClF,SAAQ,MAAR;EACC,KAAK,MACJ,QAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;EAEjC,KAAK;EACL,KAAK;EACL,KAAK,OACJ,QAAO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GAAG,CAAC,kBAAkB,MAAM;;EAGtD,KAAK,OACJ,QAAO;EAER,KAAK,YAEJ,QAAO;EAER,KAAK,OACJ,QAAO;EAER,QACC,QAAO;;;;;;AAOV,SAAS,WAAW,KAAqB;AACxC,QAAO,IACL,MAAM,0BAA0B,CAChC,OAAO,QAAQ,CACf,KAAK,SAAS,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE,CAAC,aAAa,CAAC,CACzE,KAAK,GAAG;;;;;;AAOX,SAAS,YAAY,KAAqB;AACzC,KAAI,IAAI,SAAS,MAAM,CACtB,QAAO,IAAI,MAAM,GAAG,GAAG,GAAG;AAE3B,KACC,IAAI,SAAS,KAAK,KACjB,IAAI,SAAS,OAAO,IAAI,IAAI,SAAS,MAAM,IAAI,IAAI,SAAS,OAAO,IAAI,IAAI,SAAS,OAAO,EAE5F,QAAO,IAAI,MAAM,GAAG,GAAG;AAExB,KAAI,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,SAAS,KAAK,CAC3C,QAAO,IAAI,MAAM,GAAG,GAAG;AAExB,QAAO;;;;;;;;;;;;;;;AAgBR,SAAS,iBAAiB,YAA0C;AACnE,QAAO,WAAW,YAAY,WAAW,KAAK,CAAC;;;;;;;;;;;;;AAchD,SAAgB,qBAAqB,aAA0D;CAC9F,MAAM,uBAAO,IAAI,KAAa;CAC9B,MAAM,wBAAQ,IAAI,KAAqB;AACvC,MAAK,MAAM,cAAc,aAAa;EACrC,MAAM,OAAO,iBAAiB,WAAW;EACzC,IAAI,OAAO;EACX,IAAI,SAAS;AACb,SAAO,KAAK,IAAI,KAAK,EAAE;AACtB,UAAO,GAAG,OAAO;AACjB;;AAED,OAAK,IAAI,KAAK;AACd,QAAM,IAAI,WAAW,MAAM,KAAK;;AAEjC,QAAO"}
1
+ {"version":3,"file":"zod-generator-CNRGdnBY.mjs","names":[],"sources":["../src/schema/zod-generator.ts"],"sourcesContent":["import { z, type ZodType } from \"zod\";\n\nimport { hashString } from \"../utils/hash.js\";\nimport type { CollectionWithFields, Field, FieldType, RepeaterSubField } from \"./types.js\";\n\n/** Pattern to split on underscores, hyphens, and spaces for PascalCase conversion */\nconst PASCAL_CASE_SPLIT_PATTERN = /[_\\-\\s]+/;\n\n/**\n * Generate a Zod schema from a collection's field definitions\n *\n * This allows runtime validation of content based on dynamically\n * defined schemas stored in D1.\n */\nexport function generateZodSchema(\n\tcollection: CollectionWithFields,\n): z.ZodObject<Record<string, ZodType>> {\n\tconst shape: Record<string, ZodType> = {};\n\n\tfor (const field of collection.fields) {\n\t\tshape[field.slug] = generateFieldSchema(field);\n\t}\n\n\treturn z.object(shape);\n}\n\n/**\n * Generate Zod schema for a single field\n */\nexport function generateFieldSchema(field: Field): ZodType {\n\tlet schema = getBaseSchema(field.type, field);\n\n\t// Apply validation rules\n\tif (field.validation) {\n\t\tschema = applyValidation(schema, field);\n\t}\n\n\t// Apply required/optional. Non-required fields use `.nullish()` rather\n\t// than `.optional()` because the underlying SQLite columns are nullable\n\t// (see `SchemaRegistry.addFieldColumn` -- non-required fields are added\n\t// without `NOT NULL`). The admin re-sends what it loaded from the\n\t// server on autosave, so any field that's actually `null` in the DB\n\t// must round-trip cleanly through the validator. `.optional()` only\n\t// accepts `undefined`; `.nullish()` accepts both `undefined` and\n\t// `null`. (#867 — autosave failures on seeded entries.)\n\tif (!field.required) {\n\t\tschema = schema.nullish();\n\t}\n\n\t// Apply default value\n\tif (field.defaultValue !== undefined) {\n\t\tschema = schema.default(field.defaultValue);\n\t}\n\n\treturn schema;\n}\n\n/**\n * Get base Zod schema for a field type\n */\nfunction getBaseSchema(type: FieldType, field: Pick<Field, \"validation\">): ZodType {\n\tswitch (type) {\n\t\tcase \"url\":\n\t\t\treturn z.string().check(z.url());\n\n\t\tcase \"string\":\n\t\tcase \"text\":\n\t\tcase \"slug\":\n\t\t\treturn z.string();\n\n\t\tcase \"number\":\n\t\t\treturn z.number();\n\n\t\tcase \"integer\":\n\t\t\treturn z.number().int();\n\n\t\tcase \"boolean\":\n\t\t\t// Boolean fields map to `INTEGER` columns (`FIELD_TYPE_TO_COLUMN`\n\t\t\t// in `schema/types.ts`) and `serializeValue` in\n\t\t\t// `database/repositories/content.ts` writes booleans as 0/1.\n\t\t\t// `deserializeValue` never converts them back, so reads return\n\t\t\t// numbers. Coerce the stored 0/1 shape here so a GET → POST\n\t\t\t// round-trip on a boolean field passes validation. Other inputs\n\t\t\t// (strings, other numbers) fall through to `z.boolean()` and\n\t\t\t// produce its standard rejection.\n\t\t\treturn z.preprocess((v) => (v === 0 || v === 1 ? Boolean(v) : v), z.boolean());\n\n\t\tcase \"datetime\":\n\t\t\t// Accept every value that legitimately round-trips through the admin\n\t\t\t// and seeds: ISO with `Z`, ISO with a timezone offset, a naive\n\t\t\t// datetime (`YYYY-MM-DDTHH:mm[:ss]` -- what `<input type=\"datetime-local\">`\n\t\t\t// and many seeds produce), and a date-only value. The admin re-sends\n\t\t\t// every loaded field on autosave, so a stored naive datetime must\n\t\t\t// validate or the entry becomes unsavable through its own editor\n\t\t\t// (#1368; same class as #867). `z.iso.*` retains semantic validation,\n\t\t\t// so impossible dates are still rejected.\n\t\t\treturn z.iso\n\t\t\t\t.datetime({ offset: true, local: true })\n\t\t\t\t.or(z.iso.datetime({ offset: true, local: true, precision: -1 }))\n\t\t\t\t.or(z.iso.date());\n\n\t\tcase \"select\": {\n\t\t\tconst options = field.validation?.options;\n\t\t\tif (options && options.length > 0) {\n\t\t\t\tconst [first, ...rest] = options;\n\t\t\t\treturn z.enum([first, ...rest]);\n\t\t\t}\n\t\t\treturn z.string();\n\t\t}\n\n\t\tcase \"multiSelect\": {\n\t\t\tconst multiOptions = field.validation?.options;\n\t\t\tif (multiOptions && multiOptions.length > 0) {\n\t\t\t\tconst [first, ...rest] = multiOptions;\n\t\t\t\treturn z.array(z.enum([first, ...rest]));\n\t\t\t}\n\t\t\treturn z.array(z.string());\n\t\t}\n\n\t\tcase \"repeater\":\n\t\t\treturn z.array(generateRepeaterRowSchema(field.validation?.subFields ?? []));\n\n\t\tcase \"portableText\":\n\t\t\t// Portable Text is an array of blocks. We require `_type` because\n\t\t\t// renderers dispatch on it, but `_key` is intentionally optional:\n\t\t\t// it's a UI-layer concern that the editor regenerates on every\n\t\t\t// change (see `PortableTextEditor`), and the rest of this schema\n\t\t\t// uses `.loose()` for everything below the top level. Making\n\t\t\t// `_key` strictly required here was an accidentally tight invariant\n\t\t\t// that rejected any seed/import data not authored against the\n\t\t\t// editor (#867 — autosave failures on seeded template content).\n\t\t\treturn z.array(\n\t\t\t\tz\n\t\t\t\t\t.object({\n\t\t\t\t\t\t_type: z.string(),\n\t\t\t\t\t\t_key: z.string().optional(),\n\t\t\t\t\t})\n\t\t\t\t\t.loose(),\n\t\t\t);\n\n\t\tcase \"image\": {\n\t\t\tconst mediaSchema = z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\tsrc: z.string().optional(),\n\t\t\t\talt: z.string().optional(),\n\t\t\t\twidth: z.number().optional(),\n\t\t\t\theight: z.number().optional(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\tmimeType: z.string().optional(),\n\t\t\t\tblurhash: z.string().optional(),\n\t\t\t\tdominantColor: z.string().optional(),\n\t\t\t\t/** Provider ID (e.g. \"local\", \"cloudflare-images\") */\n\t\t\t\tprovider: z.string().optional(),\n\t\t\t\t/** Admin-side preview URL for external providers (not persisted by plugins) */\n\t\t\t\tpreviewUrl: z.string().optional(),\n\t\t\t\t/** Provider-specific metadata; for local media this carries storageKey */\n\t\t\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t\t\t});\n\t\t\treturn mediaSchema.extend({\n\t\t\t\t/** Counterpart shown when the page renders in a dark color scheme */\n\t\t\t\tdarkVariant: mediaSchema.optional(),\n\t\t\t});\n\t\t}\n\n\t\tcase \"file\":\n\t\t\treturn z.object({\n\t\t\t\tid: z.string(),\n\t\t\t\turl: z.string().optional(),\n\t\t\t\tsrc: z.string().optional(),\n\t\t\t\tfilename: z.string().optional(),\n\t\t\t\tmimeType: z.string().optional(),\n\t\t\t\tsize: z.number().optional(),\n\t\t\t\t/** Provider ID (e.g. \"local\", \"s3\") */\n\t\t\t\tprovider: z.string().optional(),\n\t\t\t\t/** Provider-specific metadata; for local media this carries storageKey */\n\t\t\t\tmeta: z.record(z.string(), z.unknown()).optional(),\n\t\t\t});\n\n\t\tcase \"reference\":\n\t\t\treturn z.string(); // Reference ID\n\n\t\tcase \"json\":\n\t\t\treturn z.unknown();\n\n\t\tdefault:\n\t\t\treturn z.unknown();\n\t}\n}\n\nfunction generateRepeaterRowSchema(\n\tsubFields: readonly RepeaterSubField[],\n): z.ZodObject<Record<string, ZodType>> {\n\tconst shape: Record<string, ZodType> = {};\n\n\tfor (const subField of subFields) {\n\t\tlet schema = getBaseSchema(subField.type, {\n\t\t\tvalidation: subField.options ? { options: subField.options } : undefined,\n\t\t});\n\n\t\tif (subField.required && schema instanceof z.ZodString) {\n\t\t\tschema = schema.min(1, \"required (empty value not allowed)\");\n\t\t}\n\t\tif (!subField.required) {\n\t\t\tschema = schema.nullish();\n\t\t}\n\n\t\tshape[subField.slug] = schema;\n\t}\n\n\treturn z.object(shape).loose();\n}\n\n/**\n * Apply validation rules to a schema\n */\nfunction applyValidation(schema: ZodType, field: Field): ZodType {\n\tconst validation = field.validation;\n\tif (!validation) return schema;\n\n\t// String validations\n\tif (schema instanceof z.ZodString) {\n\t\tlet strSchema = schema;\n\t\tif (validation.minLength !== undefined) {\n\t\t\tstrSchema = strSchema.min(validation.minLength);\n\t\t}\n\t\tif (validation.maxLength !== undefined) {\n\t\t\tstrSchema = strSchema.max(validation.maxLength);\n\t\t}\n\t\tif (validation.pattern) {\n\t\t\tstrSchema = strSchema.regex(new RegExp(validation.pattern));\n\t\t}\n\t\treturn strSchema;\n\t}\n\n\t// Number validations\n\tif (schema instanceof z.ZodNumber) {\n\t\tlet numSchema = schema;\n\t\tif (validation.min !== undefined) {\n\t\t\tnumSchema = numSchema.min(validation.min);\n\t\t}\n\t\tif (validation.max !== undefined) {\n\t\t\tnumSchema = numSchema.max(validation.max);\n\t\t}\n\t\treturn numSchema;\n\t}\n\n\tif (field.type === \"repeater\" && schema instanceof z.ZodArray) {\n\t\tlet arraySchema = schema;\n\t\tif (validation.minItems !== undefined) {\n\t\t\tarraySchema = arraySchema.min(validation.minItems);\n\t\t}\n\t\tif (validation.maxItems !== undefined) {\n\t\t\tarraySchema = arraySchema.max(validation.maxItems);\n\t\t}\n\t\treturn arraySchema;\n\t}\n\n\treturn schema;\n}\n\n/**\n * Schema cache to avoid regenerating schemas on every request\n */\nconst schemaCache = new Map<string, { schema: z.ZodObject<any>; version: string }>();\n\n/**\n * Get or generate a cached schema for a collection\n */\nexport function getCachedSchema(\n\tcollection: CollectionWithFields,\n\tversion?: string,\n): z.ZodObject<any> {\n\tconst cacheKey = collection.slug;\n\tconst cached = schemaCache.get(cacheKey);\n\n\t// If version matches, return cached schema\n\tif (cached && (!version || cached.version === version)) {\n\t\treturn cached.schema;\n\t}\n\n\t// Generate new schema\n\tconst schema = generateZodSchema(collection);\n\n\t// Cache it\n\tschemaCache.set(cacheKey, {\n\t\tschema,\n\t\tversion: version || collection.updatedAt,\n\t});\n\n\treturn schema;\n}\n\n/**\n * Invalidate cached schema for a collection\n */\nexport function invalidateSchemaCache(slug: string): void {\n\tschemaCache.delete(slug);\n}\n\n/**\n * Clear all cached schemas\n */\nexport function clearSchemaCache(): void {\n\tschemaCache.clear();\n}\n\n/**\n * Validate data against a collection's schema\n */\nexport function validateContent(\n\tcollection: CollectionWithFields,\n\tdata: unknown,\n): { success: true; data: unknown } | { success: false; errors: z.ZodError } {\n\tconst schema = getCachedSchema(collection);\n\n\tconst result = schema.safeParse(data);\n\n\tif (result.success) {\n\t\treturn { success: true, data: result.data };\n\t}\n\n\treturn { success: false, errors: result.error };\n}\n\n/**\n * Generate TypeScript interface from field definitions\n * Used by CLI `emdash types` to generate types\n */\nexport function generateTypeScript(\n\tcollection: CollectionWithFields,\n\tinterfaceName: string = getInterfaceName(collection),\n): string {\n\tconst lines: string[] = [];\n\n\tlines.push(`export interface ${interfaceName} {`);\n\tlines.push(` id: string;`);\n\tlines.push(` slug: string | null;`);\n\tlines.push(` status: string;`);\n\n\tfor (const field of collection.fields) {\n\t\tconst tsType = fieldTypeToTypeScript(field);\n\t\tconst optional = field.required ? \"\" : \"?\";\n\t\tlines.push(` ${field.slug}${optional}: ${tsType};`);\n\t}\n\n\tlines.push(` createdAt: Date;`);\n\tlines.push(` updatedAt: Date;`);\n\tlines.push(` publishedAt: Date | null;`);\n\t// Bylines are eagerly loaded by getEmDashCollection/getEmDashEntry\n\tlines.push(` bylines?: ContentBylineCredit[];`);\n\t// Taxonomy terms are eagerly loaded by getEmDashCollection/getEmDashEntry,\n\t// keyed by taxonomy name (e.g. data.terms?.tag)\n\tlines.push(` terms?: Record<string, TaxonomyTerm[]>;`);\n\tlines.push(`}`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generate a complete types file with module augmentation\n * This produces emdash-env.d.ts content that provides typed query functions\n */\nexport function generateTypesFile(collections: CollectionWithFields[]): string {\n\tconst lines: string[] = [];\n\n\t// Header\n\tlines.push(`// Generated by EmDash on dev server start`);\n\tlines.push(`// Do not edit manually`);\n\tlines.push(``);\n\tlines.push(`/// <reference types=\"emdash/locals\" />`);\n\tlines.push(``);\n\n\t// Check if we need PortableTextBlock import\n\tconst needsPortableText = collections.some((c) =>\n\t\tc.fields.some((f) => f.type === \"portableText\"),\n\t);\n\n\t// Build imports - ContentBylineCredit and TaxonomyTerm are always needed\n\t// for the hydrated bylines/terms fields\n\tconst imports = [\"ContentBylineCredit\", \"TaxonomyTerm\"];\n\tif (needsPortableText) {\n\t\timports.push(\"PortableTextBlock\");\n\t}\n\tlines.push(`import type { ${imports.join(\", \")} } from \"emdash\";`);\n\tlines.push(``);\n\n\t// Singularizing the slug can map two distinct slugs to the same name\n\t// (e.g. `book` and `books` both -> `Book`), so resolve collisions up front\n\t// to keep every interface identifier unique within the file.\n\tconst interfaceNames = uniqueInterfaceNames(collections);\n\n\t// Generate individual interfaces\n\tfor (const collection of collections) {\n\t\tlines.push(generateTypeScript(collection, interfaceNames.get(collection.slug)));\n\t\tlines.push(``);\n\t}\n\n\t// Generate the Collections interface for module augmentation\n\tlines.push(`declare module \"emdash\" {`);\n\tlines.push(` interface EmDashCollections {`);\n\tfor (const collection of collections) {\n\t\tlines.push(` ${collection.slug}: ${interfaceNames.get(collection.slug)};`);\n\t}\n\tlines.push(` }`);\n\tlines.push(`}`);\n\n\treturn lines.join(\"\\n\");\n}\n\n/**\n * Generate schema hash for cache invalidation\n */\nexport async function generateSchemaHash(collections: CollectionWithFields[]): Promise<string> {\n\tconst str = JSON.stringify(\n\t\tcollections.map((c) => ({\n\t\t\tslug: c.slug,\n\t\t\tfields: c.fields.map((f) => ({\n\t\t\t\tslug: f.slug,\n\t\t\t\ttype: f.type,\n\t\t\t\trequired: f.required,\n\t\t\t\tvalidation: f.validation,\n\t\t\t})),\n\t\t})),\n\t);\n\treturn hashString(str);\n}\n\n/**\n * Map field type to TypeScript type\n */\nfunction fieldTypeToTypeScript(field: {\n\ttype: Field[\"type\"];\n\tvalidation?: Field[\"validation\"];\n}): string {\n\tswitch (field.type) {\n\t\tcase \"string\":\n\t\tcase \"text\":\n\t\tcase \"slug\":\n\t\tcase \"url\":\n\t\tcase \"datetime\":\n\t\t\treturn \"string\";\n\n\t\tcase \"number\":\n\t\tcase \"integer\":\n\t\t\treturn \"number\";\n\n\t\tcase \"boolean\":\n\t\t\treturn \"boolean\";\n\n\t\tcase \"select\":\n\t\t\tconst options = field.validation?.options;\n\t\t\tif (options && options.length > 0) {\n\t\t\t\treturn options.map((o) => `\"${o}\"`).join(\" | \");\n\t\t\t}\n\t\t\treturn \"string\";\n\n\t\tcase \"multiSelect\":\n\t\t\tconst multiOptions = field.validation?.options;\n\t\t\tif (multiOptions && multiOptions.length > 0) {\n\t\t\t\treturn `(${multiOptions.map((o) => `\"${o}\"`).join(\" | \")})[]`;\n\t\t\t}\n\t\t\treturn \"string[]\";\n\n\t\tcase \"repeater\": {\n\t\t\tconst subFields = field.validation?.subFields;\n\t\t\t// `validation` is unvalidated JSON on the seed and registry paths.\n\t\t\tif (!Array.isArray(subFields) || subFields.length === 0) return \"unknown\";\n\n\t\t\t// A duplicated slug keeps its first position and last declaration, as\n\t\t\t// `generateRepeaterRowSchema`'s `shape[subField.slug]` does.\n\t\t\tconst members = new Map<string, string>();\n\n\t\t\tfor (const subField of subFields) {\n\t\t\t\tconst type = fieldTypeToTypeScript({\n\t\t\t\t\ttype: subField.type,\n\t\t\t\t\tvalidation: subField.options ? { options: subField.options } : undefined,\n\t\t\t\t});\n\t\t\t\t// A sub-field slug is not guaranteed to be a valid identifier, so it is\n\t\t\t\t// quoted rather than emitted bare.\n\t\t\t\tconst name = JSON.stringify(subField.slug);\n\t\t\t\t// A sub-field that is not required may be null at runtime.\n\t\t\t\tmembers.set(\n\t\t\t\t\tsubField.slug,\n\t\t\t\t\tsubField.required ? `${name}: ${type}` : `${name}?: ${type} | null`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn `{ ${[...members.values()].join(\"; \")} }[]`;\n\t\t}\n\n\t\tcase \"portableText\":\n\t\t\treturn \"PortableTextBlock[]\";\n\n\t\tcase \"image\": {\n\t\t\tconst media =\n\t\t\t\t\"{ id: string; src?: string; alt?: string; width?: number; height?: number; filename?: string; mimeType?: string; blurhash?: string; dominantColor?: string; provider?: string; previewUrl?: string; meta?: Record<string, unknown> }\";\n\t\t\treturn `${media.slice(0, -2)}; darkVariant?: ${media} }`;\n\t\t}\n\n\t\tcase \"file\":\n\t\t\treturn \"{ id: string; url?: string; src?: string; filename?: string; mimeType?: string; size?: number; provider?: string; meta?: Record<string, unknown> }\";\n\n\t\tcase \"reference\":\n\t\t\t// Could be enhanced to include the referenced collection type\n\t\t\treturn \"string\";\n\n\t\tcase \"json\":\n\t\t\treturn \"unknown\";\n\n\t\tdefault:\n\t\t\treturn \"unknown\";\n\t}\n}\n\n/**\n * Convert string to PascalCase (handles slugs, spaces, etc.)\n */\nfunction pascalCase(str: string): string {\n\treturn str\n\t\t.split(PASCAL_CASE_SPLIT_PATTERN)\n\t\t.filter(Boolean)\n\t\t.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n\t\t.join(\"\");\n}\n\n/**\n * Naive singularization for slug-derived interface names. Handles the common\n * English plural endings; intentionally simple, not a full inflector.\n */\nfunction singularize(str: string): string {\n\tif (str.endsWith(\"ies\")) {\n\t\treturn str.slice(0, -3) + \"y\";\n\t}\n\tif (\n\t\tstr.endsWith(\"es\") &&\n\t\t(str.endsWith(\"sses\") || str.endsWith(\"xes\") || str.endsWith(\"ches\") || str.endsWith(\"shes\"))\n\t) {\n\t\treturn str.slice(0, -2);\n\t}\n\tif (str.endsWith(\"s\") && !str.endsWith(\"ss\")) {\n\t\treturn str.slice(0, -1);\n\t}\n\treturn str;\n}\n\n/**\n * Get the interface name for a collection.\n *\n * Derived from the slug, not the human label. Slugs are constrained to\n * `/^[a-z][a-z0-9_]*$/`, so PascalCasing one always yields a valid TS\n * identifier; labels are arbitrary and user-controlled (punctuation, spaces,\n * duplicates across collections), which produced syntactically invalid or\n * duplicate interface names. The slug is singularized first because the\n * interface describes a single entry, not the collection (`posts` -> `Post`).\n *\n * Singularization can map two distinct slugs onto the same name, so callers\n * generating more than one interface must dedupe -- see `uniqueInterfaceNames`.\n */\nfunction getInterfaceName(collection: CollectionWithFields): string {\n\treturn pascalCase(singularize(collection.slug));\n}\n\n/**\n * Resolve interface names for a set of collections, guaranteeing each is\n * unique within the file. Collisions (from singularization or PascalCasing\n * collapsing distinct slugs) get a numeric suffix in collection order, so the\n * generated `.d.ts` never declares two interfaces with the same identifier.\n *\n * The suffix is chosen against the set of names already emitted, not a\n * per-base counter, so a generated name can't collide with another slug's\n * base name (e.g. slugs `book`, `books`, `book2`: `books` -> `Book2` would\n * clash with `book2`, so it advances to `Book3`).\n */\nexport function uniqueInterfaceNames(collections: CollectionWithFields[]): Map<string, string> {\n\tconst used = new Set<string>();\n\tconst names = new Map<string, string>();\n\tfor (const collection of collections) {\n\t\tconst base = getInterfaceName(collection);\n\t\tlet name = base;\n\t\tlet suffix = 2;\n\t\twhile (used.has(name)) {\n\t\t\tname = `${base}${suffix}`;\n\t\t\tsuffix++;\n\t\t}\n\t\tused.add(name);\n\t\tnames.set(collection.slug, name);\n\t}\n\treturn names;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAMA,MAAM,4BAA4B;;;;;;;AAQlC,SAAgB,kBACf,YACuC;CACvC,MAAM,QAAiC,EAAE;AAEzC,MAAK,MAAM,SAAS,WAAW,OAC9B,OAAM,MAAM,QAAQ,oBAAoB,MAAM;AAG/C,QAAO,EAAE,OAAO,MAAM;;;;;AAMvB,SAAgB,oBAAoB,OAAuB;CAC1D,IAAI,SAAS,cAAc,MAAM,MAAM,MAAM;AAG7C,KAAI,MAAM,WACT,UAAS,gBAAgB,QAAQ,MAAM;AAWxC,KAAI,CAAC,MAAM,SACV,UAAS,OAAO,SAAS;AAI1B,KAAI,MAAM,iBAAiB,OAC1B,UAAS,OAAO,QAAQ,MAAM,aAAa;AAG5C,QAAO;;;;;AAMR,SAAS,cAAc,MAAiB,OAA2C;AAClF,SAAQ,MAAR;EACC,KAAK,MACJ,QAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;EAEjC,KAAK;EACL,KAAK;EACL,KAAK,OACJ,QAAO,EAAE,QAAQ;EAElB,KAAK,SACJ,QAAO,EAAE,QAAQ;EAElB,KAAK,UACJ,QAAO,EAAE,QAAQ,CAAC,KAAK;EAExB,KAAK,UASJ,QAAO,EAAE,YAAY,MAAO,MAAM,KAAK,MAAM,IAAI,QAAQ,EAAE,GAAG,GAAI,EAAE,SAAS,CAAC;EAE/E,KAAK,WASJ,QAAO,EAAE,IACP,SAAS;GAAE,QAAQ;GAAM,OAAO;GAAM,CAAC,CACvC,GAAG,EAAE,I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;AAOX,SAAS,YAAY,KAAqB;AACzC,KAAI,IAAI,SAAS,MAAM,CACtB,QAAO,IAAI,MAAM,GAAG,GAAG,GAAG;AAE3B,KACC,IAAI,SAAS,KAAK,KACjB,IAAI,SAAS,OAAO,IAAI,IAAI,SAAS,MAAM,IAAI,IAAI,SAAS,OAAO,IAAI,IAAI,SAAS,OAAO,EAE5F,QAAO,IAAI,MAAM,GAAG,GAAG;AAExB,KAAI,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,SAAS,KAAK,CAC3C,QAAO,IAAI,MAAM,GAAG,GAAG;AAExB,QAAO;;;;;;;;;;;;;;;AAgBR,SAAS,iBAAiB,YAA0C;AACnE,QAAO,WAAW,YAAY,WAAW,KAAK,CAAC;;;;;;;;;;;;;AAchD,SAAgB,qBAAqB,aAA0D;CAC9F,MAAM,uBAAO,IAAI,KAAa;CAC9B,MAAM,wBAAQ,IAAI,KAAqB;AACvC,MAAK,MAAM,cAAc,aAAa;EACrC,MAAM,OAAO,iBAAiB,WAAW;EACzC,IAAI,OAAO;EACX,IAAI,SAAS;AACb,SAAO,KAAK,IAAI,KAAK,EAAE;AACtB,UAAO,GAAG,OAAO;AACjB;;AAED,OAAK,IAAI,KAAK;AACd,QAAM,IAAI,WAAW,MAAM,KAAK;;AAEjC,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emdash",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "Astro-native CMS with WordPress migration support",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -262,13 +262,13 @@
262
262
  "upng-js": "^2.1.0",
263
263
  "zod": "4.5.4",
264
264
  "@atcute/client": "^5.0.0",
265
- "@emdash-cms/admin": "0.37.0",
266
- "@emdash-cms/auth": "0.37.0",
265
+ "@emdash-cms/admin": "0.38.0",
266
+ "@emdash-cms/auth": "0.38.0",
267
+ "@emdash-cms/gutenberg-to-portable-text": "0.38.0",
267
268
  "@emdash-cms/plugin-types": "0.3.1",
268
- "@emdash-cms/registry-client": "0.5.0",
269
- "@emdash-cms/gutenberg-to-portable-text": "0.37.0",
270
- "@emdash-cms/registry-lexicons": "0.4.0",
271
- "@emdash-cms/registry-verification": "0.3.0"
269
+ "@emdash-cms/registry-client": "0.6.0",
270
+ "@emdash-cms/registry-lexicons": "0.5.0",
271
+ "@emdash-cms/registry-verification": "0.3.1"
272
272
  },
273
273
  "optionalDependencies": {
274
274
  "@libsql/kysely-libsql": "^0.4.0",
@@ -289,7 +289,8 @@
289
289
  "devDependencies": {
290
290
  "@apidevtools/swagger-parser": "^12.1.0",
291
291
  "@arethetypeswrong/cli": "^0.18.2",
292
- "@cloudflare/vitest-pool-workers": "^0.16.3",
292
+ "@astrojs/react": "^6.0.5",
293
+ "@cloudflare/vitest-plugin": "^1.0.0",
293
294
  "@types/better-sqlite3": "^7.6.12",
294
295
  "better-sqlite3": "^12.8.0",
295
296
  "@types/pg": "^8.16.0",
@@ -297,6 +298,7 @@
297
298
  "@types/sanitize-html": "^2.16.0",
298
299
  "@types/sax": "^1.2.7",
299
300
  "@vitest/ui": "^4.1.10",
301
+ "astro": "^7.3.2",
300
302
  "image-size": "2.0.2",
301
303
  "publint": "0.3.17",
302
304
  "tsdown": "0.20.3",
@@ -305,8 +307,8 @@
305
307
  "vitest": "^4.1.5",
306
308
  "zod-openapi": "^5.4.6",
307
309
  "@emdash-cms/atproto-test-utils": "0.0.0",
308
- "@emdash-cms/registry-verification": "0.3.0",
309
- "@emdash-cms/blocks": "0.37.0"
310
+ "@emdash-cms/blocks": "0.38.0",
311
+ "@emdash-cms/registry-verification": "0.3.1"
310
312
  },
311
313
  "repository": {
312
314
  "type": "git",
package/src/api/errors.ts CHANGED
@@ -16,6 +16,8 @@ export const ErrorCode = {
16
16
  CONFLICT: "CONFLICT",
17
17
  SLUG_CONFLICT: "SLUG_CONFLICT",
18
18
  NOT_CONFIGURED: "NOT_CONFIGURED",
19
+ BINDING_NOT_FOUND: "BINDING_NOT_FOUND",
20
+ CONFIGURATION_ERROR: "CONFIGURATION_ERROR",
19
21
  UNAUTHORIZED: "UNAUTHORIZED",
20
22
  FORBIDDEN: "FORBIDDEN",
21
23
  RATE_LIMITED: "RATE_LIMITED",
@@ -111,6 +113,8 @@ export const ErrorCode = {
111
113
  MEDIA_USAGE_ACTIVATION_ADVANCE_ERROR: "MEDIA_USAGE_ACTIVATION_ADVANCE_ERROR",
112
114
  WORK_LEASE_ACTIVE: "WORK_LEASE_ACTIVE",
113
115
  WORK_CHANGED: "WORK_CHANGED",
116
+ ENTRY_LOCKED: "ENTRY_LOCKED",
117
+ ENTRY_LOCK_ERROR: "ENTRY_LOCK_ERROR",
114
118
  NO_STORAGE: "NO_STORAGE",
115
119
  NO_FILE: "NO_FILE",
116
120
  INVALID_TYPE: "INVALID_TYPE",
@@ -478,6 +482,7 @@ export function mapErrorStatus(code: string | undefined): number {
478
482
  case ErrorCode.ENV_INCOMPATIBLE:
479
483
  case ErrorCode.WORK_LEASE_ACTIVE:
480
484
  case ErrorCode.WORK_CHANGED:
485
+ case ErrorCode.ENTRY_LOCKED:
481
486
  case ErrorCode.MEDIA_USAGE_ACTIVATION_VERSION_MISMATCH:
482
487
  case ErrorCode.MEDIA_USAGE_ACTIVATION_BUSY:
483
488
  case ErrorCode.MEDIA_USAGE_ACTIVATION_CONFLICT:
@@ -501,6 +506,8 @@ export function mapErrorStatus(code: string | undefined): number {
501
506
 
502
507
  // 500 Internal Server Error
503
508
  case ErrorCode.NOT_CONFIGURED:
509
+ case ErrorCode.BINDING_NOT_FOUND:
510
+ case ErrorCode.CONFIGURATION_ERROR:
504
511
  case ErrorCode.NO_STORAGE:
505
512
  case ErrorCode.NO_DB:
506
513
  case ErrorCode.STORAGE_NOT_CONFIGURED: