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

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 +40 -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 +186 -0
  130. package/documentation/oauth.md +8 -7
  131. package/documentation/rpc.md +144 -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 +691 -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 +19 -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 +105 -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 +157 -0
  171. package/source/MCP/types.ts +84 -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 +183 -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 +40 -0
  220. package/source/directives/mcp/Tool.test.ts +90 -0
  221. package/source/directives/mcp/Tool.ts +47 -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 +42 -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 +122 -0
  271. package/transpiled/MCP/tools.js.map +1 -0
  272. package/transpiled/MCP/types.d.ts +66 -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 +31 -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 +29 -0
  386. package/transpiled/directives/mcp/MCP.js.map +1 -0
  387. package/transpiled/directives/mcp/Tool.d.ts +18 -0
  388. package/transpiled/directives/mcp/Tool.js +34 -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
@@ -44,6 +44,8 @@ export class Realtime {
44
44
 
45
45
  Realtime.instance = await factory.service()
46
46
 
47
+ // not awaited: the routes connect to the components that produce the events, and this
48
+ // scenario starts the producer after the service, so the connection settles later
47
49
  void Realtime.instance.connect()
48
50
  }
49
51
 
@@ -152,3 +154,4 @@ export class Realtime {
152
154
  }
153
155
  }
154
156
  }
157
+
@@ -31,6 +31,7 @@ operations:
31
31
  type: object
32
32
  type: object
33
33
  parameters:
34
+ description: Answers with what it was given.
34
35
  input:
35
36
  type: object
36
37
  properties:
@@ -24,6 +24,7 @@ entity:
24
24
 
25
25
  operations:
26
26
  create:
27
+ description: Put a pot on to brew.
27
28
  query: false
28
29
  forward: transit
29
30
  input:
@@ -71,6 +72,7 @@ operations:
71
72
  type: number
72
73
  type: object
73
74
  enumerate:
75
+ description: Every pot there is.
74
76
  output:
75
77
  type: array
76
78
  items:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/extensions.exposition",
3
- "version": "1.0.0-alpha.283",
3
+ "version": "1.0.0-alpha.285",
4
4
  "type": "module",
5
5
  "description": "Toa Exposition",
6
6
  "author": "temich <tema.gurtovoy@gmail.com>",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@simplewebauthn/server": "14.0.0",
22
- "@toa.io/core": "1.0.0-alpha.283",
22
+ "@toa.io/core": "1.0.0-alpha.284",
23
23
  "@toa.io/generic": "1.0.0-alpha.283",
24
24
  "@toa.io/schemas": "1.0.0-alpha.283",
25
25
  "bcryptjs": "3.0.3",
@@ -58,5 +58,5 @@
58
58
  "@types/cors": "2.8.19",
59
59
  "@types/negotiator": "0.6.5"
60
60
  },
61
- "gitHead": "2f52b023bed0ccb2ecdb2b82fe59fbe38bf282e1"
61
+ "gitHead": "44ed1be7e322a5ea8f1a8ed85ba96b9dfaf28224"
62
62
  }
package/readme.md CHANGED
@@ -139,6 +139,9 @@ exposition:
139
139
  | `ip` | Header the client address is read from. See [Client address](documentation/ip.md). |
140
140
  | `bouncer` | Meter of failed authentications per address. See [Identity authentication](documentation/identity.md#failed-authentications). |
141
141
  | `oauth` | Authorization server exposed to OAuth clients. See [OAuth](documentation/oauth.md). |
142
+ | `protocol` | `h1` or `h2c`. See [Protocol](documentation/protocol.md). |
143
+ | `rpc` | JSON-RPC at `/.rpc`; none is served without it. See [JSON-RPC](documentation/rpc.md). |
144
+ | `mcp` | MCP at `/.mcp`; none is served without it. See [MCP](documentation/mcp.md). |
142
145
 
143
146
  ### Observability
144
147
 
@@ -80,6 +80,39 @@ properties:
80
80
  required:
81
81
  - authorize
82
82
  additionalProperties: false
83
+ rpc:
84
+ description: JSON-RPC at `/.rpc`; writing it is what turns the endpoint on
85
+ type: object
86
+ properties:
87
+ batch:
88
+ description: Calls one request may carry
89
+ type: integer
90
+ minimum: 1
91
+ additionalProperties: false
92
+ mcp:
93
+ description: MCP at `/.mcp`; writing it is what turns the endpoint on
94
+ type: object
95
+ properties:
96
+ name:
97
+ description: What the server calls itself
98
+ type: string
99
+ minLength: 1
100
+ instructions:
101
+ description: What a model is told before it calls anything here
102
+ type: string
103
+ origins:
104
+ description: Browser origins the endpoint answers; none without it
105
+ type: array
106
+ items:
107
+ type: string
108
+ pattern: ^https?://
109
+ anonymous:
110
+ description: Whether the endpoint answers without a credential
111
+ type: boolean
112
+ default: false
113
+ required:
114
+ - name
115
+ additionalProperties: false
83
116
  /: {}
84
117
  authorities:
85
118
  type: object
@@ -0,0 +1,18 @@
1
+ description: One JSON-RPC call, as the envelope carries it
2
+ properties:
3
+ jsonrpc:
4
+ const: '2.0'
5
+ method:
6
+ type: string
7
+ minLength: 1
8
+ params:
9
+ description: By name only, because `io:input` validates an object
10
+ type: object
11
+ id:
12
+ description: Absent makes the call a notification, which answers nothing
13
+ type: [string, number]
14
+ required:
15
+ - jsonrpc
16
+ - method
17
+ additionalProperties: false
18
+ type: object
@@ -26,6 +26,12 @@ export interface Annotation {
26
26
 
27
27
  /** The authorization server this context exposes; none is exposed without it. */
28
28
  oauth?: OAuth
29
+
30
+ /** JSON-RPC at `/.rpc`; none is served without it. See `documentation/rpc.md`. */
31
+ rpc?: RPC
32
+
33
+ /** MCP at `/.mcp`; none is served without it. See `documentation/mcp.md`. */
34
+ mcp?: MCP
29
35
  '/'?: object // parsed and validated by RTD.syntax.parse
30
36
  }
31
37
 
@@ -49,6 +55,31 @@ export interface OAuth {
49
55
  registration?: 'open' | 'closed'
50
56
  }
51
57
 
58
+ export interface RPC {
59
+ /**
60
+ * Calls one request may carry, 32 by default. One request is one authentication and one
61
+ * reply however many calls it makes, so what a caller may ask for at once is bounded.
62
+ */
63
+ batch?: number
64
+ }
65
+
66
+ export interface MCP {
67
+ /** What the server calls itself, which a client shows a user. */
68
+ name: string
69
+
70
+ /** What a model is told before it calls anything here. */
71
+ instructions?: string
72
+
73
+ /**
74
+ * Browser origins the endpoint answers, which the revision requires against DNS rebinding.
75
+ * None are admitted without it; a request carrying no `Origin` is not a browser's.
76
+ */
77
+ origins?: string[]
78
+
79
+ /** Whether the endpoint answers without a credential. It does not unless it says so. */
80
+ anonymous?: boolean
81
+ }
82
+
52
83
  export interface Bouncer {
53
84
  /** what an address may fail at once, 20 by default */
54
85
  attempts?: number
@@ -16,7 +16,7 @@ const families: Array<DirectiveFamily> = [
16
16
  mandatory: true,
17
17
  create: mock.fn((_0: any, _1: any, _2: any) => generate() as any),
18
18
  arrange: mock.fn(),
19
- preflight: mock.fn(() => { sequence.push('foo'); return null }),
19
+ precall: mock.fn(() => { sequence.push('foo'); return null }),
20
20
  settle: mock.fn(),
21
21
  dispose: mock.fn()
22
22
  },
@@ -25,7 +25,7 @@ const families: Array<DirectiveFamily> = [
25
25
  mandatory: true,
26
26
  create: mock.fn((_0: any, _1: any, _2: any) => generate() as any),
27
27
  arrange: mock.fn(),
28
- preflight: mock.fn(() => { sequence.push('qux'); return null }),
28
+ precall: mock.fn(() => { sequence.push('qux'); return null }),
29
29
  settle: mock.fn(),
30
30
  dispose: mock.fn()
31
31
  },
@@ -34,7 +34,7 @@ const families: Array<DirectiveFamily> = [
34
34
  mandatory: false,
35
35
  create: mock.fn((_0: string, _1: any, _2: any) => generate() as any),
36
36
  arrange: mock.fn(),
37
- preflight: mock.fn(() => { sequence.push('bar'); return null }),
37
+ precall: mock.fn(() => { sequence.push('bar'); return null }),
38
38
  settle: mock.fn(),
39
39
  dispose: mock.fn()
40
40
  }
@@ -47,9 +47,9 @@ beforeEach(() => {
47
47
  sequence.length = 0
48
48
 
49
49
  for (const family of families) {
50
- assert.ok(family.preflight !== undefined)
50
+ assert.ok(family.precall !== undefined)
51
51
 
52
- family.preflight.mock.mockImplementation(() => { sequence.push(family.name); return null })
52
+ family.precall.mock.mockImplementation(() => { sequence.push(family.name); return null })
53
53
  }
54
54
 
55
55
  factory = new DirectivesFactory(families, {} as unknown as Remotes, {} as unknown as Host,
@@ -110,25 +110,25 @@ it('should apply directive', async () => {
110
110
  const request = generate() as unknown as Context
111
111
  const directive = families[0].create.mock.calls[0].result
112
112
 
113
- await directives.preflight(request, [])
113
+ await directives.precall(request, [])
114
114
 
115
- assert.ok(families[0].preflight !== undefined)
115
+ assert.ok(families[0].precall !== undefined)
116
116
 
117
- assert.deepStrictEqual(families[0].preflight.mock.calls[0].arguments[0], [directive])
118
- assert.deepStrictEqual(families[0].preflight.mock.calls[0].arguments[1], request)
117
+ assert.deepStrictEqual(families[0].precall.mock.calls[0].arguments[0], [directive])
118
+ assert.deepStrictEqual(families[0].precall.mock.calls[0].arguments[1], request)
119
119
  })
120
120
 
121
121
  it('should apply mandatory families', async () => {
122
122
  const directives = factory.create([])
123
123
  const request = generate() as unknown as Context
124
124
 
125
- await directives.preflight(request, [])
125
+ await directives.precall(request, [])
126
126
 
127
- assert.ok(families[0].preflight.mock.callCount() > 0)
127
+ assert.ok(families[0].precall.mock.callCount() > 0)
128
128
  })
129
129
 
130
130
  describe('order', () => {
131
- // the order the families actually ran, as each preflight recorded it
131
+ // the order the families actually ran, as each precall recorded it
132
132
  function order (): string[] {
133
133
  return sequence
134
134
  }
@@ -140,7 +140,7 @@ describe('order', () => {
140
140
  { family: 'foo', name: generate(), value: generate() }
141
141
  ])
142
142
 
143
- await directives.preflight(generate() as unknown as Context, [])
143
+ await directives.precall(generate() as unknown as Context, [])
144
144
 
145
145
  assert.deepStrictEqual(order(), ['foo', 'qux'])
146
146
  })
@@ -153,7 +153,7 @@ describe('order', () => {
153
153
  { family: 'qux', name: generate(), value: generate() }
154
154
  ])
155
155
 
156
- await directives.preflight(generate() as unknown as Context, [])
156
+ await directives.precall(generate() as unknown as Context, [])
157
157
 
158
158
  assert.deepStrictEqual(order(), ['foo', 'qux'])
159
159
  })
@@ -164,7 +164,7 @@ describe('order', () => {
164
164
  { family: 'qux', name: generate(), value: generate() }
165
165
  ])
166
166
 
167
- await directives.preflight(generate() as unknown as Context, [])
167
+ await directives.precall(generate() as unknown as Context, [])
168
168
 
169
169
  assert.deepStrictEqual(order(), ['foo', 'qux', 'bar'])
170
170
  })
@@ -3,6 +3,7 @@ import type { Context, OutgoingMessage, Options } from './HTTP/index.js'
3
3
  import type { Remotes } from './Remotes.js'
4
4
  import type { Host } from './Factory.js'
5
5
  import type { Output } from './io.js'
6
+ import type { Introspection } from './Introspection.js'
6
7
  import type * as RTD from './RTD/index.js'
7
8
 
8
9
  export class Directives implements RTD.Directives {
@@ -14,28 +15,33 @@ export class Directives implements RTD.Directives {
14
15
  public constructor (sets: RTD.DirectiveSet[]) {
15
16
  this.sets = sets
16
17
  this.spans = sets.map((set) => ({
17
- preflight: options(set, 'preflight'),
18
- settle: options(set, 'settle')
18
+ precall: options(set, 'precall'),
19
+ settle: options(set, 'settle'),
20
+ explain: options(set, 'explain')
19
21
  }))
20
22
  }
21
23
 
22
- public async preflight (context: Context, parameters: RTD.Parameter[]): Promise<Output> {
24
+ public declared<T> (family: string): T[] | undefined {
25
+ return this.sets.find((set) => set.family.name === family)?.directives as T[] | undefined
26
+ }
27
+
28
+ public async precall (context: Context, parameters: RTD.Parameter[]): Promise<Output> {
23
29
  let output = null
24
30
 
25
31
  for (let i = 0; i < this.sets.length; i++) {
26
32
  const set = this.sets[i]
27
33
 
28
- if (set.family.preflight === undefined)
34
+ if (set.family.precall === undefined)
29
35
  continue
30
36
 
31
- const out = await console.span(this.spans[i].preflight,
32
- async () => await set.family.preflight!(set.directives, context, parameters))
37
+ const out = await console.span(this.spans[i].precall,
38
+ async () => await set.family.precall!(set.directives, context, parameters))
33
39
 
34
40
  if (out === null)
35
41
  continue
36
42
 
37
43
  if (output !== null)
38
- throw new Error('Multiple preflight directives responded')
44
+ throw new Error('Multiple precall directives responded')
39
45
  else
40
46
  output = out
41
47
  }
@@ -43,6 +49,33 @@ export class Directives implements RTD.Directives {
43
49
  return output
44
50
  }
45
51
 
52
+ /**
53
+ * What the method says about itself, as its directives leave it. Each family is given
54
+ * what the one before it returned, and the first to refuse ends it: a method this caller
55
+ * cannot reach is not described at all.
56
+ */
57
+ public async explain (context: Context,
58
+ introspection: Introspection): Promise<Introspection | null> {
59
+ let described: Introspection = introspection
60
+
61
+ for (let i = 0; i < this.sets.length; i++) {
62
+ const set = this.sets[i]
63
+
64
+ if (set.family.explain === undefined)
65
+ continue
66
+
67
+ const next = await console.span(this.spans[i].explain,
68
+ async () => await set.family.explain!(set.directives, context, described))
69
+
70
+ if (next === null)
71
+ return null
72
+
73
+ described = next
74
+ }
75
+
76
+ return described
77
+ }
78
+
46
79
  public async settle (context: Context, response: OutgoingMessage): Promise<void> {
47
80
  for (let i = 0; i < this.sets.length; i++) {
48
81
  const set = this.sets[i]
@@ -65,6 +98,9 @@ export class DirectivesFactory implements RTD.DirectiveFactory {
65
98
  private readonly mandatory: string[] = []
66
99
  private readonly instances: Directives[] = []
67
100
 
101
+ /** The request-scoped stages, in registration order, with the spans they run in. */
102
+ private readonly stages: Stage[] = []
103
+
68
104
  // eslint-disable-next-line max-params
69
105
  public constructor (families: RTD.DirectiveFamily[], remotes: Remotes, host: Host,
70
106
  options: Options) {
@@ -74,11 +110,36 @@ export class DirectivesFactory implements RTD.DirectiveFactory {
74
110
 
75
111
  if (family.mandatory)
76
112
  this.mandatory.push(family.name)
113
+
114
+ this.stages.push({
115
+ family,
116
+ preflight: { name: `${family.name} preflight` },
117
+ depart: { name: `${family.name} depart` }
118
+ })
77
119
  }
78
120
 
79
121
  this.remotes = remotes
80
122
  }
81
123
 
124
+ /**
125
+ * Request-scoped, before anything is routed, so no directives are passed: a family
126
+ * answers here only for what it does on its own behalf.
127
+ */
128
+ public async preflight (context: Context): Promise<void> {
129
+ for (const stage of this.stages)
130
+ if (stage.family.preflight !== undefined)
131
+ await console.span(stage.preflight,
132
+ async () => { await stage.family.preflight!(context) })
133
+ }
134
+
135
+ /** Request-scoped, on the message going back. */
136
+ public async depart (context: Context, response: OutgoingMessage): Promise<void> {
137
+ for (const stage of this.stages)
138
+ if (stage.family.depart !== undefined)
139
+ await console.span(stage.depart,
140
+ async () => { await stage.family.depart!(context, response) })
141
+ }
142
+
82
143
  public create (declarations: RTD.syntax.Directive[], route: string = ''): Directives {
83
144
  const groups: Record<string, any> = {}
84
145
  const mandatory = new Set(this.mandatory)
@@ -146,7 +207,7 @@ export class DirectivesFactory implements RTD.DirectiveFactory {
146
207
  }
147
208
  }
148
209
 
149
- function options (set: RTD.DirectiveSet, stage: 'preflight' | 'settle'): SpanOptions {
210
+ function options (set: RTD.DirectiveSet, stage: 'precall' | 'settle' | 'explain'): SpanOptions {
150
211
  const options: SpanOptions = { name: `${set.family.name} ${stage}` }
151
212
 
152
213
  if (set.names !== undefined && set.names.length > 0)
@@ -156,8 +217,15 @@ function options (set: RTD.DirectiveSet, stage: 'preflight' | 'settle'): SpanOpt
156
217
  }
157
218
 
158
219
  interface Spans {
159
- preflight: SpanOptions
220
+ precall: SpanOptions
160
221
  settle: SpanOptions
222
+ explain: SpanOptions
223
+ }
224
+
225
+ interface Stage {
226
+ family: RTD.DirectiveFamily
227
+ preflight: SpanOptions
228
+ depart: SpanOptions
161
229
  }
162
230
 
163
231
  export const shortcuts: RTD.syntax.Shortcuts = new Map([
@@ -0,0 +1,67 @@
1
+ import { describe, it } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+
4
+ import { Endpoint } from './Endpoint.js'
5
+ import { Mapping } from './Mapping.js'
6
+ import type { Remote } from '@toa.io/core'
7
+ import type { Parameter } from './RTD/index.js'
8
+
9
+ /**
10
+ * What `Remote.explain` answers is the contract's own object, the same one every time and
11
+ * on every route that mounts the endpoint — which is what this stands in for.
12
+ */
13
+ function remote (): Promise<Remote> {
14
+ const explanation = {
15
+ input: {
16
+ type: 'object',
17
+ properties: {
18
+ a: { type: 'string' },
19
+ b: { type: 'string' }
20
+ },
21
+ required: ['a', 'b']
22
+ },
23
+ output: null
24
+ }
25
+
26
+ return Promise.resolve({
27
+ explain: async () => explanation
28
+ } as unknown as Remote)
29
+ }
30
+
31
+ const endpoint = (discovery: Promise<Remote>): Endpoint =>
32
+ new Endpoint('parameters', Mapping.create(), discovery)
33
+
34
+ const variable: Parameter[] = [{ name: 'a', value: 'a1b2' }]
35
+
36
+ describe('explain', () => {
37
+ it('should state a route variable as the route, not as the input', async () => {
38
+ const introspection = await endpoint(remote()).explain(variable)
39
+
40
+ assert.deepEqual(Object.keys(introspection.route ?? {}), ['a'])
41
+ assert.deepEqual(Object.keys((introspection.input as any).properties), ['b'])
42
+ assert.deepEqual((introspection.input as any).required, ['b'])
43
+ })
44
+
45
+ it('should leave the operation for the next route that mounts it', async () => {
46
+ const discovery = remote()
47
+
48
+ await endpoint(discovery).explain(variable)
49
+
50
+ // a second route on the same endpoint, taking no variable of its own
51
+ const introspection = await endpoint(discovery).explain([])
52
+
53
+ assert.deepEqual(Object.keys((introspection.input as any).properties), ['a', 'b'])
54
+ assert.deepEqual((introspection.input as any).required, ['a', 'b'])
55
+ })
56
+
57
+ it('should answer a copy, so what one caller narrows the next still sees', async () => {
58
+ const one = endpoint(remote())
59
+ const first = await one.explain(variable)
60
+
61
+ delete (first.input as any).properties.b
62
+
63
+ const second = await one.explain(variable)
64
+
65
+ assert.deepEqual(Object.keys((second.input as any).properties), ['b'])
66
+ })
67
+ })
@@ -1,6 +1,7 @@
1
1
  import { Readable } from 'node:stream'
2
2
  import { console } from 'openspan'
3
3
  import { Mapping } from './Mapping.js'
4
+ import { take } from './Introspection.js'
4
5
  import { redact } from './redact.js'
5
6
  import * as http from './HTTP/index.js'
6
7
  import type { Introspection, Schema } from './Introspection.js'
@@ -15,6 +16,9 @@ export class Endpoint implements RTD.Endpoint {
15
16
  private readonly discovery: Promise<Remote>
16
17
  private remote: Remote | null = null
17
18
 
19
+ /** What the operation says, with what the route takes already split out of it. */
20
+ private introspection: Introspection | null = null
21
+
18
22
  public constructor (endpoint: string, mapping: Mapping, discovery: Promise<Remote>) {
19
23
  this.endpoint = endpoint
20
24
  this.mapping = mapping
@@ -65,24 +69,40 @@ export class Endpoint implements RTD.Endpoint {
65
69
  }
66
70
 
67
71
  public async explain (parameters: RTD.Parameter[]): Promise<Introspection> {
72
+ this.introspection ??= await this.introspect(parameters)
73
+
74
+ // what a directive narrows is this caller's answer, not the next caller's
75
+ return structuredClone(this.introspection)
76
+ }
77
+
78
+ /**
79
+ * `Remote.explain` answers the contract's own object, whose `input` is the manifest's by
80
+ * reference. What follows takes properties out of it, and two routes mounting one endpoint
81
+ * share one remote — so the copy is what keeps the second from describing what the first
82
+ * took away.
83
+ */
84
+ private async introspect (parameters: RTD.Parameter[]): Promise<Introspection> {
68
85
  this.remote ??= await this.discovery
69
86
 
70
- const operation = await this.remote.explain(this.endpoint)
87
+ const operation = structuredClone(await this.remote.explain(this.endpoint))
88
+
89
+ // what the operation states it is, is the Introspection's to read and not a resource's:
90
+ // an operation is written without knowledge of any route, and the same one mounted twice
91
+ // is two methods. What a method states is what its route states, which `mcp:tool` gives.
92
+ delete operation.description
71
93
 
72
94
  let route: Record<string, Schema> | null = null
73
95
 
74
- if (operation.input?.type === 'object')
75
- for (const parameter of parameters) {
76
- const schema = operation.input.properties[parameter.name]
96
+ // a variable the operation names is taken by the path, so it is not the body's to send
97
+ for (const parameter of parameters) {
98
+ const schema = take(operation, parameter.name)
77
99
 
78
- // eslint-disable-next-line max-depth
79
- if (schema !== undefined) {
80
- route ??= {}
81
- route[parameter.name] = schema
100
+ if (schema === undefined)
101
+ continue
82
102
 
83
- delete operation.input.properties[parameter.name]
84
- }
85
- }
103
+ route ??= {}
104
+ route[parameter.name] = schema
105
+ }
86
106
 
87
107
  const query = this.mapping.explain(operation)
88
108
  const introspection: Introspection = {}
package/source/Factory.ts CHANGED
@@ -12,6 +12,8 @@ import { Composition } from './Composition.js'
12
12
  import * as root from './root.js'
13
13
  import { ATOM_GROUP } from './const.js'
14
14
  import { Interception } from './Interception.js'
15
+ import { Dispatcher } from './RPC/index.js'
16
+ import { Server as Model } from './MCP/index.js'
15
17
  import * as http from './HTTP/index.js'
16
18
  import type { Branch } from './Branch.js'
17
19
  import type { syntax } from './RTD/index.js'
@@ -58,7 +60,9 @@ export class Factory implements extensions.Factory {
58
60
  const tree = new Tree(node, methods, directives)
59
61
 
60
62
  const composition = new Composition(this.host)
61
- const gateway = new Gateway(broadcast, tree, interception)
63
+ const dispatcher = options.rpc === undefined ? null : new Dispatcher(options.rpc)
64
+ const mcp = options.mcp === undefined ? null : new Model(options.mcp, tree)
65
+ const gateway = new Gateway(broadcast, tree, interception, directives, dispatcher, mcp)
62
66
 
63
67
  gateway.depends(remotes)
64
68
  gateway.depends(composition)