emdash 0.5.0 → 0.6.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 (205) hide show
  1. package/dist/{adapters-C2BzVy0p.d.mts → adapters-Di31kZ28.d.mts} +16 -1
  2. package/dist/adapters-Di31kZ28.d.mts.map +1 -0
  3. package/dist/{apply-Cma_PiF6.mjs → apply-B4MsLM-w.mjs} +27 -12
  4. package/dist/apply-B4MsLM-w.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 +199 -33
  8. package/dist/astro/index.mjs.map +1 -1
  9. package/dist/astro/middleware/auth.d.mts +5 -5
  10. package/dist/astro/middleware/auth.d.mts.map +1 -1
  11. package/dist/astro/middleware/auth.mjs +30 -4
  12. package/dist/astro/middleware/auth.mjs.map +1 -1
  13. package/dist/astro/middleware/redirect.mjs +1 -1
  14. package/dist/astro/middleware/request-context.d.mts.map +1 -1
  15. package/dist/astro/middleware/request-context.mjs +5 -3
  16. package/dist/astro/middleware/request-context.mjs.map +1 -1
  17. package/dist/astro/middleware/setup.mjs +1 -1
  18. package/dist/astro/middleware.d.mts.map +1 -1
  19. package/dist/astro/middleware.mjs +460 -180
  20. package/dist/astro/middleware.mjs.map +1 -1
  21. package/dist/astro/types.d.mts +8 -9
  22. package/dist/astro/types.d.mts.map +1 -1
  23. package/dist/{byline-WuOq9MFJ.mjs → byline-C4OVd8b3.mjs} +3 -19
  24. package/dist/byline-C4OVd8b3.mjs.map +1 -0
  25. package/dist/{bylines-C_Wsnz4L.mjs → bylines-hPTW79hw.mjs} +20 -33
  26. package/dist/bylines-hPTW79hw.mjs.map +1 -0
  27. package/dist/{cache-E3Dts-yT.mjs → cache-BkKBuIvS.mjs} +1 -1
  28. package/dist/{cache-E3Dts-yT.mjs.map → cache-BkKBuIvS.mjs.map} +1 -1
  29. package/dist/chunks-HGz06Soa.mjs +19 -0
  30. package/dist/chunks-HGz06Soa.mjs.map +1 -0
  31. package/dist/cli/index.mjs +9 -8
  32. package/dist/cli/index.mjs.map +1 -1
  33. package/dist/client/cf-access.d.mts +1 -1
  34. package/dist/client/index.d.mts +1 -1
  35. package/dist/client/index.mjs +1 -1
  36. package/dist/{config-DkxPrM9l.mjs → config-BXwuX8Bx.mjs} +1 -1
  37. package/dist/{config-DkxPrM9l.mjs.map → config-BXwuX8Bx.mjs.map} +1 -1
  38. package/dist/{connection-B4zVnQIa.mjs → connection-2igzM-AT.mjs} +19 -2
  39. package/dist/connection-2igzM-AT.mjs.map +1 -0
  40. package/dist/database/instrumentation.d.mts +45 -0
  41. package/dist/database/instrumentation.d.mts.map +1 -0
  42. package/dist/database/instrumentation.mjs +61 -0
  43. package/dist/database/instrumentation.mjs.map +1 -0
  44. package/dist/db/index.d.mts +3 -3
  45. package/dist/db/index.mjs.map +1 -1
  46. package/dist/db/libsql.d.mts +1 -1
  47. package/dist/db/postgres.d.mts +1 -1
  48. package/dist/db/sqlite.d.mts +1 -1
  49. package/dist/db-errors-D0UT85nC.mjs +41 -0
  50. package/dist/db-errors-D0UT85nC.mjs.map +1 -0
  51. package/dist/{default-PUx9RK6u.mjs → default-CME5YdZ3.mjs} +1 -1
  52. package/dist/{default-PUx9RK6u.mjs.map → default-CME5YdZ3.mjs.map} +1 -1
  53. package/dist/{error-HBeQbVhV.mjs → error-CiYn9yDu.mjs} +1 -1
  54. package/dist/{error-HBeQbVhV.mjs.map → error-CiYn9yDu.mjs.map} +1 -1
  55. package/dist/{index-CCWzlriB.d.mts → index-BYv0mB9g.d.mts} +135 -19
  56. package/dist/index-BYv0mB9g.d.mts.map +1 -0
  57. package/dist/index.d.mts +11 -11
  58. package/dist/index.mjs +20 -18
  59. package/dist/{load-BhSSm-TS.mjs → load-CBcmDIot.mjs} +1 -1
  60. package/dist/{load-BhSSm-TS.mjs.map → load-CBcmDIot.mjs.map} +1 -1
  61. package/dist/{loader-BYzwzORf.mjs → loader-DeiBJEMe.mjs} +18 -12
  62. package/dist/loader-DeiBJEMe.mjs.map +1 -0
  63. package/dist/{manifest-schema-BsXINkQD.mjs → manifest-schema-V30qsMft.mjs} +1 -1
  64. package/dist/{manifest-schema-BsXINkQD.mjs.map → manifest-schema-V30qsMft.mjs.map} +1 -1
  65. package/dist/media/index.d.mts +1 -1
  66. package/dist/media/index.mjs +1 -1
  67. package/dist/media/local-runtime.d.mts +7 -7
  68. package/dist/{mode-CyPLdO3C.mjs → mode-CpNnGkPz.mjs} +1 -1
  69. package/dist/{mode-CyPLdO3C.mjs.map → mode-CpNnGkPz.mjs.map} +1 -1
  70. package/dist/page/index.d.mts +11 -2
  71. package/dist/page/index.d.mts.map +1 -1
  72. package/dist/page/index.mjs +23 -1
  73. package/dist/page/index.mjs.map +1 -1
  74. package/dist/{placeholder-DntBEQo7.mjs → placeholder-C-fk5hYI.mjs} +1 -1
  75. package/dist/{placeholder-DntBEQo7.mjs.map → placeholder-C-fk5hYI.mjs.map} +1 -1
  76. package/dist/{placeholder-BBCtpTES.d.mts → placeholder-tzpqGWII.d.mts} +1 -1
  77. package/dist/{placeholder-BBCtpTES.d.mts.map → placeholder-tzpqGWII.d.mts.map} +1 -1
  78. package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
  79. package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
  80. package/dist/{query-B6Vu0d2i.mjs → query-Bk_3vKvU.mjs} +78 -11
  81. package/dist/query-Bk_3vKvU.mjs.map +1 -0
  82. package/dist/{registry-BgnP3ysR.mjs → registry-Ci3WxVAr.mjs} +133 -97
  83. package/dist/registry-Ci3WxVAr.mjs.map +1 -0
  84. package/dist/request-cache-DiR961CV.mjs +79 -0
  85. package/dist/request-cache-DiR961CV.mjs.map +1 -0
  86. package/dist/request-context.d.mts +19 -16
  87. package/dist/request-context.d.mts.map +1 -1
  88. package/dist/request-context.mjs.map +1 -1
  89. package/dist/{runner-DYv3rX8P.d.mts → runner-Fl2NcUUz.d.mts} +2 -2
  90. package/dist/{runner-DYv3rX8P.d.mts.map → runner-Fl2NcUUz.d.mts.map} +1 -1
  91. package/dist/runtime.d.mts +6 -6
  92. package/dist/runtime.mjs +1 -1
  93. package/dist/{search-Cn1SYvYF.mjs → search-DI4bM2w9.mjs} +96 -206
  94. package/dist/search-DI4bM2w9.mjs.map +1 -0
  95. package/dist/seed/index.d.mts +2 -2
  96. package/dist/seed/index.mjs +8 -7
  97. package/dist/seo/index.d.mts +1 -1
  98. package/dist/storage/local.d.mts +1 -1
  99. package/dist/storage/local.mjs +1 -1
  100. package/dist/storage/s3.d.mts +1 -1
  101. package/dist/storage/s3.mjs +1 -1
  102. package/dist/taxonomies-DbrKzDju.mjs +308 -0
  103. package/dist/taxonomies-DbrKzDju.mjs.map +1 -0
  104. package/dist/{tokens-DKHiCYCB.mjs → tokens-BFPFx3CA.mjs} +1 -1
  105. package/dist/{tokens-DKHiCYCB.mjs.map → tokens-BFPFx3CA.mjs.map} +1 -1
  106. package/dist/{transport-BtcQ-Z7T.mjs → transport-BykRfpyy.mjs} +1 -1
  107. package/dist/{transport-BtcQ-Z7T.mjs.map → transport-BykRfpyy.mjs.map} +1 -1
  108. package/dist/{transport-CKQA_G44.d.mts → transport-H4Iwx7tC.d.mts} +1 -1
  109. package/dist/{transport-CKQA_G44.d.mts.map → transport-H4Iwx7tC.d.mts.map} +1 -1
  110. package/dist/{types-BmkQR1En.d.mts → types-6CUZRrZP.d.mts} +1 -1
  111. package/dist/{types-BmkQR1En.d.mts.map → types-6CUZRrZP.d.mts.map} +1 -1
  112. package/dist/{types-B6BzlZxx.d.mts → types-8xrvl_68.d.mts} +1 -1
  113. package/dist/{types-B6BzlZxx.d.mts.map → types-8xrvl_68.d.mts.map} +1 -1
  114. package/dist/{types-Dz9_WMS6.mjs → types-BH2L167P.mjs} +1 -1
  115. package/dist/{types-Dz9_WMS6.mjs.map → types-BH2L167P.mjs.map} +1 -1
  116. package/dist/{types-DNZpaCBk.d.mts → types-CFWjXmus.d.mts} +1 -1
  117. package/dist/{types-DNZpaCBk.d.mts.map → types-CFWjXmus.d.mts.map} +1 -1
  118. package/dist/{types-DeG21anB.d.mts → types-CnZYHyLW.d.mts} +55 -5
  119. package/dist/types-CnZYHyLW.d.mts.map +1 -0
  120. package/dist/{types-xxCWI3j0.mjs → types-DDS4MxsT.mjs} +11 -3
  121. package/dist/types-DDS4MxsT.mjs.map +1 -0
  122. package/dist/{types-C3ronwXb.d.mts → types-DgrIP0tF.d.mts} +102 -4
  123. package/dist/types-DgrIP0tF.d.mts.map +1 -0
  124. package/dist/{validate-Db1yNL3i.d.mts → validate-CaLH1Ia2.d.mts} +5 -52
  125. package/dist/validate-CaLH1Ia2.d.mts.map +1 -0
  126. package/dist/{validate-DuZDIxfy.mjs → validate-CqsNItbt.mjs} +2 -2
  127. package/dist/{validate-DuZDIxfy.mjs.map → validate-CqsNItbt.mjs.map} +1 -1
  128. package/dist/version-Uaf2ynPX.mjs +7 -0
  129. package/dist/{version-CMMjTuqu.mjs.map → version-Uaf2ynPX.mjs.map} +1 -1
  130. package/package.json +10 -5
  131. package/src/after.ts +62 -0
  132. package/src/api/handlers/oauth-authorization.ts +2 -32
  133. package/src/api/handlers/oauth-clients.ts +40 -4
  134. package/src/api/handlers/taxonomies.ts +13 -0
  135. package/src/api/oauth/redirect-uri.ts +34 -0
  136. package/src/api/openapi/document.ts +126 -118
  137. package/src/api/schemas/media.ts +26 -15
  138. package/src/api/schemas/schema.ts +1 -0
  139. package/src/astro/integration/font-provider.ts +176 -0
  140. package/src/astro/integration/index.ts +42 -0
  141. package/src/astro/integration/routes.ts +6 -0
  142. package/src/astro/integration/runtime.ts +63 -0
  143. package/src/astro/integration/virtual-modules.ts +41 -39
  144. package/src/astro/integration/vite-config.ts +16 -5
  145. package/src/astro/middleware/auth.ts +33 -1
  146. package/src/astro/middleware/request-context.ts +15 -3
  147. package/src/astro/middleware.ts +340 -263
  148. package/src/astro/routes/admin.astro +7 -3
  149. package/src/astro/routes/api/auth/passkey/verify.ts +5 -1
  150. package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +5 -0
  151. package/src/astro/routes/api/import/wordpress/execute.ts +1 -1
  152. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +1 -1
  153. package/src/astro/routes/api/media/upload-url.ts +10 -2
  154. package/src/astro/routes/api/media.ts +10 -7
  155. package/src/astro/routes/api/oauth/register.ts +178 -0
  156. package/src/astro/routes/api/oauth/token.ts +15 -0
  157. package/src/astro/routes/api/openapi.json.ts +15 -5
  158. package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +2 -0
  159. package/src/astro/routes/api/schema/collections/[slug]/fields/index.ts +1 -0
  160. package/src/astro/routes/api/schema/collections/[slug]/fields/reorder.ts +1 -0
  161. package/src/astro/routes/api/search/index.ts +5 -0
  162. package/src/astro/routes/api/search/suggest.ts +3 -0
  163. package/src/astro/routes/api/taxonomies/index.ts +1 -0
  164. package/src/astro/routes/api/well-known/oauth-authorization-server.ts +1 -1
  165. package/src/bylines/index.ts +22 -45
  166. package/src/components/EmDashHead.astro +23 -7
  167. package/src/database/connection.ts +23 -1
  168. package/src/database/instrumentation.ts +98 -0
  169. package/src/db/adapters.ts +15 -0
  170. package/src/emdash-runtime.ts +309 -91
  171. package/src/index.ts +6 -0
  172. package/src/loader.ts +19 -24
  173. package/src/menus/index.ts +6 -3
  174. package/src/page/index.ts +1 -1
  175. package/src/page/seo-contributions.ts +36 -0
  176. package/src/query.ts +104 -7
  177. package/src/request-cache.ts +106 -0
  178. package/src/request-context.ts +19 -0
  179. package/src/schema/query.ts +5 -2
  180. package/src/schema/registry.ts +243 -166
  181. package/src/schema/types.ts +13 -2
  182. package/src/schema/zod-generator.ts +4 -0
  183. package/src/search/fts-manager.ts +19 -5
  184. package/src/search/query.ts +4 -3
  185. package/src/seed/apply.ts +15 -1
  186. package/src/settings/index.ts +24 -5
  187. package/src/taxonomies/index.ts +324 -124
  188. package/src/utils/db-errors.ts +46 -0
  189. package/src/virtual-modules.d.ts +31 -10
  190. package/src/widgets/index.ts +54 -25
  191. package/dist/adapters-C2BzVy0p.d.mts.map +0 -1
  192. package/dist/apply-Cma_PiF6.mjs.map +0 -1
  193. package/dist/byline-WuOq9MFJ.mjs.map +0 -1
  194. package/dist/bylines-C_Wsnz4L.mjs.map +0 -1
  195. package/dist/connection-B4zVnQIa.mjs.map +0 -1
  196. package/dist/index-CCWzlriB.d.mts.map +0 -1
  197. package/dist/loader-BYzwzORf.mjs.map +0 -1
  198. package/dist/query-B6Vu0d2i.mjs.map +0 -1
  199. package/dist/registry-BgnP3ysR.mjs.map +0 -1
  200. package/dist/search-Cn1SYvYF.mjs.map +0 -1
  201. package/dist/types-C3ronwXb.d.mts.map +0 -1
  202. package/dist/types-DeG21anB.d.mts.map +0 -1
  203. package/dist/types-xxCWI3j0.mjs.map +0 -1
  204. package/dist/validate-Db1yNL3i.d.mts.map +0 -1
  205. package/dist/version-CMMjTuqu.mjs +0 -7
@@ -37,6 +37,7 @@ import {
37
37
  trashedContentListResponseSchema,
38
38
  } from "../schemas/content.js";
39
39
  import {
40
+ DEFAULT_MAX_UPLOAD_SIZE,
40
41
  mediaConfirmBody,
41
42
  mediaConfirmResponseSchema,
42
43
  mediaExistingResponseSchema,
@@ -623,121 +624,123 @@ const contentPaths = {
623
624
  // Media routes
624
625
  // ---------------------------------------------------------------------------
625
626
 
626
- const mediaPaths = {
627
- "/_emdash/api/media": {
628
- get: {
629
- operationId: "listMedia",
630
- summary: "List media items",
631
- tags: ["Media"],
632
- requestParams: { query: mediaListQuery },
633
- responses: {
634
- "200": {
635
- description: "Media list",
636
- content: { [JSON_CONTENT]: { schema: successEnvelope(mediaListResponseSchema) } },
627
+ function buildMediaPaths(maxUploadSize: number) {
628
+ return {
629
+ "/_emdash/api/media": {
630
+ get: {
631
+ operationId: "listMedia",
632
+ summary: "List media items",
633
+ tags: ["Media"],
634
+ requestParams: { query: mediaListQuery },
635
+ responses: {
636
+ "200": {
637
+ description: "Media list",
638
+ content: { [JSON_CONTENT]: { schema: successEnvelope(mediaListResponseSchema) } },
639
+ },
640
+ ...authErrors,
641
+ ...standardErrors(500),
637
642
  },
638
- ...authErrors,
639
- ...standardErrors(500),
640
643
  },
641
644
  },
642
- },
643
- "/_emdash/api/media/{id}": {
644
- get: {
645
- operationId: "getMedia",
646
- summary: "Get a media item",
647
- tags: ["Media"],
648
- requestParams: {
649
- path: z.object({ id: z.string().meta({ description: "Media ID" }) }),
650
- },
651
- responses: {
652
- "200": {
653
- description: "Media item",
654
- content: { [JSON_CONTENT]: { schema: successEnvelope(mediaResponseSchema) } },
645
+ "/_emdash/api/media/{id}": {
646
+ get: {
647
+ operationId: "getMedia",
648
+ summary: "Get a media item",
649
+ tags: ["Media"],
650
+ requestParams: {
651
+ path: z.object({ id: z.string().meta({ description: "Media ID" }) }),
655
652
  },
656
- ...authErrors,
657
- ...standardErrors(404, 500),
658
- },
659
- },
660
- put: {
661
- operationId: "updateMedia",
662
- summary: "Update media metadata",
663
- tags: ["Media"],
664
- requestParams: {
665
- path: z.object({ id: z.string().meta({ description: "Media ID" }) }),
666
- },
667
- requestBody: { content: { [JSON_CONTENT]: { schema: mediaUpdateBody } } },
668
- responses: {
669
- "200": {
670
- description: "Updated media item",
671
- content: { [JSON_CONTENT]: { schema: successEnvelope(mediaResponseSchema) } },
653
+ responses: {
654
+ "200": {
655
+ description: "Media item",
656
+ content: { [JSON_CONTENT]: { schema: successEnvelope(mediaResponseSchema) } },
657
+ },
658
+ ...authErrors,
659
+ ...standardErrors(404, 500),
660
+ },
661
+ },
662
+ put: {
663
+ operationId: "updateMedia",
664
+ summary: "Update media metadata",
665
+ tags: ["Media"],
666
+ requestParams: {
667
+ path: z.object({ id: z.string().meta({ description: "Media ID" }) }),
668
+ },
669
+ requestBody: { content: { [JSON_CONTENT]: { schema: mediaUpdateBody } } },
670
+ responses: {
671
+ "200": {
672
+ description: "Updated media item",
673
+ content: { [JSON_CONTENT]: { schema: successEnvelope(mediaResponseSchema) } },
674
+ },
675
+ ...authErrors,
676
+ ...standardErrors(400, 404, 500),
672
677
  },
673
- ...authErrors,
674
- ...standardErrors(400, 404, 500),
675
678
  },
676
- },
677
- delete: {
678
- operationId: "deleteMedia",
679
- summary: "Delete a media item",
680
- tags: ["Media"],
681
- requestParams: {
682
- path: z.object({ id: z.string().meta({ description: "Media ID" }) }),
683
- },
684
- responses: {
685
- "200": {
686
- description: "Deleted",
687
- content: { [JSON_CONTENT]: { schema: successEnvelope(deleteResponseSchema) } },
679
+ delete: {
680
+ operationId: "deleteMedia",
681
+ summary: "Delete a media item",
682
+ tags: ["Media"],
683
+ requestParams: {
684
+ path: z.object({ id: z.string().meta({ description: "Media ID" }) }),
688
685
  },
689
- ...authErrors,
690
- ...standardErrors(404, 500),
691
- },
692
- },
693
- },
694
- "/_emdash/api/media/upload-url": {
695
- post: {
696
- operationId: "getMediaUploadUrl",
697
- summary: "Get a signed URL for direct upload",
698
- description:
699
- "Returns a signed URL for direct-to-storage upload. Creates a pending media record.",
700
- tags: ["Media"],
701
- requestBody: { content: { [JSON_CONTENT]: { schema: mediaUploadUrlBody } } },
702
- responses: {
703
- "200": {
704
- description: "Upload URL or existing media (deduplication)",
705
- content: {
706
- [JSON_CONTENT]: {
707
- schema: successEnvelope(
708
- z.union([mediaUploadUrlResponseSchema, mediaExistingResponseSchema]),
709
- ),
686
+ responses: {
687
+ "200": {
688
+ description: "Deleted",
689
+ content: { [JSON_CONTENT]: { schema: successEnvelope(deleteResponseSchema) } },
690
+ },
691
+ ...authErrors,
692
+ ...standardErrors(404, 500),
693
+ },
694
+ },
695
+ },
696
+ "/_emdash/api/media/upload-url": {
697
+ post: {
698
+ operationId: "getMediaUploadUrl",
699
+ summary: "Get a signed URL for direct upload",
700
+ description:
701
+ "Returns a signed URL for direct-to-storage upload. Creates a pending media record.",
702
+ tags: ["Media"],
703
+ requestBody: { content: { [JSON_CONTENT]: { schema: mediaUploadUrlBody(maxUploadSize) } } },
704
+ responses: {
705
+ "200": {
706
+ description: "Upload URL or existing media (deduplication)",
707
+ content: {
708
+ [JSON_CONTENT]: {
709
+ schema: successEnvelope(
710
+ z.union([mediaUploadUrlResponseSchema, mediaExistingResponseSchema]),
711
+ ),
712
+ },
710
713
  },
711
714
  },
712
- },
713
- ...authErrors,
714
- ...standardErrors(400, 500),
715
- },
716
- },
717
- },
718
- "/_emdash/api/media/{id}/confirm": {
719
- post: {
720
- operationId: "confirmMediaUpload",
721
- summary: "Confirm a media upload",
722
- description: "Marks a pending media record as ready after the file has been uploaded.",
723
- tags: ["Media"],
724
- requestParams: {
725
- path: z.object({ id: z.string().meta({ description: "Media ID" }) }),
726
- },
727
- requestBody: { content: { [JSON_CONTENT]: { schema: mediaConfirmBody } } },
728
- responses: {
729
- "200": {
730
- description: "Confirmed media item with URL",
731
- content: {
732
- [JSON_CONTENT]: { schema: successEnvelope(mediaConfirmResponseSchema) },
715
+ ...authErrors,
716
+ ...standardErrors(400, 500),
717
+ },
718
+ },
719
+ },
720
+ "/_emdash/api/media/{id}/confirm": {
721
+ post: {
722
+ operationId: "confirmMediaUpload",
723
+ summary: "Confirm a media upload",
724
+ description: "Marks a pending media record as ready after the file has been uploaded.",
725
+ tags: ["Media"],
726
+ requestParams: {
727
+ path: z.object({ id: z.string().meta({ description: "Media ID" }) }),
728
+ },
729
+ requestBody: { content: { [JSON_CONTENT]: { schema: mediaConfirmBody } } },
730
+ responses: {
731
+ "200": {
732
+ description: "Confirmed media item with URL",
733
+ content: {
734
+ [JSON_CONTENT]: { schema: successEnvelope(mediaConfirmResponseSchema) },
735
+ },
733
736
  },
737
+ ...authErrors,
738
+ ...standardErrors(400, 404, 500),
734
739
  },
735
- ...authErrors,
736
- ...standardErrors(400, 404, 500),
737
740
  },
738
741
  },
739
- },
740
- } as const;
742
+ } as const;
743
+ }
741
744
 
742
745
  // ---------------------------------------------------------------------------
743
746
  // Schema routes
@@ -2249,20 +2252,22 @@ const userPaths = {
2249
2252
  // Merge all paths
2250
2253
  // ---------------------------------------------------------------------------
2251
2254
 
2252
- const allPaths = {
2253
- ...contentPaths,
2254
- ...mediaPaths,
2255
- ...schemaPaths,
2256
- ...commentsPaths,
2257
- ...taxonomyPaths,
2258
- ...menuPaths,
2259
- ...sectionPaths,
2260
- ...widgetPaths,
2261
- ...settingsPaths,
2262
- ...searchPaths,
2263
- ...redirectPaths,
2264
- ...userPaths,
2265
- } as const;
2255
+ function buildAllPaths(maxUploadSize: number) {
2256
+ return {
2257
+ ...contentPaths,
2258
+ ...buildMediaPaths(maxUploadSize),
2259
+ ...schemaPaths,
2260
+ ...commentsPaths,
2261
+ ...taxonomyPaths,
2262
+ ...menuPaths,
2263
+ ...sectionPaths,
2264
+ ...widgetPaths,
2265
+ ...settingsPaths,
2266
+ ...searchPaths,
2267
+ ...redirectPaths,
2268
+ ...userPaths,
2269
+ } as const;
2270
+ }
2266
2271
 
2267
2272
  // ---------------------------------------------------------------------------
2268
2273
  // Document
@@ -2274,7 +2279,10 @@ const allPaths = {
2274
2279
  * Covers: Content, Media, Schema, Comments, Taxonomies, Menus,
2275
2280
  * Sections, Widgets, Settings, Search, Redirects, Users.
2276
2281
  */
2277
- export function generateOpenApiDocument(): oas31.OpenAPIObject {
2282
+ export function generateOpenApiDocument(
2283
+ options: { maxUploadSize?: number } = {},
2284
+ ): oas31.OpenAPIObject {
2285
+ const maxUploadSize = options.maxUploadSize ?? DEFAULT_MAX_UPLOAD_SIZE;
2278
2286
  return createDocument({
2279
2287
  openapi: "3.1.0",
2280
2288
  info: {
@@ -2363,6 +2371,6 @@ export function generateOpenApiDocument(): oas31.OpenAPIObject {
2363
2371
  },
2364
2372
  security: [{ session: [] }, { bearer: [] }],
2365
2373
  // eslint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- readonly const paths are compatible at runtime
2366
- paths: allPaths as unknown as ZodOpenApiPathsObject,
2374
+ paths: buildAllPaths(maxUploadSize) as unknown as ZodOpenApiPathsObject,
2367
2375
  });
2368
2376
  }
@@ -21,21 +21,32 @@ export const mediaUpdateBody = z
21
21
  })
22
22
  .meta({ id: "MediaUpdateBody" });
23
23
 
24
- /** Maximum allowed file upload size (50 MB). */
25
- const MAX_UPLOAD_SIZE = 50 * 1024 * 1024;
26
-
27
- export const mediaUploadUrlBody = z
28
- .object({
29
- filename: z.string().min(1, "filename is required"),
30
- contentType: z.string().min(1, "contentType is required"),
31
- size: z
32
- .number()
33
- .int()
34
- .positive()
35
- .max(MAX_UPLOAD_SIZE, `File size must not exceed ${MAX_UPLOAD_SIZE / 1024 / 1024}MB`),
36
- contentHash: z.string().optional(),
37
- })
38
- .meta({ id: "MediaUploadUrlBody" });
24
+ /** Default maximum allowed file upload size (50 MB). */
25
+ export const DEFAULT_MAX_UPLOAD_SIZE = 50 * 1024 * 1024;
26
+
27
+ export function formatFileSize(bytes: number): string {
28
+ if (bytes < 1024) return `${bytes}B`;
29
+ if (bytes < 1024 * 1024) return `${Math.floor(bytes / 1024)}KB`;
30
+ return `${Math.floor(bytes / 1024 / 1024)}MB`;
31
+ }
32
+
33
+ export function mediaUploadUrlBody(maxSize: number) {
34
+ if (!Number.isFinite(maxSize) || maxSize <= 0) {
35
+ throw new Error(`EmDash: maxUploadSize must be a positive finite number, got ${maxSize}`);
36
+ }
37
+ return z
38
+ .object({
39
+ filename: z.string().min(1, "filename is required"),
40
+ contentType: z.string().min(1, "contentType is required"),
41
+ size: z
42
+ .number()
43
+ .int()
44
+ .positive()
45
+ .max(maxSize, `File size must not exceed ${formatFileSize(maxSize)}`),
46
+ contentHash: z.string().optional(),
47
+ })
48
+ .meta({ id: "MediaUploadUrlBody" });
49
+ }
39
50
 
40
51
  export const mediaConfirmBody = z
41
52
  .object({
@@ -13,6 +13,7 @@ const collectionSourcePattern = /^(template:.+|import:.+|manual|discovered|seed)
13
13
  const fieldTypeValues = z.enum([
14
14
  "string",
15
15
  "text",
16
+ "url",
16
17
  "number",
17
18
  "integer",
18
19
  "boolean",
@@ -0,0 +1,176 @@
1
+ /**
2
+ * EmDash Noto Sans font provider
3
+ *
4
+ * A custom Astro font provider that wraps Google Fonts to resolve
5
+ * multiple Noto Sans families (Latin, Arabic, JP, etc.) under a
6
+ * single logical font entry. This lets all @font-face blocks share
7
+ * the same font-family name, so the browser picks the right file
8
+ * per character via unicode-range.
9
+ *
10
+ * Without this, registering "Noto Sans" and "Noto Sans Arabic" as
11
+ * separate font entries on the same cssVariable triggers an Astro
12
+ * warning and the last entry overwrites the first.
13
+ */
14
+
15
+ import { fontProviders } from "astro/config";
16
+
17
+ /**
18
+ * All subset names used by Google Fonts CSS responses.
19
+ * Passed when resolving extra script families so the unifont
20
+ * provider doesn't filter out any faces.
21
+ */
22
+ const ALL_GOOGLE_SUBSETS = [
23
+ "arabic",
24
+ "armenian",
25
+ "bengali",
26
+ "chinese-simplified",
27
+ "chinese-traditional",
28
+ "chinese-hongkong",
29
+ "cyrillic",
30
+ "cyrillic-ext",
31
+ "devanagari",
32
+ "ethiopic",
33
+ "georgian",
34
+ "greek",
35
+ "greek-ext",
36
+ "gujarati",
37
+ "gurmukhi",
38
+ "hebrew",
39
+ "japanese",
40
+ "kannada",
41
+ "khmer",
42
+ "korean",
43
+ "lao",
44
+ "latin",
45
+ "latin-ext",
46
+ "malayalam",
47
+ "math",
48
+ "myanmar",
49
+ "oriya",
50
+ "sinhala",
51
+ "symbols",
52
+ "tamil",
53
+ "telugu",
54
+ "thai",
55
+ "tibetan",
56
+ "vietnamese",
57
+ ];
58
+
59
+ /**
60
+ * Known Noto Sans script families on Google Fonts.
61
+ * Maps user-friendly script names to Google Fonts family names.
62
+ */
63
+ const NOTO_SCRIPT_FAMILIES: Record<string, string> = {
64
+ arabic: "Noto Sans Arabic",
65
+ armenian: "Noto Sans Armenian",
66
+ bengali: "Noto Sans Bengali",
67
+ "chinese-simplified": "Noto Sans SC",
68
+ "chinese-traditional": "Noto Sans TC",
69
+ "chinese-hongkong": "Noto Sans HK",
70
+ devanagari: "Noto Sans Devanagari",
71
+ ethiopic: "Noto Sans Ethiopic",
72
+ georgian: "Noto Sans Georgian",
73
+ gujarati: "Noto Sans Gujarati",
74
+ gurmukhi: "Noto Sans Gurmukhi",
75
+ hebrew: "Noto Sans Hebrew",
76
+ japanese: "Noto Sans JP",
77
+ kannada: "Noto Sans Kannada",
78
+ khmer: "Noto Sans Khmer",
79
+ korean: "Noto Sans KR",
80
+ lao: "Noto Sans Lao",
81
+ malayalam: "Noto Sans Malayalam",
82
+ myanmar: "Noto Sans Myanmar",
83
+ oriya: "Noto Sans Oriya",
84
+ sinhala: "Noto Sans Sinhala",
85
+ tamil: "Noto Sans Tamil",
86
+ telugu: "Noto Sans Telugu",
87
+ thai: "Noto Sans Thai",
88
+ tibetan: "Noto Sans Tibetan",
89
+ };
90
+
91
+ export interface NotoSansProviderOptions {
92
+ /**
93
+ * Additional Noto Sans script families to include.
94
+ * Use script names like "arabic", "japanese", "chinese-simplified".
95
+ *
96
+ * @see {@link NOTO_SCRIPT_FAMILIES} for the full list of supported scripts.
97
+ */
98
+ scripts?: string[];
99
+ }
100
+
101
+ // Use ReturnType to get the provider type without importing it directly.
102
+ // The Astro FontProvider type is not part of the public API surface.
103
+ type GoogleProvider = ReturnType<typeof fontProviders.google>;
104
+
105
+ /**
106
+ * Create a font provider that resolves Noto Sans plus additional
107
+ * script-specific Noto families from Google Fonts, all under one
108
+ * font-family name.
109
+ */
110
+ export function notoSans(options?: NotoSansProviderOptions): GoogleProvider {
111
+ // Create a single Google provider instance to share initialization
112
+ const googleProvider = fontProviders.google();
113
+
114
+ return {
115
+ name: "emdash-noto",
116
+ async init(context) {
117
+ await googleProvider.init?.(context);
118
+ },
119
+ async resolveFont(resolveFontOptions) {
120
+ // Resolve the base Noto Sans (Latin, Cyrillic, Greek, etc.)
121
+ const base = await googleProvider.resolveFont(resolveFontOptions);
122
+ const baseFonts = base?.fonts ?? [];
123
+
124
+ if (!options?.scripts?.length) {
125
+ return base;
126
+ }
127
+
128
+ // Collect subset names already covered by the base font so we
129
+ // can filter out duplicate faces from extra script families.
130
+ // e.g. Noto Sans Arabic includes latin/latin-ext faces that
131
+ // would otherwise override the base Noto Sans latin faces.
132
+ const baseSubsets = new Set(baseFonts.map((f) => f.meta?.subset).filter(Boolean));
133
+
134
+ // Resolve additional script families
135
+ const extraFonts = await Promise.all(
136
+ options.scripts.map(async (script) => {
137
+ const family = NOTO_SCRIPT_FAMILIES[script];
138
+ if (!family) {
139
+ // Silently skip subset names that are already covered
140
+ // by the base Noto Sans font (latin, cyrillic, etc.)
141
+ if (ALL_GOOGLE_SUBSETS.includes(script)) {
142
+ return undefined;
143
+ }
144
+ console.warn(
145
+ `[emdash] Unknown Noto Sans script "${script}". ` +
146
+ `Available: ${Object.keys(NOTO_SCRIPT_FAMILIES).join(", ")}`,
147
+ );
148
+ return undefined;
149
+ }
150
+ return googleProvider.resolveFont({
151
+ ...resolveFontOptions,
152
+ familyName: family,
153
+ // Pass all known subset names so the unifont provider
154
+ // doesn't filter out any faces. Each script family
155
+ // only returns faces for its own subsets anyway.
156
+ subsets: ALL_GOOGLE_SUBSETS,
157
+ });
158
+ }),
159
+ );
160
+
161
+ // Merge, dropping faces from extra fonts that duplicate base subsets
162
+ const extraFaces = extraFonts.flatMap((r) =>
163
+ (r?.fonts ?? []).filter((f) => !f.meta?.subset || !baseSubsets.has(f.meta.subset)),
164
+ );
165
+
166
+ return {
167
+ fonts: [...baseFonts, ...extraFaces],
168
+ };
169
+ },
170
+ };
171
+ }
172
+
173
+ /** Get the list of available Noto Sans script names */
174
+ export function getAvailableNotoScripts(): string[] {
175
+ return Object.keys(NOTO_SCRIPT_FAMILIES);
176
+ }
@@ -14,6 +14,7 @@ import type { AstroIntegration, AstroIntegrationLogger } from "astro";
14
14
 
15
15
  import type { ResolvedPlugin } from "../../plugins/types.js";
16
16
  import { local } from "../storage/adapters.js";
17
+ import { notoSans } from "./font-provider.js";
17
18
  import { injectCoreRoutes, injectBuiltinAuthRoutes, injectMcpRoute } from "./routes.js";
18
19
  import type { EmDashConfig, PluginDescriptor } from "./runtime.js";
19
20
  import { createViteConfig } from "./vite-config.js";
@@ -158,6 +159,7 @@ export function emdash(config: EmDashConfig = {}): AstroIntegration {
158
159
  auth: resolvedConfig.auth,
159
160
  marketplace: resolvedConfig.marketplace,
160
161
  siteUrl: resolvedConfig.siteUrl,
162
+ maxUploadSize: resolvedConfig.maxUploadSize,
161
163
  };
162
164
 
163
165
  // Determine auth mode for route injection
@@ -207,8 +209,48 @@ export function emdash(config: EmDashConfig = {}): AstroIntegration {
207
209
  ? { allowedDomains: [{ hostname: new URL(resolvedConfig.siteUrl).hostname }] }
208
210
  : {}),
209
211
  };
212
+
213
+ // Inject default Noto Sans font for the admin UI.
214
+ // Uses the Astro Font API so fonts are downloaded at build time
215
+ // and self-hosted (no runtime CDN requests).
216
+ //
217
+ // The admin CSS references var(--font-emdash) with a system font
218
+ // fallback. Users can add extra script coverage (Arabic, CJK, etc.)
219
+ // by passing fonts.scripts in the emdash() config. The custom
220
+ // notoSans provider resolves all script families from Google Fonts
221
+ // under a single font-family name, so they stack via unicode-range.
222
+ const fontsConfig = resolvedConfig.fonts;
223
+ const emdashFonts =
224
+ fontsConfig === false
225
+ ? []
226
+ : [
227
+ {
228
+ provider: notoSans({
229
+ scripts: fontsConfig?.scripts,
230
+ }),
231
+ name: "Noto Sans",
232
+ cssVariable: "--font-emdash",
233
+ weights: ["100 900" as const],
234
+ styles: ["normal" as const, "italic" as const],
235
+ subsets: [
236
+ "latin" as const,
237
+ "latin-ext" as const,
238
+ "cyrillic" as const,
239
+ "cyrillic-ext" as const,
240
+ "devanagari" as const,
241
+ "greek" as const,
242
+ "greek-ext" as const,
243
+ "vietnamese" as const,
244
+ ],
245
+ fallbacks: ["ui-sans-serif", "system-ui", "sans-serif"],
246
+ },
247
+ ];
248
+
210
249
  updateConfig({
211
250
  security: securityConfig,
251
+ // fonts is a valid AstroConfig key but may not be in the
252
+ // type definition for the minimum supported Astro version
253
+ ...({ fonts: emdashFonts } as Record<string, unknown>),
212
254
  vite: createViteConfig(
213
255
  {
214
256
  serializableConfig,
@@ -515,6 +515,12 @@ export function injectCoreRoutes(injectRoute: InjectRoute): void {
515
515
  entrypoint: resolveRoute("api/well-known/oauth-authorization-server.ts"),
516
516
  });
517
517
 
518
+ // RFC 7591 Dynamic Client Registration
519
+ injectRoute({
520
+ pattern: "/_emdash/api/oauth/register",
521
+ entrypoint: resolveRoute("api/oauth/register.ts"),
522
+ });
523
+
518
524
  // Plugin-defined API routes
519
525
  // All plugin routes are handled by a single catch-all handler
520
526
  injectRoute({
@@ -256,6 +256,19 @@ export interface EmDashConfig {
256
256
  */
257
257
  marketplace?: string;
258
258
 
259
+ /**
260
+ * Maximum allowed media file upload size in bytes.
261
+ *
262
+ * Applies to both direct multipart uploads and signed-URL uploads.
263
+ * When unset, defaults to 52_428_800 (50 MB).
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * emdash({ maxUploadSize: 100 * 1024 * 1024 }) // 100 MB
268
+ * ```
269
+ */
270
+ maxUploadSize?: number;
271
+
259
272
  /**
260
273
  * Public browser-facing origin for the site.
261
274
  *
@@ -322,6 +335,56 @@ export interface EmDashConfig {
322
335
  * ```
323
336
  */
324
337
  mediaProviders?: MediaProviderDescriptor[];
338
+
339
+ /**
340
+ * Admin UI font configuration.
341
+ *
342
+ * By default, EmDash loads Noto Sans via the Astro Font API, covering
343
+ * Latin, Latin Extended, Cyrillic, Cyrillic Extended, Greek, Greek
344
+ * Extended, Devanagari, and Vietnamese. Fonts are downloaded from
345
+ * Google at build time and self-hosted, so there are no runtime CDN
346
+ * requests.
347
+ *
348
+ * To add support for additional writing systems (Arabic, CJK, etc.),
349
+ * pass script names. EmDash resolves the matching Noto Sans variant
350
+ * from Google Fonts and merges all script faces under a single
351
+ * font-family, so the browser downloads only the glyphs it needs
352
+ * via unicode-range.
353
+ *
354
+ * Set to `false` to disable font injection entirely and use system fonts.
355
+ *
356
+ * @example
357
+ * ```ts
358
+ * // Add Arabic and Japanese support
359
+ * emdash({
360
+ * fonts: {
361
+ * scripts: ["arabic", "japanese"],
362
+ * },
363
+ * })
364
+ * ```
365
+ *
366
+ * @example
367
+ * ```ts
368
+ * // Disable web fonts entirely (use system fonts)
369
+ * emdash({
370
+ * fonts: false,
371
+ * })
372
+ * ```
373
+ */
374
+ fonts?:
375
+ | false
376
+ | {
377
+ /**
378
+ * Additional Noto Sans script families to include.
379
+ *
380
+ * Available scripts: arabic, armenian, bengali, chinese-simplified,
381
+ * chinese-traditional, chinese-hongkong, devanagari, ethiopic,
382
+ * georgian, gujarati, gurmukhi, hebrew, japanese, kannada, khmer,
383
+ * korean, lao, malayalam, myanmar, oriya, sinhala, tamil, telugu,
384
+ * thai, tibetan.
385
+ */
386
+ scripts?: string[];
387
+ };
325
388
  }
326
389
 
327
390
  /**