@ddd-ts-kit/http 0.12.0 → 0.14.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 (471) hide show
  1. package/README.md +373 -11
  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/edge-problem.d.ts +11 -0
  187. package/dist/hono/edge-problem.d.ts.map +1 -0
  188. package/dist/hono/edge-problem.js +15 -0
  189. package/dist/hono/edge-problem.js.map +1 -0
  190. package/dist/hono/hono-mount-options.d.ts +10 -0
  191. package/dist/hono/hono-mount-options.d.ts.map +1 -0
  192. package/dist/hono/hono-mount-options.js +2 -0
  193. package/dist/hono/hono-mount-options.js.map +1 -0
  194. package/dist/hono/hono-raw.d.ts +11 -0
  195. package/dist/hono/hono-raw.d.ts.map +1 -0
  196. package/dist/hono/hono-raw.js +2 -0
  197. package/dist/hono/hono-raw.js.map +1 -0
  198. package/dist/hono/mount-hono.d.ts +13 -0
  199. package/dist/hono/mount-hono.d.ts.map +1 -0
  200. package/dist/hono/mount-hono.js +77 -0
  201. package/dist/hono/mount-hono.js.map +1 -0
  202. package/dist/hono/read-body.d.ts +16 -0
  203. package/dist/hono/read-body.d.ts.map +1 -0
  204. package/dist/hono/read-body.js +65 -0
  205. package/dist/hono/read-body.js.map +1 -0
  206. package/dist/hono.d.ts +4 -0
  207. package/dist/hono.d.ts.map +1 -0
  208. package/dist/hono.js +2 -0
  209. package/dist/hono.js.map +1 -0
  210. package/dist/index.d.ts +43 -0
  211. package/dist/index.d.ts.map +1 -1
  212. package/dist/index.js +20 -0
  213. package/dist/index.js.map +1 -1
  214. package/dist/openapi/cache-response-headers.d.ts +5 -2
  215. package/dist/openapi/cache-response-headers.d.ts.map +1 -1
  216. package/dist/openapi/cache-response-headers.js +10 -5
  217. package/dist/openapi/cache-response-headers.js.map +1 -1
  218. package/dist/openapi/definitions.d.ts +6 -1
  219. package/dist/openapi/definitions.d.ts.map +1 -1
  220. package/dist/openapi/definitions.js +12 -1
  221. package/dist/openapi/definitions.js.map +1 -1
  222. package/dist/openapi/documenting.d.ts +11 -0
  223. package/dist/openapi/documenting.d.ts.map +1 -0
  224. package/dist/openapi/documenting.js +2 -0
  225. package/dist/openapi/documenting.js.map +1 -0
  226. package/dist/openapi/generate-open-api.d.ts +7 -0
  227. package/dist/openapi/generate-open-api.d.ts.map +1 -1
  228. package/dist/openapi/generate-open-api.js +5 -1
  229. package/dist/openapi/generate-open-api.js.map +1 -1
  230. package/dist/openapi/path-items.d.ts +2 -3
  231. package/dist/openapi/path-items.d.ts.map +1 -1
  232. package/dist/openapi/path-items.js +8 -7
  233. package/dist/openapi/path-items.js.map +1 -1
  234. package/dist/openapi/request-body.d.ts +6 -3
  235. package/dist/openapi/request-body.d.ts.map +1 -1
  236. package/dist/openapi/request-body.js +13 -3
  237. package/dist/openapi/request-body.js.map +1 -1
  238. package/dist/openapi/responses.d.ts +2 -3
  239. package/dist/openapi/responses.d.ts.map +1 -1
  240. package/dist/openapi/responses.js +40 -12
  241. package/dist/openapi/responses.js.map +1 -1
  242. package/dist/openapi/schema-parameters.js +1 -1
  243. package/dist/openapi/schema-parameters.js.map +1 -1
  244. package/dist/pagination/every-page.d.ts +15 -0
  245. package/dist/pagination/every-page.d.ts.map +1 -0
  246. package/dist/pagination/every-page.js +21 -0
  247. package/dist/pagination/every-page.js.map +1 -0
  248. package/dist/pagination/page-schema-of.d.ts +3 -1
  249. package/dist/pagination/page-schema-of.d.ts.map +1 -1
  250. package/dist/pagination/page-schema-of.js +11 -3
  251. package/dist/pagination/page-schema-of.js.map +1 -1
  252. package/dist/pipeline/assert-cached-routes.d.ts +4 -2
  253. package/dist/pipeline/assert-cached-routes.d.ts.map +1 -1
  254. package/dist/pipeline/assert-cached-routes.js +46 -8
  255. package/dist/pipeline/assert-cached-routes.js.map +1 -1
  256. package/dist/pipeline/conditional-answer.d.ts +7 -2
  257. package/dist/pipeline/conditional-answer.d.ts.map +1 -1
  258. package/dist/pipeline/conditional-answer.js +10 -6
  259. package/dist/pipeline/conditional-answer.js.map +1 -1
  260. package/dist/pipeline/entity-tag-of.d.ts +3 -3
  261. package/dist/pipeline/entity-tag-of.d.ts.map +1 -1
  262. package/dist/pipeline/entity-tag-of.js +4 -4
  263. package/dist/pipeline/entity-tag-of.js.map +1 -1
  264. package/dist/pipeline/error-context.d.ts +6 -1
  265. package/dist/pipeline/error-context.d.ts.map +1 -1
  266. package/dist/pipeline/execute-options.d.ts +17 -0
  267. package/dist/pipeline/execute-options.d.ts.map +1 -1
  268. package/dist/pipeline/execute-route.d.ts.map +1 -1
  269. package/dist/pipeline/execute-route.js +121 -35
  270. package/dist/pipeline/execute-route.js.map +1 -1
  271. package/dist/pipeline/iterated-within.d.ts +9 -0
  272. package/dist/pipeline/iterated-within.d.ts.map +1 -0
  273. package/dist/pipeline/iterated-within.js +17 -0
  274. package/dist/pipeline/iterated-within.js.map +1 -0
  275. package/dist/pipeline/negotiated-vary.d.ts +6 -0
  276. package/dist/pipeline/negotiated-vary.d.ts.map +1 -0
  277. package/dist/pipeline/negotiated-vary.js +15 -0
  278. package/dist/pipeline/negotiated-vary.js.map +1 -0
  279. package/dist/pipeline/negotiation.d.ts +19 -0
  280. package/dist/pipeline/negotiation.d.ts.map +1 -0
  281. package/dist/pipeline/negotiation.js +19 -0
  282. package/dist/pipeline/negotiation.js.map +1 -0
  283. package/dist/pipeline/primed.d.ts +6 -0
  284. package/dist/pipeline/primed.d.ts.map +1 -0
  285. package/dist/pipeline/primed.js +20 -0
  286. package/dist/pipeline/primed.js.map +1 -0
  287. package/dist/pipeline/read-body.d.ts +10 -0
  288. package/dist/pipeline/read-body.d.ts.map +1 -0
  289. package/dist/pipeline/read-body.js +33 -0
  290. package/dist/pipeline/read-body.js.map +1 -0
  291. package/dist/pipeline/reported-stream.d.ts +6 -0
  292. package/dist/pipeline/reported-stream.d.ts.map +1 -0
  293. package/dist/pipeline/reported-stream.js +14 -0
  294. package/dist/pipeline/reported-stream.js.map +1 -0
  295. package/dist/pipeline/represented-answer.d.ts +7 -0
  296. package/dist/pipeline/represented-answer.d.ts.map +1 -0
  297. package/dist/pipeline/represented-answer.js +2 -0
  298. package/dist/pipeline/represented-answer.js.map +1 -0
  299. package/dist/pipeline/represented.d.ts +7 -0
  300. package/dist/pipeline/represented.d.ts.map +1 -0
  301. package/dist/pipeline/represented.js +19 -0
  302. package/dist/pipeline/represented.js.map +1 -0
  303. package/dist/pipeline/route-response.d.ts +2 -0
  304. package/dist/pipeline/route-response.d.ts.map +1 -1
  305. package/dist/pipeline/tagged-answer.d.ts +5 -2
  306. package/dist/pipeline/tagged-answer.d.ts.map +1 -1
  307. package/dist/pipeline/tagged-answer.js +1 -1
  308. package/dist/pipeline/tagged-answer.js.map +1 -1
  309. package/dist/pipeline/write-stream.d.ts +8 -0
  310. package/dist/pipeline/write-stream.d.ts.map +1 -0
  311. package/dist/pipeline/write-stream.js +23 -0
  312. package/dist/pipeline/write-stream.js.map +1 -0
  313. package/dist/pipeline/written-in.d.ts +10 -0
  314. package/dist/pipeline/written-in.d.ts.map +1 -0
  315. package/dist/pipeline/written-in.js +17 -0
  316. package/dist/pipeline/written-in.js.map +1 -0
  317. package/dist/representation/assert-served.d.ts +10 -0
  318. package/dist/representation/assert-served.d.ts.map +1 -0
  319. package/dist/representation/assert-served.js +18 -0
  320. package/dist/representation/assert-served.js.map +1 -0
  321. package/dist/representation/body-shape.d.ts +9 -0
  322. package/dist/representation/body-shape.d.ts.map +1 -0
  323. package/dist/representation/body-shape.js +2 -0
  324. package/dist/representation/body-shape.js.map +1 -0
  325. package/dist/representation/csv/csv-cell.d.ts +8 -0
  326. package/dist/representation/csv/csv-cell.d.ts.map +1 -0
  327. package/dist/representation/csv/csv-cell.js +19 -0
  328. package/dist/representation/csv/csv-cell.js.map +1 -0
  329. package/dist/representation/csv/csv-representation.d.ts +16 -0
  330. package/dist/representation/csv/csv-representation.d.ts.map +1 -0
  331. package/dist/representation/csv/csv-representation.js +54 -0
  332. package/dist/representation/csv/csv-representation.js.map +1 -0
  333. package/dist/representation/is-json-media-type.d.ts +3 -0
  334. package/dist/representation/is-json-media-type.d.ts.map +1 -0
  335. package/dist/representation/is-json-media-type.js +5 -0
  336. package/dist/representation/is-json-media-type.js.map +1 -0
  337. package/dist/representation/json-representation.d.ts +14 -0
  338. package/dist/representation/json-representation.d.ts.map +1 -0
  339. package/dist/representation/json-representation.js +40 -0
  340. package/dist/representation/json-representation.js.map +1 -0
  341. package/dist/representation/malformed-body.d.ts +4 -0
  342. package/dist/representation/malformed-body.d.ts.map +1 -0
  343. package/dist/representation/malformed-body.js +6 -0
  344. package/dist/representation/malformed-body.js.map +1 -0
  345. package/dist/representation/media-type-of.d.ts +3 -0
  346. package/dist/representation/media-type-of.d.ts.map +1 -0
  347. package/dist/representation/media-type-of.js +7 -0
  348. package/dist/representation/media-type-of.js.map +1 -0
  349. package/dist/representation/negotiate.d.ts +8 -0
  350. package/dist/representation/negotiate.d.ts.map +1 -0
  351. package/dist/representation/negotiate.js +55 -0
  352. package/dist/representation/negotiate.js.map +1 -0
  353. package/dist/representation/not-acceptable-error.d.ts +7 -0
  354. package/dist/representation/not-acceptable-error.d.ts.map +1 -0
  355. package/dist/representation/not-acceptable-error.js +7 -0
  356. package/dist/representation/not-acceptable-error.js.map +1 -0
  357. package/dist/representation/problem-shape.d.ts +4 -0
  358. package/dist/representation/problem-shape.d.ts.map +1 -0
  359. package/dist/representation/problem-shape.js +7 -0
  360. package/dist/representation/problem-shape.js.map +1 -0
  361. package/dist/representation/representation.d.ts +20 -0
  362. package/dist/representation/representation.d.ts.map +1 -0
  363. package/dist/representation/representation.js +9 -0
  364. package/dist/representation/representation.js.map +1 -0
  365. package/dist/representation/representations.d.ts +33 -0
  366. package/dist/representation/representations.d.ts.map +1 -0
  367. package/dist/representation/representations.js +85 -0
  368. package/dist/representation/representations.js.map +1 -0
  369. package/dist/representation/represented-body.d.ts +3 -0
  370. package/dist/representation/represented-body.d.ts.map +1 -0
  371. package/dist/representation/represented-body.js +2 -0
  372. package/dist/representation/represented-body.js.map +1 -0
  373. package/dist/representation/stream-schema-of.d.ts +10 -0
  374. package/dist/representation/stream-schema-of.d.ts.map +1 -0
  375. package/dist/representation/stream-schema-of.js +31 -0
  376. package/dist/representation/stream-schema-of.js.map +1 -0
  377. package/dist/representation/unsupported-media-type-error.d.ts +7 -0
  378. package/dist/representation/unsupported-media-type-error.d.ts.map +1 -0
  379. package/dist/representation/unsupported-media-type-error.js +7 -0
  380. package/dist/representation/unsupported-media-type-error.js.map +1 -0
  381. package/dist/representation/wire-text.d.ts +7 -0
  382. package/dist/representation/wire-text.d.ts.map +1 -0
  383. package/dist/representation/wire-text.js +21 -0
  384. package/dist/representation/wire-text.js.map +1 -0
  385. package/dist/representation/xml/decode-entities.d.ts +3 -0
  386. package/dist/representation/xml/decode-entities.d.ts.map +1 -0
  387. package/dist/representation/xml/decode-entities.js +38 -0
  388. package/dist/representation/xml/decode-entities.js.map +1 -0
  389. package/dist/representation/xml/is-xml-name.d.ts +3 -0
  390. package/dist/representation/xml/is-xml-name.d.ts.map +1 -0
  391. package/dist/representation/xml/is-xml-name.js +6 -0
  392. package/dist/representation/xml/is-xml-name.js.map +1 -0
  393. package/dist/representation/xml/xml-convention.d.ts +10 -0
  394. package/dist/representation/xml/xml-convention.d.ts.map +1 -0
  395. package/dist/representation/xml/xml-convention.js +10 -0
  396. package/dist/representation/xml/xml-convention.js.map +1 -0
  397. package/dist/representation/xml/xml-element-writer.d.ts +16 -0
  398. package/dist/representation/xml/xml-element-writer.d.ts.map +1 -0
  399. package/dist/representation/xml/xml-element-writer.js +71 -0
  400. package/dist/representation/xml/xml-element-writer.js.map +1 -0
  401. package/dist/representation/xml/xml-element.d.ts +9 -0
  402. package/dist/representation/xml/xml-element.d.ts.map +1 -0
  403. package/dist/representation/xml/xml-element.js +2 -0
  404. package/dist/representation/xml/xml-element.js.map +1 -0
  405. package/dist/representation/xml/xml-parser.d.ts +27 -0
  406. package/dist/representation/xml/xml-parser.d.ts.map +1 -0
  407. package/dist/representation/xml/xml-parser.js +154 -0
  408. package/dist/representation/xml/xml-parser.js.map +1 -0
  409. package/dist/representation/xml/xml-representation.d.ts +20 -0
  410. package/dist/representation/xml/xml-representation.d.ts.map +1 -0
  411. package/dist/representation/xml/xml-representation.js +52 -0
  412. package/dist/representation/xml/xml-representation.js.map +1 -0
  413. package/dist/representation/xml/xml-syntax-error.d.ts +5 -0
  414. package/dist/representation/xml/xml-syntax-error.d.ts.map +1 -0
  415. package/dist/representation/xml/xml-syntax-error.js +8 -0
  416. package/dist/representation/xml/xml-syntax-error.js.map +1 -0
  417. package/dist/representation/xml/xml-text.d.ts +7 -0
  418. package/dist/representation/xml/xml-text.d.ts.map +1 -0
  419. package/dist/representation/xml/xml-text.js +30 -0
  420. package/dist/representation/xml/xml-text.js.map +1 -0
  421. package/dist/representation/xml/xml-value-reader.d.ts +15 -0
  422. package/dist/representation/xml/xml-value-reader.d.ts.map +1 -0
  423. package/dist/representation/xml/xml-value-reader.js +101 -0
  424. package/dist/representation/xml/xml-value-reader.js.map +1 -0
  425. package/dist/route/answers-with-schema.d.ts +7 -0
  426. package/dist/route/answers-with-schema.d.ts.map +1 -0
  427. package/dist/route/answers-with-schema.js +10 -0
  428. package/dist/route/answers-with-schema.js.map +1 -0
  429. package/dist/route/route-spec.d.ts +11 -0
  430. package/dist/route/route-spec.d.ts.map +1 -1
  431. package/dist/schema/json-schema-of.d.ts +7 -0
  432. package/dist/schema/json-schema-of.d.ts.map +1 -0
  433. package/dist/schema/json-schema-of.js +15 -0
  434. package/dist/schema/json-schema-of.js.map +1 -0
  435. package/dist/schema/schema-node.d.ts +25 -0
  436. package/dist/schema/schema-node.d.ts.map +1 -0
  437. package/dist/schema/schema-node.js +92 -0
  438. package/dist/schema/schema-node.js.map +1 -0
  439. package/dist/schema/schema-type.d.ts +3 -0
  440. package/dist/schema/schema-type.d.ts.map +1 -0
  441. package/dist/schema/schema-type.js +2 -0
  442. package/dist/schema/schema-type.js.map +1 -0
  443. package/dist/schema/xml-hints.d.ts +9 -0
  444. package/dist/schema/xml-hints.d.ts.map +1 -0
  445. package/dist/schema/xml-hints.js +2 -0
  446. package/dist/schema/xml-hints.js.map +1 -0
  447. package/dist/schemas/accepted-schema.d.ts +8 -0
  448. package/dist/schemas/accepted-schema.d.ts.map +1 -0
  449. package/dist/schemas/accepted-schema.js +20 -0
  450. package/dist/schemas/accepted-schema.js.map +1 -0
  451. package/dist/schemas/accepted.d.ts +5 -0
  452. package/dist/schemas/accepted.d.ts.map +1 -0
  453. package/dist/schemas/accepted.js +2 -0
  454. package/dist/schemas/accepted.js.map +1 -0
  455. package/dist/serialization/decimal-text.d.ts +6 -0
  456. package/dist/serialization/decimal-text.d.ts.map +1 -0
  457. package/dist/serialization/decimal-text.js +13 -0
  458. package/dist/serialization/decimal-text.js.map +1 -0
  459. package/dist/serialization/money-body.d.ts +6 -0
  460. package/dist/serialization/money-body.d.ts.map +1 -0
  461. package/dist/serialization/money-body.js +2 -0
  462. package/dist/serialization/money-body.js.map +1 -0
  463. package/dist/serialization/money.d.ts +4 -0
  464. package/dist/serialization/money.d.ts.map +1 -0
  465. package/dist/serialization/money.js +10 -0
  466. package/dist/serialization/money.js.map +1 -0
  467. package/dist/support/is-async-iterable.d.ts +3 -0
  468. package/dist/support/is-async-iterable.d.ts.map +1 -0
  469. package/dist/support/is-async-iterable.js +5 -0
  470. package/dist/support/is-async-iterable.js.map +1 -0
  471. package/package.json +15 -5
@@ -0,0 +1,20 @@
1
+ import type { BodyShape } from './body-shape.js';
2
+ import type { RepresentedBody } from './represented-body.js';
3
+ /**
4
+ * Turns the value a route answers into the text of one media type, and back for a request body
5
+ * when the media type is accepted as input. The value is the one the response schema checked:
6
+ * a representation never sees an aggregate. Registered once in the platform (`Representations`)
7
+ * and chosen per request by the `Accept` header.
8
+ */
9
+ export declare abstract class Representation {
10
+ /** `application/xml`, without parameters. */
11
+ abstract readonly mediaType: string;
12
+ /** The media type a refusal is written in when this one was negotiated; `undefined`, `application/problem+json`. */
13
+ abstract readonly problemMediaType: string | undefined;
14
+ abstract write(body: unknown, shape: BodyShape): RepresentedBody;
15
+ /** The value the JSON path would have produced, before the schema validates it. Absent, the media type is never read. */
16
+ abstract read?(text: string, shape: BodyShape): unknown;
17
+ /** Why a body of this shape cannot be written in this media type, when it cannot: checked when the routes are mounted. */
18
+ abstract refuses?(shape: BodyShape): string | undefined;
19
+ }
20
+ //# sourceMappingURL=representation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"representation.d.ts","sourceRoot":"","sources":["../../src/representation/representation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;;GAKG;AACH,8BAAsB,cAAc;IAClC,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAEpC,oHAAoH;IACpH,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvD,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,eAAe,CAAC;IAEjE,yHAAyH;IACzH,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IAExD,0HAA0H;IAC1H,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;CACzD"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Turns the value a route answers into the text of one media type, and back for a request body
3
+ * when the media type is accepted as input. The value is the one the response schema checked:
4
+ * a representation never sees an aggregate. Registered once in the platform (`Representations`)
5
+ * and chosen per request by the `Accept` header.
6
+ */
7
+ export class Representation {
8
+ }
9
+ //# sourceMappingURL=representation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"representation.js","sourceRoot":"","sources":["../../src/representation/representation.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,OAAgB,cAAc;CAcnC"}
@@ -0,0 +1,33 @@
1
+ import type { Route } from '../route/route.js';
2
+ import type { Representation } from './representation.js';
3
+ /** A representation chosen for a body, with the media type it is written under. */
4
+ export interface Chosen {
5
+ readonly mediaType: string;
6
+ readonly representation: Representation;
7
+ }
8
+ /**
9
+ * The media types an application answers and reads in, registered once in the platform and
10
+ * given to the adapters (`representations` of the mount options) and to the contract generator,
11
+ * which must be given the same. JSON is always there and always first: it is what a route
12
+ * answers when the request says nothing, and what it refuses in when nothing else fits.
13
+ */
14
+ export declare class Representations {
15
+ private readonly byMediaType;
16
+ private readonly json;
17
+ private constructor();
18
+ /** JSON, XML and CSV, the representations of the kit. */
19
+ static standard(): Representations;
20
+ /** JSON and the given ones; one given for `application/json` replaces the default. */
21
+ static of(...representations: readonly Representation[]): Representations;
22
+ /** What the route answers in, in its order of preference: JSON first, then what it declares in `produces`. */
23
+ offeredBy(route: Pick<Route, 'produces'>): readonly string[];
24
+ answerIn(mediaType: string): Chosen | undefined;
25
+ /** The refusals of an answer negotiated in `mediaType`: its problem media type, else `application/problem+json`. */
26
+ problemIn(mediaType: string | undefined): Chosen;
27
+ /** The representation that reads a body sent in `mediaType`: JSON always, another when the route declares it in `consumes`. */
28
+ readerOf(route: Pick<Route, 'consumes'>, mediaType: string): Representation | undefined;
29
+ /** Refuses, when the routes are mounted, a media type no representation provides and a body it cannot write or read. */
30
+ assertServes(routes: readonly Route[]): void;
31
+ private assertWrites;
32
+ }
33
+ //# sourceMappingURL=representations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"representations.d.ts","sourceRoot":"","sources":["../../src/representation/representations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,mFAAmF;AACnF,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;CACzC;AAID;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqC;IAEjE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IAEtC,OAAO,eAMN;IAED,yDAAyD;IACzD,MAAM,CAAC,QAAQ,IAAI,eAAe,CAEjC;IAED,sFAAsF;IACtF,MAAM,CAAC,EAAE,CAAC,GAAG,eAAe,EAAE,SAAS,cAAc,EAAE,GAAG,eAAe,CAExE;IAED,8GAA8G;IAC9G,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,SAAS,MAAM,EAAE,CAE3D;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI9C;IAED,oHAAoH;IACpH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQ/C;IAED,+HAA+H;IAC/H,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAQtF;IAED,wHAAwH;IACxH,YAAY,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI,CAY3C;IAED,OAAO,CAAC,YAAY;CAoBrB"}
@@ -0,0 +1,85 @@
1
+ import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
2
+ import { isJsonMediaType } from './is-json-media-type.js';
3
+ import { CsvRepresentation } from './csv/csv-representation.js';
4
+ import { JsonRepresentation } from './json-representation.js';
5
+ import { XmlRepresentation } from './xml/xml-representation.js';
6
+ const JSON_MEDIA_TYPE = 'application/json';
7
+ /**
8
+ * The media types an application answers and reads in, registered once in the platform and
9
+ * given to the adapters (`representations` of the mount options) and to the contract generator,
10
+ * which must be given the same. JSON is always there and always first: it is what a route
11
+ * answers when the request says nothing, and what it refuses in when nothing else fits.
12
+ */
13
+ export class Representations {
14
+ byMediaType = new Map();
15
+ json;
16
+ constructor(representations) {
17
+ this.json = representations.find(({ mediaType }) => mediaType === JSON_MEDIA_TYPE) ?? new JsonRepresentation();
18
+ for (const representation of [this.json, ...representations]) {
19
+ this.byMediaType.set(representation.mediaType, representation);
20
+ }
21
+ }
22
+ /** JSON, XML and CSV, the representations of the kit. */
23
+ static standard() {
24
+ return new Representations([new XmlRepresentation(), new CsvRepresentation()]);
25
+ }
26
+ /** JSON and the given ones; one given for `application/json` replaces the default. */
27
+ static of(...representations) {
28
+ return new Representations(representations);
29
+ }
30
+ /** What the route answers in, in its order of preference: JSON first, then what it declares in `produces`. */
31
+ offeredBy(route) {
32
+ return [JSON_MEDIA_TYPE, ...(route.produces ?? []).filter((type) => this.byMediaType.has(type))];
33
+ }
34
+ answerIn(mediaType) {
35
+ const representation = this.byMediaType.get(mediaType);
36
+ return representation === undefined ? undefined : { mediaType, representation };
37
+ }
38
+ /** The refusals of an answer negotiated in `mediaType`: its problem media type, else `application/problem+json`. */
39
+ problemIn(mediaType) {
40
+ const negotiated = mediaType === undefined ? undefined : this.byMediaType.get(mediaType);
41
+ if (negotiated?.problemMediaType !== undefined) {
42
+ return { mediaType: negotiated.problemMediaType, representation: negotiated };
43
+ }
44
+ return { mediaType: 'application/problem+json', representation: this.json };
45
+ }
46
+ /** The representation that reads a body sent in `mediaType`: JSON always, another when the route declares it in `consumes`. */
47
+ readerOf(route, mediaType) {
48
+ const consumed = isJsonMediaType(mediaType) || route.consumes?.includes(mediaType) === true;
49
+ const representation = consumed
50
+ ? this.byMediaType.get(isJsonMediaType(mediaType) ? JSON_MEDIA_TYPE : mediaType)
51
+ : undefined;
52
+ return representation?.read === undefined ? undefined : representation;
53
+ }
54
+ /** Refuses, when the routes are mounted, a media type no representation provides and a body it cannot write or read. */
55
+ assertServes(routes) {
56
+ for (const route of routes) {
57
+ for (const mediaType of route.produces ?? []) {
58
+ this.assertWrites(route, mediaType);
59
+ }
60
+ for (const mediaType of route.consumes ?? []) {
61
+ if (this.byMediaType.get(mediaType)?.read === undefined) {
62
+ throw new DeclarationError(`Route "${route.operationId}" consumes ${mediaType}, which is never read.`);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ assertWrites(route, mediaType) {
68
+ const representation = this.byMediaType.get(mediaType);
69
+ if (representation === undefined) {
70
+ throw new DeclarationError(`Route "${route.operationId}" declares ${mediaType}, and no representation of the platform provides it.`);
71
+ }
72
+ // A copy has a string index, which is how the statuses are enumerated.
73
+ const declared = { ...route.responses };
74
+ for (const response of Object.values(declared)) {
75
+ const reason = response.body === undefined ? undefined : representation.refuses?.(shapeOf(route, response.body));
76
+ if (reason !== undefined) {
77
+ throw new DeclarationError(`Route "${route.operationId}" cannot answer in ${mediaType}: ${reason}.`);
78
+ }
79
+ }
80
+ }
81
+ }
82
+ function shapeOf(route, body) {
83
+ return { schema: body.toJsonSchema(), name: route.operationId };
84
+ }
85
+ //# sourceMappingURL=representations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"representations.js","sourceRoot":"","sources":["../../src/representation/representations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAKnE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAQhE,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IACT,WAAW,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEhD,IAAI,CAAiB;IAEtC,YAAoB,eAA0C;QAC5D,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,eAAe,CAAC,IAAI,IAAI,kBAAkB,EAAE,CAAC;QAE/G,KAAK,MAAM,cAAc,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,eAAe,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,yDAAyD;IACzD,MAAM,CAAC,QAAQ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E,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAEhF,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/C,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YAEjH,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,IAAI,gBAAgB,CAAC,UAAU,KAAK,CAAC,WAAW,sBAAsB,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC;YACvG,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,SAAS,OAAO,CAAC,KAAY,EAAE,IAAqB;IAClD,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;AAClE,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** What a representation writes: the whole text at once, or its chunks in order, for a list streamed as it is read. */
2
+ export type RepresentedBody = string | AsyncIterable<string>;
3
+ //# sourceMappingURL=represented-body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"represented-body.d.ts","sourceRoot":"","sources":["../../src/representation/represented-body.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=represented-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"represented-body.js","sourceRoot":"","sources":["../../src/representation/represented-body.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { type Schema } from '@ddd-ts-kit/validation';
2
+ /**
3
+ * The schema of a list a route answers as it reads it (an export), from the schema of one item:
4
+ * the handler returns an `AsyncIterable`, every representation writes it chunk by chunk, and the
5
+ * contract describes it as an array. What `parse` answers checks each item as it is read; the
6
+ * pipeline, which writes what the handler returned, checks with `validateResponses` only that a
7
+ * list was returned.
8
+ */
9
+ export declare function streamSchemaOf<T>(item: Schema<T>): Schema<AsyncIterable<T>>;
10
+ //# sourceMappingURL=stream-schema-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-schema-of.d.ts","sourceRoot":"","sources":["../../src/representation/stream-schema-of.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAIjF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAmB3E"}
@@ -0,0 +1,31 @@
1
+ import { err, ok } from '@ddd-ts-kit/kernel';
2
+ import { customSchema, parseOrThrow } from '@ddd-ts-kit/validation';
3
+ import { fieldAccess } from '../field-access/field-access.js';
4
+ import { isAsyncIterable } from '../support/is-async-iterable.js';
5
+ /**
6
+ * The schema of a list a route answers as it reads it (an export), from the schema of one item:
7
+ * the handler returns an `AsyncIterable`, every representation writes it chunk by chunk, and the
8
+ * contract describes it as an array. What `parse` answers checks each item as it is read; the
9
+ * pipeline, which writes what the handler returned, checks with `validateResponses` only that a
10
+ * list was returned.
11
+ */
12
+ export function streamSchemaOf(item) {
13
+ const { $schema: _dialect, $defs, definitions, ...itemSchema } = item.toJsonSchema();
14
+ const stream = customSchema((input) => isAsyncIterable(input)
15
+ ? ok(checked(input, item))
16
+ : err([{ path: '', code: 'invalid_stream', message: 'A list read as it comes is expected.' }]), {
17
+ type: 'array',
18
+ items: itemSchema,
19
+ ...($defs === undefined ? {} : { $defs }),
20
+ ...(definitions === undefined ? {} : { definitions }),
21
+ });
22
+ fieldAccess.carry(item, stream, ['*']);
23
+ return stream;
24
+ }
25
+ /** Each item through the schema as it is read: an item that does not match stops the list. */
26
+ async function* checked(items, schema) {
27
+ for await (const item of items) {
28
+ yield parseOrThrow(schema, item);
29
+ }
30
+ }
31
+ //# sourceMappingURL=stream-schema-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-schema-of.js","sourceRoot":"","sources":["../../src/representation/stream-schema-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAe,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAI,IAAe;IAC/C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IAErF,MAAM,MAAM,GAAG,YAAY,CACzB,CAAC,KAAK,EAAE,EAAE,CACR,eAAe,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC,CAAC,EAClG;QACE,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,UAAU;QACjB,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;KACtD,CACF,CAAC;IAEF,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,8FAA8F;AAC9F,KAAK,SAAS,CAAC,CAAC,OAAO,CAAI,KAA6B,EAAE,MAAiB;IACzE,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC/B,MAAM,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { DomainError } from '@ddd-ts-kit/kernel';
2
+ export declare const UNSUPPORTED_MEDIA_TYPE = "UNSUPPORTED_MEDIA_TYPE";
3
+ /** The body of the request is in a media type the route does not read: 415. */
4
+ export declare class UnsupportedMediaTypeError extends DomainError {
5
+ readonly code = "UNSUPPORTED_MEDIA_TYPE";
6
+ }
7
+ //# sourceMappingURL=unsupported-media-type-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported-media-type-error.d.ts","sourceRoot":"","sources":["../../src/representation/unsupported-media-type-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,+EAA+E;AAC/E,qBAAa,yBAA0B,SAAQ,WAAW;IACxD,QAAQ,CAAC,IAAI,4BAA0B;CACxC"}
@@ -0,0 +1,7 @@
1
+ import { DomainError } from '@ddd-ts-kit/kernel';
2
+ export const UNSUPPORTED_MEDIA_TYPE = 'UNSUPPORTED_MEDIA_TYPE';
3
+ /** The body of the request is in a media type the route does not read: 415. */
4
+ export class UnsupportedMediaTypeError extends DomainError {
5
+ code = UNSUPPORTED_MEDIA_TYPE;
6
+ }
7
+ //# sourceMappingURL=unsupported-media-type-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsupported-media-type-error.js","sourceRoot":"","sources":["../../src/representation/unsupported-media-type-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,+EAA+E;AAC/E,MAAM,OAAO,yBAA0B,SAAQ,WAAW;IAC/C,IAAI,GAAG,sBAAsB,CAAC;CACxC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The text of a scalar in every representation that is not JSON, by the rules JSON follows:
3
+ * an instant in ISO 8601 UTC, a boolean as `true` or `false`, a number as JavaScript writes it,
4
+ * a big integer in full. `undefined` for nothing (`null`, `undefined`) and for what is no scalar.
5
+ */
6
+ export declare function wireText(value: unknown): string | undefined;
7
+ //# sourceMappingURL=wire-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-text.d.ts","sourceRoot":"","sources":["../../src/representation/wire-text.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAkB3D"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The text of a scalar in every representation that is not JSON, by the rules JSON follows:
3
+ * an instant in ISO 8601 UTC, a boolean as `true` or `false`, a number as JavaScript writes it,
4
+ * a big integer in full. `undefined` for nothing (`null`, `undefined`) and for what is no scalar.
5
+ */
6
+ export function wireText(value) {
7
+ if (value instanceof Date) {
8
+ return value.toISOString();
9
+ }
10
+ if (typeof value === 'string') {
11
+ return value;
12
+ }
13
+ if (typeof value === 'number') {
14
+ return Number.isFinite(value) ? String(value) : undefined;
15
+ }
16
+ if (typeof value === 'boolean' || typeof value === 'bigint') {
17
+ return String(value);
18
+ }
19
+ return undefined;
20
+ }
21
+ //# sourceMappingURL=wire-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-text.js","sourceRoot":"","sources":["../../src/representation/wire-text.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Character data with its references replaced: the five predefined entities and numeric references, nothing else. */
2
+ export declare function decodeEntities(raw: string): string;
3
+ //# sourceMappingURL=decode-entities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode-entities.d.ts","sourceRoot":"","sources":["../../../src/representation/xml/decode-entities.ts"],"names":[],"mappings":"AAgBA,sHAAsH;AACtH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQlD"}
@@ -0,0 +1,38 @@
1
+ import { XmlSyntaxError } from './xml-syntax-error.js';
2
+ // A map, not an object: `&constructor;` names no entity, whatever an object inherits.
3
+ const PREDEFINED = new Map([
4
+ ['lt', '<'],
5
+ ['gt', '>'],
6
+ ['amp', '&'],
7
+ ['quot', '"'],
8
+ ['apos', "'"],
9
+ ]);
10
+ const REFERENCE = /&(#x[0-9A-Fa-f]+|#[0-9]+|[A-Za-z]+);|&/g;
11
+ const HEXADECIMAL = 16;
12
+ const DECIMAL = 10;
13
+ const LAST_CODE_POINT = 0x10ffff;
14
+ /** Character data with its references replaced: the five predefined entities and numeric references, nothing else. */
15
+ export function decodeEntities(raw) {
16
+ return raw.replace(REFERENCE, (whole, reference) => {
17
+ if (reference === undefined) {
18
+ throw new XmlSyntaxError('a lone "&" in character data');
19
+ }
20
+ return characterOf(reference, whole);
21
+ });
22
+ }
23
+ function characterOf(reference, whole) {
24
+ const predefined = PREDEFINED.get(reference);
25
+ if (predefined !== undefined) {
26
+ return predefined;
27
+ }
28
+ if (!reference.startsWith('#')) {
29
+ throw new XmlSyntaxError(`the entity ${whole} is not declared`);
30
+ }
31
+ const hexadecimal = reference.startsWith('#x');
32
+ const code = Number.parseInt(reference.slice(hexadecimal ? 2 : 1), hexadecimal ? HEXADECIMAL : DECIMAL);
33
+ if (code === 0 || code > LAST_CODE_POINT) {
34
+ throw new XmlSyntaxError(`the character reference ${whole} is out of range`);
35
+ }
36
+ return String.fromCodePoint(code);
37
+ }
38
+ //# sourceMappingURL=decode-entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode-entities.js","sourceRoot":"","sources":["../../../src/representation/xml/decode-entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,sFAAsF;AACtF,MAAM,UAAU,GAAgC,IAAI,GAAG,CAAC;IACtD,CAAC,IAAI,EAAE,GAAG,CAAC;IACX,CAAC,IAAI,EAAE,GAAG,CAAC;IACX,CAAC,KAAK,EAAE,GAAG,CAAC;IACZ,CAAC,MAAM,EAAE,GAAG,CAAC;IACb,CAAC,MAAM,EAAE,GAAG,CAAC;CACd,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,yCAAyC,CAAC;AAC5D,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC,sHAAsH;AACtH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,SAA6B,EAAE,EAAE;QACrE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,cAAc,CAAC,8BAA8B,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,SAAiB,EAAE,KAAa;IACnD,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAE7C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,cAAc,CAAC,cAAc,KAAK,kBAAkB,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAExG,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,GAAG,eAAe,EAAE,CAAC;QACzC,MAAM,IAAI,cAAc,CAAC,2BAA2B,KAAK,kBAAkB,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Whether a property name can be written as the name of an element as it is: no colon, no space, no leading digit. */
2
+ export declare function isXmlName(name: string): boolean;
3
+ //# sourceMappingURL=is-xml-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-xml-name.d.ts","sourceRoot":"","sources":["../../../src/representation/xml/is-xml-name.ts"],"names":[],"mappings":"AAEA,uHAAuH;AACvH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/C"}
@@ -0,0 +1,6 @@
1
+ const NAME = /^[\p{L}_][\p{L}\p{N}._-]*$/u;
2
+ /** Whether a property name can be written as the name of an element as it is: no colon, no space, no leading digit. */
3
+ export function isXmlName(name) {
4
+ return NAME.test(name);
5
+ }
6
+ //# sourceMappingURL=is-xml-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-xml-name.js","sourceRoot":"","sources":["../../../src/representation/xml/is-xml-name.ts"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,6BAA6B,CAAC;AAE3C,uHAAuH;AACvH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /** The names the XML convention of the kit uses, in the writer and the reader alike. */
2
+ export declare const XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
3
+ export declare const XSI_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance";
4
+ export declare const NIL_ATTRIBUTE = "xsi:nil=\"true\"";
5
+ /** The element of one item of a list at the root or wrapped, unless the schema of the items names it. */
6
+ export declare const ITEM_ELEMENT = "item";
7
+ /** The element of a property whose name cannot be an element name, which `key` then carries. */
8
+ export declare const ENTRY_ELEMENT = "entry";
9
+ export declare const KEY_ATTRIBUTE = "key";
10
+ //# sourceMappingURL=xml-convention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-convention.d.ts","sourceRoot":"","sources":["../../../src/representation/xml/xml-convention.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,eAAO,MAAM,eAAe,+CAA2C,CAAC;AACxE,eAAO,MAAM,aAAa,8CAA8C,CAAC;AACzE,eAAO,MAAM,aAAa,qBAAmB,CAAC;AAC9C,yGAAyG;AACzG,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,gGAAgG;AAChG,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,eAAO,MAAM,aAAa,QAAQ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /** The names the XML convention of the kit uses, in the writer and the reader alike. */
2
+ export const XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8"?>';
3
+ export const XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance';
4
+ export const NIL_ATTRIBUTE = 'xsi:nil="true"';
5
+ /** The element of one item of a list at the root or wrapped, unless the schema of the items names it. */
6
+ export const ITEM_ELEMENT = 'item';
7
+ /** The element of a property whose name cannot be an element name, which `key` then carries. */
8
+ export const ENTRY_ELEMENT = 'entry';
9
+ export const KEY_ATTRIBUTE = 'key';
10
+ //# sourceMappingURL=xml-convention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-convention.js","sourceRoot":"","sources":["../../../src/representation/xml/xml-convention.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,MAAM,CAAC,MAAM,eAAe,GAAG,wCAAwC,CAAC;AACxE,MAAM,CAAC,MAAM,aAAa,GAAG,2CAA2C,CAAC;AACzE,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAC9C,yGAAyG;AACzG,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,gGAAgG;AAChG,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AACrC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { SchemaNode } from '../../schema/schema-node.js';
2
+ /**
3
+ * Writes one value as XML by the convention of the kit, which is the default of the XML object
4
+ * of OpenAPI: a property is an element of its name, a scalar marked `xml.attribute` an attribute,
5
+ * a list one element per item named after the property unless `xml.wrapped`, `null` an empty
6
+ * element with `xsi:nil="true"` and a missing value nothing at all.
7
+ */
8
+ export declare class XmlElementWriter {
9
+ element(name: string, value: unknown, node: SchemaNode): string;
10
+ items(values: readonly unknown[], node: SchemaNode): string;
11
+ private tagged;
12
+ private attributesOf;
13
+ private members;
14
+ private member;
15
+ }
16
+ //# sourceMappingURL=xml-element-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-element-writer.d.ts","sourceRoot":"","sources":["../../../src/representation/xml/xml-element-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAezD;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAE9D;IAED,KAAK,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAK1D;IAED,OAAO,CAAC,MAAM;IAgBd,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,MAAM;CAmBf"}
@@ -0,0 +1,71 @@
1
+ import { SchemaNode } from '../../schema/schema-node.js';
2
+ import { isRecord } from '../../support/is-record.js';
3
+ import { wireText } from '../wire-text.js';
4
+ import { ENTRY_ELEMENT, ITEM_ELEMENT, KEY_ATTRIBUTE, NIL_ATTRIBUTE } from './xml-convention.js';
5
+ import { isXmlName } from './is-xml-name.js';
6
+ import { xmlText } from './xml-text.js';
7
+ const ANY = SchemaNode.of({});
8
+ /**
9
+ * Writes one value as XML by the convention of the kit, which is the default of the XML object
10
+ * of OpenAPI: a property is an element of its name, a scalar marked `xml.attribute` an attribute,
11
+ * a list one element per item named after the property unless `xml.wrapped`, `null` an empty
12
+ * element with `xsi:nil="true"` and a missing value nothing at all.
13
+ */
14
+ export class XmlElementWriter {
15
+ element(name, value, node) {
16
+ return this.tagged({ name, attributes: '' }, value, node);
17
+ }
18
+ items(values, node) {
19
+ const items = node.items();
20
+ const name = items.xml().name ?? ITEM_ELEMENT;
21
+ return values.map((value) => this.element(name, value, items)).join('');
22
+ }
23
+ tagged({ name, attributes }, value, node) {
24
+ if (value === null) {
25
+ return `<${name}${attributes} ${NIL_ATTRIBUTE}/>`;
26
+ }
27
+ if (Array.isArray(value)) {
28
+ return `<${name}${attributes}>${this.items(value, node)}</${name}>`;
29
+ }
30
+ if (isRecord(value) && !(value instanceof Date)) {
31
+ return `<${name}${attributes}${this.attributesOf(value, node)}>${this.members(value, node)}</${name}>`;
32
+ }
33
+ return `<${name}${attributes}>${xmlText(wireText(value) ?? '')}</${name}>`;
34
+ }
35
+ attributesOf(record, node) {
36
+ return node
37
+ .properties()
38
+ .filter(([, child]) => child.xml().attribute === true)
39
+ .map(([key, child]) => ({ name: child.xml().name ?? key, text: wireText(record[key]) }))
40
+ .map(({ name, text }) => (text === undefined ? '' : ` ${name}="${xmlText(text)}"`))
41
+ .join('');
42
+ }
43
+ members(record, node) {
44
+ const declared = new Map(node.properties());
45
+ return Object.entries(record)
46
+ .filter(([key]) => declared.get(key)?.xml().attribute !== true)
47
+ .sort(([a], [b]) => orderOf(declared, a) - orderOf(declared, b))
48
+ .map(([key, value]) => this.member(key, value, declared.get(key) ?? ANY))
49
+ .join('');
50
+ }
51
+ member(key, value, node) {
52
+ if (value === undefined) {
53
+ return '';
54
+ }
55
+ const name = node.xml().name ?? key;
56
+ if (!isXmlName(name)) {
57
+ return this.tagged({ name: ENTRY_ELEMENT, attributes: ` ${KEY_ATTRIBUTE}="${xmlText(name)}"` }, value, node);
58
+ }
59
+ if (Array.isArray(value) && node.xml().wrapped !== true) {
60
+ const items = node.items();
61
+ return value.map((item) => this.element(items.xml().name ?? name, item, items)).join('');
62
+ }
63
+ return this.element(name, value, node);
64
+ }
65
+ }
66
+ /** Declared properties first, in the order of the schema; the others after, in the order of the value. */
67
+ function orderOf(declared, key) {
68
+ const index = [...declared.keys()].indexOf(key);
69
+ return index === -1 ? declared.size : index;
70
+ }
71
+ //# sourceMappingURL=xml-element-writer.js.map
@@ -0,0 +1 @@
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O,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACxD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAE3B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;CACF;AAED,0GAA0G;AAC1G,SAAS,OAAO,CAAC,QAAyC,EAAE,GAAW;IACrE,MAAM,KAAK,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEhD,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** One element of a parsed XML document: its qualified name, its attributes, its child elements and its text. */
2
+ export interface XmlElement {
3
+ readonly name: string;
4
+ readonly attributes: Readonly<Record<string, string>>;
5
+ readonly children: readonly XmlElement[];
6
+ /** The text directly inside the element, character data and CDATA sections joined, entities decoded. */
7
+ readonly text: string;
8
+ }
9
+ //# sourceMappingURL=xml-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-element.d.ts","sourceRoot":"","sources":["../../../src/representation/xml/xml-element.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;IACzC,wGAAwG;IACxG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=xml-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-element.js","sourceRoot":"","sources":["../../../src/representation/xml/xml-element.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { XmlElement } from './xml-element.js';
2
+ /**
3
+ * Parses the subset of XML 1.0 a request body needs: elements, attributes, character data,
4
+ * CDATA sections, comments, processing instructions, the five predefined entities and character
5
+ * references. A document type declaration is refused, and with it every external or recursive
6
+ * entity: nothing in a body can make the parser read a file or expand without end.
7
+ */
8
+ export declare class XmlParser {
9
+ private readonly source;
10
+ private position;
11
+ constructor(source: string);
12
+ static parse(source: string): XmlElement;
13
+ private document;
14
+ /** Spaces, comments and processing instructions, where the document allows them. */
15
+ private miscellany;
16
+ private element;
17
+ private attributes;
18
+ private content;
19
+ private contentPart;
20
+ private characterData;
21
+ private name;
22
+ private expect;
23
+ /** Moves past the next `end`, and answers where `end` starts. */
24
+ private skipPast;
25
+ private match;
26
+ }
27
+ //# sourceMappingURL=xml-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml-parser.d.ts","sourceRoot":"","sources":["../../../src/representation/xml/xml-parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAanD;;;;;GAKG;AACH,qBAAa,SAAS;IAGR,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,QAAQ,CAAK;IAErB,YAA6B,MAAM,EAAE,MAAM,EAAI;IAE/C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAEvC;IAED,OAAO,CAAC,QAAQ;IAkBhB,oFAAoF;IACpF,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,OAAO;IA2Bf,OAAO,CAAC,UAAU;IAgClB,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,IAAI;IAUZ,OAAO,CAAC,MAAM;IAQd,iEAAiE;IACjE,OAAO,CAAC,QAAQ;IAYhB,OAAO,CAAC,KAAK;CAad"}