@toa.io/extensions.exposition 1.0.0-alpha.2 → 1.0.0-alpha.21

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 (383) hide show
  1. package/components/identity.bans/manifest.toa.yaml +15 -6
  2. package/components/identity.bans/operations/transit.d.ts +14 -0
  3. package/components/identity.bans/operations/transit.js +11 -0
  4. package/components/identity.bans/operations/transit.js.map +1 -0
  5. package/components/identity.bans/operations/tsconfig.tsbuildinfo +1 -0
  6. package/components/identity.bans/source/transit.ts +21 -0
  7. package/components/identity.bans/tsconfig.json +9 -0
  8. package/components/identity.basic/manifest.toa.yaml +5 -1
  9. package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
  10. package/components/identity.federation/manifest.toa.yaml +13 -7
  11. package/components/identity.federation/operations/authenticate.js +4 -4
  12. package/components/identity.federation/operations/authenticate.js.map +1 -1
  13. package/components/identity.federation/operations/create.js +4 -4
  14. package/components/identity.federation/operations/create.js.map +1 -1
  15. package/components/identity.federation/operations/{assertions-as-values.cjs → lib/assertions-as-values.js} +1 -1
  16. package/components/identity.federation/operations/lib/assertions-as-values.js.map +1 -0
  17. package/components/identity.federation/operations/{jwt.d.cts → lib/jwt.d.ts} +5 -4
  18. package/components/identity.federation/operations/{jwt.cjs → lib/jwt.js} +35 -11
  19. package/components/identity.federation/operations/lib/jwt.js.map +1 -0
  20. package/components/identity.federation/operations/schemas.d.ts +16 -0
  21. package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
  22. package/components/identity.federation/operations/types.d.ts +1 -1
  23. package/components/identity.federation/source/authenticate.ts +2 -2
  24. package/components/identity.federation/source/create.ts +2 -2
  25. package/components/identity.federation/source/{assertions-as-values.cts → lib/assertions-as-values.ts} +1 -2
  26. package/components/identity.federation/source/lib/jwt.test.ts +56 -0
  27. package/components/identity.federation/source/{jwt.cts → lib/jwt.ts} +57 -29
  28. package/components/identity.federation/source/schemas.ts +16 -0
  29. package/components/identity.federation/source/types.ts +1 -1
  30. package/components/identity.federation/tsconfig.json +2 -2
  31. package/components/identity.roles/manifest.toa.yaml +18 -5
  32. package/components/identity.roles/operations/grant.d.ts +10 -0
  33. package/components/identity.roles/operations/grant.js +21 -0
  34. package/components/identity.roles/operations/grant.js.map +1 -0
  35. package/components/identity.roles/operations/lib/Entity.d.ts +5 -0
  36. package/components/identity.roles/operations/lib/Entity.js +3 -0
  37. package/components/identity.roles/operations/lib/Entity.js.map +1 -0
  38. package/components/identity.roles/operations/list.d.ts +1 -4
  39. package/components/identity.roles/operations/list.js.map +1 -1
  40. package/components/identity.roles/operations/principal.d.ts +4 -6
  41. package/components/identity.roles/operations/principal.js +6 -1
  42. package/components/identity.roles/operations/principal.js.map +1 -1
  43. package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
  44. package/components/identity.roles/source/grant.ts +32 -0
  45. package/components/identity.roles/source/lib/Entity.ts +5 -0
  46. package/components/identity.roles/source/list.ts +2 -4
  47. package/components/identity.roles/source/principal.ts +10 -8
  48. package/components/identity.tokens/manifest.toa.yaml +12 -3
  49. package/components/identity.tokens/operations/authenticate.js +5 -2
  50. package/components/identity.tokens/operations/authenticate.js.map +1 -1
  51. package/components/identity.tokens/operations/encrypt.js +4 -1
  52. package/components/identity.tokens/operations/encrypt.js.map +1 -1
  53. package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
  54. package/components/identity.tokens/operations/types.d.ts +1 -2
  55. package/components/identity.tokens/receivers/identity.bans.created.js +3 -0
  56. package/components/identity.tokens/source/authenticate.ts +5 -2
  57. package/components/identity.tokens/source/encrypt.test.ts +22 -1
  58. package/components/identity.tokens/source/encrypt.ts +4 -1
  59. package/components/identity.tokens/source/types.ts +1 -2
  60. package/components/octets.storage/operations/store.js +1 -1
  61. package/documentation/access.md +27 -16
  62. package/documentation/cache.md +8 -1
  63. package/documentation/components.md +55 -23
  64. package/documentation/identity.md +7 -0
  65. package/documentation/io.md +56 -0
  66. package/documentation/octets.md +12 -0
  67. package/documentation/protocol.md +3 -0
  68. package/documentation/query.md +50 -5
  69. package/documentation/require.md +15 -0
  70. package/documentation/tree.md +22 -4
  71. package/documentation/vary.md +9 -3
  72. package/features/access.feature +28 -49
  73. package/features/annotation.feature +1 -0
  74. package/features/body.feature +3 -1
  75. package/features/cache.feature +39 -0
  76. package/features/cors.feature +2 -2
  77. package/features/directives.feature +2 -0
  78. package/features/dynamic.feature +14 -7
  79. package/features/errors.feature +7 -4
  80. package/features/etag.feature +97 -0
  81. package/features/identity.bans.feature +128 -0
  82. package/features/identity.basic.feature +68 -3
  83. package/features/identity.federation.feature +78 -5
  84. package/features/identity.roles.feature +205 -1
  85. package/features/identity.tokens.feature +98 -0
  86. package/features/io.feature +196 -0
  87. package/features/octets.entries.feature +3 -1
  88. package/features/octets.feature +32 -10
  89. package/features/octets.meta.feature +4 -3
  90. package/features/octets.workflows.feature +39 -0
  91. package/features/queries.feature +9 -1
  92. package/features/require.feature +64 -0
  93. package/features/response.feature +7 -1
  94. package/features/routes.feature +17 -10
  95. package/features/steps/Database.ts +17 -10
  96. package/features/steps/Gateway.ts +3 -0
  97. package/features/steps/IdP.ts +55 -21
  98. package/features/steps/components/echo/manifest.toa.yaml +5 -0
  99. package/features/steps/components/echo/operations/identity.js +7 -0
  100. package/features/steps/components/greeter/manifest.toa.yaml +1 -0
  101. package/features/steps/components/octets.tester/manifest.toa.yaml +1 -0
  102. package/features/steps/components/pots/manifest.toa.yaml +12 -3
  103. package/features/steps/components/sequences/manifest.toa.yaml +1 -0
  104. package/features/steps/components/users.properties/manifest.toa.yaml +2 -1
  105. package/features/timing.feature +66 -0
  106. package/features/vary.feature +56 -3
  107. package/package.json +13 -14
  108. package/readme.md +7 -6
  109. package/schemas/annotation.cos.yaml +1 -0
  110. package/schemas/io/input.cos.yaml +3 -0
  111. package/schemas/io/message.cos.yaml +5 -0
  112. package/schemas/io/output.cos.yaml +5 -0
  113. package/schemas/octets/workflow.cos.yaml +12 -0
  114. package/schemas/querystring.cos.yaml +1 -0
  115. package/source/Annotation.ts +1 -0
  116. package/source/Context.ts +6 -4
  117. package/source/Directive.test.ts +7 -7
  118. package/source/Directive.ts +19 -46
  119. package/source/Endpoint.ts +53 -6
  120. package/source/Factory.ts +17 -7
  121. package/source/Gateway.ts +40 -51
  122. package/source/HTTP/Context.ts +67 -0
  123. package/source/HTTP/Server.test.ts +1 -1
  124. package/source/HTTP/Server.ts +61 -96
  125. package/source/HTTP/Timing.ts +40 -0
  126. package/source/HTTP/exceptions.ts +1 -1
  127. package/source/HTTP/index.ts +1 -0
  128. package/source/HTTP/messages.test.ts +27 -8
  129. package/source/HTTP/messages.ts +32 -48
  130. package/source/Mapping.ts +7 -8
  131. package/source/RTD/Context.ts +7 -10
  132. package/source/RTD/Directives.ts +28 -4
  133. package/source/RTD/Endpoint.ts +6 -4
  134. package/source/RTD/Match.ts +2 -7
  135. package/source/RTD/Method.ts +7 -13
  136. package/source/RTD/Node.ts +13 -14
  137. package/source/RTD/Tree.ts +17 -16
  138. package/source/RTD/factory.ts +3 -6
  139. package/source/Tenant.ts +0 -8
  140. package/source/deployment.ts +6 -0
  141. package/source/directives/auth/Anonymous.ts +3 -2
  142. package/source/directives/auth/Authorization.ts +17 -14
  143. package/source/directives/auth/Delegate.ts +35 -0
  144. package/source/directives/auth/Incept.ts +11 -6
  145. package/source/directives/auth/Role.test.ts +53 -6
  146. package/source/directives/auth/Role.ts +27 -17
  147. package/source/directives/auth/Scheme.ts +2 -2
  148. package/source/directives/auth/types.ts +1 -1
  149. package/source/directives/cache/Cache.ts +5 -5
  150. package/source/directives/cache/Control.ts +48 -22
  151. package/source/directives/cache/types.ts +1 -1
  152. package/source/directives/cors/CORS.ts +18 -10
  153. package/source/directives/dev/Development.ts +4 -4
  154. package/source/directives/index.ts +6 -4
  155. package/source/directives/io/Directive.ts +11 -0
  156. package/source/directives/io/IO.ts +43 -0
  157. package/source/directives/io/Input.ts +50 -0
  158. package/source/directives/io/Message.ts +1 -0
  159. package/source/directives/io/Output.ts +69 -0
  160. package/source/directives/io/index.ts +3 -0
  161. package/source/directives/io/schemas.ts +12 -0
  162. package/source/directives/octets/Context.ts +5 -4
  163. package/source/directives/octets/Delete.ts +25 -13
  164. package/source/directives/octets/Directive.ts +10 -0
  165. package/source/directives/octets/Fetch.ts +33 -17
  166. package/source/directives/octets/List.ts +18 -8
  167. package/source/directives/octets/Octets.ts +12 -8
  168. package/source/directives/octets/Permute.ts +16 -9
  169. package/source/directives/octets/Store.ts +43 -19
  170. package/source/directives/octets/Workflow.ts +48 -0
  171. package/source/directives/octets/schemas.test.ts +21 -0
  172. package/source/directives/octets/schemas.ts +2 -0
  173. package/source/directives/octets/types.ts +0 -7
  174. package/source/directives/octets/{workflow → workflows}/Execution.ts +0 -2
  175. package/source/directives/octets/{workflow → workflows}/Workflow.ts +2 -2
  176. package/source/directives/require/Directive.ts +5 -0
  177. package/source/directives/require/Headers.ts +20 -0
  178. package/source/directives/require/Require.ts +28 -0
  179. package/source/directives/require/index.ts +3 -0
  180. package/source/directives/vary/Directive.ts +2 -1
  181. package/source/directives/vary/Embed.ts +14 -8
  182. package/source/directives/vary/Vary.ts +8 -6
  183. package/source/directives/vary/embeddings/Embedding.ts +2 -1
  184. package/source/directives/vary/embeddings/Header.ts +9 -7
  185. package/source/directives/vary/embeddings/Language.ts +2 -2
  186. package/source/directives/vary/embeddings/Parameter.ts +14 -0
  187. package/source/directives/vary/embeddings/index.ts +3 -3
  188. package/source/exceptions.ts +22 -11
  189. package/source/io.ts +2 -2
  190. package/source/root.ts +5 -0
  191. package/transpiled/Annotation.d.ts +1 -0
  192. package/transpiled/Context.d.ts +6 -4
  193. package/transpiled/Directive.d.ts +8 -21
  194. package/transpiled/Directive.js +11 -14
  195. package/transpiled/Directive.js.map +1 -1
  196. package/transpiled/Endpoint.d.ts +7 -5
  197. package/transpiled/Endpoint.js +58 -2
  198. package/transpiled/Endpoint.js.map +1 -1
  199. package/transpiled/Factory.js +8 -2
  200. package/transpiled/Factory.js.map +1 -1
  201. package/transpiled/Gateway.d.ts +4 -8
  202. package/transpiled/Gateway.js +23 -33
  203. package/transpiled/Gateway.js.map +1 -1
  204. package/transpiled/HTTP/Context.d.ts +24 -0
  205. package/transpiled/HTTP/Context.js +47 -0
  206. package/transpiled/HTTP/Context.js.map +1 -0
  207. package/transpiled/HTTP/Server.d.ts +8 -7
  208. package/transpiled/HTTP/Server.js +69 -77
  209. package/transpiled/HTTP/Server.js.map +1 -1
  210. package/transpiled/HTTP/Timing.d.ts +10 -0
  211. package/transpiled/HTTP/Timing.js +29 -0
  212. package/transpiled/HTTP/Timing.js.map +1 -0
  213. package/transpiled/HTTP/exceptions.d.ts +1 -1
  214. package/transpiled/HTTP/exceptions.js.map +1 -1
  215. package/transpiled/HTTP/index.d.ts +1 -0
  216. package/transpiled/HTTP/index.js +1 -0
  217. package/transpiled/HTTP/index.js.map +1 -1
  218. package/transpiled/HTTP/messages.d.ts +7 -21
  219. package/transpiled/HTTP/messages.js +24 -26
  220. package/transpiled/HTTP/messages.js.map +1 -1
  221. package/transpiled/Mapping.js +7 -7
  222. package/transpiled/Mapping.js.map +1 -1
  223. package/transpiled/RTD/Context.d.ts +7 -6
  224. package/transpiled/RTD/Directives.d.ts +19 -4
  225. package/transpiled/RTD/Endpoint.d.ts +6 -4
  226. package/transpiled/RTD/Match.d.ts +2 -4
  227. package/transpiled/RTD/Method.d.ts +7 -7
  228. package/transpiled/RTD/Method.js.map +1 -1
  229. package/transpiled/RTD/Node.d.ts +4 -6
  230. package/transpiled/RTD/Node.js +2 -1
  231. package/transpiled/RTD/Node.js.map +1 -1
  232. package/transpiled/RTD/Tree.d.ts +6 -6
  233. package/transpiled/RTD/Tree.js +4 -1
  234. package/transpiled/RTD/Tree.js.map +1 -1
  235. package/transpiled/RTD/factory.d.ts +2 -4
  236. package/transpiled/RTD/factory.js +1 -1
  237. package/transpiled/RTD/factory.js.map +1 -1
  238. package/transpiled/Tenant.d.ts +0 -1
  239. package/transpiled/Tenant.js +0 -6
  240. package/transpiled/Tenant.js.map +1 -1
  241. package/transpiled/deployment.js +5 -0
  242. package/transpiled/deployment.js.map +1 -1
  243. package/transpiled/directives/auth/Anonymous.js +3 -4
  244. package/transpiled/directives/auth/Anonymous.js.map +1 -1
  245. package/transpiled/directives/auth/Authorization.d.ts +2 -3
  246. package/transpiled/directives/auth/Authorization.js +10 -8
  247. package/transpiled/directives/auth/Authorization.js.map +1 -1
  248. package/transpiled/directives/auth/Delegate.d.ts +8 -0
  249. package/transpiled/directives/auth/Delegate.js +29 -0
  250. package/transpiled/directives/auth/Delegate.js.map +1 -0
  251. package/transpiled/directives/auth/Incept.d.ts +1 -1
  252. package/transpiled/directives/auth/Incept.js +11 -6
  253. package/transpiled/directives/auth/Incept.js.map +1 -1
  254. package/transpiled/directives/auth/Role.d.ts +4 -1
  255. package/transpiled/directives/auth/Role.js +25 -17
  256. package/transpiled/directives/auth/Role.js.map +1 -1
  257. package/transpiled/directives/auth/Scheme.js +2 -2
  258. package/transpiled/directives/auth/Scheme.js.map +1 -1
  259. package/transpiled/directives/cache/Cache.d.ts +3 -3
  260. package/transpiled/directives/cache/Cache.js +3 -3
  261. package/transpiled/directives/cache/Cache.js.map +1 -1
  262. package/transpiled/directives/cache/Control.d.ts +5 -4
  263. package/transpiled/directives/cache/Control.js +32 -15
  264. package/transpiled/directives/cache/Control.js.map +1 -1
  265. package/transpiled/directives/cache/types.d.ts +1 -1
  266. package/transpiled/directives/cors/CORS.d.ts +2 -3
  267. package/transpiled/directives/cors/CORS.js +17 -10
  268. package/transpiled/directives/cors/CORS.js.map +1 -1
  269. package/transpiled/directives/dev/Development.d.ts +3 -3
  270. package/transpiled/directives/dev/Development.js +1 -1
  271. package/transpiled/directives/dev/Development.js.map +1 -1
  272. package/transpiled/directives/index.d.ts +2 -2
  273. package/transpiled/directives/index.js +5 -3
  274. package/transpiled/directives/index.js.map +1 -1
  275. package/transpiled/directives/io/Directive.d.ts +8 -0
  276. package/transpiled/directives/io/Directive.js +3 -0
  277. package/transpiled/directives/io/Directive.js.map +1 -0
  278. package/transpiled/directives/io/IO.d.ts +9 -0
  279. package/transpiled/directives/io/IO.js +33 -0
  280. package/transpiled/directives/io/IO.js.map +1 -0
  281. package/transpiled/directives/io/Input.d.ts +11 -0
  282. package/transpiled/directives/io/Input.js +63 -0
  283. package/transpiled/directives/io/Input.js.map +1 -0
  284. package/transpiled/directives/io/Message.d.ts +1 -0
  285. package/transpiled/directives/io/Message.js +3 -0
  286. package/transpiled/directives/io/Message.js.map +1 -0
  287. package/transpiled/directives/io/Output.d.ts +13 -0
  288. package/transpiled/directives/io/Output.js +76 -0
  289. package/transpiled/directives/io/Output.js.map +1 -0
  290. package/transpiled/directives/io/index.d.ts +2 -0
  291. package/transpiled/directives/io/index.js +6 -0
  292. package/transpiled/directives/io/index.js.map +1 -0
  293. package/transpiled/directives/io/schemas.d.ts +7 -0
  294. package/transpiled/directives/io/schemas.js +14 -0
  295. package/transpiled/directives/io/schemas.js.map +1 -0
  296. package/transpiled/directives/octets/Context.d.ts +4 -4
  297. package/transpiled/directives/octets/Context.js +4 -2
  298. package/transpiled/directives/octets/Context.js.map +1 -1
  299. package/transpiled/directives/octets/Delete.d.ts +5 -4
  300. package/transpiled/directives/octets/Delete.js +24 -12
  301. package/transpiled/directives/octets/Delete.js.map +1 -1
  302. package/transpiled/directives/octets/Directive.d.ts +8 -0
  303. package/transpiled/directives/octets/Directive.js +8 -0
  304. package/transpiled/directives/octets/Directive.js.map +1 -0
  305. package/transpiled/directives/octets/Fetch.d.ts +4 -3
  306. package/transpiled/directives/octets/Fetch.js +31 -15
  307. package/transpiled/directives/octets/Fetch.js.map +1 -1
  308. package/transpiled/directives/octets/List.d.ts +4 -3
  309. package/transpiled/directives/octets/List.js +16 -7
  310. package/transpiled/directives/octets/List.js.map +1 -1
  311. package/transpiled/directives/octets/Octets.d.ts +4 -4
  312. package/transpiled/directives/octets/Octets.js +8 -4
  313. package/transpiled/directives/octets/Octets.js.map +1 -1
  314. package/transpiled/directives/octets/Permute.d.ts +4 -3
  315. package/transpiled/directives/octets/Permute.js +14 -7
  316. package/transpiled/directives/octets/Permute.js.map +1 -1
  317. package/transpiled/directives/octets/Store.d.ts +6 -4
  318. package/transpiled/directives/octets/Store.js +28 -13
  319. package/transpiled/directives/octets/Store.js.map +1 -1
  320. package/transpiled/directives/octets/Workflow.d.ts +15 -0
  321. package/transpiled/directives/octets/Workflow.js +59 -0
  322. package/transpiled/directives/octets/Workflow.js.map +1 -0
  323. package/transpiled/directives/octets/schemas.d.ts +2 -0
  324. package/transpiled/directives/octets/schemas.js +2 -1
  325. package/transpiled/directives/octets/schemas.js.map +1 -1
  326. package/transpiled/directives/octets/types.d.ts +0 -5
  327. package/transpiled/directives/octets/{workflow → workflows}/Execution.js +0 -1
  328. package/transpiled/directives/octets/workflows/Execution.js.map +1 -0
  329. package/transpiled/directives/octets/{workflow → workflows}/Workflow.d.ts +1 -1
  330. package/transpiled/directives/octets/{workflow → workflows}/Workflow.js +2 -2
  331. package/transpiled/directives/octets/workflows/Workflow.js.map +1 -0
  332. package/transpiled/directives/octets/workflows/index.js.map +1 -0
  333. package/transpiled/directives/require/Directive.d.ts +4 -0
  334. package/transpiled/directives/require/Directive.js +3 -0
  335. package/transpiled/directives/require/Directive.js.map +1 -0
  336. package/transpiled/directives/require/Headers.d.ts +7 -0
  337. package/transpiled/directives/require/Headers.js +19 -0
  338. package/transpiled/directives/require/Headers.js.map +1 -0
  339. package/transpiled/directives/require/Require.d.ts +9 -0
  340. package/transpiled/directives/require/Require.js +27 -0
  341. package/transpiled/directives/require/Require.js.map +1 -0
  342. package/transpiled/directives/require/index.d.ts +2 -0
  343. package/transpiled/directives/require/index.js +6 -0
  344. package/transpiled/directives/require/index.js.map +1 -0
  345. package/transpiled/directives/vary/Directive.d.ts +2 -1
  346. package/transpiled/directives/vary/Embed.d.ts +2 -1
  347. package/transpiled/directives/vary/Embed.js +8 -6
  348. package/transpiled/directives/vary/Embed.js.map +1 -1
  349. package/transpiled/directives/vary/Vary.d.ts +3 -3
  350. package/transpiled/directives/vary/Vary.js +4 -4
  351. package/transpiled/directives/vary/Vary.js.map +1 -1
  352. package/transpiled/directives/vary/embeddings/Embedding.d.ts +2 -1
  353. package/transpiled/directives/vary/embeddings/Header.js +9 -7
  354. package/transpiled/directives/vary/embeddings/Header.js.map +1 -1
  355. package/transpiled/directives/vary/embeddings/Language.js +2 -2
  356. package/transpiled/directives/vary/embeddings/Language.js.map +1 -1
  357. package/transpiled/directives/vary/embeddings/Parameter.d.ts +7 -0
  358. package/transpiled/directives/vary/embeddings/Parameter.js +14 -0
  359. package/transpiled/directives/vary/embeddings/Parameter.js.map +1 -0
  360. package/transpiled/directives/vary/embeddings/index.d.ts +2 -2
  361. package/transpiled/directives/vary/embeddings/index.js +5 -3
  362. package/transpiled/directives/vary/embeddings/index.js.map +1 -1
  363. package/transpiled/exceptions.d.ts +3 -2
  364. package/transpiled/exceptions.js +13 -7
  365. package/transpiled/exceptions.js.map +1 -1
  366. package/transpiled/io.d.ts +2 -2
  367. package/transpiled/root.js +5 -0
  368. package/transpiled/root.js.map +1 -1
  369. package/transpiled/tsconfig.tsbuildinfo +1 -1
  370. package/components/identity.federation/operations/assertions-as-values.cjs.map +0 -1
  371. package/components/identity.federation/operations/jwt.cjs.map +0 -1
  372. package/source/HTTP/Server.fixtures.ts +0 -40
  373. package/transpiled/HTTP/Server.fixtures.d.ts +0 -10
  374. package/transpiled/HTTP/Server.fixtures.js +0 -31
  375. package/transpiled/HTTP/Server.fixtures.js.map +0 -1
  376. package/transpiled/directives/octets/workflow/Execution.js.map +0 -1
  377. package/transpiled/directives/octets/workflow/Workflow.js.map +0 -1
  378. package/transpiled/directives/octets/workflow/index.js.map +0 -1
  379. /package/components/identity.federation/operations/{assertions-as-values.d.cts → lib/assertions-as-values.d.ts} +0 -0
  380. /package/source/directives/octets/{workflow → workflows}/index.ts +0 -0
  381. /package/transpiled/directives/octets/{workflow → workflows}/Execution.d.ts +0 -0
  382. /package/transpiled/directives/octets/{workflow → workflows}/index.d.ts +0 -0
  383. /package/transpiled/directives/octets/{workflow → workflows}/index.js +0 -0
@@ -31,57 +31,47 @@ class Gateway extends core_1.Connector {
31
31
  broadcast;
32
32
  tree;
33
33
  interceptor;
34
- server;
35
- // eslint-disable-next-line max-params, max-len
36
- constructor(broadcast, server, tree, interception) {
34
+ constructor(broadcast, tree, interception) {
37
35
  super();
38
36
  this.broadcast = broadcast;
39
37
  this.tree = tree;
40
38
  this.interceptor = interception;
41
- this.server = server;
42
39
  this.depends(broadcast);
43
- // this.depends(server)
44
- server.attach(this.process.bind(this));
45
40
  }
46
- async open() {
47
- await this.discover();
48
- console.info('Gateway has started and is awaiting resource branches.');
49
- }
50
- dispose() {
51
- console.info('Gateway is closed.');
52
- }
53
- async process(request) {
54
- const interception = await this.interceptor.intercept(request);
41
+ async process(context) {
42
+ const interception = await context.timing.capture('intercept', this.interceptor.intercept(context));
55
43
  if (interception !== null)
56
44
  return interception;
57
- const match = this.tree.match(request.path);
45
+ const match = this.tree.match(context.url.pathname);
58
46
  if (match === null)
59
- throw new http.NotFound();
47
+ throw new http.NotFound('Route not found');
60
48
  const { node, parameters } = match;
61
- if (!(request.method in node.methods))
49
+ if (!(context.request.method in node.methods))
62
50
  throw new http.MethodNotAllowed();
63
- const method = node.methods[request.method];
64
- const interruption = await method.directives.preflight(request, parameters);
65
- const response = interruption ?? await this.call(method, request, parameters);
66
- await method.directives.settle(request, response);
51
+ const method = node.methods[context.request.method];
52
+ const interruption = await context.timing.capture('preflight', method.directives.preflight(context, parameters)).catch(exceptions_1.rethrow);
53
+ const response = interruption ??
54
+ await context.timing.capture('call', this.call(method, context, parameters));
55
+ await context.timing.capture('settle', method.directives.settle(context, response)).catch(exceptions_1.rethrow);
67
56
  return response;
68
57
  }
69
- async call(method, request, parameters) {
70
- if (request.path[request.path.length - 1] !== '/')
58
+ async open() {
59
+ await this.discover();
60
+ console.info('Gateway has started and is awaiting resource branches.');
61
+ }
62
+ dispose() {
63
+ console.info('Gateway is closed.');
64
+ }
65
+ async call(method, context, parameters) {
66
+ if (context.url.pathname[context.url.pathname.length - 1] !== '/')
71
67
  throw new http.NotFound('Trailing slash is required.');
72
- if (request.encoder === null)
68
+ if (context.encoder === null)
73
69
  throw new http.NotAcceptable();
74
70
  if (method.endpoint === null)
75
71
  throw new http.MethodNotAllowed();
76
- const body = await request.parse();
77
- if ('embed' in request && typeof body === 'object' && body !== null)
78
- Object.assign(body, request.embed);
79
- const reply = await method.endpoint
80
- .call(body, request.query, parameters)
72
+ return await method.endpoint
73
+ .call(context, parameters)
81
74
  .catch(exceptions_1.rethrow);
82
- if (reply instanceof Error)
83
- throw new http.Conflict(reply);
84
- return { body: reply };
85
75
  }
86
76
  async discover() {
87
77
  await this.broadcast.receive('expose', this.merge.bind(this));
@@ -1 +1 @@
1
- {"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../source/Gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AACvD,6CAA8B;AAC9B,6CAAsC;AAStC,MAAa,OAAQ,SAAQ,gBAAS;IACnB,SAAS,CAAW;IACpB,IAAI,CAA4B;IAChC,WAAW,CAAa;IACxB,MAAM,CAAW;IAElC,+CAA+C;IAC/C,YAAoB,SAAoB,EAAE,MAAmB,EAAE,IAAgC,EAAE,YAAyB;QACxH,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,WAAW,GAAG,YAAY,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACvB,uBAAuB;QAEvB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACxC,CAAC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A;QAExD,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI;YAC1B,MAAM,IAAI,IAAI,CAAC,aAAa,EAAE,CAAA;QAEhC,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI;YAC1B,MAAM,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAA;QAEnC,OAAO,MAAM,MAAM,CAAC,QAAQ;aACzB,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC;aACzB,KAAK,CAAC,oBAAO,CAAyB,CAAA;IAC3C,CAAC;IAEO,KAAK,CAAC,QAAQ;QACpB,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAS,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACrE,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAO,MAAM,EAAE,IAAI,CAAC,CAAA;IACnD,CAAC;IAEO,KAAK,CAAE,MAAc;QAC3B,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YAEpC,OAAO,CAAC,IAAI,CAAC,qBAAqB;gBAChC,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,oBAAoB,CAAC,CAAA;QACjE,CAAC;QAAC,OAAO,SAAS,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;CACF;AA1FD,0BA0FC"}
@@ -0,0 +1,24 @@
1
+ /// <reference types="node" />
2
+ import { Timing } from './Timing';
3
+ import { type Format } from './formats';
4
+ import type { OutgoingMessage } from './messages';
5
+ import type * as http from 'node:http';
6
+ export declare class Context {
7
+ readonly request: IncomingMessage;
8
+ readonly url: URL;
9
+ readonly subtype: string | null;
10
+ readonly encoder: Format | null;
11
+ readonly timing: Timing;
12
+ readonly pipelines: Pipelines;
13
+ constructor(request: IncomingMessage, trace?: boolean);
14
+ body<T>(): Promise<T>;
15
+ }
16
+ export interface IncomingMessage extends http.IncomingMessage {
17
+ url: string;
18
+ method: string;
19
+ }
20
+ interface Pipelines {
21
+ body: Array<(input: unknown) => unknown>;
22
+ response: Array<(output: OutgoingMessage) => void>;
23
+ }
24
+ export {};
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Context = void 0;
7
+ const negotiator_1 = __importDefault(require("negotiator"));
8
+ const Timing_1 = require("./Timing");
9
+ const formats_1 = require("./formats");
10
+ const messages_1 = require("./messages");
11
+ class Context {
12
+ request;
13
+ url;
14
+ subtype = null;
15
+ encoder = null;
16
+ timing;
17
+ pipelines = {
18
+ body: [],
19
+ response: []
20
+ };
21
+ constructor(request, trace = false) {
22
+ this.request = request;
23
+ this.url = new URL(request.url, `https://${request.headers.host}`);
24
+ this.timing = new Timing_1.Timing(trace);
25
+ if (this.request.headers.accept !== undefined) {
26
+ const match = SUBTYPE.exec(this.request.headers.accept);
27
+ if (match !== null) {
28
+ const { type, subtype, suffix } = match.groups;
29
+ this.request.headers.accept = `${type}/${suffix}`;
30
+ this.subtype = subtype;
31
+ }
32
+ }
33
+ const negotiator = new negotiator_1.default(this.request);
34
+ const mediaType = negotiator.mediaType(formats_1.types);
35
+ if (mediaType !== undefined)
36
+ this.encoder = formats_1.formats[mediaType];
37
+ }
38
+ async body() {
39
+ const value = await (0, messages_1.read)(this);
40
+ return this.pipelines.body.length === 0
41
+ ? value
42
+ : this.pipelines.body.reduce((value, transform) => transform(value), value);
43
+ }
44
+ }
45
+ exports.Context = Context;
46
+ const SUBTYPE = /^(?<type>\w{1,32})\/(vnd\.toa\.(?<subtype>\S{1,32})\+)(?<suffix>\S{1,32})$/;
47
+ //# sourceMappingURL=Context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.js","s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KAAK,SAAS;YACzB,IAAI,CAAC,OAAO,GAAG,iBAAO,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,KAAK,GAAG,MAAM,IAAA,eAAI,EAAC,IAAI,CAAC,CAAA;QAE9B,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;YACrC,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAA;IAC/E,CAAC;CACF;AA/CD,0BA+CC;AAYD,MAAM,OAAO,GAAG,4EAA4E,CAAA"}
@@ -1,24 +1,25 @@
1
1
  import { Connector } from '@toa.io/core';
2
- import { type IncomingMessage, type OutgoingMessage } from './messages';
2
+ import { type OutgoingMessage } from './messages';
3
+ import { Context } from './Context';
3
4
  export declare class Server extends Connector {
4
- private server?;
5
- private readonly app;
6
- private readonly debug;
7
- private readonly requestedPort;
5
+ private readonly server;
6
+ private readonly properties;
7
+ private process?;
8
8
  private constructor();
9
9
  get port(): number;
10
10
  static create(options?: Partial<Properties>): Server;
11
11
  attach(process: Processing): void;
12
12
  protected open(): Promise<void>;
13
13
  protected close(): Promise<void>;
14
- private extend;
14
+ private listener;
15
15
  private success;
16
16
  private fail;
17
17
  }
18
18
  interface Properties {
19
19
  methods: Set<string>;
20
20
  debug: boolean;
21
+ trace: boolean;
21
22
  port: number;
22
23
  }
23
- export type Processing = (input: IncomingMessage) => Promise<OutgoingMessage>;
24
+ export type Processing = (input: Context) => Promise<OutgoingMessage>;
24
25
  export {};
@@ -1,4 +1,27 @@
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
  };
@@ -6,27 +29,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
29
  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_assert_1 = __importDefault(require("node:assert"));
34
+ const node_events_1 = require("node:events");
10
35
  const core_1 = require("@toa.io/core");
11
36
  const generic_1 = require("@toa.io/generic");
12
- const negotiator_1 = __importDefault(require("negotiator"));
13
37
  const messages_1 = require("./messages");
14
38
  const exceptions_1 = require("./exceptions");
15
- const formats_1 = require("./formats");
39
+ const Context_1 = require("./Context");
16
40
  class Server extends core_1.Connector {
17
- server;
18
- app;
19
- debug;
20
- requestedPort;
21
- constructor(app, debug, port) {
41
+ server = http.createServer();
42
+ properties;
43
+ process;
44
+ constructor(properties) {
22
45
  super();
23
- this.app = app;
24
- this.debug = debug;
25
- this.requestedPort = port;
46
+ this.properties = properties;
47
+ this.server.on('request', (req, res) => this.listener(req, res));
26
48
  }
27
49
  get port() {
28
- if (this.server === undefined)
29
- return this.requestedPort;
50
+ if (this.properties.port !== 0)
51
+ return this.properties.port;
30
52
  const address = this.server.address();
31
53
  if (address === null || typeof address === 'string')
32
54
  throw new Error('Server is not listening on a port.');
@@ -36,101 +58,71 @@ class Server extends core_1.Connector {
36
58
  const properties = options === undefined
37
59
  ? DEFAULTS
38
60
  : { ...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);
61
+ return new Server(properties);
43
62
  }
44
63
  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
- });
64
+ this.process = process;
51
65
  }
52
66
  async open() {
53
- const listening = (0, generic_1.promex)();
54
- this.server = this.app.listen(this.requestedPort, listening.callback);
55
- await listening;
67
+ this.server.listen(this.properties.port);
68
+ await (0, node_events_1.once)(this.server, 'listening');
56
69
  console.info('HTTP Server is listening.');
57
70
  }
58
71
  async close() {
59
- const stopped = (0, generic_1.promex)();
60
- this.server?.close(stopped.callback);
61
- await stopped;
62
- this.server = undefined;
72
+ this.server.close();
73
+ console.info('HTTP Server stopped accepting new connections.');
74
+ await (0, node_events_1.once)(this.server, 'close');
63
75
  console.info('HTTP Server has been stopped.');
64
76
  }
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;
77
+ listener(request, response) {
78
+ if (request.method === undefined || !this.properties.methods.has(request.method)) {
79
+ response.writeHead(501).end();
80
+ return;
81
+ }
82
+ if (request.url === undefined) {
83
+ response.writeHead(400).end();
84
+ return;
85
+ }
86
+ node_assert_1.default.ok(this.process !== undefined, 'No processing function has been attached to the server.');
87
+ const context = new Context_1.Context(request, this.properties.trace);
88
+ this.process(context)
89
+ .then(this.success(context, response))
90
+ .catch(this.fail(context, response));
76
91
  }
77
- success(request, response) {
92
+ success(context, response) {
78
93
  return (message) => {
79
94
  let status = message.status;
80
95
  if (status === undefined)
81
96
  if (message.body === null)
82
97
  status = 404;
83
- else if (request.method === 'POST')
98
+ else if (context.request.method === 'POST')
84
99
  status = 201;
85
100
  else if (message.body === undefined)
86
101
  status = 204;
87
102
  else
88
103
  status = 200;
89
- response.status(status);
90
- (0, messages_1.write)(request, response, message);
104
+ response.statusCode = message.status = status;
105
+ (0, messages_1.write)(context, response, message);
91
106
  };
92
107
  }
93
- fail(request, response) {
108
+ fail(context, response) {
94
109
  return async (exception) => {
95
- if (!request.complete)
96
- await adam(request);
97
- const status = exception instanceof exceptions_1.Exception
110
+ if (!context.request.complete)
111
+ await adam(context.request);
112
+ response.statusCode = exception instanceof exceptions_1.Exception
98
113
  ? exception.status
99
114
  : 500;
100
- response.status(status);
101
- const message = {};
102
- const verbose = exception instanceof exceptions_1.ClientError || this.debug;
115
+ const message = { status: response.statusCode };
116
+ const verbose = exception instanceof exceptions_1.ClientError || this.properties.debug;
103
117
  if (verbose)
104
118
  message.body = exception instanceof exceptions_1.Exception
105
119
  ? exception.body
106
120
  : (exception.stack ?? exception.message);
107
- (0, messages_1.write)(request, response, message);
121
+ (0, messages_1.write)(context, response, message);
108
122
  };
109
123
  }
110
124
  }
111
125
  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
126
  // https://github.com/whatwg/fetch/issues/1254
135
127
  async function adam(request) {
136
128
  const completed = (0, generic_1.promex)();
@@ -138,12 +130,12 @@ async function adam(request) {
138
130
  request
139
131
  .on('end', completed.callback)
140
132
  .pipe(devnull);
141
- return await completed;
133
+ return completed;
142
134
  }
143
135
  const DEFAULTS = {
144
136
  methods: new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']),
145
137
  debug: false,
138
+ trace: false,
146
139
  port: 8000
147
140
  };
148
- const SUBTYPE = /^(?<type>\w{1,32})\/(vnd\.toa\.(?<subtype>\S{1,32})\+)(?<suffix>\S{1,32})$/;
149
141
  //# 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,C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AAC,GAAG,CAAA;YAEP,MAAM,OAAO,GAAoB,EAAE,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAA;YAChE,MAAM,OAAO,GAAG,SAAS,YAAY,wBAAW,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAA;YAEzE,IAAI,OAAO;gBACT,OAAO,CAAC,IAAI,GAAG,SAAS,YAAY,sBAAS;oBAC3C,CAAC,CAAC,SAAS,CAAC,IAAI;oBAChB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,OAAO,CAAC,CAAA;YAE5C,IAAA,gBAAK,EAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;QACnC,CAAC,CAAA;IACH,CAAC;CACF;AArHD,wBAqHC;AAED,8CAA8C;AAC9C,KAAK,UAAU,IAAI,CAAE,OAA6B;IAChD,MAAM,SAAS,GAAG,IAAA,gBAAM,GAAE,CAAA;IAC1B,MAAM,OAAO,GAAG,iBAAE,CAAC,iBAAiB,CAAC,iBAAE,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO;SACJ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC;SAC7B,IAAI,CAAC,OAAO,CAAC,CAAA;IAEhB,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,QAAQ,GAAe;IAC3B,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,IAAI;CACX,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,7 @@ 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
22
  }
23
23
  export declare class MethodNotAllowed extends ClientError {
24
24
  constructor();
@@ -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,I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ceptions';
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
  }