@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
@@ -2,17 +2,22 @@ import { Readable } from 'node:stream';
2
2
  import { assertCachedRoutes } from '../pipeline/assert-cached-routes.js';
3
3
  import { executeRoute } from '../pipeline/execute-route.js';
4
4
  import { serializeBody } from '../pipeline/serialize-body.js';
5
+ import { assertServed } from '../representation/assert-served.js';
5
6
  import { assertUniqueRoutes } from '../route/assert-unique-routes.js';
6
7
  /**
7
8
  * Registers the routes on a Fastify 5 instance. Validation stays in the shared pipeline. The
8
9
  * routes that read their body as a stream (an upload, a raw body) are registered in a context of
9
- * their own, where no body parser runs: the rest of the instance keeps its parsers.
10
+ * their own, where no body parser runs: the rest of the instance keeps its parsers. A media type
11
+ * a route consumes (`consumes`) is given a parser that hands the body over as text.
10
12
  */
11
13
  export function mountFastify(instance, routes, options = {}) {
12
14
  assertUniqueRoutes(routes);
15
+ assertServed(routes, options.representations);
13
16
  assertCachedRoutes(routes, options);
14
17
  const streamed = routes.filter(readsItsStream);
15
- register(instance, routes.filter((route) => !readsItsStream(route)), options);
18
+ const parsed = routes.filter((route) => !readsItsStream(route));
19
+ readAsText(instance, parsed);
20
+ register(instance, parsed, options);
16
21
  if (streamed.length > 0) {
17
22
  void instance.register(async (unparsed) => {
18
23
  unparsed.removeAllContentTypeParsers();
@@ -26,6 +31,14 @@ export function mountFastify(instance, routes, options = {}) {
26
31
  function readsItsStream(route) {
27
32
  return route.upload !== undefined || route.rawBody === true;
28
33
  }
34
+ function readAsText(instance, routes) {
35
+ const consumed = new Set(routes.flatMap((route) => route.consumes ?? []));
36
+ for (const mediaType of [...consumed].filter((type) => !instance.hasContentTypeParser(type))) {
37
+ instance.addContentTypeParser(mediaType, { parseAs: 'string' }, (_request, body, done) => {
38
+ done(null, body);
39
+ });
40
+ }
41
+ }
29
42
  function register(instance, routes, options) {
30
43
  for (const route of routes) {
31
44
  instance.route({
@@ -35,10 +48,16 @@ function register(instance, routes, options) {
35
48
  const { params, query, headers, body } = request;
36
49
  const raw = { params, query, headers, body, raw: request, stream: request.raw };
37
50
  const result = await executeRoute(route, raw, options);
38
- const sent = result.body instanceof Readable ? result.body : serializeBody(result);
39
- return reply.code(result.status).headers(result.headers).send(sent);
51
+ return reply.code(result.status).headers(result.headers).send(sentOf(result));
40
52
  },
41
53
  });
42
54
  }
43
55
  }
56
+ /** A file as it is, a streamed list as a stream of its chunks, anything else serialized. */
57
+ function sentOf(result) {
58
+ if (result.body instanceof Readable) {
59
+ return result.body;
60
+ }
61
+ return result.stream === undefined ? serializeBody(result) : Readable.from(result.stream);
62
+ }
44
63
  //# sourceMappingURL=mount-fastify.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mount-fastify.js","sourceRoot":"","sources":["../../src/fastify/mount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CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YAChF,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,4FAA4F;AAC5F,SAAS,MAAM,CAAC,MAAqB;IACnC,IAAI,MAAM,CAAC,IAAI,YAAY,QAAQ,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { FieldJudge } from './field-judge.js';
2
+ import type { FieldTree } from './field-tree.js';
3
+ /**
4
+ * Refuses a body that sets a field the actor may not set, with 403 and the path of the field:
5
+ * what a form shows read-only is held by the server too. A field left out is not judged.
6
+ */
7
+ export declare function assertWritable(body: unknown, tree: FieldTree, judge: FieldJudge): Promise<void>;
8
+ //# sourceMappingURL=assert-writable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-writable.d.ts","sourceRoot":"","sources":["../../src/field-access/assert-writable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQjD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAErG"}
@@ -0,0 +1,29 @@
1
+ import { ForbiddenError } from '../error/forbidden-error.js';
2
+ import { isRecord } from '../support/is-record.js';
3
+ /**
4
+ * Refuses a body that sets a field the actor may not set, with 403 and the path of the field:
5
+ * what a form shows read-only is held by the server too. A field left out is not judged.
6
+ */
7
+ export async function assertWritable(body, tree, judge) {
8
+ await writable({ value: body, path: 'body' }, tree, judge);
9
+ }
10
+ async function writable({ value, path }, tree, judge) {
11
+ if (tree.isEmpty()) {
12
+ return;
13
+ }
14
+ if (Array.isArray(value)) {
15
+ const items = tree.below('*');
16
+ await Promise.all(value.map((item, index) => writable({ value: item, path: `${path}.${String(index)}` }, items, judge)));
17
+ return;
18
+ }
19
+ if (!isRecord(value)) {
20
+ return;
21
+ }
22
+ for (const [name, rule] of tree.own()) {
23
+ if (value[name] !== undefined && !(await judge.writes(rule, value))) {
24
+ throw new ForbiddenError(`The field ${path}.${name} may not be set by this caller.`);
25
+ }
26
+ }
27
+ await Promise.all(tree.branches().map((name) => writable({ value: value[name], path: `${path}.${name}` }, tree.below(name), judge)));
28
+ }
29
+ //# sourceMappingURL=assert-writable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-writable.js","sourceRoot":"","sources":["../../src/field-access/assert-writable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAUnD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAa,EAAE,IAAe,EAAE,KAAiB;IACpF,MAAM,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAW,EAAE,IAAe,EAAE,KAAiB;IAClF,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,CAAC,IAAa,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAC/G,CAAC;QAEF,OAAO;IACT,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO;IACT,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;YACpE,MAAM,IAAI,cAAc,CAAC,aAAa,IAAI,IAAI,IAAI,iCAAiC,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAClH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { FieldRule } from './field-rule.js';
2
+ /** One restricted field, by its path from the root of a body: `*` stands for every item of a list. */
3
+ export interface FieldAccessEntry {
4
+ readonly path: readonly string[];
5
+ readonly rule: FieldRule;
6
+ }
7
+ //# sourceMappingURL=field-access-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-access-entry.d.ts","sourceRoot":"","sources":["../../src/field-access/field-access-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,sGAAsG;AACtG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-access-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-access-entry.js","sourceRoot":"","sources":["../../src/field-access/field-access-entry.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { type Schema } from '@ddd-ts-kit/validation';
2
+ import type { FieldAccessEntry } from './field-access-entry.js';
3
+ /**
4
+ * The restricted fields of a schema: those `withFieldAccess` marked, those of the items of a page
5
+ * or a stream, and those of the schema it was built from (`sharedSchema` over a marked schema).
6
+ */
7
+ export declare const fieldAccess: {
8
+ of(schema: Schema<unknown> | undefined): readonly FieldAccessEntry[];
9
+ /** What a schema built from another one (a page, a stream) carries of it, under `prefix`. */
10
+ carry(from: Schema<unknown>, to: Schema<unknown>, prefix: readonly string[]): void;
11
+ mark(schema: Schema<unknown>, entries: readonly FieldAccessEntry[]): void;
12
+ };
13
+ //# sourceMappingURL=field-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-access.d.ts","sourceRoot":"","sources":["../../src/field-access/field-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAYhE;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB,EAAE,SAAS,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,GAAG,SAAS,gBAAgB,EAAE;IAQpE,6FAA6F;IAC7F,KAAK,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,SAAS,MAAM,EAAE,GAAG,IAAI;IAWlF,IAAI,SAAS,MAAM,CAAC,OAAO,CAAC,WAAW,SAAS,gBAAgB,EAAE,GAAG,IAAI;CAG1E,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { schemaBehind } from '@ddd-ts-kit/validation';
2
+ /*
3
+ * One registry per process, whatever the number of copies of this package it loaded, as the
4
+ * presentation registry: the global symbol registry is what they all share.
5
+ */
6
+ const REGISTRY = Symbol.for('@ddd-ts-kit/http/field-access/v1');
7
+ /**
8
+ * The restricted fields of a schema: those `withFieldAccess` marked, those of the items of a page
9
+ * or a stream, and those of the schema it was built from (`sharedSchema` over a marked schema).
10
+ */
11
+ export const fieldAccess = {
12
+ of(schema) {
13
+ if (schema === undefined) {
14
+ return [];
15
+ }
16
+ return registry().fields.get(schema) ?? fieldAccess.of(schemaBehind.of(schema));
17
+ },
18
+ /** What a schema built from another one (a page, a stream) carries of it, under `prefix`. */
19
+ carry(from, to, prefix) {
20
+ const entries = fieldAccess.of(from);
21
+ if (entries.length > 0) {
22
+ registry().fields.set(to, entries.map(({ path, rule }) => ({ path: [...prefix, ...path], rule })));
23
+ }
24
+ },
25
+ mark(schema, entries) {
26
+ registry().fields.set(schema, entries);
27
+ },
28
+ };
29
+ function registry() {
30
+ const existing = Reflect.get(globalThis, REGISTRY);
31
+ if (isRegistry(existing)) {
32
+ return existing;
33
+ }
34
+ const created = { fields: new WeakMap() };
35
+ Reflect.set(globalThis, REGISTRY, created);
36
+ return created;
37
+ }
38
+ function isRegistry(value) {
39
+ return typeof value === 'object' && value !== null && 'fields' in value && value.fields instanceof WeakMap;
40
+ }
41
+ //# sourceMappingURL=field-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-access.js","sourceRoot":"","sources":["../../src/field-access/field-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,wBAAwB,CAAC;AAOnE;;;GAGG;AACH,MAAM,Q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,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE3C,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,YAAY,OAAO,CAAC;AAC7G,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { Actor, Clock } from '@ddd-ts-kit/kernel';
2
+ import type { FieldDecider } from './field-decider.js';
3
+ interface Decided {
4
+ readonly allowed: boolean;
5
+ }
6
+ /** What the decider asks of the `Access` port of `@ddd-ts-kit/auth`, which fits as it is. */
7
+ export interface FieldAccessDecisions {
8
+ decide(actor: Actor, permission: {
9
+ readonly id: string;
10
+ }, subject: unknown): Promise<Decided>;
11
+ /** Preferred when present (the `PolicyAccess` of `@ddd-ts-kit/auth` has it): it takes the context, and records only an act. */
12
+ decideOn?(question: {
13
+ readonly actor: Actor;
14
+ readonly permission: {
15
+ readonly id: string;
16
+ };
17
+ readonly subject?: unknown;
18
+ readonly context?: Readonly<Record<string, unknown>>;
19
+ readonly recorded?: boolean;
20
+ }): Promise<Decided>;
21
+ }
22
+ export interface FieldDeciderOptions {
23
+ /** The `Access` of the application: a permission of a field is decided as the permission of a use case, its policies and its authorizer. */
24
+ readonly access: FieldAccessDecisions;
25
+ /** What a policy of a field is told the time with. */
26
+ readonly clock: Clock;
27
+ }
28
+ /**
29
+ * The decider of the field rules from the `Access` of the application:
30
+ * `fieldAccess: fieldDeciderOf({ access: app.resolve(Access), clock })`. A permission is asked
31
+ * of `access.decideOn` (else `decide`), which runs the policies of the permission then the
32
+ * authorizer; the decision is recorded only for an act (a field set, a form opened), never for a
33
+ * field shown or left out. A policy named on the field is asked directly.
34
+ */
35
+ export declare function fieldDeciderOf({ access, clock }: FieldDeciderOptions): FieldDecider;
36
+ export {};
37
+ //# sourceMappingURL=field-dec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
2
+ * The decider of the field rules from the `Access` of the application:
3
+ * `fieldAccess: fieldDeciderOf({ access: app.resolve(Access), clock })`. A permission is asked
4
+ * of `access.decideOn` (else `decide`), which runs the policies of the permission then the
5
+ * authorizer; the decision is recorded only for an act (a field set, a form opened), never for a
6
+ * field shown or left out. A policy named on the field is asked directly.
7
+ */
8
+ export function fieldDeciderOf({ access, clock }) {
9
+ return async (question) => {
10
+ const { actor, requirement, subject } = question;
11
+ if ('permission' in requirement) {
12
+ return (await decisionOf(access, question, requirement.permission)).allowed;
13
+ }
14
+ return policyAllows(requirement.policy, { actor, subject, now: clock.now() });
15
+ };
16
+ }
17
+ function decisionOf(access, { actor, subject, context, recorded }, permission) {
18
+ if (access.decideOn === undefined) {
19
+ return access.decide(actor, permission, subject);
20
+ }
21
+ return access.decideOn({ actor, permission, subject, recorded, ...(context === undefined ? {} : { context }) });
22
+ }
23
+ function policyAllows(policy, { actor, subject, now }) {
24
+ if (policy.appliesTo !== undefined && !policy.appliesTo(subject)) {
25
+ return false;
26
+ }
27
+ const verdict = policy.allows(actor, subject, { now });
28
+ return typeof verdict === 'boolean' ? verdict : verdict.allowed;
29
+ }
30
+ //# sourceMappingURL=field-decider-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-decider-of.js","sourceRoot":"","sources":["../../src/field-access/field-decider-of.ts"],"names":[],"mappings":"AA8BA;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,MAAM,EAAE,KAAK,EAAuB;IACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,EAAE;QACxB,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAEjD,IAAI,YAAY,IAAI,WAAW,EAAE,CAAC;YAChC,OAAO,CAAC,MAAM,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9E,CAAC;QAED,OAAO,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAChF,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,MAA4B,EAC5B,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAiB,EACpD,UAAmC;IAEnC,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AAClH,CAAC;AAQD,SAAS,YAAY,CAAC,MAAmB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAU;IACxE,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QACjE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAEvD,OAAO,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AAClE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FieldQuestion } from './field-question.js';
2
+ /** Whether the actor meets the requirement of a field, about this element: given to the adapters as `fieldAccess`. */
3
+ export type FieldDecider = (question: FieldQuestion) => Promise<boolean>;
4
+ //# sourceMappingURL=field-decider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-decider.d.ts","sourceRoot":"","sources":["../../src/field-access/field-decider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,sHAAsH;AACtH,MAAM,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-decider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-decider.js","sourceRoot":"","sources":["../../src/field-access/field-decider.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import type { Actor } from '@ddd-ts-kit/kernel';
2
+ import type { FieldDecider } from './field-decider.js';
3
+ import type { FieldRule } from './field-rule.js';
4
+ /**
5
+ * The decisions about the fields of one request, for one actor. A requirement about no element
6
+ * is asked once; one about an element is asked once per element among the last ones met, so a
7
+ * page of a hundred rows of one calendar asks once, and a long export with an element per row
8
+ * asks once per row while holding a bounded memory. Without a decider, a restricted field is
9
+ * refused to everybody: nothing is shown by omission. A judge that `records` keeps its decisions
10
+ * in the audit trail: the one that checks a body, whose refusal is an act refused.
11
+ */
12
+ export declare class FieldJudge {
13
+ private readonly actor;
14
+ private readonly decide;
15
+ private readonly records;
16
+ /**
17
+ * The elements a judge remembers a decision about, for each requirement: enough for a page of
18
+ * rows that share a few elements, bounded so that a streamed export with an element per row
19
+ * holds no more than this many, whatever its length.
20
+ */
21
+ static readonly rememberedSubjects = 256;
22
+ private readonly withoutSubject;
23
+ private readonly bySubject;
24
+ constructor(actor: Actor, decide: FieldDecider | undefined, records?: boolean);
25
+ /** Whether the actor may see the field held by `container`. */
26
+ reads(rule: FieldRule, container: unknown): Promise<boolean>;
27
+ /** Whether the actor may set the field held by `container`: see it, and meet its write requirement. */
28
+ writes(rule: FieldRule, container: unknown): Promise<boolean>;
29
+ private allows;
30
+ private aboutElement;
31
+ private asked;
32
+ }
33
+ //# sourceMappingURL=field-judge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-judge.d.ts","sourceRoot":"","sources":["../../src/field-access/field-judge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;;;GAOG;AACH,qBAAa,UAAU;IAanB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAd1B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,OAAO;IAEzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiD;IAEhF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+D;IAEzF,YACmB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,OAAO,UAAQ,EAC9B;IAEJ,+DAA+D;IACzD,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEjE;IAED,uGAAuG;IACjG,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAMlE;IAED,OAAO,CAAC,MAAM;IAYd,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,KAAK;CAOd"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The decisions about the fields of one request, for one actor. A requirement about no element
3
+ * is asked once; one about an element is asked once per element among the last ones met, so a
4
+ * page of a hundred rows of one calendar asks once, and a long export with an element per row
5
+ * asks once per row while holding a bounded memory. Without a decider, a restricted field is
6
+ * refused to everybody: nothing is shown by omission. A judge that `records` keeps its decisions
7
+ * in the audit trail: the one that checks a body, whose refusal is an act refused.
8
+ */
9
+ export class FieldJudge {
10
+ actor;
11
+ decide;
12
+ records;
13
+ /**
14
+ * The elements a judge remembers a decision about, for each requirement: enough for a page of
15
+ * rows that share a few elements, bounded so that a streamed export with an element per row
16
+ * holds no more than this many, whatever its length.
17
+ */
18
+ static rememberedSubjects = 256;
19
+ withoutSubject = new Map();
20
+ bySubject = new Map();
21
+ constructor(actor, decide, records = false) {
22
+ this.actor = actor;
23
+ this.decide = decide;
24
+ this.records = records;
25
+ }
26
+ /** Whether the actor may see the field held by `container`. */
27
+ async reads(rule, container) {
28
+ return rule.read === undefined || (await this.allows(rule.read, rule.subject?.(container)));
29
+ }
30
+ /** Whether the actor may set the field held by `container`: see it, and meet its write requirement. */
31
+ async writes(rule, container) {
32
+ if (!(await this.reads(rule, container))) {
33
+ return false;
34
+ }
35
+ return rule.write === undefined || (await this.allows(rule.write, rule.subject?.(container)));
36
+ }
37
+ allows(requirement, subject) {
38
+ if (subject === undefined) {
39
+ const known = this.withoutSubject.get(requirement) ?? this.asked(requirement, subject);
40
+ this.withoutSubject.set(requirement, known);
41
+ return known;
42
+ }
43
+ return this.aboutElement(requirement, subject);
44
+ }
45
+ aboutElement(requirement, subject) {
46
+ const remembered = this.bySubject.get(requirement) ?? new Map();
47
+ const key = keyOf(subject);
48
+ const known = remembered.get(key);
49
+ if (known !== undefined) {
50
+ return known;
51
+ }
52
+ const decided = this.asked(requirement, subject);
53
+ forgetOldest(remembered);
54
+ remembered.set(key, decided);
55
+ this.bySubject.set(requirement, remembered);
56
+ return decided;
57
+ }
58
+ asked(requirement, subject) {
59
+ if (this.decide === undefined) {
60
+ return Promise.resolve(false);
61
+ }
62
+ return this.decide({ actor: this.actor, requirement, subject, recorded: this.records });
63
+ }
64
+ }
65
+ /** Makes room for one more element: the one met first is forgotten, and asked again if it comes back. */
66
+ function forgetOldest(remembered) {
67
+ if (remembered.size < FieldJudge.rememberedSubjects) {
68
+ return;
69
+ }
70
+ const [oldest] = remembered.keys();
71
+ remembered.delete(oldest);
72
+ }
73
+ /** A reference `{ type, id }` built anew for every row names the same element: it is keyed by what it says. */
74
+ function keyOf(subject) {
75
+ if (typeof subject !== 'object' || subject === null || !('type' in subject) || !('id' in subject)) {
76
+ return subject;
77
+ }
78
+ const { type, id } = subject;
79
+ return typeof type === 'string' && typeof id === 'string' ? `${type}:${id}` : subject;
80
+ }
81
+ //# sourceMappingURL=field-judge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-judge.js","sourceRoot":"","sources":["../../src/field-access/field-judge.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IAaF,KAAK;IACL,MAAM;IACN,OAAO;IAd1B;;;;OAIG;IACH,MAAM,CAAU,kBAAkB,GAAG,GAAG,CAAC;IAExB,cAAc,GAAG,IAAI,GAAG,EAAsC,CAAC;IAE/D,SAAS,GAAG,IAAI,GAAG,EAAoD,CAAC;IAEzF,YACmB,KAAY,EACZ,MAAgC,EAChC,OAAO,GAAG,KAAK;qBAFf,KAAK;sBACL,MAAM;uBACN,OAAO;IACvB,CAAC;IAEJ,+DAA+D;IAC/D,KAAK,CAAC,KAAK,CAAC,IAAe,EAAE,SAAkB;QAC7C,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,uGAAuG;IACvG,KAAK,CAAC,MAAM,CAAC,IAAe,EAAE,SAAkB;QAC9C,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;YACzC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC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,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC1F,CAAC;CACF;AAED,yGAAyG;AACzG,SAAS,YAAY,CAAC,UAA0C;IAC9D,IAAI,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC;QACpD,OAAO;IACT,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;IAEnC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,+GAA+G;AAC/G,SAAS,KAAK,CAAC,OAAgB;IAC7B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE,CAAC;QAClG,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC;IAE7B,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACxF,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Actor } from '@ddd-ts-kit/kernel';
2
+ /**
3
+ * A rule about one element that decides a field, as `definePolicy` of `@ddd-ts-kit/auth` writes
4
+ * one: a policy of that package is one, with no import of it here.
5
+ */
6
+ export interface FieldPolicy {
7
+ readonly name: string;
8
+ appliesTo?(subject: unknown): boolean;
9
+ allows(actor: Actor, subject: unknown, context: {
10
+ readonly now: Date;
11
+ }): boolean | {
12
+ readonly allowed: boolean;
13
+ };
14
+ }
15
+ //# sourceMappingURL=field-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-policy.d.ts","sourceRoot":"","sources":["../../src/field-access/field-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAEtC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,GAAG;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAClH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-policy.js","sourceRoot":"","sources":["../../src/field-access/field-policy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import type { Actor } from '@ddd-ts-kit/kernel';
2
+ import type { FieldRequirement } from './field-requirement.js';
3
+ /** What a decider is asked: whether the actor meets a requirement of a field, or of the form of a route. */
4
+ export interface FieldQuestion {
5
+ readonly actor: Actor;
6
+ readonly requirement: FieldRequirement;
7
+ /** The element the requirement is asked about; `undefined` for none. */
8
+ readonly subject: unknown;
9
+ /** Facts beside the actor and the element, as `@Requires(..., { context })` gives a use case. */
10
+ readonly context?: Readonly<Record<string, unknown>>;
11
+ /**
12
+ * Whether the decision is an act to keep in the audit trail: a field set in a body, the form of
13
+ * a use case opened. A field shown or left out of an answer or a form only shapes it, and the
14
+ * decision about it is not recorded.
15
+ */
16
+ readonly recorded: boolean;
17
+ }
18
+ //# sourceMappingURL=field-question.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-question.d.ts","sourceRoot":"","sources":["../../src/field-access/field-question.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,4GAA4G;AAC5G,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,iGAAiG;IACjG,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-question.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-question.js","sourceRoot":"","sources":["../../src/field-access/field-question.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import type { FieldPolicy } from './field-policy.js';
2
+ /**
3
+ * What an actor needs to see or set a field: a permission, decided by the `Access` of the
4
+ * application as for a use case (a `Permission` of `@ddd-ts-kit/auth` is one), or a policy.
5
+ */
6
+ export type FieldRequirement = {
7
+ readonly permission: {
8
+ readonly id: string;
9
+ };
10
+ } | {
11
+ readonly policy: FieldPolicy;
12
+ };
13
+ //# sourceMappingURL=field-requirement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-requirement.d.ts","sourceRoot":"","sources":["../../src/field-access/field-requirement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-requirement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-requirement.js","sourceRoot":"","sources":["../../src/field-access/field-requirement.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { FieldRequirement } from './field-requirement.js';
2
+ /** Who may see and who may set one field of a schema. */
3
+ export interface FieldRule<Container = unknown> {
4
+ /** Who sees the field in an answer, in every representation; absent, whoever may call the route. */
5
+ readonly read?: FieldRequirement;
6
+ /** Who may set it in a request body, and finds it editable in a form; absent, whoever may see it. */
7
+ readonly write?: FieldRequirement;
8
+ /** The element the requirement is asked about, from the object that holds the field; absent, none. */
9
+ subject?(container: Container): unknown;
10
+ }
11
+ //# sourceMappingURL=field-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-rule.d.ts","sourceRoot":"","sources":["../../src/field-access/field-rule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,yDAAyD;AACzD,MAAM,WAAW,SAAS,CAAC,SAAS,GAAG,OAAO;IAC5C,oGAAoG;IACpG,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACjC,qGAAqG;IACrG,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAElC,sGAAsG;IACtG,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;CACzC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-rule.js","sourceRoot":"","sources":["../../src/field-access/field-rule.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { FieldRule } from './field-rule.js';
2
+ /** The rules of the fields of one object schema, by property name. */
3
+ export type FieldRules<T> = {
4
+ readonly [Name in keyof T & string]?: FieldRule<T>;
5
+ };
6
+ //# sourceMappingURL=field-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-rules.d.ts","sourceRoot":"","sources":["../../src/field-access/field-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,sEAAsE;AACtE,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,IAAI,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-rules.js","sourceRoot":"","sources":["../../src/field-access/field-rules.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { FieldAccessEntry } from './field-access-entry.js';
2
+ import type { FieldRule } from './field-rule.js';
3
+ /** The restricted fields seen from one object: those it holds itself, and those further down, by the name that leads to them. */
4
+ export declare class FieldTree {
5
+ private readonly entries;
6
+ private constructor();
7
+ static of(entries: readonly FieldAccessEntry[]): FieldTree;
8
+ isEmpty(): boolean;
9
+ /** The rules of the fields of this very object, by name. */
10
+ own(): readonly (readonly [string, FieldRule])[];
11
+ /** The names that lead to restricted fields further down. */
12
+ branches(): readonly string[];
13
+ /** The tree seen from the value under `name`, `*` for an item of a list. */
14
+ below(name: string): FieldTree;
15
+ }
16
+ //# sourceMappingURL=field-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-tree.d.ts","sourceRoot":"","sources":["../../src/field-access/field-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,iIAAiI;AACjI,qBAAa,SAAS;IACA,OAAO,CAAC,QAAQ,CAAC,OAAO;IAA5C,OAAO,eAAsE;IAE7E,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAAG,SAAS,CAEzD;IAED,OAAO,IAAI,OAAO,CAEjB;IAED,4DAA4D;IAC5D,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,CAI/C;IAED,6DAA6D;IAC7D,QAAQ,IAAI,SAAS,MAAM,EAAE,CAI5B;IAED,4EAA4E;IAC5E,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAM7B;CACF"}
@@ -0,0 +1,28 @@
1
+ /** The restricted fields seen from one object: those it holds itself, and those further down, by the name that leads to them. */
2
+ export class FieldTree {
3
+ entries;
4
+ constructor(entries) {
5
+ this.entries = entries;
6
+ }
7
+ static of(entries) {
8
+ return new FieldTree(entries);
9
+ }
10
+ isEmpty() {
11
+ return this.entries.length === 0;
12
+ }
13
+ /** The rules of the fields of this very object, by name. */
14
+ own() {
15
+ return this.entries.flatMap(({ path, rule }) => path.length === 1 && path[0] !== undefined ? [[path[0], rule]] : []);
16
+ }
17
+ /** The names that lead to restricted fields further down. */
18
+ branches() {
19
+ return [
20
+ ...new Set(this.entries.flatMap(({ path }) => (path.length > 1 && path[0] !== undefined ? [path[0]] : []))),
21
+ ];
22
+ }
23
+ /** The tree seen from the value under `name`, `*` for an item of a list. */
24
+ below(name) {
25
+ return new FieldTree(this.entries.flatMap(({ path, rule }) => path.length > 1 && path[0] === name ? [{ path: path.slice(1), rule }] : []));
26
+ }
27
+ }
28
+ //# sourceMappingURL=field-tree.js.map