@ddd-ts-kit/http 0.13.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 (441) hide show
  1. package/README.md +319 -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 +41 -0
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +19 -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/package.json +4 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-tree.js","sourceRoot":"","sources":["../../src/field-access/field-tree.ts"],"names":[],"mappings":"AAGA,iIAAiI;AACjI,MAAM,OAAO,SAAS;IACiB,OAAO;IAA5C,YAAqC,OAAoC;uBAApC,OAAO;IAAgC,CAAC;IAE7E,MAAM,CAAC,EAAE,CAAC,OAAoC;QAC5C,OAAO,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,4DAA4D;IAC5D,GAAG;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAC7C,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CACpE,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,QAAQ;QACN,OAAO;YACL,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC5G,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CACtC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAC3E,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import type { FieldJudge } from './field-judge.js';
2
+ import type { FieldTree } from './field-tree.js';
3
+ /**
4
+ * The body as the actor may see it: every restricted field the actor may not read is left out,
5
+ * in a copy, whatever the representation it is written in next. A streamed list is filtered
6
+ * item by item as it is read.
7
+ */
8
+ export declare function visibleBody(body: unknown, tree: FieldTree, judge: FieldJudge): Promise<unknown>;
9
+ //# sourceMappingURL=visible-body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visible-body.d.ts","sourceRoot":"","sources":["../../src/field-access/visible-body.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAErG"}
@@ -0,0 +1,42 @@
1
+ import { isAsyncIterable } from '../support/is-async-iterable.js';
2
+ import { isRecord } from '../support/is-record.js';
3
+ const EVERY_ITEM = '*';
4
+ /**
5
+ * The body as the actor may see it: every restricted field the actor may not read is left out,
6
+ * in a copy, whatever the representation it is written in next. A streamed list is filtered
7
+ * item by item as it is read.
8
+ */
9
+ export async function visibleBody(body, tree, judge) {
10
+ return isAsyncIterable(body) ? visibleItems(body, tree.below(EVERY_ITEM), judge) : visible(body, tree, judge);
11
+ }
12
+ async function* visibleItems(items, tree, judge) {
13
+ for await (const item of items) {
14
+ yield await visible(item, tree, judge);
15
+ }
16
+ }
17
+ /** A value that holds no restricted field, a class instance included, is left as it is: only the branches that lead to one are copied. */
18
+ async function visible(value, tree, judge) {
19
+ if (tree.isEmpty()) {
20
+ return value;
21
+ }
22
+ if (Array.isArray(value)) {
23
+ const items = tree.below(EVERY_ITEM);
24
+ return Promise.all(value.map((item) => visible(item, items, judge)));
25
+ }
26
+ if (!isRecord(value) || value instanceof Date) {
27
+ return value;
28
+ }
29
+ const hidden = new Set();
30
+ for (const [name, rule] of tree.own()) {
31
+ if (name in value && !(await judge.reads(rule, value))) {
32
+ hidden.add(name);
33
+ }
34
+ }
35
+ const entries = Object.entries(value).filter(([name]) => !hidden.has(name));
36
+ const branches = new Set(tree.branches());
37
+ return Object.fromEntries(await Promise.all(entries.map(async ([name, field]) => [
38
+ name,
39
+ branches.has(name) ? await visible(field, tree.below(name), judge) : field,
40
+ ])));
41
+ }
42
+ //# sourceMappingURL=visible-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visible-body.js","sourceRoot":"","sources":["../../src/field-access/visible-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAInD,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAa,EAAE,IAAe,EAAE,KAAiB;IACjF,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAChH,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,YAAY,CAC1B,KAA6B,EAC7B,IAAe,EACf,KAAiB;IAEjB,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC/B,MAAM,MAAM,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED,0IAA0I;AAC1I,KAAK,UAAU,OAAO,CAAC,KAAc,EAAE,IAAe,EAAE,KAAiB;IACvE,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAErC,OAAO,OAAO,CAAC,GAAG,CAA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 import { type Schema } from '@ddd-ts-kit/validation';
2
+ import type { FieldRules } from './field-rules.js';
3
+ /**
4
+ * The same schema, with fields reserved to some callers:
5
+ *
6
+ * const answer = withFieldAccess(classSchema(GetAppointmentAnswer), {
7
+ * internalNote: { read: { permission: notes.read }, write: { policy: notesOfTheirOwnPatients } },
8
+ * });
9
+ *
10
+ * In an answer, a field the actor may not read is left out, in every representation; in a request
11
+ * body, a field the actor may not set is refused with 403; in a form, the first is absent and the
12
+ * second read-only. The contract marks each one with `x-field-access` and no longer lists it as
13
+ * required, since a caller may not receive it; for a shared schema, in the definition it refers
14
+ * to. Validation is the schema's own, unchanged.
15
+ */
16
+ export declare function withFieldAccess<T>(schema: Schema<T>, rules: FieldRules<T>): Schema<T>;
17
+ //# sourceMappingURL=with-field-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-field-access.d.ts","sourceRoot":"","sources":["../../src/field-access/with-field-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAMpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAarF"}
@@ -0,0 +1,63 @@
1
+ import { sharedNameOf } from '@ddd-ts-kit/validation';
2
+ import { isRecord } from '../support/is-record.js';
3
+ import { fieldAccess } from './field-access.js';
4
+ /**
5
+ * The same schema, with fields reserved to some callers:
6
+ *
7
+ * const answer = withFieldAccess(classSchema(GetAppointmentAnswer), {
8
+ * internalNote: { read: { permission: notes.read }, write: { policy: notesOfTheirOwnPatients } },
9
+ * });
10
+ *
11
+ * In an answer, a field the actor may not read is left out, in every representation; in a request
12
+ * body, a field the actor may not set is refused with 403; in a form, the first is absent and the
13
+ * second read-only. The contract marks each one with `x-field-access` and no longer lists it as
14
+ * required, since a caller may not receive it; for a shared schema, in the definition it refers
15
+ * to. Validation is the schema's own, unchanged.
16
+ */
17
+ export function withFieldAccess(schema, rules) {
18
+ const entries = Object.entries(rules).flatMap(([name, rule]) => rule === undefined ? [] : [{ path: [name], rule }]);
19
+ const restricted = {
20
+ parse: (input) => schema.parse(input),
21
+ toJsonSchema: () => annotatedDefinition(schema.toJsonSchema(), entries),
22
+ };
23
+ fieldAccess.mark(restricted, entries);
24
+ return restricted;
25
+ }
26
+ /** A shared schema is a reference to its own definition: the fields are marked there. */
27
+ function annotatedDefinition(schema, entries) {
28
+ const shared = sharedNameOf(schema);
29
+ const definitions = schema['$defs'];
30
+ const definition = shared === undefined || !isRecord(definitions) ? undefined : definitions[shared];
31
+ if (shared === undefined || !isRecord(definitions) || !isRecord(definition)) {
32
+ return annotated(schema, entries);
33
+ }
34
+ return { ...schema, $defs: { ...definitions, [shared]: annotated(definition, entries) } };
35
+ }
36
+ function annotated(schema, entries) {
37
+ const { properties, required } = schema;
38
+ const names = new Set(entries.flatMap(({ path }) => path));
39
+ if (!isRecord(properties)) {
40
+ return schema;
41
+ }
42
+ const marked = Object.fromEntries(Object.entries(properties).map(([name, property]) => {
43
+ const rule = entries.find(({ path }) => path[0] === name)?.rule;
44
+ return [
45
+ name,
46
+ rule === undefined || !isRecord(property) ? property : { ...property, 'x-field-access': described(rule) },
47
+ ];
48
+ }));
49
+ const stillRequired = Array.isArray(required)
50
+ ? required.filter((name) => typeof name !== 'string' || !names.has(name))
51
+ : undefined;
52
+ return { ...schema, properties: marked, ...(stillRequired === undefined ? {} : { required: stillRequired }) };
53
+ }
54
+ function described(rule) {
55
+ return {
56
+ ...(rule.read === undefined ? {} : { read: requirementOf(rule.read) }),
57
+ ...(rule.write === undefined ? {} : { write: requirementOf(rule.write) }),
58
+ };
59
+ }
60
+ function requirementOf(requirement) {
61
+ return 'permission' in requirement ? { permission: requirement.permission.id } : { policy: requirement.policy.name };
62
+ }
63
+ //# sourceMappingURL=with-field-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-field-access.js","sourceRoot":"","sources":["../../src/field-access/with-field-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgC,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAI,MAAiB,EAAE,KAAoB;IACxE,MAAM,OAAO,GAAuB,MAAM,CAAC,OAAO,CAA2B,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAC3G,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CACnD,CAAC;IAEF,MAAM,UAAU,GAAc;QAC5B,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QACrC,YAAY,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,OAAO,CAAC;KACxE,CAAC;IAEF,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAEtC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,yFAAyF;AACzF,SAAS,mBAAmB,CAAC,MAAkB,EAAE,OAAoC;IACnF,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,UAAU,GAAG,MAAM,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,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E;SAC1G,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC3C,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzE,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;AAChH,CAAC;AAED,SAAS,SAAS,CAAC,IAAe;IAChC,OAAO;QACL,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtE,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,WAA6B;IAClD,OAAO,YAAY,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AACvH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { SchemaNode } from '../schema/schema-node.js';
2
+ import type { FieldLookup } from './field-lookup.js';
3
+ import type { FormHints } from './form-hints.js';
4
+ interface Hinted {
5
+ readonly operation: string;
6
+ readonly body: SchemaNode;
7
+ readonly hints: FormHints;
8
+ }
9
+ /** Every field a hint names is a field of the body, every lookup a `GET` route: a typo stops the build, not a user. */
10
+ export declare function assertHints({ operation, body, hints }: Hinted, lookups: ReadonlyMap<string, FieldLookup>): void;
11
+ export {};
12
+ //# sourceMappingURL=assert-hints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-hints.d.ts","sourceRoot":"","sources":["../../src/forms/assert-hints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,UAAU,MAAM;IACd,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED,uHAAuH;AACvH,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI,CAwB/G"}
@@ -0,0 +1,32 @@
1
+ import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
2
+ const MAX_DEPTH = 8;
3
+ /** Every field a hint names is a field of the body, every lookup a `GET` route: a typo stops the build, not a user. */
4
+ export function assertHints({ operation, body, hints }, lookups) {
5
+ const known = new Set(pathsOf(body, '', 0));
6
+ const named = [
7
+ ...Object.keys(hints.fields ?? {}),
8
+ ...(hints.groups ?? []).flatMap(fieldsOfGroup),
9
+ ...Object.values(hints.fields ?? {}).flatMap((hint) => [hint?.visibleWhen?.field, hint?.requiredWhen?.field]),
10
+ ].filter((name) => name !== undefined);
11
+ const unknown = named.find((name) => !known.has(name));
12
+ if (unknown !== undefined) {
13
+ throw new DeclarationError(`The form of "${operation}" names "${unknown}", which its request body does not hold.`);
14
+ }
15
+ const lookup = Object.values(hints.fields ?? {}).find((hint) => hint?.lookup !== undefined && !lookups.has(hint.lookup));
16
+ if (lookup?.lookup !== undefined) {
17
+ throw new DeclarationError(`The form of "${operation}" looks its options up from "${lookup.lookup}", which is no GET route.`);
18
+ }
19
+ }
20
+ /** The fields of the body and of its nested objects, dotted; a schema that holds itself is followed a few levels only. */
21
+ function pathsOf(node, prefix, depth) {
22
+ if (depth > MAX_DEPTH) {
23
+ return [];
24
+ }
25
+ return node
26
+ .properties()
27
+ .flatMap(([name, child]) => [`${prefix}${name}`, ...pathsOf(child, `${prefix}${name}.`, depth + 1)]);
28
+ }
29
+ function fieldsOfGroup(group) {
30
+ return [...group.fields, ...(group.groups ?? []).flatMap(fieldsOfGroup)];
31
+ }
32
+ //# sourceMappingURL=assert-hints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-hints.js","sourceRoot":"","sources":["../../src/forms/assert-hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,MAAM,SAAS,GAAG,CAAC,CAAC;AAQpB,uHAAuH;AACvH,MAAM,UAAU,WAAW,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAU,EAAE,OAAyC;IACvG,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAE5C,MAAM,KAAK,GAAG;QACZ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QAClC,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;QAC9C,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE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,CAAC,CAAC,CAAC,CAAC,CAAC;AACzG,CAAC;AAED,SAAS,aAAa,CAAC,KAAoB;IACzC,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Actor } from '@ddd-ts-kit/kernel';
2
+ import type { FieldDecider } from '../field-access/field-decider.js';
3
+ import type { FormRequirement } from './form-requirement.js';
4
+ /** Who asks for a form, how their rights are decided, and the values they ask it with. */
5
+ export interface FormAsker {
6
+ readonly actor: Actor;
7
+ readonly decide: FieldDecider | undefined;
8
+ readonly values: Readonly<Record<string, unknown>>;
9
+ }
10
+ /**
11
+ * Refuses with 403 the caller who may not run the use case a form describes, decided as the use
12
+ * case decides it and recorded as an act: they learn nothing of its fields. Without a decider,
13
+ * nobody is given a form that declares a requirement.
14
+ */
15
+ export declare function assertOpens(requires: FormRequirement | undefined, asker: FormAsker): Promise<void>;
16
+ //# sourceMappingURL=assert-opens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-opens.d.ts","sourceRoot":"","sources":["../../src/forms/assert-opens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,0FAA0F;AAC1F,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBxG"}
@@ -0,0 +1,24 @@
1
+ import { ForbiddenError } from '../error/forbidden-error.js';
2
+ /**
3
+ * Refuses with 403 the caller who may not run the use case a form describes, decided as the use
4
+ * case decides it and recorded as an act: they learn nothing of its fields. Without a decider,
5
+ * nobody is given a form that declares a requirement.
6
+ */
7
+ export async function assertOpens(requires, asker) {
8
+ if (requires === undefined) {
9
+ return;
10
+ }
11
+ const { actor, decide, values } = asker;
12
+ const context = requires.context?.(values, actor);
13
+ const question = {
14
+ actor,
15
+ requirement: requires,
16
+ subject: requires.subject?.(values),
17
+ recorded: true,
18
+ ...(context === undefined ? {} : { context }),
19
+ };
20
+ if (decide === undefined || !(await decide(question))) {
21
+ throw new ForbiddenError('The caller may not run the use case this form describes.');
22
+ }
23
+ }
24
+ //# sourceMappingURL=assert-opens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-opens.js","sourceRoot":"","sources":["../../src/forms/assert-opens.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAW7D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAqC,EAAE,KAAgB;IACvF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAElD,MAAM,QAAQ,GAAG;QACf,KAAK;QACL,WAAW,EAAE,QAAQ;QACrB,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC;QACnC,QAAQ,EAAE,IAAI;QACd,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;KAC9C,CAAC;IAEF,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,cAAc,CAAC,0DAA0D,CAAC,CAAC;IACvF,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { SchemaNode } from '../schema/schema-node.js';
2
+ import type { FieldBlock } from './field-block.js';
3
+ export declare function constraintsOf(node: SchemaNode): Pick<FieldBlock, 'constraints'>;
4
+ //# sourceMappingURL=constraints-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constraints-of.d.ts","sourceRoot":"","sources":["../../src/forms/constraints-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiBnD,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAU/E"}
@@ -0,0 +1,24 @@
1
+ /** The keywords of JSON Schema a form mirrors so that the user is told early; the server checks them again. */
2
+ const CONSTRAINTS = [
3
+ 'minLength',
4
+ 'maxLength',
5
+ 'minimum',
6
+ 'maximum',
7
+ 'exclusiveMinimum',
8
+ 'exclusiveMaximum',
9
+ 'multipleOf',
10
+ 'pattern',
11
+ 'format',
12
+ 'minItems',
13
+ 'maxItems',
14
+ ];
15
+ export function constraintsOf(node) {
16
+ const found = CONSTRAINTS.flatMap((keyword) => {
17
+ const value = node.node[keyword];
18
+ return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'
19
+ ? [[keyword, value]]
20
+ : [];
21
+ });
22
+ return found.length === 0 ? {} : { constraints: Object.fromEntries(found) };
23
+ }
24
+ //# sourceMappingURL=constraints-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constraints-of.js","sourceRoot":"","sources":["../../src/forms/constraints-of.ts"],"names":[],"mappings":"AAGA,+GAA+G;AAC/G,MAAM,WAAW,GAAG;IAClB,WAAW;IACX,WAAW;IACX,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,kBAAkB;IAClB,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,UAAU;IACV,UAAU;CACX,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,IAAgB;IAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,EAAyC,EAAE;QACnF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;YACzF,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { FieldHint } from './field-hint.js';
2
+ import type { FormGroupHint } from './form-group-hint.js';
3
+ import type { FormHints } from './form-hints.js';
4
+ import type { FormRequirement } from './form-requirement.js';
5
+ /** The hints of a form whose field names the compiler checks against the body of the route. */
6
+ export interface TypedFormHints<Body> {
7
+ readonly groups?: readonly (FormGroupHint & {
8
+ readonly fields: readonly (keyof Body & string)[];
9
+ })[];
10
+ readonly fields?: {
11
+ readonly [Name in keyof Body & string]?: FieldHint;
12
+ };
13
+ readonly requires?: FormRequirement<Partial<Body>>;
14
+ }
15
+ /**
16
+ * The hints of the form of a route, next to the schemas of its controller:
17
+ * `const form = defineForm<Infer<typeof body>>({ fields: { reason: { widget: 'textarea' } } })`.
18
+ */
19
+ export declare function defineForm<Body>(hints: TypedFormHints<Body>): FormHints;
20
+ //# sourceMappingURL=define-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-form.d.ts","sourceRoot":"","sources":["../../src/forms/define-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,+FAA+F;AAC/F,MAAM,WAAW,cAAc,CAAC,IAAI;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,aAAa,GAAG;QAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAA;KAAE,CAAC,EAAE,CAAC;IACrG,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,EAAE,IAAI,IAAI,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,EAAE,SAAS;KAAE,CAAC;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,SAAS,CAEvE"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The hints of the form of a route, next to the schemas of its controller:
3
+ * `const form = defineForm<Infer<typeof body>>({ fields: { reason: { widget: 'textarea' } } })`.
4
+ */
5
+ export function defineForm(hints) {
6
+ return hints;
7
+ }
8
+ //# sourceMappingURL=define-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-form.js","sourceRoot":"","sources":["../../src/forms/define-form.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAO,KAA2B;IAC1D,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { FormCondition } from './form-condition.js';
2
+ import type { FieldLookup } from './field-lookup.js';
3
+ import type { Widget } from './widget.js';
4
+ /** One field of a form described by the server, as the caller may use it: `Block` is what a nested object holds, a `FormBlock`. */
5
+ export interface FieldBlock<Block = unknown> {
6
+ readonly type: 'field';
7
+ /** The path of the field in the body, dotted for a field of a nested object: `patient.phone`. */
8
+ readonly name: string;
9
+ /** A translation key: `<operationId>.<field>`. */
10
+ readonly label: string;
11
+ readonly widget: Widget;
12
+ readonly required: boolean;
13
+ /** Present when the caller may see the field and not set it. */
14
+ readonly readOnly?: true;
15
+ /** What the schema says of the value: `minLength`, `maxLength`, `minimum`, `maximum`, `pattern`, `format`, `multipleOf`. */
16
+ readonly constraints?: Readonly<Record<string, string | number | boolean>>;
17
+ /** The values it may take, with the translation key of each: `<operationId>.<field>.<value>`. */
18
+ readonly options?: readonly {
19
+ readonly value: string | number | boolean;
20
+ readonly label: string;
21
+ }[];
22
+ /** Whether several options may be chosen: a list of values from a closed vocabulary. */
23
+ readonly multiple?: true;
24
+ /** The route whose items are the options. */
25
+ readonly lookup?: FieldLookup;
26
+ readonly visibleWhen?: FormCondition;
27
+ readonly requiredWhen?: FormCondition;
28
+ /** The value the request gave for it, when it gave one. */
29
+ readonly value?: unknown;
30
+ /** The fields of a nested object, for the widget `group`. */
31
+ readonly blocks?: readonly Block[];
32
+ }
33
+ //# sourceMappingURL=field-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-block.d.ts","sourceRoot":"","sources":["../../src/forms/field-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,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
+ {"version":3,"file":"field-block.js","sourceRoot":"","sources":["../../src/forms/field-block.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import type { FormCondition } from './form-condition.js';
2
+ import type { Widget } from './widget.js';
3
+ /** What the request schema cannot say about one field of a form: how it is entered and when it applies. */
4
+ export interface FieldHint {
5
+ /** Left out, taken from the schema: `select` for an enumeration, `datetime` for a `date-time`, `checkbox` for a boolean. */
6
+ readonly widget?: Widget;
7
+ /** The values a field may take when the schema does not list them, a closed vocabulary: `Object.values(AppointmentKind)`. */
8
+ readonly options?: readonly (string | number | boolean)[];
9
+ /** The operation id of a `GET` route whose items are the options: the form names its path. */
10
+ readonly lookup?: string;
11
+ /** Shown only when the condition holds. */
12
+ readonly visibleWhen?: FormCondition;
13
+ /** Required only when the condition holds; the server still decides with its own rules. */
14
+ readonly requiredWhen?: FormCondition;
15
+ /** A translation key of its own; left out, `<operationId>.<field>`. */
16
+ readonly label?: string;
17
+ }
18
+ //# sourceMappingURL=field-hint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-hint.d.ts","sourceRoot":"","sources":["../../src/forms/field-hint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,2GAA2G;AAC3G,MAAM,WAAW,SAAS;IACxB,4HAA4H;IAC5H,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,6HAA6H;IAC7H,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC1D,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;IACrC,2FAA2F;IAC3F,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC;IACtC,uEAAuE;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-hint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-hint.js","sourceRoot":"","sources":["../../src/forms/field-hint.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ /** The route whose items are the options of a field: a front end calls it as the user types or opens the list. */
2
+ export interface FieldLookup {
3
+ readonly operation: string;
4
+ readonly method: 'GET';
5
+ readonly path: string;
6
+ }
7
+ //# sourceMappingURL=field-lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-lookup.d.ts","sourceRoot":"","sources":["../../src/forms/field-lookup.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-lookup.js","sourceRoot":"","sources":["../../src/forms/field-lookup.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { FieldBlock } from './field-block.js';
2
+ import type { GroupBlock } from './group-block.js';
3
+ /** A block of the neutral tree of a form: a group or a field. */
4
+ export type FormBlock = GroupBlock<FormBlock> | FieldBlock<FormBlock>;
5
+ //# sourceMappingURL=form-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-block.d.ts","sourceRoot":"","sources":["../../src/forms/form-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,iEAAiE;AACjE,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=form-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-block.js","sourceRoot":"","sources":["../../src/forms/form-block.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /** A simple condition on another field of the same form: equal to one value, or to one of several. */
2
+ export type FormCondition = {
3
+ readonly field: string;
4
+ readonly equals: string | number | boolean;
5
+ } | {
6
+ readonly field: string;
7
+ readonly in: readonly (string | number | boolean)[];
8
+ };
9
+ //# sourceMappingURL=form-condition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-condition.d.ts","sourceRoot":"","sources":["../../src/forms/form-condition.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=form-condition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-condition.js","sourceRoot":"","sources":["../../src/forms/form-condition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import type { FieldJudge } from '../field-access/field-judge.js';
2
+ import type { FieldTree } from '../field-access/field-tree.js';
3
+ import type { SchemaNode } from '../schema/schema-node.js';
4
+ import type { FormBlock } from './form-block.js';
5
+ import type { FormHints } from './form-hints.js';
6
+ import type { FieldLookup } from './field-lookup.js';
7
+ /** What a form is described from: the request schema, its hints, the caller and the values the request gave. */
8
+ export interface FormSource {
9
+ readonly operation: string;
10
+ readonly body: SchemaNode;
11
+ readonly fields: FieldTree;
12
+ readonly hints: FormHints;
13
+ readonly lookups: ReadonlyMap<string, FieldLookup>;
14
+ }
15
+ /**
16
+ * The blocks of a form, for one caller: a field the caller may not see is absent, one they may
17
+ * not set is read-only, constraints and options come from the schema, layout and conditions
18
+ * from the hints. It describes; the route that receives the body still validates it, and its
19
+ * use case still enforces its rules.
20
+ */
21
+ export declare class FormDescriber {
22
+ private readonly source;
23
+ private readonly judge;
24
+ constructor(source: FormSource, judge: FieldJudge);
25
+ blocks(values: Readonly<Record<string, unknown>>): Promise<FormBlock[]>;
26
+ private grouped;
27
+ /** Every field of one object the caller may see, by name, in the order of the schema. */
28
+ private fieldsOf;
29
+ private field;
30
+ /** What depends on the schema of the field and its hint: widget, constraints, options, conditions, nested fields. */
31
+ private shapeOf;
32
+ private choicesOf;
33
+ private hintOf;
34
+ }
35
+ //# sourceMappingURL=form-describer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-describer.d.ts","sourceRoot":"","sources":["../../src/forms/form-describer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAK3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD,gHAAgH;AAChH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,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