@toa.io/extensions.exposition 1.0.0-alpha.3 → 1.0.0-alpha.31

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 (431) hide show
  1. package/components/context.toa.yaml +2 -2
  2. package/components/identity.bans/manifest.toa.yaml +15 -6
  3. package/components/identity.bans/operations/transit.d.ts +14 -0
  4. package/components/identity.bans/operations/transit.js +11 -0
  5. package/components/identity.bans/operations/transit.js.map +1 -0
  6. package/components/identity.bans/operations/tsconfig.tsbuildinfo +1 -0
  7. package/components/identity.bans/source/transit.ts +21 -0
  8. package/components/identity.bans/tsconfig.json +9 -0
  9. package/components/identity.basic/manifest.toa.yaml +21 -8
  10. package/components/identity.basic/operations/authenticate.d.ts +5 -1
  11. package/components/identity.basic/operations/authenticate.js +5 -2
  12. package/components/identity.basic/operations/authenticate.js.map +1 -1
  13. package/components/identity.basic/operations/incept.d.ts +12 -0
  14. package/components/identity.basic/operations/incept.js +20 -0
  15. package/components/identity.basic/operations/incept.js.map +1 -0
  16. package/components/identity.basic/operations/transit.d.ts +3 -3
  17. package/components/identity.basic/operations/transit.js +5 -3
  18. package/components/identity.basic/operations/transit.js.map +1 -1
  19. package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
  20. package/components/identity.basic/operations/types.d.ts +2 -0
  21. package/components/identity.basic/source/authenticate.ts +16 -5
  22. package/components/identity.basic/source/incept.ts +32 -0
  23. package/components/identity.basic/source/transit.ts +7 -5
  24. package/components/identity.basic/source/types.ts +2 -0
  25. package/components/identity.federation/manifest.toa.yaml +28 -17
  26. package/components/identity.federation/operations/authenticate.d.ts +2 -2
  27. package/components/identity.federation/operations/authenticate.js +6 -5
  28. package/components/identity.federation/operations/authenticate.js.map +1 -1
  29. package/components/identity.federation/operations/incept.d.ts +11 -0
  30. package/components/identity.federation/operations/{create.js → incept.js} +6 -7
  31. package/components/identity.federation/operations/incept.js.map +1 -0
  32. package/components/identity.federation/operations/lib/jwt.d.ts +4 -5
  33. package/components/identity.federation/operations/lib/jwt.js +3 -3
  34. package/components/identity.federation/operations/lib/jwt.js.map +1 -1
  35. package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
  36. package/components/identity.federation/operations/types/configuration.d.ts +15 -0
  37. package/components/identity.federation/operations/types/configuration.js +3 -0
  38. package/components/identity.federation/operations/types/configuration.js.map +1 -0
  39. package/components/identity.federation/operations/{types.d.ts → types/context.d.ts} +8 -3
  40. package/components/identity.federation/operations/types/context.js +3 -0
  41. package/components/identity.federation/operations/types/context.js.map +1 -0
  42. package/components/identity.federation/operations/types/entity.d.ts +6 -0
  43. package/components/identity.federation/operations/{types.js → types/entity.js} +1 -1
  44. package/components/identity.federation/operations/types/entity.js.map +1 -0
  45. package/components/identity.federation/operations/types/index.d.ts +3 -0
  46. package/components/identity.federation/operations/types/index.js +20 -0
  47. package/components/identity.federation/operations/types/index.js.map +1 -0
  48. package/components/identity.federation/source/authenticate.ts +10 -9
  49. package/components/identity.federation/source/{create.ts → incept.ts} +10 -9
  50. package/components/identity.federation/source/lib/jwt.test.ts +2 -2
  51. package/components/identity.federation/source/lib/jwt.ts +7 -8
  52. package/components/identity.federation/source/types/configuration.ts +16 -0
  53. package/components/identity.federation/source/{types.ts → types/context.ts} +9 -4
  54. package/components/identity.federation/source/types/entity.ts +6 -0
  55. package/components/identity.federation/source/types/index.ts +3 -0
  56. package/components/identity.federation/tsconfig.json +2 -2
  57. package/components/identity.roles/manifest.toa.yaml +18 -5
  58. package/components/identity.roles/operations/grant.d.ts +10 -0
  59. package/components/identity.roles/operations/grant.js +21 -0
  60. package/components/identity.roles/operations/grant.js.map +1 -0
  61. package/components/identity.roles/operations/lib/Entity.d.ts +5 -0
  62. package/components/identity.roles/operations/lib/Entity.js +3 -0
  63. package/components/identity.roles/operations/lib/Entity.js.map +1 -0
  64. package/components/identity.roles/operations/list.d.ts +1 -4
  65. package/components/identity.roles/operations/list.js.map +1 -1
  66. package/components/identity.roles/operations/principal.d.ts +4 -6
  67. package/components/identity.roles/operations/principal.js +6 -1
  68. package/components/identity.roles/operations/principal.js.map +1 -1
  69. package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
  70. package/components/identity.roles/source/grant.ts +32 -0
  71. package/components/identity.roles/source/lib/Entity.ts +5 -0
  72. package/components/identity.roles/source/list.ts +2 -4
  73. package/components/identity.roles/source/principal.ts +10 -8
  74. package/components/identity.tokens/manifest.toa.yaml +19 -4
  75. package/components/identity.tokens/operations/authenticate.d.ts +2 -2
  76. package/components/identity.tokens/operations/authenticate.js +10 -4
  77. package/components/identity.tokens/operations/authenticate.js.map +1 -1
  78. package/components/identity.tokens/operations/decrypt.js +1 -0
  79. package/components/identity.tokens/operations/decrypt.js.map +1 -1
  80. package/components/identity.tokens/operations/encrypt.js +5 -1
  81. package/components/identity.tokens/operations/encrypt.js.map +1 -1
  82. package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
  83. package/components/identity.tokens/operations/types.d.ts +8 -2
  84. package/components/identity.tokens/receivers/identity.bans.created.js +3 -0
  85. package/components/identity.tokens/source/authenticate.test.ts +11 -4
  86. package/components/identity.tokens/source/authenticate.ts +12 -5
  87. package/components/identity.tokens/source/decrypt.test.ts +5 -3
  88. package/components/identity.tokens/source/decrypt.ts +9 -8
  89. package/components/identity.tokens/source/encrypt.test.ts +26 -2
  90. package/components/identity.tokens/source/encrypt.ts +5 -1
  91. package/components/identity.tokens/source/types.ts +9 -2
  92. package/components/octets.storage/manifest.toa.yaml +0 -6
  93. package/components/octets.storage/operations/store.js +1 -1
  94. package/documentation/access.md +27 -16
  95. package/documentation/authorities.md +53 -0
  96. package/documentation/cache.md +8 -1
  97. package/documentation/components.md +52 -27
  98. package/documentation/identity.md +17 -22
  99. package/documentation/io.md +56 -0
  100. package/documentation/protocol.md +3 -0
  101. package/documentation/query.md +57 -8
  102. package/documentation/require.md +15 -0
  103. package/documentation/tree.md +22 -4
  104. package/documentation/vary.md +14 -14
  105. package/entity.json +0 -0
  106. package/features/access.feature +83 -56
  107. package/features/annotation.feature +2 -0
  108. package/features/authorities.basic.feature +141 -0
  109. package/features/authorities.feature +32 -0
  110. package/features/authorities.federation.feature +99 -0
  111. package/features/authorities.tokens.feature +118 -0
  112. package/features/body.feature +5 -1
  113. package/features/cache.feature +78 -5
  114. package/features/cors.feature +6 -2
  115. package/features/debug.feature +34 -0
  116. package/features/directives.feature +5 -0
  117. package/features/dynamic.feature +18 -7
  118. package/features/errors.feature +19 -5
  119. package/features/etag.feature +103 -0
  120. package/features/identity.bans.feature +137 -0
  121. package/features/identity.basic.feature +137 -14
  122. package/features/identity.feature +7 -2
  123. package/features/identity.federation.feature +61 -8
  124. package/features/identity.roles.feature +220 -4
  125. package/features/identity.tokens.feature +114 -4
  126. package/features/io.feature +205 -0
  127. package/features/octets.entries.feature +11 -1
  128. package/features/octets.feature +60 -64
  129. package/features/octets.meta.feature +7 -3
  130. package/features/octets.workflows.feature +14 -0
  131. package/features/probes.feature +14 -0
  132. package/features/{queries.feature → query.feature} +50 -3
  133. package/features/require.feature +67 -0
  134. package/features/response.feature +12 -3
  135. package/features/routes.feature +25 -12
  136. package/features/steps/Database.ts +17 -10
  137. package/features/steps/Gateway.ts +24 -4
  138. package/features/steps/IdP.ts +28 -23
  139. package/features/steps/components/echo/manifest.toa.yaml +5 -0
  140. package/features/steps/components/echo/operations/identity.js +7 -0
  141. package/features/steps/components/greeter/manifest.toa.yaml +1 -0
  142. package/features/steps/components/octets.tester/manifest.toa.yaml +1 -0
  143. package/features/steps/components/pots/manifest.toa.yaml +12 -3
  144. package/features/steps/components/sequences/manifest.toa.yaml +1 -0
  145. package/features/steps/components/users.properties/manifest.toa.yaml +2 -1
  146. package/features/streams.feature +1 -0
  147. package/features/timing.feature +69 -0
  148. package/features/vary.feature +105 -3
  149. package/package.json +12 -14
  150. package/readme.md +19 -13
  151. package/schemas/annotation.cos.yaml +2 -1
  152. package/schemas/io/input.cos.yaml +3 -0
  153. package/schemas/io/message.cos.yaml +5 -0
  154. package/schemas/io/output.cos.yaml +5 -0
  155. package/schemas/querystring.cos.yaml +1 -0
  156. package/source/Annotation.ts +3 -2
  157. package/source/Context.ts +6 -4
  158. package/source/Directive.test.ts +7 -7
  159. package/source/Directive.ts +19 -46
  160. package/source/Endpoint.ts +55 -6
  161. package/source/Factory.ts +17 -9
  162. package/source/Gateway.ts +38 -53
  163. package/source/HTTP/Context.ts +89 -0
  164. package/source/HTTP/Server.ts +99 -121
  165. package/source/HTTP/Timing.ts +40 -0
  166. package/source/HTTP/exceptions.ts +7 -1
  167. package/source/HTTP/index.ts +1 -0
  168. package/source/HTTP/messages.test.ts +27 -8
  169. package/source/HTTP/messages.ts +32 -48
  170. package/source/Mapping.ts +12 -8
  171. package/source/Query.test.ts +1 -1
  172. package/source/Query.ts +35 -24
  173. package/source/RTD/Context.ts +7 -10
  174. package/source/RTD/Directives.ts +28 -4
  175. package/source/RTD/Endpoint.ts +6 -4
  176. package/source/RTD/Match.ts +2 -7
  177. package/source/RTD/Method.ts +7 -13
  178. package/source/RTD/Node.ts +13 -14
  179. package/source/RTD/Tree.ts +17 -16
  180. package/source/RTD/factory.ts +3 -6
  181. package/source/Tenant.ts +0 -8
  182. package/source/deployment.ts +33 -17
  183. package/source/directives/auth/Anonymous.ts +3 -2
  184. package/source/directives/auth/Authorization.ts +34 -21
  185. package/source/directives/auth/Delegate.ts +35 -0
  186. package/source/directives/auth/Incept.ts +13 -7
  187. package/source/directives/auth/Role.test.ts +53 -6
  188. package/source/directives/auth/Role.ts +27 -17
  189. package/source/directives/auth/Scheme.ts +2 -2
  190. package/source/directives/auth/types.ts +1 -1
  191. package/source/directives/cache/Cache.ts +5 -5
  192. package/source/directives/cache/Control.ts +48 -22
  193. package/source/directives/cache/types.ts +1 -1
  194. package/source/directives/cors/CORS.ts +18 -10
  195. package/source/directives/dev/Development.ts +4 -4
  196. package/source/directives/index.ts +6 -4
  197. package/source/directives/io/Directive.ts +11 -0
  198. package/source/directives/io/IO.ts +43 -0
  199. package/source/directives/io/Input.ts +50 -0
  200. package/source/directives/io/Message.ts +1 -0
  201. package/source/directives/io/Output.ts +69 -0
  202. package/source/directives/io/index.ts +3 -0
  203. package/source/directives/io/schemas.ts +12 -0
  204. package/source/directives/octets/Context.ts +5 -4
  205. package/source/directives/octets/Delete.ts +23 -11
  206. package/source/directives/octets/Directive.ts +10 -0
  207. package/source/directives/octets/Fetch.ts +33 -17
  208. package/source/directives/octets/List.ts +18 -8
  209. package/source/directives/octets/Octets.ts +9 -9
  210. package/source/directives/octets/Store.ts +29 -19
  211. package/source/directives/octets/Workflow.ts +12 -5
  212. package/source/directives/octets/types.ts +0 -7
  213. package/source/directives/octets/workflows/Workflow.ts +2 -2
  214. package/source/directives/require/Directive.ts +5 -0
  215. package/source/directives/require/Headers.ts +20 -0
  216. package/source/directives/require/Require.ts +28 -0
  217. package/source/directives/require/index.ts +3 -0
  218. package/source/directives/vary/Directive.ts +2 -1
  219. package/source/directives/vary/Embed.ts +14 -8
  220. package/source/directives/vary/Vary.ts +8 -6
  221. package/source/directives/vary/embeddings/Authority.ts +8 -0
  222. package/source/directives/vary/embeddings/Embedding.ts +2 -1
  223. package/source/directives/vary/embeddings/Header.ts +9 -7
  224. package/source/directives/vary/embeddings/Language.ts +2 -2
  225. package/source/directives/vary/embeddings/Parameter.ts +14 -0
  226. package/source/directives/vary/embeddings/index.ts +6 -4
  227. package/source/exceptions.ts +22 -11
  228. package/source/io.ts +2 -2
  229. package/source/root.ts +5 -0
  230. package/source/schemas.ts +1 -1
  231. package/transpiled/Annotation.d.ts +3 -2
  232. package/transpiled/Context.d.ts +6 -4
  233. package/transpiled/Directive.d.ts +8 -21
  234. package/transpiled/Directive.js +11 -14
  235. package/transpiled/Directive.js.map +1 -1
  236. package/transpiled/Endpoint.d.ts +7 -5
  237. package/transpiled/Endpoint.js +60 -2
  238. package/transpiled/Endpoint.js.map +1 -1
  239. package/transpiled/Factory.js +11 -4
  240. package/transpiled/Factory.js.map +1 -1
  241. package/transpiled/Gateway.d.ts +4 -8
  242. package/transpiled/Gateway.js +25 -35
  243. package/transpiled/Gateway.js.map +1 -1
  244. package/transpiled/HTTP/Context.d.ts +31 -0
  245. package/transpiled/HTTP/Context.js +60 -0
  246. package/transpiled/HTTP/Context.js.map +1 -0
  247. package/transpiled/HTTP/Server.d.ts +21 -9
  248. package/transpiled/HTTP/Server.js +98 -100
  249. package/transpiled/HTTP/Server.js.map +1 -1
  250. package/transpiled/HTTP/Timing.d.ts +10 -0
  251. package/transpiled/HTTP/Timing.js +29 -0
  252. package/transpiled/HTTP/Timing.js.map +1 -0
  253. package/transpiled/HTTP/exceptions.d.ts +4 -1
  254. package/transpiled/HTTP/exceptions.js +7 -1
  255. package/transpiled/HTTP/exceptions.js.map +1 -1
  256. package/transpiled/HTTP/index.d.ts +1 -0
  257. package/transpiled/HTTP/index.js +1 -0
  258. package/transpiled/HTTP/index.js.map +1 -1
  259. package/transpiled/HTTP/messages.d.ts +7 -21
  260. package/transpiled/HTTP/messages.js +24 -26
  261. package/transpiled/HTTP/messages.js.map +1 -1
  262. package/transpiled/Mapping.js +11 -8
  263. package/transpiled/Mapping.js.map +1 -1
  264. package/transpiled/Query.d.ts +1 -0
  265. package/transpiled/Query.js +21 -20
  266. package/transpiled/Query.js.map +1 -1
  267. package/transpiled/RTD/Context.d.ts +7 -6
  268. package/transpiled/RTD/Directives.d.ts +19 -4
  269. package/transpiled/RTD/Endpoint.d.ts +6 -4
  270. package/transpiled/RTD/Match.d.ts +2 -4
  271. package/transpiled/RTD/Method.d.ts +7 -7
  272. package/transpiled/RTD/Method.js.map +1 -1
  273. package/transpiled/RTD/Node.d.ts +4 -6
  274. package/transpiled/RTD/Node.js +2 -1
  275. package/transpiled/RTD/Node.js.map +1 -1
  276. package/transpiled/RTD/Tree.d.ts +6 -6
  277. package/transpiled/RTD/Tree.js +4 -1
  278. package/transpiled/RTD/Tree.js.map +1 -1
  279. package/transpiled/RTD/factory.d.ts +2 -4
  280. package/transpiled/RTD/factory.js +1 -1
  281. package/transpiled/RTD/factory.js.map +1 -1
  282. package/transpiled/Tenant.d.ts +0 -1
  283. package/transpiled/Tenant.js +0 -6
  284. package/transpiled/Tenant.js.map +1 -1
  285. package/transpiled/deployment.d.ts +1 -1
  286. package/transpiled/deployment.js +28 -15
  287. package/transpiled/deployment.js.map +1 -1
  288. package/transpiled/directives/auth/Anonymous.js +3 -4
  289. package/transpiled/directives/auth/Anonymous.js.map +1 -1
  290. package/transpiled/directives/auth/Authorization.d.ts +2 -3
  291. package/transpiled/directives/auth/Authorization.js +18 -11
  292. package/transpiled/directives/auth/Authorization.js.map +1 -1
  293. package/transpiled/directives/auth/Delegate.d.ts +8 -0
  294. package/transpiled/directives/auth/Delegate.js +29 -0
  295. package/transpiled/directives/auth/Delegate.js.map +1 -0
  296. package/transpiled/directives/auth/Incept.d.ts +1 -1
  297. package/transpiled/directives/auth/Incept.js +13 -7
  298. package/transpiled/directives/auth/Incept.js.map +1 -1
  299. package/transpiled/directives/auth/Role.d.ts +4 -1
  300. package/transpiled/directives/auth/Role.js +25 -17
  301. package/transpiled/directives/auth/Role.js.map +1 -1
  302. package/transpiled/directives/auth/Scheme.js +2 -2
  303. package/transpiled/directives/auth/Scheme.js.map +1 -1
  304. package/transpiled/directives/cache/Cache.d.ts +3 -3
  305. package/transpiled/directives/cache/Cache.js +3 -3
  306. package/transpiled/directives/cache/Cache.js.map +1 -1
  307. package/transpiled/directives/cache/Control.d.ts +5 -4
  308. package/transpiled/directives/cache/Control.js +32 -15
  309. package/transpiled/directives/cache/Control.js.map +1 -1
  310. package/transpiled/directives/cache/types.d.ts +1 -1
  311. package/transpiled/directives/cors/CORS.d.ts +2 -3
  312. package/transpiled/directives/cors/CORS.js +17 -10
  313. package/transpiled/directives/cors/CORS.js.map +1 -1
  314. package/transpiled/directives/dev/Development.d.ts +3 -3
  315. package/transpiled/directives/dev/Development.js +1 -1
  316. package/transpiled/directives/dev/Development.js.map +1 -1
  317. package/transpiled/directives/index.d.ts +2 -2
  318. package/transpiled/directives/index.js +5 -3
  319. package/transpiled/directives/index.js.map +1 -1
  320. package/transpiled/directives/io/Directive.d.ts +8 -0
  321. package/transpiled/directives/io/Directive.js +3 -0
  322. package/transpiled/directives/io/Directive.js.map +1 -0
  323. package/transpiled/directives/io/IO.d.ts +9 -0
  324. package/transpiled/directives/io/IO.js +33 -0
  325. package/transpiled/directives/io/IO.js.map +1 -0
  326. package/transpiled/directives/io/Input.d.ts +11 -0
  327. package/transpiled/directives/{octets/Permute.js → io/Input.js} +33 -21
  328. package/transpiled/directives/io/Input.js.map +1 -0
  329. package/transpiled/directives/io/Message.d.ts +1 -0
  330. package/transpiled/directives/io/Message.js +3 -0
  331. package/transpiled/directives/io/Message.js.map +1 -0
  332. package/transpiled/directives/io/Output.d.ts +13 -0
  333. package/transpiled/directives/io/Output.js +76 -0
  334. package/transpiled/directives/io/Output.js.map +1 -0
  335. package/transpiled/directives/io/index.d.ts +2 -0
  336. package/transpiled/directives/io/index.js +6 -0
  337. package/transpiled/directives/io/index.js.map +1 -0
  338. package/transpiled/directives/io/schemas.d.ts +7 -0
  339. package/transpiled/directives/io/schemas.js +14 -0
  340. package/transpiled/directives/io/schemas.js.map +1 -0
  341. package/transpiled/directives/octets/Context.d.ts +4 -4
  342. package/transpiled/directives/octets/Context.js +4 -2
  343. package/transpiled/directives/octets/Context.js.map +1 -1
  344. package/transpiled/directives/octets/Delete.d.ts +4 -3
  345. package/transpiled/directives/octets/Delete.js +22 -10
  346. package/transpiled/directives/octets/Delete.js.map +1 -1
  347. package/transpiled/directives/octets/Directive.d.ts +8 -0
  348. package/transpiled/directives/octets/Directive.js +8 -0
  349. package/transpiled/directives/octets/Directive.js.map +1 -0
  350. package/transpiled/directives/octets/Fetch.d.ts +4 -3
  351. package/transpiled/directives/octets/Fetch.js +31 -15
  352. package/transpiled/directives/octets/Fetch.js.map +1 -1
  353. package/transpiled/directives/octets/List.d.ts +4 -3
  354. package/transpiled/directives/octets/List.js +16 -7
  355. package/transpiled/directives/octets/List.js.map +1 -1
  356. package/transpiled/directives/octets/Octets.d.ts +4 -4
  357. package/transpiled/directives/octets/Octets.js +5 -5
  358. package/transpiled/directives/octets/Octets.js.map +1 -1
  359. package/transpiled/directives/octets/Store.d.ts +4 -3
  360. package/transpiled/directives/octets/Store.js +20 -13
  361. package/transpiled/directives/octets/Store.js.map +1 -1
  362. package/transpiled/directives/octets/Workflow.d.ts +4 -3
  363. package/transpiled/directives/octets/Workflow.js +11 -4
  364. package/transpiled/directives/octets/Workflow.js.map +1 -1
  365. package/transpiled/directives/octets/types.d.ts +0 -5
  366. package/transpiled/directives/octets/workflows/Workflow.d.ts +1 -1
  367. package/transpiled/directives/octets/workflows/Workflow.js +2 -2
  368. package/transpiled/directives/octets/workflows/Workflow.js.map +1 -1
  369. package/transpiled/directives/require/Directive.d.ts +4 -0
  370. package/transpiled/directives/require/Directive.js +3 -0
  371. package/transpiled/directives/require/Directive.js.map +1 -0
  372. package/transpiled/directives/require/Headers.d.ts +7 -0
  373. package/transpiled/directives/require/Headers.js +19 -0
  374. package/transpiled/directives/require/Headers.js.map +1 -0
  375. package/transpiled/directives/require/Require.d.ts +9 -0
  376. package/transpiled/directives/require/Require.js +27 -0
  377. package/transpiled/directives/require/Require.js.map +1 -0
  378. package/transpiled/directives/require/index.d.ts +2 -0
  379. package/transpiled/directives/require/index.js +6 -0
  380. package/transpiled/directives/require/index.js.map +1 -0
  381. package/transpiled/directives/vary/Directive.d.ts +2 -1
  382. package/transpiled/directives/vary/Embed.d.ts +2 -1
  383. package/transpiled/directives/vary/Embed.js +8 -6
  384. package/transpiled/directives/vary/Embed.js.map +1 -1
  385. package/transpiled/directives/vary/Vary.d.ts +3 -3
  386. package/transpiled/directives/vary/Vary.js +4 -4
  387. package/transpiled/directives/vary/Vary.js.map +1 -1
  388. package/transpiled/directives/vary/embeddings/Authority.d.ts +5 -0
  389. package/transpiled/directives/vary/embeddings/Authority.js +10 -0
  390. package/transpiled/directives/vary/embeddings/Authority.js.map +1 -0
  391. package/transpiled/directives/vary/embeddings/Embedding.d.ts +2 -1
  392. package/transpiled/directives/vary/embeddings/Header.js +9 -7
  393. package/transpiled/directives/vary/embeddings/Header.js.map +1 -1
  394. package/transpiled/directives/vary/embeddings/Language.js +2 -2
  395. package/transpiled/directives/vary/embeddings/Language.js.map +1 -1
  396. package/transpiled/directives/vary/embeddings/Parameter.d.ts +7 -0
  397. package/transpiled/directives/vary/embeddings/Parameter.js +14 -0
  398. package/transpiled/directives/vary/embeddings/Parameter.js.map +1 -0
  399. package/transpiled/directives/vary/embeddings/index.d.ts +2 -2
  400. package/transpiled/directives/vary/embeddings/index.js +8 -4
  401. package/transpiled/directives/vary/embeddings/index.js.map +1 -1
  402. package/transpiled/exceptions.d.ts +3 -2
  403. package/transpiled/exceptions.js +13 -7
  404. package/transpiled/exceptions.js.map +1 -1
  405. package/transpiled/io.d.ts +2 -2
  406. package/transpiled/root.js +5 -0
  407. package/transpiled/root.js.map +1 -1
  408. package/transpiled/schemas.d.ts +1 -1
  409. package/transpiled/schemas.js +2 -2
  410. package/transpiled/schemas.js.map +1 -1
  411. package/transpiled/tsconfig.tsbuildinfo +1 -1
  412. package/components/identity.basic/operations/create.d.ts +0 -10
  413. package/components/identity.basic/operations/create.js +0 -10
  414. package/components/identity.basic/operations/create.js.map +0 -1
  415. package/components/identity.basic/source/create.ts +0 -18
  416. package/components/identity.federation/operations/create.d.ts +0 -10
  417. package/components/identity.federation/operations/create.js.map +0 -1
  418. package/components/identity.federation/operations/schemas.d.ts +0 -59
  419. package/components/identity.federation/operations/schemas.js +0 -9
  420. package/components/identity.federation/operations/schemas.js.map +0 -1
  421. package/components/identity.federation/operations/types.js.map +0 -1
  422. package/components/identity.federation/source/schemas.ts +0 -61
  423. package/components/octets.storage/operations/permute.js +0 -7
  424. package/source/HTTP/Server.fixtures.ts +0 -40
  425. package/source/HTTP/Server.test.ts +0 -126
  426. package/source/directives/octets/Permute.ts +0 -37
  427. package/transpiled/HTTP/Server.fixtures.d.ts +0 -10
  428. package/transpiled/HTTP/Server.fixtures.js +0 -31
  429. package/transpiled/HTTP/Server.fixtures.js.map +0 -1
  430. package/transpiled/directives/octets/Permute.d.ts +0 -10
  431. package/transpiled/directives/octets/Permute.js.map +0 -1
@@ -1,149 +1,147 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Server = void 0;
29
+ exports.DELAY = exports.PORT = exports.Server = void 0;
7
30
  const node_fs_1 = __importDefault(require("node:fs"));
8
31
  const node_os_1 = __importDefault(require("node:os"));
9
- const express_1 = __importDefault(require("express"));
32
+ const http = __importStar(require("node:http"));
33
+ const node_events_1 = require("node:events");
34
+ const promises_1 = require("node:timers/promises");
10
35
  const core_1 = require("@toa.io/core");
11
- const generic_1 = require("@toa.io/generic");
12
- const negotiator_1 = __importDefault(require("negotiator"));
13
36
  const messages_1 = require("./messages");
14
37
  const exceptions_1 = require("./exceptions");
15
- const formats_1 = require("./formats");
38
+ const Context_1 = require("./Context");
16
39
  class Server extends core_1.Connector {
17
- server;
18
- app;
19
- debug;
20
- requestedPort;
21
- constructor(app, debug, port) {
40
+ server = http.createServer();
41
+ properties;
42
+ authorities;
43
+ process;
44
+ ready = false;
45
+ startedAt = 0;
46
+ constructor(properties) {
22
47
  super();
23
- this.app = app;
24
- this.debug = debug;
25
- this.requestedPort = port;
26
- }
27
- get port() {
28
- if (this.server === undefined)
29
- return this.requestedPort;
30
- const address = this.server.address();
31
- if (address === null || typeof address === 'string')
32
- throw new Error('Server is not listening on a port.');
33
- return address.port;
48
+ this.properties = properties;
49
+ this.authorities = Object.fromEntries(Object.entries(properties.authorities).map(([key, value]) => [value, key]));
50
+ this.server.on('request', (req, res) => this.listener(req, res));
34
51
  }
35
52
  static create(options) {
36
- const properties = options === undefined
37
- ? DEFAULTS
38
- : { ...DEFAULTS, ...options };
39
- const app = (0, express_1.default)();
40
- app.disable('x-powered-by');
41
- app.use(supportedMethods(properties.methods));
42
- return new Server(app, properties.debug, properties.port);
53
+ const properties = Object.assign({}, DEFAULTS, options);
54
+ return new Server(properties);
43
55
  }
44
56
  attach(process) {
45
- this.app.use((request, response) => {
46
- const message = this.extend(request);
47
- process(message)
48
- .then(this.success(message, response))
49
- .catch(this.fail(message, response));
50
- });
57
+ this.process = process;
51
58
  }
52
59
  async open() {
53
- const listening = (0, generic_1.promex)();
54
- this.server = this.app.listen(this.requestedPort, listening.callback);
55
- await listening;
56
- console.info('HTTP Server is listening.');
60
+ this.startedAt = Date.now();
61
+ this.server.listen(this.properties.port);
62
+ await (0, node_events_1.once)(this.server, 'listening');
63
+ console.info('HTTP Server is listening');
64
+ await (0, promises_1.setTimeout)(this.properties.delay);
65
+ this.ready = true;
66
+ console.info('Ready');
57
67
  }
58
68
  async close() {
59
- const stopped = (0, generic_1.promex)();
60
- this.server?.close(stopped.callback);
61
- await stopped;
62
- this.server = undefined;
63
- console.info('HTTP Server has been stopped.');
69
+ this.server.close();
70
+ this.ready = false;
71
+ console.info('HTTP Server stopped accepting new connections');
72
+ await (0, node_events_1.once)(this.server, 'close');
73
+ console.info('HTTP Server has been stopped');
64
74
  }
65
- extend(request) {
66
- const message = request;
67
- negotiate(request, message);
68
- message.pipelines = { body: [], response: [] };
69
- message.parse = async () => {
70
- const value = await (0, messages_1.read)(request);
71
- if (message.pipelines.body.length === 0)
72
- return value;
73
- return message.pipelines.body.reduce((value, transform) => transform(value), value);
74
- };
75
- return message;
75
+ listener(request, response) {
76
+ if (request.method === undefined || !this.properties.methods.has(request.method)) {
77
+ response.writeHead(501).end();
78
+ return;
79
+ }
80
+ if (request.url === '/.ready') {
81
+ if (this.ready)
82
+ response.writeHead(200, { 'cache-control': 'no-store' }).end();
83
+ else {
84
+ const remaining = (Math.ceil((Date.now() - this.startedAt) / 1000)).toString();
85
+ response.writeHead(503, { 'retry-after': remaining }).end();
86
+ }
87
+ return;
88
+ }
89
+ if (request.headers.host === undefined || !(request.headers.host in this.authorities)) {
90
+ response.writeHead(404).end('Unknown authority');
91
+ return;
92
+ }
93
+ const authority = this.authorities[request.headers.host];
94
+ const context = new Context_1.Context(authority, request, this.properties);
95
+ this.process(context)
96
+ .then(this.success(context, response))
97
+ .catch(this.fail(context, response));
76
98
  }
77
- success(request, response) {
99
+ success(context, response) {
78
100
  return (message) => {
79
101
  let status = message.status;
80
102
  if (status === undefined)
81
103
  if (message.body === null)
82
104
  status = 404;
83
- else if (request.method === 'POST')
105
+ else if (context.request.method === 'POST')
84
106
  status = 201;
85
107
  else if (message.body === undefined)
86
108
  status = 204;
87
109
  else
88
110
  status = 200;
89
- response.status(status);
90
- (0, messages_1.write)(request, response, message);
111
+ response.statusCode = message.status = status;
112
+ (0, messages_1.write)(context, response, message);
91
113
  };
92
114
  }
93
- fail(request, response) {
115
+ fail(context, response) {
94
116
  return async (exception) => {
95
- if (!request.complete)
96
- await adam(request);
97
- const status = exception instanceof exceptions_1.Exception
98
- ? exception.status
99
- : 500;
100
- response.status(status);
101
- const message = {};
102
- const verbose = exception instanceof exceptions_1.ClientError || this.debug;
117
+ if (!context.request.complete)
118
+ await adam(context.request);
119
+ response.statusCode = exception instanceof exceptions_1.Exception ? exception.status : 500;
120
+ const message = { status: response.statusCode };
121
+ const verbose = exception instanceof exceptions_1.ClientError || this.properties.debug;
103
122
  if (verbose)
104
- message.body = exception instanceof exceptions_1.Exception
105
- ? exception.body
106
- : (exception.stack ?? exception.message);
107
- (0, messages_1.write)(request, response, message);
123
+ message.body =
124
+ exception instanceof exceptions_1.Exception
125
+ ? exception.body
126
+ : exception.stack ?? exception.message;
127
+ (0, messages_1.write)(context, response, message);
108
128
  };
109
129
  }
110
130
  }
111
131
  exports.Server = Server;
112
- function supportedMethods(methods) {
113
- return (req, res, next) => {
114
- if (methods.has(req.method))
115
- next();
116
- else
117
- res.sendStatus(501);
118
- };
119
- }
120
- function negotiate(request, message) {
121
- if (request.headers.accept !== undefined) {
122
- const match = SUBTYPE.exec(request.headers.accept);
123
- if (match !== null) {
124
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
125
- const { type, subtype, suffix } = match.groups;
126
- request.headers.accept = `${type}/${suffix}`;
127
- message.subtype = subtype;
128
- }
129
- }
130
- const negotiator = new negotiator_1.default(request);
131
- const mediaType = negotiator.mediaType(formats_1.types);
132
- message.encoder = mediaType === undefined ? null : formats_1.formats[mediaType];
133
- }
134
132
  // https://github.com/whatwg/fetch/issues/1254
135
133
  async function adam(request) {
136
- const completed = (0, generic_1.promex)();
137
134
  const devnull = node_fs_1.default.createWriteStream(node_os_1.default.devNull);
138
- request
139
- .on('end', completed.callback)
140
- .pipe(devnull);
141
- return await completed;
135
+ request.pipe(devnull);
136
+ return (0, node_events_1.once)(request, 'end');
142
137
  }
138
+ exports.PORT = 8000;
139
+ exports.DELAY = 3; // seconds
143
140
  const DEFAULTS = {
144
141
  methods: new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']),
145
142
  debug: false,
146
- port: 8000
143
+ trace: false,
144
+ port: exports.PORT,
145
+ delay: exports.DELAY * 1000
147
146
  };
148
- const SUBTYPE = /^(?<type>\w{1,32})\/(vnd\.toa\.(?<subtype>\S{1,32})\+)(?<suffix>\S{1,32})$/;
149
147
  //# sourceMappingURL=Server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Server.js","sourceRoot":"","sources":["../../source/HTTP/Server.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwB;AACxB,sDAAwB;AACxB,sDAA6B;AAC7B,uCAAwC;AACxC,6CAAwC;AACxC,4DAAmC;AACnC,yCAAoF;AACpF,6CAAqD;AACrD,uCAA0C;AAI1C,MAAa,MAAO,SAAQ,gBAAS;IAC3B,MAAM,CAAc;IACX,GAAG,CAAS;IACZ,KAAK,CAAS;IACd,aAAa,CAAQ;IAEtC,YAAqB,GAAY,EAAE,KAAc,EAAE,IAAY;QAC7D,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;IAC3B,CAAC;IAED,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,aAAa,CAAA;QAExD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QAErC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ;YACjD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;QAEvD,OAAO,OAAO,CAAC,IAAI,CAAA;IACrB,CAAC;IAEM,MAAM,CAAC,MAAM,CAAE,OAA6B;QACjD,MAAM,UAAU,GAAG,OAAO,KAAK,SAAS;YACtC,CAAC,CAA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EY,QAAA,IAAI,GAAG,IAAI,CAAA;AACX,QAAA,KAAK,GAAG,CAAC,CAAA,CAAC,UAAU;AAEjC,MAAM,QAAQ,GAAoC;IAChD,OAAO,EAAE,IAAI,GAAG,CAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC9E,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,YAAI;IACV,KAAK,EAAE,aAAK,GAAG,IAAI;CACpB,CAAA"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import type { ServerResponse } from 'node:http';
3
+ export declare class Timing {
4
+ private readonly skip;
5
+ private readonly start;
6
+ private readonly breakpoints;
7
+ constructor(enabled: boolean);
8
+ capture<T>(id: string, promise: Promise<T>): Promise<T>;
9
+ append(response: ServerResponse): void;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Timing = void 0;
4
+ const node_perf_hooks_1 = require("node:perf_hooks");
5
+ class Timing {
6
+ skip;
7
+ start = node_perf_hooks_1.performance.now();
8
+ breakpoints = [];
9
+ constructor(enabled) {
10
+ this.skip = !enabled;
11
+ }
12
+ async capture(id, promise) {
13
+ if (this.skip)
14
+ return promise;
15
+ const start = node_perf_hooks_1.performance.now();
16
+ const result = promise instanceof Promise ? await promise : promise;
17
+ this.breakpoints.push({ id, duration: node_perf_hooks_1.performance.now() - start });
18
+ return result;
19
+ }
20
+ append(response) {
21
+ if (this.skip)
22
+ return;
23
+ this.breakpoints.push({ id: 'total', duration: node_perf_hooks_1.performance.now() - this.start });
24
+ for (const breakpoint of this.breakpoints)
25
+ response.appendHeader('server-timing', `${breakpoint.id};dur=${breakpoint.duration.toFixed(3)}`);
26
+ }
27
+ }
28
+ exports.Timing = Timing;
29
+ //# sourceMappingURL=Timing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Timing.js","sourceRoot":"","sources":["../../source/HTTP/Timing.ts"],"names":[],"mappings":";;;AAAA,qDAA6C;AAG7C,MAAa,MAAM;IACA,IAAI,CAAS;IACb,KAAK,GAAG,6BAAW,CAAC,GAAG,EAAE,CAAA;IACzB,WAAW,GAAiB,EAAE,CAAA;IAE/C,YAAoB,OAAgB;QAClC,IAAI,CAAC,IAAI,GAAG,CAAC,OAAO,CAAA;IACtB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAK,EAAU,EAAE,OAAmB;QACtD,IAAI,IAAI,CAAC,IAAI;YACX,OAAO,OAAO,CAAA;QAEhB,MAAM,KAAK,GAAG,6BAAW,CAAC,GAAG,EAAE,CAAA;QAC/B,MAAM,MAAM,GAAG,OAAO,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,OAAO,CAAA;QAEnE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,6BAAW,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;QAElE,OAAO,MAAM,CAAA;IACf,CAAC;IAEM,MAAM,CAAE,QAAwB;QACrC,IAAI,IAAI,CAAC,IAAI;YACX,OAAM;QAER,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,6BAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QAEhF,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW;YACvC,QAAQ,CAAC,YAAY,CAAC,eAAe,EACnC,GAAG,UAAU,CAAC,EAAE,QAAQ,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IAC/D,CAAC;CACF;AA/BD,wBA+BC"}
@@ -18,7 +18,10 @@ export declare class NotFound extends ClientError {
18
18
  constructor(body?: any);
19
19
  }
20
20
  export declare class Conflict extends ClientError {
21
- constructor(body: any);
21
+ constructor(body?: any);
22
+ }
23
+ export declare class UnprocessableEntity extends ClientError {
24
+ constructor(body?: any);
22
25
  }
23
26
  export declare class MethodNotAllowed extends ClientError {
24
27
  constructor();
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PreconditionFailed = exports.UnsupportedMediaType = exports.NotAcceptable = exports.MethodNotAllowed = exports.Conflict = exports.NotFound = exports.Forbidden = exports.Unauthorized = exports.BadRequest = exports.ClientError = exports.Exception = void 0;
3
+ exports.PreconditionFailed = exports.UnsupportedMediaType = exports.NotAcceptable = exports.MethodNotAllowed = exports.UnprocessableEntity = exports.Conflict = exports.NotFound = exports.Forbidden = exports.Unauthorized = exports.BadRequest = exports.ClientError = exports.Exception = void 0;
4
4
  class Exception extends Error {
5
5
  status;
6
6
  body;
@@ -44,6 +44,12 @@ class Conflict extends ClientError {
44
44
  }
45
45
  }
46
46
  exports.Conflict = Conflict;
47
+ class UnprocessableEntity extends ClientError {
48
+ constructor(body) {
49
+ super(422, body);
50
+ }
51
+ }
52
+ exports.UnprocessableEntity = UnprocessableEntity;
47
53
  class MethodNotAllowed extends ClientError {
48
54
  constructor() {
49
55
  super(405);
@@ -1 +1 @@
1
- {"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../source/HTTP/exceptions.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAClB,MAAM,CAAQ;IACd,IAAI,CAAM;IAE1B,YAAuB,MAAc,EAAE,IAAU;QAC/C,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AATD,8BASC;AAED,MAAa,WAAY,SAAQ,SAAS;CACzC;AADD,kCACC;AAED,MAAa,UAAW,SAAQ,WAAW;IACzC,YAAoB,IAAU;QAC5B,KAAK,CAAC,GAAG,EAAE,IAAI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E,KAAK,CAAC,GAAG,CAAC,CAAA;IACZ,CAAC;CACF;AAJD,gDAIC"}
@@ -1,3 +1,4 @@
1
1
  export * from './Server';
2
2
  export * from './messages';
3
3
  export * from './exceptions';
4
+ export * from './Context';
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Server"), exports);
18
18
  __exportStar(require("./messages"), exports);
19
19
  __exportStar(require("./exceptions"), exports);
20
+ __exportStar(require("./Context"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/HTTP/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,6CAA0B;AAC1B,+CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/HTTP/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,6CAA0B;AAC1B,+CAA4B;AAC5B,4CAAyB"}
@@ -1,33 +1,19 @@
1
1
  /// <reference types="node" />
2
- import { type IncomingHttpHeaders } from 'node:http';
3
- import { type Request, type Response } from 'express';
4
- import type { ParsedQs } from 'qs';
5
- import type { Format } from './formats';
6
- export declare function write(request: IncomingMessage, response: Response, message: OutgoingMessage): void;
7
- export declare function read(request: Request): Promise<any>;
8
- export interface IncomingMessage extends Request {
9
- method: string;
10
- path: string;
11
- url: string;
12
- headers: IncomingHttpHeaders;
13
- query: Query;
14
- parse: <T>() => Promise<T>;
15
- encoder: Format | null;
16
- subtype: string | null;
17
- pipelines: {
18
- body: Array<(input: unknown) => unknown>;
19
- response: Array<(output: OutgoingMessage) => void>;
20
- };
21
- }
2
+ import type { Context } from './Context';
3
+ import type * as http from 'node:http';
4
+ export declare function write(context: Context, response: http.ServerResponse, message: OutgoingMessage): void;
5
+ export declare function read(context: Context): Promise<any>;
22
6
  export interface OutgoingMessage {
23
7
  status?: number;
24
8
  headers?: Headers;
25
9
  body?: any;
26
10
  }
27
- export interface Query extends ParsedQs {
11
+ export interface Query {
12
+ [key: string]: string | number | undefined;
28
13
  id?: string;
29
14
  criteria?: string;
30
15
  sort?: string;
31
16
  omit?: string;
32
17
  limit?: string;
18
+ version?: number;
33
19
  }
@@ -2,27 +2,28 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.read = exports.write = void 0;
4
4
  const node_stream_1 = require("node:stream");
5
- const streams_1 = require("@toa.io/streams");
5
+ const consumers_1 = require("node:stream/consumers");
6
6
  const formats_1 = require("./formats");
7
7
  const exceptions_1 = require("./exceptions");
8
- function write(request, response, message) {
9
- for (const transform of request.pipelines.response)
8
+ function write(context, response, message) {
9
+ for (const transform of context.pipelines.response)
10
10
  transform(message);
11
- message.headers?.forEach((value, key) => response.set(key, value));
11
+ message.headers?.forEach((value, key) => response.setHeader(key, value));
12
+ context.timing.append(response);
12
13
  if (message.body instanceof node_stream_1.Readable)
13
- stream(message, request, response);
14
+ stream(message, context, response);
14
15
  else
15
- send(message, request, response);
16
+ send(message, context, response);
16
17
  }
17
18
  exports.write = write;
18
- async function read(request) {
19
- const type = request.headers['content-type'];
19
+ async function read(context) {
20
+ const type = context.request.headers['content-type'];
20
21
  if (type === undefined)
21
22
  return undefined;
22
23
  if (!(type in formats_1.formats))
23
24
  throw new exceptions_1.UnsupportedMediaType();
24
25
  const format = formats_1.formats[type];
25
- const buf = await (0, streams_1.buffer)(request);
26
+ const buf = await context.timing.capture('buffer', (0, consumers_1.buffer)(context.request));
26
27
  try {
27
28
  return format.decode(buf);
28
29
  }
@@ -31,45 +32,42 @@ async function read(request) {
31
32
  }
32
33
  }
33
34
  exports.read = read;
34
- function send(message, request, response) {
35
+ function send(message, context, response) {
35
36
  if (message.body === undefined || message.body === null) {
36
37
  response.end();
37
38
  return;
38
39
  }
39
- if (request.encoder === null)
40
+ if (context.encoder === null)
40
41
  throw new exceptions_1.NotAcceptable();
41
- const buf = request.encoder.encode(message.body);
42
+ const buf = context.encoder.encode(message.body);
42
43
  response
43
- .set('content-type', request.encoder.type)
44
- .append('vary', 'accept')
44
+ .setHeader('content-type', context.encoder.type)
45
+ .appendHeader('vary', 'accept')
45
46
  .end(buf);
46
47
  }
47
- function stream(message, request, response) {
48
+ function stream(message, context, response) {
48
49
  const encoded = message.headers !== undefined && message.headers.has('content-type');
49
50
  if (encoded)
50
- pipe(message, response);
51
+ message.body.pipe(response);
51
52
  else
52
- multipart(message, request, response);
53
+ multipart(message, context, response);
53
54
  message.body.on('error', (e) => {
54
55
  console.error(e);
55
56
  response.end();
56
57
  });
57
58
  }
58
- function pipe(message, response) {
59
- message.headers?.forEach((value, key) => response.set(key, value));
60
- message.body.pipe(response);
61
- }
62
- function multipart(message, request, response) {
63
- if (request.encoder === null)
59
+ function multipart(message, context, response) {
60
+ if (context.encoder === null)
64
61
  throw new exceptions_1.NotAcceptable();
65
- const encoder = request.encoder;
66
- response.set('content-type', `${encoder.multipart}; boundary=${BOUNDARY}`);
62
+ const encoder = context.encoder;
63
+ response.setHeader('content-type', `${encoder.multipart}; boundary=${BOUNDARY}`);
67
64
  message.body
68
- .map((part) => Buffer.concat([CUT, encoder.encode(part)]))
65
+ .map((part) => Buffer.concat([CUT, encoder.encode(part), CRLF]))
69
66
  .on('end', () => response.end(FINALCUT))
70
67
  .pipe(response);
71
68
  }
72
69
  const BOUNDARY = 'cut';
73
70
  const CUT = Buffer.from(`--${BOUNDARY}\r\n`);
71
+ const CRLF = Buffer.from('\r\n');
74
72
  const FINALCUT = Buffer.from(`--${BOUNDARY}--`);
75
73
  //# sourceMappingURL=messages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../source/HTTP/messages.ts"],"names":[],"mappings":";;;AACA,6CAAsC;AAEtC,6CAAwC;AACxC,uCAAmC;AACnC,6CAA8E;AAI9E,SAAgB,KAAK,CACpB,OAAwB,EAAE,QAAkB,EAAE,OAAwB;IACrE,KAAK,MAAM,SAAS,IAAI,OAAO,CAA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AC,CAAA;AAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAA"}
@@ -19,20 +19,23 @@ class QueryableMapping extends Mapping {
19
19
  }
20
20
  fit(input, qs, parameters) {
21
21
  const query = this.query.fit(qs, parameters);
22
- return { input, query };
22
+ return {
23
+ input,
24
+ query
25
+ };
23
26
  }
24
27
  }
25
28
  class InputMapping extends Mapping {
26
29
  fit(input, _, parameters) {
30
+ const request = {};
27
31
  if (input === undefined && parameters.length > 0)
28
32
  input = {};
29
- if (typeof input === 'object')
30
- this.assign(input, parameters);
31
- return { input };
32
- }
33
- assign(input, parameters) {
34
- for (const parameter of parameters)
35
- input[parameter.name] = parameter.value;
33
+ if (typeof input === 'object' && input !== null)
34
+ for (const parameter of parameters)
35
+ input[parameter.name] = parameter.value;
36
+ if (input !== undefined)
37
+ request.input = input;
38
+ return request;
36
39
  }
37
40
  }
38
41
  //# sourceMappingURL=Mapping.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Mapping.js","sourceRoot":"","sources":["../source/Mapping.ts"],"names":[],"mappings":";;;AACA,mCAA+B;AAK/B,MAAsB,OAAO;IACpB,MAAM,CAAC,MAAM,CAAE,KAAoB;QACxC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YACvC,OAAO,IAAI,YAAY,EAAE,CAAA;QAE3B,MAAM,CAAC,GAAG,IAAI,aAAK,CAAC,KAAK,CAAC,CAAA;QAE1B,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAChC,CAAC;CAGF;AAXD,0BAWC;AAED,MAAM,gBAAiB,SAAQ,OAAO;IACnB,KAAK,CAAO;IAE7B,YAAoB,KAAY;QAC9B,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEM,GAAG,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,KAAU,EAAE,EAAc,EAAE,UAAuB;QAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;QAE5C,OAAO;YACL,KAAK;YACL,KAAK;SACN,CAAA;IACH,CAAC;CACF;AAED,MAAM,YAAa,SAAQ,OAAO;IACzB,GAAG,CAAE,KAAU,EAAE,CAAU,EAAE,UAAuB;QACzD,MAAM,OAAO,GAAiB,EAAE,CAAA;QAEhC,IAAI,KAAK,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;YAC9C,KAAK,GAAG,EAAE,CAAA;QAEZ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;YAC7C,KAAK,MAAM,SAAS,IAAI,UAAU;gBAChC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAA;QAE3C,IAAI,KAAK,KAAK,SAAS;YACrB,OAAO,CAAC,KAAK,GAAG,KAAK,CAAA;QAEvB,OAAO,OAAO,CAAA;IAChB,CAAC;CACF"}
@@ -5,6 +5,7 @@ import type * as core from '@toa.io/core';
5
5
  export declare class Query {
6
6
  private readonly query;
7
7
  private readonly closed;
8
+ private readonly prepend;
8
9
  constructor(query: syntax.Query);
9
10
  fit(query: http.Query, parameters: Parameter[]): core.Query;
10
11
  private fitCriteria;