emdash 0.8.0 → 0.9.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 (286) hide show
  1. package/dist/{adapters-BKSf3T9R.d.mts → adapters-DoNJiveC.d.mts} +1 -1
  2. package/dist/{adapters-BKSf3T9R.d.mts.map → adapters-DoNJiveC.d.mts.map} +1 -1
  3. package/dist/{apply-x0eMK1lX.mjs → apply-BzltprvY.mjs} +85 -135
  4. package/dist/apply-BzltprvY.mjs.map +1 -0
  5. package/dist/astro/index.d.mts +6 -6
  6. package/dist/astro/index.d.mts.map +1 -1
  7. package/dist/astro/index.mjs +110 -4
  8. package/dist/astro/index.mjs.map +1 -1
  9. package/dist/astro/middleware/auth.d.mts +6 -7
  10. package/dist/astro/middleware/auth.d.mts.map +1 -1
  11. package/dist/astro/middleware/auth.mjs +16 -59
  12. package/dist/astro/middleware/auth.mjs.map +1 -1
  13. package/dist/astro/middleware/redirect.d.mts.map +1 -1
  14. package/dist/astro/middleware/redirect.mjs +17 -12
  15. package/dist/astro/middleware/redirect.mjs.map +1 -1
  16. package/dist/astro/middleware/request-context.d.mts.map +1 -1
  17. package/dist/astro/middleware/request-context.mjs +9 -6
  18. package/dist/astro/middleware/request-context.mjs.map +1 -1
  19. package/dist/astro/middleware/setup.mjs +1 -1
  20. package/dist/astro/middleware.d.mts.map +1 -1
  21. package/dist/astro/middleware.mjs +72 -124
  22. package/dist/astro/middleware.mjs.map +1 -1
  23. package/dist/astro/types.d.mts +26 -10
  24. package/dist/astro/types.d.mts.map +1 -1
  25. package/dist/{base64-MBPo9ozB.mjs → base64-BRICGH2l.mjs} +1 -1
  26. package/dist/{base64-MBPo9ozB.mjs.map → base64-BRICGH2l.mjs.map} +1 -1
  27. package/dist/{byline-Chbr2GoP.mjs → byline-BSaNL1w7.mjs} +4 -4
  28. package/dist/{byline-Chbr2GoP.mjs.map → byline-BSaNL1w7.mjs.map} +1 -1
  29. package/dist/bylines-CvJ3PYz2.mjs +113 -0
  30. package/dist/bylines-CvJ3PYz2.mjs.map +1 -0
  31. package/dist/cache-C6N_hhN7.mjs +65 -0
  32. package/dist/cache-C6N_hhN7.mjs.map +1 -0
  33. package/dist/{chunks-HGz06Soa.mjs → chunks-NBQVDOci.mjs} +8 -2
  34. package/dist/{chunks-HGz06Soa.mjs.map → chunks-NBQVDOci.mjs.map} +1 -1
  35. package/dist/cli/index.mjs +224 -30
  36. package/dist/cli/index.mjs.map +1 -1
  37. package/dist/client/cf-access.d.mts +1 -1
  38. package/dist/client/index.d.mts +1 -1
  39. package/dist/client/index.mjs +3 -3
  40. package/dist/client/index.mjs.map +1 -1
  41. package/dist/{config-BXwuX8Bx.mjs → config-BI0V3ICQ.mjs} +1 -1
  42. package/dist/{config-BXwuX8Bx.mjs.map → config-BI0V3ICQ.mjs.map} +1 -1
  43. package/dist/{content-BcQPYxdV.mjs → content-8lOYF0pr.mjs} +32 -15
  44. package/dist/{content-BcQPYxdV.mjs.map → content-8lOYF0pr.mjs.map} +1 -1
  45. package/dist/db/index.d.mts +3 -3
  46. package/dist/db/index.mjs +2 -2
  47. package/dist/db/libsql.d.mts +1 -1
  48. package/dist/db/libsql.d.mts.map +1 -1
  49. package/dist/db/libsql.mjs +7 -2
  50. package/dist/db/libsql.mjs.map +1 -1
  51. package/dist/db/postgres.d.mts +1 -1
  52. package/dist/db/sqlite.d.mts +1 -1
  53. package/dist/db/sqlite.d.mts.map +1 -1
  54. package/dist/db/sqlite.mjs +8 -3
  55. package/dist/db/sqlite.mjs.map +1 -1
  56. package/dist/{db-errors-l1Qh2RPR.mjs → db-errors-WRezodiz.mjs} +1 -1
  57. package/dist/{db-errors-l1Qh2RPR.mjs.map → db-errors-WRezodiz.mjs.map} +1 -1
  58. package/dist/{default-DCVqE5ib.mjs → default-D8ksjWhO.mjs} +1 -1
  59. package/dist/{default-DCVqE5ib.mjs.map → default-D8ksjWhO.mjs.map} +1 -1
  60. package/dist/{dialect-helpers-DhTzaUxP.mjs → dialect-helpers-BKCvISIQ.mjs} +19 -2
  61. package/dist/dialect-helpers-BKCvISIQ.mjs.map +1 -0
  62. package/dist/{error-zG5T1UGA.mjs → error-D_-tqP-I.mjs} +1 -1
  63. package/dist/{error-zG5T1UGA.mjs.map → error-D_-tqP-I.mjs.map} +1 -1
  64. package/dist/{index-DIb-CzNx.d.mts → index-BFRaVcD6.d.mts} +94 -34
  65. package/dist/index-BFRaVcD6.d.mts.map +1 -0
  66. package/dist/index.d.mts +11 -11
  67. package/dist/index.mjs +29 -27
  68. package/dist/{load-CyEoextb.mjs → load-DDqMMvZL.mjs} +2 -2
  69. package/dist/{load-CyEoextb.mjs.map → load-DDqMMvZL.mjs.map} +1 -1
  70. package/dist/{loader-CndGj8kM.mjs → loader-CKLbBnhK.mjs} +27 -7
  71. package/dist/loader-CKLbBnhK.mjs.map +1 -0
  72. package/dist/{manifest-schema-DH9xhc6t.mjs → manifest-schema-DqWNC3lM.mjs} +33 -3
  73. package/dist/manifest-schema-DqWNC3lM.mjs.map +1 -0
  74. package/dist/media/index.d.mts +1 -1
  75. package/dist/media/index.mjs +1 -1
  76. package/dist/media/local-runtime.d.mts +7 -7
  77. package/dist/media/local-runtime.mjs +3 -3
  78. package/dist/{media-D8FbNsl0.mjs → media-BW32b4gi.mjs} +2 -2
  79. package/dist/{media-D8FbNsl0.mjs.map → media-BW32b4gi.mjs.map} +1 -1
  80. package/dist/{mode-BnAOqItE.mjs → mode-ier8jbBk.mjs} +1 -1
  81. package/dist/{mode-BnAOqItE.mjs.map → mode-ier8jbBk.mjs.map} +1 -1
  82. package/dist/options-BVp3UsTS.mjs +117 -0
  83. package/dist/options-BVp3UsTS.mjs.map +1 -0
  84. package/dist/page/index.d.mts +2 -2
  85. package/dist/{placeholder-D29tWZ7o.d.mts → placeholder-BE4o_2dc.d.mts} +1 -1
  86. package/dist/{placeholder-D29tWZ7o.d.mts.map → placeholder-BE4o_2dc.d.mts.map} +1 -1
  87. package/dist/{placeholder-C-fk5hYI.mjs → placeholder-CIJejMlK.mjs} +1 -1
  88. package/dist/{placeholder-C-fk5hYI.mjs.map → placeholder-CIJejMlK.mjs.map} +1 -1
  89. package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
  90. package/dist/plugins/adapt-sandbox-entry.d.mts.map +1 -1
  91. package/dist/plugins/adapt-sandbox-entry.mjs +6 -5
  92. package/dist/plugins/adapt-sandbox-entry.mjs.map +1 -1
  93. package/dist/public-url-DByxYjUw.mjs +51 -0
  94. package/dist/public-url-DByxYjUw.mjs.map +1 -0
  95. package/dist/{query-fqEdLFms.mjs → query-Cg9ZKRQ0.mjs} +114 -16
  96. package/dist/query-Cg9ZKRQ0.mjs.map +1 -0
  97. package/dist/{redirect-D_pshWdf.mjs → redirect-BhUBKRc1.mjs} +11 -6
  98. package/dist/redirect-BhUBKRc1.mjs.map +1 -0
  99. package/dist/{registry-C3Mr0ODu.mjs → registry-Dw70ChxB.mjs} +38 -4
  100. package/dist/registry-Dw70ChxB.mjs.map +1 -0
  101. package/dist/{request-cache-Ci7f5pBb.mjs → request-cache-B-bmkipQ.mjs} +1 -1
  102. package/dist/{request-cache-Ci7f5pBb.mjs.map → request-cache-B-bmkipQ.mjs.map} +1 -1
  103. package/dist/runner-Bnoj7vjK.d.mts +44 -0
  104. package/dist/runner-Bnoj7vjK.d.mts.map +1 -0
  105. package/dist/{runner-tQ7BJ4T7.mjs → runner-C7ADox5q.mjs} +185 -55
  106. package/dist/{runner-tQ7BJ4T7.mjs.map → runner-C7ADox5q.mjs.map} +1 -1
  107. package/dist/runtime.d.mts +6 -6
  108. package/dist/runtime.mjs +4 -4
  109. package/dist/{search-BoZYFuUk.mjs → search-dOGEccMa.mjs} +129 -83
  110. package/dist/search-dOGEccMa.mjs.map +1 -0
  111. package/dist/secrets-CW3reAnU.mjs +314 -0
  112. package/dist/secrets-CW3reAnU.mjs.map +1 -0
  113. package/dist/seed/index.d.mts +2 -2
  114. package/dist/seed/index.mjs +15 -14
  115. package/dist/seo/index.d.mts +1 -1
  116. package/dist/storage/local.d.mts +1 -1
  117. package/dist/storage/local.mjs +1 -1
  118. package/dist/storage/s3.d.mts +1 -1
  119. package/dist/storage/s3.mjs +1 -1
  120. package/dist/{taxonomies-B4IAshV8.mjs → taxonomies-ZlRtD6AG.mjs} +14 -7
  121. package/dist/taxonomies-ZlRtD6AG.mjs.map +1 -0
  122. package/dist/{tokens-D9vnZqYS.mjs → tokens-D7zMmWi2.mjs} +2 -2
  123. package/dist/{tokens-D9vnZqYS.mjs.map → tokens-D7zMmWi2.mjs.map} +1 -1
  124. package/dist/{transport-C9ugt2Nr.mjs → transport-BeMCmin1.mjs} +6 -5
  125. package/dist/{transport-C9ugt2Nr.mjs.map → transport-BeMCmin1.mjs.map} +1 -1
  126. package/dist/{transport-CUnEL3Vs.d.mts → transport-DNEfeMaU.d.mts} +1 -1
  127. package/dist/{transport-CUnEL3Vs.d.mts.map → transport-DNEfeMaU.d.mts.map} +1 -1
  128. package/dist/types-4fVtCIm0.mjs +68 -0
  129. package/dist/types-4fVtCIm0.mjs.map +1 -0
  130. package/dist/{types-BmPPSUEx.d.mts → types-BSyXeCFW.d.mts} +24 -2
  131. package/dist/{types-BmPPSUEx.d.mts.map → types-BSyXeCFW.d.mts.map} +1 -1
  132. package/dist/{types-i36XcA_X.d.mts → types-BuBIptGk.d.mts} +65 -134
  133. package/dist/types-BuBIptGk.d.mts.map +1 -0
  134. package/dist/{types-CgqmmMJB.mjs → types-CDbKp7ND.mjs} +1 -1
  135. package/dist/{types-CgqmmMJB.mjs.map → types-CDbKp7ND.mjs.map} +1 -1
  136. package/dist/{types-Bm1dn-q3.mjs → types-CIOg5AR8.mjs} +1 -1
  137. package/dist/{types-Bm1dn-q3.mjs.map → types-CIOg5AR8.mjs.map} +1 -1
  138. package/dist/{types-BrA0xf5I.d.mts → types-CJsYGpco.d.mts} +1 -1
  139. package/dist/{types-BrA0xf5I.d.mts.map → types-CJsYGpco.d.mts.map} +1 -1
  140. package/dist/{types-BIgulNsW.mjs → types-CRxNbK-Z.mjs} +2 -2
  141. package/dist/{types-BIgulNsW.mjs.map → types-CRxNbK-Z.mjs.map} +1 -1
  142. package/dist/{types-CS8FIX7L.d.mts → types-CrtWgIvl.d.mts} +1 -1
  143. package/dist/{types-CS8FIX7L.d.mts.map → types-CrtWgIvl.d.mts.map} +1 -1
  144. package/dist/{types-DIMwPFub.d.mts → types-M78DQ1lx.d.mts} +1 -1
  145. package/dist/{types-DIMwPFub.d.mts.map → types-M78DQ1lx.d.mts.map} +1 -1
  146. package/dist/{validate-CxVsLehf.mjs → validate-Baqf0slj.mjs} +3 -3
  147. package/dist/{validate-CxVsLehf.mjs.map → validate-Baqf0slj.mjs.map} +1 -1
  148. package/dist/{validate-DHxmpFJt.d.mts → validate-BfQh_C_y.d.mts} +4 -4
  149. package/dist/{validate-DHxmpFJt.d.mts.map → validate-BfQh_C_y.d.mts.map} +1 -1
  150. package/dist/{validation-C-ZpN2GI.mjs → validation-BfEI7tNe.mjs} +6 -6
  151. package/dist/{validation-C-ZpN2GI.mjs.map → validation-BfEI7tNe.mjs.map} +1 -1
  152. package/dist/version-DoxrVdYf.mjs +7 -0
  153. package/dist/{version-Bbq8TCrz.mjs.map → version-DoxrVdYf.mjs.map} +1 -1
  154. package/dist/{zod-generator-CpwccCIv.mjs → zod-generator-CC0xNe_K.mjs} +4 -4
  155. package/dist/zod-generator-CC0xNe_K.mjs.map +1 -0
  156. package/locals.d.ts +1 -6
  157. package/package.json +9 -8
  158. package/src/api/handlers/comments.ts +6 -4
  159. package/src/api/handlers/content.ts +29 -1
  160. package/src/api/handlers/device-flow.ts +5 -0
  161. package/src/api/handlers/marketplace.ts +11 -4
  162. package/src/api/handlers/oauth-authorization.ts +72 -33
  163. package/src/api/handlers/revision.ts +23 -14
  164. package/src/api/handlers/taxonomies.ts +3 -6
  165. package/src/api/public-url.ts +48 -2
  166. package/src/api/schemas/comments.ts +2 -2
  167. package/src/api/schemas/content.ts +17 -0
  168. package/src/api/schemas/sections.ts +3 -3
  169. package/src/api/schemas/users.ts +1 -1
  170. package/src/api/types.ts +5 -1
  171. package/src/astro/integration/index.ts +17 -0
  172. package/src/astro/integration/runtime.ts +30 -0
  173. package/src/astro/integration/virtual-modules.ts +32 -2
  174. package/src/astro/integration/vite-config.ts +6 -1
  175. package/src/astro/middleware/auth.ts +13 -6
  176. package/src/astro/middleware/redirect.ts +29 -16
  177. package/src/astro/middleware/request-context.ts +15 -5
  178. package/src/astro/middleware.ts +23 -9
  179. package/src/astro/routes/api/auth/invite/complete.ts +6 -1
  180. package/src/astro/routes/api/auth/passkey/register/verify.ts +6 -1
  181. package/src/astro/routes/api/auth/passkey/verify.ts +6 -1
  182. package/src/astro/routes/api/auth/signup/complete.ts +6 -1
  183. package/src/astro/routes/api/comments/[collection]/[contentId]/index.ts +2 -2
  184. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +4 -2
  185. package/src/astro/routes/api/content/[collection]/[id]/preview-url.ts +34 -12
  186. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +32 -2
  187. package/src/astro/routes/api/content/[collection]/[id]/restore.ts +4 -2
  188. package/src/astro/routes/api/content/[collection]/[id]/revisions.ts +3 -2
  189. package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +8 -4
  190. package/src/astro/routes/api/content/[collection]/[id].ts +12 -0
  191. package/src/astro/routes/api/import/wordpress/execute.ts +3 -1
  192. package/src/astro/routes/api/import/wordpress/prepare.ts +7 -8
  193. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +3 -1
  194. package/src/astro/routes/api/manifest.ts +62 -45
  195. package/src/astro/routes/api/media/[id]/confirm.ts +10 -1
  196. package/src/astro/routes/api/media/providers/[providerId]/index.ts +12 -3
  197. package/src/astro/routes/api/openapi.json.ts +27 -10
  198. package/src/astro/routes/api/redirects/404s/index.ts +10 -4
  199. package/src/astro/routes/api/redirects/404s/summary.ts +4 -2
  200. package/src/astro/routes/api/redirects/[id].ts +10 -4
  201. package/src/astro/routes/api/redirects/index.ts +7 -3
  202. package/src/astro/routes/api/revisions/[revisionId]/index.ts +1 -1
  203. package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +0 -2
  204. package/src/astro/routes/api/schema/collections/[slug]/fields/index.ts +0 -1
  205. package/src/astro/routes/api/schema/collections/[slug]/fields/reorder.ts +0 -1
  206. package/src/astro/routes/api/schema/collections/[slug]/index.ts +2 -2
  207. package/src/astro/routes/api/schema/collections/index.ts +1 -1
  208. package/src/astro/routes/api/search/index.ts +10 -2
  209. package/src/astro/routes/api/sections/[slug].ts +10 -4
  210. package/src/astro/routes/api/sections/index.ts +7 -3
  211. package/src/astro/routes/api/setup/admin-verify.ts +6 -1
  212. package/src/astro/routes/api/snapshot.ts +44 -18
  213. package/src/astro/routes/api/taxonomies/index.ts +0 -1
  214. package/src/astro/routes/api/themes/preview.ts +11 -5
  215. package/src/astro/types.ts +23 -3
  216. package/src/auth/allowed-origins.ts +168 -0
  217. package/src/auth/passkey-config.ts +35 -13
  218. package/src/bylines/index.ts +37 -88
  219. package/src/cli/commands/auth.ts +28 -6
  220. package/src/cli/commands/bundle-utils.ts +11 -2
  221. package/src/cli/commands/bundle.ts +28 -8
  222. package/src/cli/commands/content.ts +13 -0
  223. package/src/cli/commands/login.ts +8 -1
  224. package/src/cli/commands/publish.ts +24 -0
  225. package/src/cli/commands/secrets.ts +183 -0
  226. package/src/cli/credentials.ts +1 -1
  227. package/src/cli/index.ts +5 -1
  228. package/src/client/index.ts +4 -4
  229. package/src/client/transport.ts +17 -7
  230. package/src/components/Break.astro +2 -2
  231. package/src/components/EmDashHead.astro +18 -13
  232. package/src/components/Embed.astro +1 -1
  233. package/src/components/Gallery.astro +1 -1
  234. package/src/components/Image.astro +1 -1
  235. package/src/components/InlinePortableTextEditor.tsx +104 -18
  236. package/src/config/secrets.ts +528 -0
  237. package/src/database/dialect-helpers.ts +50 -0
  238. package/src/database/migrations/034_published_at_index.ts +1 -1
  239. package/src/database/migrations/035_bounded_404_log.ts +56 -39
  240. package/src/database/migrations/runner.ts +156 -23
  241. package/src/database/repositories/content.ts +36 -12
  242. package/src/database/repositories/redirect.ts +14 -3
  243. package/src/database/repositories/taxonomy.ts +26 -0
  244. package/src/db/libsql.ts +1 -3
  245. package/src/db/sqlite.ts +2 -5
  246. package/src/emdash-runtime.ts +84 -159
  247. package/src/index.ts +9 -0
  248. package/src/loader.ts +24 -1
  249. package/src/mcp/server.ts +103 -36
  250. package/src/page/site-identity.ts +58 -0
  251. package/src/plugins/adapt-sandbox-entry.ts +22 -10
  252. package/src/plugins/context.ts +13 -10
  253. package/src/plugins/define-plugin.ts +40 -12
  254. package/src/plugins/hooks.ts +23 -19
  255. package/src/plugins/index.ts +9 -0
  256. package/src/plugins/manifest-schema.ts +37 -2
  257. package/src/plugins/types.ts +151 -11
  258. package/src/preview/urls.ts +23 -3
  259. package/src/query.ts +148 -5
  260. package/src/redirects/cache.ts +38 -18
  261. package/src/schema/registry.ts +56 -0
  262. package/src/schema/zod-generator.ts +27 -5
  263. package/src/seed/apply.ts +2 -0
  264. package/src/settings/index.ts +80 -6
  265. package/src/settings/types.ts +23 -1
  266. package/src/taxonomies/index.ts +11 -1
  267. package/dist/apply-x0eMK1lX.mjs.map +0 -1
  268. package/dist/bylines-CRNsVG88.mjs +0 -157
  269. package/dist/bylines-CRNsVG88.mjs.map +0 -1
  270. package/dist/cache-BkKBuIvS.mjs +0 -56
  271. package/dist/cache-BkKBuIvS.mjs.map +0 -1
  272. package/dist/chunk-ClPoSABd.mjs +0 -21
  273. package/dist/dialect-helpers-DhTzaUxP.mjs.map +0 -1
  274. package/dist/index-DIb-CzNx.d.mts.map +0 -1
  275. package/dist/loader-CndGj8kM.mjs.map +0 -1
  276. package/dist/manifest-schema-DH9xhc6t.mjs.map +0 -1
  277. package/dist/query-fqEdLFms.mjs.map +0 -1
  278. package/dist/redirect-D_pshWdf.mjs.map +0 -1
  279. package/dist/registry-C3Mr0ODu.mjs.map +0 -1
  280. package/dist/runner-OURCaApa.d.mts +0 -34
  281. package/dist/runner-OURCaApa.d.mts.map +0 -1
  282. package/dist/search-BoZYFuUk.mjs.map +0 -1
  283. package/dist/taxonomies-B4IAshV8.mjs.map +0 -1
  284. package/dist/types-i36XcA_X.d.mts.map +0 -1
  285. package/dist/version-Bbq8TCrz.mjs +0 -7
  286. package/dist/zod-generator-CpwccCIv.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"validate-CxVsLehf.mjs","names":[],"sources":["../src/seed/validate.ts"],"sourcesContent":["/**\n * Seed file validation\n *\n * Validates a seed file structure before applying it.\n */\n\nimport { FIELD_TYPES } from \"../schema/types.js\";\nimport type { SeedFile, SeedMenuItem, ValidationResult } from \"./types.js\";\n\nconst COLLECTION_FIELD_SLUG_PATTERN = /^[a-z][a-z0-9_]*$/;\nconst SLUG_PATTERN = /^[a-z0-9-]+$/;\nconst REDIRECT_TYPES = new Set([301, 302, 307, 308]);\nconst CRLF_PATTERN = /[\\r\\n]/;\n\n/** Type guard for Record<string, unknown> */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isValidRedirectPath(path: string): boolean {\n\tif (!path.startsWith(\"/\") || path.startsWith(\"//\") || CRLF_PATTERN.test(path)) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\treturn !decodeURIComponent(path).split(\"/\").includes(\"..\");\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Validate a seed file\n *\n * @param data - Unknown data to validate as a seed file\n * @returns Validation result with errors and warnings\n */\nexport function validateSeed(data: unknown): ValidationResult {\n\tconst errors: string[] = [];\n\tconst warnings: string[] = [];\n\n\t// Basic type check\n\tif (!data || typeof data !== \"object\") {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terrors: [\"Seed must be an object\"],\n\t\t\twarnings: [],\n\t\t};\n\t}\n\n\tconst seed = data as Partial<SeedFile>;\n\n\t// Required fields\n\tif (!seed.version) {\n\t\terrors.push(\"Seed must have a version field\");\n\t} else if (seed.version !== \"1\") {\n\t\terrors.push(`Unsupported seed version: ${String(seed.version)}`);\n\t}\n\n\t// Validate collections\n\tif (seed.collections) {\n\t\tif (!Array.isArray(seed.collections)) {\n\t\t\terrors.push(\"collections must be an array\");\n\t\t} else {\n\t\t\tconst collectionSlugs = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.collections.length; i++) {\n\t\t\t\tconst collection = seed.collections[i];\n\t\t\t\tconst prefix = `collections[${i}]`;\n\n\t\t\t\tif (!collection.slug) {\n\t\t\t\t\terrors.push(`${prefix}: slug is required`);\n\t\t\t\t} else {\n\t\t\t\t\t// Check for valid slug format\n\t\t\t\t\tif (!COLLECTION_FIELD_SLUG_PATTERN.test(collection.slug)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`${prefix}.slug: must start with a letter and contain only lowercase letters, numbers, and underscores`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check for duplicate slugs\n\t\t\t\t\tif (collectionSlugs.has(collection.slug)) {\n\t\t\t\t\t\terrors.push(`${prefix}.slug: duplicate collection slug \"${collection.slug}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tcollectionSlugs.add(collection.slug);\n\t\t\t\t}\n\n\t\t\t\tif (!collection.label) {\n\t\t\t\t\terrors.push(`${prefix}: label is required`);\n\t\t\t\t}\n\n\t\t\t\t// Validate fields\n\t\t\t\tif (!Array.isArray(collection.fields)) {\n\t\t\t\t\terrors.push(`${prefix}.fields: must be an array`);\n\t\t\t\t} else {\n\t\t\t\t\tconst fieldSlugs = new Set<string>();\n\n\t\t\t\t\tfor (let j = 0; j < collection.fields.length; j++) {\n\t\t\t\t\t\tconst field = collection.fields[j];\n\t\t\t\t\t\tconst fieldPrefix = `${prefix}.fields[${j}]`;\n\n\t\t\t\t\t\tif (!field.slug) {\n\t\t\t\t\t\t\terrors.push(`${fieldPrefix}: slug is required`);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Check for valid slug format\n\t\t\t\t\t\t\tif (!COLLECTION_FIELD_SLUG_PATTERN.test(field.slug)) {\n\t\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t\t`${fieldPrefix}.slug: must start with a letter and contain only lowercase letters, numbers, and underscores`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Check for duplicate field slugs\n\t\t\t\t\t\t\tif (fieldSlugs.has(field.slug)) {\n\t\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t\t`${fieldPrefix}.slug: duplicate field slug \"${field.slug}\" in collection \"${collection.slug}\"`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfieldSlugs.add(field.slug);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!field.label) {\n\t\t\t\t\t\t\terrors.push(`${fieldPrefix}: label is required`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!field.type) {\n\t\t\t\t\t\t\terrors.push(`${fieldPrefix}: type is required`);\n\t\t\t\t\t\t} else if (!(FIELD_TYPES as readonly string[]).includes(field.type)) {\n\t\t\t\t\t\t\terrors.push(`${fieldPrefix}.type: unsupported field type \"${field.type}\"`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate taxonomies\n\tif (seed.taxonomies) {\n\t\tif (!Array.isArray(seed.taxonomies)) {\n\t\t\terrors.push(\"taxonomies must be an array\");\n\t\t} else {\n\t\t\tconst taxonomyNames = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.taxonomies.length; i++) {\n\t\t\t\tconst taxonomy = seed.taxonomies[i];\n\t\t\t\tconst prefix = `taxonomies[${i}]`;\n\n\t\t\t\tif (!taxonomy.name) {\n\t\t\t\t\terrors.push(`${prefix}: name is required`);\n\t\t\t\t} else {\n\t\t\t\t\t// Check for duplicate taxonomy names\n\t\t\t\t\tif (taxonomyNames.has(taxonomy.name)) {\n\t\t\t\t\t\terrors.push(`${prefix}.name: duplicate taxonomy name \"${taxonomy.name}\"`);\n\t\t\t\t\t}\n\t\t\t\t\ttaxonomyNames.add(taxonomy.name);\n\t\t\t\t}\n\n\t\t\t\tif (!taxonomy.label) {\n\t\t\t\t\terrors.push(`${prefix}: label is required`);\n\t\t\t\t}\n\n\t\t\t\tif (taxonomy.hierarchical === undefined) {\n\t\t\t\t\terrors.push(`${prefix}: hierarchical is required`);\n\t\t\t\t}\n\n\t\t\t\tif (!Array.isArray(taxonomy.collections)) {\n\t\t\t\t\terrors.push(`${prefix}.collections: must be an array`);\n\t\t\t\t} else if (taxonomy.collections.length === 0) {\n\t\t\t\t\twarnings.push(\n\t\t\t\t\t\t`${prefix}.collections: taxonomy \"${taxonomy.name}\" is not assigned to any collections`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Validate terms if present\n\t\t\t\tif (taxonomy.terms) {\n\t\t\t\t\tif (!Array.isArray(taxonomy.terms)) {\n\t\t\t\t\t\terrors.push(`${prefix}.terms: must be an array`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst termSlugs = new Set<string>();\n\n\t\t\t\t\t\tfor (let j = 0; j < taxonomy.terms.length; j++) {\n\t\t\t\t\t\t\tconst term = taxonomy.terms[j];\n\t\t\t\t\t\t\tconst termPrefix = `${prefix}.terms[${j}]`;\n\n\t\t\t\t\t\t\tif (!term.slug) {\n\t\t\t\t\t\t\t\terrors.push(`${termPrefix}: slug is required`);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Check for duplicate term slugs\n\t\t\t\t\t\t\t\tif (termSlugs.has(term.slug)) {\n\t\t\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t\t\t`${termPrefix}.slug: duplicate term slug \"${term.slug}\" in taxonomy \"${taxonomy.name}\"`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttermSlugs.add(term.slug);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!term.label) {\n\t\t\t\t\t\t\t\terrors.push(`${termPrefix}: label is required`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Check parent reference validity (for hierarchical taxonomies)\n\t\t\t\t\t\t\tif (term.parent && taxonomy.hierarchical) {\n\t\t\t\t\t\t\t\t// Parent will be validated in a second pass\n\t\t\t\t\t\t\t} else if (term.parent && !taxonomy.hierarchical) {\n\t\t\t\t\t\t\t\twarnings.push(\n\t\t\t\t\t\t\t\t\t`${termPrefix}.parent: taxonomy \"${taxonomy.name}\" is not hierarchical, parent will be ignored`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Second pass: validate parent references\n\t\t\t\t\t\tif (taxonomy.hierarchical && taxonomy.terms) {\n\t\t\t\t\t\t\tfor (let j = 0; j < taxonomy.terms.length; j++) {\n\t\t\t\t\t\t\t\tconst term = taxonomy.terms[j];\n\t\t\t\t\t\t\t\tif (term.parent && !termSlugs.has(term.parent)) {\n\t\t\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t\t\t`${prefix}.terms[${j}].parent: parent term \"${term.parent}\" not found in taxonomy`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Check for circular references\n\t\t\t\t\t\t\t\tif (term.parent === term.slug) {\n\t\t\t\t\t\t\t\t\terrors.push(`${prefix}.terms[${j}].parent: term cannot be its own parent`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate menus\n\tif (seed.menus) {\n\t\tif (!Array.isArray(seed.menus)) {\n\t\t\terrors.push(\"menus must be an array\");\n\t\t} else {\n\t\t\tconst menuNames = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.menus.length; i++) {\n\t\t\t\tconst menu = seed.menus[i];\n\t\t\t\tconst prefix = `menus[${i}]`;\n\n\t\t\t\tif (!menu.name) {\n\t\t\t\t\terrors.push(`${prefix}: name is required`);\n\t\t\t\t} else {\n\t\t\t\t\t// Check for duplicate menu names\n\t\t\t\t\tif (menuNames.has(menu.name)) {\n\t\t\t\t\t\terrors.push(`${prefix}.name: duplicate menu name \"${menu.name}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tmenuNames.add(menu.name);\n\t\t\t\t}\n\n\t\t\t\tif (!menu.label) {\n\t\t\t\t\terrors.push(`${prefix}: label is required`);\n\t\t\t\t}\n\n\t\t\t\tif (!Array.isArray(menu.items)) {\n\t\t\t\t\terrors.push(`${prefix}.items: must be an array`);\n\t\t\t\t} else {\n\t\t\t\t\tvalidateMenuItems(menu.items, prefix, errors, warnings);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate redirects\n\tif (seed.redirects) {\n\t\tif (!Array.isArray(seed.redirects)) {\n\t\t\terrors.push(\"redirects must be an array\");\n\t\t} else {\n\t\t\tconst redirectSources = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.redirects.length; i++) {\n\t\t\t\tconst redirect = seed.redirects[i];\n\t\t\t\tconst prefix = `redirects[${i}]`;\n\n\t\t\t\tif (!isRecord(redirect)) {\n\t\t\t\t\terrors.push(`${prefix}: must be an object`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst source = typeof redirect.source === \"string\" ? redirect.source : undefined;\n\t\t\t\tconst destination =\n\t\t\t\t\ttypeof redirect.destination === \"string\" ? redirect.destination : undefined;\n\n\t\t\t\tif (!source) {\n\t\t\t\t\terrors.push(`${prefix}: source is required`);\n\t\t\t\t} else {\n\t\t\t\t\tif (!isValidRedirectPath(source)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`${prefix}.source: must be a path starting with / (no protocol-relative URLs, path traversal, or newlines)`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (redirectSources.has(source)) {\n\t\t\t\t\t\terrors.push(`${prefix}.source: duplicate redirect source \"${source}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tredirectSources.add(source);\n\t\t\t\t}\n\n\t\t\t\tif (!destination) {\n\t\t\t\t\terrors.push(`${prefix}: destination is required`);\n\t\t\t\t} else if (!isValidRedirectPath(destination)) {\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\t`${prefix}.destination: must be a path starting with / (no protocol-relative URLs, path traversal, or newlines)`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (redirect.type !== undefined) {\n\t\t\t\t\tif (typeof redirect.type !== \"number\" || !REDIRECT_TYPES.has(redirect.type)) {\n\t\t\t\t\t\terrors.push(`${prefix}.type: must be 301, 302, 307, or 308`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (redirect.enabled !== undefined && typeof redirect.enabled !== \"boolean\") {\n\t\t\t\t\terrors.push(`${prefix}.enabled: must be a boolean`);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tredirect.groupName !== undefined &&\n\t\t\t\t\ttypeof redirect.groupName !== \"string\" &&\n\t\t\t\t\tredirect.groupName !== null\n\t\t\t\t) {\n\t\t\t\t\terrors.push(`${prefix}.groupName: must be a string or null`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate widget areas\n\tif (seed.widgetAreas) {\n\t\tif (!Array.isArray(seed.widgetAreas)) {\n\t\t\terrors.push(\"widgetAreas must be an array\");\n\t\t} else {\n\t\t\tconst areaNames = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.widgetAreas.length; i++) {\n\t\t\t\tconst area = seed.widgetAreas[i];\n\t\t\t\tconst prefix = `widgetAreas[${i}]`;\n\n\t\t\t\tif (!area.name) {\n\t\t\t\t\terrors.push(`${prefix}: name is required`);\n\t\t\t\t} else {\n\t\t\t\t\t// Check for duplicate area names\n\t\t\t\t\tif (areaNames.has(area.name)) {\n\t\t\t\t\t\terrors.push(`${prefix}.name: duplicate widget area name \"${area.name}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tareaNames.add(area.name);\n\t\t\t\t}\n\n\t\t\t\tif (!area.label) {\n\t\t\t\t\terrors.push(`${prefix}: label is required`);\n\t\t\t\t}\n\n\t\t\t\tif (!Array.isArray(area.widgets)) {\n\t\t\t\t\terrors.push(`${prefix}.widgets: must be an array`);\n\t\t\t\t} else {\n\t\t\t\t\tfor (let j = 0; j < area.widgets.length; j++) {\n\t\t\t\t\t\tconst widget = area.widgets[j];\n\t\t\t\t\t\tconst widgetPrefix = `${prefix}.widgets[${j}]`;\n\n\t\t\t\t\t\tif (!widget.type) {\n\t\t\t\t\t\t\terrors.push(`${widgetPrefix}: type is required`);\n\t\t\t\t\t\t} else if (![\"content\", \"menu\", \"component\"].includes(widget.type)) {\n\t\t\t\t\t\t\terrors.push(`${widgetPrefix}.type: must be \"content\", \"menu\", or \"component\"`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Type-specific validation\n\t\t\t\t\t\tif (widget.type === \"menu\" && !widget.menuName) {\n\t\t\t\t\t\t\terrors.push(`${widgetPrefix}: menuName is required for menu widgets`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (widget.type === \"component\" && !widget.componentId) {\n\t\t\t\t\t\t\terrors.push(`${widgetPrefix}: componentId is required for component widgets`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate sections\n\tif (seed.sections) {\n\t\tif (!Array.isArray(seed.sections)) {\n\t\t\terrors.push(\"sections must be an array\");\n\t\t} else {\n\t\t\tconst sectionSlugs = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.sections.length; i++) {\n\t\t\t\tconst section = seed.sections[i];\n\t\t\t\tconst prefix = `sections[${i}]`;\n\n\t\t\t\tif (!section.slug) {\n\t\t\t\t\terrors.push(`${prefix}: slug is required`);\n\t\t\t\t} else {\n\t\t\t\t\tif (!SLUG_PATTERN.test(section.slug)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`${prefix}.slug: must contain only lowercase letters, numbers, and hyphens`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (sectionSlugs.has(section.slug)) {\n\t\t\t\t\t\terrors.push(`${prefix}.slug: duplicate section slug \"${section.slug}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tsectionSlugs.add(section.slug);\n\t\t\t\t}\n\n\t\t\t\tif (!section.title) {\n\t\t\t\t\terrors.push(`${prefix}: title is required`);\n\t\t\t\t}\n\n\t\t\t\tif (!Array.isArray(section.content)) {\n\t\t\t\t\terrors.push(`${prefix}.content: must be an array`);\n\t\t\t\t}\n\n\t\t\t\t// Validate source\n\t\t\t\tif (section.source && ![\"theme\", \"import\"].includes(section.source)) {\n\t\t\t\t\terrors.push(`${prefix}.source: must be \"theme\" or \"import\"`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate bylines\n\tif (seed.bylines) {\n\t\tif (!Array.isArray(seed.bylines)) {\n\t\t\terrors.push(\"bylines must be an array\");\n\t\t} else {\n\t\t\tconst bylineIds = new Set<string>();\n\t\t\tconst bylineSlugs = new Set<string>();\n\t\t\tfor (let i = 0; i < seed.bylines.length; i++) {\n\t\t\t\tconst byline = seed.bylines[i];\n\t\t\t\tconst prefix = `bylines[${i}]`;\n\n\t\t\t\tif (!byline.id) {\n\t\t\t\t\terrors.push(`${prefix}: id is required`);\n\t\t\t\t} else {\n\t\t\t\t\tif (bylineIds.has(byline.id)) {\n\t\t\t\t\t\terrors.push(`${prefix}.id: duplicate byline id \"${byline.id}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tbylineIds.add(byline.id);\n\t\t\t\t}\n\n\t\t\t\tif (!byline.slug) {\n\t\t\t\t\terrors.push(`${prefix}: slug is required`);\n\t\t\t\t} else {\n\t\t\t\t\tif (!SLUG_PATTERN.test(byline.slug)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`${prefix}.slug: must contain only lowercase letters, numbers, and hyphens`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (bylineSlugs.has(byline.slug)) {\n\t\t\t\t\t\terrors.push(`${prefix}.slug: duplicate byline slug \"${byline.slug}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tbylineSlugs.add(byline.slug);\n\t\t\t\t}\n\n\t\t\t\tif (!byline.displayName) {\n\t\t\t\t\terrors.push(`${prefix}: displayName is required`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate content\n\tif (seed.content) {\n\t\tif (typeof seed.content !== \"object\" || Array.isArray(seed.content)) {\n\t\t\terrors.push(\"content must be an object (collection -> entries)\");\n\t\t} else {\n\t\t\tfor (const [collectionSlug, entries] of Object.entries(seed.content)) {\n\t\t\t\tif (!Array.isArray(entries)) {\n\t\t\t\t\terrors.push(`content.${collectionSlug}: must be an array`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst entryIds = new Set<string>();\n\n\t\t\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\t\t\tconst entry = entries[i];\n\t\t\t\t\tconst prefix = `content.${collectionSlug}[${i}]`;\n\n\t\t\t\t\tif (!entry.id) {\n\t\t\t\t\t\terrors.push(`${prefix}: id is required`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Check for duplicate entry IDs\n\t\t\t\t\t\tif (entryIds.has(entry.id)) {\n\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t`${prefix}.id: duplicate entry id \"${entry.id}\" in collection \"${collectionSlug}\"`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tentryIds.add(entry.id);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!entry.slug) {\n\t\t\t\t\t\terrors.push(`${prefix}: slug is required`);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!entry.data || typeof entry.data !== \"object\") {\n\t\t\t\t\t\terrors.push(`${prefix}: data must be an object`);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Validate i18n fields\n\t\t\t\t\tif (entry.translationOf) {\n\t\t\t\t\t\tif (!entry.locale) {\n\t\t\t\t\t\t\terrors.push(`${prefix}: locale is required when translationOf is set`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Second pass: validate translationOf references within this collection\n\t\t\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\t\t\tconst entry = entries[i];\n\t\t\t\t\tif (entry.translationOf && !entryIds.has(entry.translationOf)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`content.${collectionSlug}[${i}].translationOf: references \"${entry.translationOf}\" which is not in this collection`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate cross-references (content refs in menus)\n\tif (seed.menus && seed.content) {\n\t\tconst allContentIds = new Set<string>();\n\t\tfor (const entries of Object.values(seed.content)) {\n\t\t\tif (Array.isArray(entries)) {\n\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\tif (entry.id) {\n\t\t\t\t\t\tallContentIds.add(entry.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check menu item refs\n\t\tfor (const menu of seed.menus) {\n\t\t\tif (Array.isArray(menu.items)) {\n\t\t\t\tvalidateMenuItemRefs(menu.items, allContentIds, warnings);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate byline refs in content\n\tif (seed.content) {\n\t\tconst seedBylineIds = new Set<string>((seed.bylines ?? []).map((byline) => byline.id));\n\t\tfor (const [collectionSlug, entries] of Object.entries(seed.content)) {\n\t\t\tif (!Array.isArray(entries)) continue;\n\t\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\t\tconst entry = entries[i];\n\t\t\t\tif (!entry.bylines) continue;\n\t\t\t\tif (!Array.isArray(entry.bylines)) {\n\t\t\t\t\terrors.push(`content.${collectionSlug}[${i}].bylines: must be an array`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (let j = 0; j < entry.bylines.length; j++) {\n\t\t\t\t\tconst credit = entry.bylines[j];\n\t\t\t\t\tconst prefix = `content.${collectionSlug}[${i}].bylines[${j}]`;\n\t\t\t\t\tif (!credit.byline) {\n\t\t\t\t\t\terrors.push(`${prefix}.byline: is required`);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!seedBylineIds.has(credit.byline)) {\n\t\t\t\t\t\terrors.push(`${prefix}.byline: references unknown byline \"${credit.byline}\"`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tvalid: errors.length === 0,\n\t\terrors,\n\t\twarnings,\n\t};\n}\n\n/**\n * Validate menu items recursively\n */\nfunction validateMenuItems(\n\titems: unknown[],\n\tprefix: string,\n\terrors: string[],\n\twarnings: string[],\n): void {\n\tfor (let i = 0; i < items.length; i++) {\n\t\tconst raw = items[i];\n\t\tconst itemPrefix = `${prefix}.items[${i}]`;\n\n\t\tif (!isRecord(raw)) {\n\t\t\terrors.push(`${itemPrefix}: must be an object`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst item = raw;\n\n\t\tconst itemType = typeof item.type === \"string\" ? item.type : undefined;\n\n\t\tif (!itemType) {\n\t\t\terrors.push(`${itemPrefix}: type is required`);\n\t\t} else if (![\"custom\", \"page\", \"post\", \"taxonomy\", \"collection\"].includes(itemType)) {\n\t\t\terrors.push(\n\t\t\t\t`${itemPrefix}.type: must be \"custom\", \"page\", \"post\", \"taxonomy\", or \"collection\"`,\n\t\t\t);\n\t\t}\n\n\t\t// Type-specific validation\n\t\tif (itemType === \"custom\" && !item.url) {\n\t\t\terrors.push(`${itemPrefix}: url is required for custom menu items`);\n\t\t}\n\n\t\tif ((itemType === \"page\" || itemType === \"post\") && !item.ref) {\n\t\t\terrors.push(`${itemPrefix}: ref is required for page/post menu items`);\n\t\t}\n\n\t\t// Validate children recursively\n\t\tif (Array.isArray(item.children)) {\n\t\t\tvalidateMenuItems(item.children, itemPrefix, errors, warnings);\n\t\t}\n\t}\n}\n\n/**\n * Validate menu item references exist in content\n */\nfunction validateMenuItemRefs(\n\titems: SeedMenuItem[],\n\tcontentIds: Set<string>,\n\twarnings: string[],\n): void {\n\tfor (const item of items) {\n\t\tif ((item.type === \"page\" || item.type === \"post\") && item.ref) {\n\t\t\tif (!contentIds.has(item.ref)) {\n\t\t\t\twarnings.push(`Menu item references content \"${item.ref}\" which is not in the seed file`);\n\t\t\t}\n\t\t}\n\n\t\tif (item.children) {\n\t\t\tvalidateMenuItemRefs(item.children, contentIds, warnings);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;AASA,MAAM,gCAAgC;AACtC,MAAM,eAAe;AACrB,MAAM,iBAAiB,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;CAAI,CAAC;AACpD,MAAM,eAAe;;AAGrB,SAAS,SAAS,OAAkD;AACnE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG5E,SAAS,oBAAoB,MAAuB;AACnD,KAAI,CAAC,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,KAAK,IAAI,aAAa,KAAK,KAAK,CAC5E,QAAO;AAGR,KAAI;AACH,SAAO,CAAC,mBAAmB,KAAK,CAAC,MAAM,IAAI,CAAC,SAAS,KAAK;SACnD;AACP,SAAO;;;;;;;;;AAUT,SAAgB,aAAa,MAAiC;CAC7D,MAAM,SAAmB,EAAE;CAC3B,MAAM,WAAqB,EAAE;AAG7B,KAAI,CAAC,QAAQ,OAAO,SAAS,SAC5B,QAAO;EACN,OAAO;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validates a seed file structure before applying it.\n */\n\nimport { FIELD_TYPES } from \"../schema/types.js\";\nimport type { SeedFile, SeedMenuItem, ValidationResult } from \"./types.js\";\n\nconst COLLECTION_FIELD_SLUG_PATTERN = /^[a-z][a-z0-9_]*$/;\nconst SLUG_PATTERN = /^[a-z0-9-]+$/;\nconst REDIRECT_TYPES = new Set([301, 302, 307, 308]);\nconst CRLF_PATTERN = /[\\r\\n]/;\n\n/** Type guard for Record<string, unknown> */\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isValidRedirectPath(path: string): boolean {\n\tif (!path.startsWith(\"/\") || path.startsWith(\"//\") || CRLF_PATTERN.test(path)) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\treturn !decodeURIComponent(path).split(\"/\").includes(\"..\");\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Validate a seed file\n *\n * @param data - Unknown data to validate as a seed file\n * @returns Validation result with errors and warnings\n */\nexport function validateSeed(data: unknown): ValidationResult {\n\tconst errors: string[] = [];\n\tconst warnings: string[] = [];\n\n\t// Basic type check\n\tif (!data || typeof data !== \"object\") {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terrors: [\"Seed must be an object\"],\n\t\t\twarnings: [],\n\t\t};\n\t}\n\n\tconst seed = data as Partial<SeedFile>;\n\n\t// Required fields\n\tif (!seed.version) {\n\t\terrors.push(\"Seed must have a version field\");\n\t} else if (seed.version !== \"1\") {\n\t\terrors.push(`Unsupported seed version: ${String(seed.version)}`);\n\t}\n\n\t// Validate collections\n\tif (seed.collections) {\n\t\tif (!Array.isArray(seed.collections)) {\n\t\t\terrors.push(\"collections must be an array\");\n\t\t} else {\n\t\t\tconst collectionSlugs = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.collections.length; i++) {\n\t\t\t\tconst collection = seed.collections[i];\n\t\t\t\tconst prefix = `collections[${i}]`;\n\n\t\t\t\tif (!collection.slug) {\n\t\t\t\t\terrors.push(`${prefix}: slug is required`);\n\t\t\t\t} else {\n\t\t\t\t\t// Check for valid slug format\n\t\t\t\t\tif (!COLLECTION_FIELD_SLUG_PATTERN.test(collection.slug)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`${prefix}.slug: must start with a letter and contain only lowercase letters, numbers, and underscores`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check for duplicate slugs\n\t\t\t\t\tif (collectionSlugs.has(collection.slug)) {\n\t\t\t\t\t\terrors.push(`${prefix}.slug: duplicate collection slug \"${collection.slug}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tcollectionSlugs.add(collection.slug);\n\t\t\t\t}\n\n\t\t\t\tif (!collection.label) {\n\t\t\t\t\terrors.push(`${prefix}: label is required`);\n\t\t\t\t}\n\n\t\t\t\t// Validate fields\n\t\t\t\tif (!Array.isArray(collection.fields)) {\n\t\t\t\t\terrors.push(`${prefix}.fields: must be an array`);\n\t\t\t\t} else {\n\t\t\t\t\tconst fieldSlugs = new Set<string>();\n\n\t\t\t\t\tfor (let j = 0; j < collection.fields.length; j++) {\n\t\t\t\t\t\tconst field = collection.fields[j];\n\t\t\t\t\t\tconst fieldPrefix = `${prefix}.fields[${j}]`;\n\n\t\t\t\t\t\tif (!field.slug) {\n\t\t\t\t\t\t\terrors.push(`${fieldPrefix}: slug is required`);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Check for valid slug format\n\t\t\t\t\t\t\tif (!COLLECTION_FIELD_SLUG_PATTERN.test(field.slug)) {\n\t\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t\t`${fieldPrefix}.slug: must start with a letter and contain only lowercase letters, numbers, and underscores`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Check for duplicate field slugs\n\t\t\t\t\t\t\tif (fieldSlugs.has(field.slug)) {\n\t\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t\t`${fieldPrefix}.slug: duplicate field slug \"${field.slug}\" in collection \"${collection.slug}\"`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfieldSlugs.add(field.slug);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!field.label) {\n\t\t\t\t\t\t\terrors.push(`${fieldPrefix}: label is required`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!field.type) {\n\t\t\t\t\t\t\terrors.push(`${fieldPrefix}: type is required`);\n\t\t\t\t\t\t} else if (!(FIELD_TYPES as readonly string[]).includes(field.type)) {\n\t\t\t\t\t\t\terrors.push(`${fieldPrefix}.type: unsupported field type \"${field.type}\"`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate taxonomies\n\tif (seed.taxonomies) {\n\t\tif (!Array.isArray(seed.taxonomies)) {\n\t\t\terrors.push(\"taxonomies must be an array\");\n\t\t} else {\n\t\t\tconst taxonomyNames = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.taxonomies.length; i++) {\n\t\t\t\tconst taxonomy = seed.taxonomies[i];\n\t\t\t\tconst prefix = `taxonomies[${i}]`;\n\n\t\t\t\tif (!taxonomy.name) {\n\t\t\t\t\terrors.push(`${prefix}: name is required`);\n\t\t\t\t} else {\n\t\t\t\t\t// Check for duplicate taxonomy names\n\t\t\t\t\tif (taxonomyNames.has(taxonomy.name)) {\n\t\t\t\t\t\terrors.push(`${prefix}.name: duplicate taxonomy name \"${taxonomy.name}\"`);\n\t\t\t\t\t}\n\t\t\t\t\ttaxonomyNames.add(taxonomy.name);\n\t\t\t\t}\n\n\t\t\t\tif (!taxonomy.label) {\n\t\t\t\t\terrors.push(`${prefix}: label is required`);\n\t\t\t\t}\n\n\t\t\t\tif (taxonomy.hierarchical === undefined) {\n\t\t\t\t\terrors.push(`${prefix}: hierarchical is required`);\n\t\t\t\t}\n\n\t\t\t\tif (!Array.isArray(taxonomy.collections)) {\n\t\t\t\t\terrors.push(`${prefix}.collections: must be an array`);\n\t\t\t\t} else if (taxonomy.collections.length === 0) {\n\t\t\t\t\twarnings.push(\n\t\t\t\t\t\t`${prefix}.collections: taxonomy \"${taxonomy.name}\" is not assigned to any collections`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Validate terms if present\n\t\t\t\tif (taxonomy.terms) {\n\t\t\t\t\tif (!Array.isArray(taxonomy.terms)) {\n\t\t\t\t\t\terrors.push(`${prefix}.terms: must be an array`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst termSlugs = new Set<string>();\n\n\t\t\t\t\t\tfor (let j = 0; j < taxonomy.terms.length; j++) {\n\t\t\t\t\t\t\tconst term = taxonomy.terms[j];\n\t\t\t\t\t\t\tconst termPrefix = `${prefix}.terms[${j}]`;\n\n\t\t\t\t\t\t\tif (!term.slug) {\n\t\t\t\t\t\t\t\terrors.push(`${termPrefix}: slug is required`);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Check for duplicate term slugs\n\t\t\t\t\t\t\t\tif (termSlugs.has(term.slug)) {\n\t\t\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t\t\t`${termPrefix}.slug: duplicate term slug \"${term.slug}\" in taxonomy \"${taxonomy.name}\"`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttermSlugs.add(term.slug);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!term.label) {\n\t\t\t\t\t\t\t\terrors.push(`${termPrefix}: label is required`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Check parent reference validity (for hierarchical taxonomies)\n\t\t\t\t\t\t\tif (term.parent && taxonomy.hierarchical) {\n\t\t\t\t\t\t\t\t// Parent will be validated in a second pass\n\t\t\t\t\t\t\t} else if (term.parent && !taxonomy.hierarchical) {\n\t\t\t\t\t\t\t\twarnings.push(\n\t\t\t\t\t\t\t\t\t`${termPrefix}.parent: taxonomy \"${taxonomy.name}\" is not hierarchical, parent will be ignored`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Second pass: validate parent references\n\t\t\t\t\t\tif (taxonomy.hierarchical && taxonomy.terms) {\n\t\t\t\t\t\t\tfor (let j = 0; j < taxonomy.terms.length; j++) {\n\t\t\t\t\t\t\t\tconst term = taxonomy.terms[j];\n\t\t\t\t\t\t\t\tif (term.parent && !termSlugs.has(term.parent)) {\n\t\t\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t\t\t`${prefix}.terms[${j}].parent: parent term \"${term.parent}\" not found in taxonomy`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Check for circular references\n\t\t\t\t\t\t\t\tif (term.parent === term.slug) {\n\t\t\t\t\t\t\t\t\terrors.push(`${prefix}.terms[${j}].parent: term cannot be its own parent`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate menus\n\tif (seed.menus) {\n\t\tif (!Array.isArray(seed.menus)) {\n\t\t\terrors.push(\"menus must be an array\");\n\t\t} else {\n\t\t\tconst menuNames = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.menus.length; i++) {\n\t\t\t\tconst menu = seed.menus[i];\n\t\t\t\tconst prefix = `menus[${i}]`;\n\n\t\t\t\tif (!menu.name) {\n\t\t\t\t\terrors.push(`${prefix}: name is required`);\n\t\t\t\t} else {\n\t\t\t\t\t// Check for duplicate menu names\n\t\t\t\t\tif (menuNames.has(menu.name)) {\n\t\t\t\t\t\terrors.push(`${prefix}.name: duplicate menu name \"${menu.name}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tmenuNames.add(menu.name);\n\t\t\t\t}\n\n\t\t\t\tif (!menu.label) {\n\t\t\t\t\terrors.push(`${prefix}: label is required`);\n\t\t\t\t}\n\n\t\t\t\tif (!Array.isArray(menu.items)) {\n\t\t\t\t\terrors.push(`${prefix}.items: must be an array`);\n\t\t\t\t} else {\n\t\t\t\t\tvalidateMenuItems(menu.items, prefix, errors, warnings);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate redirects\n\tif (seed.redirects) {\n\t\tif (!Array.isArray(seed.redirects)) {\n\t\t\terrors.push(\"redirects must be an array\");\n\t\t} else {\n\t\t\tconst redirectSources = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.redirects.length; i++) {\n\t\t\t\tconst redirect = seed.redirects[i];\n\t\t\t\tconst prefix = `redirects[${i}]`;\n\n\t\t\t\tif (!isRecord(redirect)) {\n\t\t\t\t\terrors.push(`${prefix}: must be an object`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst source = typeof redirect.source === \"string\" ? redirect.source : undefined;\n\t\t\t\tconst destination =\n\t\t\t\t\ttypeof redirect.destination === \"string\" ? redirect.destination : undefined;\n\n\t\t\t\tif (!source) {\n\t\t\t\t\terrors.push(`${prefix}: source is required`);\n\t\t\t\t} else {\n\t\t\t\t\tif (!isValidRedirectPath(source)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`${prefix}.source: must be a path starting with / (no protocol-relative URLs, path traversal, or newlines)`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (redirectSources.has(source)) {\n\t\t\t\t\t\terrors.push(`${prefix}.source: duplicate redirect source \"${source}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tredirectSources.add(source);\n\t\t\t\t}\n\n\t\t\t\tif (!destination) {\n\t\t\t\t\terrors.push(`${prefix}: destination is required`);\n\t\t\t\t} else if (!isValidRedirectPath(destination)) {\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\t`${prefix}.destination: must be a path starting with / (no protocol-relative URLs, path traversal, or newlines)`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (redirect.type !== undefined) {\n\t\t\t\t\tif (typeof redirect.type !== \"number\" || !REDIRECT_TYPES.has(redirect.type)) {\n\t\t\t\t\t\terrors.push(`${prefix}.type: must be 301, 302, 307, or 308`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (redirect.enabled !== undefined && typeof redirect.enabled !== \"boolean\") {\n\t\t\t\t\terrors.push(`${prefix}.enabled: must be a boolean`);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tredirect.groupName !== undefined &&\n\t\t\t\t\ttypeof redirect.groupName !== \"string\" &&\n\t\t\t\t\tredirect.groupName !== null\n\t\t\t\t) {\n\t\t\t\t\terrors.push(`${prefix}.groupName: must be a string or null`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate widget areas\n\tif (seed.widgetAreas) {\n\t\tif (!Array.isArray(seed.widgetAreas)) {\n\t\t\terrors.push(\"widgetAreas must be an array\");\n\t\t} else {\n\t\t\tconst areaNames = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.widgetAreas.length; i++) {\n\t\t\t\tconst area = seed.widgetAreas[i];\n\t\t\t\tconst prefix = `widgetAreas[${i}]`;\n\n\t\t\t\tif (!area.name) {\n\t\t\t\t\terrors.push(`${prefix}: name is required`);\n\t\t\t\t} else {\n\t\t\t\t\t// Check for duplicate area names\n\t\t\t\t\tif (areaNames.has(area.name)) {\n\t\t\t\t\t\terrors.push(`${prefix}.name: duplicate widget area name \"${area.name}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tareaNames.add(area.name);\n\t\t\t\t}\n\n\t\t\t\tif (!area.label) {\n\t\t\t\t\terrors.push(`${prefix}: label is required`);\n\t\t\t\t}\n\n\t\t\t\tif (!Array.isArray(area.widgets)) {\n\t\t\t\t\terrors.push(`${prefix}.widgets: must be an array`);\n\t\t\t\t} else {\n\t\t\t\t\tfor (let j = 0; j < area.widgets.length; j++) {\n\t\t\t\t\t\tconst widget = area.widgets[j];\n\t\t\t\t\t\tconst widgetPrefix = `${prefix}.widgets[${j}]`;\n\n\t\t\t\t\t\tif (!widget.type) {\n\t\t\t\t\t\t\terrors.push(`${widgetPrefix}: type is required`);\n\t\t\t\t\t\t} else if (![\"content\", \"menu\", \"component\"].includes(widget.type)) {\n\t\t\t\t\t\t\terrors.push(`${widgetPrefix}.type: must be \"content\", \"menu\", or \"component\"`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Type-specific validation\n\t\t\t\t\t\tif (widget.type === \"menu\" && !widget.menuName) {\n\t\t\t\t\t\t\terrors.push(`${widgetPrefix}: menuName is required for menu widgets`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (widget.type === \"component\" && !widget.componentId) {\n\t\t\t\t\t\t\terrors.push(`${widgetPrefix}: componentId is required for component widgets`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate sections\n\tif (seed.sections) {\n\t\tif (!Array.isArray(seed.sections)) {\n\t\t\terrors.push(\"sections must be an array\");\n\t\t} else {\n\t\t\tconst sectionSlugs = new Set<string>();\n\n\t\t\tfor (let i = 0; i < seed.sections.length; i++) {\n\t\t\t\tconst section = seed.sections[i];\n\t\t\t\tconst prefix = `sections[${i}]`;\n\n\t\t\t\tif (!section.slug) {\n\t\t\t\t\terrors.push(`${prefix}: slug is required`);\n\t\t\t\t} else {\n\t\t\t\t\tif (!SLUG_PATTERN.test(section.slug)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`${prefix}.slug: must contain only lowercase letters, numbers, and hyphens`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (sectionSlugs.has(section.slug)) {\n\t\t\t\t\t\terrors.push(`${prefix}.slug: duplicate section slug \"${section.slug}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tsectionSlugs.add(section.slug);\n\t\t\t\t}\n\n\t\t\t\tif (!section.title) {\n\t\t\t\t\terrors.push(`${prefix}: title is required`);\n\t\t\t\t}\n\n\t\t\t\tif (!Array.isArray(section.content)) {\n\t\t\t\t\terrors.push(`${prefix}.content: must be an array`);\n\t\t\t\t}\n\n\t\t\t\t// Validate source\n\t\t\t\tif (section.source && ![\"theme\", \"import\"].includes(section.source)) {\n\t\t\t\t\terrors.push(`${prefix}.source: must be \"theme\" or \"import\"`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate bylines\n\tif (seed.bylines) {\n\t\tif (!Array.isArray(seed.bylines)) {\n\t\t\terrors.push(\"bylines must be an array\");\n\t\t} else {\n\t\t\tconst bylineIds = new Set<string>();\n\t\t\tconst bylineSlugs = new Set<string>();\n\t\t\tfor (let i = 0; i < seed.bylines.length; i++) {\n\t\t\t\tconst byline = seed.bylines[i];\n\t\t\t\tconst prefix = `bylines[${i}]`;\n\n\t\t\t\tif (!byline.id) {\n\t\t\t\t\terrors.push(`${prefix}: id is required`);\n\t\t\t\t} else {\n\t\t\t\t\tif (bylineIds.has(byline.id)) {\n\t\t\t\t\t\terrors.push(`${prefix}.id: duplicate byline id \"${byline.id}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tbylineIds.add(byline.id);\n\t\t\t\t}\n\n\t\t\t\tif (!byline.slug) {\n\t\t\t\t\terrors.push(`${prefix}: slug is required`);\n\t\t\t\t} else {\n\t\t\t\t\tif (!SLUG_PATTERN.test(byline.slug)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`${prefix}.slug: must contain only lowercase letters, numbers, and hyphens`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (bylineSlugs.has(byline.slug)) {\n\t\t\t\t\t\terrors.push(`${prefix}.slug: duplicate byline slug \"${byline.slug}\"`);\n\t\t\t\t\t}\n\t\t\t\t\tbylineSlugs.add(byline.slug);\n\t\t\t\t}\n\n\t\t\t\tif (!byline.displayName) {\n\t\t\t\t\terrors.push(`${prefix}: displayName is required`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate content\n\tif (seed.content) {\n\t\tif (typeof seed.content !== \"object\" || Array.isArray(seed.content)) {\n\t\t\terrors.push(\"content must be an object (collection -> entries)\");\n\t\t} else {\n\t\t\tfor (const [collectionSlug, entries] of Object.entries(seed.content)) {\n\t\t\t\tif (!Array.isArray(entries)) {\n\t\t\t\t\terrors.push(`content.${collectionSlug}: must be an array`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst entryIds = new Set<string>();\n\n\t\t\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\t\t\tconst entry = entries[i];\n\t\t\t\t\tconst prefix = `content.${collectionSlug}[${i}]`;\n\n\t\t\t\t\tif (!entry.id) {\n\t\t\t\t\t\terrors.push(`${prefix}: id is required`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Check for duplicate entry IDs\n\t\t\t\t\t\tif (entryIds.has(entry.id)) {\n\t\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t\t`${prefix}.id: duplicate entry id \"${entry.id}\" in collection \"${collectionSlug}\"`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tentryIds.add(entry.id);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!entry.slug) {\n\t\t\t\t\t\terrors.push(`${prefix}: slug is required`);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!entry.data || typeof entry.data !== \"object\") {\n\t\t\t\t\t\terrors.push(`${prefix}: data must be an object`);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Validate i18n fields\n\t\t\t\t\tif (entry.translationOf) {\n\t\t\t\t\t\tif (!entry.locale) {\n\t\t\t\t\t\t\terrors.push(`${prefix}: locale is required when translationOf is set`);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Second pass: validate translationOf references within this collection\n\t\t\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\t\t\tconst entry = entries[i];\n\t\t\t\t\tif (entry.translationOf && !entryIds.has(entry.translationOf)) {\n\t\t\t\t\t\terrors.push(\n\t\t\t\t\t\t\t`content.${collectionSlug}[${i}].translationOf: references \"${entry.translationOf}\" which is not in this collection`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate cross-references (content refs in menus)\n\tif (seed.menus && seed.content) {\n\t\tconst allContentIds = new Set<string>();\n\t\tfor (const entries of Object.values(seed.content)) {\n\t\t\tif (Array.isArray(entries)) {\n\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\tif (entry.id) {\n\t\t\t\t\t\tallContentIds.add(entry.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check menu item refs\n\t\tfor (const menu of seed.menus) {\n\t\t\tif (Array.isArray(menu.items)) {\n\t\t\t\tvalidateMenuItemRefs(menu.items, allContentIds, warnings);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate byline refs in content\n\tif (seed.content) {\n\t\tconst seedBylineIds = new Set<string>((seed.bylines ?? []).map((byline) => byline.id));\n\t\tfor (const [collectionSlug, entries] of Object.entries(seed.content)) {\n\t\t\tif (!Array.isArray(entries)) continue;\n\t\t\tfor (let i = 0; i < entries.length; i++) {\n\t\t\t\tconst entry = entries[i];\n\t\t\t\tif (!entry.bylines) continue;\n\t\t\t\tif (!Array.isArray(entry.bylines)) {\n\t\t\t\t\terrors.push(`content.${collectionSlug}[${i}].bylines: must be an array`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (let j = 0; j < entry.bylines.length; j++) {\n\t\t\t\t\tconst credit = entry.bylines[j];\n\t\t\t\t\tconst prefix = `content.${collectionSlug}[${i}].bylines[${j}]`;\n\t\t\t\t\tif (!credit.byline) {\n\t\t\t\t\t\terrors.push(`${prefix}.byline: is required`);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!seedBylineIds.has(credit.byline)) {\n\t\t\t\t\t\terrors.push(`${prefix}.byline: references unknown byline \"${credit.byline}\"`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tvalid: errors.length === 0,\n\t\terrors,\n\t\twarnings,\n\t};\n}\n\n/**\n * Validate menu items recursively\n */\nfunction validateMenuItems(\n\titems: unknown[],\n\tprefix: string,\n\terrors: string[],\n\twarnings: string[],\n): void {\n\tfor (let i = 0; i < items.length; i++) {\n\t\tconst raw = items[i];\n\t\tconst itemPrefix = `${prefix}.items[${i}]`;\n\n\t\tif (!isRecord(raw)) {\n\t\t\terrors.push(`${itemPrefix}: must be an object`);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst item = raw;\n\n\t\tconst itemType = typeof item.type === \"string\" ? item.type : undefined;\n\n\t\tif (!itemType) {\n\t\t\terrors.push(`${itemPrefix}: type is required`);\n\t\t} else if (![\"custom\", \"page\", \"post\", \"taxonomy\", \"collection\"].includes(itemType)) {\n\t\t\terrors.push(\n\t\t\t\t`${itemPrefix}.type: must be \"custom\", \"page\", \"post\", \"taxonomy\", or \"collection\"`,\n\t\t\t);\n\t\t}\n\n\t\t// Type-specific validation\n\t\tif (itemType === \"custom\" && !item.url) {\n\t\t\terrors.push(`${itemPrefix}: url is required for custom menu items`);\n\t\t}\n\n\t\tif ((itemType === \"page\" || itemType === \"post\") && !item.ref) {\n\t\t\terrors.push(`${itemPrefix}: ref is required for page/post menu items`);\n\t\t}\n\n\t\t// Validate children recursively\n\t\tif (Array.isArray(item.children)) {\n\t\t\tvalidateMenuItems(item.children, itemPrefix, errors, warnings);\n\t\t}\n\t}\n}\n\n/**\n * Validate menu item references exist in content\n */\nfunction validateMenuItemRefs(\n\titems: SeedMenuItem[],\n\tcontentIds: Set<string>,\n\twarnings: string[],\n): void {\n\tfor (const item of items) {\n\t\tif ((item.type === \"page\" || item.type === \"post\") && item.ref) {\n\t\t\tif (!contentIds.has(item.ref)) {\n\t\t\t\twarnings.push(`Menu item references content \"${item.ref}\" which is not in the seed file`);\n\t\t\t}\n\t\t}\n\n\t\tif (item.children) {\n\t\t\tvalidateMenuItemRefs(item.children, contentIds, warnings);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;AASA,MAAM,gCAAgC;AACtC,MAAM,eAAe;AACrB,MAAM,iBAAiB,IAAI,IAAI;CAAC;CAAK;CAAK;CAAK;CAAI,CAAC;AACpD,MAAM,eAAe;;AAGrB,SAAS,SAAS,OAAkD;AACnE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG5E,SAAS,oBAAoB,MAAuB;AACnD,KAAI,CAAC,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,KAAK,IAAI,aAAa,KAAK,KAAK,CAC5E,QAAO;AAGR,KAAI;AACH,SAAO,CAAC,mBAAmB,KAAK,CAAC,MAAM,IAAI,CAAC,SAAS,KAAK;SACnD;AACP,SAAO;;;;;;;;;AAUT,SAAgB,aAAa,MAAiC;CAC7D,MAAM,SAAmB,EAAE;CAC3B,MAAM,WAAqB,EAAE;AAG7B,KAAI,CAAC,QAAQ,OAAO,SAAS,SAC5B,QAAO;EACN,OAAO;EACP,QAAQ,CAAC,yBAAyB;EAClC,UAAU,EAAE;EACZ;CAGF,MAAM,OAAO;AAGb,KAAI,CAAC,KAAK,QACT,QAAO,KAAK,iCAAiC;UACnC,KAAK,YAAY,IAC3B,QAAO,KAAK,6BAA6B,OAAO,KAAK,QAAQ,GAAG;AAIjE,KAAI,KAAK,YACR,KAAI,CAAC,MAAM,QAAQ,KAAK,YAAY,CACnC,QAAO,KAAK,+BAA+B;MACrC;EACN,MAAM,kCAAkB,IAAI,KAAa;AAEzC,OAAK,IAAI,IAAI,GAAG,IAAI,KAAK,YAAY,QAAQ,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B;AAC/C;;EAGD,MAAM,OAAO;EAEb,MAAM,WAAW,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AAE7D,MAAI,CAAC,SACJ,QAAO,KAAK,GAAG,WAAW,oBAAoB;WACpC,CAAC;GAAC;GAAU;GAAQ;GAAQ;GAAY;GAAa,CAAC,SAAS,SAAS,CAClF,QAAO,KACN,GAAG,WAAW,sEACd;AAIF,MAAI,aAAa,YAAY,CAAC,KAAK,IAClC,QAAO,KAAK,GAAG,WAAW,yCAAyC;AAGpE,OAAK,aAAa,UAAU,aAAa,WAAW,CAAC,KAAK,IACzD,QAAO,KAAK,GAAG,WAAW,4CAA4C;AAIvE,MAAI,MAAM,QAAQ,KAAK,SAAS,CAC/B,mBAAkB,KAAK,UAAU,YAAY,QAAQ,SAAS;;;;;;AAQjE,SAAS,qBACR,OACA,YACA,UACO;AACP,MAAK,MAAM,QAAQ,OAAO;AACzB,OAAK,KAAK,SAAS,UAAU,KAAK,SAAS,WAAW,KAAK,KAC1D;OAAI,CAAC,WAAW,IAAI,KAAK,IAAI,CAC5B,UAAS,KAAK,iCAAiC,KAAK,IAAI,iCAAiC;;AAI3F,MAAI,KAAK,SACR,sBAAqB,KAAK,UAAU,YAAY,SAAS"}
@@ -1,6 +1,6 @@
1
- import { t as Database } from "./types-CS8FIX7L.mjs";
2
- import { i as SiteSettings, m as FieldType } from "./types-BmPPSUEx.mjs";
3
- import { d as Storage } from "./types-DIMwPFub.mjs";
1
+ import { t as Database } from "./types-CrtWgIvl.mjs";
2
+ import { i as SiteSettings, m as FieldType } from "./types-BSyXeCFW.mjs";
3
+ import { d as Storage } from "./types-M78DQ1lx.mjs";
4
4
  import { Kysely } from "kysely";
5
5
 
6
6
  //#region src/seed/types.d.ts
@@ -328,4 +328,4 @@ declare function loadUserSeed(): Promise<SeedFile | null>;
328
328
  declare function validateSeed(data: unknown): ValidationResult;
329
329
  //#endregion
330
330
  export { SeedTaxonomyTerm as _, applySeed as a, ValidationResult as b, SeedCollection as c, SeedFile as d, SeedMenu as f, SeedTaxonomy as g, SeedSection as h, defaultSeed as i, SeedContentEntry as l, SeedRedirect as m, loadSeed as n, SeedApplyOptions as o, SeedMenuItem as p, loadUserSeed as r, SeedApplyResult as s, validateSeed as t, SeedField as u, SeedWidget as v, SeedWidgetArea as y };
331
- //# sourceMappingURL=validate-DHxmpFJt.d.mts.map
331
+ //# sourceMappingURL=validate-BfQh_C_y.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-DHxmpFJt.d.mts","names":[],"sources":["../src/seed/types.ts","../src/seed/apply.ts","../src/seed/default.ts","../src/seed/load.ts","../src/seed/validate.ts"],"mappings":";;;;;;;;;UAciB,QAAA;EAwBR;EAtBR,OAAA;EA4Bc;EAzBd,OAAA;EA+BU;EA5BV,IAAA;IACC,IAAA;IACA,WAAA;IACA,MAAA;EAAA;EAND;EAUA,QAAA,GAAW,OAAA,CAAQ,YAAA;EANlB;EASD,WAAA,GAAc,cAAA;EAPb;EAUD,UAAA,GAAa,YAAA;EANF;EASX,KAAA,GAAQ,QAAA;EANR;EASA,SAAA,GAAY,YAAA;EANZ;EASA,WAAA,GAAc,cAAA;EANd;EASA,QAAA,GAAW,WAAA;EANX;EASA,OAAA,GAAU,UAAA;EANV;EASA,OAAA,GAAU,MAAA,SAAe,gBAAA;AAAA;;;;UAMT,cAAA;EAChB,IAAA;EACA,KAAA;EACA,aAAA;EACA,WAAA;EACA,IAAA;EACA,QAAA;EACA,UAAA;EAGiB;EADjB,eAAA;EACA,MAAA,EAAQ,SAAA;AAAA;;;;UAMQ,SAAA;EAChB,IAAA;EACA,KAAA;EACA,IAAA,EAAM,SAAA;EACN,QAAA;EACA,MAAA;EACA,UAAA;EACA,YAAA;EACA,UAAA,GAAa,MAAA;EACb,MAAA;EACA,OAAA,GAAU,MAAA;AAAA;;;;UAMM,YAAA;EAChB,IAAA;EACA,KAAA;EACA,aAAA;EACA,YAAA;EACA,WAAA;EACA,KAAA,GAAQ,gBAAA;AAA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A,UAAA;EAnCA;EAsCA,aAAA;EAnCM;;;;EAyCN,OAAA,GAAU,OAAA;EAhCV;;;;AASD;;;;;AASA;EA0BC,iBAAA;AAAA;;;;UAMgB,eAAA;EAChB,WAAA;IAAe,OAAA;IAAiB,OAAA;IAAiB,OAAA;EAAA;EACjD,MAAA;IAAU,OAAA;IAAiB,OAAA;IAAiB,OAAA;EAAA;EAC5C,UAAA;IAAc,OAAA;IAAiB,KAAA;EAAA;EAC/B,OAAA;IAAW,OAAA;IAAiB,OAAA;IAAiB,OAAA;EAAA;EAC7C,KAAA;IAAS,OAAA;IAAiB,KAAA;EAAA;EAC1B,SAAA;IAAa,OAAA;IAAiB,OAAA;IAAiB,OAAA;EAAA;EAC/C,WAAA;IAAe,OAAA;IAAiB,OAAA;EAAA;EAChC,QAAA;IAAY,OAAA;IAAiB,OAAA;IAAiB,OAAA;EAAA;EAC9C,QAAA;IAAY,OAAA;EAAA;EACZ,OAAA;IAAW,OAAA;IAAiB,OAAA;IAAiB,OAAA;EAAA;EAC7C,KAAA;IAAS,OAAA;IAAiB,OAAA;EAAA;AAAA;;;;UAMV,gBAAA;EAChB,KAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;;;;;;;;iBCzOqB,SAAA,CACrB,EAAA,EAAI,MAAA,CAAO,QAAA,GACX,IAAA,EAAM,QAAA,EACN,OAAA,GAAS,gBAAA,GACP,OAAA,CAAQ,eAAA;;;cCxDE,WAAA,EAAa,QAAA;;;;;;iBCcJ,QAAA,CAAA,GAAY,OAAA,CAAQ,QAAA;;;;iBAQpB,YAAA,CAAA,GAAgB,OAAA,CAAQ,QAAA;;;AHjB9C;;;;;;AAAA,iBIuBgB,YAAA,CAAa,IAAA,YAAgB,gBAAA"}
1
+ {"version":3,"file":"validate-BfQh_C_y.d.mts","names":[],"sources":["../src/seed/types.ts","../src/seed/apply.ts","../src/seed/default.ts","../src/seed/load.ts","../src/seed/validate.ts"],"mappings":";;;;;;;;;UAciB,QAAA;EAwBR;EA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AA;EAC/C,WAAA;IAAe,OAAA;IAAiB,OAAA;EAAA;EAChC,QAAA;IAAY,OAAA;IAAiB,OAAA;IAAiB,OAAA;EAAA;EAC9C,QAAA;IAAY,OAAA;EAAA;EACZ,OAAA;IAAW,OAAA;IAAiB,OAAA;IAAiB,OAAA;EAAA;EAC7C,KAAA;IAAS,OAAA;IAAiB,OAAA;EAAA;AAAA;;;;UAMV,gBAAA;EAChB,KAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;;;;;;;;iBCzOqB,SAAA,CACrB,EAAA,EAAI,MAAA,CAAO,QAAA,GACX,IAAA,EAAM,QAAA,EACN,OAAA,GAAS,gBAAA,GACP,OAAA,CAAQ,eAAA;;;cCxDE,WAAA,EAAa,QAAA;;;;;;iBCcJ,QAAA,CAAA,GAAY,OAAA,CAAQ,QAAA;;;;iBAQpB,YAAA,CAAA,GAAgB,OAAA,CAAQ,QAAA;;;AHjB9C;;;;;;AAAA,iBIuBgB,YAAA,CAAa,IAAA,YAAgB,gBAAA"}
@@ -1,9 +1,9 @@
1
1
  import { t as validateIdentifier } from "./validate-VPnKoIzW.mjs";
2
- import "./dialect-helpers-DhTzaUxP.mjs";
3
- import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-HGz06Soa.mjs";
4
- import { t as isMissingTableError } from "./db-errors-l1Qh2RPR.mjs";
5
- import { t as generateZodSchema } from "./zod-generator-CpwccCIv.mjs";
6
- import { n as SchemaRegistry } from "./registry-C3Mr0ODu.mjs";
2
+ import "./dialect-helpers-BKCvISIQ.mjs";
3
+ import { n as chunks, t as SQL_BATCH_SIZE } from "./chunks-NBQVDOci.mjs";
4
+ import { t as isMissingTableError } from "./db-errors-WRezodiz.mjs";
5
+ import { t as generateZodSchema } from "./zod-generator-CC0xNe_K.mjs";
6
+ import { n as SchemaRegistry } from "./registry-Dw70ChxB.mjs";
7
7
  import { sql } from "kysely";
8
8
 
9
9
  //#region src/api/handlers/validation.ts
@@ -141,4 +141,4 @@ async function validateContentData(db, collection, data, options = {}) {
141
141
 
142
142
  //#endregion
143
143
  export { validateContentData };
144
- //# sourceMappingURL=validation-C-ZpN2GI.mjs.map
144
+ //# sourceMappingURL=validation-BfEI7tNe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation-C-ZpN2GI.mjs","names":[],"sources":["../src/api/handlers/validation.ts"],"sourcesContent":["/**\n * Field-level validation for content create / update.\n *\n * Wires the existing `generateZodSchema()` pipeline (`schema/zod-generator.ts`)\n * into the handler boundary so REST and MCP both get the same enforcement:\n *\n * - required fields must be present and non-empty\n * - select / multiSelect values must match the configured options\n * - reference fields must resolve to a real, non-trashed target\n *\n * Errors surface as `{ code: \"VALIDATION_ERROR\", message }` with all\n * offending fields listed in one message so callers can fix everything in\n * a single round trip.\n */\n\nimport { sql, type Kysely } from \"kysely\";\n\nimport type { Database } from \"../../database/types.js\";\nimport { validateIdentifier } from \"../../database/validate.js\";\nimport { SchemaRegistry } from \"../../schema/registry.js\";\nimport type { Field } from \"../../schema/types.js\";\nimport { generateZodSchema } from \"../../schema/zod-generator.js\";\nimport { chunks, SQL_BATCH_SIZE } from \"../../utils/chunks.js\";\nimport { isMissingTableError } from \"../../utils/db-errors.js\";\n\ntype ValidationResult =\n\t| { ok: true }\n\t| { ok: false; error: { code: \"VALIDATION_ERROR\" | \"COLLECTION_NOT_FOUND\"; message: string } };\n\n/** Treat `undefined`, `null`, and `\"\"` as \"not set\". */\nfunction isMissing(value: unknown): boolean {\n\treturn value === undefined || value === null || value === \"\";\n}\n\n/**\n * Resolve the target collection slug for a reference field.\n *\n * Schema-defined reference fields (the static `reference()` factory in\n * `fields/reference.ts`) put the target in `options.collection`. The MCP\n * `schema_create_field` tool also puts it there. Tests and some admin paths\n * stash it inside `validation.collection` directly; we accept both.\n */\nfunction getReferenceTargetCollection(field: Field): string | undefined {\n\tconst fromOptions = field.options?.collection;\n\tif (typeof fromOptions === \"string\" && fromOptions.length > 0) return fromOptions;\n\tconst validation = field.validation;\n\tif (validation && \"collection\" in validation) {\n\t\tconst fromValidation: unknown = (validation as { collection?: unknown }).collection;\n\t\tif (typeof fromValidation === \"string\" && fromValidation.length > 0) return fromValidation;\n\t}\n\treturn undefined;\n}\n\n/**\n * Format a Zod issue path into a human-readable field reference, e.g.\n * `tags`, `tags.1`, `image.alt`.\n */\nfunction formatIssuePath(path: ReadonlyArray<PropertyKey>): string {\n\tif (path.length === 0) return \"(root)\";\n\treturn path.map((seg) => String(seg)).join(\".\");\n}\n\n/**\n * Validate `data` against the collection's field definitions.\n *\n * `partial: true` switches Zod into partial mode so updates can include\n * only the fields being changed without tripping required-field errors on\n * fields the caller didn't touch. Required fields that ARE present in\n * partial-mode data still get the empty-string check below.\n */\nexport async function validateContentData(\n\tdb: Kysely<Database>,\n\tcollection: string,\n\tdata: Record<string, unknown>,\n\toptions: { partial?: boolean } = {},\n): Promise<ValidationResult> {\n\tconst registry = new SchemaRegistry(db);\n\tconst collectionWithFields = await registry.getCollectionWithFields(collection);\n\tif (!collectionWithFields) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: {\n\t\t\t\tcode: \"COLLECTION_NOT_FOUND\",\n\t\t\t\tmessage: `Collection '${collection}' not found`,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst issues: string[] = [];\n\n\t// Detect unknown keys explicitly so callers get a useful error rather\n\t// than silently dropped data. Leading-underscore keys (e.g. `_slug`,\n\t// `_rev`) are reserved for internal handler/runtime use and aren't real\n\t// fields; skip them.\n\tconst knownFields = new Set(collectionWithFields.fields.map((f) => f.slug));\n\tfor (const key of Object.keys(data)) {\n\t\tif (key.startsWith(\"_\")) continue;\n\t\tif (!knownFields.has(key)) {\n\t\t\tissues.push(`${key}: unknown field on collection '${collection}'`);\n\t\t}\n\t}\n\n\t// Zod handles type, enum, length and missing-required (in non-partial\n\t// mode) checks. Empty-string handling for required string fields is\n\t// done as a separate pass below since Zod's `z.string()` accepts \"\".\n\tconst baseSchema = generateZodSchema(collectionWithFields);\n\tconst schema = options.partial ? baseSchema.partial() : baseSchema;\n\tconst parsed = schema.safeParse(data);\n\tif (!parsed.success) {\n\t\tfor (const issue of parsed.error.issues) {\n\t\t\tissues.push(`${formatIssuePath(issue.path)}: ${issue.message}`);\n\t\t}\n\t}\n\n\t// Empty-string-on-required check. In create mode (partial=false) Zod\n\t// already catches missing/null for required fields, but `z.string()`\n\t// happily accepts \"\". In update mode (partial=true) the field is only\n\t// checked if it's present in `data`.\n\tfor (const field of collectionWithFields.fields) {\n\t\tif (!field.required) continue;\n\t\tconst present = Object.hasOwn(data, field.slug);\n\t\tif (options.partial && !present) continue;\n\t\tif (data[field.slug] === \"\") {\n\t\t\tissues.push(`${field.slug}: required (empty value not allowed)`);\n\t\t}\n\t}\n\n\t// Reference target existence. Only check fields that:\n\t// - have a value (non-missing) in `data`\n\t// - have a resolvable target collection\n\t// - in partial mode: are present in `data`\n\t// Batch one IN-query per target collection to keep round-trips low.\n\tconst refsByTarget = new Map<string, { field: string; id: string }[]>();\n\tfor (const field of collectionWithFields.fields) {\n\t\tif (field.type !== \"reference\") continue;\n\t\tif (options.partial && !Object.hasOwn(data, field.slug)) continue;\n\t\tconst value = data[field.slug];\n\t\tif (isMissing(value)) continue;\n\t\tif (typeof value !== \"string\") continue; // Zod will have flagged this already\n\t\tconst target = getReferenceTargetCollection(field);\n\t\tif (!target) continue;\n\t\tconst list = refsByTarget.get(target) ?? [];\n\t\tlist.push({ field: field.slug, id: value });\n\t\trefsByTarget.set(target, list);\n\t}\n\n\tfor (const [target, refs] of refsByTarget) {\n\t\t// Validate the target collection slug before interpolating into raw\n\t\t// SQL — defense-in-depth even though slugs are already validated at\n\t\t// schema-create time.\n\t\ttry {\n\t\t\tvalidateIdentifier(target, \"reference target collection\");\n\t\t} catch {\n\t\t\tfor (const ref of refs) {\n\t\t\t\tissues.push(`${ref.field}: invalid reference target collection '${target}'`);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst ids = [...new Set(refs.map((r) => r.id))];\n\t\tconst tableName = `ec_${target}`;\n\n\t\t// Chunk the IN clause to stay below D1's bind-parameter limit. One\n\t\t// reference per request is the common case today; chunking makes the\n\t\t// helper safe if a future multiSelect-of-references is added.\n\t\tconst found = new Set<string>();\n\t\tlet targetTableMissing = false;\n\t\tfor (const idChunk of chunks(ids, SQL_BATCH_SIZE)) {\n\t\t\ttry {\n\t\t\t\tconst rows = await sql<{ id: string }>`\n\t\t\t\t\tSELECT id FROM ${sql.ref(tableName)}\n\t\t\t\t\tWHERE id IN (${sql.join(idChunk)})\n\t\t\t\t\tAND deleted_at IS NULL\n\t\t\t\t`.execute(db);\n\t\t\t\tfor (const row of rows.rows) {\n\t\t\t\t\tfound.add(row.id);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Missing table = the target collection table doesn't exist\n\t\t\t\t// (orphan reference). Treat all those references as missing.\n\t\t\t\t// Any other DB error (permissions, connection, syntax) must\n\t\t\t\t// propagate — silently dropping data integrity errors as\n\t\t\t\t// \"not found\" is exactly the bug F5 fixes.\n\t\t\t\tif (isMissingTableError(error)) {\n\t\t\t\t\ttargetTableMissing = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif (targetTableMissing) {\n\t\t\tfor (const ref of refs) {\n\t\t\t\tissues.push(`${ref.field}: target '${ref.id}' not found in collection '${target}'`);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const ref of refs) {\n\t\t\tif (!found.has(ref.id)) {\n\t\t\t\tissues.push(`${ref.field}: target '${ref.id}' not found in collection '${target}'`);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (issues.length === 0) return { ok: true };\n\treturn {\n\t\tok: false,\n\t\terror: {\n\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\tmessage: issues.join(\"; \"),\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,UAAU,OAAyB;AAC3C,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AMf,OAAI,oBAAoB,MAAM,EAAE;AAC/B,yBAAqB;AACrB;;AAED,SAAM;;AAGR,MAAI,oBAAoB;AACvB,QAAK,MAAM,OAAO,KACjB,QAAO,KAAK,GAAG,IAAI,MAAM,YAAY,IAAI,GAAG,6BAA6B,OAAO,GAAG;AAEpF;;AAED,OAAK,MAAM,OAAO,KACjB,KAAI,CAAC,MAAM,IAAI,IAAI,GAAG,CACrB,QAAO,KAAK,GAAG,IAAI,MAAM,YAAY,IAAI,GAAG,6BAA6B,OAAO,GAAG;;AAKtF,KAAI,OAAO,WAAW,EAAG,QAAO,EAAE,IAAI,MAAM;AAC5C,QAAO;EACN,IAAI;EACJ,OAAO;GACN,MAAM;GACN,SAAS,OAAO,KAAK,KAAK;GAC1B;EACD"}
1
+ {"version":3,"file":"validation-BfEI7tNe.mjs","names":[],"sources":["../src/api/handlers/validation.ts"],"sourcesContent":["/**\n * Field-level validation for content create / update.\n *\n * Wires the existing `generateZodSchema()` pipeline (`schema/zod-generator.ts`)\n * into the handler boundary so REST and MCP both get the same enforcement:\n *\n * - required fields must be present and non-empty\n * - select / multiSelect values must match the configured options\n * - reference fields must resolve to a real, non-trashed target\n *\n * Errors surface as `{ code: \"VALIDATION_ERROR\", message }` with all\n * offending fields listed in one message so callers can fix everything in\n * a single round trip.\n */\n\nimport { sql, type Kysely } from \"kysely\";\n\nimport type { Database } from \"../../database/types.js\";\nimport { validateIdentifier } from \"../../database/validate.js\";\nimport { SchemaRegistry } from \"../../schema/registry.js\";\nimport type { Field } from \"../../schema/types.js\";\nimport { generateZodSchema } from \"../../schema/zod-generator.js\";\nimport { chunks, SQL_BATCH_SIZE } from \"../../utils/chunks.js\";\nimport { isMissingTableError } from \"../../utils/db-errors.js\";\n\ntype ValidationResult =\n\t| { ok: true }\n\t| { ok: false; error: { code: \"VALIDATION_ERROR\" | \"COLLECTION_NOT_FOUND\"; message: string } };\n\n/** Treat `undefined`, `null`, and `\"\"` as \"not set\". */\nfunction isMissing(value: unknown): boolean {\n\treturn value === undefined || value === null || value === \"\";\n}\n\n/**\n * Resolve the target collection slug for a reference field.\n *\n * Schema-defined reference fields (the static `reference()` factory in\n * `fields/reference.ts`) put the target in `options.collection`. The MCP\n * `schema_create_field` tool also puts it there. Tests and some admin paths\n * stash it inside `validation.collection` directly; we accept both.\n */\nfunction getReferenceTargetCollection(field: Field): string | undefined {\n\tconst fromOptions = field.options?.collection;\n\tif (typeof fromOptions === \"string\" && fromOptions.length > 0) return fromOptions;\n\tconst validation = field.validation;\n\tif (validation && \"collection\" in validation) {\n\t\tconst fromValidation: unknown = (validation as { collection?: unknown }).collection;\n\t\tif (typeof fromValidation === \"string\" && fromValidation.length > 0) return fromValidation;\n\t}\n\treturn undefined;\n}\n\n/**\n * Format a Zod issue path into a human-readable field reference, e.g.\n * `tags`, `tags.1`, `image.alt`.\n */\nfunction formatIssuePath(path: ReadonlyArray<PropertyKey>): string {\n\tif (path.length === 0) return \"(root)\";\n\treturn path.map((seg) => String(seg)).join(\".\");\n}\n\n/**\n * Validate `data` against the collection's field definitions.\n *\n * `partial: true` switches Zod into partial mode so updates can include\n * only the fields being changed without tripping required-field errors on\n * fields the caller didn't touch. Required fields that ARE present in\n * partial-mode data still get the empty-string check below.\n */\nexport async function validateContentData(\n\tdb: Kysely<Database>,\n\tcollection: string,\n\tdata: Record<string, unknown>,\n\toptions: { partial?: boolean } = {},\n): Promise<ValidationResult> {\n\tconst registry = new SchemaRegistry(db);\n\tconst collectionWithFields = await registry.getCollectionWithFields(collection);\n\tif (!collectionWithFields) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: {\n\t\t\t\tcode: \"COLLECTION_NOT_FOUND\",\n\t\t\t\tmessage: `Collection '${collection}' not found`,\n\t\t\t},\n\t\t};\n\t}\n\n\tconst issues: string[] = [];\n\n\t// Detect unknown keys explicitly so callers get a useful error rather\n\t// than silently dropped data. Leading-underscore keys (e.g. `_slug`,\n\t// `_rev`) are reserved for internal handler/runtime use and aren't real\n\t// fields; skip them.\n\tconst knownFields = new Set(collectionWithFields.fields.map((f) => f.slug));\n\tfor (const key of Object.keys(data)) {\n\t\tif (key.startsWith(\"_\")) continue;\n\t\tif (!knownFields.has(key)) {\n\t\t\tissues.push(`${key}: unknown field on collection '${collection}'`);\n\t\t}\n\t}\n\n\t// Zod handles type, enum, length and missing-required (in non-partial\n\t// mode) checks. Empty-string handling for required string fields is\n\t// done as a separate pass below since Zod's `z.string()` accepts \"\".\n\tconst baseSchema = generateZodSchema(collectionWithFields);\n\tconst schema = options.partial ? baseSchema.partial() : baseSchema;\n\tconst parsed = schema.safeParse(data);\n\tif (!parsed.success) {\n\t\tfor (const issue of parsed.error.issues) {\n\t\t\tissues.push(`${formatIssuePath(issue.path)}: ${issue.message}`);\n\t\t}\n\t}\n\n\t// Empty-string-on-required check. In create mode (partial=false) Zod\n\t// already catches missing/null for required fields, but `z.string()`\n\t// happily accepts \"\". In update mode (partial=true) the field is only\n\t// checked if it's present in `data`.\n\tfor (const field of collectionWithFields.fields) {\n\t\tif (!field.required) continue;\n\t\tconst present = Object.hasOwn(data, field.slug);\n\t\tif (options.partial && !present) continue;\n\t\tif (data[field.slug] === \"\") {\n\t\t\tissues.push(`${field.slug}: required (empty value not allowed)`);\n\t\t}\n\t}\n\n\t// Reference target existence. Only check fields that:\n\t// - have a value (non-missing) in `data`\n\t// - have a resolvable target collection\n\t// - in partial mode: are present in `data`\n\t// Batch one IN-query per target collection to keep round-trips low.\n\tconst refsByTarget = new Map<string, { field: string; id: string }[]>();\n\tfor (const field of collectionWithFields.fields) {\n\t\tif (field.type !== \"reference\") continue;\n\t\tif (options.partial && !Object.hasOwn(data, field.slug)) continue;\n\t\tconst value = data[field.slug];\n\t\tif (isMissing(value)) continue;\n\t\tif (typeof value !== \"string\") continue; // Zod will have flagged this already\n\t\tconst target = getReferenceTargetCollection(field);\n\t\tif (!target) continue;\n\t\tconst list = refsByTarget.get(target) ?? [];\n\t\tlist.push({ field: field.slug, id: value });\n\t\trefsByTarget.set(target, list);\n\t}\n\n\tfor (const [target, refs] of refsByTarget) {\n\t\t// Validate the target collection slug before interpolating into raw\n\t\t// SQL — defense-in-depth even though slugs are already validated at\n\t\t// schema-create time.\n\t\ttry {\n\t\t\tvalidateIdentifier(target, \"reference target collection\");\n\t\t} catch {\n\t\t\tfor (const ref of refs) {\n\t\t\t\tissues.push(`${ref.field}: invalid reference target collection '${target}'`);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst ids = [...new Set(refs.map((r) => r.id))];\n\t\tconst tableName = `ec_${target}`;\n\n\t\t// Chunk the IN clause to stay below D1's bind-parameter limit. One\n\t\t// reference per request is the common case today; chunking makes the\n\t\t// helper safe if a future multiSelect-of-references is added.\n\t\tconst found = new Set<string>();\n\t\tlet targetTableMissing = false;\n\t\tfor (const idChunk of chunks(ids, SQL_BATCH_SIZE)) {\n\t\t\ttry {\n\t\t\t\tconst rows = await sql<{ id: string }>`\n\t\t\t\t\tSELECT id FROM ${sql.ref(tableName)}\n\t\t\t\t\tWHERE id IN (${sql.join(idChunk)})\n\t\t\t\t\tAND deleted_at IS NULL\n\t\t\t\t`.execute(db);\n\t\t\t\tfor (const row of rows.rows) {\n\t\t\t\t\tfound.add(row.id);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Missing table = the target collection table doesn't exist\n\t\t\t\t// (orphan reference). Treat all those references as missing.\n\t\t\t\t// Any other DB error (permissions, connection, syntax) must\n\t\t\t\t// propagate — silently dropping data integrity errors as\n\t\t\t\t// \"not found\" is exactly the bug F5 fixes.\n\t\t\t\tif (isMissingTableError(error)) {\n\t\t\t\t\ttargetTableMissing = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tif (targetTableMissing) {\n\t\t\tfor (const ref of refs) {\n\t\t\t\tissues.push(`${ref.field}: target '${ref.id}' not found in collection '${target}'`);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const ref of refs) {\n\t\t\tif (!found.has(ref.id)) {\n\t\t\t\tissues.push(`${ref.field}: target '${ref.id}' not found in collection '${target}'`);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (issues.length === 0) return { ok: true };\n\treturn {\n\t\tok: false,\n\t\terror: {\n\t\t\tcode: \"VALIDATION_ERROR\",\n\t\t\tmessage: issues.join(\"; \"),\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,UAAU,OAAyB;AAC3C,QAAO,UAAU,UAAa,UAAU,QAAQ,UAAU;;;;;;;;;;AAW3D,SAAS,6BAA6B,OAAkC;CACvE,MAAM,cAAc,MAAM,SAAS;AACnC,KAAI,OAAO,gBAAgB,YAAY,YAAY,SAAS,EAAG,QAAO;CACtE,MAAM,aAAa,MAAM;AACzB,KAAI,cAAc,gBAAgB,YAAY;EAC7C,MAAM,iBAA2B,WAAwC;AACzE,MAAI,OAAO,mBAAmB,YAAY,eAAe,SAAS,EAAG,QAAO;;;;;;;AAS9E,SAAS,gBAAgB,MAA0C;AAClE,KAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAO,KAAK,KAAK,QAAQ,OAAO,IAAI,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;AAWhD,eAAsB,oBACrB,IACA,YACA,MACA,UAAiC,EAAE,EACP;CAE5B,MAAM,uBAAuB,MADZ,IAAI,eAAe,GAAG,CACK,wBAAwB,WAAW;AAC/E,KAAI,CAAC,qBACJ,QAAO;EACN,IAAI;EACJ,OAAO;GACN,MAAM;GACN,SAAS,eAAe,WAAW;GACnC;EACD;CAGF,MAAM,SAAmB,EAAE;CAM3B,MAAM,cAAc,IAAI,IAAI,qBAAqB,OAAO,KAAK,MAAM,EAAE,KAAK,CAAC;AAC3E,MAAK,MAAM,OAAO,OAAO,KAAK,KAAK,EAAE;AACpC,MAAI,IAAI,WAAW,IAAI,CAAE;AACzB,MAAI,CAAC,YAAY,IAAI,IAAI,CAC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C,CAAC;EAC/C,MAAM,YAAY,MAAM;EAKxB,MAAM,wBAAQ,IAAI,KAAa;EAC/B,IAAI,qBAAqB;AACzB,OAAK,MAAM,WAAW,OAAO,KAAK,eAAe,CAChD,KAAI;GACH,MAAM,OAAO,MAAM,GAAmB;sBACpB,IAAI,IAAI,UAAU,CAAC;oBACrB,IAAI,KAAK,QAAQ,CAAC;;MAEhC,QAAQ,GAAG;AACb,QAAK,MAAM,OAAO,KAAK,KACtB,OAAM,IAAI,IAAI,GAAG;WAEV,OAAO;AAMf,OAAI,oBAAoB,MAAM,EAAE;AAC/B,yBAAqB;AACrB;;AAED,SAAM;;AAGR,MAAI,oBAAoB;AACvB,QAAK,MAAM,OAAO,KACjB,QAAO,KAAK,GAAG,IAAI,MAAM,YAAY,IAAI,GAAG,6BAA6B,OAAO,GAAG;AAEpF;;AAED,OAAK,MAAM,OAAO,KACjB,KAAI,CAAC,MAAM,IAAI,IAAI,GAAG,CACrB,QAAO,KAAK,GAAG,IAAI,MAAM,YAAY,IAAI,GAAG,6BAA6B,OAAO,GAAG;;AAKtF,KAAI,OAAO,WAAW,EAAG,QAAO,EAAE,IAAI,MAAM;AAC5C,QAAO;EACN,IAAI;EACJ,OAAO;GACN,MAAM;GACN,SAAS,OAAO,KAAK,KAAK;GAC1B;EACD"}
@@ -0,0 +1,7 @@
1
+ //#region src/version.ts
2
+ const VERSION = "0.9.0";
3
+ const COMMIT = "be5f05b";
4
+
5
+ //#endregion
6
+ export { VERSION as n, COMMIT as t };
7
+ //# sourceMappingURL=version-DoxrVdYf.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"version-Bbq8TCrz.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["/**\n * Build-time version constants, replaced by tsdown/Vite `define`.\n * Falls back to \"dev\" when running uncompiled (tests, dev).\n */\n\ndeclare const __EMDASH_VERSION__: string;\ndeclare const __EMDASH_COMMIT__: string;\n\nexport const VERSION: string =\n\ttypeof __EMDASH_VERSION__ !== \"undefined\" ? __EMDASH_VERSION__ : \"dev\";\n\nexport const COMMIT: string = typeof __EMDASH_COMMIT__ !== \"undefined\" ? __EMDASH_COMMIT__ : \"dev\";\n"],"mappings":";AAQA,MAAa;AAGb,MAAa"}
1
+ {"version":3,"file":"version-DoxrVdYf.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["/**\n * Build-time version constants, replaced by tsdown/Vite `define`.\n * Falls back to \"dev\" when running uncompiled (tests, dev).\n */\n\ndeclare const __EMDASH_VERSION__: string;\ndeclare const __EMDASH_COMMIT__: string;\n\nexport const VERSION: string =\n\ttypeof __EMDASH_VERSION__ !== \"undefined\" ? __EMDASH_VERSION__ : \"dev\";\n\nexport const COMMIT: string = typeof __EMDASH_COMMIT__ !== \"undefined\" ? __EMDASH_COMMIT__ : \"dev\";\n"],"mappings":";AAQA,MAAa;AAGb,MAAa"}
@@ -49,7 +49,7 @@ function generateZodSchema(collection) {
49
49
  function generateFieldSchema(field) {
50
50
  let schema = getBaseSchema(field.type, field);
51
51
  if (field.validation) schema = applyValidation(schema, field);
52
- if (!field.required) schema = schema.optional();
52
+ if (!field.required) schema = schema.nullish();
53
53
  if (field.defaultValue !== void 0) schema = schema.default(field.defaultValue);
54
54
  return schema;
55
55
  }
@@ -64,7 +64,7 @@ function getBaseSchema(type, field) {
64
64
  case "slug": return z.string();
65
65
  case "number": return z.number();
66
66
  case "integer": return z.number().int();
67
- case "boolean": return z.boolean();
67
+ case "boolean": return z.preprocess((v) => v === 0 || v === 1 ? Boolean(v) : v, z.boolean());
68
68
  case "datetime": return z.string().datetime().or(z.string().date());
69
69
  case "select": {
70
70
  const options = field.validation?.options;
@@ -84,7 +84,7 @@ function getBaseSchema(type, field) {
84
84
  }
85
85
  case "portableText": return z.array(z.object({
86
86
  _type: z.string(),
87
- _key: z.string()
87
+ _key: z.string().optional()
88
88
  }).passthrough());
89
89
  case "image": return z.object({
90
90
  id: z.string(),
@@ -129,4 +129,4 @@ function applyValidation(schema, field) {
129
129
 
130
130
  //#endregion
131
131
  export { computeContentHash as n, hashString as r, generateZodSchema as t };
132
- //# sourceMappingURL=zod-generator-CpwccCIv.mjs.map
132
+ //# sourceMappingURL=zod-generator-CC0xNe_K.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-generator-CC0xNe_K.mjs","names":[],"sources":["../src/utils/hash.ts","../src/schema/zod-generator.ts"],"sourcesContent":["/**\n * SHA-256 hash of a string, truncated to 16 hex chars (64 bits).\n * For cache invalidation / ETags — not for security.\n */\nexport async function hashString(content: string): Promise<string> {\n\tconst buf = await crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(content));\n\treturn Array.from(new Uint8Array(buf).slice(0, 8), (b) => b.toString(16).padStart(2, \"0\")).join(\n\t\t\"\",\n\t);\n}\n\n/**\n * Compute content hash using Web Crypto API\n *\n * Uses SHA-1 which is the fastest option in SubtleCrypto.\n * SHA-1 is cryptographically weak but fine for content deduplication\n * where we only need to detect identical files, not resist attacks.\n *\n * Returns hex string prefixed with \"sha1:\" for future-proofing\n */\nexport async function computeContentHash(content: Uint8Array | ArrayBuffer): Promise<string> {\n\t// SubtleCrypto.digest() requires BufferSource (ArrayBuffer | ArrayBufferView<ArrayBuffer>).\n\t// Uint8Array.buffer is ArrayBufferLike which may include SharedArrayBuffer in the type system,\n\t// so we ensure we have a plain ArrayBuffer.\n\tlet buf: ArrayBuffer;\n\tif (content instanceof ArrayBuffer) {\n\t\tbuf = content;\n\t} else {\n\t\tbuf = new ArrayBuffer(content.byteLength);\n\t\tnew Uint8Array(buf).set(content);\n\t}\n\tconst hashBuffer = await crypto.subtle.digest(\"SHA-1\", buf);\n\tconst hashArray = new Uint8Array(hashBuffer);\n\tconst hashHex = Array.from(hashArray, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n\treturn `sha1:${hashHex}`;\n}\n","import { z, type ZodTypeAny } from \"zod\";\n\nimport { hashString } from \"../utils/hash.js\";\nimport type { Field, FieldType, CollectionWithFields } 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, ZodTypeAny>> {\n\tconst shape: Record<string, ZodTypeAny> = {};\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): ZodTypeAny {\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: Field): ZodTypeAny {\n\tswitch (type) {\n\t\tcase \"url\":\n\t\t\treturn z.string().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\treturn z.string().datetime().or(z.string().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 \"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 `.passthrough()` 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.passthrough(),\n\t\t\t);\n\n\t\tcase \"image\":\n\t\t\treturn 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});\n\n\t\tcase \"file\":\n\t\t\treturn z.object({\n\t\t\t\tid: z.string(),\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});\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\n/**\n * Apply validation rules to a schema\n */\nfunction applyValidation(schema: ZodTypeAny, field: Field): ZodTypeAny {\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\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(collection: CollectionWithFields): string {\n\tconst interfaceName = getInterfaceName(collection);\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\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 is always needed for bylines\n\tconst imports = [\"ContentBylineCredit\"];\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// Generate individual interfaces\n\tfor (const collection of collections) {\n\t\tlines.push(generateTypeScript(collection));\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\tconst interfaceName = getInterfaceName(collection);\n\t\tlines.push(` ${collection.slug}: ${interfaceName};`);\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: Field): 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 \"portableText\":\n\t\t\treturn \"PortableTextBlock[]\";\n\n\t\tcase \"image\":\n\t\t\treturn \"{ id: string; src?: string; alt?: string; width?: number; height?: number }\";\n\n\t\tcase \"file\":\n\t\t\treturn \"{ id: string; src?: string; filename?: string; mimeType?: string; size?: number }\";\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 * Simple singularization - handles common cases\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 */\nfunction getInterfaceName(collection: CollectionWithFields): string {\n\treturn pascalCase(collection.labelSingular || singularize(collection.slug));\n}\n"],"mappings":";;;;;;;AAIA,eAAsB,WAAW,SAAkC;CAClE,MAAM,MAAM,MAAM,OAAO,OAAO,OAAO,WAAW,IAAI,aAAa,CAAC,OAAO,QAAQ,CAAC;AACpF,QAAO,MAAM,KAAK,IAAI,WAAW,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KAC1F,GACA;;;;;;;;;;;AAYF,eAAsB,mBAAmB,SAAoD;CAI5F,IAAI;AACJ,KAAI,mBAAmB,YACtB,OAAM;MACA;AACN,QAAM,IAAI,YAAY,QAAQ,WAAW;AACzC,MAAI,WAAW,IAAI,CAAC,IAAI,QAAQ;;CAEjC,MAAM,aAAa,MAAM,OAAO,OAAO,OAAO,SAAS,IAAI;CAC3D,MAAM,YAAY,IAAI,WAAW,WAAW;AAE5C,QAAO,QADS,MAAM,KAAK,YAAY,MAAM,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG;;;;;;;;;;;ACnBvF,SAAgB,kBACf,YAC0C;CAC1C,MAAM,QAAoC,EAAE;AAE5C,MAAK,MAAM,SAAS,WAAW,OAC9B,OAAM,MAAM,QAAQ,oBAAoB,MAAM;AAG/C,QAAO,EAAE,OAAO,MAAM;;;;;AAMvB,SAAgB,oBAAoB,OAA0B;CAC7D,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,OAA0B;AACjE,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AAK,OACJ,QAAO,EAAE,OAAO;GACf,IAAI,EAAE,QAAQ;GACd,KAAK,EAAE,QAAQ,CAAC,UAAU;GAC1B,UAAU,EAAE,QAAQ,CAAC,UAAU;GAC/B,UAAU,EAAE,QAAQ,CAAC,UAAU;GAC/B,MAAM,EAAE,QAAQ,CAAC,UAAU;GAC3B,CAAC;EAEH,KAAK,YACJ,QAAO,EAAE,QAAQ;EAElB,KAAK,OACJ,QAAO,EAAE,SAAS;EAEnB,QACC,QAAO,EAAE,SAAS;;;;;;AAOrB,SAAS,gBAAgB,QAAoB,OAA0B;CACtE,MAAM,aAAa,MAAM;AACzB,KAAI,CAAC,WAAY,QAAO;AAGxB,KAAI,kBAAkB,EAAE,WAAW;EAClC,IAAI,YAAY;AAChB,MAAI,WAAW,cAAc,OAC5B,aAAY,UAAU,IAAI,WAAW,UAAU;AAEhD,MAAI,WAAW,cAAc,OAC5B,aAAY,UAAU,IAAI,WAAW,UAAU;AAEhD,MAAI,WAAW,QACd,aAAY,UAAU,MAAM,IAAI,OAAO,WAAW,QAAQ,CAAC;AAE5D,SAAO;;AAIR,KAAI,kBAAkB,EAAE,WAAW;EAClC,IAAI,YAAY;AAChB,MAAI,WAAW,QAAQ,OACtB,aAAY,UAAU,IAAI,WAAW,IAAI;AAE1C,MAAI,WAAW,QAAQ,OACtB,aAAY,UAAU,IAAI,WAAW,IAAI;AAE1C,SAAO;;AAGR,QAAO"}
package/locals.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import type { User } from "@emdash-cms/auth";
9
9
 
10
- import type { EmDashHandlers, EmDashManifest } from "./dist/types.d.mts";
10
+ import type { EmDashHandlers } from "./dist/types.d.mts";
11
11
 
12
12
  declare global {
13
13
  namespace App {
@@ -17,11 +17,6 @@ declare global {
17
17
  */
18
18
  emdash: EmDashHandlers;
19
19
 
20
- /**
21
- * EmDash manifest - the serialized admin configuration
22
- */
23
- emdashManifest: EmDashManifest;
24
-
25
20
  /**
26
21
  * Authenticated user - set by auth middleware when a valid session exists
27
22
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emdash",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Astro-native CMS with WordPress migration support",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -134,6 +134,7 @@
134
134
  "imports": {
135
135
  "#api/schemas.js": "./src/api/schemas/index.js",
136
136
  "#api/*": "./src/api/*",
137
+ "#config/*": "./src/config/*",
137
138
  "#db/*": "./src/database/*",
138
139
  "#auth/*": "./src/auth/*",
139
140
  "#schema/*": "./src/schema/*",
@@ -159,6 +160,8 @@
159
160
  "dependencies": {
160
161
  "@floating-ui/react": "^0.27.16",
161
162
  "@modelcontextprotocol/sdk": "^1.26.0",
163
+ "@oslojs/crypto": "^1.0.1",
164
+ "@oslojs/encoding": "^1.1.0",
162
165
  "@portabletext/toolkit": "^5.0.1",
163
166
  "@tiptap/core": "^3.20.0",
164
167
  "@tiptap/extension-focus": "^3.20.0",
@@ -191,9 +194,9 @@
191
194
  "ulidx": "^2.4.1",
192
195
  "upng-js": "^2.1.0",
193
196
  "zod": "^4.3.5",
194
- "@emdash-cms/admin": "0.8.0",
195
- "@emdash-cms/auth": "0.8.0",
196
- "@emdash-cms/gutenberg-to-portable-text": "0.8.0"
197
+ "@emdash-cms/admin": "0.9.0",
198
+ "@emdash-cms/auth": "0.9.0",
199
+ "@emdash-cms/gutenberg-to-portable-text": "0.9.0"
197
200
  },
198
201
  "optionalDependencies": {
199
202
  "@libsql/kysely-libsql": "^0.4.0",
@@ -201,9 +204,7 @@
201
204
  },
202
205
  "peerDependencies": {
203
206
  "@astrojs/react": ">=5.0.0-beta.0",
204
- "@emdash-cms/auth-atproto": ">=0.2.0",
205
- "@tanstack/react-query": ">=5.0.0",
206
- "@tanstack/react-router": ">=1.100.0",
207
+ "@emdash-cms/auth-atproto": ">=0.2.1",
207
208
  "astro": ">=6.0.0-beta.0",
208
209
  "react": ">=18.0.0",
209
210
  "react-dom": ">=18.0.0"
@@ -228,7 +229,7 @@
228
229
  "vite": "^6.0.0",
229
230
  "vitest": "^4.0.18",
230
231
  "zod-openapi": "^5.4.6",
231
- "@emdash-cms/blocks": "0.8.0"
232
+ "@emdash-cms/blocks": "0.9.0"
232
233
  },
233
234
  "repository": {
234
235
  "type": "git",
@@ -316,11 +316,13 @@ export async function checkRateLimit(
316
316
  /**
317
317
  * Hash an IP address for storage (never store cleartext IPs).
318
318
  *
319
- * Uses full SHA-256 with an application salt to prevent rainbow-table
320
- * recovery of IPs. The caller should pass a site-specific secret;
321
- * falls back to a static salt if none is provided.
319
+ * Uses full SHA-256 with a site-specific salt to prevent rainbow-table
320
+ * recovery of IPs. The salt must be provided by the caller — typically
321
+ * via `resolveSecretsCached(db).ipSalt` from `#config/secrets.js`. The
322
+ * salt is generated and persisted on first need so it's stable across
323
+ * requests within a deployment but unique per install.
322
324
  */
323
- export async function hashIp(ip: string, salt: string = "emdash-ip-salt"): Promise<string> {
325
+ export async function hashIp(ip: string, salt: string): Promise<string> {
324
326
  const data = `ip:${salt}:${ip}`;
325
327
  const buf = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(data));
326
328
  return Array.from(new Uint8Array(buf), (b) => b.toString(16).padStart(2, "0")).join("");
@@ -1093,6 +1093,15 @@ export async function handleContentUnschedule(
1093
1093
  data: { item },
1094
1094
  };
1095
1095
  } catch (error) {
1096
+ if (error instanceof EmDashValidationError) {
1097
+ return {
1098
+ success: false,
1099
+ error: {
1100
+ code: "VALIDATION_ERROR",
1101
+ message: error.message,
1102
+ },
1103
+ };
1104
+ }
1096
1105
  console.error("Content unschedule error:", error);
1097
1106
  return {
1098
1107
  success: false,
@@ -1115,12 +1124,13 @@ export async function handleContentPublish(
1115
1124
  db: Kysely<Database>,
1116
1125
  collection: string,
1117
1126
  id: string,
1127
+ options: { publishedAt?: string } = {},
1118
1128
  ): Promise<ApiResult<ContentResponse>> {
1119
1129
  try {
1120
1130
  const item = await withTransaction(db, async (trx) => {
1121
1131
  const repo = new ContentRepository(trx);
1122
1132
  const resolvedId = (await resolveId(repo, collection, id)) ?? id;
1123
- return repo.publish(collection, resolvedId);
1133
+ return repo.publish(collection, resolvedId, options.publishedAt);
1124
1134
  });
1125
1135
 
1126
1136
  const hasSeo = await collectionHasSeo(db, collection);
@@ -1131,6 +1141,15 @@ export async function handleContentPublish(
1131
1141
  data: { item },
1132
1142
  };
1133
1143
  } catch (error) {
1144
+ if (error instanceof EmDashValidationError) {
1145
+ return {
1146
+ success: false,
1147
+ error: {
1148
+ code: "VALIDATION_ERROR",
1149
+ message: error.message,
1150
+ },
1151
+ };
1152
+ }
1134
1153
  console.error("Content publish error:", error);
1135
1154
  return {
1136
1155
  success: false,
@@ -1168,6 +1187,15 @@ export async function handleContentUnpublish(
1168
1187
  data: { item },
1169
1188
  };
1170
1189
  } catch (error) {
1190
+ if (error instanceof EmDashValidationError) {
1191
+ return {
1192
+ success: false,
1193
+ error: {
1194
+ code: "VALIDATION_ERROR",
1195
+ message: error.message,
1196
+ },
1197
+ };
1198
+ }
1171
1199
  console.error("Content unpublish error:", error);
1172
1200
  return {
1173
1201
  success: false,
@@ -135,6 +135,11 @@ export async function handleDeviceCodeRequest(
135
135
  verificationUri: string,
136
136
  ): Promise<ApiResult<DeviceCodeResponse>> {
137
137
  try {
138
+ // Note: client_id is accepted but not validated against _emdash_oauth_clients
139
+ // because the CLI uses a well-known built-in client ID ("emdash-cli") that
140
+ // isn't stored in the DB. Full client_id validation + scope clamping for the
141
+ // device flow is tracked as a follow-up.
142
+
138
143
  // Parse and validate scopes
139
144
  const requestedScopes = input.scope ? input.scope.split(" ").filter(Boolean) : [];
140
145
  const scopes = normalizeScopes(requestedScopes);
@@ -24,6 +24,7 @@ import {
24
24
  } from "../../plugins/marketplace.js";
25
25
  import type { SandboxRunner } from "../../plugins/sandbox/types.js";
26
26
  import { PluginStateRepository } from "../../plugins/state.js";
27
+ import { normalizeCapabilities } from "../../plugins/types.js";
27
28
  import type { PluginManifest } from "../../plugins/types.js";
28
29
  import { EmDashStorageError } from "../../storage/types.js";
29
30
  import type { Storage } from "../../storage/types.js";
@@ -95,11 +96,17 @@ function diffCapabilities(
95
96
  oldCaps: string[],
96
97
  newCaps: string[],
97
98
  ): { added: string[]; removed: string[] } {
98
- const oldSet = new Set(oldCaps);
99
- const newSet = new Set(newCaps);
99
+ // Normalize both sides before diffing so that an installed v1 manifest
100
+ // declaring `read:content` and an upgrade v2 manifest declaring
101
+ // `content:read` produces an empty diff — users should not see a
102
+ // spurious "capability changed" prompt for a pure rename.
103
+ const oldNorm = normalizeCapabilities(oldCaps);
104
+ const newNorm = normalizeCapabilities(newCaps);
105
+ const oldSet = new Set(oldNorm);
106
+ const newSet = new Set(newNorm);
100
107
  return {
101
- added: newCaps.filter((c) => !oldSet.has(c)),
102
- removed: oldCaps.filter((c) => !newSet.has(c)),
108
+ added: newNorm.filter((c) => !oldSet.has(c)),
109
+ removed: oldNorm.filter((c) => !newSet.has(c)),
103
110
  };
104
111
  }
105
112