@toa.io/extensions.exposition 1.0.0-alpha.283 → 1.0.0-alpha.284

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 (568) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/components/exposition.octets/types/index.d.ts +1 -1
  3. package/components/identity.bans/operations/transit.js +1 -1
  4. package/components/identity.bans/tsconfig.json +1 -1
  5. package/components/identity.bans/tsconfig.tsbuildinfo +1 -1
  6. package/components/identity.bans/types/index.d.ts +1 -1
  7. package/components/identity.basic/operations/add.js +1 -1
  8. package/components/identity.basic/operations/authenticate.js +1 -1
  9. package/components/identity.basic/operations/check.js +1 -1
  10. package/components/identity.basic/operations/delete.js +1 -1
  11. package/components/identity.basic/operations/incept.js +18 -2
  12. package/components/identity.basic/operations/info.js +1 -1
  13. package/components/identity.basic/operations/lib/credentials.js +1 -1
  14. package/components/identity.basic/operations/transit.js +1 -1
  15. package/components/identity.basic/source/incept.ts +29 -1
  16. package/components/identity.basic/tsconfig.json +1 -1
  17. package/components/identity.basic/tsconfig.tsbuildinfo +1 -1
  18. package/components/identity.basic/types/index.d.ts +3 -2
  19. package/components/identity.clients/operations/describe.js +1 -1
  20. package/components/identity.clients/operations/lib/Context.js +1 -1
  21. package/components/identity.clients/operations/lib/Entity.js +1 -1
  22. package/components/identity.clients/operations/lib/canonical.js +1 -1
  23. package/components/identity.clients/operations/lib/cimd.js +1 -1
  24. package/components/identity.clients/operations/lib/errors.js +1 -1
  25. package/components/identity.clients/operations/lib/index.js +1 -1
  26. package/components/identity.clients/operations/lib/redirect.js +1 -1
  27. package/components/identity.clients/operations/register.js +1 -1
  28. package/components/identity.clients/tsconfig.json +1 -1
  29. package/components/identity.clients/tsconfig.tsbuildinfo +1 -1
  30. package/components/identity.clients/types/index.d.ts +1 -1
  31. package/components/identity.credentials/operations/list.js +1 -1
  32. package/components/identity.credentials/tsconfig.json +4 -2
  33. package/components/identity.credentials/tsconfig.tsbuildinfo +1 -1
  34. package/components/identity.credentials/types/index.d.ts +1 -1
  35. package/components/identity.federation/operations/authenticate.js +7 -3
  36. package/components/identity.federation/operations/create.js +1 -1
  37. package/components/identity.federation/operations/decode.js +1 -1
  38. package/components/identity.federation/operations/delete.js +1 -1
  39. package/components/identity.federation/operations/incept.js +6 -2
  40. package/components/identity.federation/operations/lib/Configuration.js +1 -1
  41. package/components/identity.federation/operations/lib/Ctx.js +1 -1
  42. package/components/identity.federation/operations/lib/Payload.js +1 -1
  43. package/components/identity.federation/operations/lib/decode.js +1 -1
  44. package/components/identity.federation/operations/lib/discovery.js +1 -1
  45. package/components/identity.federation/operations/lib/errors.js +1 -1
  46. package/components/identity.federation/operations/lib/exchange.js +1 -1
  47. package/components/identity.federation/operations/lib/index.js +2 -1
  48. package/components/identity.federation/operations/lib/jose.js +1 -1
  49. package/components/identity.federation/operations/lib/principal.js +14 -0
  50. package/components/identity.federation/operations/lib/resolve.js +1 -1
  51. package/components/identity.federation/operations/list.js +1 -1
  52. package/components/identity.federation/operations/types/Scheme.js +1 -1
  53. package/components/identity.federation/operations/types/configuration.js +1 -1
  54. package/components/identity.federation/operations/types/context.js +1 -1
  55. package/components/identity.federation/operations/types/entity.js +1 -1
  56. package/components/identity.federation/operations/types/index.js +1 -1
  57. package/components/identity.federation/source/authenticate.ts +8 -2
  58. package/components/identity.federation/source/incept.ts +7 -1
  59. package/components/identity.federation/source/lib/index.ts +1 -0
  60. package/components/identity.federation/source/lib/principal.ts +17 -0
  61. package/components/identity.federation/source/types/context.ts +3 -0
  62. package/components/identity.federation/tsconfig.json +4 -2
  63. package/components/identity.federation/tsconfig.tsbuildinfo +1 -1
  64. package/components/identity.federation/types/index.d.ts +1 -1
  65. package/components/identity.grants/operations/authorize.js +1 -1
  66. package/components/identity.grants/operations/exchange.js +1 -1
  67. package/components/identity.grants/operations/lib/code.js +1 -1
  68. package/components/identity.grants/operations/lib/identify.js +1 -1
  69. package/components/identity.grants/operations/lib/index.js +1 -1
  70. package/components/identity.grants/operations/list.js +1 -1
  71. package/components/identity.grants/operations/revoke.js +1 -1
  72. package/components/identity.grants/tsconfig.json +1 -1
  73. package/components/identity.grants/tsconfig.tsbuildinfo +1 -1
  74. package/components/identity.grants/types/index.d.ts +1 -1
  75. package/components/identity.keys/operations/create.js +1 -1
  76. package/components/identity.keys/operations/disable.js +1 -1
  77. package/components/identity.keys/operations/revoke.js +1 -1
  78. package/components/identity.keys/tsconfig.json +1 -1
  79. package/components/identity.keys/tsconfig.tsbuildinfo +1 -1
  80. package/components/identity.keys/types/index.d.ts +1 -1
  81. package/components/identity.otp/operations/authenticate.js +1 -1
  82. package/components/identity.otp/operations/issue.js +1 -1
  83. package/components/identity.otp/operations/lib/Context.js +1 -1
  84. package/components/identity.otp/operations/lib/Entity.js +1 -1
  85. package/components/identity.otp/operations/lib/index.js +1 -1
  86. package/components/identity.otp/tsconfig.json +1 -1
  87. package/components/identity.otp/tsconfig.tsbuildinfo +1 -1
  88. package/components/identity.otp/types/index.d.ts +1 -1
  89. package/components/identity.passkeys/operations/authenticate.js +1 -1
  90. package/components/identity.passkeys/operations/challenge.js +1 -1
  91. package/components/identity.passkeys/operations/create.js +1 -1
  92. package/components/identity.passkeys/operations/delete.js +1 -1
  93. package/components/identity.passkeys/operations/lib/const.js +1 -1
  94. package/components/identity.passkeys/operations/list.js +1 -1
  95. package/components/identity.passkeys/operations/types/Configuration.js +1 -1
  96. package/components/identity.passkeys/operations/types/Context.js +1 -1
  97. package/components/identity.passkeys/operations/types/Passkey.js +1 -1
  98. package/components/identity.passkeys/operations/types/index.js +1 -1
  99. package/components/identity.passkeys/operations/use.js +1 -1
  100. package/components/identity.passkeys/tsconfig.json +1 -1
  101. package/components/identity.passkeys/tsconfig.tsbuildinfo +1 -1
  102. package/components/identity.passkeys/types/index.d.ts +1 -1
  103. package/components/identity.roles/operations/grant.js +1 -1
  104. package/components/identity.roles/operations/lib/Entity.js +1 -1
  105. package/components/identity.roles/operations/list.js +1 -1
  106. package/components/identity.roles/operations/principal.js +29 -5
  107. package/components/identity.roles/source/principal.ts +33 -5
  108. package/components/identity.roles/tsconfig.json +1 -1
  109. package/components/identity.roles/tsconfig.tsbuildinfo +1 -1
  110. package/components/identity.roles/types/index.d.ts +1 -1
  111. package/components/identity.tokens/operations/authenticate.js +1 -1
  112. package/components/identity.tokens/operations/decrypt.js +1 -1
  113. package/components/identity.tokens/operations/encrypt.js +1 -1
  114. package/components/identity.tokens/operations/issue.js +1 -1
  115. package/components/identity.tokens/operations/lib/form.js +1 -1
  116. package/components/identity.tokens/operations/lib/index.js +1 -1
  117. package/components/identity.tokens/operations/lib/jose.js +1 -1
  118. package/components/identity.tokens/operations/lib/key.js +1 -1
  119. package/components/identity.tokens/operations/lib/pad.js +1 -1
  120. package/components/identity.tokens/operations/revoke.js +1 -1
  121. package/components/identity.tokens/tsconfig.json +1 -1
  122. package/components/identity.tokens/tsconfig.tsbuildinfo +1 -1
  123. package/components/identity.tokens/types/index.d.ts +1 -1
  124. package/documentation/access.md +13 -0
  125. package/documentation/components.md +3 -0
  126. package/documentation/introspection.md +13 -5
  127. package/documentation/io.md +6 -0
  128. package/documentation/map.md +8 -0
  129. package/documentation/mcp.md +180 -0
  130. package/documentation/oauth.md +8 -7
  131. package/documentation/rpc.md +140 -0
  132. package/documentation/tree.md +3 -0
  133. package/features/identity.basic.feature +44 -0
  134. package/features/identity.federation.feature +2 -5
  135. package/features/introspection.feature +333 -0
  136. package/features/mcp.feature +687 -0
  137. package/features/oauth.discovery.feature +10 -11
  138. package/features/oauth.grants.feature +22 -9
  139. package/features/octets.cloudinary.feature +1 -0
  140. package/features/rpc.feature +429 -0
  141. package/features/steps/Cloudinary.ts +13 -0
  142. package/features/steps/Components.ts +0 -4
  143. package/features/steps/Gateway.ts +18 -2
  144. package/features/steps/Parameters.ts +18 -7
  145. package/features/steps/Realtime.ts +3 -0
  146. package/features/steps/components/echo/manifest.toa.yaml +1 -0
  147. package/features/steps/components/pots/manifest.toa.yaml +2 -0
  148. package/package.json +3 -3
  149. package/readme.md +3 -0
  150. package/schemas/annotation.cos.yaml +33 -0
  151. package/schemas/call.cos.yaml +18 -0
  152. package/source/Annotation.ts +31 -0
  153. package/source/Directive.test.ts +15 -15
  154. package/source/Directive.ts +77 -9
  155. package/source/Endpoint.test.ts +67 -0
  156. package/source/Endpoint.ts +31 -11
  157. package/source/Factory.ts +5 -1
  158. package/source/Gateway.ts +73 -11
  159. package/source/HTTP/Context.ts +7 -0
  160. package/source/HTTP/Server.ts +7 -1
  161. package/source/HTTP/exceptions.ts +2 -2
  162. package/source/HTTP/messages.ts +10 -1
  163. package/source/Introspection.ts +102 -0
  164. package/source/MCP/Server.ts +275 -0
  165. package/source/MCP/discover.ts +52 -0
  166. package/source/MCP/errors.ts +81 -0
  167. package/source/MCP/index.ts +1 -0
  168. package/source/MCP/schema.test.ts +85 -0
  169. package/source/MCP/schema.ts +87 -0
  170. package/source/MCP/tools.ts +156 -0
  171. package/source/MCP/types.ts +81 -0
  172. package/source/Query.ts +48 -8
  173. package/source/RPC/Context.ts +78 -0
  174. package/source/RPC/Dispatcher.ts +130 -0
  175. package/source/RPC/errors.test.ts +52 -0
  176. package/source/RPC/errors.ts +83 -0
  177. package/source/RPC/index.ts +1 -0
  178. package/source/RPC/names.test.ts +122 -0
  179. package/source/RPC/names.ts +182 -0
  180. package/source/RPC/types.ts +34 -0
  181. package/source/RTD/Directives.ts +52 -2
  182. package/source/RTD/Endpoint.ts +2 -1
  183. package/source/RTD/Method.ts +14 -11
  184. package/source/RTD/Node.ts +38 -7
  185. package/source/RTD/Route.ts +30 -3
  186. package/source/RTD/Tree.ts +37 -1
  187. package/source/RTD/expiration.test.ts +1 -1
  188. package/source/RTD/walk.test.ts +110 -0
  189. package/source/const.ts +15 -0
  190. package/source/deployment.ts +8 -1
  191. package/source/directives/auth/Anonymous.test.ts +38 -0
  192. package/source/directives/auth/Anonymous.ts +12 -0
  193. package/source/directives/auth/Anyone.ts +4 -0
  194. package/source/directives/auth/Authorization.ts +62 -3
  195. package/source/directives/auth/Delegate.test.ts +36 -0
  196. package/source/directives/auth/Delegate.ts +14 -0
  197. package/source/directives/auth/Echo.ts +5 -0
  198. package/source/directives/auth/Incept.ts +2 -1
  199. package/source/directives/auth/Role.ts +13 -0
  200. package/source/directives/auth/Rule.ts +29 -0
  201. package/source/directives/auth/Scheme.ts +5 -0
  202. package/source/directives/auth/types.ts +21 -0
  203. package/source/directives/cache/Cache.ts +1 -1
  204. package/source/directives/dev/Development.ts +1 -1
  205. package/source/directives/flow/Flow.ts +1 -1
  206. package/source/directives/index.ts +3 -1
  207. package/source/directives/io/Directive.ts +1 -1
  208. package/source/directives/io/IO.ts +32 -3
  209. package/source/directives/io/Input.ts +3 -2
  210. package/source/directives/io/Output.ts +6 -3
  211. package/source/directives/io/Status.test.ts +2 -2
  212. package/source/directives/io/Status.ts +1 -1
  213. package/source/directives/io/Throttle.ts +1 -1
  214. package/source/directives/io/lib/throttle/Quotas.ts +2 -2
  215. package/source/directives/map/Headers.ts +11 -0
  216. package/source/directives/map/Map.ts +10 -1
  217. package/source/directives/map/Mapping.ts +23 -0
  218. package/source/directives/map/Segments.ts +12 -0
  219. package/source/directives/mcp/MCP.ts +33 -0
  220. package/source/directives/mcp/Tool.test.ts +66 -0
  221. package/source/directives/mcp/Tool.ts +28 -0
  222. package/source/directives/mcp/index.ts +6 -0
  223. package/source/directives/oauth/Discovery.ts +10 -16
  224. package/source/directives/octets/Octets.ts +1 -1
  225. package/source/directives/require/Directive.ts +1 -1
  226. package/source/directives/require/Headers.ts +1 -1
  227. package/source/directives/require/Require.ts +2 -2
  228. package/source/schemas.ts +2 -0
  229. package/transpiled/Annotation.d.ts +24 -0
  230. package/transpiled/Directive.d.ts +18 -1
  231. package/transpiled/Directive.js +50 -6
  232. package/transpiled/Directive.js.map +1 -1
  233. package/transpiled/Endpoint.d.ts +9 -0
  234. package/transpiled/Endpoint.js +27 -11
  235. package/transpiled/Endpoint.js.map +1 -1
  236. package/transpiled/Factory.js +5 -1
  237. package/transpiled/Factory.js.map +1 -1
  238. package/transpiled/Gateway.d.ts +19 -2
  239. package/transpiled/Gateway.js +51 -9
  240. package/transpiled/Gateway.js.map +1 -1
  241. package/transpiled/HTTP/Context.d.ts +6 -0
  242. package/transpiled/HTTP/Context.js +6 -0
  243. package/transpiled/HTTP/Context.js.map +1 -1
  244. package/transpiled/HTTP/Server.d.ts +5 -1
  245. package/transpiled/HTTP/exceptions.d.ts +1 -1
  246. package/transpiled/HTTP/exceptions.js +2 -2
  247. package/transpiled/HTTP/exceptions.js.map +1 -1
  248. package/transpiled/HTTP/messages.d.ts +6 -0
  249. package/transpiled/HTTP/messages.js +9 -1
  250. package/transpiled/HTTP/messages.js.map +1 -1
  251. package/transpiled/Introspection.d.ts +40 -0
  252. package/transpiled/Introspection.js +50 -1
  253. package/transpiled/Introspection.js.map +1 -1
  254. package/transpiled/MCP/Server.d.ts +41 -0
  255. package/transpiled/MCP/Server.js +180 -0
  256. package/transpiled/MCP/Server.js.map +1 -0
  257. package/transpiled/MCP/discover.d.ts +13 -0
  258. package/transpiled/MCP/discover.js +29 -0
  259. package/transpiled/MCP/discover.js.map +1 -0
  260. package/transpiled/MCP/errors.d.ts +24 -0
  261. package/transpiled/MCP/errors.js +67 -0
  262. package/transpiled/MCP/errors.js.map +1 -0
  263. package/transpiled/MCP/index.d.ts +1 -0
  264. package/transpiled/MCP/index.js +2 -0
  265. package/transpiled/MCP/index.js.map +1 -0
  266. package/transpiled/MCP/schema.d.ts +18 -0
  267. package/transpiled/MCP/schema.js +64 -0
  268. package/transpiled/MCP/schema.js.map +1 -0
  269. package/transpiled/MCP/tools.d.ts +31 -0
  270. package/transpiled/MCP/tools.js +121 -0
  271. package/transpiled/MCP/tools.js.map +1 -0
  272. package/transpiled/MCP/types.d.ts +64 -0
  273. package/transpiled/MCP/types.js +13 -0
  274. package/transpiled/MCP/types.js.map +1 -0
  275. package/transpiled/Query.d.ts +7 -0
  276. package/transpiled/Query.js +38 -7
  277. package/transpiled/Query.js.map +1 -1
  278. package/transpiled/RPC/Context.d.ts +11 -0
  279. package/transpiled/RPC/Context.js +63 -0
  280. package/transpiled/RPC/Context.js.map +1 -0
  281. package/transpiled/RPC/Dispatcher.d.ts +19 -0
  282. package/transpiled/RPC/Dispatcher.js +100 -0
  283. package/transpiled/RPC/Dispatcher.js.map +1 -0
  284. package/transpiled/RPC/errors.d.ts +18 -0
  285. package/transpiled/RPC/errors.js +67 -0
  286. package/transpiled/RPC/errors.js.map +1 -0
  287. package/transpiled/RPC/index.d.ts +1 -0
  288. package/transpiled/RPC/index.js +2 -0
  289. package/transpiled/RPC/index.js.map +1 -0
  290. package/transpiled/RPC/names.d.ts +30 -0
  291. package/transpiled/RPC/names.js +121 -0
  292. package/transpiled/RPC/names.js.map +1 -0
  293. package/transpiled/RPC/types.d.ts +27 -0
  294. package/transpiled/RPC/types.js +8 -0
  295. package/transpiled/RPC/types.js.map +1 -0
  296. package/transpiled/RTD/Directives.d.ts +41 -2
  297. package/transpiled/RTD/Endpoint.d.ts +2 -1
  298. package/transpiled/RTD/Method.d.ts +8 -3
  299. package/transpiled/RTD/Method.js +12 -10
  300. package/transpiled/RTD/Method.js.map +1 -1
  301. package/transpiled/RTD/Node.d.ts +20 -2
  302. package/transpiled/RTD/Node.js +22 -4
  303. package/transpiled/RTD/Node.js.map +1 -1
  304. package/transpiled/RTD/Route.d.ts +2 -1
  305. package/transpiled/RTD/Route.js +27 -2
  306. package/transpiled/RTD/Route.js.map +1 -1
  307. package/transpiled/RTD/Tree.d.ts +3 -1
  308. package/transpiled/RTD/Tree.js +26 -0
  309. package/transpiled/RTD/Tree.js.map +1 -1
  310. package/transpiled/const.d.ts +12 -0
  311. package/transpiled/const.js +12 -0
  312. package/transpiled/const.js.map +1 -1
  313. package/transpiled/deployment.js +4 -0
  314. package/transpiled/deployment.js.map +1 -1
  315. package/transpiled/directives/auth/Anonymous.d.ts +6 -0
  316. package/transpiled/directives/auth/Anonymous.js +10 -0
  317. package/transpiled/directives/auth/Anonymous.js.map +1 -1
  318. package/transpiled/directives/auth/Anyone.d.ts +1 -0
  319. package/transpiled/directives/auth/Anyone.js +3 -0
  320. package/transpiled/directives/auth/Anyone.js.map +1 -1
  321. package/transpiled/directives/auth/Authorization.d.ts +27 -1
  322. package/transpiled/directives/auth/Authorization.js +49 -1
  323. package/transpiled/directives/auth/Authorization.js.map +1 -1
  324. package/transpiled/directives/auth/Delegate.d.ts +5 -0
  325. package/transpiled/directives/auth/Delegate.js +10 -0
  326. package/transpiled/directives/auth/Delegate.js.map +1 -1
  327. package/transpiled/directives/auth/Echo.d.ts +2 -0
  328. package/transpiled/directives/auth/Echo.js +4 -0
  329. package/transpiled/directives/auth/Echo.js.map +1 -1
  330. package/transpiled/directives/auth/Incept.js +2 -1
  331. package/transpiled/directives/auth/Incept.js.map +1 -1
  332. package/transpiled/directives/auth/Role.d.ts +2 -0
  333. package/transpiled/directives/auth/Role.js +9 -0
  334. package/transpiled/directives/auth/Role.js.map +1 -1
  335. package/transpiled/directives/auth/Rule.d.ts +5 -0
  336. package/transpiled/directives/auth/Rule.js +20 -0
  337. package/transpiled/directives/auth/Rule.js.map +1 -1
  338. package/transpiled/directives/auth/Scheme.d.ts +2 -0
  339. package/transpiled/directives/auth/Scheme.js +4 -0
  340. package/transpiled/directives/auth/Scheme.js.map +1 -1
  341. package/transpiled/directives/auth/types.d.ts +16 -0
  342. package/transpiled/directives/cache/Cache.d.ts +1 -1
  343. package/transpiled/directives/cache/Cache.js +1 -1
  344. package/transpiled/directives/cache/Cache.js.map +1 -1
  345. package/transpiled/directives/dev/Development.d.ts +1 -1
  346. package/transpiled/directives/dev/Development.js +1 -1
  347. package/transpiled/directives/dev/Development.js.map +1 -1
  348. package/transpiled/directives/flow/Flow.d.ts +1 -1
  349. package/transpiled/directives/flow/Flow.js +1 -1
  350. package/transpiled/directives/flow/Flow.js.map +1 -1
  351. package/transpiled/directives/index.js +2 -1
  352. package/transpiled/directives/index.js.map +1 -1
  353. package/transpiled/directives/io/Directive.d.ts +1 -1
  354. package/transpiled/directives/io/IO.d.ts +7 -1
  355. package/transpiled/directives/io/IO.js +23 -3
  356. package/transpiled/directives/io/IO.js.map +1 -1
  357. package/transpiled/directives/io/Input.d.ts +3 -2
  358. package/transpiled/directives/io/Input.js +2 -1
  359. package/transpiled/directives/io/Input.js.map +1 -1
  360. package/transpiled/directives/io/Output.d.ts +5 -3
  361. package/transpiled/directives/io/Output.js +4 -2
  362. package/transpiled/directives/io/Output.js.map +1 -1
  363. package/transpiled/directives/io/Status.d.ts +1 -1
  364. package/transpiled/directives/io/Status.js +1 -1
  365. package/transpiled/directives/io/Status.js.map +1 -1
  366. package/transpiled/directives/io/Throttle.d.ts +1 -1
  367. package/transpiled/directives/io/Throttle.js +1 -1
  368. package/transpiled/directives/io/Throttle.js.map +1 -1
  369. package/transpiled/directives/io/lib/throttle/Quotas.d.ts +1 -1
  370. package/transpiled/directives/io/lib/throttle/Quotas.js +2 -2
  371. package/transpiled/directives/io/lib/throttle/Quotas.js.map +1 -1
  372. package/transpiled/directives/map/Headers.d.ts +2 -0
  373. package/transpiled/directives/map/Headers.js +8 -0
  374. package/transpiled/directives/map/Headers.js.map +1 -1
  375. package/transpiled/directives/map/Map.d.ts +3 -1
  376. package/transpiled/directives/map/Map.js +7 -1
  377. package/transpiled/directives/map/Map.js.map +1 -1
  378. package/transpiled/directives/map/Mapping.d.ts +13 -0
  379. package/transpiled/directives/map/Mapping.js +20 -0
  380. package/transpiled/directives/map/Mapping.js.map +1 -1
  381. package/transpiled/directives/map/Segments.d.ts +3 -0
  382. package/transpiled/directives/map/Segments.js +9 -0
  383. package/transpiled/directives/map/Segments.js.map +1 -1
  384. package/transpiled/directives/mcp/MCP.d.ts +15 -0
  385. package/transpiled/directives/mcp/MCP.js +23 -0
  386. package/transpiled/directives/mcp/MCP.js.map +1 -0
  387. package/transpiled/directives/mcp/Tool.d.ts +13 -0
  388. package/transpiled/directives/mcp/Tool.js +23 -0
  389. package/transpiled/directives/mcp/Tool.js.map +1 -0
  390. package/transpiled/directives/mcp/index.d.ts +4 -0
  391. package/transpiled/directives/mcp/index.js +4 -0
  392. package/transpiled/directives/mcp/index.js.map +1 -0
  393. package/transpiled/directives/oauth/Discovery.js +10 -13
  394. package/transpiled/directives/oauth/Discovery.js.map +1 -1
  395. package/transpiled/directives/octets/Octets.d.ts +1 -1
  396. package/transpiled/directives/octets/Octets.js +1 -1
  397. package/transpiled/directives/octets/Octets.js.map +1 -1
  398. package/transpiled/directives/require/Directive.d.ts +1 -1
  399. package/transpiled/directives/require/Headers.d.ts +1 -1
  400. package/transpiled/directives/require/Headers.js +1 -1
  401. package/transpiled/directives/require/Headers.js.map +1 -1
  402. package/transpiled/directives/require/Require.d.ts +1 -1
  403. package/transpiled/directives/require/Require.js +2 -2
  404. package/transpiled/directives/require/Require.js.map +1 -1
  405. package/transpiled/schemas.d.ts +2 -0
  406. package/transpiled/schemas.js +1 -0
  407. package/transpiled/schemas.js.map +1 -1
  408. package/tsconfig.tsbuildinfo +1 -1
  409. package/components/identity.bans/operations/transit.d.ts +0 -14
  410. package/components/identity.bans/operations/transit.js.map +0 -1
  411. package/components/identity.basic/operations/add.d.ts +0 -3
  412. package/components/identity.basic/operations/add.js.map +0 -1
  413. package/components/identity.basic/operations/authenticate.d.ts +0 -13
  414. package/components/identity.basic/operations/authenticate.js.map +0 -1
  415. package/components/identity.basic/operations/check.d.ts +0 -7
  416. package/components/identity.basic/operations/check.js.map +0 -1
  417. package/components/identity.basic/operations/delete.d.ts +0 -7
  418. package/components/identity.basic/operations/delete.js.map +0 -1
  419. package/components/identity.basic/operations/incept.d.ts +0 -12
  420. package/components/identity.basic/operations/incept.js.map +0 -1
  421. package/components/identity.basic/operations/info.d.ts +0 -10
  422. package/components/identity.basic/operations/info.js.map +0 -1
  423. package/components/identity.basic/operations/lib/credentials.d.ts +0 -5
  424. package/components/identity.basic/operations/lib/credentials.js.map +0 -1
  425. package/components/identity.basic/operations/transit.d.ts +0 -15
  426. package/components/identity.basic/operations/transit.js.map +0 -1
  427. package/components/identity.clients/operations/describe.d.ts +0 -27
  428. package/components/identity.clients/operations/describe.js.map +0 -1
  429. package/components/identity.clients/operations/lib/Context.d.ts +0 -29
  430. package/components/identity.clients/operations/lib/Context.js.map +0 -1
  431. package/components/identity.clients/operations/lib/Entity.d.ts +0 -29
  432. package/components/identity.clients/operations/lib/Entity.js.map +0 -1
  433. package/components/identity.clients/operations/lib/canonical.d.ts +0 -11
  434. package/components/identity.clients/operations/lib/canonical.js.map +0 -1
  435. package/components/identity.clients/operations/lib/cimd.d.ts +0 -8
  436. package/components/identity.clients/operations/lib/cimd.js.map +0 -1
  437. package/components/identity.clients/operations/lib/errors.d.ts +0 -7
  438. package/components/identity.clients/operations/lib/errors.js.map +0 -1
  439. package/components/identity.clients/operations/lib/index.d.ts +0 -6
  440. package/components/identity.clients/operations/lib/index.js.map +0 -1
  441. package/components/identity.clients/operations/lib/redirect.d.ts +0 -10
  442. package/components/identity.clients/operations/lib/redirect.js.map +0 -1
  443. package/components/identity.clients/operations/register.d.ts +0 -37
  444. package/components/identity.clients/operations/register.js.map +0 -1
  445. package/components/identity.credentials/operations/list.d.ts +0 -52
  446. package/components/identity.credentials/operations/list.js.map +0 -1
  447. package/components/identity.federation/operations/authenticate.d.ts +0 -16
  448. package/components/identity.federation/operations/authenticate.js.map +0 -1
  449. package/components/identity.federation/operations/create.d.ts +0 -8
  450. package/components/identity.federation/operations/create.js.map +0 -1
  451. package/components/identity.federation/operations/decode.d.ts +0 -3
  452. package/components/identity.federation/operations/decode.js.map +0 -1
  453. package/components/identity.federation/operations/delete.d.ts +0 -8
  454. package/components/identity.federation/operations/delete.js.map +0 -1
  455. package/components/identity.federation/operations/incept.d.ts +0 -11
  456. package/components/identity.federation/operations/incept.js.map +0 -1
  457. package/components/identity.federation/operations/lib/Configuration.d.ts +0 -39
  458. package/components/identity.federation/operations/lib/Configuration.js.map +0 -1
  459. package/components/identity.federation/operations/lib/Ctx.d.ts +0 -8
  460. package/components/identity.federation/operations/lib/Ctx.js.map +0 -1
  461. package/components/identity.federation/operations/lib/Payload.d.ts +0 -5
  462. package/components/identity.federation/operations/lib/Payload.js.map +0 -1
  463. package/components/identity.federation/operations/lib/decode.d.ts +0 -3
  464. package/components/identity.federation/operations/lib/decode.js.map +0 -1
  465. package/components/identity.federation/operations/lib/discovery.d.ts +0 -5
  466. package/components/identity.federation/operations/lib/discovery.js.map +0 -1
  467. package/components/identity.federation/operations/lib/errors.d.ts +0 -77
  468. package/components/identity.federation/operations/lib/errors.js.map +0 -1
  469. package/components/identity.federation/operations/lib/exchange.d.ts +0 -3
  470. package/components/identity.federation/operations/lib/exchange.js.map +0 -1
  471. package/components/identity.federation/operations/lib/index.d.ts +0 -4
  472. package/components/identity.federation/operations/lib/index.js.map +0 -1
  473. package/components/identity.federation/operations/lib/jose.d.ts +0 -1
  474. package/components/identity.federation/operations/lib/jose.js.map +0 -1
  475. package/components/identity.federation/operations/lib/resolve.d.ts +0 -3
  476. package/components/identity.federation/operations/lib/resolve.js.map +0 -1
  477. package/components/identity.federation/operations/list.d.ts +0 -7
  478. package/components/identity.federation/operations/list.js.map +0 -1
  479. package/components/identity.federation/operations/types/Scheme.d.ts +0 -1
  480. package/components/identity.federation/operations/types/Scheme.js.map +0 -1
  481. package/components/identity.federation/operations/types/configuration.d.ts +0 -22
  482. package/components/identity.federation/operations/types/configuration.js.map +0 -1
  483. package/components/identity.federation/operations/types/context.d.ts +0 -36
  484. package/components/identity.federation/operations/types/context.js.map +0 -1
  485. package/components/identity.federation/operations/types/entity.d.ts +0 -9
  486. package/components/identity.federation/operations/types/entity.js.map +0 -1
  487. package/components/identity.federation/operations/types/index.d.ts +0 -4
  488. package/components/identity.federation/operations/types/index.js.map +0 -1
  489. package/components/identity.grants/operations/authorize.d.ts +0 -35
  490. package/components/identity.grants/operations/authorize.js.map +0 -1
  491. package/components/identity.grants/operations/exchange.d.ts +0 -37
  492. package/components/identity.grants/operations/exchange.js.map +0 -1
  493. package/components/identity.grants/operations/lib/code.d.ts +0 -15
  494. package/components/identity.grants/operations/lib/code.js.map +0 -1
  495. package/components/identity.grants/operations/lib/identify.d.ts +0 -6
  496. package/components/identity.grants/operations/lib/identify.js.map +0 -1
  497. package/components/identity.grants/operations/lib/index.d.ts +0 -3
  498. package/components/identity.grants/operations/lib/index.js.map +0 -1
  499. package/components/identity.grants/operations/list.d.ts +0 -13
  500. package/components/identity.grants/operations/list.js.map +0 -1
  501. package/components/identity.grants/operations/revoke.d.ts +0 -18
  502. package/components/identity.grants/operations/revoke.js.map +0 -1
  503. package/components/identity.keys/operations/create.d.ts +0 -22
  504. package/components/identity.keys/operations/create.js.map +0 -1
  505. package/components/identity.keys/operations/disable.d.ts +0 -5
  506. package/components/identity.keys/operations/disable.js.map +0 -1
  507. package/components/identity.keys/operations/revoke.d.ts +0 -15
  508. package/components/identity.keys/operations/revoke.js.map +0 -1
  509. package/components/identity.otp/operations/authenticate.d.ts +0 -12
  510. package/components/identity.otp/operations/authenticate.js.map +0 -1
  511. package/components/identity.otp/operations/issue.d.ts +0 -12
  512. package/components/identity.otp/operations/issue.js.map +0 -1
  513. package/components/identity.otp/operations/lib/Context.d.ts +0 -16
  514. package/components/identity.otp/operations/lib/Context.js.map +0 -1
  515. package/components/identity.otp/operations/lib/Entity.d.ts +0 -6
  516. package/components/identity.otp/operations/lib/Entity.js.map +0 -1
  517. package/components/identity.otp/operations/lib/index.d.ts +0 -1
  518. package/components/identity.otp/operations/lib/index.js.map +0 -1
  519. package/components/identity.passkeys/operations/authenticate.d.ts +0 -16
  520. package/components/identity.passkeys/operations/authenticate.js.map +0 -1
  521. package/components/identity.passkeys/operations/challenge.d.ts +0 -35
  522. package/components/identity.passkeys/operations/challenge.js.map +0 -1
  523. package/components/identity.passkeys/operations/create.d.ts +0 -19
  524. package/components/identity.passkeys/operations/create.js.map +0 -1
  525. package/components/identity.passkeys/operations/delete.d.ts +0 -8
  526. package/components/identity.passkeys/operations/delete.js.map +0 -1
  527. package/components/identity.passkeys/operations/lib/const.d.ts +0 -1
  528. package/components/identity.passkeys/operations/lib/const.js.map +0 -1
  529. package/components/identity.passkeys/operations/list.d.ts +0 -7
  530. package/components/identity.passkeys/operations/list.js.map +0 -1
  531. package/components/identity.passkeys/operations/types/Configuration.d.ts +0 -6
  532. package/components/identity.passkeys/operations/types/Configuration.js.map +0 -1
  533. package/components/identity.passkeys/operations/types/Context.d.ts +0 -16
  534. package/components/identity.passkeys/operations/types/Context.js.map +0 -1
  535. package/components/identity.passkeys/operations/types/Passkey.d.ts +0 -12
  536. package/components/identity.passkeys/operations/types/Passkey.js.map +0 -1
  537. package/components/identity.passkeys/operations/types/index.d.ts +0 -2
  538. package/components/identity.passkeys/operations/types/index.js.map +0 -1
  539. package/components/identity.passkeys/operations/use.d.ts +0 -16
  540. package/components/identity.passkeys/operations/use.js.map +0 -1
  541. package/components/identity.roles/operations/grant.d.ts +0 -10
  542. package/components/identity.roles/operations/grant.js.map +0 -1
  543. package/components/identity.roles/operations/lib/Entity.d.ts +0 -5
  544. package/components/identity.roles/operations/lib/Entity.js.map +0 -1
  545. package/components/identity.roles/operations/list.d.ts +0 -2
  546. package/components/identity.roles/operations/list.js.map +0 -1
  547. package/components/identity.roles/operations/principal.d.ts +0 -13
  548. package/components/identity.roles/operations/principal.js.map +0 -1
  549. package/components/identity.tokens/operations/authenticate.d.ts +0 -10
  550. package/components/identity.tokens/operations/authenticate.js.map +0 -1
  551. package/components/identity.tokens/operations/decrypt.d.ts +0 -16
  552. package/components/identity.tokens/operations/decrypt.js.map +0 -1
  553. package/components/identity.tokens/operations/encrypt.d.ts +0 -9
  554. package/components/identity.tokens/operations/encrypt.js.map +0 -1
  555. package/components/identity.tokens/operations/issue.d.ts +0 -25
  556. package/components/identity.tokens/operations/issue.js.map +0 -1
  557. package/components/identity.tokens/operations/lib/form.d.ts +0 -8
  558. package/components/identity.tokens/operations/lib/form.js.map +0 -1
  559. package/components/identity.tokens/operations/lib/index.d.ts +0 -4
  560. package/components/identity.tokens/operations/lib/index.js.map +0 -1
  561. package/components/identity.tokens/operations/lib/jose.d.ts +0 -1
  562. package/components/identity.tokens/operations/lib/jose.js.map +0 -1
  563. package/components/identity.tokens/operations/lib/key.d.ts +0 -1
  564. package/components/identity.tokens/operations/lib/key.js.map +0 -1
  565. package/components/identity.tokens/operations/lib/pad.d.ts +0 -1
  566. package/components/identity.tokens/operations/lib/pad.js.map +0 -1
  567. package/components/identity.tokens/operations/revoke.d.ts +0 -2
  568. package/components/identity.tokens/operations/revoke.js.map +0 -1
@@ -0,0 +1,100 @@
1
+ import { console } from 'openspan';
2
+ import * as http from '../HTTP/index.js';
3
+ import * as schemas from '../schemas.js';
4
+ import { BATCH } from '../const.js';
5
+ import { address, split } from './names.js';
6
+ import { fork } from './Context.js';
7
+ import { BATCH_TOO_LARGE, INVALID_REQUEST, PARSE, failure, of, response } from './errors.js';
8
+ import { VERSION } from './types.js';
9
+ /**
10
+ * JSON-RPC, as the calls a request carries.
11
+ *
12
+ * It clones the context per call and hands each clone back to the gateway: it holds no
13
+ * tree, no index and no knowledge of routing. Whether a name resolves, what it resolves
14
+ * to, and what the directives of that route do are answered by the same `route` an
15
+ * ordinary request goes through.
16
+ */
17
+ export class Dispatcher {
18
+ batch;
19
+ constructor(options) {
20
+ this.batch = options.batch ?? BATCH;
21
+ }
22
+ async dispatch(context, route) {
23
+ if (context.request.method !== 'POST')
24
+ throw new http.MethodNotAllowed(new Headers({ allow: 'POST' }));
25
+ const envelope = await this.read(context);
26
+ const batched = Array.isArray(envelope);
27
+ const calls = batched ? envelope : [envelope];
28
+ if (calls.length === 0)
29
+ throw new http.BadRequest(response(null, failure(INVALID_REQUEST, 'A request carries at least one call')));
30
+ if (calls.length > this.batch)
31
+ throw new http.BadRequest(response(null, failure(BATCH_TOO_LARGE, `A request carries at most ${this.batch} calls`)));
32
+ const answers = [];
33
+ // one after another: a request the caller writes should not become a fan-out they own
34
+ for (const call of calls) {
35
+ const answer = await this.answer(call, context, route);
36
+ if (answer !== null)
37
+ answers.push(answer);
38
+ }
39
+ // every call was a notification, and a notification is answered by not answering
40
+ if (answers.length === 0)
41
+ return { status: NO_CONTENT };
42
+ // a reply assembled from several is not one of them, and is not stored as if it were
43
+ return {
44
+ status: OK,
45
+ body: batched ? answers : answers[0],
46
+ headers: new Headers({ 'cache-control': 'no-store' })
47
+ };
48
+ }
49
+ async answer(input, context, route) {
50
+ const invalid = schemas.call.fit(input);
51
+ // it may have carried an id, but nothing about it is trustworthy enough to answer to
52
+ if (invalid !== null)
53
+ return response(null, failure(INVALID_REQUEST, invalid.message));
54
+ return await this.call(input, context, route);
55
+ }
56
+ async call(call, context, route) {
57
+ const notification = call.id === undefined;
58
+ try {
59
+ const params = call.params ?? {};
60
+ const { path, verb, variables } = address(call.method, params);
61
+ const { query, input } = split(params, variables);
62
+ const clone = fork(context, path, verb, query, input);
63
+ // one span per call, so what the directives of that call open has somewhere to hang
64
+ const message = await console.span({ name: call.method, attributes: { id: call.id } }, async () => await route(clone));
65
+ // what `io:output` restricts, over this call's reply rather than the envelope
66
+ await http.shape(clone, message);
67
+ if (notification)
68
+ return null;
69
+ return { jsonrpc: VERSION, id: call.id, result: message.body ?? null };
70
+ }
71
+ catch (exception) {
72
+ /*
73
+ * A credential belongs to the request. Refusing one call for it would leave the
74
+ * reply a 200, and the challenge that tells a client where to authenticate is
75
+ * attached to a 401 — so the whole envelope is refused instead.
76
+ */
77
+ if (exception instanceof http.Unauthorized)
78
+ throw exception;
79
+ if (notification) {
80
+ console.debug('Notification failed', { method: call.method, error: of(exception) });
81
+ return null;
82
+ }
83
+ return { jsonrpc: VERSION, id: call.id, error: of(exception) };
84
+ }
85
+ }
86
+ /** A body the decoder refuses is a parse error; a media type it does not know is not. */
87
+ async read(context) {
88
+ try {
89
+ return await context.body();
90
+ }
91
+ catch (exception) {
92
+ if (exception instanceof http.BadRequest)
93
+ throw new http.BadRequest(response(null, failure(PARSE, 'Parse error')));
94
+ throw exception;
95
+ }
96
+ }
97
+ }
98
+ const OK = 200;
99
+ const NO_CONTENT = 204;
100
+ //# sourceMappingURL=Dispatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dispatcher.js","sourceRoot":"","sources":["../../source/RPC/Dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AACxC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC5F,OAAO,EAAE,OAAO,EAA4B,MAAM,YAAY,CAAA;AAG9D;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACJ,KAAK,CAAQ;IAE9B,YAAoB,OAAY;QAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAA;IACrC,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAE,OAAqB,EAC1C,KAAqB;QACrB,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM;YACnC,MAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;QAEjE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACvC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC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C,OAAO,SAAS,EAAE,CAAC;YACnB;;;;eAIG;YACH,IAAI,SAAS,YAAY,IAAI,CAAC,YAAY;gBACxC,MAAM,SAAS,CAAA;YAEjB,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;gBAEnF,OAAO,IAAI,CAAA;YACb,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,EAAG,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAA;QACjE,CAAC;IACH,CAAC;IAED,yFAAyF;IACjF,KAAK,CAAC,IAAI,CAAE,OAAqB;QACvC,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;QAC7B,CAAC;QAAC,OAAO,SAAS,EAAE,CAAC;YACnB,IAAI,SAAS,YAAY,IAAI,CAAC,UAAU;gBACtC,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;YAE1E,MAAM,SAAS,CAAA;QACjB,CAAC;IACH,CAAC;CACF;AAED,MAAM,EAAE,GAAG,GAAG,CAAA;AACd,MAAM,UAAU,GAAG,GAAG,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { type Failure, type Response } from './types.js';
2
+ export declare const PARSE = -32700;
3
+ export declare const INVALID_REQUEST = -32600;
4
+ export declare const METHOD_NOT_FOUND = -32601;
5
+ export declare const INVALID_PARAMS = -32602;
6
+ export declare const INTERNAL = -32603;
7
+ export declare const FORBIDDEN = -32000;
8
+ export declare const REFUSED = -32001;
9
+ export declare const BATCH_TOO_LARGE = -32002;
10
+ export declare function failure(code: number, message: string, data?: unknown): Failure;
11
+ export declare function response(id: string | number | null, error: Failure): Response;
12
+ /**
13
+ * What an exception says as a JSON-RPC error.
14
+ *
15
+ * The readable text is `body`, never `message`: `http.Exception` calls `super()` with no
16
+ * argument, so every one of them carries an empty `message`.
17
+ */
18
+ export declare function of(exception: unknown): Failure;
@@ -0,0 +1,67 @@
1
+ import * as http from '../HTTP/index.js';
2
+ import { VERSION } from './types.js';
3
+ /*
4
+ * The five the specification fixes (JSON-RPC 2.0 §5.1). A client reads these the same
5
+ * whoever answers.
6
+ */
7
+ export const PARSE = -32700;
8
+ export const INVALID_REQUEST = -32600;
9
+ export const METHOD_NOT_FOUND = -32601;
10
+ export const INVALID_PARAMS = -32602;
11
+ export const INTERNAL = -32603;
12
+ /*
13
+ * Ours. The specification reserves -32000 to -32099 for implementation-defined server
14
+ * errors and defines nothing in it, so these mean nothing outside Toa — which is why
15
+ * `REFUSED` carries the operation's own code in `data`.
16
+ */
17
+ export const FORBIDDEN = -32000;
18
+ export const REFUSED = -32001;
19
+ export const BATCH_TOO_LARGE = -32002;
20
+ export function failure(code, message, data) {
21
+ const value = { code, message };
22
+ if (data !== undefined)
23
+ value.data = data;
24
+ return value;
25
+ }
26
+ export function response(id, error) {
27
+ return { jsonrpc: VERSION, id, error };
28
+ }
29
+ /**
30
+ * What an exception says as a JSON-RPC error.
31
+ *
32
+ * The readable text is `body`, never `message`: `http.Exception` calls `super()` with no
33
+ * argument, so every one of them carries an empty `message`.
34
+ */
35
+ export function of(exception) {
36
+ if (exception instanceof http.UnprocessableEntity)
37
+ return refusal(exception);
38
+ if (exception instanceof http.NotFound || exception instanceof http.MethodNotAllowed)
39
+ return failure(METHOD_NOT_FOUND, text(exception, 'Method not found'));
40
+ if (exception instanceof http.Forbidden)
41
+ return failure(FORBIDDEN, text(exception, 'Forbidden'));
42
+ if (exception instanceof http.BadRequest)
43
+ return failure(INVALID_PARAMS, text(exception, 'Invalid params'));
44
+ // a conflict, a precondition, a throttle: the call was refused, and by what is worth saying
45
+ if (exception instanceof http.ClientError)
46
+ return failure(REFUSED, text(exception, 'Refused'), { status: exception.status });
47
+ return failure(INTERNAL, 'Internal error');
48
+ }
49
+ /**
50
+ * An operation that declares its errors answers with one rather than throwing, and the
51
+ * reply contract states `{ code, message? }` — the message optional. The number says the
52
+ * operation refused; `data.code` says what it refused with, and is what a caller branches on.
53
+ */
54
+ function refusal(exception) {
55
+ const body = exception.body;
56
+ if (typeof body !== 'object' || body === null || typeof body.code !== 'string')
57
+ return failure(REFUSED, text(exception, 'Refused'));
58
+ const code = body.code;
59
+ const message = typeof body.message === 'string' && body.message !== '' ? body.message : code;
60
+ return failure(REFUSED, message, { code });
61
+ }
62
+ function text(exception, fallback) {
63
+ return typeof exception.body === 'string' && exception.body !== ''
64
+ ? exception.body
65
+ : fallback;
66
+ }
67
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../source/RPC/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,OAAO,EAA+B,MAAM,YAAY,CAAA;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAK,CAAA;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAK,CAAA;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAA;AACtC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,CAAA;AACpC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAA;AAE9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,CAAA;AAC/B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAK,CAAA;AAC7B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAK,CAAA;AAErC,MAAM,UAAU,OAAO,CAAE,IAAY,EAAE,OAAe,EAAE,IAAc;IACpE,MAAM,KA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IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;QAC5E,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAA;IAErD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAc,CAAA;IAChC,MAAM,OAAO,GAAG,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;IAE7F,OAAO,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AAC5C,CAAC;AAED,SAAS,IAAI,CAAE,SAAyB,EAAE,QAAgB;IACxD,OAAO,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,KAAK,EAAE;QAChE,CAAC,CAAC,SAAS,CAAC,IAAI;QAChB,CAAC,CAAC,QAAQ,CAAA;AACd,CAAC"}
@@ -0,0 +1 @@
1
+ export { Dispatcher } from './Dispatcher.js';
@@ -0,0 +1,2 @@
1
+ export { Dispatcher } from './Dispatcher.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/RPC/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,30 @@
1
+ import type { Segment } from '../RTD/segment.js';
2
+ import { type Params } from './types.js';
3
+ /**
4
+ * What a name resolves to: the path the call is made at, and the verb it is made with.
5
+ *
6
+ * A name is the route template with its variables marked and the verb appended as a segment
7
+ * of its own — `pots/_id/GET`. Neither `/` nor a verb can be mistaken for anything else: the
8
+ * verb is always the last segment, and `/` cannot occur inside one.
9
+ */
10
+ export interface Address {
11
+ path: string;
12
+ verb: string;
13
+ /** the `params` the path took, which are therefore not the operation's input */
14
+ variables: string[];
15
+ }
16
+ export declare function address(method: string, params: Params): Address;
17
+ /**
18
+ * What the call carries, as a request carries it: the path took its variables, `query` is
19
+ * the querystring, and the rest is the body.
20
+ */
21
+ export declare function split(params: Params, variables: string[]): {
22
+ query?: Params;
23
+ input?: Params;
24
+ };
25
+ /** The name of a method on this route, or nothing where the route has none. */
26
+ export declare function name(segments: Segment[], verb: string): string | null;
27
+ /** The segment that leaves a route unnameable, as it was declared, or nothing where none does. */
28
+ export declare function refusal(segments: Segment[]): string | null;
29
+ /** The route as it was declared, which is how a message about it should read. */
30
+ export declare function template(segments: Segment[]): string;
@@ -0,0 +1,121 @@
1
+ import * as http from '../HTTP/index.js';
2
+ import { verbs } from '../RTD/syntax/index.js';
3
+ import { QUERY } from './types.js';
4
+ export function address(method, params) {
5
+ const parts = method.split(SEPARATOR);
6
+ const verb = parts.pop();
7
+ if (!verbs.has(verb))
8
+ throw new http.NotFound(`'${method}' names no method`);
9
+ const variables = [];
10
+ const fragments = [];
11
+ for (const part of parts) {
12
+ const key = parameter(part);
13
+ if (key === null) {
14
+ fragments.push(literal(part, method));
15
+ continue;
16
+ }
17
+ if (part !== TAIL && !NAMEABLE.test(key))
18
+ throw new http.NotFound(`'${method}' names no procedure`);
19
+ const value = params[key];
20
+ if (value === undefined || value === null)
21
+ throw new http.BadRequest(`'${method}' requires the parameter '${key}'`);
22
+ const fragment = String(value);
23
+ // `__` stands for the rest of the path and may carry separators; a variable is one segment
24
+ if (!(part === TAIL ? TAILED : OPAQUE).test(fragment))
25
+ throw new http.BadRequest(`The parameter '${key}' cannot be a path of its own`);
26
+ variables.push(key);
27
+ fragments.push(fragment);
28
+ }
29
+ // a route is matched with its trailing slash, and the trunk is the bare one
30
+ const path = fragments.length === 0 ? '/' : `/${fragments.join('/')}/`;
31
+ return { path, verb, variables };
32
+ }
33
+ /**
34
+ * What the call carries, as a request carries it: the path took its variables, `query` is
35
+ * the querystring, and the rest is the body.
36
+ */
37
+ export function split(params, variables) {
38
+ const input = {};
39
+ let query;
40
+ for (const [key, value] of Object.entries(params)) {
41
+ if (variables.includes(key))
42
+ continue;
43
+ if (key !== QUERY) {
44
+ input[key] = value;
45
+ continue;
46
+ }
47
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
48
+ throw new http.BadRequest(`'${QUERY}' must be an object`);
49
+ query = value;
50
+ }
51
+ // an absent body is what a request without one has, and the mapping fills it as it does
52
+ return { query, input: Object.keys(input).length === 0 ? undefined : input };
53
+ }
54
+ /** The parameter a part reads, or nothing where the part is a literal segment. */
55
+ function parameter(part) {
56
+ if (part === TAIL)
57
+ return WILDCARD;
58
+ return part[0] === VARIABLE ? part.slice(1) : null;
59
+ }
60
+ /** A segment a name cannot spell is a segment no name has, so this one names nothing. */
61
+ function literal(part, method) {
62
+ if (!NAMEABLE.test(part))
63
+ throw new http.NotFound(`'${method}' names no procedure`);
64
+ return part;
65
+ }
66
+ /** The name of a method on this route, or nothing where the route has none. */
67
+ export function name(segments, verb) {
68
+ const parts = [];
69
+ for (const segment of segments) {
70
+ const part = component(segment);
71
+ if (part === null)
72
+ return null;
73
+ parts.push(part);
74
+ }
75
+ parts.push(verb);
76
+ return parts.join(SEPARATOR);
77
+ }
78
+ /** The segment that leaves a route unnameable, as it was declared, or nothing where none does. */
79
+ export function refusal(segments) {
80
+ for (const segment of segments)
81
+ if (component(segment) === null)
82
+ return declared(segment);
83
+ return null;
84
+ }
85
+ function component(segment) {
86
+ if (segment.fragment !== null)
87
+ return NAMEABLE.test(segment.fragment) ? segment.fragment : null;
88
+ if (segment.wildcard === true)
89
+ return TAIL;
90
+ // it stands for a segment the caller cannot name, so there is nothing to substitute
91
+ if (segment.placeholder === null)
92
+ return null;
93
+ return NAMEABLE.test(segment.placeholder) ? VARIABLE + segment.placeholder : null;
94
+ }
95
+ /** The route as it was declared, which is how a message about it should read. */
96
+ export function template(segments) {
97
+ return '/' + segments.map(declared).join('/');
98
+ }
99
+ function declared(segment) {
100
+ if (segment.fragment !== null)
101
+ return segment.fragment;
102
+ if (segment.wildcard === true)
103
+ return '**';
104
+ return segment.placeholder === null ? '*' : ':' + segment.placeholder;
105
+ }
106
+ const SEPARATOR = '/';
107
+ const VARIABLE = '_';
108
+ const TAIL = '__';
109
+ /** How the RTD names the rest of a path, wherever a parameter of it is read. */
110
+ const WILDCARD = '**';
111
+ /**
112
+ * What a segment may hold to have a name. `_` is the convention's own, and every other
113
+ * character a client leaves alone is here: a client shows a model the name with the rest
114
+ * turned into `_`, and two names must not become one.
115
+ */
116
+ const NAMEABLE = /^[A-Za-z0-9-]+$/;
117
+ /** A segment ends at what divides or ends a path. */
118
+ const OPAQUE = /^[^/?#]*$/;
119
+ /** A tail is several segments, so it keeps the divider and loses only what ends a path. */
120
+ const TAILED = /^[^?#]*$/;
121
+ //# sourceMappingURL=names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.js","sourceRoot":"","sources":["../../source/RPC/names.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE9C,OAAO,EAAE,KAAK,EAAe,MAAM,YAAY,CAAA;AAiB/C,MAAM,UAAU,OAAO,CAAE,MAAc,EAAE,MAAc;IACrD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IACrC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAG,CAAA;IAEzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;QAClB,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,mBAAmB,CAAC,CAAA;IAExD,MAAM,SAAS,GAAa,EAAE,CAAA;IAC9B,MAAM,SAAS,GAAa,EAAE,CAAA;IAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,SAAS,CAAC,IA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AC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAED,SAAS,QAAQ,CAAE,OAAgB;IACjC,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI;QAC3B,OAAO,OAAO,CAAC,QAAQ,CAAA;IAEzB,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI;QAC3B,OAAO,IAAI,CAAA;IAEb,OAAO,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,WAAW,CAAA;AACvE,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,CAAA;AACrB,MAAM,QAAQ,GAAG,GAAG,CAAA;AACpB,MAAM,IAAI,GAAG,IAAI,CAAA;AAEjB,gFAAgF;AAChF,MAAM,QAAQ,GAAG,IAAI,CAAA;AAErB;;;;GAIG;AACH,MAAM,QAAQ,GAAG,iBAAiB,CAAA;AAElC,qDAAqD;AACrD,MAAM,MAAM,GAAG,WAAW,CAAA;AAE1B,2FAA2F;AAC3F,MAAM,MAAM,GAAG,UAAU,CAAA"}
@@ -0,0 +1,27 @@
1
+ /** The version every call and every response states. */
2
+ export declare const VERSION = "2.0";
3
+ /**
4
+ * The member `params` reserves for what a querystring would carry. An operation's input is
5
+ * free to have an `id` or a `limit` of its own, so the two cannot share one object.
6
+ */
7
+ export declare const QUERY = "query";
8
+ export type Params = Record<string, unknown>;
9
+ export interface Call {
10
+ jsonrpc: string;
11
+ method: string;
12
+ params?: Params;
13
+ /** Absent makes this a notification: it runs, and nothing is returned for it. */
14
+ id?: string | number;
15
+ }
16
+ export interface Response {
17
+ jsonrpc: string;
18
+ /** `null` where the request was not readable enough to carry one. */
19
+ id: string | number | null;
20
+ result?: unknown;
21
+ error?: Failure;
22
+ }
23
+ export interface Failure {
24
+ code: number;
25
+ message: string;
26
+ data?: unknown;
27
+ }
@@ -0,0 +1,8 @@
1
+ /** The version every call and every response states. */
2
+ export const VERSION = '2.0';
3
+ /**
4
+ * The member `params` reserves for what a querystring would carry. An operation's input is
5
+ * free to have an `id` or a `limit` of its own, so the two cannot share one object.
6
+ */
7
+ export const QUERY = 'query';
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../source/RPC/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAA;AAE5B;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA"}
@@ -2,15 +2,28 @@ import type { Parameter } from './Match.js';
2
2
  import type * as syntax from './syntax/index.js';
3
3
  import type { Context, OutgoingMessage, Options } from '../HTTP/index.js';
4
4
  import type { Output } from '../io.js';
5
+ import type { Introspection } from '../Introspection.js';
5
6
  import type { extensions } from '@toa.io/core';
6
7
  type Host = extensions.Host;
7
8
  export interface Directives {
8
- preflight: (context: Context, parameters: Parameter[]) => Promise<Output>;
9
+ /**
10
+ * The directives of one family on this method, or nothing where it declares none of it.
11
+ * For a consumer of a declaration rather than of a stage: what a method is published as
12
+ * is stated on the route, and read where the publishing happens.
13
+ */
14
+ declared: <T>(family: string) => T[] | undefined;
15
+ precall: (context: Context, parameters: Parameter[]) => Promise<Output>;
16
+ /** What this route's directives make of what its method says about itself. */
17
+ explain: (context: Context, introspection: Introspection) => Promise<Introspection | null>;
9
18
  settle: (context: Context, response: OutgoingMessage) => Promise<void>;
10
19
  dispose: () => void;
11
20
  }
12
21
  export interface DirectiveFactory {
13
22
  create: (directives: syntax.Directive[], route: string) => Directives;
23
+ /** Runs every family's `preflight`, which is request-scoped and needs no node. */
24
+ preflight: (context: Context) => Promise<void>;
25
+ /** Runs every family's `depart`, the counterpart of `preflight`. */
26
+ depart: (context: Context, response: OutgoingMessage) => Promise<void>;
14
27
  dispose: () => void;
15
28
  }
16
29
  export interface DirectiveSet {
@@ -33,8 +46,34 @@ export interface DirectiveFamily<TDirective = any, TExtension = any> {
33
46
  * the set is built — the order cannot depend on the request.
34
47
  */
35
48
  arrange?: (directives: TDirective[]) => void;
36
- preflight?: (directives: TDirective[], request: Context & TExtension, parameters: Parameter[]) => Output | Promise<Output>;
49
+ /**
50
+ * Request-scoped, before anything is routed. It takes no directives: no node is known
51
+ * yet, and a request that carries several calls has no single node at all. What a
52
+ * directive declares is call-scoped by definition, so only what a family does on its
53
+ * own behalf — authenticating a credential — belongs here. It answers nothing: a stage
54
+ * that runs before a route is known has no reply to make, and refuses by throwing.
55
+ */
56
+ preflight?: (request: Context & TExtension) => void | Promise<void>;
57
+ /** Call-scoped, with what the node declares. Runs once per call. */
58
+ precall?: (directives: TDirective[], request: Context & TExtension, parameters: Parameter[]) => Output | Promise<Output>;
59
+ /**
60
+ * What this family's directives make of what the method says about itself, which is
61
+ * what `OPTIONS` answers and what a tool is described by. `null` refuses: the method
62
+ * is not reachable by this caller, and is not described at all.
63
+ *
64
+ * There is no request here — no route variable has a value and no body has arrived, which
65
+ * is why no parameters are passed — so a directive that can only tell from one hands back
66
+ * what it was given.
67
+ */
68
+ explain?: (directives: TDirective[], request: Context & TExtension, introspection: Introspection) => Introspection | null | Promise<Introspection | null>;
69
+ /** Call-scoped, on the message that call produced. */
37
70
  settle?: (directives: TDirective[], request: Context & TExtension, response: OutgoingMessage) => void | Promise<void>;
71
+ /**
72
+ * Request-scoped, on the message going back — the counterpart of `preflight`, and
73
+ * likewise without directives. A reply the whole request carries, such as a re-issued
74
+ * credential, is written here rather than by a call that would not own it.
75
+ */
76
+ depart?: (request: Context & TExtension, response: OutgoingMessage) => void | Promise<void>;
38
77
  dispose?: (directives: TDirective[]) => void;
39
78
  }
40
79
  export {};
@@ -2,9 +2,10 @@ import { type Context } from './Context.js';
2
2
  import type * as http from '../HTTP/index.js';
3
3
  import type * as syntax from './syntax/index.js';
4
4
  import type * as RTD from './index.js';
5
+ import type { Introspection } from '../Introspection.js';
5
6
  export interface Endpoint {
6
7
  call: (context: http.Context, parameters: RTD.Parameter[]) => Promise<http.OutgoingMessage>;
7
- explain: (parameters: RTD.Parameter[]) => Promise<unknown>;
8
+ explain: (parameters: RTD.Parameter[]) => Promise<Introspection>;
8
9
  close: () => Promise<void>;
9
10
  }
10
11
  export interface EndpointsFactory {
@@ -1,13 +1,18 @@
1
1
  import type { Parameter } from './Match.js';
2
2
  import type { Endpoint } from './Endpoint.js';
3
3
  import type { Directives } from './Directives.js';
4
+ import type { Context } from '../HTTP/index.js';
5
+ import type { Introspection } from '../Introspection.js';
4
6
  export declare class Method {
5
7
  readonly endpoint: Endpoint | null;
6
8
  readonly directives: Directives;
7
- private introspection;
8
- private introspecting;
9
9
  constructor(endpoint: Endpoint | null, directives: Directives);
10
- explain(parameters: Parameter[]): Promise<unknown>;
10
+ /**
11
+ * What this method says about itself, as its directives leave it, or nothing where they
12
+ * refuse this caller. A method of no endpoint — one a directive answers on its own —
13
+ * states nothing of its own, and its directives still have their say.
14
+ */
15
+ explain(context: Context, parameters: Parameter[]): Promise<Introspection | null>;
11
16
  close(): Promise<void>;
12
17
  }
13
18
  export type Methods = Record<string, Method>;
@@ -1,20 +1,22 @@
1
+ import { order } from '../Introspection.js';
1
2
  export class Method {
2
3
  endpoint;
3
4
  directives;
4
- introspection = null;
5
- introspecting = null;
6
5
  constructor(endpoint, directives) {
7
6
  this.endpoint = endpoint;
8
7
  this.directives = directives;
9
8
  }
10
- async explain(parameters) {
11
- if (this.introspection !== null)
12
- return this.introspection;
13
- if (this.introspecting === null)
14
- // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
15
- this.introspecting = this.endpoint?.explain(parameters);
16
- this.introspection = await this.introspecting;
17
- return this.introspection;
9
+ /**
10
+ * What this method says about itself, as its directives leave it, or nothing where they
11
+ * refuse this caller. A method of no endpoint — one a directive answers on its own —
12
+ * states nothing of its own, and its directives still have their say.
13
+ */
14
+ async explain(context, parameters) {
15
+ const introspection = this.endpoint === null
16
+ ? {}
17
+ : await this.endpoint.explain(parameters);
18
+ const described = await this.directives.explain(context, introspection);
19
+ return described === null ? null : order(described);
18
20
  }
19
21
  async close() {
20
22
  await this.endpoint?.close();
@@ -1 +1 @@
1
- {"version":3,"file":"Method.js","sourceRoot":"","sources":["../../source/RTD/Method.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,MAAM;IACD,QAAQ,CAAiB;IACzB,UAAU,CAAY;IAC9B,aAAa,GAAmB,IAAI,CAAA;IACpC,aAAa,GAA4B,IAAI,CAAA;IAErD,YAAoB,QAAyB,EAAE,UAAsB;QACnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAC,OAAO,CAAE,UAAuB;QAC3C,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI;YAC7B,OAAO,IAAI,CAAC,aAAa,CAAA;QAE3B,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI;YAC7B,kFAAkF;YAClF,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAE,CAAA;QAE1D,IAAI,CAAC,aAAa,GAAG,MAAM,IAAI,CAAC,aAAa,CAAA;QAE7C,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;IAC9B,CAAC;CACF"}
1
+ {"version":3,"file":"Method.js","sourceRoot":"","sources":["../../source/RTD/Method.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,MAAM,OAAO,MAAM;IACD,QAAQ,CAAiB;IACzB,UAAU,CAAY;IAEtC,YAAoB,QAAyB,EAAE,UAAsB;QACnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO,CAAE,OAAgB,EAAE,UAAuB;QAC7D,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,KAAK,IAAI;YAC1C,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAE3C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;QAEvE,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IACrD,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;IAC9B,CAAC;CACF"}
@@ -1,6 +1,9 @@
1
1
  import { type Route } from './Route.js';
2
- import { type Methods } from './Method.js';
2
+ import { type Method, type Methods } from './Method.js';
3
3
  import { type Match, type Parameter } from './Match.js';
4
+ import type { Segment } from './segment.js';
5
+ import type { Context } from '../HTTP/index.js';
6
+ import type { Introspection } from '../Introspection.js';
4
7
  export declare class Node {
5
8
  intermediate: boolean;
6
9
  forward: string | null;
@@ -16,13 +19,28 @@ export declare class Node {
16
19
  */
17
20
  merge(node: Node): Node[];
18
21
  touch(expiration: number): void;
19
- explain(parameters: Parameter[]): Promise<Record<string, unknown>>;
22
+ /**
23
+ * Every method under this node, with the template it answers at.
24
+ *
25
+ * An intermediate node is skipped: it is never what a path matches, because its `/` route
26
+ * answers at the same place and is reached instead. The trunk is the exception `match`
27
+ * makes for it — `'/'` answers the trunk itself, whatever it holds.
28
+ */
29
+ walk(segments: Segment[], trunk?: boolean): Generator<Mount>;
30
+ /** Every method of this node that this caller may reach, in the order they were declared. */
31
+ explain(context: Context, parameters: Parameter[]): Promise<Record<string, Introspection>>;
20
32
  private replace;
21
33
  private append;
22
34
  private route;
23
35
  private nodes;
24
36
  private sort;
25
37
  }
38
+ /** A method, and the route template it is reached by. */
39
+ export interface Mount {
40
+ segments: Segment[];
41
+ verb: string;
42
+ method: Method;
43
+ }
26
44
  export interface Properties {
27
45
  protected: boolean;
28
46
  forward?: string;
@@ -37,11 +37,29 @@ export class Node {
37
37
  if (!this.protected)
38
38
  this.expiration = expiration;
39
39
  }
40
- async explain(parameters) {
40
+ /**
41
+ * Every method under this node, with the template it answers at.
42
+ *
43
+ * An intermediate node is skipped: it is never what a path matches, because its `/` route
44
+ * answers at the same place and is reached instead. The trunk is the exception `match`
45
+ * makes for it — `'/'` answers the trunk itself, whatever it holds.
46
+ */
47
+ *walk(segments, trunk = false) {
48
+ if (trunk || !this.intermediate)
49
+ for (const [verb, method] of Object.entries(this.methods))
50
+ yield { segments, verb, method };
51
+ for (const route of this.routes)
52
+ yield* route.walk(segments);
53
+ }
54
+ /** Every method of this node that this caller may reach, in the order they were declared. */
55
+ async explain(context, parameters) {
56
+ const entries = Object.entries(this.methods);
57
+ const explained = await Promise.all(entries
58
+ .map(async ([, method]) => await method.explain(context, parameters)));
41
59
  const methods = {};
42
- const explained = Object.entries(this.methods)
43
- .map(async ([verb, method]) => (methods[verb] = await method.explain(parameters)));
44
- await Promise.all(explained);
60
+ for (let i = 0; i < entries.length; i++)
61
+ if (explained[i] !== null)
62
+ methods[entries[i][0]] = explained[i];
45
63
  return methods;
46
64
  }
47
65
  replace(node) {