@h4ad/serverless-adapter 2.17.0 → 3.0.0

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 (325) hide show
  1. package/README.md +7 -0
  2. package/lib/@types/binary-settings.js +2 -11
  3. package/lib/@types/binary-settings.js.map +1 -1
  4. package/lib/@types/digital-ocean/digital-ocean-http-event.js +2 -7
  5. package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +1 -1
  6. package/lib/@types/digital-ocean/digital-ocean-http-response.js +2 -7
  7. package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +1 -1
  8. package/lib/@types/digital-ocean/index.js +2 -18
  9. package/lib/@types/digital-ocean/index.js.map +1 -1
  10. package/lib/@types/headers.js +2 -11
  11. package/lib/@types/headers.js.map +1 -1
  12. package/lib/@types/helpers.js +2 -6
  13. package/lib/@types/helpers.js.map +1 -1
  14. package/lib/@types/huawei/huawei-api-gateway-event.js +2 -14
  15. package/lib/@types/huawei/huawei-api-gateway-event.js.map +1 -1
  16. package/lib/@types/huawei/huawei-api-gateway-response.js +2 -7
  17. package/lib/@types/huawei/huawei-api-gateway-response.js.map +1 -1
  18. package/lib/@types/huawei/huawei-context.js +2 -36
  19. package/lib/@types/huawei/huawei-context.js.map +1 -1
  20. package/lib/@types/huawei/index.js +2 -20
  21. package/lib/@types/huawei/index.js.map +1 -1
  22. package/lib/@types/index.js +2 -20
  23. package/lib/@types/index.js.map +1 -1
  24. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +2 -86
  25. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +1 -1
  26. package/lib/adapters/apollo-server/index.js +2 -18
  27. package/lib/adapters/apollo-server/index.js.map +1 -1
  28. package/lib/adapters/aws/alb.adapter.js +2 -129
  29. package/lib/adapters/aws/alb.adapter.js.map +1 -1
  30. package/lib/adapters/aws/api-gateway-v1.adapter.js +2 -140
  31. package/lib/adapters/aws/api-gateway-v1.adapter.js.map +1 -1
  32. package/lib/adapters/aws/api-gateway-v2.adapter.js +2 -134
  33. package/lib/adapters/aws/api-gateway-v2.adapter.js.map +1 -1
  34. package/lib/adapters/aws/base/aws-simple-adapter.js +2 -99
  35. package/lib/adapters/aws/base/aws-simple-adapter.js.map +1 -1
  36. package/lib/adapters/aws/base/index.js +2 -18
  37. package/lib/adapters/aws/base/index.js.map +1 -1
  38. package/lib/adapters/aws/dynamodb.adapter.js +2 -64
  39. package/lib/adapters/aws/dynamodb.adapter.js.map +1 -1
  40. package/lib/adapters/aws/event-bridge.adapter.js +2 -75
  41. package/lib/adapters/aws/event-bridge.adapter.js.map +1 -1
  42. package/lib/adapters/aws/index.js +2 -27
  43. package/lib/adapters/aws/index.js.map +1 -1
  44. package/lib/adapters/aws/lambda-edge.adapter.js +2 -284
  45. package/lib/adapters/aws/lambda-edge.adapter.js.map +1 -1
  46. package/lib/adapters/aws/s3.adapter.js +2 -63
  47. package/lib/adapters/aws/s3.adapter.js.map +1 -1
  48. package/lib/adapters/aws/sns.adapter.js +2 -63
  49. package/lib/adapters/aws/sns.adapter.js.map +1 -1
  50. package/lib/adapters/aws/sqs.adapter.js +2 -64
  51. package/lib/adapters/aws/sqs.adapter.js.map +1 -1
  52. package/lib/adapters/azure/http-trigger-v4.adapter.js +2 -202
  53. package/lib/adapters/azure/http-trigger-v4.adapter.js.map +1 -1
  54. package/lib/adapters/azure/index.js +2 -18
  55. package/lib/adapters/azure/index.js.map +1 -1
  56. package/lib/adapters/digital-ocean/http-function.adapter.js +2 -118
  57. package/lib/adapters/digital-ocean/http-function.adapter.js.map +1 -1
  58. package/lib/adapters/digital-ocean/index.js +2 -18
  59. package/lib/adapters/digital-ocean/index.js.map +1 -1
  60. package/lib/adapters/dummy/dummy.adapter.js +2 -54
  61. package/lib/adapters/dummy/dummy.adapter.js.map +1 -1
  62. package/lib/adapters/dummy/index.js +2 -18
  63. package/lib/adapters/dummy/index.js.map +1 -1
  64. package/lib/adapters/huawei/huawei-api-gateway.adapter.js +2 -126
  65. package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +1 -1
  66. package/lib/adapters/huawei/index.js +2 -18
  67. package/lib/adapters/huawei/index.js.map +1 -1
  68. package/lib/contracts/adapter.contract.js +2 -18
  69. package/lib/contracts/adapter.contract.js.map +1 -1
  70. package/lib/contracts/framework.contract.js +2 -7
  71. package/lib/contracts/framework.contract.js.map +1 -1
  72. package/lib/contracts/handler.contract.js +2 -13
  73. package/lib/contracts/handler.contract.js.map +1 -1
  74. package/lib/contracts/index.js +2 -21
  75. package/lib/contracts/index.js.map +1 -1
  76. package/lib/contracts/resolver.contract.js +2 -15
  77. package/lib/contracts/resolver.contract.js.map +1 -1
  78. package/lib/core/base-handler.js +2 -67
  79. package/lib/core/base-handler.js.map +1 -1
  80. package/lib/core/constants.js +2 -33
  81. package/lib/core/constants.js.map +1 -1
  82. package/lib/core/current-invoke.js +2 -46
  83. package/lib/core/current-invoke.js.map +1 -1
  84. package/lib/core/event-body.js +2 -31
  85. package/lib/core/event-body.js.map +1 -1
  86. package/lib/core/headers.js +3 -97
  87. package/lib/core/headers.js.map +1 -1
  88. package/lib/core/index.js +2 -28
  89. package/lib/core/index.js.map +1 -1
  90. package/lib/core/is-binary.js +2 -118
  91. package/lib/core/is-binary.js.map +1 -1
  92. package/lib/core/logger.js +2 -115
  93. package/lib/core/logger.js.map +1 -1
  94. package/lib/core/no-op.js +2 -12
  95. package/lib/core/no-op.js.map +1 -1
  96. package/lib/core/optional.js +2 -31
  97. package/lib/core/optional.js.map +1 -1
  98. package/lib/core/path.js +2 -68
  99. package/lib/core/path.js.map +1 -1
  100. package/lib/core/stream.js +2 -63
  101. package/lib/core/stream.js.map +1 -1
  102. package/lib/frameworks/apollo-server/apollo-server.framework.js +2 -87
  103. package/lib/frameworks/apollo-server/apollo-server.framework.js.map +1 -1
  104. package/lib/frameworks/apollo-server/index.js +2 -18
  105. package/lib/frameworks/apollo-server/index.js.map +1 -1
  106. package/lib/frameworks/body-parser/base-body-parser.framework.js +2 -66
  107. package/lib/frameworks/body-parser/base-body-parser.framework.js.map +1 -1
  108. package/lib/frameworks/body-parser/index.js +2 -22
  109. package/lib/frameworks/body-parser/index.js.map +1 -1
  110. package/lib/frameworks/body-parser/json-body-parser.framework.js +2 -29
  111. package/lib/frameworks/body-parser/json-body-parser.framework.js.map +1 -1
  112. package/lib/frameworks/body-parser/raw-body-parser.framework.js +2 -29
  113. package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +1 -1
  114. package/lib/frameworks/body-parser/text-body-parser.framework.js +2 -29
  115. package/lib/frameworks/body-parser/text-body-parser.framework.js.map +1 -1
  116. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +2 -29
  117. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +1 -1
  118. package/lib/frameworks/cors/cors.framework.js +3 -145
  119. package/lib/frameworks/cors/cors.framework.js.map +1 -1
  120. package/lib/frameworks/cors/index.js +2 -18
  121. package/lib/frameworks/cors/index.js.map +1 -1
  122. package/lib/frameworks/deepkit/http-deepkit.framework.js +2 -33
  123. package/lib/frameworks/deepkit/http-deepkit.framework.js.map +1 -1
  124. package/lib/frameworks/deepkit/index.js +2 -18
  125. package/lib/frameworks/deepkit/index.js.map +1 -1
  126. package/lib/frameworks/express/express.framework.js +2 -22
  127. package/lib/frameworks/express/express.framework.js.map +1 -1
  128. package/lib/frameworks/express/index.js +2 -18
  129. package/lib/frameworks/express/index.js.map +1 -1
  130. package/lib/frameworks/fastify/fastify.framework.js +2 -23
  131. package/lib/frameworks/fastify/fastify.framework.js.map +1 -1
  132. package/lib/frameworks/fastify/helpers/no-op-content-parser.js +2 -27
  133. package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +1 -1
  134. package/lib/frameworks/fastify/index.js +2 -18
  135. package/lib/frameworks/fastify/index.js.map +1 -1
  136. package/lib/frameworks/hapi/hapi.framework.js +2 -23
  137. package/lib/frameworks/hapi/hapi.framework.js.map +1 -1
  138. package/lib/frameworks/hapi/index.js +2 -18
  139. package/lib/frameworks/hapi/index.js.map +1 -1
  140. package/lib/frameworks/koa/index.js +2 -18
  141. package/lib/frameworks/koa/index.js.map +1 -1
  142. package/lib/frameworks/koa/koa.framework.js +2 -22
  143. package/lib/frameworks/koa/koa.framework.js.map +1 -1
  144. package/lib/frameworks/lazy/index.js +2 -18
  145. package/lib/frameworks/lazy/index.js.map +1 -1
  146. package/lib/frameworks/lazy/lazy.framework.js +2 -82
  147. package/lib/frameworks/lazy/lazy.framework.js.map +1 -1
  148. package/lib/frameworks/trpc/index.js +2 -18
  149. package/lib/frameworks/trpc/index.js.map +1 -1
  150. package/lib/frameworks/trpc/trpc.framework.js +2 -153
  151. package/lib/frameworks/trpc/trpc.framework.js.map +1 -1
  152. package/lib/handlers/aws/aws-stream.handler.js +2 -169
  153. package/lib/handlers/aws/aws-stream.handler.js.map +1 -1
  154. package/lib/handlers/aws/index.js +2 -18
  155. package/lib/handlers/aws/index.js.map +1 -1
  156. package/lib/handlers/azure/azure.handler.js +2 -74
  157. package/lib/handlers/azure/azure.handler.js.map +1 -1
  158. package/lib/handlers/azure/index.js +2 -18
  159. package/lib/handlers/azure/index.js.map +1 -1
  160. package/lib/handlers/base/index.js +2 -18
  161. package/lib/handlers/base/index.js.map +1 -1
  162. package/lib/handlers/base/raw-request.js +2 -65
  163. package/lib/handlers/base/raw-request.js.map +1 -1
  164. package/lib/handlers/default/default.handler.js +2 -191
  165. package/lib/handlers/default/default.handler.js.map +1 -1
  166. package/lib/handlers/default/index.js +2 -18
  167. package/lib/handlers/default/index.js.map +1 -1
  168. package/lib/handlers/digital-ocean/digital-ocean.handler.js +2 -34
  169. package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +1 -1
  170. package/lib/handlers/digital-ocean/index.js +2 -18
  171. package/lib/handlers/digital-ocean/index.js.map +1 -1
  172. package/lib/handlers/firebase/http-firebase-v2.handler.js +2 -50
  173. package/lib/handlers/firebase/http-firebase-v2.handler.js.map +1 -1
  174. package/lib/handlers/firebase/http-firebase.handler.js +2 -27
  175. package/lib/handlers/firebase/http-firebase.handler.js.map +1 -1
  176. package/lib/handlers/firebase/index.js +2 -19
  177. package/lib/handlers/firebase/index.js.map +1 -1
  178. package/lib/handlers/gcp/gcp.handler.js +2 -40
  179. package/lib/handlers/gcp/gcp.handler.js.map +1 -1
  180. package/lib/handlers/gcp/index.js +2 -18
  181. package/lib/handlers/gcp/index.js.map +1 -1
  182. package/lib/handlers/huawei/http-huawei.handler.js +2 -106
  183. package/lib/handlers/huawei/http-huawei.handler.js.map +1 -1
  184. package/lib/handlers/huawei/index.js +2 -18
  185. package/lib/handlers/huawei/index.js.map +1 -1
  186. package/lib/index.doc.js +2 -0
  187. package/lib/index.doc.js.map +1 -0
  188. package/lib/index.js +2 -22
  189. package/lib/index.js.map +1 -1
  190. package/lib/network/index.js +2 -21
  191. package/lib/network/index.js.map +1 -1
  192. package/lib/network/request.js +2 -46
  193. package/lib/network/request.js.map +1 -1
  194. package/lib/network/response-stream.js +7 -88
  195. package/lib/network/response-stream.js.map +1 -1
  196. package/lib/network/response.js +4 -127
  197. package/lib/network/response.js.map +1 -1
  198. package/lib/network/utils.js +2 -21
  199. package/lib/network/utils.js.map +1 -1
  200. package/lib/resolvers/aws-context/aws-context.resolver.js +2 -59
  201. package/lib/resolvers/aws-context/aws-context.resolver.js.map +1 -1
  202. package/lib/resolvers/aws-context/index.js +2 -18
  203. package/lib/resolvers/aws-context/index.js.map +1 -1
  204. package/lib/resolvers/callback/callback.resolver.js +2 -53
  205. package/lib/resolvers/callback/callback.resolver.js.map +1 -1
  206. package/lib/resolvers/callback/index.js +2 -18
  207. package/lib/resolvers/callback/index.js.map +1 -1
  208. package/lib/resolvers/dummy/dummy.resolver.js +2 -24
  209. package/lib/resolvers/dummy/dummy.resolver.js.map +1 -1
  210. package/lib/resolvers/dummy/index.js +2 -18
  211. package/lib/resolvers/dummy/index.js.map +1 -1
  212. package/lib/resolvers/promise/index.js +2 -18
  213. package/lib/resolvers/promise/index.js.map +1 -1
  214. package/lib/resolvers/promise/promise.resolver.js +2 -48
  215. package/lib/resolvers/promise/promise.resolver.js.map +1 -1
  216. package/lib/serverless-adapter.js +2 -176
  217. package/lib/serverless-adapter.js.map +1 -1
  218. package/package.json +61 -79
  219. package/lib/@types/binary-settings.d.ts +0 -43
  220. package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +0 -37
  221. package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +0 -22
  222. package/lib/@types/digital-ocean/index.d.ts +0 -1
  223. package/lib/@types/headers.d.ts +0 -39
  224. package/lib/@types/helpers.d.ts +0 -10
  225. package/lib/@types/huawei/huawei-api-gateway-event.d.ts +0 -84
  226. package/lib/@types/huawei/huawei-api-gateway-response.d.ts +0 -27
  227. package/lib/@types/huawei/huawei-context.d.ts +0 -203
  228. package/lib/@types/huawei/index.d.ts +0 -3
  229. package/lib/@types/index.d.ts +0 -3
  230. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts +0 -56
  231. package/lib/adapters/apollo-server/index.d.ts +0 -1
  232. package/lib/adapters/aws/alb.adapter.d.ts +0 -66
  233. package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +0 -71
  234. package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +0 -70
  235. package/lib/adapters/aws/base/aws-simple-adapter.d.ts +0 -85
  236. package/lib/adapters/aws/base/index.d.ts +0 -1
  237. package/lib/adapters/aws/dynamodb.adapter.d.ts +0 -56
  238. package/lib/adapters/aws/event-bridge.adapter.d.ts +0 -64
  239. package/lib/adapters/aws/index.d.ts +0 -10
  240. package/lib/adapters/aws/lambda-edge.adapter.d.ts +0 -213
  241. package/lib/adapters/aws/s3.adapter.d.ts +0 -56
  242. package/lib/adapters/aws/sns.adapter.d.ts +0 -56
  243. package/lib/adapters/aws/sqs.adapter.d.ts +0 -56
  244. package/lib/adapters/azure/http-trigger-v4.adapter.d.ts +0 -81
  245. package/lib/adapters/azure/index.d.ts +0 -1
  246. package/lib/adapters/digital-ocean/http-function.adapter.d.ts +0 -65
  247. package/lib/adapters/digital-ocean/index.d.ts +0 -1
  248. package/lib/adapters/dummy/dummy.adapter.d.ts +0 -30
  249. package/lib/adapters/dummy/index.d.ts +0 -1
  250. package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +0 -66
  251. package/lib/adapters/huawei/index.d.ts +0 -1
  252. package/lib/contracts/adapter.contract.d.ts +0 -155
  253. package/lib/contracts/framework.contract.d.ts +0 -19
  254. package/lib/contracts/handler.contract.d.ts +0 -26
  255. package/lib/contracts/index.d.ts +0 -4
  256. package/lib/contracts/resolver.contract.d.ts +0 -86
  257. package/lib/core/base-handler.d.ts +0 -31
  258. package/lib/core/constants.d.ts +0 -31
  259. package/lib/core/current-invoke.d.ts +0 -48
  260. package/lib/core/event-body.d.ts +0 -21
  261. package/lib/core/headers.d.ts +0 -47
  262. package/lib/core/index.d.ts +0 -11
  263. package/lib/core/is-binary.d.ts +0 -72
  264. package/lib/core/logger.d.ts +0 -67
  265. package/lib/core/no-op.d.ts +0 -7
  266. package/lib/core/optional.d.ts +0 -21
  267. package/lib/core/path.d.ts +0 -36
  268. package/lib/core/stream.d.ts +0 -20
  269. package/lib/frameworks/apollo-server/apollo-server.framework.d.ts +0 -71
  270. package/lib/frameworks/apollo-server/index.d.ts +0 -1
  271. package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +0 -69
  272. package/lib/frameworks/body-parser/index.d.ts +0 -5
  273. package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +0 -26
  274. package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +0 -26
  275. package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +0 -26
  276. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +0 -26
  277. package/lib/frameworks/cors/cors.framework.d.ts +0 -78
  278. package/lib/frameworks/cors/index.d.ts +0 -1
  279. package/lib/frameworks/deepkit/http-deepkit.framework.d.ts +0 -17
  280. package/lib/frameworks/deepkit/index.d.ts +0 -1
  281. package/lib/frameworks/express/express.framework.d.ts +0 -16
  282. package/lib/frameworks/express/index.d.ts +0 -1
  283. package/lib/frameworks/fastify/fastify.framework.d.ts +0 -16
  284. package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +0 -13
  285. package/lib/frameworks/fastify/index.d.ts +0 -1
  286. package/lib/frameworks/hapi/hapi.framework.d.ts +0 -16
  287. package/lib/frameworks/hapi/index.d.ts +0 -1
  288. package/lib/frameworks/koa/index.d.ts +0 -1
  289. package/lib/frameworks/koa/koa.framework.d.ts +0 -16
  290. package/lib/frameworks/lazy/index.d.ts +0 -1
  291. package/lib/frameworks/lazy/lazy.framework.d.ts +0 -55
  292. package/lib/frameworks/trpc/index.d.ts +0 -1
  293. package/lib/frameworks/trpc/trpc.framework.d.ts +0 -155
  294. package/lib/handlers/aws/aws-stream.handler.d.ts +0 -83
  295. package/lib/handlers/aws/index.d.ts +0 -1
  296. package/lib/handlers/azure/azure.handler.d.ts +0 -45
  297. package/lib/handlers/azure/index.d.ts +0 -1
  298. package/lib/handlers/base/index.d.ts +0 -1
  299. package/lib/handlers/base/raw-request.d.ts +0 -30
  300. package/lib/handlers/default/default.handler.d.ts +0 -87
  301. package/lib/handlers/default/index.d.ts +0 -1
  302. package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +0 -16
  303. package/lib/handlers/digital-ocean/index.d.ts +0 -1
  304. package/lib/handlers/firebase/http-firebase-v2.handler.d.ts +0 -26
  305. package/lib/handlers/firebase/http-firebase.handler.d.ts +0 -18
  306. package/lib/handlers/firebase/index.d.ts +0 -2
  307. package/lib/handlers/gcp/gcp.handler.d.ts +0 -25
  308. package/lib/handlers/gcp/index.d.ts +0 -1
  309. package/lib/handlers/huawei/http-huawei.handler.d.ts +0 -59
  310. package/lib/handlers/huawei/index.d.ts +0 -1
  311. package/lib/index.d.ts +0 -5
  312. package/lib/network/index.d.ts +0 -4
  313. package/lib/network/request.d.ts +0 -44
  314. package/lib/network/response-stream.d.ts +0 -41
  315. package/lib/network/response.d.ts +0 -48
  316. package/lib/network/utils.d.ts +0 -7
  317. package/lib/resolvers/aws-context/aws-context.resolver.d.ts +0 -18
  318. package/lib/resolvers/aws-context/index.d.ts +0 -1
  319. package/lib/resolvers/callback/callback.resolver.d.ts +0 -23
  320. package/lib/resolvers/callback/index.d.ts +0 -1
  321. package/lib/resolvers/dummy/dummy.resolver.d.ts +0 -13
  322. package/lib/resolvers/dummy/index.d.ts +0 -1
  323. package/lib/resolvers/promise/index.d.ts +0 -1
  324. package/lib/resolvers/promise/promise.resolver.d.ts +0 -13
  325. package/lib/serverless-adapter.d.ts +0 -118
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.contract.js","sourceRoot":"","sources":["../../src/contracts/resolver.contract.ts"],"names":[],"mappings":";;;+BAEwB,SAAS;uCACD,oBAAoB"}
1
+ {"version":3,"file":"resolver.contract.js","sources":["../../src/contracts/resolver.contract.ts"],"sourcesContent":["//#region Imports\n\nimport { ILogger } from '../core';\nimport { AdapterContract } from './adapter.contract';\n\n//#endregion\n\n/**\n * The type that represents a resolver used to send the response, error or success, to the client\n *\n * @breadcrumb Contracts / ResolverContract\n * @public\n */\nexport type Resolver<TResponse, TReturn> = {\n /**\n * The method that will perform the task of forwarding the request to the framework and waiting for the promise to be resolved with the response\n *\n * @param task - The task to be executed\n */\n run(task: () => Promise<TResponse>): TReturn;\n};\n\n/**\n * The type that represents a delegate resolver that is passed to the adapter to handle what to do when an error occurs during forwarding.\n *\n * @breadcrumb Contracts / ResolverContract\n * @public\n */\nexport type DelegatedResolver<TResponse> = {\n /**\n * Send the success response to the client\n *\n * @param success - The serverless response\n */\n succeed: (response: TResponse) => void;\n\n /**\n * Send the error response to the client\n *\n * @param error - The error object\n */\n fail: (error: Error) => void;\n};\n\n/**\n * The createResolver contract props\n *\n * @breadcrumb Contracts / ResolverContract\n * @public\n */\nexport type ResolverProps<TEvent, TContext, TCallback, TResponse> = {\n /**\n * The event sent by the serverless environment\n */\n event: TEvent;\n\n /**\n * Indicates whether to forward the (error.stack) or not to the client\n */\n respondWithErrors: boolean;\n\n /**\n * The instance of the logger\n */\n log: ILogger;\n\n /**\n * The instance of the adapter\n */\n adapter: AdapterContract<TEvent, TContext, TResponse>;\n\n /**\n * The context sent by serverless\n */\n context?: TContext;\n\n /**\n * The callback sent by serverless\n */\n callback?: TCallback;\n};\n\n/**\n * The interface that represents the contract used to send the response to the client\n *\n * @breadcrumb Contracts / ResolverContract\n * @public\n */\nexport interface ResolverContract<\n TEvent,\n TContext,\n TCallback,\n TResponse,\n TReturn,\n> {\n /**\n * Create the resolver based on the context, callback or promise\n *\n * @param props - The props used to create the resolver\n */\n createResolver(\n props: ResolverProps<TEvent, TContext, TCallback, TResponse>,\n ): Resolver<TResponse, TReturn>;\n}\n"],"names":["resolver_contract_exports","__toCommonJS"],"mappings":"2VAAAA,EAAA,CAAA,EAAA,OAAA,QAAAC,EAAAD,CAAA"}
@@ -1,67 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseHandler = void 0;
4
- const { __ΩFrameworkContract } = require('../contracts');
5
- const { __ΩAdapterContract } = require('../contracts');
6
- const { __ΩResolverContract } = require('../contracts');
7
- const { __ΩBinarySettings } = require('../@types');
8
- const { __ΩILogger } = require('./index');
9
- const { __ΩServerlessHandler } = require('../contracts');
10
- const { __ΩAdapterRequest } = require('../contracts');
11
- function __assignType(fn, args) {
12
- fn.__type = args;
13
- return fn;
14
- }
15
- const network_1 = require("../network");
16
- //#endregion
17
- /**
18
- * The abstract class that represents the base class for a handler
19
- *
20
- * @breadcrumb Core
21
- * @public
22
- */
23
- class BaseHandler {
24
- //#endregion
25
- //#region Protected Methods
26
- /**
27
- * Get the adapter to handle a specific event and context
28
- *
29
- * @param event - The event sent by serverless
30
- * @param context - The context sent by serverless
31
- * @param adapters - The list of adapters
32
- * @param log - The instance of logger
33
- */
34
- getAdapterByEventAndContext(event, context, adapters, log) {
35
- const resolvedAdapters = adapters.filter(__assignType(adapter => adapter.canHandle(event, context, log), ['adapter', '', 'P"2!"/"']));
36
- if (resolvedAdapters.length === 0) {
37
- throw new Error("SERVERLESS_ADAPTER: Couldn't find adapter to handle this event.");
38
- }
39
- if (resolvedAdapters.length > 1) {
40
- throw new Error(`SERVERLESS_ADAPTER: Two or more adapters was resolved by the event, the adapters are: ${adapters
41
- .map(__assignType(adapter => adapter.getAdapterName(), ['adapter', '', 'P"2!"/"']))
42
- .join(', ')}.`);
43
- }
44
- return resolvedAdapters[0];
45
- }
46
- /**
47
- * Get serverless request and response frmo the adapter request
48
- *
49
- * @param requestValues - The request values from adapter
50
- */
51
- getServerlessRequestResponseFromAdapterRequest(requestValues) {
52
- const request = new network_1.ServerlessRequest({
53
- method: requestValues.method,
54
- headers: requestValues.headers,
55
- body: requestValues.body,
56
- remoteAddress: requestValues.remoteAddress,
57
- url: requestValues.path,
58
- });
59
- const response = new network_1.ServerlessResponse({
60
- method: requestValues.method,
61
- });
62
- return [request, response];
63
- }
64
- }
65
- exports.BaseHandler = BaseHandler;
66
- BaseHandler.__type = ['TApp', 'TEvent', 'TContext', 'TCallback', 'TResponse', 'TReturn', 'app', () => __ΩFrameworkContract, 'framework', () => __ΩAdapterContract, 'adapters', () => __ΩResolverContract, 'resolverFactory', () => __ΩBinarySettings, 'binarySettings', 'respondWithErrors', () => __ΩILogger, 'log', () => __ΩServerlessHandler, 'getHandler', 'event', 'context', () => __ΩAdapterContract, () => __ΩILogger, () => __ΩAdapterContract, 'getAdapterByEventAndContext', () => __ΩAdapterRequest, 'requestValues', () => network_1.ServerlessRequest, 'request', () => network_1.ServerlessResponse, 'response', 'getServerlessRequestResponseFromAdapterRequest', 'b!b"b#b$b%b&Pe"!2\'e"!o("2)e""e"#e"%o*$F2+e""e"#e"$e"%e"&o,&2-n.2/)20n122e"&o3"04=Pe""25e"#26e""e"#e"%o7$F2+n822e""e"#e"%o9$0:<Pn;2<PP7=I>P7?I@G0A<5e!!e!"e!#e!$e!%e!&6\''];
67
- //# sourceMappingURL=base-handler.js.map
1
+ "use strict";var d=Object.defineProperty,v=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,c=(r,e)=>{for(var t in e)d(r,t,{get:e[t],enumerable:!0})},i=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of h(e))!l.call(r,n)&&n!==t&&d(r,n,{get:()=>e[n],enumerable:!(o=v(e,n))||o.enumerable});return r},w=r=>i(d({},"__esModule",{value:!0}),r),_={};c(_,{BaseHandler:()=>y});module.exports=w(_);var p=require("../network");class y{getAdapterByEventAndContext(e,t,o,n){const a=o.filter(s=>s.canHandle(e,t,n));if(a.length===0)throw new Error("SERVERLESS_ADAPTER: Couldn't find adapter to handle this event.");if(a.length>1)throw new Error(`SERVERLESS_ADAPTER: Two or more adapters was resolved by the event, the adapters are: ${o.map(s=>s.getAdapterName()).join(", ")}.`);return a[0]}getServerlessRequestResponseFromAdapterRequest(e){const t=new p.ServerlessRequest({method:e.method,headers:e.headers,body:e.body,remoteAddress:e.remoteAddress,url:e.path}),o=new p.ServerlessResponse({method:e.method});return[t,o]}}
2
+ //# sourceMappingURL=base-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-handler.js","sourceRoot":"","sources":["../../src/core/base-handler.ts"],"names":[],"mappings":";;;yCAUO,cAAc;uCAAd,cAAc;wCAAd,cAAc;sCARU,WAAW;+BAUlB,SAAS;yCAF1B,cAAc;sCAAd,cAAc;;;;;AACrB,wCAAmE;AAGnE,YAAY;AAEZ;;;;;GAKG;AACH,MAAsB,WAAW;IA+B/B,YAAY;IAEZ,2BAA2B;IAE3B;;;;;;;OAOG;IACO,2BAA2B,CACnC,KAAa,EACb,OAAiB,EACjB,QAAwD,EACxD,GAAY;QAEZ,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,cAAC,OAAO,CAAC,EAAE,CACjD,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,8BACvC,CAAC;QAEF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE;YACjC,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;SACH;QAED,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;YAC/B,MAAM,IAAI,KAAK,CACb,yFAAyF,QAAQ;iBAC9F,GAAG,cAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,8BAAC;iBACxC,IAAI,CAAC,IAAI,CAAC,GAAG,CACjB,CAAC;SACH;QAED,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACO,8CAA8C,CACtD,aAA6B;QAE7B,MAAM,OAAO,GAAG,IAAI,2BAAiB,CAAC;YACpC,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,OAAO,EAAE,aAAa,CAAC,OAAO;YAC9B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,aAAa,EAAE,aAAa,CAAC,aAAa;YAC1C,GAAG,EAAE,aAAa,CAAC,IAAI;SACxB,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,IAAI,4BAAkB,CAAC;YACtC,MAAM,EAAE,aAAa,CAAC,MAAM;SAC7B,CAAC,CAAC;QAEH,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7B,CAAC;;AA3FH,kCA8FC"}
1
+ {"version":3,"file":"base-handler.js","sources":["../../src/core/base-handler.ts"],"sourcesContent":["//#region Imports\n\nimport { BinarySettings } from '../@types';\nimport {\n AdapterContract,\n AdapterRequest,\n FrameworkContract,\n HandlerContract,\n ResolverContract,\n ServerlessHandler,\n} from '../contracts';\nimport { ServerlessRequest, ServerlessResponse } from '../network';\nimport { ILogger } from './index';\n\n//#endregion\n\n/**\n * The abstract class that represents the base class for a handler\n *\n * @breadcrumb Core\n * @public\n */\nexport abstract class BaseHandler<\n TApp,\n TEvent,\n TContext,\n TCallback,\n TResponse,\n TReturn,\n> implements\n HandlerContract<TApp, TEvent, TContext, TCallback, TResponse, TReturn>\n{\n //#region Public Methods\n\n /**\n * Get the handler that will handle serverless requests\n */\n public abstract getHandler(\n app: TApp,\n framework: FrameworkContract<TApp>,\n adapters: AdapterContract<TEvent, TContext, TResponse>[],\n resolverFactory: ResolverContract<\n TEvent,\n TContext,\n TCallback,\n TResponse,\n TReturn\n >,\n binarySettings: BinarySettings,\n respondWithErrors: boolean,\n log: ILogger,\n ): ServerlessHandler<TReturn>;\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Get the adapter to handle a specific event and context\n *\n * @param event - The event sent by serverless\n * @param context - The context sent by serverless\n * @param adapters - The list of adapters\n * @param log - The instance of logger\n */\n protected getAdapterByEventAndContext(\n event: TEvent,\n context: TContext,\n adapters: AdapterContract<TEvent, TContext, TResponse>[],\n log: ILogger,\n ): AdapterContract<TEvent, TContext, TResponse> {\n const resolvedAdapters = adapters.filter(adapter =>\n adapter.canHandle(event, context, log),\n );\n\n if (resolvedAdapters.length === 0) {\n throw new Error(\n \"SERVERLESS_ADAPTER: Couldn't find adapter to handle this event.\",\n );\n }\n\n if (resolvedAdapters.length > 1) {\n throw new Error(\n `SERVERLESS_ADAPTER: Two or more adapters was resolved by the event, the adapters are: ${adapters\n .map(adapter => adapter.getAdapterName())\n .join(', ')}.`,\n );\n }\n\n return resolvedAdapters[0];\n }\n\n /**\n * Get serverless request and response frmo the adapter request\n *\n * @param requestValues - The request values from adapter\n */\n protected getServerlessRequestResponseFromAdapterRequest(\n requestValues: AdapterRequest,\n ): [request: ServerlessRequest, response: ServerlessResponse] {\n const request = new ServerlessRequest({\n method: requestValues.method,\n headers: requestValues.headers,\n body: requestValues.body,\n remoteAddress: requestValues.remoteAddress,\n url: requestValues.path,\n });\n\n const response = new ServerlessResponse({\n method: requestValues.method,\n });\n\n return [request, response];\n }\n\n //#endregion\n}\n"],"names":["base_handler_exports","__export","BaseHandler","__toCommonJS","import_network","event","context","adapters","log","resolvedAdapters","adapter","requestValues","request","response"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,YAAA,IAAAE,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAH,CAAA,EAWA,IAAsDI,EAAA,QAAA,YAAA,EAW/C,MAAeF,CAStB,CAkCY,4BACRG,EACAC,EACAC,EACAC,EAC8C,CAC9C,MAAMC,EAAmBF,EAAS,OAChCG,GAAAA,EAAQ,UAAUL,EAAOC,EAASE,CAAG,CAAA,EAGnC,GAAAC,EAAiB,SAAW,EAC9B,MAAM,IAAI,MACR,iEAAA,EAIA,GAAAA,EAAiB,OAAS,EAC5B,MAAM,IAAI,MACR,yFAAyFF,EACtF,IAAIG,GAAWA,EAAQ,eAAe,CAAC,EACvC,KAAK,IAAI,IAAA,EAIhB,OAAOD,EAAiB,CAAC,CAC3B,CAOU,+CACRE,EAC4D,CACtD,MAAAC,EAAU,IAAIR,EAAkB,kBAAA,CACpC,OAAQO,EAAc,OACtB,QAASA,EAAc,QACvB,KAAMA,EAAc,KACpB,cAAeA,EAAc,cAC7B,IAAKA,EAAc,IAAA,CACpB,EAEKE,EAAW,IAAIT,EAAmB,mBAAA,CACtC,OAAQO,EAAc,MAAA,CACvB,EAEM,MAAA,CAACC,EAASC,CAAQ,CAC3B,CAGF"}
@@ -1,33 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmptyResponse = exports.__ΩIEmptyResponse = exports.DEFAULT_BINARY_CONTENT_TYPES = exports.DEFAULT_BINARY_ENCODINGS = void 0;
4
- /**
5
- * Default encodings that are treated as binary, they are compared with the `Content-Encoding` header.
6
- *
7
- * @breadcrumb Core / Constants
8
- * @defaultValue ['gzip', 'deflate', 'br']
9
- * @public
10
- */
11
- exports.DEFAULT_BINARY_ENCODINGS = ['gzip', 'deflate', 'br'];
12
- /**
13
- * Default content types that are treated as binary, they are compared with the `Content-Type` header.
14
- *
15
- * @breadcrumb Core / Constants
16
- * @defaultValue [new RegExp('^image/.*$'), new RegExp('^video/.*$'), 'application/pdf']
17
- * @public
18
- */
19
- exports.DEFAULT_BINARY_CONTENT_TYPES = [
20
- new RegExp('^image/.*$'),
21
- new RegExp('^video/.*$'),
22
- 'application/pdf',
23
- ];
24
- const __ΩIEmptyResponse = ['PM'];
25
- exports.__ΩIEmptyResponse = __ΩIEmptyResponse;
26
- /**
27
- * Constant for empty response and can be used on some adapters when the adapter does not need to return a response.
28
- *
29
- * @breadcrumb Core / Constants
30
- * @public
31
- */
32
- exports.EmptyResponse = {};
33
- //# sourceMappingURL=constants.js.map
1
+ "use strict";var a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,s=(t,e)=>{for(var p in e)a(t,p,{get:e[p],enumerable:!0})},c=(t,e,p,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of i(e))!g.call(t,r)&&r!==p&&a(t,r,{get:()=>e[r],enumerable:!(o=n(e,r))||o.enumerable});return t},N=t=>c(a({},"__esModule",{value:!0}),t),_={};s(_,{DEFAULT_BINARY_CONTENT_TYPES:()=>m,DEFAULT_BINARY_ENCODINGS:()=>O,EmptyResponse:()=>v});module.exports=N(_);const O=["gzip","deflate","br"],m=["image/png","image/jpeg","image/jpg","image/avif","image/bmp","image/x-png","image/gif","image/webp","video/mp4","application/pdf"],v={};
2
+ //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACU,QAAA,wBAAwB,GAAa,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AAE5E;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAwB;IAC/D,IAAI,MAAM,CAAC,YAAY,CAAC;IACxB,IAAI,MAAM,CAAC,YAAY,CAAC;IACxB,iBAAiB;CAClB,CAAC;;;AAWF;;;;;GAKG;AACU,QAAA,aAAa,GAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"constants.js","sources":["../../src/core/constants.ts"],"sourcesContent":["/**\n * Default encodings that are treated as binary, they are compared with the `Content-Encoding` header.\n *\n * @breadcrumb Core / Constants\n * @defaultValue ['gzip', 'deflate', 'br']\n * @public\n */\nexport const DEFAULT_BINARY_ENCODINGS: string[] = ['gzip', 'deflate', 'br'];\n\n/**\n * Default content types that are treated as binary, they are compared with the `Content-Type` header.\n *\n * @breadcrumb Core / Constants\n * @defaultValue ['image/png', 'image/jpeg', 'image/jpg', 'image/avif', 'image/bmp', 'image/x-png', 'image/gif', 'image/webp', 'video/mp4', 'application/pdf']\n * @public\n */\nexport const DEFAULT_BINARY_CONTENT_TYPES: string[] = [\n 'image/png',\n 'image/jpeg',\n 'image/jpg',\n 'image/avif',\n 'image/bmp',\n 'image/x-png',\n 'image/gif',\n 'image/webp',\n 'video/mp4',\n 'application/pdf',\n];\n\n/**\n * Type alias for empty response and can be used on some adapters when the adapter does not need to return a response.\n *\n * @breadcrumb Core / Constants\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type IEmptyResponse = {};\n\n/**\n * Constant for empty response and can be used on some adapters when the adapter does not need to return a response.\n *\n * @breadcrumb Core / Constants\n * @public\n */\nexport const EmptyResponse: IEmptyResponse = {};\n"],"names":["constants_exports","__export","DEFAULT_BINARY_CONTENT_TYPES","DEFAULT_BINARY_ENCODINGS","EmptyResponse","__toCommonJS"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,6BAAA,IAAAE,EAAA,yBAAA,IAAAC,EAAA,cAAA,IAAAC,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAL,CAAA,EAOO,MAAMG,EAAqC,CAAC,OAAQ,UAAW,IAAI,EAS7DD,EAAyC,CACpD,YACA,aACA,YACA,aACA,YACA,cACA,YACA,aACA,YACA,iBACF,EAiBaE,EAAgC,CAAC"}
@@ -1,46 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setCurrentInvoke = exports.getCurrentInvoke = exports.__ΩCurrentInvoke = void 0;
4
- const __ΩCurrentInvoke = ['TEvent', 'TContext', 'event', 'context', 'b!b"PPe#!,J4#Pe#",J4$M'];
5
- exports.__ΩCurrentInvoke = __ΩCurrentInvoke;
6
- const currentInvoke = {
7
- context: null,
8
- event: null,
9
- };
10
- /**
11
- * Get the reference to the event created by the serverless trigger or context created by the serverless environment.
12
- *
13
- * @example
14
- * ```typescript
15
- * import type { ALBEvent, Context } from 'aws-lambda';
16
- *
17
- * // inside the method that handles the aws alb request.
18
- * const { event, context } = getCurrentInvoke<ALBEvent, Context>();
19
- * ```
20
- *
21
- * @breadcrumb Core / Current Invoke
22
- * @public
23
- */
24
- function getCurrentInvoke() {
25
- return currentInvoke;
26
- }
27
- exports.getCurrentInvoke = getCurrentInvoke;
28
- getCurrentInvoke.__type = [() => __ΩCurrentInvoke, 'getCurrentInvoke', 'P""o!#/"'];
29
- /**
30
- * Method that saves to the event created by the serverless trigger or context created by the serverless environment.
31
- *
32
- * @remarks This method MUST NOT be called by you, this method MUST only be used internally in this library.
33
- *
34
- * @param event - The event created by the serverless trigger
35
- * @param context - The context created by the serverless environment
36
- *
37
- * @breadcrumb Core / Current Invoke
38
- * @public
39
- */
40
- function setCurrentInvoke({ event, context, }) {
41
- currentInvoke.event = event;
42
- currentInvoke.context = context;
43
- }
44
- exports.setCurrentInvoke = setCurrentInvoke;
45
- setCurrentInvoke.__type = [() => __ΩCurrentInvoke, 'param0', 'setCurrentInvoke', 'P""o!#2""/#'];
46
- //# sourceMappingURL=current-invoke.js.map
1
+ "use strict";var u=Object.defineProperty,_=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,s=(t,e)=>{for(var n in e)u(t,n,{get:e[n],enumerable:!0})},i=(t,e,n,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!a.call(t,r)&&r!==n&&u(t,r,{get:()=>e[r],enumerable:!(p=_(e,r))||p.enumerable});return t},l=t=>i(u({},"__esModule",{value:!0}),t),v={};s(v,{getCurrentInvoke:()=>O,setCurrentInvoke:()=>y});module.exports=l(v);const o={context:null,event:null};function O(){return o}function y({event:t,context:e}){o.event=t,o.context=e}
2
+ //# sourceMappingURL=current-invoke.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"current-invoke.js","sourceRoot":"","sources":["../../src/core/current-invoke.ts"],"names":[],"mappings":";;;;;AAsBA,MAAM,aAAa,GAA4B;IAC7C,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB;IAI9B,OAAO,aAAa,CAAC;AACvB,CAAC;AALD,4CAKC;;AAED;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAA+B,EAC7D,KAAK,EACL,OAAO,GACyB;IAChC,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC;AAClC,CAAC;AAND,4CAMC"}
1
+ {"version":3,"file":"current-invoke.js","sources":["../../src/core/current-invoke.ts"],"sourcesContent":["/**\n * The type that represents the object that handles the references to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport type CurrentInvoke<TEvent, TContext> = {\n /**\n * The event created by the serverless trigger\n *\n * @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.\n */\n event: TEvent | null;\n\n /**\n * The context created by the serverless environment\n *\n * @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.\n */\n context: TContext | null;\n};\n\nconst currentInvoke: CurrentInvoke<any, any> = {\n context: null,\n event: null,\n};\n\n/**\n * Get the reference to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @example\n * ```typescript\n * import type { ALBEvent, Context } from 'aws-lambda';\n *\n * // inside the method that handles the aws alb request.\n * const { event, context } = getCurrentInvoke<ALBEvent, Context>();\n * ```\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport function getCurrentInvoke<TEvent = any, TContext = any>(): CurrentInvoke<\n TEvent,\n TContext\n> {\n return currentInvoke;\n}\n\n/**\n * Method that saves to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @remarks This method MUST NOT be called by you, this method MUST only be used internally in this library.\n *\n * @param event - The event created by the serverless trigger\n * @param context - The context created by the serverless environment\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport function setCurrentInvoke<TEvent = any, TContext = any>({\n event,\n context,\n}: CurrentInvoke<TEvent, TContext>) {\n currentInvoke.event = event;\n currentInvoke.context = context;\n}\n"],"names":["current_invoke_exports","__export","getCurrentInvoke","setCurrentInvoke","__toCommonJS","currentInvoke","event","context"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,iBAAA,IAAAE,EAAA,iBAAA,IAAAC,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAJ,CAAA,EAsBA,MAAMK,EAAyC,CAC7C,QAAS,KACT,MAAO,IACT,EAgBO,SAASH,GAGd,CACO,OAAAG,CACT,CAaO,SAASF,EAA+C,CAC7D,MAAAG,EACA,QAAAC,CACF,EAAoC,CAClCF,EAAc,MAAQC,EACtBD,EAAc,QAAUE,CAC1B"}
@@ -1,31 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getEventBodyAsBuffer = void 0;
4
- /**
5
- * Get the event body as buffer from body string with content length
6
- *
7
- * @example
8
- * ```typescript
9
- * const body = '{}';
10
- * const [buffer, contentLength] = getEventBodyAsBuffer(body, false);
11
- * console.log(buffer);
12
- * // <Buffer 7b 7d>
13
- * console.log(contentLength);
14
- * // 2
15
- * ```
16
- *
17
- * @param body - The body string that can be encoded or not
18
- * @param isBase64Encoded - Tells if body string is encoded in base64
19
- *
20
- * @breadcrumb Core
21
- * @public
22
- */
23
- function getEventBodyAsBuffer(body, isBase64Encoded) {
24
- const encoding = isBase64Encoded ? 'base64' : 'utf8';
25
- const buffer = Buffer.from(body, encoding);
26
- const contentLength = Buffer.byteLength(buffer, encoding);
27
- return [buffer, contentLength];
28
- }
29
- exports.getEventBodyAsBuffer = getEventBodyAsBuffer;
30
- getEventBodyAsBuffer.__type = ['body', 'isBase64Encoded', 'contentLength', 'getEventBodyAsBuffer', 'P&2!)2"P!I!\'I#G/$'];
31
- //# sourceMappingURL=event-body.js.map
1
+ "use strict";var f=Object.defineProperty,u=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,s=(t,e)=>{for(var r in e)f(t,r,{get:e[r],enumerable:!0})},c=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _(e))!a.call(t,o)&&o!==r&&f(t,o,{get:()=>e[o],enumerable:!(n=u(e,o))||n.enumerable});return t},v=t=>c(f({},"__esModule",{value:!0}),t),p={};s(p,{getEventBodyAsBuffer:()=>y});module.exports=v(p);function y(t,e){const r=e?"base64":"utf8",n=Buffer.from(t,r),o=Buffer.byteLength(n,r);return[n,o]}
2
+ //# sourceMappingURL=event-body.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-body.js","sourceRoot":"","sources":["../../src/core/event-body.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,oBAAoB,CAClC,IAAY,EACZ,eAAwB;IAExB,MAAM,QAAQ,GAAmB,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAErE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE1D,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AACjC,CAAC;AAVD,oDAUC"}
1
+ {"version":3,"file":"event-body.js","sources":["../../src/core/event-body.ts"],"sourcesContent":["/**\n * Get the event body as buffer from body string with content length\n *\n * @example\n * ```typescript\n * const body = '{}';\n * const [buffer, contentLength] = getEventBodyAsBuffer(body, false);\n * console.log(buffer);\n * // <Buffer 7b 7d>\n * console.log(contentLength);\n * // 2\n * ```\n *\n * @param body - The body string that can be encoded or not\n * @param isBase64Encoded - Tells if body string is encoded in base64\n *\n * @breadcrumb Core\n * @public\n */\nexport function getEventBodyAsBuffer(\n body: string,\n isBase64Encoded: boolean,\n): [body: Buffer, contentLength: number] {\n const encoding: BufferEncoding = isBase64Encoded ? 'base64' : 'utf8';\n\n const buffer = Buffer.from(body, encoding);\n const contentLength = Buffer.byteLength(buffer, encoding);\n\n return [buffer, contentLength];\n}\n"],"names":["event_body_exports","__export","getEventBodyAsBuffer","__toCommonJS","body","isBase64Encoded","encoding","buffer","contentLength"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,qBAAA,IAAAE,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAH,CAAA,EAmBO,SAASE,EACdE,EACAC,EACuC,CACjC,MAAAC,EAA2BD,EAAkB,SAAW,OAExDE,EAAS,OAAO,KAAKH,EAAME,CAAQ,EACnCE,EAAgB,OAAO,WAAWD,EAAQD,CAAQ,EAEjD,MAAA,CAACC,EAAQC,CAAa,CAC/B"}
@@ -1,97 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseHeaders = exports.getMultiValueHeadersMap = exports.getFlattenedHeadersMap = void 0;
4
- const { __ΩBothValueHeaders } = require('../@types');
5
- const __ΩRecord = ['K', 'T', 'l\'e#"Rb!b"Pde"!N#!'];
6
- //#endregion
7
- /**
8
- * Transform a header map and make sure the value is not an array
9
- *
10
- * @example
11
- * ```typescript
12
- * const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };
13
- * const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);
14
- * console.log(flattenedHeaders);
15
- * // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }
16
- * ```
17
- *
18
- * @param headersMap - The initial headers
19
- * @param separator - The separator used when we join the array of header's value
20
- * @param lowerCaseKey - Should put all keys in lowercase
21
- *
22
- * @breadcrumb Core / Headers
23
- * @public
24
- */
25
- function getFlattenedHeadersMap(headersMap, separator = ',', lowerCaseKey = false) {
26
- const commaDelimitedHeaders = {};
27
- const headersMapEntries = Object.entries(headersMap);
28
- for (const [headerKey, headerValue] of headersMapEntries) {
29
- const newKey = lowerCaseKey ? headerKey.toLowerCase() : headerKey;
30
- if (Array.isArray(headerValue))
31
- commaDelimitedHeaders[newKey] = headerValue.join(separator);
32
- else
33
- commaDelimitedHeaders[newKey] = String(headerValue !== null && headerValue !== void 0 ? headerValue : '');
34
- }
35
- return commaDelimitedHeaders;
36
- }
37
- exports.getFlattenedHeadersMap = getFlattenedHeadersMap;
38
- getFlattenedHeadersMap.__type = [() => __ΩBothValueHeaders, 'headersMap', 'separator', () => ",", 'lowerCaseKey', () => false, () => __ΩRecord, 'getFlattenedHeadersMap', 'Pn!2"&2#>$)2%>&&&o\'#/('];
39
- /**
40
- * Transforms a header map into a multi-value map header.
41
- *
42
- * @example
43
- * ```typescript
44
- * const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };
45
- * const multiValueHeaders = getMultiValueHeadersMap(headers);
46
- * console.log(multiValueHeaders);
47
- * // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }
48
- * ```
49
- *
50
- * @param headersMap - The initial headers
51
- *
52
- * @breadcrumb Core / Headers
53
- * @public
54
- */
55
- function getMultiValueHeadersMap(headersMap) {
56
- const multiValueHeaders = {};
57
- const headersMapEntries = Object.entries(headersMap);
58
- for (const [headerKey, headerValue] of headersMapEntries) {
59
- multiValueHeaders[headerKey.toLowerCase()] = Array.isArray(headerValue)
60
- ? headerValue.map(String)
61
- : [String(headerValue)];
62
- }
63
- return multiValueHeaders;
64
- }
65
- exports.getMultiValueHeadersMap = getMultiValueHeadersMap;
66
- getMultiValueHeadersMap.__type = [() => __ΩBothValueHeaders, 'headersMap', () => __ΩRecord, 'getMultiValueHeadersMap', 'Pn!2"&&Fo##/$'];
67
- /**
68
- * Parse HTTP Raw Headers
69
- * Attribution to {@link https://github.com/kesla/parse-headers/blob/master/parse-headers.js}
70
- *
71
- * @param headers - The raw headers
72
- *
73
- * @breadcrumb Core / Headers
74
- * @public
75
- */
76
- function parseHeaders(headers) {
77
- if (!headers)
78
- return {};
79
- const result = {};
80
- const headersArr = headers.trim().split('\n');
81
- for (let i = 0; i < headersArr.length; i++) {
82
- const row = headersArr[i];
83
- const index = row.indexOf(':');
84
- const key = row.slice(0, index).trim().toLowerCase();
85
- const value = row.slice(index + 1).trim();
86
- if (typeof result[key] === 'undefined')
87
- result[key] = value;
88
- else if (Array.isArray(result[key]))
89
- result[key].push(value);
90
- else
91
- result[key] = [result[key], value];
92
- }
93
- return result;
94
- }
95
- exports.parseHeaders = parseHeaders;
96
- parseHeaders.__type = ['headers', () => __ΩRecord, 'parseHeaders', 'P&2!&P&&FJo"#/#'];
97
- //# sourceMappingURL=headers.js.map
1
+ "use strict";var u=Object.defineProperty,p=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,f=(t,e)=>{for(var s in e)u(t,s,{get:e[s],enumerable:!0})},y=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of c(e))!d.call(t,o)&&o!==s&&u(t,o,{get:()=>e[o],enumerable:!(r=p(e,o))||r.enumerable});return t},_=t=>y(u({},"__esModule",{value:!0}),t),l={};f(l,{getFlattenedHeadersMap:()=>g,getFlattenedHeadersMapAndCookies:()=>w,getMultiValueHeadersMap:()=>O,parseHeaders:()=>k});module.exports=_(l);function g(t,e=",",s=!1){return Object.keys(t).reduce((r,o)=>{const i=s?o.toLowerCase():o,n=t[o];return Array.isArray(n)?r[i]=n.join(e):r[i]=(n??"")+"",r},{})}function O(t){return Object.keys(t).reduce((e,s)=>{const r=t[s];return e[s.toLowerCase()]=Array.isArray(r)?r.map(String):[String(r)],e},{})}function w(t){return Object.keys(t).reduce((e,s)=>{const r=t[s],o=s.toLowerCase();return Array.isArray(r)?o!=="set-cookie"?e.headers[s]=r.join(","):e.cookies.push(...r):o==="set-cookie"&&r!==void 0?e.cookies.push(r??""):e.headers[s]=String(r??""),e},{cookies:[],headers:{}})}function k(t){if(!t)return{};const e={},s=t.trim().split(`
2
+ `);for(let r=0;r<s.length;r++){const o=s[r],i=o.indexOf(":"),n=o.slice(0,i).trim().toLowerCase(),a=o.slice(i+1).trim();typeof e[n]>"u"?e[n]=a:Array.isArray(e[n])?e[n].push(a):e[n]=[e[n],a]}return e}
3
+ //# sourceMappingURL=headers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/core/headers.ts"],"names":[],"mappings":";;;wCAEiC,WAAW;;AAE5C,YAAY;AAEZ;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,sBAAsB,CACpC,UAA4B,EAC5B,YAAoB,GAAG,EACvB,eAAwB,KAAK;IAE7B,MAAM,qBAAqB,GAA2B,EAAE,CAAC;IACzD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,iBAAiB,EAAE;QACxD,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAElE,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YAC5B,qBAAqB,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;YACzD,qBAAqB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC,CAAC;KAChE;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAjBD,wDAiBC;;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,uBAAuB,CACrC,UAA4B;IAE5B,MAAM,iBAAiB,GAA6B,EAAE,CAAC;IACvD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,iBAAiB,EAAE;QACxD,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YACrE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;YACzB,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;KAC3B;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAbD,0DAaC;;AAED;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAC1B,OAAe;IAEf,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACrD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAE1C,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,WAAW;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;aACvD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;YACxD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;KACzC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AApBD,oCAoBC"}
1
+ {"version":3,"file":"headers.js","sources":["../../src/core/headers.ts"],"sourcesContent":["//#region Imports\n\nimport { BothValueHeaders } from '../@types';\n\n//#endregion\n\n/**\n * Transform a header map and make sure the value is not an array\n *\n * @example\n * ```typescript\n * const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };\n * const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);\n * console.log(flattenedHeaders);\n * // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }\n * ```\n *\n * @param headersMap - The initial headers\n * @param separator - The separator used when we join the array of header's value\n * @param lowerCaseKey - Should put all keys in lowercase\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getFlattenedHeadersMap(\n headersMap: BothValueHeaders,\n separator: string = ',',\n lowerCaseKey: boolean = false,\n): Record<string, string> {\n return Object.keys(headersMap).reduce((acc, headerKey) => {\n const newKey = lowerCaseKey ? headerKey.toLowerCase() : headerKey;\n const headerValue = headersMap[headerKey];\n\n if (Array.isArray(headerValue)) acc[newKey] = headerValue.join(separator);\n else acc[newKey] = (headerValue ?? '') + '';\n\n return acc;\n }, {});\n}\n\n/**\n * Transforms a header map into a multi-value map header.\n *\n * @example\n * ```typescript\n * const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };\n * const multiValueHeaders = getMultiValueHeadersMap(headers);\n * console.log(multiValueHeaders);\n * // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }\n * ```\n *\n * @param headersMap - The initial headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getMultiValueHeadersMap(\n headersMap: BothValueHeaders,\n): Record<string, string[]> {\n return Object.keys(headersMap).reduce((acc, headerKey) => {\n const headerValue = headersMap[headerKey];\n\n acc[headerKey.toLowerCase()] = Array.isArray(headerValue)\n ? headerValue.map(String)\n : [String(headerValue)];\n\n return acc;\n }, {});\n}\n\n/**\n * The wrapper that holds the information about single value headers and cookies\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport type FlattenedHeadersAndCookies = {\n /**\n * Just the single value headers\n */\n headers: Record<string, string>;\n\n /**\n * The list of cookies\n */\n cookies: string[];\n};\n\n/**\n * Transforms a header map into a single value headers and cookies\n *\n * @param headersMap - The initial headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getFlattenedHeadersMapAndCookies(\n headersMap: BothValueHeaders,\n): FlattenedHeadersAndCookies {\n return Object.keys(headersMap).reduce(\n (acc, headerKey) => {\n const headerValue = headersMap[headerKey];\n const lowerHeaderKey = headerKey.toLowerCase();\n\n if (Array.isArray(headerValue)) {\n if (lowerHeaderKey !== 'set-cookie')\n acc.headers[headerKey] = headerValue.join(',');\n else acc.cookies.push(...headerValue);\n } else {\n if (lowerHeaderKey === 'set-cookie' && headerValue !== undefined)\n acc.cookies.push(headerValue ?? '');\n else acc.headers[headerKey] = String(headerValue ?? '');\n }\n\n return acc;\n },\n {\n cookies: [],\n headers: {},\n } as FlattenedHeadersAndCookies,\n );\n}\n\n/**\n * Parse HTTP Raw Headers\n * Attribution to {@link https://github.com/kesla/parse-headers/blob/master/parse-headers.js}\n *\n * @param headers - The raw headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function parseHeaders(\n headers: string,\n): Record<string, string | string[]> {\n if (!headers) return {};\n\n const result = {};\n const headersArr = headers.trim().split('\\n');\n\n for (let i = 0; i < headersArr.length; i++) {\n const row = headersArr[i];\n const index = row.indexOf(':');\n const key = row.slice(0, index).trim().toLowerCase();\n const value = row.slice(index + 1).trim();\n\n if (typeof result[key] === 'undefined') result[key] = value;\n else if (Array.isArray(result[key])) result[key].push(value);\n else result[key] = [result[key], value];\n }\n\n return result;\n}\n"],"names":["headers_exports","__export","getFlattenedHeadersMap","getFlattenedHeadersMapAndCookies","getMultiValueHeadersMap","parseHeaders","__toCommonJS","headersMap","separator","lowerCaseKey","acc","headerKey","newKey","headerValue","lowerHeaderKey","headers","result","headersArr","i","row","index","key","value"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,uBAAA,IAAAE,EAAA,iCAAA,IAAAC,EAAA,wBAAA,IAAAC,EAAA,aAAA,IAAAC,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAN,CAAA,EAwBO,SAASE,EACdK,EACAC,EAAoB,IACpBC,EAAwB,GACA,CACxB,OAAO,OAAO,KAAKF,CAAU,EAAE,OAAO,CAACG,EAAKC,IAAc,CACxD,MAAMC,EAASH,EAAeE,EAAU,YAAA,EAAgBA,EAClDE,EAAcN,EAAWI,CAAS,EAEpC,OAAA,MAAM,QAAQE,CAAW,EAAGH,EAAIE,CAAM,EAAIC,EAAY,KAAKL,CAAS,EAC/DE,EAAAE,CAAM,GAAKC,GAAe,IAAM,GAElCH,CACT,EAAG,CAAE,CAAA,CACP,CAkBO,SAASN,EACdG,EAC0B,CAC1B,OAAO,OAAO,KAAKA,CAAU,EAAE,OAAO,CAACG,EAAKC,IAAc,CAClD,MAAAE,EAAcN,EAAWI,CAAS,EAExC,OAAAD,EAAIC,EAAU,YAAA,CAAa,EAAI,MAAM,QAAQE,CAAW,EACpDA,EAAY,IAAI,MAAM,EACtB,CAAC,OAAOA,CAAW,CAAC,EAEjBH,CACT,EAAG,CAAE,CAAA,CACP,CA4BO,SAASP,EACdI,EAC4B,CACrB,OAAA,OAAO,KAAKA,CAAU,EAAE,OAC7B,CAACG,EAAKC,IAAc,CACZ,MAAAE,EAAcN,EAAWI,CAAS,EAClCG,EAAiBH,EAAU,cAE7B,OAAA,MAAM,QAAQE,CAAW,EACvBC,IAAmB,aACrBJ,EAAI,QAAQC,CAAS,EAAIE,EAAY,KAAK,GAAG,EACtCH,EAAA,QAAQ,KAAK,GAAGG,CAAW,EAEhCC,IAAmB,cAAgBD,IAAgB,OACjDH,EAAA,QAAQ,KAAKG,GAAe,EAAE,EAC/BH,EAAI,QAAQC,CAAS,EAAI,OAAOE,GAAe,EAAE,EAGjDH,CACT,EACA,CACE,QAAS,CAAC,EACV,QAAS,CAAC,CACZ,CAAA,CAEJ,CAWO,SAASL,EACdU,EACmC,CACnC,GAAI,CAACA,EAAS,MAAO,GAErB,MAAMC,EAAS,CAAA,EACTC,EAAaF,EAAQ,KAAK,EAAE,MAAM;AAAA,CAAI,EAE5C,QAASG,EAAI,EAAGA,EAAID,EAAW,OAAQC,IAAK,CACpC,MAAAC,EAAMF,EAAWC,CAAC,EAClBE,EAAQD,EAAI,QAAQ,GAAG,EACvBE,EAAMF,EAAI,MAAM,EAAGC,CAAK,EAAE,OAAO,cACjCE,EAAQH,EAAI,MAAMC,EAAQ,CAAC,EAAE,OAE/B,OAAOJ,EAAOK,CAAG,EAAM,IAAaL,EAAOK,CAAG,EAAIC,EAC7C,MAAM,QAAQN,EAAOK,CAAG,CAAC,EAAUL,EAAAK,CAAG,EAAE,KAAKC,CAAK,EACtDN,EAAOK,CAAG,EAAI,CAACL,EAAOK,CAAG,EAAGC,CAAK,EAGjC,OAAAN,CACT"}
package/lib/core/index.js CHANGED
@@ -1,28 +1,2 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./base-handler"), exports);
18
- __exportStar(require("./constants"), exports);
19
- __exportStar(require("./current-invoke"), exports);
20
- __exportStar(require("./event-body"), exports);
21
- __exportStar(require("./headers"), exports);
22
- __exportStar(require("./is-binary"), exports);
23
- __exportStar(require("./logger"), exports);
24
- __exportStar(require("./no-op"), exports);
25
- __exportStar(require("./optional"), exports);
26
- __exportStar(require("./path"), exports);
27
- __exportStar(require("./stream"), exports);
28
- //# sourceMappingURL=index.js.map
1
+ "use strict";var i=Object.defineProperty,_=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,u=(o,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of x(t))!n.call(o,p)&&p!==s&&i(o,p,{get:()=>t[p],enumerable:!(a=_(t,p))||a.enumerable});return o},r=(o,t,s)=>(u(o,t,"default"),s&&u(s,t,"default")),q=o=>u(i({},"__esModule",{value:!0}),o),e={};module.exports=q(e);r(e,require("./base-handler"),module.exports);r(e,require("./constants"),module.exports);r(e,require("./current-invoke"),module.exports);r(e,require("./event-body"),module.exports);r(e,require("./headers"),module.exports);r(e,require("./is-binary"),module.exports);r(e,require("./logger"),module.exports);r(e,require("./no-op"),module.exports);r(e,require("./optional"),module.exports);r(e,require("./path"),module.exports);r(e,require("./stream"),module.exports);
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,8CAA4B;AAC5B,mDAAiC;AACjC,+CAA6B;AAC7B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB"}
1
+ {"version":3,"file":"index.js","sources":["../../src/core/index.ts"],"sourcesContent":["export * from './base-handler';\nexport * from './constants';\nexport * from './current-invoke';\nexport * from './event-body';\nexport * from './headers';\nexport * from './is-binary';\nexport * from './logger';\nexport * from './no-op';\nexport * from './optional';\nexport * from './path';\nexport * from './stream';\n"],"names":["core_exports","__toCommonJS","__reExport"],"mappings":"6YAAAA,EAAA,CAAA,EAAA,OAAA,QAAAC,EAAAD,CAAA,EAAAE,EAAAF,EAAc,QAAd,gBAAA,EAAA,OAAA,OAAA,EACAE,EAAAF,EAAc,QADd,aAAA,EAAA,OAAA,OAAA,EAEAE,EAAAF,EAAc,QAFd,kBAAA,EAAA,OAAA,OAAA,EAGAE,EAAAF,EAAc,QAHd,cAAA,EAAA,OAAA,OAAA,EAIAE,EAAAF,EAAc,QAJd,WAAA,EAAA,OAAA,OAAA,EAKAE,EAAAF,EAAc,QALd,aAAA,EAAA,OAAA,OAAA,EAMAE,EAAAF,EAAc,QANd,UAAA,EAAA,OAAA,OAAA,EAOAE,EAAAF,EAAc,QAPd,SAAA,EAAA,OAAA,OAAA,EAQAE,EAAAF,EAAc,QARd,YAAA,EAAA,OAAA,OAAA,EASAE,EAAAF,EAAc,QATd,QAAA,EAAA,OAAA,OAAA,EAUAE,EAAAF,EAAc,QAVd,UAAA,EAAA,OAAA,OAAA"}
@@ -1,118 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBinary = exports.isContentTypeBinary = exports.getContentType = exports.isContentEncodingBinary = void 0;
4
- const { __ΩBothValueHeaders } = require('../@types');
5
- const { __ΩBinarySettings } = require('../@types');
6
- function __assignType(fn, args) {
7
- fn.__type = args;
8
- return fn;
9
- }
10
- const headers_1 = require("./headers");
11
- //#endregion
12
- /**
13
- * The function that determines by the content encoding whether the response should be treated as binary
14
- *
15
- * @example
16
- * ```typescript
17
- * const headers = { 'Content-Encoding': 'gzip' };
18
- * const isBinary = isContentEncodingBinary(headers, ['gzip']);
19
- * console.log(isBinary);
20
- * // true
21
- * ```
22
- *
23
- * @param headers - The headers of the response
24
- * @param binaryEncodingTypes - The list of content encodings that will be treated as binary
25
- *
26
- * @breadcrumb Core / isBinary
27
- * @public
28
- */
29
- function isContentEncodingBinary(headers, binaryEncodingTypes) {
30
- const multiValueHeaders = (0, headers_1.getMultiValueHeadersMap)(headers);
31
- const contentEncodings = multiValueHeaders['content-encoding'];
32
- if (!Array.isArray(contentEncodings))
33
- return false;
34
- return contentEncodings.some(__assignType(value => binaryEncodingTypes.some(__assignType(binaryEncoding => value.includes(binaryEncoding), ['binaryEncoding', '', 'P"2!"/"'])), ['value', '', 'P"2!"/"']));
35
- }
36
- exports.isContentEncodingBinary = isContentEncodingBinary;
37
- isContentEncodingBinary.__type = [() => __ΩBothValueHeaders, 'headers', 'binaryEncodingTypes', 'isContentEncodingBinary', 'Pn!2"&F2#)/$'];
38
- /**
39
- * The function that returns the content type of headers
40
- *
41
- * @example
42
- * ```typescript
43
- * const headers = { 'Content-Type': 'application/json' };
44
- * const contentType = getContentType(headers);
45
- * console.log(contentType);
46
- * // application/json
47
- * ```
48
- *
49
- * @param headers - The headers of the response
50
- *
51
- * @breadcrumb Core / isBinary
52
- * @public
53
- */
54
- function getContentType(headers) {
55
- const flattenedHeaders = (0, headers_1.getFlattenedHeadersMap)(headers, ';', true);
56
- const contentTypeHeader = flattenedHeaders['content-type'] || '';
57
- // only compare mime type; ignore encoding part
58
- return contentTypeHeader.split(';')[0];
59
- }
60
- exports.getContentType = getContentType;
61
- getContentType.__type = [() => __ΩBothValueHeaders, 'headers', 'getContentType', 'Pn!2"&/#'];
62
- /**
63
- * The function that determines by the content type whether the response should be treated as binary
64
- *
65
- * @example
66
- * ```typescript
67
- * const headers = { 'Content-Type': 'image/png' };
68
- * const isBinary = isContentTypeBinary(headers, [new RegExp('^image/.*$')]);
69
- * console.log(isBinary);
70
- * // true
71
- * ```
72
- *
73
- * @param headers - The headers of the response
74
- * @param binaryContentTypes - The list of content types that will be treated as binary
75
- *
76
- * @breadcrumb Core / isBinary
77
- * @public
78
- */
79
- function isContentTypeBinary(headers, binaryContentTypes) {
80
- const binaryContentTypesRegexes = binaryContentTypes.map(__assignType(binaryContentType => binaryContentType instanceof RegExp
81
- ? binaryContentType
82
- : new RegExp(`${binaryContentType}`), ['binaryContentType', '', 'P"2!"/"']));
83
- const contentType = getContentType(headers);
84
- if (!contentType)
85
- return false;
86
- return binaryContentTypesRegexes.some(__assignType(binaryContentType => binaryContentType.test(contentType), ['binaryContentType', '', 'P"2!"/"']));
87
- }
88
- exports.isContentTypeBinary = isContentTypeBinary;
89
- isContentTypeBinary.__type = [() => __ΩBothValueHeaders, 'headers', 'binaryContentTypes', 'isContentTypeBinary', 'Pn!2"P&AJF2#"/$'];
90
- /**
91
- * The function used to determine from the headers and the binary settings if a response should be encoded or not
92
- *
93
- * @example
94
- * ```typescript
95
- * const headers = { 'Content-Type': 'image/png', 'Content-Encoding': 'gzip' };
96
- * const isContentBinary = isBinary(headers, { contentEncodings: ['gzip'], contentTypes: [new RegExp('^image/.*$')] });
97
- * console.log(isContentBinary);
98
- * // true
99
- * ```
100
- *
101
- * @param headers - The headers of the response
102
- * @param binarySettings - The settings for the validation
103
- *
104
- * @breadcrumb Core / isBinary
105
- * @public
106
- */
107
- function isBinary(headers, binarySettings) {
108
- if ('isBinary' in binarySettings) {
109
- if (binarySettings.isBinary === false)
110
- return false;
111
- return binarySettings.isBinary(headers);
112
- }
113
- return (isContentEncodingBinary(headers, binarySettings.contentEncodings) ||
114
- isContentTypeBinary(headers, binarySettings.contentTypes));
115
- }
116
- exports.isBinary = isBinary;
117
- isBinary.__type = [() => __ΩBothValueHeaders, 'headers', () => __ΩBinarySettings, 'binarySettings', 'isBinary', 'Pn!2"n#2$)/%'];
118
- //# sourceMappingURL=is-binary.js.map
1
+ "use strict";var i=Object.defineProperty,y=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,f=Object.prototype.hasOwnProperty,_=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},l=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of u(e))!f.call(n,o)&&o!==t&&i(n,o,{get:()=>e[o],enumerable:!(r=y(e,o))||r.enumerable});return n},O=n=>l(i({},"__esModule",{value:!0}),n),c={};_(c,{getContentType:()=>a,isBinary:()=>d,isContentEncodingBinary:()=>s,isContentTypeBinary:()=>p});module.exports=O(c);function s(n,e){let t=n["content-encoding"];return t?(Array.isArray(t)||(t=t.split(",")),t.some(r=>e.includes(r.trim()))):!1}function a(n){const e=n["content-type"],t=Array.isArray(e)?e[0]||"":e||"";if(!e)return"";const r=t.indexOf(";");return r===-1?t:t.slice(0,r)}function p(n,e){const t=a(n);return t?e.includes(t.trim()):!1}function d(n,e){return"isBinary"in e?e.isBinary===!1?!1:e.isBinary(n):s(n,e.contentEncodings)||p(n,e.contentTypes)}
2
+ //# sourceMappingURL=is-binary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-binary.js","sourceRoot":"","sources":["../../src/core/is-binary.ts"],"names":[],"mappings":";;;wCAIiD,WAAW;sCAAX,WAAW;;;;;AAC5D,uCAA4E;AAE5E,YAAY;AAEZ;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,uBAAuB,CACrC,OAAyB,EACzB,mBAA6B;IAE7B,MAAM,iBAAiB,GAAG,IAAA,iCAAuB,EAAC,OAAO,CAAC,CAAC;IAE3D,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;IAE/D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnD,OAAO,gBAAgB,CAAC,IAAI,cAAC,KAAK,CAAC,EAAE,CACnC,mBAAmB,CAAC,IAAI,cAAC,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,qCAAC,4BAC3E,CAAC;AACJ,CAAC;AAbD,0DAaC;;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,cAAc,CAAC,OAAyB;IACtD,MAAM,gBAAgB,GAAG,IAAA,gCAAsB,EAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACpE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAEjE,+CAA+C;IAC/C,OAAO,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AAND,wCAMC;;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,mBAAmB,CACjC,OAAyB,EACzB,kBAAuC;IAEvC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,GAAG,cAAC,iBAAiB,CAAC,EAAE,CAC3E,iBAAiB,YAAY,MAAM;QACjC,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,iBAAiB,EAAE,CAAC,wCACvC,CAAC;IAEF,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAE5C,IAAI,CAAC,WAAW;QAAE,OAAO,KAAK,CAAC;IAE/B,OAAO,yBAAyB,CAAC,IAAI,cAAC,iBAAiB,CAAC,EAAE,CACxD,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,wCACpC,CAAC;AACJ,CAAC;AAjBD,kDAiBC;;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,QAAQ,CACtB,OAAyB,EACzB,cAA8B;IAE9B,IAAI,UAAU,IAAI,cAAc,EAAE;QAChC,IAAI,cAAc,CAAC,QAAQ,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC;QAEpD,OAAO,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KACzC;IAED,OAAO,CACL,uBAAuB,CAAC,OAAO,EAAE,cAAc,CAAC,gBAAgB,CAAC;QACjE,mBAAmB,CAAC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAC1D,CAAC;AACJ,CAAC;AAdD,4BAcC"}
1
+ {"version":3,"file":"is-binary.js","sources":["../../src/core/is-binary.ts"],"sourcesContent":["// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http\n\n//#region Imports\n\nimport { BinarySettings, BothValueHeaders } from '../@types';\n\n//#endregion\n\n/**\n * The function that determines by the content encoding whether the response should be treated as binary\n *\n * @example\n * ```typescript\n * const headers = { 'content-encoding': 'gzip' };\n * const isBinary = isContentEncodingBinary(headers, ['gzip']);\n * console.log(isBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binaryEncodingTypes - The list of content encodings that will be treated as binary\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isContentEncodingBinary(\n headers: BothValueHeaders,\n binaryEncodingTypes: string[],\n): boolean {\n let contentEncodings = headers['content-encoding'];\n\n if (!contentEncodings) return false;\n\n if (!Array.isArray(contentEncodings))\n contentEncodings = contentEncodings.split(',');\n\n return contentEncodings.some(value =>\n binaryEncodingTypes.includes(value.trim()),\n );\n}\n\n/**\n * The function that returns the content type of headers\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'application/json' };\n * const contentType = getContentType(headers);\n * console.log(contentType);\n * // application/json\n * ```\n *\n * @param headers - The headers of the response\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function getContentType(headers: BothValueHeaders): string {\n const contentTypeHeaderRaw = headers['content-type'];\n const contentTypeHeader = Array.isArray(contentTypeHeaderRaw)\n ? contentTypeHeaderRaw[0] || ''\n : contentTypeHeaderRaw || '';\n\n if (!contentTypeHeaderRaw) return '';\n\n // only compare mime type; ignore encoding part\n const contentTypeStart = contentTypeHeader.indexOf(';');\n\n if (contentTypeStart === -1) return contentTypeHeader;\n\n return contentTypeHeader.slice(0, contentTypeStart);\n}\n\n/**\n * The function that determines by the content type whether the response should be treated as binary\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'image/png' };\n * const isBinary = isContentTypeBinary(headers, new Map([['image/png', true]]));\n * console.log(isBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binaryContentTypes - The list of content types that will be treated as binary\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isContentTypeBinary(\n headers: BothValueHeaders,\n binaryContentTypes: string[],\n) {\n const contentType = getContentType(headers);\n\n if (!contentType) return false;\n\n return binaryContentTypes.includes(contentType.trim());\n}\n\n/**\n * The function used to determine from the headers and the binary settings if a response should be encoded or not\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'image/png', 'content-encoding': 'gzip' };\n * const isContentBinary = isBinary(headers, { contentEncodings: ['gzip'], contentTypes: ['image/png'] });\n * console.log(isContentBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binarySettings - The settings for the validation\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isBinary(\n headers: BothValueHeaders,\n binarySettings: BinarySettings,\n): boolean {\n if ('isBinary' in binarySettings) {\n if (binarySettings.isBinary === false) return false;\n\n return binarySettings.isBinary(headers);\n }\n\n return (\n isContentEncodingBinary(headers, binarySettings.contentEncodings) ||\n isContentTypeBinary(headers, binarySettings.contentTypes)\n );\n}\n"],"names":["is_binary_exports","__export","getContentType","isBinary","isContentEncodingBinary","isContentTypeBinary","__toCommonJS","headers","binaryEncodingTypes","contentEncodings","value","contentTypeHeaderRaw","contentTypeHeader","contentTypeStart","binaryContentTypes","contentType","binarySettings"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,eAAA,IAAAE,EAAA,SAAA,IAAAC,EAAA,wBAAA,IAAAC,EAAA,oBAAA,IAAAC,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAN,CAAA,EAyBO,SAASI,EACdG,EACAC,EACS,CACL,IAAAC,EAAmBF,EAAQ,kBAAkB,EAEjD,OAAKE,GAEA,MAAM,QAAQA,CAAgB,IACdA,EAAAA,EAAiB,MAAM,GAAG,GAExCA,EAAiB,KACtBC,GAAAF,EAAoB,SAASE,EAAM,MAAM,CAAA,GANb,EAQhC,CAkBO,SAASR,EAAeK,EAAmC,CAC1D,MAAAI,EAAuBJ,EAAQ,cAAc,EAC7CK,EAAoB,MAAM,QAAQD,CAAoB,EACxDA,EAAqB,CAAC,GAAK,GAC3BA,GAAwB,GAE5B,GAAI,CAACA,EAA6B,MAAA,GAG5B,MAAAE,EAAmBD,EAAkB,QAAQ,GAAG,EAEtD,OAAIC,IAAqB,GAAWD,EAE7BA,EAAkB,MAAM,EAAGC,CAAgB,CACpD,CAmBO,SAASR,EACdE,EACAO,EACA,CACM,MAAAC,EAAcb,EAAeK,CAAO,EAE1C,OAAKQ,EAEED,EAAmB,SAASC,EAAY,KAAM,CAAA,EAF5B,EAG3B,CAmBO,SAASZ,EACdI,EACAS,EACS,CACT,MAAI,aAAcA,EACZA,EAAe,WAAa,GAAc,GAEvCA,EAAe,SAAST,CAAO,EAItCH,EAAwBG,EAASS,EAAe,gBAAgB,GAChEX,EAAoBE,EAASS,EAAe,YAAY,CAE5D"}