@toa.io/extensions.exposition 1.0.0-alpha.0 → 1.0.0-alpha.10

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 (547) hide show
  1. package/components/context.toa.yaml +12 -0
  2. package/components/identity.bans/manifest.toa.yaml +2 -1
  3. package/components/identity.basic/manifest.toa.yaml +6 -2
  4. package/components/identity.basic/operations/authenticate.d.ts +9 -0
  5. package/components/identity.basic/operations/authenticate.js +24 -0
  6. package/components/identity.basic/operations/authenticate.js.map +1 -0
  7. package/components/identity.basic/operations/create.d.ts +10 -0
  8. package/components/identity.basic/operations/create.js +10 -0
  9. package/components/identity.basic/operations/create.js.map +1 -0
  10. package/components/identity.basic/operations/transit.d.ts +12 -0
  11. package/components/identity.basic/operations/transit.js +53 -0
  12. package/components/identity.basic/operations/transit.js.map +1 -0
  13. package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -0
  14. package/components/identity.basic/operations/types.d.ts +38 -0
  15. package/components/identity.basic/operations/types.js +3 -0
  16. package/components/identity.basic/operations/types.js.map +1 -0
  17. package/components/identity.basic/source/authenticate.ts +0 -1
  18. package/components/identity.federation/events/principal.js +22 -0
  19. package/components/identity.federation/manifest.toa.yaml +94 -0
  20. package/components/identity.federation/operations/authenticate.d.ts +3 -0
  21. package/components/identity.federation/operations/authenticate.js +20 -0
  22. package/components/identity.federation/operations/authenticate.js.map +1 -0
  23. package/components/identity.federation/operations/create.d.ts +10 -0
  24. package/components/identity.federation/operations/create.js +15 -0
  25. package/components/identity.federation/operations/create.js.map +1 -0
  26. package/components/identity.federation/operations/lib/assertions-as-values.d.ts +4 -0
  27. package/components/identity.federation/operations/lib/assertions-as-values.js +45 -0
  28. package/components/identity.federation/operations/lib/assertions-as-values.js.map +1 -0
  29. package/components/identity.federation/operations/lib/jwt.d.ts +20 -0
  30. package/components/identity.federation/operations/lib/jwt.js +136 -0
  31. package/components/identity.federation/operations/lib/jwt.js.map +1 -0
  32. package/components/identity.federation/operations/schemas.d.ts +59 -0
  33. package/components/identity.federation/operations/schemas.js +9 -0
  34. package/components/identity.federation/operations/schemas.js.map +1 -0
  35. package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -0
  36. package/components/identity.federation/operations/types.d.ts +51 -0
  37. package/components/identity.federation/operations/types.js +3 -0
  38. package/components/identity.federation/operations/types.js.map +1 -0
  39. package/components/identity.federation/source/authenticate.ts +28 -0
  40. package/components/identity.federation/source/create.ts +26 -0
  41. package/components/identity.federation/source/lib/assertions-as-values.ts +19 -0
  42. package/components/identity.federation/source/lib/jwt.test.ts +56 -0
  43. package/components/identity.federation/source/lib/jwt.ts +171 -0
  44. package/components/identity.federation/source/schemas.ts +61 -0
  45. package/components/identity.federation/source/types.ts +56 -0
  46. package/components/identity.federation/tsconfig.json +9 -0
  47. package/components/identity.roles/manifest.toa.yaml +17 -5
  48. package/components/identity.roles/operations/grant.d.ts +10 -0
  49. package/components/identity.roles/operations/grant.js +20 -0
  50. package/components/identity.roles/operations/grant.js.map +1 -0
  51. package/components/identity.roles/operations/lib/Entity.d.ts +5 -0
  52. package/components/identity.roles/operations/lib/Entity.js +3 -0
  53. package/components/identity.roles/operations/lib/Entity.js.map +1 -0
  54. package/components/identity.roles/operations/list.d.ts +2 -0
  55. package/components/identity.roles/operations/list.js +8 -0
  56. package/components/identity.roles/operations/list.js.map +1 -0
  57. package/components/identity.roles/operations/principal.d.ts +13 -0
  58. package/components/identity.roles/operations/principal.js +13 -0
  59. package/components/identity.roles/operations/principal.js.map +1 -0
  60. package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -0
  61. package/components/identity.roles/source/grant.ts +31 -0
  62. package/components/identity.roles/source/lib/Entity.ts +5 -0
  63. package/components/identity.roles/source/list.ts +2 -4
  64. package/components/identity.roles/source/principal.ts +10 -8
  65. package/components/identity.tokens/manifest.toa.yaml +1 -1
  66. package/components/identity.tokens/operations/authenticate.d.ts +9 -0
  67. package/components/identity.tokens/operations/authenticate.js +32 -0
  68. package/components/identity.tokens/operations/authenticate.js.map +1 -0
  69. package/components/identity.tokens/operations/decrypt.d.ts +3 -0
  70. package/components/identity.tokens/operations/decrypt.js +32 -0
  71. package/components/identity.tokens/operations/decrypt.js.map +1 -0
  72. package/components/identity.tokens/operations/encrypt.d.ts +8 -0
  73. package/components/identity.tokens/operations/encrypt.js +22 -0
  74. package/components/identity.tokens/operations/encrypt.js.map +1 -0
  75. package/components/identity.tokens/operations/revoke.d.ts +2 -0
  76. package/components/identity.tokens/operations/revoke.js +8 -0
  77. package/components/identity.tokens/operations/revoke.js.map +1 -0
  78. package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -0
  79. package/components/identity.tokens/operations/types.d.ts +40 -0
  80. package/components/identity.tokens/operations/types.js +3 -0
  81. package/components/identity.tokens/operations/types.js.map +1 -0
  82. package/components/octets.storage/manifest.toa.yaml +1 -0
  83. package/components/octets.storage/operations/store.js +3 -3
  84. package/cucumber.js +0 -1
  85. package/documentation/access.md +11 -11
  86. package/documentation/components.md +49 -13
  87. package/documentation/identity.md +14 -7
  88. package/documentation/io.md +56 -0
  89. package/documentation/octets.md +105 -40
  90. package/documentation/protocol.md +21 -1
  91. package/documentation/query.md +51 -6
  92. package/documentation/tree.md +22 -4
  93. package/documentation/vary.md +69 -0
  94. package/features/access.feature +13 -2
  95. package/features/annotation.feature +1 -0
  96. package/features/body.feature +3 -1
  97. package/features/cache.feature +3 -0
  98. package/features/cors.feature +72 -0
  99. package/features/directives.feature +2 -0
  100. package/features/dynamic.feature +14 -7
  101. package/features/errors.feature +4 -3
  102. package/features/etag.feature +97 -0
  103. package/features/identity.basic.feature +68 -0
  104. package/features/identity.feature +19 -3
  105. package/features/identity.federation.feature +153 -0
  106. package/features/identity.roles.feature +151 -0
  107. package/features/identity.tokens.feature +3 -0
  108. package/features/io.feature +167 -0
  109. package/features/octets.entries.feature +123 -0
  110. package/features/octets.feature +4 -28
  111. package/features/octets.meta.feature +66 -0
  112. package/features/octets.workflows.feature +177 -4
  113. package/features/queries.feature +9 -1
  114. package/features/response.feature +68 -0
  115. package/features/routes.feature +54 -10
  116. package/features/steps/Captures.ts +6 -0
  117. package/features/steps/Components.ts +18 -6
  118. package/features/steps/Database.ts +1 -1
  119. package/features/steps/Gateway.ts +4 -2
  120. package/features/steps/HTTP.ts +40 -87
  121. package/features/steps/IdP.ts +149 -0
  122. package/features/steps/Parameters.ts +8 -2
  123. package/features/steps/Workspace.ts +5 -7
  124. package/features/steps/components/echo/manifest.toa.yaml +1 -0
  125. package/features/steps/components/echo/operations/error.js +11 -0
  126. package/features/steps/components/greeter/manifest.toa.yaml +1 -0
  127. package/features/steps/components/octets.tester/manifest.toa.yaml +4 -0
  128. package/features/steps/components/octets.tester/operations/concat.js +7 -0
  129. package/features/steps/components/octets.tester/operations/echo.js +7 -0
  130. package/features/steps/components/pots/manifest.toa.yaml +12 -3
  131. package/features/steps/components/sequences/manifest.toa.yaml +1 -0
  132. package/features/steps/components/users/manifest.toa.yaml +4 -0
  133. package/features/steps/components/users.properties/manifest.toa.yaml +14 -0
  134. package/features/steps/tsconfig.json +1 -1
  135. package/features/timing.feature +66 -0
  136. package/features/vary.feature +180 -0
  137. package/package.json +16 -20
  138. package/readme.md +7 -6
  139. package/schemas/annotation.cos.yaml +1 -0
  140. package/schemas/io/input.cos.yaml +3 -0
  141. package/schemas/io/message.cos.yaml +5 -0
  142. package/schemas/io/output.cos.yaml +5 -0
  143. package/schemas/octets/delete.cos.yaml +2 -1
  144. package/schemas/octets/list.cos.yaml +2 -1
  145. package/schemas/octets/workflow.cos.yaml +12 -0
  146. package/schemas/querystring.cos.yaml +1 -0
  147. package/source/Annotation.ts +1 -0
  148. package/source/Context.ts +6 -4
  149. package/source/Directive.test.ts +14 -8
  150. package/source/Directive.ts +26 -49
  151. package/source/Endpoint.ts +53 -6
  152. package/source/Factory.ts +23 -12
  153. package/source/Gateway.ts +45 -42
  154. package/source/HTTP/Context.ts +67 -0
  155. package/source/HTTP/Server.test.ts +61 -134
  156. package/source/HTTP/Server.ts +96 -87
  157. package/source/HTTP/Timing.ts +40 -0
  158. package/source/HTTP/formats/msgpack.ts +9 -6
  159. package/source/HTTP/formats/text.ts +1 -1
  160. package/source/HTTP/formats/yaml.ts +1 -1
  161. package/source/HTTP/index.ts +1 -0
  162. package/source/HTTP/messages.test.ts +27 -8
  163. package/source/HTTP/messages.ts +38 -42
  164. package/source/Interception.ts +24 -0
  165. package/source/Mapping.ts +7 -8
  166. package/source/RTD/Context.ts +7 -10
  167. package/source/RTD/Directives.ts +28 -4
  168. package/source/RTD/Endpoint.ts +6 -4
  169. package/source/RTD/Match.ts +2 -7
  170. package/source/RTD/Method.ts +7 -13
  171. package/source/RTD/Node.ts +13 -14
  172. package/source/RTD/Tree.ts +19 -15
  173. package/source/RTD/factory.ts +2 -5
  174. package/source/RTD/syntax/parse.ts +6 -6
  175. package/source/RTD/syntax/types.ts +1 -1
  176. package/source/deployment.ts +7 -2
  177. package/source/directives/auth/Anonymous.ts +3 -2
  178. package/source/directives/auth/{Family.ts → Authorization.ts} +39 -40
  179. package/source/directives/auth/Delegate.ts +32 -0
  180. package/source/directives/auth/Incept.ts +11 -6
  181. package/source/directives/auth/Role.ts +5 -3
  182. package/source/directives/auth/Rule.ts +2 -2
  183. package/source/directives/auth/Scheme.ts +2 -2
  184. package/source/directives/auth/index.ts +2 -2
  185. package/source/directives/auth/schemes.ts +2 -1
  186. package/source/directives/auth/types.ts +9 -6
  187. package/source/directives/cache/{Family.ts → Cache.ts} +6 -7
  188. package/source/directives/cache/Control.ts +5 -5
  189. package/source/directives/cache/index.ts +2 -2
  190. package/source/directives/cache/types.ts +2 -2
  191. package/source/directives/cors/CORS.ts +62 -0
  192. package/source/directives/cors/index.ts +3 -0
  193. package/source/directives/dev/{Family.ts → Development.ts} +4 -5
  194. package/source/directives/dev/Stub.ts +4 -4
  195. package/source/directives/dev/Throw.ts +4 -4
  196. package/source/directives/dev/index.ts +2 -2
  197. package/source/directives/dev/types.ts +1 -1
  198. package/source/directives/index.ts +11 -6
  199. package/source/directives/io/Directive.ts +11 -0
  200. package/source/directives/io/IO.ts +43 -0
  201. package/source/directives/io/Input.ts +50 -0
  202. package/source/directives/io/Message.ts +1 -0
  203. package/source/directives/io/Output.ts +69 -0
  204. package/source/directives/io/index.ts +3 -0
  205. package/source/directives/io/schemas.ts +12 -0
  206. package/source/directives/octets/Context.ts +6 -5
  207. package/source/directives/octets/Delete.ts +64 -11
  208. package/source/directives/octets/Directive.ts +10 -0
  209. package/source/directives/octets/Fetch.ts +44 -29
  210. package/source/directives/octets/List.ts +50 -10
  211. package/source/directives/octets/{Family.ts → Octets.ts} +14 -9
  212. package/source/directives/octets/Permute.ts +18 -11
  213. package/source/directives/octets/Store.ts +70 -102
  214. package/source/directives/octets/Workflow.ts +48 -0
  215. package/source/directives/octets/index.ts +2 -2
  216. package/source/directives/octets/schemas.test.ts +21 -0
  217. package/source/directives/octets/schemas.ts +13 -6
  218. package/source/directives/octets/types.ts +2 -8
  219. package/source/directives/octets/workflows/Execution.ts +76 -0
  220. package/source/directives/octets/workflows/Workflow.ts +37 -0
  221. package/source/directives/octets/workflows/index.ts +1 -0
  222. package/source/directives/vary/Directive.ts +6 -0
  223. package/source/directives/vary/Embed.ts +62 -0
  224. package/source/directives/vary/Properties.ts +17 -0
  225. package/source/directives/vary/Vary.ts +48 -0
  226. package/source/directives/vary/embeddings/Embedding.ts +6 -0
  227. package/source/directives/vary/embeddings/Header.ts +32 -0
  228. package/source/directives/vary/embeddings/Language.ts +31 -0
  229. package/source/directives/vary/embeddings/index.ts +11 -0
  230. package/source/directives/vary/index.ts +3 -0
  231. package/source/exceptions.ts +13 -9
  232. package/source/io.ts +4 -0
  233. package/source/manifest.test.ts +6 -14
  234. package/source/manifest.ts +9 -6
  235. package/source/root.ts +5 -0
  236. package/source/schemas.ts +7 -3
  237. package/transpiled/Annotation.d.ts +8 -0
  238. package/transpiled/Annotation.js +3 -0
  239. package/transpiled/Annotation.js.map +1 -0
  240. package/transpiled/Branch.d.ts +7 -0
  241. package/transpiled/Branch.js +3 -0
  242. package/transpiled/Branch.js.map +1 -0
  243. package/transpiled/Composition.d.ts +14 -0
  244. package/transpiled/Composition.js +43 -0
  245. package/transpiled/Composition.js.map +1 -0
  246. package/transpiled/Context.d.ts +7 -0
  247. package/transpiled/Context.js +3 -0
  248. package/transpiled/Context.js.map +1 -0
  249. package/transpiled/Directive.d.ts +18 -0
  250. package/transpiled/Directive.js +75 -0
  251. package/transpiled/Directive.js.map +1 -0
  252. package/transpiled/Endpoint.d.ts +22 -0
  253. package/transpiled/Endpoint.js +101 -0
  254. package/transpiled/Endpoint.js.map +1 -0
  255. package/transpiled/Factory.d.ts +9 -0
  256. package/transpiled/Factory.js +73 -0
  257. package/transpiled/Factory.js.map +1 -0
  258. package/transpiled/Gateway.d.ts +18 -0
  259. package/transpiled/Gateway.js +92 -0
  260. package/transpiled/Gateway.js.map +1 -0
  261. package/transpiled/HTTP/Context.d.ts +24 -0
  262. package/transpiled/HTTP/Context.js +47 -0
  263. package/transpiled/HTTP/Context.js.map +1 -0
  264. package/transpiled/HTTP/Server.d.ts +25 -0
  265. package/transpiled/HTTP/Server.js +141 -0
  266. package/transpiled/HTTP/Server.js.map +1 -0
  267. package/transpiled/HTTP/Timing.d.ts +10 -0
  268. package/transpiled/HTTP/Timing.js +29 -0
  269. package/transpiled/HTTP/Timing.js.map +1 -0
  270. package/transpiled/HTTP/exceptions.d.ts +34 -0
  271. package/transpiled/HTTP/exceptions.js +71 -0
  272. package/transpiled/HTTP/exceptions.js.map +1 -0
  273. package/transpiled/HTTP/formats/index.d.ts +10 -0
  274. package/transpiled/HTTP/formats/index.js +38 -0
  275. package/transpiled/HTTP/formats/index.js.map +1 -0
  276. package/transpiled/HTTP/formats/json.d.ts +6 -0
  277. package/transpiled/HTTP/formats/json.js +17 -0
  278. package/transpiled/HTTP/formats/json.js.map +1 -0
  279. package/transpiled/HTTP/formats/msgpack.d.ts +6 -0
  280. package/transpiled/HTTP/formats/msgpack.js +17 -0
  281. package/transpiled/HTTP/formats/msgpack.js.map +1 -0
  282. package/transpiled/HTTP/formats/text.d.ts +8 -0
  283. package/transpiled/HTTP/formats/text.js +15 -0
  284. package/transpiled/HTTP/formats/text.js.map +1 -0
  285. package/transpiled/HTTP/formats/yaml.d.ts +6 -0
  286. package/transpiled/HTTP/formats/yaml.js +41 -0
  287. package/transpiled/HTTP/formats/yaml.js.map +1 -0
  288. package/transpiled/HTTP/index.d.ts +4 -0
  289. package/transpiled/HTTP/index.js +21 -0
  290. package/transpiled/HTTP/index.js.map +1 -0
  291. package/transpiled/HTTP/messages.d.ts +19 -0
  292. package/transpiled/HTTP/messages.js +73 -0
  293. package/transpiled/HTTP/messages.js.map +1 -0
  294. package/transpiled/Interception.d.ts +9 -0
  295. package/transpiled/Interception.js +19 -0
  296. package/transpiled/Interception.js.map +1 -0
  297. package/transpiled/Mapping.d.ts +8 -0
  298. package/transpiled/Mapping.js +38 -0
  299. package/transpiled/Mapping.js.map +1 -0
  300. package/transpiled/Query.d.ts +13 -0
  301. package/transpiled/Query.js +107 -0
  302. package/transpiled/Query.js.map +1 -0
  303. package/transpiled/RTD/Context.d.ts +12 -0
  304. package/transpiled/RTD/Context.js +3 -0
  305. package/transpiled/RTD/Context.js.map +1 -0
  306. package/transpiled/RTD/Directives.d.ts +22 -0
  307. package/transpiled/RTD/Directives.js +3 -0
  308. package/transpiled/RTD/Directives.js.map +1 -0
  309. package/transpiled/RTD/Endpoint.d.ts +11 -0
  310. package/transpiled/RTD/Endpoint.js +3 -0
  311. package/transpiled/RTD/Endpoint.js.map +1 -0
  312. package/transpiled/RTD/Match.d.ts +9 -0
  313. package/transpiled/RTD/Match.js +3 -0
  314. package/transpiled/RTD/Match.js.map +1 -0
  315. package/transpiled/RTD/Method.d.ts +9 -0
  316. package/transpiled/RTD/Method.js +16 -0
  317. package/transpiled/RTD/Method.js.map +1 -0
  318. package/transpiled/RTD/Node.d.ts +19 -0
  319. package/transpiled/RTD/Node.js +62 -0
  320. package/transpiled/RTD/Node.js.map +1 -0
  321. package/transpiled/RTD/Route.d.ts +14 -0
  322. package/transpiled/RTD/Route.js +49 -0
  323. package/transpiled/RTD/Route.js.map +1 -0
  324. package/transpiled/RTD/Tree.d.ts +14 -0
  325. package/transpiled/RTD/Tree.js +45 -0
  326. package/transpiled/RTD/Tree.js.map +1 -0
  327. package/transpiled/RTD/factory.d.ts +4 -0
  328. package/transpiled/RTD/factory.js +36 -0
  329. package/transpiled/RTD/factory.js.map +1 -0
  330. package/transpiled/RTD/index.d.ts +8 -0
  331. package/transpiled/RTD/index.js +38 -0
  332. package/transpiled/RTD/index.js.map +1 -0
  333. package/transpiled/RTD/segment.d.ts +8 -0
  334. package/transpiled/RTD/segment.js +25 -0
  335. package/transpiled/RTD/segment.js.map +1 -0
  336. package/transpiled/RTD/syntax/index.d.ts +2 -0
  337. package/transpiled/RTD/syntax/index.js +19 -0
  338. package/transpiled/RTD/syntax/index.js.map +1 -0
  339. package/transpiled/RTD/syntax/parse.d.ts +4 -0
  340. package/transpiled/RTD/syntax/parse.js +128 -0
  341. package/transpiled/RTD/syntax/parse.js.map +1 -0
  342. package/transpiled/RTD/syntax/types.d.ts +41 -0
  343. package/transpiled/RTD/syntax/types.js +5 -0
  344. package/transpiled/RTD/syntax/types.js.map +1 -0
  345. package/transpiled/Remotes.d.ts +9 -0
  346. package/transpiled/Remotes.js +25 -0
  347. package/transpiled/Remotes.js.map +1 -0
  348. package/transpiled/Tenant.d.ts +13 -0
  349. package/transpiled/Tenant.js +34 -0
  350. package/transpiled/Tenant.js.map +1 -0
  351. package/transpiled/deployment.d.ts +3 -0
  352. package/transpiled/deployment.js +71 -0
  353. package/transpiled/deployment.js.map +1 -0
  354. package/transpiled/directives/auth/Anonymous.d.ts +6 -0
  355. package/transpiled/directives/auth/Anonymous.js +16 -0
  356. package/transpiled/directives/auth/Anonymous.js.map +1 -0
  357. package/transpiled/directives/auth/Authorization.d.ts +19 -0
  358. package/transpiled/directives/auth/Authorization.js +127 -0
  359. package/transpiled/directives/auth/Authorization.js.map +1 -0
  360. package/transpiled/directives/auth/Delegate.d.ts +8 -0
  361. package/transpiled/directives/auth/Delegate.js +27 -0
  362. package/transpiled/directives/auth/Delegate.js.map +1 -0
  363. package/transpiled/directives/auth/Echo.d.ts +6 -0
  364. package/transpiled/directives/auth/Echo.js +13 -0
  365. package/transpiled/directives/auth/Echo.js.map +1 -0
  366. package/transpiled/directives/auth/Id.d.ts +7 -0
  367. package/transpiled/directives/auth/Id.js +17 -0
  368. package/transpiled/directives/auth/Id.js.map +1 -0
  369. package/transpiled/directives/auth/Incept.d.ts +10 -0
  370. package/transpiled/directives/auth/Incept.js +63 -0
  371. package/transpiled/directives/auth/Incept.js.map +1 -0
  372. package/transpiled/directives/auth/Role.d.ts +11 -0
  373. package/transpiled/directives/auth/Role.js +46 -0
  374. package/transpiled/directives/auth/Role.js.map +1 -0
  375. package/transpiled/directives/auth/Rule.d.ts +9 -0
  376. package/transpiled/directives/auth/Rule.js +22 -0
  377. package/transpiled/directives/auth/Rule.js.map +1 -0
  378. package/transpiled/directives/auth/Scheme.d.ts +7 -0
  379. package/transpiled/directives/auth/Scheme.js +47 -0
  380. package/transpiled/directives/auth/Scheme.js.map +1 -0
  381. package/transpiled/directives/auth/index.d.ts +2 -0
  382. package/transpiled/directives/auth/index.js +6 -0
  383. package/transpiled/directives/auth/index.js.map +1 -0
  384. package/transpiled/directives/auth/schemes.d.ts +3 -0
  385. package/transpiled/directives/auth/schemes.js +10 -0
  386. package/transpiled/directives/auth/schemes.js.map +1 -0
  387. package/transpiled/directives/auth/split.d.ts +2 -0
  388. package/transpiled/directives/auth/split.js +38 -0
  389. package/transpiled/directives/auth/split.js.map +1 -0
  390. package/transpiled/directives/auth/types.d.ts +31 -0
  391. package/transpiled/directives/auth/types.js +3 -0
  392. package/transpiled/directives/auth/types.js.map +1 -0
  393. package/transpiled/directives/cache/Cache.d.ts +11 -0
  394. package/transpiled/directives/cache/Cache.js +28 -0
  395. package/transpiled/directives/cache/Cache.js.map +1 -0
  396. package/transpiled/directives/cache/Control.d.ts +9 -0
  397. package/transpiled/directives/cache/Control.js +42 -0
  398. package/transpiled/directives/cache/Control.js.map +1 -0
  399. package/transpiled/directives/cache/Exact.d.ts +4 -0
  400. package/transpiled/directives/cache/Exact.js +11 -0
  401. package/transpiled/directives/cache/Exact.js.map +1 -0
  402. package/transpiled/directives/cache/index.d.ts +2 -0
  403. package/transpiled/directives/cache/index.js +6 -0
  404. package/transpiled/directives/cache/index.js.map +1 -0
  405. package/transpiled/directives/cache/types.d.ts +7 -0
  406. package/transpiled/directives/cache/types.js +3 -0
  407. package/transpiled/directives/cache/types.js.map +1 -0
  408. package/transpiled/directives/cors/CORS.d.ts +10 -0
  409. package/transpiled/directives/cors/CORS.js +51 -0
  410. package/transpiled/directives/cors/CORS.js.map +1 -0
  411. package/transpiled/directives/cors/index.d.ts +2 -0
  412. package/transpiled/directives/cors/index.js +6 -0
  413. package/transpiled/directives/cors/index.js.map +1 -0
  414. package/transpiled/directives/dev/Development.d.ts +9 -0
  415. package/transpiled/directives/dev/Development.js +29 -0
  416. package/transpiled/directives/dev/Development.js.map +1 -0
  417. package/transpiled/directives/dev/Stub.d.ts +7 -0
  418. package/transpiled/directives/dev/Stub.js +14 -0
  419. package/transpiled/directives/dev/Stub.js.map +1 -0
  420. package/transpiled/directives/dev/Throw.d.ts +7 -0
  421. package/transpiled/directives/dev/Throw.js +14 -0
  422. package/transpiled/directives/dev/Throw.js.map +1 -0
  423. package/transpiled/directives/dev/index.d.ts +2 -0
  424. package/transpiled/directives/dev/index.js +6 -0
  425. package/transpiled/directives/dev/index.js.map +1 -0
  426. package/transpiled/directives/dev/types.d.ts +4 -0
  427. package/transpiled/directives/dev/types.js +3 -0
  428. package/transpiled/directives/dev/types.js.map +1 -0
  429. package/transpiled/directives/index.d.ts +4 -0
  430. package/transpiled/directives/index.js +13 -0
  431. package/transpiled/directives/index.js.map +1 -0
  432. package/transpiled/directives/io/Directive.d.ts +8 -0
  433. package/transpiled/directives/io/Directive.js +3 -0
  434. package/transpiled/directives/io/Directive.js.map +1 -0
  435. package/transpiled/directives/io/IO.d.ts +9 -0
  436. package/transpiled/directives/io/IO.js +33 -0
  437. package/transpiled/directives/io/IO.js.map +1 -0
  438. package/transpiled/directives/io/Input.d.ts +11 -0
  439. package/transpiled/directives/io/Input.js +63 -0
  440. package/transpiled/directives/io/Input.js.map +1 -0
  441. package/transpiled/directives/io/Message.d.ts +1 -0
  442. package/transpiled/directives/io/Message.js +3 -0
  443. package/transpiled/directives/io/Message.js.map +1 -0
  444. package/transpiled/directives/io/Output.d.ts +13 -0
  445. package/transpiled/directives/io/Output.js +76 -0
  446. package/transpiled/directives/io/Output.js.map +1 -0
  447. package/transpiled/directives/io/index.d.ts +2 -0
  448. package/transpiled/directives/io/index.js +6 -0
  449. package/transpiled/directives/io/index.js.map +1 -0
  450. package/transpiled/directives/io/schemas.d.ts +7 -0
  451. package/transpiled/directives/io/schemas.js +14 -0
  452. package/transpiled/directives/io/schemas.js.map +1 -0
  453. package/transpiled/directives/octets/Context.d.ts +8 -0
  454. package/transpiled/directives/octets/Context.js +42 -0
  455. package/transpiled/directives/octets/Context.js.map +1 -0
  456. package/transpiled/directives/octets/Delete.d.ts +20 -0
  457. package/transpiled/directives/octets/Delete.js +84 -0
  458. package/transpiled/directives/octets/Delete.js.map +1 -0
  459. package/transpiled/directives/octets/Directive.d.ts +8 -0
  460. package/transpiled/directives/octets/Directive.js +8 -0
  461. package/transpiled/directives/octets/Directive.js.map +1 -0
  462. package/transpiled/directives/octets/Fetch.d.ts +18 -0
  463. package/transpiled/directives/octets/Fetch.js +92 -0
  464. package/transpiled/directives/octets/Fetch.js.map +1 -0
  465. package/transpiled/directives/octets/List.d.ts +16 -0
  466. package/transpiled/directives/octets/List.js +74 -0
  467. package/transpiled/directives/octets/List.js.map +1 -0
  468. package/transpiled/directives/octets/Octets.d.ts +12 -0
  469. package/transpiled/directives/octets/Octets.js +55 -0
  470. package/transpiled/directives/octets/Octets.js.map +1 -0
  471. package/transpiled/directives/octets/Permute.d.ts +11 -0
  472. package/transpiled/directives/octets/Permute.js +58 -0
  473. package/transpiled/directives/octets/Permute.js.map +1 -0
  474. package/transpiled/directives/octets/Store.d.ts +24 -0
  475. package/transpiled/directives/octets/Store.js +95 -0
  476. package/transpiled/directives/octets/Store.js.map +1 -0
  477. package/transpiled/directives/octets/Workflow.d.ts +15 -0
  478. package/transpiled/directives/octets/Workflow.js +59 -0
  479. package/transpiled/directives/octets/Workflow.js.map +1 -0
  480. package/transpiled/directives/octets/index.d.ts +2 -0
  481. package/transpiled/directives/octets/index.js +6 -0
  482. package/transpiled/directives/octets/index.js.map +1 -0
  483. package/transpiled/directives/octets/schemas.d.ts +13 -0
  484. package/transpiled/directives/octets/schemas.js +18 -0
  485. package/transpiled/directives/octets/schemas.js.map +1 -0
  486. package/transpiled/directives/octets/types.d.ts +5 -0
  487. package/transpiled/directives/octets/types.js +3 -0
  488. package/transpiled/directives/octets/types.js.map +1 -0
  489. package/transpiled/directives/octets/workflows/Execution.d.ts +25 -0
  490. package/transpiled/directives/octets/workflows/Execution.js +54 -0
  491. package/transpiled/directives/octets/workflows/Execution.js.map +1 -0
  492. package/transpiled/directives/octets/workflows/Workflow.d.ts +12 -0
  493. package/transpiled/directives/octets/workflows/Workflow.js +25 -0
  494. package/transpiled/directives/octets/workflows/Workflow.js.map +1 -0
  495. package/transpiled/directives/octets/workflows/index.d.ts +1 -0
  496. package/transpiled/directives/octets/workflows/index.js +6 -0
  497. package/transpiled/directives/octets/workflows/index.js.map +1 -0
  498. package/transpiled/directives/vary/Directive.d.ts +5 -0
  499. package/transpiled/directives/vary/Directive.js +3 -0
  500. package/transpiled/directives/vary/Directive.js.map +1 -0
  501. package/transpiled/directives/vary/Embed.d.ts +10 -0
  502. package/transpiled/directives/vary/Embed.js +49 -0
  503. package/transpiled/directives/vary/Embed.js.map +1 -0
  504. package/transpiled/directives/vary/Properties.d.ts +9 -0
  505. package/transpiled/directives/vary/Properties.js +16 -0
  506. package/transpiled/directives/vary/Properties.js.map +1 -0
  507. package/transpiled/directives/vary/Vary.d.ts +10 -0
  508. package/transpiled/directives/vary/Vary.js +36 -0
  509. package/transpiled/directives/vary/Vary.js.map +1 -0
  510. package/transpiled/directives/vary/embeddings/Embedding.d.ts +5 -0
  511. package/transpiled/directives/vary/embeddings/Embedding.js +3 -0
  512. package/transpiled/directives/vary/embeddings/Embedding.js.map +1 -0
  513. package/transpiled/directives/vary/embeddings/Header.d.ts +7 -0
  514. package/transpiled/directives/vary/embeddings/Header.js +28 -0
  515. package/transpiled/directives/vary/embeddings/Header.js.map +1 -0
  516. package/transpiled/directives/vary/embeddings/Language.d.ts +7 -0
  517. package/transpiled/directives/vary/embeddings/Language.js +28 -0
  518. package/transpiled/directives/vary/embeddings/Language.js.map +1 -0
  519. package/transpiled/directives/vary/embeddings/index.d.ts +5 -0
  520. package/transpiled/directives/vary/embeddings/index.js +10 -0
  521. package/transpiled/directives/vary/embeddings/index.js.map +1 -0
  522. package/transpiled/directives/vary/index.d.ts +2 -0
  523. package/transpiled/directives/vary/index.js +6 -0
  524. package/transpiled/directives/vary/index.js.map +1 -0
  525. package/transpiled/discovery.d.ts +1 -0
  526. package/transpiled/discovery.js +3 -0
  527. package/transpiled/discovery.js.map +1 -0
  528. package/transpiled/exceptions.d.ts +2 -0
  529. package/transpiled/exceptions.js +39 -0
  530. package/transpiled/exceptions.js.map +1 -0
  531. package/transpiled/index.d.ts +5 -0
  532. package/transpiled/index.js +12 -0
  533. package/transpiled/index.js.map +1 -0
  534. package/transpiled/io.d.ts +3 -0
  535. package/transpiled/io.js +3 -0
  536. package/transpiled/io.js.map +1 -0
  537. package/transpiled/manifest.d.ts +3 -0
  538. package/transpiled/manifest.js +66 -0
  539. package/transpiled/manifest.js.map +1 -0
  540. package/transpiled/root.d.ts +2 -0
  541. package/transpiled/root.js +44 -0
  542. package/transpiled/root.js.map +1 -0
  543. package/transpiled/schemas.d.ts +7 -0
  544. package/transpiled/schemas.js +14 -0
  545. package/transpiled/schemas.js.map +1 -0
  546. package/transpiled/tsconfig.tsbuildinfo +1 -0
  547. package/source/HTTP/Server.fixtures.ts +0 -41
@@ -2,7 +2,7 @@ Feature: Octets storage workflows
2
2
 
3
3
  Scenario: Running a workflow
4
4
  Given the `octets.tester` is running
5
- Given the annotation:
5
+ And the annotation:
6
6
  """yaml
7
7
  /:
8
8
  auth:anonymous: true
@@ -15,6 +15,7 @@ Feature: Octets storage workflows
15
15
  - add-baz: octets.tester.baz
16
16
  - diversify: octets.tester.diversify
17
17
  /*:
18
+ io:output: true
18
19
  GET:
19
20
  octets:fetch:
20
21
  meta: true
@@ -47,8 +48,8 @@ Feature: Octets storage workflows
47
48
  """
48
49
  When the following request is received:
49
50
  """
50
- GET /10cf16b458f759e0d617f2f3d83599ff:meta HTTP/1.1
51
- accept: application/yaml
51
+ GET /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
52
+ accept: application/vnd.toa.octets.entry+yaml
52
53
  """
53
54
  Then the following reply is sent:
54
55
  """
@@ -74,7 +75,7 @@ Feature: Octets storage workflows
74
75
  content-length: 473831
75
76
  """
76
77
 
77
- Scenario: Getting error when adding metadata to a file
78
+ Scenario: Getting error when running workflow on `store`
78
79
  Given the `octets.tester` is running
79
80
  Given the annotation:
80
81
  """yaml
@@ -112,3 +113,175 @@ Feature: Octets storage workflows
112
113
  message: Something went wrong
113
114
  --cut--
114
115
  """
116
+
117
+ Scenario: Running a workflow on `delete`
118
+ Given the `octets.tester` is running
119
+ And the annotation:
120
+ """yaml
121
+ /:
122
+ auth:anonymous: true
123
+ octets:context: octets
124
+ POST:
125
+ octets:store: ~
126
+ /*:
127
+ GET:
128
+ octets:fetch: ~
129
+ DELETE:
130
+ octets:delete:
131
+ workflow:
132
+ echo: octets.tester.echo
133
+ """
134
+ When the stream of `lenna.ascii` is received with the following headers:
135
+ """
136
+ POST / HTTP/1.1
137
+ content-type: application/octet-stream
138
+ """
139
+ Then the following reply is sent:
140
+ """
141
+ 201 Created
142
+ """
143
+ When the following request is received:
144
+ """
145
+ DELETE /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
146
+ accept: application/yaml
147
+ """
148
+ Then the following reply is sent:
149
+ """
150
+ 202 Accepted
151
+ content-type: multipart/yaml; boundary=cut
152
+
153
+ --cut
154
+ echo: 10cf16b458f759e0d617f2f3d83599ff
155
+ --cut--
156
+ """
157
+ When the following request is received:
158
+ """
159
+ GET /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
160
+ """
161
+ Then the following reply is sent:
162
+ """
163
+ 404 Not Found
164
+ """
165
+
166
+ Scenario: Error in the workflow on `delete`
167
+ Given the `octets.tester` is running
168
+ And the annotation:
169
+ """yaml
170
+ /:
171
+ auth:anonymous: true
172
+ octets:context: octets
173
+ POST:
174
+ octets:store: ~
175
+ /*:
176
+ GET:
177
+ octets:fetch: ~
178
+ DELETE:
179
+ octets:delete:
180
+ workflow:
181
+ err: octets.tester.err
182
+ """
183
+ When the stream of `lenna.ascii` is received with the following headers:
184
+ """
185
+ POST / HTTP/1.1
186
+ content-type: application/octet-stream
187
+ """
188
+ Then the following reply is sent:
189
+ """
190
+ 201 Created
191
+ """
192
+ When the following request is received:
193
+ """
194
+ DELETE /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
195
+ accept: application/yaml
196
+ """
197
+ Then the following reply is sent:
198
+ """
199
+ 202 Accepted
200
+ content-type: multipart/yaml; boundary=cut
201
+
202
+ --cut
203
+ error:
204
+ step: err
205
+ code: ERROR
206
+ message: Something went wrong
207
+ --cut--
208
+ """
209
+ When the following request is received:
210
+ """
211
+ GET /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
212
+ """
213
+ Then the following reply is sent:
214
+ """
215
+ 200 OK
216
+ """
217
+
218
+ Scenario: Passing parameters to the workflow
219
+ Given the `octets.tester` is running
220
+ And the annotation:
221
+ """yaml
222
+ /:
223
+ /:a/:b:
224
+ auth:anonymous: true
225
+ octets:context: octets
226
+ POST:
227
+ octets:store:
228
+ workflow:
229
+ concat: octets.tester.concat
230
+ """
231
+ When the stream of `lenna.ascii` is received with the following headers:
232
+ """
233
+ POST /hello/world/ HTTP/1.1
234
+ accept: application/yaml
235
+ content-type: application/octet-stream
236
+ """
237
+ Then the following reply is sent:
238
+ """
239
+ 201 Created
240
+ content-type: multipart/yaml; boundary=cut
241
+
242
+ --cut
243
+ id: 10cf16b458f759e0d617f2f3d83599ff
244
+ type: application/octet-stream
245
+ size: 8169
246
+ --cut
247
+ concat: hello world
248
+ --cut--
249
+ """
250
+
251
+ Scenario: Executing a workflow with `octets:workflow`
252
+ Given the `octets.tester` is running
253
+ And the annotation:
254
+ """yaml
255
+ /:
256
+ auth:anonymous: true
257
+ octets:context: octets
258
+ POST:
259
+ octets:store: ~
260
+ /*:
261
+ DELETE:
262
+ octets:workflow:
263
+ echo: octets.tester.echo
264
+ """
265
+ When the stream of `lenna.ascii` is received with the following headers:
266
+ """
267
+ POST / HTTP/1.1
268
+ content-type: application/octet-stream
269
+ """
270
+ Then the following reply is sent:
271
+ """
272
+ 201 Created
273
+ """
274
+ When the following request is received:
275
+ """
276
+ DELETE /10cf16b458f759e0d617f2f3d83599ff HTTP/1.1
277
+ accept: application/yaml
278
+ """
279
+ Then the following reply is sent:
280
+ """
281
+ 202 Accepted
282
+ content-type: multipart/yaml; boundary=cut
283
+
284
+ --cut
285
+ echo: 10cf16b458f759e0d617f2f3d83599ff
286
+ --cut--
287
+ """
@@ -13,6 +13,7 @@ Feature: Queries
13
13
  """yaml
14
14
  exposition:
15
15
  /pot:
16
+ io:output: true
16
17
  GET: observe
17
18
  """
18
19
  When the following request is received:
@@ -35,6 +36,7 @@ Feature: Queries
35
36
  """yaml
36
37
  exposition:
37
38
  /:
39
+ io:output: true
38
40
  GET: enumerate
39
41
  """
40
42
  When the following request is received:
@@ -60,6 +62,7 @@ Feature: Queries
60
62
  """yaml
61
63
  exposition:
62
64
  /:
65
+ io:output: true
63
66
  GET: enumerate
64
67
  """
65
68
  When the following request is received:
@@ -85,6 +88,7 @@ Feature: Queries
85
88
  """yaml
86
89
  exposition:
87
90
  /:
91
+ io:output: true
88
92
  GET: enumerate
89
93
  """
90
94
  When the following request is received:
@@ -110,6 +114,7 @@ Feature: Queries
110
114
  """yaml
111
115
  exposition:
112
116
  /:id:
117
+ io:output: true
113
118
  GET: observe
114
119
  """
115
120
  When the following request is received:
@@ -127,11 +132,12 @@ Feature: Queries
127
132
  volume: 200
128
133
  """
129
134
 
130
- Scenario: Request to a route with predefined criretia
135
+ Scenario: Request to a route with predefined criteria
131
136
  Given the `pots` is running with the following manifest:
132
137
  """yaml
133
138
  exposition:
134
139
  /big:
140
+ io:output: true
135
141
  GET:
136
142
  endpoint: enumerate
137
143
  query:
@@ -160,6 +166,7 @@ Feature: Queries
160
166
  """yaml
161
167
  exposition:
162
168
  /big:
169
+ io:output: true
163
170
  GET:
164
171
  endpoint: enumerate
165
172
  query:
@@ -186,6 +193,7 @@ Feature: Queries
186
193
  """yaml
187
194
  exposition:
188
195
  /hottest2:
196
+ io:output: true
189
197
  GET:
190
198
  endpoint: enumerate
191
199
  query:
@@ -0,0 +1,68 @@
1
+ Feature: Response
2
+
3
+ Scenario: Content negotiation
4
+ Given the annotation:
5
+ """yaml
6
+ /:
7
+ io:output: true
8
+ GET:
9
+ anonymous: true
10
+ dev:stub: hello
11
+ """
12
+ When the following request is received:
13
+ """
14
+ GET / HTTP/1.1
15
+ accept: application/json
16
+ """
17
+ Then the following reply is sent:
18
+ """
19
+ 200 OK
20
+ content-type: application/json
21
+ vary: accept
22
+ """
23
+
24
+ Scenario: Error as YAML
25
+ Given the `echo` is running with the following manifest:
26
+ """yaml
27
+ exposition:
28
+ /:
29
+ io:output: true
30
+ GET: error
31
+ """
32
+ When the following request is received:
33
+ """
34
+ GET /echo/ HTTP/1.1
35
+ accept: application/yaml
36
+ """
37
+ Then the following reply is sent:
38
+ """
39
+ 409 Conflict
40
+ content-type: application/yaml
41
+
42
+ code: CODE
43
+ message: message
44
+ """
45
+
46
+ Scenario: Error as MessagePack
47
+ Given the `echo` is running with the following manifest:
48
+ """yaml
49
+ exposition:
50
+ /:
51
+ io:output: true
52
+ GET: error
53
+ """
54
+ When the following request is received:
55
+ """
56
+ GET /echo/ HTTP/1.1
57
+ accept: application/msgpack
58
+ """
59
+ Then the following reply is sent:
60
+ """
61
+ 409 Conflict
62
+ content-type: application/msgpack
63
+ """
64
+ And response body contains MessagePack-encoded value:
65
+ """yaml
66
+ code: CODE
67
+ message: message
68
+ """
@@ -6,12 +6,14 @@ Feature: Routes
6
6
  namespace: basic
7
7
 
8
8
  exposition:
9
- /strict:
10
- GET:
11
- endpoint: greet
12
- /shortcuts:
13
- /operation:
14
- GET: greet
9
+ /:
10
+ io:output: true
11
+ /strict:
12
+ GET:
13
+ endpoint: greet
14
+ /shortcuts:
15
+ /operation:
16
+ GET: greet
15
17
  """
16
18
  When the following request is received:
17
19
  """
@@ -34,6 +36,7 @@ Feature: Routes
34
36
  """yaml
35
37
  exposition:
36
38
  /:
39
+ io:output: true
37
40
  GET: greet
38
41
  """
39
42
  When the following request is received:
@@ -52,10 +55,12 @@ Feature: Routes
52
55
  Given the `greeter` is running with the following manifest:
53
56
  """yaml
54
57
  exposition:
55
- /*:
56
- GET: greet
57
- /foo/*/bar:
58
- GET: greet
58
+ /:
59
+ io:output: true
60
+ /*:
61
+ GET: greet
62
+ /foo/*/bar:
63
+ GET: greet
59
64
  """
60
65
  When the following request is received:
61
66
  """
@@ -87,3 +92,42 @@ Feature: Routes
87
92
 
88
93
  Hello
89
94
  """
95
+
96
+ Scenario: Routes with naming conflicts
97
+ Given the Gateway is running
98
+ And the `users` is running with the following manifest:
99
+ """yaml
100
+ exposition:
101
+ /:
102
+ io:output: true
103
+ POST: create
104
+ """
105
+ And the `users.properties` is running with the following manifest:
106
+ """yaml
107
+ exposition:
108
+ /:id:
109
+ io:output: true
110
+ GET: observe
111
+ """
112
+ When the following request is received:
113
+ """
114
+ GET /users/properties/b5534021e30042259badffbd1831e472/ HTTP/1.1
115
+ accept: application/yaml
116
+ """
117
+ Then the following reply is sent:
118
+ """
119
+ 200 OK
120
+
121
+ newbie: false
122
+ """
123
+ When the following request is received:
124
+ """
125
+ POST /users/ HTTP/1.1
126
+ content-type: application/yaml
127
+
128
+ name: Alice
129
+ """
130
+ Then the following reply is sent:
131
+ """
132
+ 201 Created
133
+ """
@@ -0,0 +1,6 @@
1
+ import * as http from '@toa.io/agent'
2
+ import { binding } from 'cucumber-tsflow'
3
+
4
+ @binding()
5
+ export class Captures extends http.Captures {
6
+ }
@@ -1,3 +1,4 @@
1
+ import * as assert from 'node:assert'
1
2
  import { after, binding, given } from 'cucumber-tsflow'
2
3
  import * as boot from '@toa.io/boot'
3
4
  import { timeout } from '@toa.io/generic'
@@ -8,7 +9,7 @@ import { Workspace } from './Workspace'
8
9
  @binding([Workspace])
9
10
  export class Components {
10
11
  private readonly workspace: Workspace
11
- private composition: Connector | null = null
12
+ private compositions: Record<string, Connector> = {}
12
13
 
13
14
  public constructor (workspace: Workspace) {
14
15
  this.workspace = workspace
@@ -26,18 +27,29 @@ export class Components {
26
27
  await this.runComponent(name, manifest)
27
28
  }
28
29
 
29
- @after()
30
30
  @given('the `{word}` is stopped')
31
- public async stop (_?: string): Promise<void> {
32
- await this.composition?.disconnect()
31
+ public async stop (name: string): Promise<void> {
32
+ assert.ok(name in this.compositions, `Composition '${name}' is not running`)
33
+
34
+ await this.compositions[name].disconnect()
35
+ delete this.compositions[name]
36
+ }
37
+
38
+ @after()
39
+ public async shutdown (): Promise<void> {
40
+ const promises = Object.values(this.compositions).map((composition) => composition.disconnect())
41
+
42
+ await Promise.all(promises)
33
43
  }
34
44
 
35
45
  private async runComponent (name: string, manifest?: object): Promise<void> {
46
+ assert.ok(!(name in this.compositions), `Composition '${name}' is already running`)
47
+
36
48
  const path = await this.workspace.addComponent(name, manifest)
37
49
 
38
- this.composition = await boot.composition([path])
50
+ this.compositions[name] = await boot.composition([path])
39
51
 
40
- await this.composition.connect()
52
+ await this.compositions[name].connect()
41
53
  await timeout(50) // discovery
42
54
  }
43
55
  }
@@ -1,6 +1,6 @@
1
1
  import { afterAll, beforeAll, binding, given } from 'cucumber-tsflow'
2
- import { type DataTable } from '@cucumber/cucumber'
3
2
  import { MongoClient } from 'mongodb'
3
+ import type { DataTable } from '@cucumber/cucumber'
4
4
 
5
5
  @binding()
6
6
  export class Database {
@@ -18,8 +18,7 @@ export class Gateway {
18
18
  const annotation = parse(yaml)
19
19
 
20
20
  if ('/' in annotation) {
21
- const node = { '/': annotation['/'] }
22
- const tree = syntax.parse(node, shortcuts)
21
+ const tree = syntax.parse(annotation['/'], shortcuts)
23
22
 
24
23
  process.env.TOA_EXPOSITION = encode(tree)
25
24
  }
@@ -27,6 +26,9 @@ export class Gateway {
27
26
  if (annotation.debug === true)
28
27
  process.env.TOA_EXPOSITION_DEBUG = '1'
29
28
 
29
+ if (annotation.trace === true)
30
+ process.env.TOA_EXPOSITION_TRACE = '1'
31
+
30
32
  await Gateway.stop()
31
33
 
32
34
  this.default = false
@@ -1,121 +1,74 @@
1
- import { AssertionError } from 'node:assert'
1
+ import * as assert from 'node:assert'
2
+ import * as fs from 'node:fs'
3
+ import * as path from 'node:path'
2
4
  import { binding, then, when } from 'cucumber-tsflow'
3
- import * as http from '@toa.io/http'
4
- import { trim } from '@toa.io/generic'
5
- import { buffer } from '@toa.io/streams'
6
- import { open } from '../../../storages/source/test/util'
5
+ import * as http from '@toa.io/agent'
6
+ import * as msgpack from 'msgpackr'
7
+ import * as YAML from 'js-yaml'
8
+ import { Captures } from './Captures'
7
9
  import { Parameters } from './Parameters'
8
10
  import { Gateway } from './Gateway'
11
+ import type { Readable } from 'node:stream'
9
12
 
10
- @binding([Gateway, Parameters])
11
- export class HTTP {
13
+ @binding([Gateway, Parameters, Captures])
14
+ export class HTTP extends http.Agent {
12
15
  private readonly gateway: Gateway
13
- private readonly origin: string
14
- private response: string = ''
15
- private readonly variables: Record<string, string> = {}
16
+ private fetched: Response | null = null
16
17
 
17
- public constructor (gateway: Gateway, parameters: Parameters) {
18
+ public constructor (gateway: Gateway, parameters: Parameters, captures: Captures) {
19
+ super(parameters.origin, captures)
18
20
  this.gateway = gateway
19
- this.origin = parameters.origin
20
21
  }
21
22
 
22
23
  @when('the following request is received:')
23
- public async request (input: string): Promise<any> {
24
- let [headers, body] = trim(input).split('\n\n')
25
-
26
- if (body !== undefined)
27
- headers += '\ncontent-length: ' + body?.length
28
-
29
- const text = headers + '\n\n' + (body ?? '')
30
- const request = text.replaceAll(SUBSTITUTE, (_, name) => this.variables[name])
31
-
24
+ public override async request (input: string): Promise<any> {
32
25
  await this.gateway.start()
33
-
34
- this.response = await http.request(request, this.origin)
26
+ this.fetched = await super.request(input)
35
27
  }
36
28
 
37
29
  @then('the following reply is sent:')
38
- public responseIncludes (expected: string): void {
39
- const lines = trim(expected).split('\n')
40
-
41
- for (const line of lines) {
42
- const escaped = line.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
43
-
44
- const expression = escaped.replace(CAPTURE,
45
- (_, name) => `(?<${name}>\\S{1,2048})`)
30
+ public override responseIncludes (expected: string): void {
31
+ super.responseIncludes(expected)
32
+ }
46
33
 
47
- const rx = new RegExp(expression, 'i')
48
- const match = this.response.match(rx)
34
+ @then('response body contains {word}-encoded value:')
35
+ public async bodyIs (format: string, yaml: string): Promise<void> {
36
+ assert.ok(this.fetched !== null, 'Response is null')
49
37
 
50
- if (match === null)
51
- throw new AssertionError({
52
- message: `Response is missing '${line}'`,
53
- expected: line,
54
- actual: this.response
55
- })
38
+ const buf = await this.fetched.arrayBuffer()
39
+ const value = encoders[format]?.(buf as Buffer)
40
+ const expected = YAML.load(yaml)
56
41
 
57
- Object.assign(this.variables, match.groups)
58
- }
42
+ assert.deepEqual(value, expected, 'Values are not equal')
59
43
  }
60
44
 
61
45
  @then('the reply does not contain:')
62
- public responseExcludes (expected: string): void {
63
- const lines = trim(expected).split('\n')
64
-
65
- for (const line of lines) {
66
- line.replace(SUBSTITUTE, (_, name) => this.variables[name])
67
-
68
- const includes = this.response.includes(line)
69
-
70
- if (includes)
71
- throw new AssertionError({
72
- message: `Response contains '${line}'`,
73
- expected: line,
74
- actual: this.response
75
- })
76
- }
46
+ public override responseExcludes (expected: string): void {
47
+ super.responseExcludes(expected)
77
48
  }
78
49
 
79
50
  @when('the stream of `{word}` is received with the following headers:')
80
51
  public async streamRequest (filename: string, head: string): Promise<any> {
81
- head = trim(head) + '\n\n'
52
+ const stream = open(filename)
82
53
 
83
54
  await this.gateway.start()
84
-
85
- const { url, method, headers } = http.parse.request(head)
86
- const href = new URL(url, this.origin).href
87
- const body = open(filename)
88
-
89
- headers.connection = 'close' // required for interrupted streams
90
-
91
- const request = {
92
- method,
93
- headers,
94
- body: body as unknown as ReadableStream,
95
- duplex: 'half'
96
- }
97
-
98
- try {
99
- const response = await fetch(href, request)
100
-
101
- this.response = await http.parse.response(response)
102
- } catch (e: any) {
103
- console.error(e)
104
- console.error(e.cause)
105
-
106
- throw e
107
- }
55
+ await super.stream(head, stream)
108
56
  }
109
57
 
110
58
  @then('the stream equals to `{word}` is sent with the following headers:')
111
59
  public async responseStreamMatch (filename: string, head: string): Promise<any> {
112
- const buf = await buffer(open(filename))
113
- const text = buf.toString('utf8')
114
- const expected = head + '\n\n' + text
60
+ const stream = open(filename)
115
61
 
116
- this.responseIncludes(expected)
62
+ await super.streamMatch(head, stream)
117
63
  }
118
64
  }
119
65
 
120
- const CAPTURE = /\\\$\\{\\{ (?<name>[A-Za-z_]{0,32}) \\}\\}/g
121
- const SUBSTITUTE = /\${{ (?<name>[A-Za-z_]{0,32}) }}/g
66
+ const FILEDIR = path.resolve(__dirname, '../../../storages/source/test')
67
+
68
+ function open (filename: string): Readable {
69
+ return fs.createReadStream(path.join(FILEDIR, filename))
70
+ }
71
+
72
+ const encoders: Record<string, (buf: Buffer | Uint8Array) => any> = {
73
+ MessagePack: msgpack.decode
74
+ }