emdash 0.9.0 → 0.11.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 (239) hide show
  1. package/dist/{adapters-DoNJiveC.d.mts → adapters-BktHA7EO.d.mts} +1 -1
  2. package/dist/{adapters-DoNJiveC.d.mts.map → adapters-BktHA7EO.d.mts.map} +1 -1
  3. package/dist/{apply-BzltprvY.mjs → apply-Ded_1vng.mjs} +167 -254
  4. package/dist/apply-Ded_1vng.mjs.map +1 -0
  5. package/dist/astro/index.d.mts +6 -6
  6. package/dist/astro/index.mjs +10 -2
  7. package/dist/astro/index.mjs.map +1 -1
  8. package/dist/astro/middleware/auth.d.mts +5 -5
  9. package/dist/astro/middleware/auth.mjs +5 -5
  10. package/dist/astro/middleware/redirect.mjs +5 -5
  11. package/dist/astro/middleware/request-context.mjs +4 -4
  12. package/dist/astro/middleware/setup.mjs +1 -1
  13. package/dist/astro/middleware.d.mts.map +1 -1
  14. package/dist/astro/middleware.mjs +94 -43
  15. package/dist/astro/middleware.mjs.map +1 -1
  16. package/dist/astro/types.d.mts +12 -11
  17. package/dist/astro/types.d.mts.map +1 -1
  18. package/dist/{base64-BRICGH2l.mjs → base64-MBPo9ozB.mjs} +1 -1
  19. package/dist/{base64-BRICGH2l.mjs.map → base64-MBPo9ozB.mjs.map} +1 -1
  20. package/dist/{byline-BSaNL1w7.mjs → byline-gFn1r0vA.mjs} +4 -4
  21. package/dist/{byline-BSaNL1w7.mjs.map → byline-gFn1r0vA.mjs.map} +1 -1
  22. package/dist/{bylines-CvJ3PYz2.mjs → bylines-DTFI8nDM.mjs} +5 -5
  23. package/dist/{bylines-CvJ3PYz2.mjs.map → bylines-DTFI8nDM.mjs.map} +1 -1
  24. package/dist/{cache-C6N_hhN7.mjs → cache-BAJbeoZ8.mjs} +3 -3
  25. package/dist/{cache-C6N_hhN7.mjs.map → cache-BAJbeoZ8.mjs.map} +1 -1
  26. package/dist/{chunks-NBQVDOci.mjs → chunks-BK1oZS-l.mjs} +2 -2
  27. package/dist/{chunks-NBQVDOci.mjs.map → chunks-BK1oZS-l.mjs.map} +1 -1
  28. package/dist/cli/index.mjs +342 -95
  29. package/dist/cli/index.mjs.map +1 -1
  30. package/dist/client/cf-access.d.mts +1 -1
  31. package/dist/client/index.d.mts +1 -1
  32. package/dist/client/index.mjs +1 -1
  33. package/dist/{config-BI0V3ICQ.mjs → config-CVssduLe.mjs} +1 -1
  34. package/dist/{config-BI0V3ICQ.mjs.map → config-CVssduLe.mjs.map} +1 -1
  35. package/dist/{content-8lOYF0pr.mjs → content-CERxPUN0.mjs} +14 -3
  36. package/dist/content-CERxPUN0.mjs.map +1 -0
  37. package/dist/database/instrumentation.d.mts +6 -4
  38. package/dist/database/instrumentation.d.mts.map +1 -1
  39. package/dist/database/instrumentation.mjs +19 -7
  40. package/dist/database/instrumentation.mjs.map +1 -1
  41. package/dist/db/index.d.mts +3 -3
  42. package/dist/db/index.mjs +1 -1
  43. package/dist/db/libsql.d.mts +1 -1
  44. package/dist/db/postgres.d.mts +1 -1
  45. package/dist/db/sqlite.d.mts +1 -1
  46. package/dist/{db-errors-WRezodiz.mjs → db-errors-B7P2pSCn.mjs} +1 -1
  47. package/dist/{db-errors-WRezodiz.mjs.map → db-errors-B7P2pSCn.mjs.map} +1 -1
  48. package/dist/{default-D8ksjWhO.mjs → default-pHuz9WF6.mjs} +1 -1
  49. package/dist/{default-D8ksjWhO.mjs.map → default-pHuz9WF6.mjs.map} +1 -1
  50. package/dist/{error-D_-tqP-I.mjs → error-DqnRMM5z.mjs} +1 -1
  51. package/dist/{error-D_-tqP-I.mjs.map → error-DqnRMM5z.mjs.map} +1 -1
  52. package/dist/{index-BFRaVcD6.d.mts → index-Cg-rC4Gj.d.mts} +110 -87
  53. package/dist/index-Cg-rC4Gj.d.mts.map +1 -0
  54. package/dist/index.d.mts +11 -11
  55. package/dist/index.mjs +29 -28
  56. package/dist/{load-DDqMMvZL.mjs → load-DR1VwFXR.mjs} +2 -2
  57. package/dist/{load-DDqMMvZL.mjs.map → load-DR1VwFXR.mjs.map} +1 -1
  58. package/dist/{loader-CKLbBnhK.mjs → loader-ou_PXAjg.mjs} +31 -6
  59. package/dist/loader-ou_PXAjg.mjs.map +1 -0
  60. package/dist/{manifest-schema-DqWNC3lM.mjs → manifest-schema-CXAbd1vH.mjs} +1 -1
  61. package/dist/{manifest-schema-DqWNC3lM.mjs.map → manifest-schema-CXAbd1vH.mjs.map} +1 -1
  62. package/dist/media/index.d.mts +1 -1
  63. package/dist/media/index.mjs +1 -1
  64. package/dist/media/local-runtime.d.mts +7 -7
  65. package/dist/media/local-runtime.mjs +3 -3
  66. package/dist/{media-BW32b4gi.mjs → media-1fFhub9c.mjs} +22 -10
  67. package/dist/media-1fFhub9c.mjs.map +1 -0
  68. package/dist/{mode-ier8jbBk.mjs → mode-YhqNVef_.mjs} +1 -1
  69. package/dist/{mode-ier8jbBk.mjs.map → mode-YhqNVef_.mjs.map} +1 -1
  70. package/dist/{options-BVp3UsTS.mjs → options-nPxWnrya.mjs} +1 -1
  71. package/dist/{options-BVp3UsTS.mjs.map → options-nPxWnrya.mjs.map} +1 -1
  72. package/dist/page/index.d.mts +2 -2
  73. package/dist/{patterns-CrCYkMBb.mjs → patterns-DsUZ4uxI.mjs} +1 -1
  74. package/dist/{patterns-CrCYkMBb.mjs.map → patterns-DsUZ4uxI.mjs.map} +1 -1
  75. package/dist/{placeholder-BE4o_2dc.d.mts → placeholder-CDPtkelt.d.mts} +1 -1
  76. package/dist/{placeholder-BE4o_2dc.d.mts.map → placeholder-CDPtkelt.d.mts.map} +1 -1
  77. package/dist/{placeholder-CIJejMlK.mjs → placeholder-Ci0RLeCk.mjs} +1 -1
  78. package/dist/{placeholder-CIJejMlK.mjs.map → placeholder-Ci0RLeCk.mjs.map} +1 -1
  79. package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
  80. package/dist/plugins/adapt-sandbox-entry.mjs +2 -2
  81. package/dist/{public-url-DByxYjUw.mjs → public-url-B1AxbbbQ.mjs} +1 -1
  82. package/dist/{public-url-DByxYjUw.mjs.map → public-url-B1AxbbbQ.mjs.map} +1 -1
  83. package/dist/{query-Cg9ZKRQ0.mjs → query-8c_meo_K.mjs} +13 -13
  84. package/dist/{query-Cg9ZKRQ0.mjs.map → query-8c_meo_K.mjs.map} +1 -1
  85. package/dist/{redirect-BhUBKRc1.mjs → redirect-C5H7VGIX.mjs} +3 -3
  86. package/dist/{redirect-BhUBKRc1.mjs.map → redirect-C5H7VGIX.mjs.map} +1 -1
  87. package/dist/{registry-Dw70ChxB.mjs → registry-Do34mz_P.mjs} +7 -6
  88. package/dist/registry-Do34mz_P.mjs.map +1 -0
  89. package/dist/{request-cache-B-bmkipQ.mjs → request-cache-D4I69LeL.mjs} +6 -2
  90. package/dist/request-cache-D4I69LeL.mjs.map +1 -0
  91. package/dist/request-context.d.mts +27 -1
  92. package/dist/request-context.d.mts.map +1 -1
  93. package/dist/request-context.mjs +16 -3
  94. package/dist/request-context.mjs.map +1 -1
  95. package/dist/{runner-C7ADox5q.mjs → runner-DIcU2UCC.mjs} +465 -148
  96. package/dist/runner-DIcU2UCC.mjs.map +1 -0
  97. package/dist/{runner-Bnoj7vjK.d.mts → runner-Iu3IZSDM.d.mts} +2 -2
  98. package/dist/{runner-Bnoj7vjK.d.mts.map → runner-Iu3IZSDM.d.mts.map} +1 -1
  99. package/dist/runtime.d.mts +6 -6
  100. package/dist/runtime.mjs +3 -3
  101. package/dist/{search-dOGEccMa.mjs → search-DuWhx4NG.mjs} +322 -108
  102. package/dist/search-DuWhx4NG.mjs.map +1 -0
  103. package/dist/{secrets-CW3reAnU.mjs → secrets-CZ8rxLX3.mjs} +3 -3
  104. package/dist/{secrets-CW3reAnU.mjs.map → secrets-CZ8rxLX3.mjs.map} +1 -1
  105. package/dist/seed/index.d.mts +2 -2
  106. package/dist/seed/index.mjs +15 -14
  107. package/dist/seo/index.d.mts +1 -1
  108. package/dist/storage/local.d.mts +1 -1
  109. package/dist/storage/local.mjs +1 -1
  110. package/dist/storage/s3.d.mts +1 -1
  111. package/dist/storage/s3.mjs +1 -1
  112. package/dist/taxonomies-Bw76xAxo.mjs +407 -0
  113. package/dist/taxonomies-Bw76xAxo.mjs.map +1 -0
  114. package/dist/taxonomy-D6NvlKo8.mjs +218 -0
  115. package/dist/taxonomy-D6NvlKo8.mjs.map +1 -0
  116. package/dist/{tokens-D7zMmWi2.mjs → tokens-CyRDPVW2.mjs} +2 -2
  117. package/dist/{tokens-D7zMmWi2.mjs.map → tokens-CyRDPVW2.mjs.map} +1 -1
  118. package/dist/{transaction-Cn2rjY78.mjs → transaction-D44LBXvU.mjs} +1 -1
  119. package/dist/{transaction-Cn2rjY78.mjs.map → transaction-D44LBXvU.mjs.map} +1 -1
  120. package/dist/{transport-DNEfeMaU.d.mts → transport-DX_5rpsq.d.mts} +1 -1
  121. package/dist/{transport-DNEfeMaU.d.mts.map → transport-DX_5rpsq.d.mts.map} +1 -1
  122. package/dist/{transport-BeMCmin1.mjs → transport-xpzIjCIB.mjs} +1 -1
  123. package/dist/{transport-BeMCmin1.mjs.map → transport-xpzIjCIB.mjs.map} +1 -1
  124. package/dist/{types-CIOg5AR8.mjs → types-56BKbld_.mjs} +1 -1
  125. package/dist/types-56BKbld_.mjs.map +1 -0
  126. package/dist/{types-CRxNbK-Z.mjs → types-BIgulNsW.mjs} +2 -2
  127. package/dist/{types-CRxNbK-Z.mjs.map → types-BIgulNsW.mjs.map} +1 -1
  128. package/dist/{types-CrtWgIvl.d.mts → types-BQx6ZXpR.d.mts} +10 -1
  129. package/dist/types-BQx6ZXpR.d.mts.map +1 -0
  130. package/dist/{types-CJsYGpco.d.mts → types-B_CXXnzh.d.mts} +1 -1
  131. package/dist/{types-CJsYGpco.d.mts.map → types-B_CXXnzh.d.mts.map} +1 -1
  132. package/dist/{types-M78DQ1lx.d.mts → types-C-aFbqmA.d.mts} +1 -1
  133. package/dist/{types-M78DQ1lx.d.mts.map → types-C-aFbqmA.d.mts.map} +1 -1
  134. package/dist/types-DiI8NOG_.mjs +16 -0
  135. package/dist/types-DiI8NOG_.mjs.map +1 -0
  136. package/dist/{types-BuBIptGk.d.mts → types-IN5z_S3P.d.mts} +158 -92
  137. package/dist/types-IN5z_S3P.d.mts.map +1 -0
  138. package/dist/{types-BSyXeCFW.d.mts → types-IZSZfEwv.d.mts} +4 -3
  139. package/dist/types-IZSZfEwv.d.mts.map +1 -0
  140. package/dist/{types-CDbKp7ND.mjs → types-K-EkEQCI.mjs} +1 -1
  141. package/dist/{types-CDbKp7ND.mjs.map → types-K-EkEQCI.mjs.map} +1 -1
  142. package/dist/{validate-BfQh_C_y.d.mts → validate-CO3JjFV5.d.mts} +22 -5
  143. package/dist/validate-CO3JjFV5.d.mts.map +1 -0
  144. package/dist/{validate-Baqf0slj.mjs → validate-UK4Ja1uo.mjs} +14 -10
  145. package/dist/validate-UK4Ja1uo.mjs.map +1 -0
  146. package/dist/{validation-BfEI7tNe.mjs → validation-Vc5DQkJa.mjs} +5 -5
  147. package/dist/{validation-BfEI7tNe.mjs.map → validation-Vc5DQkJa.mjs.map} +1 -1
  148. package/dist/version-Bg31I_Ff.mjs +7 -0
  149. package/dist/{version-DoxrVdYf.mjs.map → version-Bg31I_Ff.mjs.map} +1 -1
  150. package/dist/{zod-generator-CC0xNe_K.mjs → zod-generator-CHnJUP2l.mjs} +8 -3
  151. package/dist/zod-generator-CHnJUP2l.mjs.map +1 -0
  152. package/package.json +9 -8
  153. package/src/api/errors.ts +5 -0
  154. package/src/api/handlers/content.ts +20 -0
  155. package/src/api/handlers/dashboard.ts +29 -36
  156. package/src/api/handlers/media-allowlist.ts +40 -0
  157. package/src/api/handlers/media.ts +1 -1
  158. package/src/api/handlers/menus.ts +400 -89
  159. package/src/api/handlers/taxonomies.ts +273 -97
  160. package/src/api/handlers/validate-media-fields.ts +125 -0
  161. package/src/api/schemas/common.ts +7 -0
  162. package/src/api/schemas/media.ts +23 -3
  163. package/src/api/schemas/menus.ts +23 -0
  164. package/src/api/schemas/schema.ts +11 -2
  165. package/src/api/schemas/taxonomies.ts +39 -0
  166. package/src/astro/integration/routes.ts +10 -0
  167. package/src/astro/middleware.ts +46 -11
  168. package/src/astro/routes/api/content/[collection]/[id]/permanent.ts +1 -1
  169. package/src/astro/routes/api/import/wordpress/rewrite-url-helpers.ts +196 -0
  170. package/src/astro/routes/api/import/wordpress/rewrite-urls.ts +9 -177
  171. package/src/astro/routes/api/media/upload-url.ts +10 -4
  172. package/src/astro/routes/api/media.ts +12 -4
  173. package/src/astro/routes/api/menus/[name]/items.ts +16 -6
  174. package/src/astro/routes/api/menus/[name]/reorder.ts +8 -3
  175. package/src/astro/routes/api/menus/[name]/translations.ts +82 -0
  176. package/src/astro/routes/api/menus/[name].ts +19 -10
  177. package/src/astro/routes/api/menus/index.ts +9 -6
  178. package/src/astro/routes/api/taxonomies/[name]/terms/[slug]/translations.ts +89 -0
  179. package/src/astro/routes/api/taxonomies/[name]/terms/[slug].ts +22 -22
  180. package/src/astro/routes/api/taxonomies/[name]/terms/index.ts +11 -14
  181. package/src/astro/routes/api/taxonomies/index.ts +9 -6
  182. package/src/astro/types.ts +5 -1
  183. package/src/auth/rate-limit.ts +3 -3
  184. package/src/cli/commands/bundle-utils.ts +81 -6
  185. package/src/cli/commands/bundle.ts +18 -15
  186. package/src/cli/commands/export-seed.ts +139 -24
  187. package/src/cli/commands/plugin-init.ts +216 -90
  188. package/src/database/instrumentation.ts +22 -8
  189. package/src/database/migrations/016_api_tokens.ts +18 -3
  190. package/src/database/migrations/036_i18n_menus_and_taxonomies.ts +477 -0
  191. package/src/database/migrations/037_credential_algorithm.ts +18 -0
  192. package/src/database/migrations/runner.ts +4 -0
  193. package/src/database/repositories/content.ts +11 -0
  194. package/src/database/repositories/media.ts +40 -10
  195. package/src/database/repositories/taxonomy.ts +193 -89
  196. package/src/database/types.ts +12 -3
  197. package/src/emdash-runtime.ts +16 -3
  198. package/src/fields/file.ts +7 -6
  199. package/src/fields/image.ts +12 -11
  200. package/src/fields/types.ts +3 -0
  201. package/src/i18n/resolve.ts +37 -0
  202. package/src/index.ts +1 -1
  203. package/src/loader.ts +49 -2
  204. package/src/mcp/server.ts +114 -26
  205. package/src/media/mime.ts +75 -0
  206. package/src/menus/index.ts +143 -124
  207. package/src/menus/types.ts +15 -1
  208. package/src/plugins/types.ts +81 -191
  209. package/src/request-cache.ts +6 -2
  210. package/src/request-context.ts +42 -2
  211. package/src/schema/registry.ts +5 -5
  212. package/src/schema/types.ts +3 -2
  213. package/src/schema/zod-generator.ts +12 -2
  214. package/src/seed/apply.ts +157 -54
  215. package/src/seed/types.ts +18 -1
  216. package/src/seed/validate.ts +27 -13
  217. package/src/taxonomies/index.ts +230 -213
  218. package/src/taxonomies/types.ts +10 -0
  219. package/dist/apply-BzltprvY.mjs.map +0 -1
  220. package/dist/content-8lOYF0pr.mjs.map +0 -1
  221. package/dist/index-BFRaVcD6.d.mts.map +0 -1
  222. package/dist/loader-CKLbBnhK.mjs.map +0 -1
  223. package/dist/media-BW32b4gi.mjs.map +0 -1
  224. package/dist/registry-Dw70ChxB.mjs.map +0 -1
  225. package/dist/request-cache-B-bmkipQ.mjs.map +0 -1
  226. package/dist/runner-C7ADox5q.mjs.map +0 -1
  227. package/dist/search-dOGEccMa.mjs.map +0 -1
  228. package/dist/taxonomies-ZlRtD6AG.mjs +0 -315
  229. package/dist/taxonomies-ZlRtD6AG.mjs.map +0 -1
  230. package/dist/types-4fVtCIm0.mjs +0 -68
  231. package/dist/types-4fVtCIm0.mjs.map +0 -1
  232. package/dist/types-BSyXeCFW.d.mts.map +0 -1
  233. package/dist/types-BuBIptGk.d.mts.map +0 -1
  234. package/dist/types-CIOg5AR8.mjs.map +0 -1
  235. package/dist/types-CrtWgIvl.d.mts.map +0 -1
  236. package/dist/validate-Baqf0slj.mjs.map +0 -1
  237. package/dist/validate-BfQh_C_y.d.mts.map +0 -1
  238. package/dist/version-DoxrVdYf.mjs +0 -7
  239. package/dist/zod-generator-CC0xNe_K.mjs.map +0 -1
@@ -1,8 +1,8 @@
1
- import "../../types-CrtWgIvl.mjs";
2
- import "../../index-BFRaVcD6.mjs";
3
- import "../../runner-Bnoj7vjK.mjs";
4
- import "../../types-BuBIptGk.mjs";
5
- import "../../validate-BfQh_C_y.mjs";
1
+ import "../../types-BQx6ZXpR.mjs";
2
+ import "../../index-Cg-rC4Gj.mjs";
3
+ import "../../runner-Iu3IZSDM.mjs";
4
+ import "../../types-IN5z_S3P.mjs";
5
+ import "../../validate-CO3JjFV5.mjs";
6
6
  import { EmDashHandlers } from "../types.mjs";
7
7
  import { User } from "@emdash-cms/auth";
8
8
  import * as astro from "astro";
@@ -1,8 +1,8 @@
1
- import "../../base64-BRICGH2l.mjs";
2
- import "../../types-CRxNbK-Z.mjs";
3
- import { t as apiError } from "../../error-D_-tqP-I.mjs";
4
- import { t as getPublicOrigin } from "../../public-url-DByxYjUw.mjs";
5
- import { t as getAuthMode } from "../../mode-ier8jbBk.mjs";
1
+ import "../../base64-MBPo9ozB.mjs";
2
+ import "../../types-BIgulNsW.mjs";
3
+ import { t as apiError } from "../../error-DqnRMM5z.mjs";
4
+ import { t as getPublicOrigin } from "../../public-url-B1AxbbbQ.mjs";
5
+ import { t as getAuthMode } from "../../mode-YhqNVef_.mjs";
6
6
  import { ulid } from "ulidx";
7
7
  import { defineMiddleware } from "astro:middleware";
8
8
  import virtualConfig from "virtual:emdash/config";
@@ -1,9 +1,9 @@
1
1
  import "../../dialect-helpers-BKCvISIQ.mjs";
2
- import "../../base64-BRICGH2l.mjs";
3
- import "../../types-CRxNbK-Z.mjs";
4
- import { t as RedirectRepository } from "../../redirect-BhUBKRc1.mjs";
5
- import { a as setCachedRedirects, i as matchCachedPatterns, n as getCachedRedirects } from "../../cache-C6N_hhN7.mjs";
6
- import { r as getDb } from "../../loader-CKLbBnhK.mjs";
2
+ import "../../base64-MBPo9ozB.mjs";
3
+ import "../../types-BIgulNsW.mjs";
4
+ import { t as RedirectRepository } from "../../redirect-C5H7VGIX.mjs";
5
+ import { a as setCachedRedirects, i as matchCachedPatterns, n as getCachedRedirects } from "../../cache-BAJbeoZ8.mjs";
6
+ import { r as getDb } from "../../loader-ou_PXAjg.mjs";
7
7
  import { defineMiddleware } from "astro:middleware";
8
8
 
9
9
  //#region src/astro/middleware/redirect.ts
@@ -1,8 +1,8 @@
1
1
  import { getRequestContext, runWithContext } from "../../request-context.mjs";
2
- import "../../base64-BRICGH2l.mjs";
3
- import "../../options-BVp3UsTS.mjs";
4
- import { n as parseContentId, r as verifyPreviewToken } from "../../tokens-D7zMmWi2.mjs";
5
- import { i as resolveSecretsCached } from "../../secrets-CW3reAnU.mjs";
2
+ import "../../base64-MBPo9ozB.mjs";
3
+ import "../../options-nPxWnrya.mjs";
4
+ import { n as parseContentId, r as verifyPreviewToken } from "../../tokens-CyRDPVW2.mjs";
5
+ import { i as resolveSecretsCached } from "../../secrets-CZ8rxLX3.mjs";
6
6
  import { defineMiddleware } from "astro:middleware";
7
7
 
8
8
  //#region src/visual-editing/toolbar.ts
@@ -1,4 +1,4 @@
1
- import { t as getAuthMode } from "../../mode-ier8jbBk.mjs";
1
+ import { t as getAuthMode } from "../../mode-YhqNVef_.mjs";
2
2
  import { defineMiddleware } from "astro:middleware";
3
3
 
4
4
  //#region src/astro/middleware/setup.ts
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.mts","names":[],"sources":["../../src/astro/middleware.ts"],"mappings":";;;;;;AAwOA;;;cAAa,SAAA,EAsUX,KAAA,CAtUoB,iBAAA"}
1
+ {"version":3,"file":"middleware.d.mts","names":[],"sources":["../../src/astro/middleware.ts"],"mappings":";;;;;;AAwQA;;;cAAa,SAAA,EAyUX,KAAA,CAzUoB,iBAAA"}
@@ -1,36 +1,37 @@
1
- import { r as runMigrations } from "../runner-C7ADox5q.mjs";
2
- import { getRequestContext, runWithContext } from "../request-context.mjs";
1
+ import { r as runMigrations } from "../runner-DIcU2UCC.mjs";
2
+ import { createRequestMetrics, getRequestContext, runWithContext } from "../request-context.mjs";
3
3
  import { createRecorder, flushRecorder, isInstrumentationEnabled, kyselyLogOption } from "../database/instrumentation.mjs";
4
4
  import "../connection-2igzM-AT.mjs";
5
5
  import { t as validateIdentifier } from "../validate-VPnKoIzW.mjs";
6
6
  import { o as isSqlite } from "../dialect-helpers-BKCvISIQ.mjs";
7
- import { At as handleContentTranslations, Ct as handleContentGetIncludingTrashed, Dt as handleContentPublish, Et as handleContentPermanentDelete, G as sanitizeHeadersForSandbox, H as resolveExclusiveHooks, I as PluginRouteRegistry, K as getTrustedProxyHeaders, L as DEV_CONSOLE_EMAIL_PLUGIN_ID, Mt as handleContentUnschedule, Nt as handleContentUpdate, Ot as handleContentRestore, Pt as validateRev, R as devConsoleEmailDeliver, St as handleContentGet, Tt as handleContentListTrashed, U as CronExecutor, V as createHookPipeline, W as extractRequestMeta, X as after, _t as handleContentCountTrashed, bt as handleContentDiscardDraft, ct as handleMediaGet, dt as handleRevisionGet, ft as handleRevisionList, gt as handleContentCountScheduled, ht as handleContentCompare, it as PluginStateRepository, jt as handleContentUnpublish, kt as handleContentSchedule, lt as handleMediaList, ot as handleMediaCreate, pt as handleRevisionRestore, q as definePlugin, st as handleMediaDelete, tt as loadBundleFromR2, ut as handleMediaUpdate, vt as handleContentCreate, wt as handleContentList, xt as handleContentDuplicate, yt as handleContentDelete, z as EmailPipeline } from "../search-dOGEccMa.mjs";
8
- import { r as RevisionRepository } from "../content-8lOYF0pr.mjs";
9
- import "../base64-BRICGH2l.mjs";
10
- import "../types-CRxNbK-Z.mjs";
11
- import { t as MediaRepository } from "../media-BW32b4gi.mjs";
12
- import "../apply-BzltprvY.mjs";
13
- import { t as OptionsRepository } from "../options-BVp3UsTS.mjs";
14
- import "../redirect-BhUBKRc1.mjs";
15
- import "../byline-BSaNL1w7.mjs";
16
- import { n as normalizeMediaValue } from "../placeholder-CIJejMlK.mjs";
17
- import { i as setI18nConfig } from "../config-BI0V3ICQ.mjs";
18
- import { r as hashString } from "../zod-generator-CC0xNe_K.mjs";
19
- import { i as FTSManager, n as SchemaRegistry } from "../registry-Dw70ChxB.mjs";
20
- import { r as getDb } from "../loader-CKLbBnhK.mjs";
21
- import { n as requestCached } from "../request-cache-B-bmkipQ.mjs";
22
- import "../taxonomies-ZlRtD6AG.mjs";
23
- import { r as normalizeManifestRoute } from "../manifest-schema-DqWNC3lM.mjs";
24
- import "../types-4fVtCIm0.mjs";
25
- import "../error-D_-tqP-I.mjs";
26
- import { a as invalidateUrlPatternCache } from "../query-Cg9ZKRQ0.mjs";
27
- import "../tokens-D7zMmWi2.mjs";
28
- import "../bylines-CvJ3PYz2.mjs";
29
- import "../load-DDqMMvZL.mjs";
7
+ import { i as setI18nConfig } from "../config-CVssduLe.mjs";
8
+ import { At as handleContentTranslations, Ct as handleContentGetIncludingTrashed, Dt as handleContentPublish, Et as handleContentPermanentDelete, G as sanitizeHeadersForSandbox, H as resolveExclusiveHooks, I as PluginRouteRegistry, K as getTrustedProxyHeaders, L as DEV_CONSOLE_EMAIL_PLUGIN_ID, Mt as handleContentUnschedule, Nt as handleContentUpdate, Ot as handleContentRestore, Pt as validateRev, R as devConsoleEmailDeliver, St as handleContentGet, Tt as handleContentListTrashed, U as CronExecutor, V as createHookPipeline, W as extractRequestMeta, X as after, _t as handleContentCountTrashed, bt as handleContentDiscardDraft, ct as handleMediaGet, dt as handleRevisionGet, ft as handleRevisionList, gt as handleContentCountScheduled, ht as handleContentCompare, it as PluginStateRepository, jt as handleContentUnpublish, kt as handleContentSchedule, lt as handleMediaList, ot as handleMediaCreate, pt as handleRevisionRestore, q as definePlugin, st as handleMediaDelete, tt as loadBundleFromR2, ut as handleMediaUpdate, vt as handleContentCreate, wt as handleContentList, xt as handleContentDuplicate, yt as handleContentDelete, z as EmailPipeline } from "../search-DuWhx4NG.mjs";
9
+ import { r as RevisionRepository } from "../content-CERxPUN0.mjs";
10
+ import "../base64-MBPo9ozB.mjs";
11
+ import "../types-BIgulNsW.mjs";
12
+ import { t as MediaRepository } from "../media-1fFhub9c.mjs";
13
+ import "../taxonomy-D6NvlKo8.mjs";
14
+ import { t as OptionsRepository } from "../options-nPxWnrya.mjs";
15
+ import "../redirect-C5H7VGIX.mjs";
16
+ import "../byline-gFn1r0vA.mjs";
17
+ import { n as normalizeMediaValue } from "../placeholder-Ci0RLeCk.mjs";
18
+ import { n as requestCached } from "../request-cache-D4I69LeL.mjs";
19
+ import { r as hashString } from "../zod-generator-CHnJUP2l.mjs";
20
+ import { i as FTSManager, n as SchemaRegistry } from "../registry-Do34mz_P.mjs";
21
+ import { r as getDb } from "../loader-ou_PXAjg.mjs";
22
+ import "../apply-Ded_1vng.mjs";
23
+ import "../taxonomies-Bw76xAxo.mjs";
24
+ import { r as normalizeManifestRoute } from "../manifest-schema-CXAbd1vH.mjs";
25
+ import "../types-DiI8NOG_.mjs";
26
+ import "../error-DqnRMM5z.mjs";
27
+ import { a as invalidateUrlPatternCache } from "../query-8c_meo_K.mjs";
28
+ import "../tokens-CyRDPVW2.mjs";
29
+ import "../bylines-DTFI8nDM.mjs";
30
+ import "../load-DR1VwFXR.mjs";
30
31
  import "../index.mjs";
31
- import { n as VERSION, t as COMMIT } from "../version-DoxrVdYf.mjs";
32
- import { t as getAuthMode } from "../mode-ier8jbBk.mjs";
33
- import { a as validateEncryptionKeyAtStartup } from "../secrets-CW3reAnU.mjs";
32
+ import { n as VERSION, t as COMMIT } from "../version-Bg31I_Ff.mjs";
33
+ import { t as getAuthMode } from "../mode-YhqNVef_.mjs";
34
+ import { a as validateEncryptionKeyAtStartup } from "../secrets-CZ8rxLX3.mjs";
34
35
  import { Kysely, sql } from "kysely";
35
36
  import { defineMiddleware } from "astro:middleware";
36
37
  import virtualConfig from "virtual:emdash/config";
@@ -800,9 +801,9 @@ var EmDashRuntime = class EmDashRuntime {
800
801
  }
801
802
  })();
802
803
  if (collectionCount.count === 0 && !setupDone) {
803
- const { applySeed } = await import("../apply-BzltprvY.mjs").then((n) => n.n);
804
- const { loadSeed } = await import("../load-DDqMMvZL.mjs").then((n) => n.r);
805
- const { validateSeed } = await import("../validate-Baqf0slj.mjs").then((n) => n.n);
804
+ const { applySeed } = await import("../apply-Ded_1vng.mjs").then((n) => n.n);
805
+ const { loadSeed } = await import("../load-DR1VwFXR.mjs").then((n) => n.r);
806
+ const { validateSeed } = await import("../validate-UK4Ja1uo.mjs").then((n) => n.n);
806
807
  const seed = await loadSeed();
807
808
  if (validateSeed(seed).valid) {
808
809
  await applySeed(db, seed, { onConflict: "skip" });
@@ -982,13 +983,14 @@ var EmDashRuntime = class EmDashRuntime {
982
983
  label: field.label,
983
984
  required: field.required
984
985
  };
986
+ entry.id = field.id;
985
987
  if (field.widget) entry.widget = field.widget;
986
988
  if (field.options) entry.options = field.options;
987
989
  if (field.validation?.options) entry.options = field.validation.options.map((v) => ({
988
990
  value: v,
989
991
  label: v.charAt(0).toUpperCase() + v.slice(1)
990
992
  }));
991
- if (field.type === "repeater" && field.validation) entry.validation = field.validation;
993
+ if ((field.type === "repeater" || field.type === "file" || field.type === "image") && field.validation) entry.validation = { ...field.validation };
992
994
  fields[field.slug] = entry;
993
995
  }
994
996
  manifestCollections[collection.slug] = {
@@ -1187,7 +1189,7 @@ var EmDashRuntime = class EmDashRuntime {
1187
1189
  if (this.hooks.hasHooks("content:beforeSave")) processedData = (await this.hooks.runContentBeforeSave(body.data, collection, true)).content;
1188
1190
  processedData = await this.runSandboxedBeforeSave(processedData, collection, true);
1189
1191
  processedData = await this.normalizeMediaFields(collection, processedData);
1190
- const { validateContentData } = await import("../validation-BfEI7tNe.mjs");
1192
+ const { validateContentData } = await import("../validation-Vc5DQkJa.mjs");
1191
1193
  const validation = await validateContentData(this.db, collection, processedData, { partial: false });
1192
1194
  if (!validation.ok) return {
1193
1195
  success: false,
@@ -1203,7 +1205,7 @@ var EmDashRuntime = class EmDashRuntime {
1203
1205
  return result;
1204
1206
  }
1205
1207
  async handleContentUpdate(collection, id, body) {
1206
- const { ContentRepository } = await import("../content-8lOYF0pr.mjs").then((n) => n.n);
1208
+ const { ContentRepository } = await import("../content-CERxPUN0.mjs").then((n) => n.n);
1207
1209
  const repo = new ContentRepository(this.db);
1208
1210
  const resolvedItem = await repo.findByIdOrSlug(collection, id);
1209
1211
  const resolvedId = resolvedItem?.id ?? id;
@@ -1230,7 +1232,7 @@ var EmDashRuntime = class EmDashRuntime {
1230
1232
  if (this.hooks.hasHooks("content:beforeSave")) processedData = (await this.hooks.runContentBeforeSave(bodyWithoutRev.data, collection, false)).content;
1231
1233
  processedData = await this.runSandboxedBeforeSave(processedData, collection, false);
1232
1234
  processedData = await this.normalizeMediaFields(collection, processedData);
1233
- const { validateContentData } = await import("../validation-BfEI7tNe.mjs");
1235
+ const { validateContentData } = await import("../validation-Vc5DQkJa.mjs");
1234
1236
  const validation = await validateContentData(this.db, collection, processedData, { partial: true });
1235
1237
  if (!validation.ok) return {
1236
1238
  success: false,
@@ -1872,6 +1874,49 @@ function finalizeResponse(response, serverTimings) {
1872
1874
  }).join(", "));
1873
1875
  return res;
1874
1876
  }
1877
+ /**
1878
+ * Append always-on counters (db.*, cache.*) to the Server-Timing list.
1879
+ *
1880
+ * dur values for `count`, `hit`, `miss` are integer counts — Server-Timing
1881
+ * spec only models milliseconds, but browsers show whatever number is given,
1882
+ * which is the convention most projects use for non-time samples.
1883
+ */
1884
+ function pushMetricsTimings(timings, metrics) {
1885
+ if (metrics.dbCount > 0) {
1886
+ timings.push({
1887
+ name: "db.total",
1888
+ dur: metrics.dbTotalMs,
1889
+ desc: "DB total"
1890
+ });
1891
+ timings.push({
1892
+ name: "db.count",
1893
+ dur: metrics.dbCount,
1894
+ desc: "Query count"
1895
+ });
1896
+ if (metrics.dbFirstOffset !== null) timings.push({
1897
+ name: "db.first",
1898
+ dur: metrics.dbFirstOffset,
1899
+ desc: "First query at"
1900
+ });
1901
+ if (metrics.dbLastOffset !== null) timings.push({
1902
+ name: "db.last",
1903
+ dur: metrics.dbLastOffset,
1904
+ desc: "Last query at"
1905
+ });
1906
+ }
1907
+ if (metrics.cacheHits + metrics.cacheMisses > 0) {
1908
+ timings.push({
1909
+ name: "cache.hit",
1910
+ dur: metrics.cacheHits,
1911
+ desc: "Cache hits"
1912
+ });
1913
+ timings.push({
1914
+ name: "cache.miss",
1915
+ dur: metrics.cacheMisses,
1916
+ desc: "Cache misses"
1917
+ });
1918
+ }
1919
+ }
1875
1920
  /** Public routes that require the runtime (sitemap, robots.txt, etc.) */
1876
1921
  const PUBLIC_RUNTIME_ROUTES = new Set(["/sitemap.xml", "/robots.txt"]);
1877
1922
  const SITEMAP_COLLECTION_RE = /^\/sitemap-[a-z][a-z0-9_]*\.xml$/;
@@ -1892,6 +1937,7 @@ const onRequest = defineMiddleware(async (context, next) => {
1892
1937
  if (virtualConfig.authProviders.some((p) => p.routes?.some((r) => r.pattern && url.pathname === r.pattern))) return finalizeResponse(await next());
1893
1938
  }
1894
1939
  const queryRecorder = isInstrumentationEnabled() ? createRecorder(url.pathname, request.method, request.headers.get("x-perf-phase") ?? "default") : void 0;
1940
+ const metrics = createRequestMetrics(performance.now());
1895
1941
  const run = async () => {
1896
1942
  const isEmDashRoute = url.pathname.startsWith("/_emdash");
1897
1943
  const isPublicRuntimeRoute = PUBLIC_RUNTIME_ROUTES.has(url.pathname) || SITEMAP_COLLECTION_RE.test(url.pathname);
@@ -1907,7 +1953,7 @@ const onRequest = defineMiddleware(async (context, next) => {
1907
1953
  if (!setupVerified) {
1908
1954
  const t0 = performance.now();
1909
1955
  try {
1910
- const { getDb } = await import("../loader-CKLbBnhK.mjs").then((n) => n.i);
1956
+ const { getDb } = await import("../loader-ou_PXAjg.mjs").then((n) => n.i);
1911
1957
  await (await getDb()).selectFrom("_emdash_migrations").selectAll().limit(1).execute();
1912
1958
  setupVerified = true;
1913
1959
  } catch {
@@ -1959,6 +2005,7 @@ const onRequest = defineMiddleware(async (context, next) => {
1959
2005
  dur: performance.now() - mwStart,
1960
2006
  desc: "Total middleware"
1961
2007
  });
2008
+ pushMetricsTimings(timings, metrics);
1962
2009
  return finalizeResponse(response, timings);
1963
2010
  };
1964
2011
  if (anonScoped) {
@@ -1968,7 +2015,8 @@ const onRequest = defineMiddleware(async (context, next) => {
1968
2015
  db: anonScoped.db
1969
2016
  } : {
1970
2017
  editMode: false,
1971
- db: anonScoped.db
2018
+ db: anonScoped.db,
2019
+ metrics
1972
2020
  }, async () => {
1973
2021
  const response = await runAnon();
1974
2022
  anonScoped.commit();
@@ -2068,6 +2116,7 @@ const onRequest = defineMiddleware(async (context, next) => {
2068
2116
  dur: performance.now() - mwStart,
2069
2117
  desc: "Total middleware"
2070
2118
  });
2119
+ pushMetricsTimings(timings, metrics);
2071
2120
  return finalizeResponse(response, timings);
2072
2121
  };
2073
2122
  if (scoped) {
@@ -2077,7 +2126,8 @@ const onRequest = defineMiddleware(async (context, next) => {
2077
2126
  db: scoped.db
2078
2127
  } : {
2079
2128
  editMode: false,
2080
- db: scoped.db
2129
+ db: scoped.db,
2130
+ metrics
2081
2131
  }, async () => {
2082
2132
  const response = await renderAndFinalize();
2083
2133
  scoped.commit();
@@ -2097,20 +2147,21 @@ const onRequest = defineMiddleware(async (context, next) => {
2097
2147
  } : {
2098
2148
  editMode,
2099
2149
  db: playgroundDb,
2100
- dbIsIsolated: true
2150
+ dbIsIsolated: true,
2151
+ metrics
2101
2152
  }, doInit);
2102
2153
  }
2103
2154
  return doInit();
2104
2155
  };
2105
- if (queryRecorder) try {
2156
+ try {
2106
2157
  return await runWithContext({
2107
2158
  editMode: false,
2108
- queryRecorder
2159
+ queryRecorder,
2160
+ metrics
2109
2161
  }, run);
2110
2162
  } finally {
2111
- flushRecorder(queryRecorder);
2163
+ if (queryRecorder) flushRecorder(queryRecorder);
2112
2164
  }
2113
- return run();
2114
2165
  });
2115
2166
 
2116
2167
  //#endregion