@ddd-ts-kit/http 0.13.0 → 0.15.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 (445) hide show
  1. package/README.md +320 -9
  2. package/dist/controller/controller-routes.d.ts.map +1 -1
  3. package/dist/controller/controller-routes.js +8 -0
  4. package/dist/controller/controller-routes.js.map +1 -1
  5. package/dist/controller/controller-spec.d.ts +7 -0
  6. package/dist/controller/controller-spec.d.ts.map +1 -1
  7. package/dist/error/default-error-mapping.d.ts.map +1 -1
  8. package/dist/error/default-error-mapping.js +1 -0
  9. package/dist/error/default-error-mapping.js.map +1 -1
  10. package/dist/express/mount-express.d.ts +4 -2
  11. package/dist/express/mount-express.d.ts.map +1 -1
  12. package/dist/express/mount-express.js +25 -11
  13. package/dist/express/mount-express.js.map +1 -1
  14. package/dist/fastify/mount-fastify.d.ts +2 -1
  15. package/dist/fastify/mount-fastify.d.ts.map +1 -1
  16. package/dist/fastify/mount-fastify.js +23 -4
  17. package/dist/fastify/mount-fastify.js.map +1 -1
  18. package/dist/field-access/assert-writable.d.ts +8 -0
  19. package/dist/field-access/assert-writable.d.ts.map +1 -0
  20. package/dist/field-access/assert-writable.js +29 -0
  21. package/dist/field-access/assert-writable.js.map +1 -0
  22. package/dist/field-access/field-access-entry.d.ts +7 -0
  23. package/dist/field-access/field-access-entry.d.ts.map +1 -0
  24. package/dist/field-access/field-access-entry.js +2 -0
  25. package/dist/field-access/field-access-entry.js.map +1 -0
  26. package/dist/field-access/field-access.d.ts +13 -0
  27. package/dist/field-access/field-access.d.ts.map +1 -0
  28. package/dist/field-access/field-access.js +41 -0
  29. package/dist/field-access/field-access.js.map +1 -0
  30. package/dist/field-access/field-decider-of.d.ts +37 -0
  31. package/dist/field-access/field-decider-of.d.ts.map +1 -0
  32. package/dist/field-access/field-decider-of.js +30 -0
  33. package/dist/field-access/field-decider-of.js.map +1 -0
  34. package/dist/field-access/field-decider.d.ts +4 -0
  35. package/dist/field-access/field-decider.d.ts.map +1 -0
  36. package/dist/field-access/field-decider.js +2 -0
  37. package/dist/field-access/field-decider.js.map +1 -0
  38. package/dist/field-access/field-judge.d.ts +33 -0
  39. package/dist/field-access/field-judge.d.ts.map +1 -0
  40. package/dist/field-access/field-judge.js +81 -0
  41. package/dist/field-access/field-judge.js.map +1 -0
  42. package/dist/field-access/field-policy.d.ts +15 -0
  43. package/dist/field-access/field-policy.d.ts.map +1 -0
  44. package/dist/field-access/field-policy.js +2 -0
  45. package/dist/field-access/field-policy.js.map +1 -0
  46. package/dist/field-access/field-question.d.ts +18 -0
  47. package/dist/field-access/field-question.d.ts.map +1 -0
  48. package/dist/field-access/field-question.js +2 -0
  49. package/dist/field-access/field-question.js.map +1 -0
  50. package/dist/field-access/field-requirement.d.ts +13 -0
  51. package/dist/field-access/field-requirement.d.ts.map +1 -0
  52. package/dist/field-access/field-requirement.js +2 -0
  53. package/dist/field-access/field-requirement.js.map +1 -0
  54. package/dist/field-access/field-rule.d.ts +11 -0
  55. package/dist/field-access/field-rule.d.ts.map +1 -0
  56. package/dist/field-access/field-rule.js +2 -0
  57. package/dist/field-access/field-rule.js.map +1 -0
  58. package/dist/field-access/field-rules.d.ts +6 -0
  59. package/dist/field-access/field-rules.d.ts.map +1 -0
  60. package/dist/field-access/field-rules.js +2 -0
  61. package/dist/field-access/field-rules.js.map +1 -0
  62. package/dist/field-access/field-tree.d.ts +16 -0
  63. package/dist/field-access/field-tree.d.ts.map +1 -0
  64. package/dist/field-access/field-tree.js +28 -0
  65. package/dist/field-access/field-tree.js.map +1 -0
  66. package/dist/field-access/visible-body.d.ts +9 -0
  67. package/dist/field-access/visible-body.d.ts.map +1 -0
  68. package/dist/field-access/visible-body.js +42 -0
  69. package/dist/field-access/visible-body.js.map +1 -0
  70. package/dist/field-access/with-field-access.d.ts +17 -0
  71. package/dist/field-access/with-field-access.d.ts.map +1 -0
  72. package/dist/field-access/with-field-access.js +63 -0
  73. package/dist/field-access/with-field-access.js.map +1 -0
  74. package/dist/forms/assert-hints.d.ts +12 -0
  75. package/dist/forms/assert-hints.d.ts.map +1 -0
  76. package/dist/forms/assert-hints.js +32 -0
  77. package/dist/forms/assert-hints.js.map +1 -0
  78. package/dist/forms/assert-opens.d.ts +16 -0
  79. package/dist/forms/assert-opens.d.ts.map +1 -0
  80. package/dist/forms/assert-opens.js +24 -0
  81. package/dist/forms/assert-opens.js.map +1 -0
  82. package/dist/forms/constraints-of.d.ts +4 -0
  83. package/dist/forms/constraints-of.d.ts.map +1 -0
  84. package/dist/forms/constraints-of.js +24 -0
  85. package/dist/forms/constraints-of.js.map +1 -0
  86. package/dist/forms/define-form.d.ts +20 -0
  87. package/dist/forms/define-form.d.ts.map +1 -0
  88. package/dist/forms/define-form.js +8 -0
  89. package/dist/forms/define-form.js.map +1 -0
  90. package/dist/forms/field-block.d.ts +33 -0
  91. package/dist/forms/field-block.d.ts.map +1 -0
  92. package/dist/forms/field-block.js +2 -0
  93. package/dist/forms/field-block.js.map +1 -0
  94. package/dist/forms/field-hint.d.ts +18 -0
  95. package/dist/forms/field-hint.d.ts.map +1 -0
  96. package/dist/forms/field-hint.js +2 -0
  97. package/dist/forms/field-hint.js.map +1 -0
  98. package/dist/forms/field-lookup.d.ts +7 -0
  99. package/dist/forms/field-lookup.d.ts.map +1 -0
  100. package/dist/forms/field-lookup.js +2 -0
  101. package/dist/forms/field-lookup.js.map +1 -0
  102. package/dist/forms/form-block.d.ts +5 -0
  103. package/dist/forms/form-block.d.ts.map +1 -0
  104. package/dist/forms/form-block.js +2 -0
  105. package/dist/forms/form-block.js.map +1 -0
  106. package/dist/forms/form-condition.d.ts +9 -0
  107. package/dist/forms/form-condition.d.ts.map +1 -0
  108. package/dist/forms/form-condition.js +2 -0
  109. package/dist/forms/form-condition.js.map +1 -0
  110. package/dist/forms/form-describer.d.ts +35 -0
  111. package/dist/forms/form-describer.d.ts.map +1 -0
  112. package/dist/forms/form-describer.js +132 -0
  113. package/dist/forms/form-describer.js.map +1 -0
  114. package/dist/forms/form-description.d.ts +17 -0
  115. package/dist/forms/form-description.d.ts.map +1 -0
  116. package/dist/forms/form-description.js +2 -0
  117. package/dist/forms/form-description.js.map +1 -0
  118. package/dist/forms/form-document.d.ts +9 -0
  119. package/dist/forms/form-document.d.ts.map +1 -0
  120. package/dist/forms/form-document.js +2 -0
  121. package/dist/forms/form-document.js.map +1 -0
  122. package/dist/forms/form-documents-of.d.ts +10 -0
  123. package/dist/forms/form-documents-of.d.ts.map +1 -0
  124. package/dist/forms/form-documents-of.js +22 -0
  125. package/dist/forms/form-documents-of.js.map +1 -0
  126. package/dist/forms/form-format.d.ts +7 -0
  127. package/dist/forms/form-format.d.ts.map +1 -0
  128. package/dist/forms/form-format.js +3 -0
  129. package/dist/forms/form-format.js.map +1 -0
  130. package/dist/forms/form-group-hint.d.ts +8 -0
  131. package/dist/forms/form-group-hint.d.ts.map +1 -0
  132. package/dist/forms/form-group-hint.js +2 -0
  133. package/dist/forms/form-group-hint.js.map +1 -0
  134. package/dist/forms/form-hints.d.ts +16 -0
  135. package/dist/forms/form-hints.d.ts.map +1 -0
  136. package/dist/forms/form-hints.js +2 -0
  137. package/dist/forms/form-hints.js.map +1 -0
  138. package/dist/forms/form-of-route.d.ts +17 -0
  139. package/dist/forms/form-of-route.d.ts.map +1 -0
  140. package/dist/forms/form-of-route.js +47 -0
  141. package/dist/forms/form-of-route.js.map +1 -0
  142. package/dist/forms/form-query-schema.d.ts +10 -0
  143. package/dist/forms/form-query-schema.d.ts.map +1 -0
  144. package/dist/forms/form-query-schema.js +58 -0
  145. package/dist/forms/form-query-schema.js.map +1 -0
  146. package/dist/forms/form-query.d.ts +7 -0
  147. package/dist/forms/form-query.d.ts.map +1 -0
  148. package/dist/forms/form-query.js +2 -0
  149. package/dist/forms/form-query.js.map +1 -0
  150. package/dist/forms/form-requirement.d.ts +18 -0
  151. package/dist/forms/form-requirement.d.ts.map +1 -0
  152. package/dist/forms/form-requirement.js +2 -0
  153. package/dist/forms/form-requirement.js.map +1 -0
  154. package/dist/forms/form-routes.d.ts +19 -0
  155. package/dist/forms/form-routes.d.ts.map +1 -0
  156. package/dist/forms/form-routes.js +67 -0
  157. package/dist/forms/form-routes.js.map +1 -0
  158. package/dist/forms/form-schema.d.ts +4 -0
  159. package/dist/forms/form-schema.d.ts.map +1 -0
  160. package/dist/forms/form-schema.js +52 -0
  161. package/dist/forms/form-schema.js.map +1 -0
  162. package/dist/forms/group-block.d.ts +9 -0
  163. package/dist/forms/group-block.d.ts.map +1 -0
  164. package/dist/forms/group-block.js +2 -0
  165. package/dist/forms/group-block.js.map +1 -0
  166. package/dist/forms/json-form.d.ts +8 -0
  167. package/dist/forms/json-form.d.ts.map +1 -0
  168. package/dist/forms/json-form.js +2 -0
  169. package/dist/forms/json-form.js.map +1 -0
  170. package/dist/forms/json-forms-of.d.ts +12 -0
  171. package/dist/forms/json-forms-of.d.ts.map +1 -0
  172. package/dist/forms/json-forms-of.js +129 -0
  173. package/dist/forms/json-forms-of.js.map +1 -0
  174. package/dist/forms/lookups-of.d.ts +5 -0
  175. package/dist/forms/lookups-of.d.ts.map +1 -0
  176. package/dist/forms/lookups-of.js +7 -0
  177. package/dist/forms/lookups-of.js.map +1 -0
  178. package/dist/forms/widget-of.d.ts +5 -0
  179. package/dist/forms/widget-of.d.ts.map +1 -0
  180. package/dist/forms/widget-of.js +25 -0
  181. package/dist/forms/widget-of.js.map +1 -0
  182. package/dist/forms/widget.d.ts +3 -0
  183. package/dist/forms/widget.d.ts.map +1 -0
  184. package/dist/forms/widget.js +2 -0
  185. package/dist/forms/widget.js.map +1 -0
  186. package/dist/hono/mount-hono.d.ts +4 -2
  187. package/dist/hono/mount-hono.d.ts.map +1 -1
  188. package/dist/hono/mount-hono.js +19 -7
  189. package/dist/hono/mount-hono.js.map +1 -1
  190. package/dist/hono/read-body.d.ts +4 -3
  191. package/dist/hono/read-body.d.ts.map +1 -1
  192. package/dist/hono/read-body.js +12 -5
  193. package/dist/hono/read-body.js.map +1 -1
  194. package/dist/index.d.ts +42 -0
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +20 -0
  197. package/dist/index.js.map +1 -1
  198. package/dist/openapi/cache-response-headers.d.ts +5 -2
  199. package/dist/openapi/cache-response-headers.d.ts.map +1 -1
  200. package/dist/openapi/cache-response-headers.js +10 -5
  201. package/dist/openapi/cache-response-headers.js.map +1 -1
  202. package/dist/openapi/documenting.d.ts +11 -0
  203. package/dist/openapi/documenting.d.ts.map +1 -0
  204. package/dist/openapi/documenting.js +2 -0
  205. package/dist/openapi/documenting.js.map +1 -0
  206. package/dist/openapi/generate-open-api.d.ts +7 -0
  207. package/dist/openapi/generate-open-api.d.ts.map +1 -1
  208. package/dist/openapi/generate-open-api.js +5 -1
  209. package/dist/openapi/generate-open-api.js.map +1 -1
  210. package/dist/openapi/path-items.d.ts +2 -3
  211. package/dist/openapi/path-items.d.ts.map +1 -1
  212. package/dist/openapi/path-items.js +8 -7
  213. package/dist/openapi/path-items.js.map +1 -1
  214. package/dist/openapi/request-body.d.ts +6 -3
  215. package/dist/openapi/request-body.d.ts.map +1 -1
  216. package/dist/openapi/request-body.js +13 -3
  217. package/dist/openapi/request-body.js.map +1 -1
  218. package/dist/openapi/responses.d.ts +2 -3
  219. package/dist/openapi/responses.d.ts.map +1 -1
  220. package/dist/openapi/responses.js +40 -12
  221. package/dist/openapi/responses.js.map +1 -1
  222. package/dist/pagination/every-page.d.ts +15 -0
  223. package/dist/pagination/every-page.d.ts.map +1 -0
  224. package/dist/pagination/every-page.js +21 -0
  225. package/dist/pagination/every-page.js.map +1 -0
  226. package/dist/pagination/page-schema-of.d.ts +2 -1
  227. package/dist/pagination/page-schema-of.d.ts.map +1 -1
  228. package/dist/pagination/page-schema-of.js +6 -2
  229. package/dist/pagination/page-schema-of.js.map +1 -1
  230. package/dist/pipeline/assert-cached-routes.d.ts +4 -2
  231. package/dist/pipeline/assert-cached-routes.d.ts.map +1 -1
  232. package/dist/pipeline/assert-cached-routes.js +46 -8
  233. package/dist/pipeline/assert-cached-routes.js.map +1 -1
  234. package/dist/pipeline/conditional-answer.d.ts +7 -2
  235. package/dist/pipeline/conditional-answer.d.ts.map +1 -1
  236. package/dist/pipeline/conditional-answer.js +10 -6
  237. package/dist/pipeline/conditional-answer.js.map +1 -1
  238. package/dist/pipeline/entity-tag-of.d.ts +3 -3
  239. package/dist/pipeline/entity-tag-of.d.ts.map +1 -1
  240. package/dist/pipeline/entity-tag-of.js +4 -4
  241. package/dist/pipeline/entity-tag-of.js.map +1 -1
  242. package/dist/pipeline/error-context.d.ts +6 -1
  243. package/dist/pipeline/error-context.d.ts.map +1 -1
  244. package/dist/pipeline/execute-options.d.ts +17 -0
  245. package/dist/pipeline/execute-options.d.ts.map +1 -1
  246. package/dist/pipeline/execute-route.d.ts.map +1 -1
  247. package/dist/pipeline/execute-route.js +121 -35
  248. package/dist/pipeline/execute-route.js.map +1 -1
  249. package/dist/pipeline/iterated-within.d.ts +9 -0
  250. package/dist/pipeline/iterated-within.d.ts.map +1 -0
  251. package/dist/pipeline/iterated-within.js +17 -0
  252. package/dist/pipeline/iterated-within.js.map +1 -0
  253. package/dist/pipeline/negotiated-vary.d.ts +6 -0
  254. package/dist/pipeline/negotiated-vary.d.ts.map +1 -0
  255. package/dist/pipeline/negotiated-vary.js +15 -0
  256. package/dist/pipeline/negotiated-vary.js.map +1 -0
  257. package/dist/pipeline/negotiation.d.ts +19 -0
  258. package/dist/pipeline/negotiation.d.ts.map +1 -0
  259. package/dist/pipeline/negotiation.js +19 -0
  260. package/dist/pipeline/negotiation.js.map +1 -0
  261. package/dist/pipeline/primed.d.ts +6 -0
  262. package/dist/pipeline/primed.d.ts.map +1 -0
  263. package/dist/pipeline/primed.js +20 -0
  264. package/dist/pipeline/primed.js.map +1 -0
  265. package/dist/pipeline/read-body.d.ts +10 -0
  266. package/dist/pipeline/read-body.d.ts.map +1 -0
  267. package/dist/pipeline/read-body.js +33 -0
  268. package/dist/pipeline/read-body.js.map +1 -0
  269. package/dist/pipeline/reported-stream.d.ts +6 -0
  270. package/dist/pipeline/reported-stream.d.ts.map +1 -0
  271. package/dist/pipeline/reported-stream.js +14 -0
  272. package/dist/pipeline/reported-stream.js.map +1 -0
  273. package/dist/pipeline/represented-answer.d.ts +7 -0
  274. package/dist/pipeline/represented-answer.d.ts.map +1 -0
  275. package/dist/pipeline/represented-answer.js +2 -0
  276. package/dist/pipeline/represented-answer.js.map +1 -0
  277. package/dist/pipeline/represented.d.ts +7 -0
  278. package/dist/pipeline/represented.d.ts.map +1 -0
  279. package/dist/pipeline/represented.js +19 -0
  280. package/dist/pipeline/represented.js.map +1 -0
  281. package/dist/pipeline/route-response.d.ts +2 -0
  282. package/dist/pipeline/route-response.d.ts.map +1 -1
  283. package/dist/pipeline/tagged-answer.d.ts +5 -2
  284. package/dist/pipeline/tagged-answer.d.ts.map +1 -1
  285. package/dist/pipeline/tagged-answer.js +1 -1
  286. package/dist/pipeline/tagged-answer.js.map +1 -1
  287. package/dist/pipeline/write-stream.d.ts +8 -0
  288. package/dist/pipeline/write-stream.d.ts.map +1 -0
  289. package/dist/pipeline/write-stream.js +23 -0
  290. package/dist/pipeline/write-stream.js.map +1 -0
  291. package/dist/pipeline/written-in.d.ts +10 -0
  292. package/dist/pipeline/written-in.d.ts.map +1 -0
  293. package/dist/pipeline/written-in.js +17 -0
  294. package/dist/pipeline/written-in.js.map +1 -0
  295. package/dist/representation/assert-served.d.ts +10 -0
  296. package/dist/representation/assert-served.d.ts.map +1 -0
  297. package/dist/representation/assert-served.js +18 -0
  298. package/dist/representation/assert-served.js.map +1 -0
  299. package/dist/representation/body-shape.d.ts +9 -0
  300. package/dist/representation/body-shape.d.ts.map +1 -0
  301. package/dist/representation/body-shape.js +2 -0
  302. package/dist/representation/body-shape.js.map +1 -0
  303. package/dist/representation/csv/csv-cell.d.ts +8 -0
  304. package/dist/representation/csv/csv-cell.d.ts.map +1 -0
  305. package/dist/representation/csv/csv-cell.js +19 -0
  306. package/dist/representation/csv/csv-cell.js.map +1 -0
  307. package/dist/representation/csv/csv-representation.d.ts +16 -0
  308. package/dist/representation/csv/csv-representation.d.ts.map +1 -0
  309. package/dist/representation/csv/csv-representation.js +54 -0
  310. package/dist/representation/csv/csv-representation.js.map +1 -0
  311. package/dist/representation/is-json-media-type.d.ts +3 -0
  312. package/dist/representation/is-json-media-type.d.ts.map +1 -0
  313. package/dist/representation/is-json-media-type.js +5 -0
  314. package/dist/representation/is-json-media-type.js.map +1 -0
  315. package/dist/representation/json-representation.d.ts +14 -0
  316. package/dist/representation/json-representation.d.ts.map +1 -0
  317. package/dist/representation/json-representation.js +40 -0
  318. package/dist/representation/json-representation.js.map +1 -0
  319. package/dist/representation/malformed-body.d.ts +4 -0
  320. package/dist/representation/malformed-body.d.ts.map +1 -0
  321. package/dist/representation/malformed-body.js +6 -0
  322. package/dist/representation/malformed-body.js.map +1 -0
  323. package/dist/representation/media-type-of.d.ts +3 -0
  324. package/dist/representation/media-type-of.d.ts.map +1 -0
  325. package/dist/representation/media-type-of.js +7 -0
  326. package/dist/representation/media-type-of.js.map +1 -0
  327. package/dist/representation/negotiate.d.ts +8 -0
  328. package/dist/representation/negotiate.d.ts.map +1 -0
  329. package/dist/representation/negotiate.js +55 -0
  330. package/dist/representation/negotiate.js.map +1 -0
  331. package/dist/representation/not-acceptable-error.d.ts +7 -0
  332. package/dist/representation/not-acceptable-error.d.ts.map +1 -0
  333. package/dist/representation/not-acceptable-error.js +7 -0
  334. package/dist/representation/not-acceptable-error.js.map +1 -0
  335. package/dist/representation/problem-shape.d.ts +4 -0
  336. package/dist/representation/problem-shape.d.ts.map +1 -0
  337. package/dist/representation/problem-shape.js +7 -0
  338. package/dist/representation/problem-shape.js.map +1 -0
  339. package/dist/representation/representation.d.ts +20 -0
  340. package/dist/representation/representation.d.ts.map +1 -0
  341. package/dist/representation/representation.js +9 -0
  342. package/dist/representation/representation.js.map +1 -0
  343. package/dist/representation/representations.d.ts +33 -0
  344. package/dist/representation/representations.d.ts.map +1 -0
  345. package/dist/representation/representations.js +85 -0
  346. package/dist/representation/representations.js.map +1 -0
  347. package/dist/representation/represented-body.d.ts +3 -0
  348. package/dist/representation/represented-body.d.ts.map +1 -0
  349. package/dist/representation/represented-body.js +2 -0
  350. package/dist/representation/represented-body.js.map +1 -0
  351. package/dist/representation/stream-schema-of.d.ts +10 -0
  352. package/dist/representation/stream-schema-of.d.ts.map +1 -0
  353. package/dist/representation/stream-schema-of.js +31 -0
  354. package/dist/representation/stream-schema-of.js.map +1 -0
  355. package/dist/representation/unsupported-media-type-error.d.ts +7 -0
  356. package/dist/representation/unsupported-media-type-error.d.ts.map +1 -0
  357. package/dist/representation/unsupported-media-type-error.js +7 -0
  358. package/dist/representation/unsupported-media-type-error.js.map +1 -0
  359. package/dist/representation/wire-text.d.ts +7 -0
  360. package/dist/representation/wire-text.d.ts.map +1 -0
  361. package/dist/representation/wire-text.js +21 -0
  362. package/dist/representation/wire-text.js.map +1 -0
  363. package/dist/representation/xml/decode-entities.d.ts +3 -0
  364. package/dist/representation/xml/decode-entities.d.ts.map +1 -0
  365. package/dist/representation/xml/decode-entities.js +38 -0
  366. package/dist/representation/xml/decode-entities.js.map +1 -0
  367. package/dist/representation/xml/is-xml-name.d.ts +3 -0
  368. package/dist/representation/xml/is-xml-name.d.ts.map +1 -0
  369. package/dist/representation/xml/is-xml-name.js +6 -0
  370. package/dist/representation/xml/is-xml-name.js.map +1 -0
  371. package/dist/representation/xml/xml-convention.d.ts +10 -0
  372. package/dist/representation/xml/xml-convention.d.ts.map +1 -0
  373. package/dist/representation/xml/xml-convention.js +10 -0
  374. package/dist/representation/xml/xml-convention.js.map +1 -0
  375. package/dist/representation/xml/xml-element-writer.d.ts +16 -0
  376. package/dist/representation/xml/xml-element-writer.d.ts.map +1 -0
  377. package/dist/representation/xml/xml-element-writer.js +71 -0
  378. package/dist/representation/xml/xml-element-writer.js.map +1 -0
  379. package/dist/representation/xml/xml-element.d.ts +9 -0
  380. package/dist/representation/xml/xml-element.d.ts.map +1 -0
  381. package/dist/representation/xml/xml-element.js +2 -0
  382. package/dist/representation/xml/xml-element.js.map +1 -0
  383. package/dist/representation/xml/xml-parser.d.ts +27 -0
  384. package/dist/representation/xml/xml-parser.d.ts.map +1 -0
  385. package/dist/representation/xml/xml-parser.js +154 -0
  386. package/dist/representation/xml/xml-parser.js.map +1 -0
  387. package/dist/representation/xml/xml-representation.d.ts +20 -0
  388. package/dist/representation/xml/xml-representation.d.ts.map +1 -0
  389. package/dist/representation/xml/xml-representation.js +52 -0
  390. package/dist/representation/xml/xml-representation.js.map +1 -0
  391. package/dist/representation/xml/xml-syntax-error.d.ts +5 -0
  392. package/dist/representation/xml/xml-syntax-error.d.ts.map +1 -0
  393. package/dist/representation/xml/xml-syntax-error.js +8 -0
  394. package/dist/representation/xml/xml-syntax-error.js.map +1 -0
  395. package/dist/representation/xml/xml-text.d.ts +7 -0
  396. package/dist/representation/xml/xml-text.d.ts.map +1 -0
  397. package/dist/representation/xml/xml-text.js +30 -0
  398. package/dist/representation/xml/xml-text.js.map +1 -0
  399. package/dist/representation/xml/xml-value-reader.d.ts +15 -0
  400. package/dist/representation/xml/xml-value-reader.d.ts.map +1 -0
  401. package/dist/representation/xml/xml-value-reader.js +101 -0
  402. package/dist/representation/xml/xml-value-reader.js.map +1 -0
  403. package/dist/route/answers-with-schema.d.ts +7 -0
  404. package/dist/route/answers-with-schema.d.ts.map +1 -0
  405. package/dist/route/answers-with-schema.js +10 -0
  406. package/dist/route/answers-with-schema.js.map +1 -0
  407. package/dist/route/route-spec.d.ts +11 -0
  408. package/dist/route/route-spec.d.ts.map +1 -1
  409. package/dist/schema/json-schema-of.d.ts +7 -0
  410. package/dist/schema/json-schema-of.d.ts.map +1 -0
  411. package/dist/schema/json-schema-of.js +15 -0
  412. package/dist/schema/json-schema-of.js.map +1 -0
  413. package/dist/schema/schema-node.d.ts +25 -0
  414. package/dist/schema/schema-node.d.ts.map +1 -0
  415. package/dist/schema/schema-node.js +92 -0
  416. package/dist/schema/schema-node.js.map +1 -0
  417. package/dist/schema/schema-type.d.ts +3 -0
  418. package/dist/schema/schema-type.d.ts.map +1 -0
  419. package/dist/schema/schema-type.js +2 -0
  420. package/dist/schema/schema-type.js.map +1 -0
  421. package/dist/schema/xml-hints.d.ts +9 -0
  422. package/dist/schema/xml-hints.d.ts.map +1 -0
  423. package/dist/schema/xml-hints.js +2 -0
  424. package/dist/schema/xml-hints.js.map +1 -0
  425. package/dist/serialization/decimal-text.d.ts +6 -0
  426. package/dist/serialization/decimal-text.d.ts.map +1 -0
  427. package/dist/serialization/decimal-text.js +13 -0
  428. package/dist/serialization/decimal-text.js.map +1 -0
  429. package/dist/serialization/money-body.d.ts +6 -0
  430. package/dist/serialization/money-body.d.ts.map +1 -0
  431. package/dist/serialization/money-body.js +2 -0
  432. package/dist/serialization/money-body.js.map +1 -0
  433. package/dist/serialization/money.d.ts +4 -0
  434. package/dist/serialization/money.d.ts.map +1 -0
  435. package/dist/serialization/money.js +10 -0
  436. package/dist/serialization/money.js.map +1 -0
  437. package/dist/support/is-async-iterable.d.ts +3 -0
  438. package/dist/support/is-async-iterable.d.ts.map +1 -0
  439. package/dist/support/is-async-iterable.js +5 -0
  440. package/dist/support/is-async-iterable.js.map +1 -0
  441. package/dist/tenancy/served-tenant-of.d.ts +9 -0
  442. package/dist/tenancy/served-tenant-of.d.ts.map +1 -0
  443. package/dist/tenancy/served-tenant-of.js +19 -0
  444. package/dist/tenancy/served-tenant-of.js.map +1 -0
  445. package/package.json +4 -4
package/README.md CHANGED
@@ -84,7 +84,7 @@ const routes = controllerRoutes([PlaceOrderController], { resolve: application.r
84
84
 
85
85
  | Export | What it is |
86
86
  |---|---|
87
- | `Controller(spec)` | the decorator of a controller: `group`, `method`, `path` (after the prefix of the group), `operationId` (the class name without `Controller` by default), `summary`, `description`, `tags`, `params`, `query`, `headers`, `body`, `response: { status, description?, body? }`, `errors`, `guards`, `deprecated`, `cache` and `ifMatch` (see "HTTP caching") |
87
+ | `Controller(spec)` | the decorator of a controller: `group`, `method`, `path` (after the prefix of the group), `operationId` (the class name without `Controller` by default), `summary`, `description`, `tags`, `params`, `query`, `headers`, `body`, `response: { status, description?, body? }`, `errors`, `guards`, `deprecated`, `cache` and `ifMatch` (see "HTTP caching"), `produces` and `consumes` (see [Representations](#representations-json-xml-csv)), `form` (see [Forms described by the server](#forms-described-by-the-server)) |
88
88
  | `RouteGroup({ parent, prefix, tags, guards, errors, cache })` | names a set of routes on an empty class; a child inherits from its `parent` and adds; the nearest `cache` wins |
89
89
  | `Guard` | the interface `{ documents?, check(request: GuardRequest) }`, and the decorator of a guard class that takes dependencies |
90
90
  | `Authenticated`, `Public`, `HasRole(...roles)`, `HasScope(...scopes)`, `TenantMember` | the guards the package ships, over the `Actor` and the `Session` of the request: 401 to the anonymous caller, 403 without one of the roles, without every scope named (`Session.scopes`, typed by the `SessionScopes` of the project) or outside the tenant of the request; `Public` lets everybody in and stands alone. A refusal of a guard is reported to `onGuardRefusal` |
@@ -152,9 +152,12 @@ the application are known, and a public answer is held to them with a `Declarati
152
152
 
153
153
  - on a route that knows its caller, `vary` names `Authorization`, `Cookie`, or a header the tenant
154
154
  is read from (`resolveTenant`): `vary: ['Accept-Language']` alone is refused;
155
+ - on any route, even one anybody may call, an answer whose schema reserves fields to some
156
+ callers (`withFieldAccess` with a `read` requirement, on the answer, its page or its stream)
157
+ names `Authorization` or `Cookie` in `vary`: what it shows depends on who calls;
155
158
  - behind a cache that ignores `Vary` (`cacheTags.header` of Cloudflare or Bunny), a public answer
156
159
  that varies is refused, unless `cacheTags.honoursVary: true` says the cache keys on those
157
- headers;
160
+ headers; an answer chosen by `Accept` among several media types (`produces`) varies on it;
158
161
  - with tags filed per tenant (`cacheTags.perTenant`), a tagged route anybody may call needs
159
162
  `resolveTenant`: an anonymous call names no tenant otherwise, and no purge would meet its answer.
160
163
 
@@ -192,7 +195,10 @@ without a body to a caller that already holds that version:
192
195
  `If-None-Match` is read first and compared weakly, `If-Modified-Since` only without it. A body
193
196
  that lacks the field it names answers 500, as any answer its declaration does not allow. The
194
197
  contract gains the `If-None-Match` and `If-Modified-Since` parameters, the `ETag` and
195
- `Last-Modified` headers and the `304` answer.
198
+ `Last-Modified` headers and the `304` answer. Under [representations](#representations-json-xml-csv), the
199
+ version, the instant and the cache tags are read from what the handler answered, the same in
200
+ JSON, XML or CSV; a strong tag digests the bytes of the media type sent, so each representation
201
+ has its own, and a streamed list, whose bytes are not known when its headers go, has none.
196
202
 
197
203
  A write made on the version a client read declares `ifMatch` (`IfMatch.optional` or
198
204
  `IfMatch.required`). The pipeline reads the version named in `If-Match` (the weak tag the read
@@ -335,7 +341,8 @@ message nor its facts.
335
341
 
336
342
  Defaults: `VALIDATION_FAILED` 422 (with `issues`, paths prefixed by the part:
337
343
  `body.items.0.sku`), `NOT_FOUND` 404, `CONFLICT` 409, `INVARIANT_VIOLATION` 422, `UNAUTHORIZED`
338
- 401, `FORBIDDEN` 403, `PRECONDITION_FAILED` 412, `PRECONDITION_REQUIRED` 428. A domain code that is not mapped answers 422.
344
+ 401, `FORBIDDEN` 403, `NOT_ACCEPTABLE` 406, `PRECONDITION_FAILED` 412, `UNSUPPORTED_MEDIA_TYPE` 415,
345
+ `PRECONDITION_REQUIRED` 428. A domain code that is not mapped answers 422.
339
346
 
340
347
  ```ts
341
348
  import { createErrorMapper } from '@ddd-ts-kit/http';
@@ -450,6 +457,7 @@ const options: ExecuteOptions = {
450
457
  | `tenantFromPath(parameter?)` | a path parameter, `tenantId` by default |
451
458
  | `tenantFromClaim()` | the tenant of the credential, `Actor.tenantId` |
452
459
  | `firstTenantOf(...resolvers)` | the first that names one |
460
+ | `servedTenantOf(resolver, served)` | what `resolver` names, when it is among the tenants served; any other is answered 404 (`NOT_FOUND`), so a credential naming a tenant the deployment does not know (its jobs, its directory) reaches nothing |
453
461
 
454
462
  The pipeline then checks the membership itself, before any guard or handler: an authenticated
455
463
  caller that does not belong to the tenant named (its `tenantId`, or its `tenants` attribute for an
@@ -609,6 +617,287 @@ issue per mistake, none quoting a value:
609
617
  The scope of the actor is not a parameter: the handler of the query joins it with `scoped`,
610
618
  and nothing in a query string can remove it.
611
619
 
620
+ ## Representations: JSON, XML, CSV
621
+
622
+ A route keeps answering a typed value its response schema checks; a `Representation` turns it
623
+ into the text of one media type, chosen per request by the `Accept` header among those the
624
+ route declares. The application registers its representations once and gives the same set to
625
+ the adapters and to the contract generator:
626
+
627
+ ```ts
628
+ import { Representations, type ExecuteOptions } from '@ddd-ts-kit/http';
629
+
630
+ const representations = Representations.standard(); // JSON, XML and CSV
631
+ const options: ExecuteOptions = { ...boundary, representations };
632
+ const document = generateOpenApi({ info, routes, errorMapper, representations });
633
+ ```
634
+
635
+ A route says what it answers in besides JSON (`produces`) and what it reads a body in besides
636
+ JSON (`consumes`), on `@Controller` or on `defineRoute` alike:
637
+
638
+ ```ts
639
+ @Controller({
640
+ group: PartnerRoutes, method: 'GET', path: '/:practiceId/appointments', summary: 'Export appointments',
641
+ params, response: { status: 200, body: streamSchemaOf(line) },
642
+ produces: ['text/csv', 'application/xml'],
643
+ })
644
+ ```
645
+
646
+ | Media type | Answers | Reads | Notes |
647
+ |---|---|---|---|
648
+ | `application/json` | always, and first: what a request without `Accept` gets | always | as before; a big integer is written as a string |
649
+ | `application/problem+json` | a refusal, unless XML was negotiated | | RFC 9457, as before |
650
+ | `application/xml` | `XmlRepresentation` | `XmlRepresentation`, when the route `consumes` it | the convention below |
651
+ | `application/problem+xml` | a refusal of a request that negotiated XML | | `<problem xmlns="urn:ietf:rfc:7807">` |
652
+ | `text/csv` | `CsvRepresentation`, for a page or a list of flat rows | never | streamed; RFC 4180 |
653
+
654
+ - **Negotiation** (RFC 9110): the media type of highest quality among those the route offers,
655
+ the most specific range of the header deciding, the order `application/json` then `produces`
656
+ breaking ties. None acceptable: `406 NOT_ACCEPTABLE` in `application/problem+json`, before
657
+ the handler runs. A route that offers more than one answers with `Vary: accept`, added to the
658
+ `Vary` of its cache policy or the one its handler sets, and documented in the contract. A route that declares no body schema in any response (a file, a
659
+ redirect, no content) is never refused 406: its answer is its own, and a `Readable` or bytes
660
+ go out as the handler wrote them, under its content type.
661
+ - **Bodies**: a body sent in a media type the route consumes is read by its representation
662
+ into the value the JSON path produces, then validated by the same schema; one sent in a media
663
+ type the route does not read is refused with `415 UNSUPPORTED_MEDIA_TYPE`. `mountExpress`
664
+ installs a text parser on each route that consumes another media type, `mountFastify` a
665
+ content type parser, `mountHono` reads it as text under its `bodyLimit`: nothing to add to
666
+ the application.
667
+ - **Streaming**: a handler that answers an `AsyncIterable` under a `streamSchemaOf(item)`
668
+ response is written item by item in every representation (one JSON array, one XML root, one
669
+ CSV line per row), honouring the back pressure of the client and stopping when it leaves.
670
+ Each item is read inside the execution scope of the request, as the handler was. The first
671
+ item is read before the status is sent: a cursor that cannot open is answered as a problem. A
672
+ failure after that cuts the response short and is told to `onError` with the correlation of
673
+ the request and `interrupted: true`, to count as a server fault.
674
+ - **A streamed list read through the bus**: build it with `everyPage((cursor) =>
675
+ this.queries.execute(new SearchQuery(actor, ..., pageAt(cursor))))`, one query per page. Each
676
+ page then goes through the middlewares of the bus: authorization, the unit of work and its
677
+ transaction-scoped tenant session (the row-level security of `@ddd-ts-kit/knex` and
678
+ `@ddd-ts-kit/drizzle`), timeout, tracing, metrics, error reporting. A query handler that
679
+ answers a lazy `AsyncIterable` is read after the bus has returned, outside all of them: its
680
+ reads have no transaction, no tenant session, no span. The deadline of the request
681
+ (`requestTimeoutMs`) counts from its arrival, so a long export needs a route of its own with a
682
+ longer one, or a job that writes a file.
683
+ - **Mount-time checks**: a media type no registered representation provides, a CSV answer
684
+ whose rows hold a list or an object, and a consumed media type nothing reads are refused with
685
+ a `DeclarationError` when the routes are mounted; so is a route that declares `produces` or
686
+ `consumes` when no `representations` are mounted. A body in a consumed media type that another
687
+ parser (a plugin, a middleware) already turned into an object is a defect, answered 500.
688
+ - **The contract** follows the representations it is given, which must be those the server is
689
+ mounted with (`generateOpenApi({ representations })`): every media type a route answers in is
690
+ listed under its response, every media type it reads under its request body, the problem
691
+ types under each refusal, `406` on every route whose answer a representation writes and `415`
692
+ on every route that reads a body, declared in `produces` and `consumes` or not. Without
693
+ `representations`, the contract says JSON only and neither status, as the server answers.
694
+ - **Without `representations`**, nothing changes: every answer is JSON, whatever the request
695
+ accepts. With them, an answer in the JSON of the kit stays a value in the `RouteResponse` (a
696
+ spec calling `executeRoute` reads it as before); another representation gives bytes in
697
+ `body`, or chunks in `stream`.
698
+
699
+ ### The serialization rules, the same in every representation
700
+
701
+ | Value | Written as |
702
+ |---|---|
703
+ | an instant (`Date`) | ISO 8601 in UTC, `2026-10-13T07:05:00.000Z` |
704
+ | a decimal | a string, `decimalText(value)`: `'12.30'`, never a binary number a client rounds |
705
+ | money | `money(amount, currency)`: `{ amount: '12.30', currency: 'EUR' }`, the ISO 4217 code always next to the amount |
706
+ | an identifier | a string; a `bigint` is written in full |
707
+ | a closed vocabulary | its code, the value of the object `as const` that declares it |
708
+ | a list | the page envelope `{ items, total?, nextCursor? }` of `pageResponse`, or a streamed list |
709
+
710
+ `standard-serialization.spec.ts` holds the three representations to this table.
711
+
712
+ ### The XML convention
713
+
714
+ One convention, the default of the XML object of OpenAPI, so the contract describes the XML
715
+ with nothing added:
716
+
717
+ - the root element is `xml.name` of the response schema, else the operation id of the route
718
+ (`<getAppointment>`), and declares `xmlns:xsi`;
719
+ - a property is an element of its name, in the order of the schema; `xml.name` renames it,
720
+ `xml.attribute: true` makes a scalar an attribute; a name that cannot be an element name is
721
+ written `<entry key="two words">`;
722
+ - a list is unwrapped: one element per item, named after the property (or `items.xml.name`);
723
+ `xml.wrapped: true` puts them in an element of the property, each named `items.xml.name` or
724
+ `item`; a list at the root holds `<item>` elements;
725
+ - `null` is an empty element with `xsi:nil="true"`; a missing value is no element at all;
726
+ - a scalar is the text JSON would hold: an instant in ISO 8601 UTC, `true` or `false`, a
727
+ number as JavaScript writes it; a character XML 1.0 cannot carry becomes U+FFFD.
728
+
729
+ Reading follows the schema: text becomes a number or a boolean where the schema says so,
730
+ repeated elements a list, an element the schema does not declare stays in the value so the
731
+ schema refuses it as it refuses an unknown JSON property. The parser is the package's own and
732
+ reads elements, attributes, CDATA, comments, processing instructions, the predefined entities
733
+ and character references; it refuses a document type declaration, so no body can declare an
734
+ entity (no XXE, no expansion bomb), and nests at most 64 elements deep.
735
+
736
+ ### CSV
737
+
738
+ One header line with the properties of a row in the order of the schema, then one line per
739
+ row, `\r\n` at the end of each. A cell holding a comma, a quote, a line break or surrounding
740
+ spaces is quoted; a text that starts with `=`, `+`, `-`, `@`, a tab or a carriage return is
741
+ prefixed with `'`, so a spreadsheet does not run it as a formula (a number never is). `null`
742
+ and a missing value are an empty cell. CSV is never read: an import is a route of its own,
743
+ with a body schema of its own.
744
+
745
+ ### A representation of your own
746
+
747
+ ```ts
748
+ class YamlRepresentation implements Representation {
749
+ readonly mediaType = 'application/yaml';
750
+ readonly problemMediaType = undefined; // refusals stay application/problem+json
751
+
752
+ write(body: unknown, shape: BodyShape): RepresentedBody { ... }
753
+ }
754
+
755
+ const representations = Representations.of(new XmlRepresentation(), new YamlRepresentation());
756
+ ```
757
+
758
+ `write` gets the value and its shape (the JSON Schema of the response and the operation id);
759
+ `read`, when present, turns a body back into the value; `refuses`, when present, says at mount
760
+ time why a shape cannot be written. One given for `application/json` replaces the default.
761
+
762
+ ## Fields reserved to some callers
763
+
764
+ A response or a request schema marks a field as requiring a permission or a policy; the
765
+ pipeline does the rest, for every representation, instead of an `if (admin)` in a handler:
766
+
767
+ ```ts
768
+ import { fieldDeciderOf, withFieldAccess } from '@ddd-ts-kit/http';
769
+
770
+ const answer = withFieldAccess(classSchema(AppointmentAnswer), {
771
+ internalNote: {
772
+ read: { permission: schedulingPermissions['appointment.note.read'] },
773
+ write: { policy: notesOfTheirOwnCalendars }, // a policy of @ddd-ts-kit/auth fits as it is
774
+ subject: (row) => ({ type: 'calendar', id: row.calendarId }), // what the requirement is asked about
775
+ },
776
+ });
777
+
778
+ const options: ExecuteOptions = { ...boundary, fieldAccess: fieldDeciderOf({ access: app.resolve(Access), clock }) };
779
+ ```
780
+
781
+ | Where | A field the actor may not read | A field the actor may read but not set |
782
+ |---|---|---|
783
+ | an answer (JSON, XML, CSV, a streamed list) | left out; in CSV the column stays, its cells empty | kept |
784
+ | a request body | refused with `403 FORBIDDEN`, naming the path (`body.internalNote`) | refused the same way |
785
+ | a form described by the server | absent | read-only |
786
+ | the contract | `x-field-access: { read: { permission }, write: { policy } }` on the property, which is no longer listed in `required` | the same |
787
+
788
+ - `read` absent: whoever may call the route sees the field; `write` absent: whoever sees it may
789
+ set it. A field left out of a body is never judged.
790
+ - A permission is decided by `access.decideOn(question)` of `@ddd-ts-kit/auth` (else
791
+ `access.decide`), the policies of the permission then the authorizer, as for a use case; a
792
+ policy named on the field is asked directly, with the time of `clock`. `subject` names the
793
+ element: left out, the requirement is asked about nothing, which a role grant answers and a
794
+ relationship does not.
795
+ - **What is recorded**: a field set in a body is an act, and its decision goes to the audit
796
+ trail (`onDecision`) with who asked and the correlation; a field shown or left out of an
797
+ answer or a form only shapes it, and its decision is not recorded. The use case keeps
798
+ recording its own decision.
799
+ - **Cost**: each requirement is decided once per element and per request, inside the execution
800
+ scope of the request. A requirement about no element is asked once; a page of a hundred rows
801
+ of the same calendar asks once. A streamed export whose rule names a subject per row asks one
802
+ decision per distinct row (one evaluation of the policies and of the authorizer, a lookup of
803
+ relationships for a relationship model); the judge remembers the last 256 elements per
804
+ requirement, so its memory stays bounded whatever the length of the export. For a long export,
805
+ prefer a rule without subject, or a read model that already holds only what the caller may
806
+ read.
807
+ - `pageSchemaOf(item)` and `streamSchemaOf(item)` carry the restricted fields of their item.
808
+ A shared schema carries them in either order: `withFieldAccess(sharedSchema('Note', schema),
809
+ rules)`, `withFieldAccess(classSchema(NoteDto, { shared: true }), rules)` and
810
+ `sharedSchema('Note', withFieldAccess(schema, rules))` mark the shared definition and filter
811
+ the answer alike.
812
+ - **A public cache policy**: an answer with a field some callers may not read differs per caller.
813
+ When the routes are mounted, a `public` policy on such a route is refused unless its `vary`
814
+ names `Authorization` or `Cookie`, whoever may call the route (see "HTTP caching").
815
+ The rules apply to the properties of the schema given to `withFieldAccess`; a nested object is
816
+ restricted by wrapping its own schema.
817
+ - Without `fieldAccess` in the options, a restricted field is left out of every answer and
818
+ refused in every body: nothing is shown by omission.
819
+ - The rule `authz/fields-by-schema` of the checker and of the ESLint plugin refuses the
820
+ hand-written alternative, a test on the roles of the actor under `application/queries/`;
821
+ `authz/in-application` already refuses one in `presentation/`.
822
+
823
+ ## Forms described by the server
824
+
825
+ A route that declares `form` is described as a form, from what it already declares: its request
826
+ body schema, the restricted fields of that schema, and a few presentation hints. `formRoutes`
827
+ serves one `GET /forms/<operationId>` per such route, mounted and documented like any route:
828
+
829
+ ```ts
830
+ // presentation/http/appointments/book-appointment/book-appointment.controller.ts, next to its schemas
831
+ const form = defineForm<Infer<typeof body>>({
832
+ groups: [{ name: 'when', fields: ['startsAt', 'appointmentTypeId'] }],
833
+ fields: {
834
+ appointmentTypeId: { lookup: 'searchAppointmentTypes' }, // options from a GET route
835
+ reason: { widget: 'textarea', visibleWhen: { field: 'kind', equals: AppointmentKind.consultation } },
836
+ },
837
+ });
838
+
839
+ @Controller({ ..., body, form })
840
+
841
+ // the composition root
842
+ const routes = defineRoutes(appRoutes, formRoutes(appRoutes, { fieldAccess }));
843
+ ```
844
+
845
+ `GET /forms/bookAppointment?calendarId=c-1` answers **JSON Forms** (the default): `schema`,
846
+ `uischema` and `data`, which every renderer of JSON Forms takes as they are.
847
+ `?format=blocks` answers the **neutral tree of blocks** for a front end with its own engine:
848
+
849
+ ```json
850
+ { "type": "form", "operation": "bookAppointment", "method": "POST", "path": "/appointments", "label": "bookAppointment",
851
+ "blocks": [
852
+ { "type": "group", "name": "when", "label": "bookAppointment.when", "blocks": [
853
+ { "type": "field", "name": "startsAt", "label": "bookAppointment.startsAt", "widget": "datetime", "required": true,
854
+ "constraints": { "format": "date-time" } } ] },
855
+ { "type": "field", "name": "internalNote", "label": "bookAppointment.internalNote", "widget": "textarea",
856
+ "required": false, "readOnly": true } ] }
857
+ ```
858
+
859
+ | What | Taken from | In the tree | In JSON Forms |
860
+ |---|---|---|---|
861
+ | fields, their order, `required` | the request schema | `field` blocks | `schema` |
862
+ | constraints | `minLength`, `maxLength`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, `multipleOf`, `pattern`, `format`, `minItems`, `maxItems` | `constraints` | the same keywords in `schema` |
863
+ | options | an `enum` of the schema (a closed vocabulary), else `options` of the hint | `options`, each with a translation key | `enum` |
864
+ | a lookup | `lookup: '<operationId>'` of a `GET` route | `lookup: { operation, method, path }` | `options.lookup` of the control |
865
+ | widget | the hint, else the schema: `select` for an enumeration, `checkbox`, `number`, `datetime`, `date`, `time`, `email`, `list`, `text` | `widget` | the control, `options.multi` for `textarea`, `options.format: 'radio'` |
866
+ | groups | `groups` of the hints, nested; a nested object of the body is a group of its own | `group` blocks | `Group` elements |
867
+ | a field shown on a condition | `visibleWhen: { field, equals }` or `{ field, in }` | `visibleWhen` | a `SHOW` rule |
868
+ | a field required on a condition | `requiredWhen` | `requiredWhen` | `allOf` of `if`/`then` in `schema` |
869
+ | labels | `<operationId>`, `<operationId>.<group>`, `<operationId>.<field>`, `<operationId>.<field>.<option>`; `label` of a hint replaces one | `label` | `i18n` |
870
+ | values known in advance | the query: `?calendarId=c-1`, typed by the schema | `value` | `data` |
871
+
872
+ **The description respects the caller.** A form names the permission of the use case it
873
+ describes, asked as its `@Requires` asks it, from the values of the query:
874
+
875
+ ```ts
876
+ const form = defineForm<Infer<typeof body>>({
877
+ requires: {
878
+ permission: schedulingPermissions['appointment.book'],
879
+ subject: (values) => (values.calendarId === undefined ? undefined : { type: 'calendar', id: values.calendarId }),
880
+ context: (values, actor) => ({ selfService: (values.patientId ?? actor.id) === actor.id }),
881
+ },
882
+ });
883
+ ```
884
+
885
+ A caller who may not run the use case is refused with 403 (recorded as a decision) and learns
886
+ nothing of the fields; without `fieldAccess`, nobody is given a form that declares `requires`.
887
+ A form without `requires` is given to whoever may call the route. Then a field the actor may not
888
+ read (`withFieldAccess`) is absent, one they may read but not set is `readOnly` (`readOnly` in
889
+ `schema`, `options.readonly` on the control), with every field it holds when it is an object,
890
+ each asked about the element its `subject` names from the values of the query; a value of the
891
+ query for a field the caller does not see is not given back in `data`. The form of a route that
892
+ is not public refuses the anonymous caller with 401. The server still validates the body when
893
+ it is sent, refuses a field the caller may not set with 403, and the use case still enforces
894
+ its rules: a form carries shape and presentation, never a business rule.
895
+
896
+ Hints naming a field the body does not hold, or a lookup that is no `GET` route, stop
897
+ `formRoutes` with a `DeclarationError`. `formDocumentsOf(routes)` gives every form whole, in
898
+ both formats, for the documentation: a project generated by the CLI writes them to
899
+ `openapi/forms/<operationId>.json` next to its contract.
900
+
612
901
  ## Express 5
613
902
 
614
903
  ```ts
@@ -647,8 +936,11 @@ serve({ fetch: app.fetch, port: 3000 });
647
936
  The adapter reads the JSON body itself, chunk by chunk and up to `bodyLimit` bytes (1 MiB by
648
937
  default, as Fastify; Express stops at 100 kB): a larger body is answered 413 as a problem
649
938
  (`BODY_TOO_LARGE`), a body that is not JSON 400 (`MALFORMED_BODY`), both before the pipeline and
650
- without holding the body whole. An upload and a raw body are read from the request stream, with
651
- the limits their route declares, and a stream answer is streamed. A request carries `HonoRaw` as
939
+ without holding the body whole. A body in a media type the route consumes (`consumes`) is read
940
+ as text under the same limit, for its representation; another media type is not read, and the
941
+ pipeline answers 415 when representations are mounted. An upload and a raw body are read from
942
+ the request stream, with the limits their route declares, and a stream answer or a streamed
943
+ list is streamed. A request carries `HonoRaw` as
652
944
  its raw request (its headers as a record, which the authenticators of the kit read, and the
653
945
  `Context` of Hono), and a repeated query parameter is a list, as on Express and Fastify. The
654
946
  adapter imports nothing of Hono at run time and `node:stream` for the streams: the kit proves
@@ -742,6 +1034,7 @@ The platform shares three schemas of its own:
742
1034
  | the problem document | `Problem` | every refusal, RFC 9457 with the stable `code` |
743
1035
 
744
1036
  A shared request part (`params`, `query`, `headers`) still gives one parameter per property.
1037
+ Fields reserved by `withFieldAccess` stay reserved whichever of the two wraps the other.
745
1038
 
746
1039
  ## Serving the contract and its page
747
1040
 
@@ -847,12 +1140,30 @@ Express, mount them before `express.json()`: that parser reads a JSON body first
847
1140
  store answers its own links and needs no route.
848
1141
 
849
1142
  A handler may answer a stream (`Readable`) as its body: it is piped to the response, with its
850
- own `content-type`.
1143
+ own `content-type`, whatever `representations` the routes are mounted with: no representation
1144
+ writes a file, and a route that declares no body schema is never refused 406.
851
1145
 
852
1146
  ## Limits
853
1147
 
854
1148
  - A body the framework itself refuses (malformed JSON, payload too large) is answered by the
855
1149
  framework's own error handler, before the pipeline runs.
856
1150
  - Routes are JSON first. A handler may answer a string, bytes or a stream by setting its own
857
- `content-type` header. A request body streams only as a declared upload or a raw body
858
- (`rawBody`): server-sent events and WebSockets are written natively in the framework.
1151
+ `content-type` header, which no representation touches. A request body streams only as a
1152
+ declared upload or a raw body (`rawBody`): server-sent events and WebSockets are written
1153
+ natively in the framework.
1154
+ - XML is a faithful rendering of the JSON model, not a design tool for XML vocabularies: no
1155
+ namespaces but the default one of the root, no mixed content, no XML Schema. A partner format
1156
+ with a schema of its own is an anti-corruption layer with its own mapper.
1157
+ - A streamed list cannot be refused once its first item is written: the connection is cut,
1158
+ the client sees a truncated body, and `onError` is told. The items of a stream are not checked
1159
+ one by one by `validateResponses`.
1160
+ - CSV is written, never read, and holds flat rows only.
1161
+ - A form describes scalars, nested objects and lists of a closed vocabulary; a list of objects
1162
+ is a `list` field with no detail. Layout beyond groups and order is the front end's. A lookup
1163
+ names the route of the options; how the front end calls it and labels its items is its own.
1164
+ - Field access judges the fields a schema declares, not the rows: which rows an actor may read is
1165
+ the access scope of the query. A requirement about an element is one decision per element of
1166
+ the answer, not recorded; there is no batch decision of many elements at once.
1167
+ - A form is given to who may run its use case only when it declares `requires`; the values of
1168
+ its query name the element and the context, which the caller chooses, as they would in the
1169
+ body they send.
@@ -1 +1 @@
1
- {"version":3,"file":"controller-routes.d.ts","sourceRoot":"","sources":["../../src/controller/controller-routes.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAQ9E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,CAAC,eAAe,GAAG,gBAAgB,CAAC,EAAE,EAC5D,OAAO,GAAE,uBAA4B,GACpC,SAAS,KAAK,EAAE,CAMlB"}
1
+ {"version":3,"file":"controller-routes.d.ts","sourceRoot":"","sources":["../../src/controller/controller-routes.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAS9E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,CAAC,eAAe,GAAG,gBAAgB,CAAC,EAAE,EAC5D,OAAO,GAAE,uBAA4B,GACpC,SAAS,KAAK,EAAE,CAMlB"}
@@ -42,6 +42,7 @@ function documentationOf({ spec, declared, guards }) {
42
42
  responses: { [status]: { description: description ?? defaultDescription(body), ...bodyOf(body) } },
43
43
  errors: [...new Set([...declared.errors, ...guards.flatMap((guard) => guard.documents?.errors ?? [])])],
44
44
  ...(spec.deprecated === true ? { deprecated: true } : {}),
45
+ ...presentationOf(spec),
45
46
  };
46
47
  }
47
48
  function handlerOf(resolved, options, identity) {
@@ -81,6 +82,13 @@ function requestOf(parts) {
81
82
  }).filter(([, schema]) => schema !== undefined);
82
83
  return declared.length === 0 ? {} : { request: Object.fromEntries(declared) };
83
84
  }
85
+ function presentationOf({ produces, consumes, form }) {
86
+ return {
87
+ ...(produces === undefined ? {} : { produces: [...produces] }),
88
+ ...(consumes === undefined ? {} : { consumes: [...consumes] }),
89
+ ...(form === undefined ? {} : { form }),
90
+ };
91
+ }
84
92
  function bodyOf(body) {
85
93
  return body === undefined ? {} : { body };
86
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"controller-routes.js","sourceRoot":"","sources":["../../src/controller/controller-routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAUtE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,0BAA0B,CAAC;AAEvF,MAAM,gBAAgB,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,WAA4D,EAC5D,OAAO,GAA4B,EAAE;IAErC,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAExG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAE3B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,QAA4B,EAAE,OAAgC;IAC7E,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;IACpC,MAAM,QAAQ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CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,YAAY,CACnB,QAA+D,EAC/D,KAAiB;IAEjB,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAE7C,OAAO;QACL,GAAG,QAAQ;QACX,MAAM,EAAE,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;QAC5F,OAAO,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACjC,KAAK;QACL,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7C,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { Schema } from '@ddd-ts-kit/validation';
2
+ import type { FormHints } from '../forms/form-hints.js';
2
3
  import type { CachePolicy } from '../cache/cache-policy.js';
3
4
  import type { IfMatch } from '../cache/if-match.js';
4
5
  import type { HttpMethod } from '../route/http-method.js';
@@ -35,6 +36,12 @@ export interface ControllerSpec {
35
36
  /** Run after the guards of the group. With no group, at least one is required: `[Public]` says the route is open. */
36
37
  readonly guards?: readonly GuardReference[];
37
38
  readonly deprecated?: boolean;
39
+ /** Media types answered besides `application/json`, chosen by `Accept`: `['application/xml', 'text/csv']`. */
40
+ readonly produces?: readonly string[];
41
+ /** Media types a body is read in besides `application/json`: `['application/xml']`. */
42
+ readonly consumes?: readonly string[];
43
+ /** Describes the body as a form at `GET /forms/<operationId>` (`formRoutes`): `defineForm(...)` next to the schemas, or `{}`. */
44
+ readonly form?: FormHints;
38
45
  /** How the caches on the way may keep the answer; replaces the policy of the group. */
39
46
  readonly cache?: CachePolicy;
40
47
  /** A write conditional on the version the client read, handed to `handle` as `context.expectedVersion`. */
@@ -1 +1 @@
1
- {"version":3,"file":"controller-spec.d.ts","sourceRoot":"","sources":["../../src/controller/controller-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,oFAAoF;AACpF,MAAM,WAAW,cAAc;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,yGAAyG;IACzG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC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,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"default-error-mapping.d.ts","sourceRoot":"","sources":["../../src/error/default-error-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,qBAAqB,EAAE,YAYnC,CAAC"}
1
+ {"version":3,"file":"default-error-mapping.d.ts","sourceRoot":"","sources":["../../src/error/default-error-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,qBAAqB,EAAE,YAanC,CAAC"}
@@ -5,6 +5,7 @@ export const DEFAULT_ERROR_MAPPING = {
5
5
  INVARIANT_VIOLATION: 422,
6
6
  UNAUTHORIZED: 401,
7
7
  FORBIDDEN: 403,
8
+ NOT_ACCEPTABLE: 406,
8
9
  PRECONDITION_FAILED: 412,
9
10
  PRECONDITION_REQUIRED: 428,
10
11
  FILE_NOT_FOUND: 404,
@@ -1 +1 @@
1
- {"version":3,"file":"default-error-mapping.js","sourceRoot":"","sources":["../../src/error/default-error-mapping.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,iBAAiB,EAAE,GAAG;IACtB,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,GAAG;IACb,mBAAmB,EAAE,GAAG;IACxB,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,mBAAmB,EAAE,GAAG;IACxB,qBAAqB,EAAE,GAAG;IAC1B,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,GAAG;IACnB,sBAAsB,EAAE,GAAG;CAC5B,CAAC"}
1
+ {"version":3,"file":"default-error-mapping.js","sourceRoot":"","sources":["../../src/error/default-error-mapping.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,iBAAiB,EAAE,GAAG;IACtB,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,GAAG;IACb,mBAAmB,EAAE,GAAG;IACxB,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,cAAc,EAAE,GAAG;IACnB,mBAAmB,EAAE,GAAG;IACxB,qBAAqB,EAAE,GAAG;IAC1B,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,GAAG;IACnB,sBAAsB,EAAE,GAAG;CAC5B,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { IRouter } from 'express';
1
+ import { type IRouter } from 'express';
2
2
  import type { ExecuteOptions } from '../pipeline/execute-options.js';
3
3
  import type { Route } from '../route/route.js';
4
4
  export type ExpressMountOptions = ExecuteOptions;
@@ -6,7 +6,9 @@ export type ExpressMountOptions = ExecuteOptions;
6
6
  * Registers the routes on an Express 5 application or router. A JSON body parser
7
7
  * (`express.json()`) must be installed before, otherwise bodies reach validation as `undefined`.
8
8
  * An upload and a raw body are read from the request stream, which that parser leaves alone
9
- * unless the request is JSON. A body that is a stream is piped to the response.
9
+ * unless the request is JSON; a route that consumes another media type (`consumes`) gets a text
10
+ * parser of its own for it. A body that is a stream is piped to the response, a streamed list
11
+ * written chunk by chunk.
10
12
  */
11
13
  export declare function mountExpress(target: IRouter, routes: readonly Route[], options?: ExpressMountOptions): void;
12
14
  //# sourceMappingURL=mount-express.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount-express.d.ts","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAMrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAMjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAS/G"}
1
+ {"version":3,"file":"mount-express.d.ts","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAEA,OAAgB,EAAE,KAAK,OAAO,EAAoD,MAAM,SAAS,CAAC;AAClG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAQrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAMjD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAU/G"}
@@ -1,32 +1,42 @@
1
1
  import { Readable } from 'node:stream';
2
2
  import { pipeline } from 'node:stream/promises';
3
+ import express, {} from 'express';
3
4
  import { assertCachedRoutes } from '../pipeline/assert-cached-routes.js';
4
5
  import { executeRoute } from '../pipeline/execute-route.js';
5
6
  import { serializeBody } from '../pipeline/serialize-body.js';
7
+ import { writeStream } from '../pipeline/write-stream.js';
8
+ import { assertServed } from '../representation/assert-served.js';
6
9
  import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
7
10
  /**
8
11
  * Registers the routes on an Express 5 application or router. A JSON body parser
9
12
  * (`express.json()`) must be installed before, otherwise bodies reach validation as `undefined`.
10
13
  * An upload and a raw body are read from the request stream, which that parser leaves alone
11
- * unless the request is JSON. A body that is a stream is piped to the response.
14
+ * unless the request is JSON; a route that consumes another media type (`consumes`) gets a text
15
+ * parser of its own for it. A body that is a stream is piped to the response, a streamed list
16
+ * written chunk by chunk.
12
17
  */
13
18
  export function mountExpress(target, routes, options = {}) {
14
19
  assertUniqueRoutes(routes);
20
+ assertServed(routes, options.representations);
15
21
  assertCachedRoutes(routes, options);
16
22
  const register = registrarOf(target);
17
23
  for (const route of routes) {
18
- register[route.method](route.path, handlerOf(route, options));
24
+ register[route.method](route.path, ...bodyParsers(route), handlerOf(route, options));
19
25
  }
20
26
  }
27
+ function bodyParsers(route) {
28
+ const consumed = route.consumes ?? [];
29
+ return consumed.length === 0 ? [] : [express.text({ type: [...consumed] })];
30
+ }
21
31
  function registrarOf(target) {
22
32
  return {
23
- GET: (path, handler) => target.get(path, handler),
24
- POST: (path, handler) => target.post(path, handler),
25
- PUT: (path, handler) => target.put(path, handler),
26
- PATCH: (path, handler) => target.patch(path, handler),
27
- DELETE: (path, handler) => target.delete(path, handler),
28
- HEAD: (path, handler) => target.head(path, handler),
29
- OPTIONS: (path, handler) => target.options(path, handler),
33
+ GET: (path, ...handlers) => target.get(path, ...handlers),
34
+ POST: (path, ...handlers) => target.post(path, ...handlers),
35
+ PUT: (path, ...handlers) => target.put(path, ...handlers),
36
+ PATCH: (path, ...handlers) => target.patch(path, ...handlers),
37
+ DELETE: (path, ...handlers) => target.delete(path, ...handlers),
38
+ HEAD: (path, ...handlers) => target.head(path, ...handlers),
39
+ OPTIONS: (path, ...handlers) => target.options(path, ...handlers),
30
40
  };
31
41
  }
32
42
  function handlerOf(route, options) {
@@ -40,9 +50,13 @@ function handlerOf(route, options) {
40
50
  }
41
51
  if (result.body instanceof Readable) {
42
52
  await pipeline(result.body, response).catch(() => response.destroy());
43
- return;
44
53
  }
45
- response.end(serializeBody(result));
54
+ else if (result.stream === undefined) {
55
+ response.end(serializeBody(result));
56
+ }
57
+ else {
58
+ await writeStream(response, result.stream);
59
+ }
46
60
  };
47
61
  }
48
62
  //# sourceMappingURL=mount-express.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount-express.js","sourceRoot":"","sources":["../../src/express/mount-express.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CA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AAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;QAEnH,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE/B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3D,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,YAAY,QAAQ,EAAE,CAAC;YACpC,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACxE,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACvC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -4,7 +4,8 @@ import type { FastifyMountOptions } from './fastify-mount-options.js';
4
4
  /**
5
5
  * Registers the routes on a Fastify 5 instance. Validation stays in the shared pipeline. The
6
6
  * routes that read their body as a stream (an upload, a raw body) are registered in a context of
7
- * their own, where no body parser runs: the rest of the instance keeps its parsers.
7
+ * their own, where no body parser runs: the rest of the instance keeps its parsers. A media type
8
+ * a route consumes (`consumes`) is given a parser that hands the body over as text.
8
9
  */
9
10
  export declare function mountFastify(instance: FastifyInstance, routes: readonly Route[], options?: FastifyMountOptions): void;
10
11
  //# sourceMappingURL=mount-fastify.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount-fastify.d.ts","sourceRoot":"","sources":["../../src/fastify/mount-fastify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAK/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,OAAO,GAAE,mBAAwB,GAChC,IAAI,CAuBN"}
1
+ {"version":3,"file":"mount-fastify.d.ts","sourceRoot":"","sources":["../../src/fastify/mount-fastify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,OAAO,GAAE,mBAAwB,GAChC,IAAI,CAsBN"}