@h4ad/serverless-adapter 3.2.0 → 4.0.1

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 (578) hide show
  1. package/lib/adapter.contract-EQE3rlgO.d.ts +278 -0
  2. package/lib/adapter.contract-y5xSjOjo.d.cts +278 -0
  3. package/lib/adapters/apollo-server/index.cjs +4 -0
  4. package/lib/adapters/apollo-server/index.cjs.map +1 -0
  5. package/lib/adapters/apollo-server/{apollo-server-mutation.adapter.d.ts → index.d.cts} +10 -5
  6. package/lib/adapters/apollo-server/index.d.ts +61 -2
  7. package/lib/adapters/apollo-server/index.mjs +2 -0
  8. package/lib/adapters/apollo-server/index.mjs.map +1 -0
  9. package/lib/adapters/aws/index.cjs +4 -0
  10. package/lib/adapters/aws/index.cjs.map +1 -0
  11. package/lib/adapters/aws/index.d.cts +910 -0
  12. package/lib/adapters/aws/index.d.ts +910 -12
  13. package/lib/adapters/aws/index.mjs +2 -0
  14. package/lib/adapters/aws/index.mjs.map +1 -0
  15. package/lib/adapters/azure/index.cjs +4 -0
  16. package/lib/adapters/azure/index.cjs.map +1 -0
  17. package/lib/adapters/azure/{http-trigger-v4.adapter.d.ts → index.d.cts} +11 -6
  18. package/lib/adapters/azure/index.d.ts +86 -2
  19. package/lib/adapters/azure/index.mjs +2 -0
  20. package/lib/adapters/azure/index.mjs.map +1 -0
  21. package/lib/adapters/digital-ocean/index.cjs +4 -0
  22. package/lib/adapters/digital-ocean/index.cjs.map +1 -0
  23. package/lib/adapters/digital-ocean/index.d.cts +126 -0
  24. package/lib/adapters/digital-ocean/index.d.ts +126 -2
  25. package/lib/adapters/digital-ocean/index.mjs +2 -0
  26. package/lib/adapters/digital-ocean/index.mjs.map +1 -0
  27. package/lib/adapters/dummy/index.cjs +4 -0
  28. package/lib/adapters/dummy/index.cjs.map +1 -0
  29. package/lib/adapters/dummy/{dummy.adapter.d.ts → index.d.cts} +10 -4
  30. package/lib/adapters/dummy/index.d.ts +37 -2
  31. package/lib/adapters/dummy/index.mjs +2 -0
  32. package/lib/adapters/dummy/index.mjs.map +1 -0
  33. package/lib/adapters/huawei/index.cjs +4 -0
  34. package/lib/adapters/huawei/index.cjs.map +1 -0
  35. package/lib/adapters/huawei/index.d.cts +365 -0
  36. package/lib/adapters/huawei/index.d.ts +365 -2
  37. package/lib/adapters/huawei/index.mjs +2 -0
  38. package/lib/adapters/huawei/index.mjs.map +1 -0
  39. package/lib/{core/base-handler.d.ts → base-handler-fYEk59Xq.d.ts} +9 -6
  40. package/lib/base-handler-peEBoKtZ.d.cts +35 -0
  41. package/lib/chunk-22SSVZU5.mjs +1 -0
  42. package/lib/chunk-22SSVZU5.mjs.map +1 -0
  43. package/lib/chunk-HU5XBQCP.mjs +10 -0
  44. package/lib/chunk-HU5XBQCP.mjs.map +1 -0
  45. package/lib/chunk-NSO4L3EI.mjs +2 -0
  46. package/lib/chunk-NSO4L3EI.mjs.map +1 -0
  47. package/lib/chunk-OYOJMOFP.mjs +2 -0
  48. package/lib/chunk-OYOJMOFP.mjs.map +1 -0
  49. package/lib/chunk-Y6H576RS.mjs +2 -0
  50. package/lib/chunk-Y6H576RS.mjs.map +1 -0
  51. package/lib/{core/constants.d.ts → constants-0cgQlFSV.d.cts} +6 -5
  52. package/lib/constants-0cgQlFSV.d.ts +32 -0
  53. package/lib/{contracts/framework.contract.d.ts → framework.contract-YnJ-fl1w.d.cts} +4 -3
  54. package/lib/framework.contract-YnJ-fl1w.d.ts +20 -0
  55. package/lib/frameworks/apollo-server/index.cjs +4 -0
  56. package/lib/frameworks/apollo-server/index.cjs.map +1 -0
  57. package/lib/frameworks/apollo-server/{apollo-server.framework.d.ts → index.d.cts} +12 -9
  58. package/lib/frameworks/apollo-server/index.d.ts +72 -2
  59. package/lib/frameworks/apollo-server/index.mjs +2 -0
  60. package/lib/frameworks/apollo-server/index.mjs.map +1 -0
  61. package/lib/frameworks/body-parser/index.cjs +4 -0
  62. package/lib/frameworks/body-parser/index.cjs.map +1 -0
  63. package/lib/frameworks/body-parser/index.d.cts +159 -0
  64. package/lib/frameworks/body-parser/index.d.ts +159 -6
  65. package/lib/frameworks/body-parser/index.mjs +2 -0
  66. package/lib/frameworks/body-parser/index.mjs.map +1 -0
  67. package/lib/frameworks/cors/index.cjs +5 -0
  68. package/lib/frameworks/cors/index.cjs.map +1 -0
  69. package/lib/frameworks/cors/{cors.framework.d.ts → index.d.cts} +6 -5
  70. package/lib/frameworks/cors/index.d.ts +79 -2
  71. package/lib/frameworks/cors/index.mjs +3 -0
  72. package/lib/frameworks/cors/index.mjs.map +1 -0
  73. package/lib/frameworks/deepkit/index.cjs +4 -0
  74. package/lib/frameworks/deepkit/index.cjs.map +1 -0
  75. package/lib/frameworks/deepkit/{http-deepkit.framework.d.ts → index.d.cts} +8 -5
  76. package/lib/frameworks/deepkit/index.d.ts +21 -2
  77. package/lib/frameworks/deepkit/index.mjs +2 -0
  78. package/lib/frameworks/deepkit/index.mjs.map +1 -0
  79. package/lib/frameworks/express/index.cjs +2 -0
  80. package/lib/frameworks/express/index.cjs.map +1 -0
  81. package/lib/frameworks/express/{express.framework.d.ts → index.d.cts} +6 -5
  82. package/lib/frameworks/express/index.d.ts +18 -2
  83. package/lib/frameworks/express/index.mjs +2 -0
  84. package/lib/frameworks/express/index.mjs.map +1 -0
  85. package/lib/frameworks/fastify/index.cjs +2 -0
  86. package/lib/frameworks/fastify/index.cjs.map +1 -0
  87. package/lib/frameworks/fastify/{fastify.framework.d.ts → index.d.cts} +6 -5
  88. package/lib/frameworks/fastify/index.d.ts +18 -2
  89. package/lib/frameworks/fastify/index.mjs +2 -0
  90. package/lib/frameworks/fastify/index.mjs.map +1 -0
  91. package/lib/frameworks/hapi/index.cjs +2 -0
  92. package/lib/frameworks/hapi/index.cjs.map +1 -0
  93. package/lib/frameworks/hapi/{hapi.framework.d.ts → index.d.cts} +6 -5
  94. package/lib/frameworks/hapi/index.d.ts +18 -2
  95. package/lib/frameworks/hapi/index.mjs +2 -0
  96. package/lib/frameworks/hapi/index.mjs.map +1 -0
  97. package/lib/frameworks/koa/index.cjs +2 -0
  98. package/lib/frameworks/koa/index.cjs.map +1 -0
  99. package/lib/frameworks/koa/{koa.framework.d.ts → index.d.cts} +6 -5
  100. package/lib/frameworks/koa/index.d.ts +18 -2
  101. package/lib/frameworks/koa/index.mjs +2 -0
  102. package/lib/frameworks/koa/index.mjs.map +1 -0
  103. package/lib/frameworks/lazy/index.cjs +4 -0
  104. package/lib/frameworks/lazy/index.cjs.map +1 -0
  105. package/lib/frameworks/lazy/{lazy.framework.d.ts → index.d.cts} +7 -6
  106. package/lib/frameworks/lazy/index.d.ts +57 -2
  107. package/lib/frameworks/lazy/index.mjs +2 -0
  108. package/lib/frameworks/lazy/index.mjs.map +1 -0
  109. package/lib/frameworks/trpc/index.cjs +4 -0
  110. package/lib/frameworks/trpc/index.cjs.map +1 -0
  111. package/lib/frameworks/trpc/{trpc.framework.d.ts → index.d.cts} +12 -11
  112. package/lib/frameworks/trpc/index.d.ts +154 -2
  113. package/lib/frameworks/trpc/index.mjs +2 -0
  114. package/lib/frameworks/trpc/index.mjs.map +1 -0
  115. package/lib/handler.contract-8Cb7qLSi.d.ts +66 -0
  116. package/lib/handler.contract-TQk8iM8f.d.cts +66 -0
  117. package/lib/handlers/aws/index.cjs +10 -0
  118. package/lib/handlers/aws/index.cjs.map +1 -0
  119. package/lib/handlers/aws/{aws-stream.handler.d.ts → index.d.cts} +22 -15
  120. package/lib/handlers/aws/index.d.ts +96 -2
  121. package/lib/handlers/aws/index.mjs +2 -0
  122. package/lib/handlers/aws/index.mjs.map +1 -0
  123. package/lib/handlers/azure/index.cjs +4 -0
  124. package/lib/handlers/azure/index.cjs.map +1 -0
  125. package/lib/handlers/azure/{azure.handler.d.ts → index.d.cts} +16 -8
  126. package/lib/handlers/azure/index.d.ts +53 -2
  127. package/lib/handlers/azure/index.mjs +2 -0
  128. package/lib/handlers/azure/index.mjs.map +1 -0
  129. package/lib/handlers/default/index.cjs +4 -0
  130. package/lib/handlers/default/index.cjs.map +1 -0
  131. package/lib/handlers/default/{default.handler.d.ts → index.d.cts} +13 -6
  132. package/lib/handlers/default/index.d.ts +95 -2
  133. package/lib/handlers/default/index.mjs +2 -0
  134. package/lib/handlers/default/index.mjs.map +1 -0
  135. package/lib/handlers/digital-ocean/index.cjs +4 -0
  136. package/lib/handlers/digital-ocean/index.cjs.map +1 -0
  137. package/lib/handlers/digital-ocean/index.d.cts +25 -0
  138. package/lib/handlers/digital-ocean/index.d.ts +25 -2
  139. package/lib/handlers/digital-ocean/index.mjs +2 -0
  140. package/lib/handlers/digital-ocean/index.mjs.map +1 -0
  141. package/lib/handlers/firebase/index.cjs +4 -0
  142. package/lib/handlers/firebase/index.cjs.map +1 -0
  143. package/lib/handlers/firebase/index.d.cts +59 -0
  144. package/lib/handlers/firebase/index.d.ts +59 -3
  145. package/lib/handlers/firebase/index.mjs +2 -0
  146. package/lib/handlers/firebase/index.mjs.map +1 -0
  147. package/lib/handlers/gcp/index.cjs +4 -0
  148. package/lib/handlers/gcp/index.cjs.map +1 -0
  149. package/lib/handlers/gcp/{gcp.handler.d.ts → index.d.cts} +12 -5
  150. package/lib/handlers/gcp/index.d.ts +33 -2
  151. package/lib/handlers/gcp/index.mjs +2 -0
  152. package/lib/handlers/gcp/index.mjs.map +1 -0
  153. package/lib/handlers/huawei/index.cjs +4 -0
  154. package/lib/handlers/huawei/index.cjs.map +1 -0
  155. package/lib/handlers/huawei/{http-huawei.handler.d.ts → index.d.cts} +15 -12
  156. package/lib/handlers/huawei/index.d.ts +62 -2
  157. package/lib/handlers/huawei/index.mjs +2 -0
  158. package/lib/handlers/huawei/index.mjs.map +1 -0
  159. package/lib/{@types/headers.d.ts → headers-K2qbcurv.d.cts} +5 -4
  160. package/lib/headers-K2qbcurv.d.ts +38 -0
  161. package/lib/index.cjs +10 -0
  162. package/lib/index.cjs.map +1 -0
  163. package/lib/index.d.cts +439 -0
  164. package/lib/index.d.ts +439 -6
  165. package/lib/index.mjs +2 -0
  166. package/lib/index.mjs.map +1 -0
  167. package/lib/{core/logger.d.ts → logger-9me5n48P.d.cts} +8 -7
  168. package/lib/logger-9me5n48P.d.ts +65 -0
  169. package/lib/{core/path.d.ts → path-yBwCb8C1.d.cts} +16 -5
  170. package/lib/path-yBwCb8C1.d.ts +64 -0
  171. package/lib/{handlers/base/raw-request.d.ts → raw-request-B2vPjAfE.d.cts} +6 -5
  172. package/lib/raw-request-b6AYnkxd.d.ts +32 -0
  173. package/lib/{network/request.d.ts → request-DNNIV9ub.d.cts} +7 -7
  174. package/lib/request-sVa4pxmx.d.ts +44 -0
  175. package/lib/resolvers/aws-context/index.cjs +2 -0
  176. package/lib/resolvers/aws-context/index.cjs.map +1 -0
  177. package/lib/resolvers/aws-context/{aws-context.resolver.d.ts → index.d.cts} +10 -4
  178. package/lib/resolvers/aws-context/index.d.ts +25 -2
  179. package/lib/resolvers/aws-context/index.mjs +2 -0
  180. package/lib/resolvers/aws-context/index.mjs.map +1 -0
  181. package/lib/resolvers/callback/index.cjs +2 -0
  182. package/lib/resolvers/callback/index.cjs.map +1 -0
  183. package/lib/resolvers/callback/{callback.resolver.d.ts → index.d.cts} +10 -4
  184. package/lib/resolvers/callback/index.d.ts +29 -2
  185. package/lib/resolvers/callback/index.mjs +2 -0
  186. package/lib/resolvers/callback/index.mjs.map +1 -0
  187. package/lib/resolvers/dummy/index.cjs +2 -0
  188. package/lib/resolvers/dummy/index.cjs.map +1 -0
  189. package/lib/resolvers/dummy/index.d.cts +20 -0
  190. package/lib/resolvers/dummy/index.d.ts +20 -2
  191. package/lib/resolvers/dummy/index.mjs +2 -0
  192. package/lib/resolvers/dummy/index.mjs.map +1 -0
  193. package/lib/resolvers/promise/index.cjs +2 -0
  194. package/lib/resolvers/promise/index.cjs.map +1 -0
  195. package/lib/resolvers/promise/index.d.cts +20 -0
  196. package/lib/resolvers/promise/index.d.ts +20 -2
  197. package/lib/resolvers/promise/index.mjs +2 -0
  198. package/lib/resolvers/promise/index.mjs.map +1 -0
  199. package/package.json +565 -7
  200. package/lib/@types/binary-settings.d.ts +0 -41
  201. package/lib/@types/binary-settings.d.ts.map +0 -1
  202. package/lib/@types/binary-settings.js +0 -2
  203. package/lib/@types/binary-settings.js.map +0 -1
  204. package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +0 -37
  205. package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts.map +0 -1
  206. package/lib/@types/digital-ocean/digital-ocean-http-event.js +0 -2
  207. package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +0 -1
  208. package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +0 -22
  209. package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts.map +0 -1
  210. package/lib/@types/digital-ocean/digital-ocean-http-response.js +0 -2
  211. package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +0 -1
  212. package/lib/@types/digital-ocean/index.d.ts +0 -2
  213. package/lib/@types/digital-ocean/index.d.ts.map +0 -1
  214. package/lib/@types/digital-ocean/index.js +0 -2
  215. package/lib/@types/digital-ocean/index.js.map +0 -1
  216. package/lib/@types/headers.d.ts.map +0 -1
  217. package/lib/@types/headers.js +0 -2
  218. package/lib/@types/headers.js.map +0 -1
  219. package/lib/@types/helpers.d.ts +0 -10
  220. package/lib/@types/helpers.d.ts.map +0 -1
  221. package/lib/@types/helpers.js +0 -2
  222. package/lib/@types/helpers.js.map +0 -1
  223. package/lib/@types/huawei/huawei-api-gateway-event.d.ts +0 -81
  224. package/lib/@types/huawei/huawei-api-gateway-event.d.ts.map +0 -1
  225. package/lib/@types/huawei/huawei-api-gateway-event.js +0 -2
  226. package/lib/@types/huawei/huawei-api-gateway-event.js.map +0 -1
  227. package/lib/@types/huawei/huawei-api-gateway-response.d.ts +0 -27
  228. package/lib/@types/huawei/huawei-api-gateway-response.d.ts.map +0 -1
  229. package/lib/@types/huawei/huawei-api-gateway-response.js +0 -2
  230. package/lib/@types/huawei/huawei-api-gateway-response.js.map +0 -1
  231. package/lib/@types/huawei/huawei-context.d.ts +0 -188
  232. package/lib/@types/huawei/huawei-context.d.ts.map +0 -1
  233. package/lib/@types/huawei/huawei-context.js +0 -2
  234. package/lib/@types/huawei/huawei-context.js.map +0 -1
  235. package/lib/@types/huawei/index.d.ts +0 -4
  236. package/lib/@types/huawei/index.d.ts.map +0 -1
  237. package/lib/@types/huawei/index.js +0 -2
  238. package/lib/@types/huawei/index.js.map +0 -1
  239. package/lib/@types/index.d.ts +0 -4
  240. package/lib/@types/index.d.ts.map +0 -1
  241. package/lib/@types/index.js +0 -2
  242. package/lib/@types/index.js.map +0 -1
  243. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts.map +0 -1
  244. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +0 -2
  245. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +0 -1
  246. package/lib/adapters/apollo-server/index.d.ts.map +0 -1
  247. package/lib/adapters/apollo-server/index.js +0 -2
  248. package/lib/adapters/apollo-server/index.js.map +0 -1
  249. package/lib/adapters/aws/alb.adapter.d.ts +0 -71
  250. package/lib/adapters/aws/alb.adapter.d.ts.map +0 -1
  251. package/lib/adapters/aws/alb.adapter.js +0 -2
  252. package/lib/adapters/aws/alb.adapter.js.map +0 -1
  253. package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +0 -76
  254. package/lib/adapters/aws/api-gateway-v1.adapter.d.ts.map +0 -1
  255. package/lib/adapters/aws/api-gateway-v1.adapter.js +0 -2
  256. package/lib/adapters/aws/api-gateway-v1.adapter.js.map +0 -1
  257. package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +0 -75
  258. package/lib/adapters/aws/api-gateway-v2.adapter.d.ts.map +0 -1
  259. package/lib/adapters/aws/api-gateway-v2.adapter.js +0 -2
  260. package/lib/adapters/aws/api-gateway-v2.adapter.js.map +0 -1
  261. package/lib/adapters/aws/base/aws-simple-adapter.d.ts +0 -83
  262. package/lib/adapters/aws/base/aws-simple-adapter.d.ts.map +0 -1
  263. package/lib/adapters/aws/base/aws-simple-adapter.js +0 -2
  264. package/lib/adapters/aws/base/aws-simple-adapter.js.map +0 -1
  265. package/lib/adapters/aws/base/index.d.ts +0 -2
  266. package/lib/adapters/aws/base/index.d.ts.map +0 -1
  267. package/lib/adapters/aws/base/index.js +0 -2
  268. package/lib/adapters/aws/base/index.js.map +0 -1
  269. package/lib/adapters/aws/dynamodb.adapter.d.ts +0 -56
  270. package/lib/adapters/aws/dynamodb.adapter.d.ts.map +0 -1
  271. package/lib/adapters/aws/dynamodb.adapter.js +0 -2
  272. package/lib/adapters/aws/dynamodb.adapter.js.map +0 -1
  273. package/lib/adapters/aws/event-bridge.adapter.d.ts +0 -63
  274. package/lib/adapters/aws/event-bridge.adapter.d.ts.map +0 -1
  275. package/lib/adapters/aws/event-bridge.adapter.js +0 -2
  276. package/lib/adapters/aws/event-bridge.adapter.js.map +0 -1
  277. package/lib/adapters/aws/index.d.ts.map +0 -1
  278. package/lib/adapters/aws/index.js +0 -2
  279. package/lib/adapters/aws/index.js.map +0 -1
  280. package/lib/adapters/aws/lambda-edge.adapter.d.ts +0 -209
  281. package/lib/adapters/aws/lambda-edge.adapter.d.ts.map +0 -1
  282. package/lib/adapters/aws/lambda-edge.adapter.js +0 -2
  283. package/lib/adapters/aws/lambda-edge.adapter.js.map +0 -1
  284. package/lib/adapters/aws/request-lambda-edge.adapter.d.ts +0 -131
  285. package/lib/adapters/aws/request-lambda-edge.adapter.d.ts.map +0 -1
  286. package/lib/adapters/aws/request-lambda-edge.adapter.js +0 -2
  287. package/lib/adapters/aws/request-lambda-edge.adapter.js.map +0 -1
  288. package/lib/adapters/aws/s3.adapter.d.ts +0 -56
  289. package/lib/adapters/aws/s3.adapter.d.ts.map +0 -1
  290. package/lib/adapters/aws/s3.adapter.js +0 -2
  291. package/lib/adapters/aws/s3.adapter.js.map +0 -1
  292. package/lib/adapters/aws/sns.adapter.d.ts +0 -56
  293. package/lib/adapters/aws/sns.adapter.d.ts.map +0 -1
  294. package/lib/adapters/aws/sns.adapter.js +0 -2
  295. package/lib/adapters/aws/sns.adapter.js.map +0 -1
  296. package/lib/adapters/aws/sqs.adapter.d.ts +0 -56
  297. package/lib/adapters/aws/sqs.adapter.d.ts.map +0 -1
  298. package/lib/adapters/aws/sqs.adapter.js +0 -2
  299. package/lib/adapters/aws/sqs.adapter.js.map +0 -1
  300. package/lib/adapters/azure/http-trigger-v4.adapter.d.ts.map +0 -1
  301. package/lib/adapters/azure/http-trigger-v4.adapter.js +0 -2
  302. package/lib/adapters/azure/http-trigger-v4.adapter.js.map +0 -1
  303. package/lib/adapters/azure/index.d.ts.map +0 -1
  304. package/lib/adapters/azure/index.js +0 -2
  305. package/lib/adapters/azure/index.js.map +0 -1
  306. package/lib/adapters/digital-ocean/http-function.adapter.d.ts +0 -65
  307. package/lib/adapters/digital-ocean/http-function.adapter.d.ts.map +0 -1
  308. package/lib/adapters/digital-ocean/http-function.adapter.js +0 -2
  309. package/lib/adapters/digital-ocean/http-function.adapter.js.map +0 -1
  310. package/lib/adapters/digital-ocean/index.d.ts.map +0 -1
  311. package/lib/adapters/digital-ocean/index.js +0 -2
  312. package/lib/adapters/digital-ocean/index.js.map +0 -1
  313. package/lib/adapters/dummy/dummy.adapter.d.ts.map +0 -1
  314. package/lib/adapters/dummy/dummy.adapter.js +0 -2
  315. package/lib/adapters/dummy/dummy.adapter.js.map +0 -1
  316. package/lib/adapters/dummy/index.d.ts.map +0 -1
  317. package/lib/adapters/dummy/index.js +0 -2
  318. package/lib/adapters/dummy/index.js.map +0 -1
  319. package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +0 -66
  320. package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts.map +0 -1
  321. package/lib/adapters/huawei/huawei-api-gateway.adapter.js +0 -2
  322. package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +0 -1
  323. package/lib/adapters/huawei/index.d.ts.map +0 -1
  324. package/lib/adapters/huawei/index.js +0 -2
  325. package/lib/adapters/huawei/index.js.map +0 -1
  326. package/lib/contracts/adapter.contract.d.ts +0 -152
  327. package/lib/contracts/adapter.contract.d.ts.map +0 -1
  328. package/lib/contracts/adapter.contract.js +0 -2
  329. package/lib/contracts/adapter.contract.js.map +0 -1
  330. package/lib/contracts/framework.contract.d.ts.map +0 -1
  331. package/lib/contracts/framework.contract.js +0 -2
  332. package/lib/contracts/framework.contract.js.map +0 -1
  333. package/lib/contracts/handler.contract.d.ts +0 -25
  334. package/lib/contracts/handler.contract.d.ts.map +0 -1
  335. package/lib/contracts/handler.contract.js +0 -2
  336. package/lib/contracts/handler.contract.js.map +0 -1
  337. package/lib/contracts/index.d.ts +0 -5
  338. package/lib/contracts/index.d.ts.map +0 -1
  339. package/lib/contracts/index.js +0 -2
  340. package/lib/contracts/index.js.map +0 -1
  341. package/lib/contracts/resolver.contract.d.ts +0 -83
  342. package/lib/contracts/resolver.contract.d.ts.map +0 -1
  343. package/lib/contracts/resolver.contract.js +0 -2
  344. package/lib/contracts/resolver.contract.js.map +0 -1
  345. package/lib/core/base-handler.d.ts.map +0 -1
  346. package/lib/core/base-handler.js +0 -2
  347. package/lib/core/base-handler.js.map +0 -1
  348. package/lib/core/constants.d.ts.map +0 -1
  349. package/lib/core/constants.js +0 -2
  350. package/lib/core/constants.js.map +0 -1
  351. package/lib/core/current-invoke.d.ts +0 -48
  352. package/lib/core/current-invoke.d.ts.map +0 -1
  353. package/lib/core/current-invoke.js +0 -2
  354. package/lib/core/current-invoke.js.map +0 -1
  355. package/lib/core/event-body.d.ts +0 -22
  356. package/lib/core/event-body.d.ts.map +0 -1
  357. package/lib/core/event-body.js +0 -2
  358. package/lib/core/event-body.js.map +0 -1
  359. package/lib/core/headers.d.ts +0 -73
  360. package/lib/core/headers.d.ts.map +0 -1
  361. package/lib/core/headers.js +0 -3
  362. package/lib/core/headers.js.map +0 -1
  363. package/lib/core/index.d.ts +0 -12
  364. package/lib/core/index.d.ts.map +0 -1
  365. package/lib/core/index.js +0 -2
  366. package/lib/core/index.js.map +0 -1
  367. package/lib/core/is-binary.d.ts +0 -73
  368. package/lib/core/is-binary.d.ts.map +0 -1
  369. package/lib/core/is-binary.js +0 -2
  370. package/lib/core/is-binary.js.map +0 -1
  371. package/lib/core/logger.d.ts.map +0 -1
  372. package/lib/core/logger.js +0 -2
  373. package/lib/core/logger.js.map +0 -1
  374. package/lib/core/no-op.d.ts +0 -8
  375. package/lib/core/no-op.d.ts.map +0 -1
  376. package/lib/core/no-op.js +0 -2
  377. package/lib/core/no-op.js.map +0 -1
  378. package/lib/core/optional.d.ts +0 -22
  379. package/lib/core/optional.d.ts.map +0 -1
  380. package/lib/core/optional.js +0 -2
  381. package/lib/core/optional.js.map +0 -1
  382. package/lib/core/path.d.ts.map +0 -1
  383. package/lib/core/path.js +0 -2
  384. package/lib/core/path.js.map +0 -1
  385. package/lib/core/stream.d.ts +0 -21
  386. package/lib/core/stream.d.ts.map +0 -1
  387. package/lib/core/stream.js +0 -2
  388. package/lib/core/stream.js.map +0 -1
  389. package/lib/frameworks/apollo-server/apollo-server.framework.d.ts.map +0 -1
  390. package/lib/frameworks/apollo-server/apollo-server.framework.js +0 -2
  391. package/lib/frameworks/apollo-server/apollo-server.framework.js.map +0 -1
  392. package/lib/frameworks/apollo-server/index.d.ts.map +0 -1
  393. package/lib/frameworks/apollo-server/index.js +0 -2
  394. package/lib/frameworks/apollo-server/index.js.map +0 -1
  395. package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +0 -69
  396. package/lib/frameworks/body-parser/base-body-parser.framework.d.ts.map +0 -1
  397. package/lib/frameworks/body-parser/base-body-parser.framework.js +0 -2
  398. package/lib/frameworks/body-parser/base-body-parser.framework.js.map +0 -1
  399. package/lib/frameworks/body-parser/index.d.ts.map +0 -1
  400. package/lib/frameworks/body-parser/index.js +0 -2
  401. package/lib/frameworks/body-parser/index.js.map +0 -1
  402. package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +0 -26
  403. package/lib/frameworks/body-parser/json-body-parser.framework.d.ts.map +0 -1
  404. package/lib/frameworks/body-parser/json-body-parser.framework.js +0 -2
  405. package/lib/frameworks/body-parser/json-body-parser.framework.js.map +0 -1
  406. package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +0 -26
  407. package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts.map +0 -1
  408. package/lib/frameworks/body-parser/raw-body-parser.framework.js +0 -2
  409. package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +0 -1
  410. package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +0 -26
  411. package/lib/frameworks/body-parser/text-body-parser.framework.d.ts.map +0 -1
  412. package/lib/frameworks/body-parser/text-body-parser.framework.js +0 -2
  413. package/lib/frameworks/body-parser/text-body-parser.framework.js.map +0 -1
  414. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +0 -26
  415. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts.map +0 -1
  416. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +0 -2
  417. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +0 -1
  418. package/lib/frameworks/cors/cors.framework.d.ts.map +0 -1
  419. package/lib/frameworks/cors/cors.framework.js +0 -3
  420. package/lib/frameworks/cors/cors.framework.js.map +0 -1
  421. package/lib/frameworks/cors/index.d.ts.map +0 -1
  422. package/lib/frameworks/cors/index.js +0 -2
  423. package/lib/frameworks/cors/index.js.map +0 -1
  424. package/lib/frameworks/deepkit/http-deepkit.framework.d.ts.map +0 -1
  425. package/lib/frameworks/deepkit/http-deepkit.framework.js +0 -2
  426. package/lib/frameworks/deepkit/http-deepkit.framework.js.map +0 -1
  427. package/lib/frameworks/deepkit/index.d.ts.map +0 -1
  428. package/lib/frameworks/deepkit/index.js +0 -2
  429. package/lib/frameworks/deepkit/index.js.map +0 -1
  430. package/lib/frameworks/express/express.framework.d.ts.map +0 -1
  431. package/lib/frameworks/express/express.framework.js +0 -2
  432. package/lib/frameworks/express/express.framework.js.map +0 -1
  433. package/lib/frameworks/express/index.d.ts.map +0 -1
  434. package/lib/frameworks/express/index.js +0 -2
  435. package/lib/frameworks/express/index.js.map +0 -1
  436. package/lib/frameworks/fastify/fastify.framework.d.ts.map +0 -1
  437. package/lib/frameworks/fastify/fastify.framework.js +0 -2
  438. package/lib/frameworks/fastify/fastify.framework.js.map +0 -1
  439. package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +0 -14
  440. package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts.map +0 -1
  441. package/lib/frameworks/fastify/helpers/no-op-content-parser.js +0 -2
  442. package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +0 -1
  443. package/lib/frameworks/fastify/index.d.ts.map +0 -1
  444. package/lib/frameworks/fastify/index.js +0 -2
  445. package/lib/frameworks/fastify/index.js.map +0 -1
  446. package/lib/frameworks/hapi/hapi.framework.d.ts.map +0 -1
  447. package/lib/frameworks/hapi/hapi.framework.js +0 -2
  448. package/lib/frameworks/hapi/hapi.framework.js.map +0 -1
  449. package/lib/frameworks/hapi/index.d.ts.map +0 -1
  450. package/lib/frameworks/hapi/index.js +0 -2
  451. package/lib/frameworks/hapi/index.js.map +0 -1
  452. package/lib/frameworks/koa/index.d.ts.map +0 -1
  453. package/lib/frameworks/koa/index.js +0 -2
  454. package/lib/frameworks/koa/index.js.map +0 -1
  455. package/lib/frameworks/koa/koa.framework.d.ts.map +0 -1
  456. package/lib/frameworks/koa/koa.framework.js +0 -2
  457. package/lib/frameworks/koa/koa.framework.js.map +0 -1
  458. package/lib/frameworks/lazy/index.d.ts.map +0 -1
  459. package/lib/frameworks/lazy/index.js +0 -2
  460. package/lib/frameworks/lazy/index.js.map +0 -1
  461. package/lib/frameworks/lazy/lazy.framework.d.ts.map +0 -1
  462. package/lib/frameworks/lazy/lazy.framework.js +0 -2
  463. package/lib/frameworks/lazy/lazy.framework.js.map +0 -1
  464. package/lib/frameworks/trpc/index.d.ts.map +0 -1
  465. package/lib/frameworks/trpc/index.js +0 -2
  466. package/lib/frameworks/trpc/index.js.map +0 -1
  467. package/lib/frameworks/trpc/trpc.framework.d.ts.map +0 -1
  468. package/lib/frameworks/trpc/trpc.framework.js +0 -2
  469. package/lib/frameworks/trpc/trpc.framework.js.map +0 -1
  470. package/lib/handlers/aws/aws-stream.handler.d.ts.map +0 -1
  471. package/lib/handlers/aws/aws-stream.handler.js +0 -2
  472. package/lib/handlers/aws/aws-stream.handler.js.map +0 -1
  473. package/lib/handlers/aws/index.d.ts.map +0 -1
  474. package/lib/handlers/aws/index.js +0 -2
  475. package/lib/handlers/aws/index.js.map +0 -1
  476. package/lib/handlers/azure/azure.handler.d.ts.map +0 -1
  477. package/lib/handlers/azure/azure.handler.js +0 -2
  478. package/lib/handlers/azure/azure.handler.js.map +0 -1
  479. package/lib/handlers/azure/index.d.ts.map +0 -1
  480. package/lib/handlers/azure/index.js +0 -2
  481. package/lib/handlers/azure/index.js.map +0 -1
  482. package/lib/handlers/base/index.d.ts +0 -2
  483. package/lib/handlers/base/index.d.ts.map +0 -1
  484. package/lib/handlers/base/index.js +0 -2
  485. package/lib/handlers/base/index.js.map +0 -1
  486. package/lib/handlers/base/raw-request.d.ts.map +0 -1
  487. package/lib/handlers/base/raw-request.js +0 -2
  488. package/lib/handlers/base/raw-request.js.map +0 -1
  489. package/lib/handlers/default/default.handler.d.ts.map +0 -1
  490. package/lib/handlers/default/default.handler.js +0 -2
  491. package/lib/handlers/default/default.handler.js.map +0 -1
  492. package/lib/handlers/default/index.d.ts.map +0 -1
  493. package/lib/handlers/default/index.js +0 -2
  494. package/lib/handlers/default/index.js.map +0 -1
  495. package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +0 -17
  496. package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts.map +0 -1
  497. package/lib/handlers/digital-ocean/digital-ocean.handler.js +0 -2
  498. package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +0 -1
  499. package/lib/handlers/digital-ocean/index.d.ts.map +0 -1
  500. package/lib/handlers/digital-ocean/index.js +0 -2
  501. package/lib/handlers/digital-ocean/index.js.map +0 -1
  502. package/lib/handlers/firebase/http-firebase-v2.handler.d.ts +0 -27
  503. package/lib/handlers/firebase/http-firebase-v2.handler.d.ts.map +0 -1
  504. package/lib/handlers/firebase/http-firebase-v2.handler.js +0 -2
  505. package/lib/handlers/firebase/http-firebase-v2.handler.js.map +0 -1
  506. package/lib/handlers/firebase/http-firebase.handler.d.ts +0 -19
  507. package/lib/handlers/firebase/http-firebase.handler.d.ts.map +0 -1
  508. package/lib/handlers/firebase/http-firebase.handler.js +0 -2
  509. package/lib/handlers/firebase/http-firebase.handler.js.map +0 -1
  510. package/lib/handlers/firebase/index.d.ts.map +0 -1
  511. package/lib/handlers/firebase/index.js +0 -2
  512. package/lib/handlers/firebase/index.js.map +0 -1
  513. package/lib/handlers/gcp/gcp.handler.d.ts.map +0 -1
  514. package/lib/handlers/gcp/gcp.handler.js +0 -2
  515. package/lib/handlers/gcp/gcp.handler.js.map +0 -1
  516. package/lib/handlers/gcp/index.d.ts.map +0 -1
  517. package/lib/handlers/gcp/index.js +0 -2
  518. package/lib/handlers/gcp/index.js.map +0 -1
  519. package/lib/handlers/huawei/http-huawei.handler.d.ts.map +0 -1
  520. package/lib/handlers/huawei/http-huawei.handler.js +0 -2
  521. package/lib/handlers/huawei/http-huawei.handler.js.map +0 -1
  522. package/lib/handlers/huawei/index.d.ts.map +0 -1
  523. package/lib/handlers/huawei/index.js +0 -2
  524. package/lib/handlers/huawei/index.js.map +0 -1
  525. package/lib/index.d.ts.map +0 -1
  526. package/lib/index.doc.js +0 -2
  527. package/lib/index.doc.js.map +0 -1
  528. package/lib/index.js +0 -2
  529. package/lib/index.js.map +0 -1
  530. package/lib/network/index.d.ts +0 -5
  531. package/lib/network/index.d.ts.map +0 -1
  532. package/lib/network/index.js +0 -2
  533. package/lib/network/index.js.map +0 -1
  534. package/lib/network/request.d.ts.map +0 -1
  535. package/lib/network/request.js +0 -2
  536. package/lib/network/request.js.map +0 -1
  537. package/lib/network/response-stream.d.ts +0 -41
  538. package/lib/network/response-stream.d.ts.map +0 -1
  539. package/lib/network/response-stream.js +0 -7
  540. package/lib/network/response-stream.js.map +0 -1
  541. package/lib/network/response.d.ts +0 -48
  542. package/lib/network/response.d.ts.map +0 -1
  543. package/lib/network/response.js +0 -4
  544. package/lib/network/response.js.map +0 -1
  545. package/lib/network/utils.d.ts +0 -9
  546. package/lib/network/utils.d.ts.map +0 -1
  547. package/lib/network/utils.js +0 -2
  548. package/lib/network/utils.js.map +0 -1
  549. package/lib/resolvers/aws-context/aws-context.resolver.d.ts.map +0 -1
  550. package/lib/resolvers/aws-context/aws-context.resolver.js +0 -2
  551. package/lib/resolvers/aws-context/aws-context.resolver.js.map +0 -1
  552. package/lib/resolvers/aws-context/index.d.ts.map +0 -1
  553. package/lib/resolvers/aws-context/index.js +0 -2
  554. package/lib/resolvers/aws-context/index.js.map +0 -1
  555. package/lib/resolvers/callback/callback.resolver.d.ts.map +0 -1
  556. package/lib/resolvers/callback/callback.resolver.js +0 -2
  557. package/lib/resolvers/callback/callback.resolver.js.map +0 -1
  558. package/lib/resolvers/callback/index.d.ts.map +0 -1
  559. package/lib/resolvers/callback/index.js +0 -2
  560. package/lib/resolvers/callback/index.js.map +0 -1
  561. package/lib/resolvers/dummy/dummy.resolver.d.ts +0 -14
  562. package/lib/resolvers/dummy/dummy.resolver.d.ts.map +0 -1
  563. package/lib/resolvers/dummy/dummy.resolver.js +0 -2
  564. package/lib/resolvers/dummy/dummy.resolver.js.map +0 -1
  565. package/lib/resolvers/dummy/index.d.ts.map +0 -1
  566. package/lib/resolvers/dummy/index.js +0 -2
  567. package/lib/resolvers/dummy/index.js.map +0 -1
  568. package/lib/resolvers/promise/index.d.ts.map +0 -1
  569. package/lib/resolvers/promise/index.js +0 -2
  570. package/lib/resolvers/promise/index.js.map +0 -1
  571. package/lib/resolvers/promise/promise.resolver.d.ts +0 -14
  572. package/lib/resolvers/promise/promise.resolver.d.ts.map +0 -1
  573. package/lib/resolvers/promise/promise.resolver.js +0 -2
  574. package/lib/resolvers/promise/promise.resolver.js.map +0 -1
  575. package/lib/serverless-adapter.d.ts +0 -119
  576. package/lib/serverless-adapter.d.ts.map +0 -1
  577. package/lib/serverless-adapter.js +0 -2
  578. package/lib/serverless-adapter.js.map +0 -1
@@ -1,2 +0,0 @@
1
- "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default")),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),aws_exports={};module.exports=__toCommonJS(aws_exports);__reExport(aws_exports,require("./alb.adapter"),module.exports);__reExport(aws_exports,require("./api-gateway-v1.adapter"),module.exports);__reExport(aws_exports,require("./api-gateway-v2.adapter"),module.exports);__reExport(aws_exports,require("./dynamodb.adapter"),module.exports);__reExport(aws_exports,require("./event-bridge.adapter"),module.exports);__reExport(aws_exports,require("./lambda-edge.adapter"),module.exports);__reExport(aws_exports,require("./s3.adapter"),module.exports);__reExport(aws_exports,require("./sns.adapter"),module.exports);__reExport(aws_exports,require("./sqs.adapter"),module.exports);__reExport(aws_exports,require("./base"),module.exports);__reExport(aws_exports,require("./request-lambda-edge.adapter"),module.exports);
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/adapters/aws/index.ts"],"sourcesContent":["export * from './alb.adapter';\nexport * from './api-gateway-v1.adapter';\nexport * from './api-gateway-v2.adapter';\nexport * from './dynamodb.adapter';\nexport * from './event-bridge.adapter';\nexport * from './lambda-edge.adapter';\nexport * from './s3.adapter';\nexport * from './sns.adapter';\nexport * from './sqs.adapter';\nexport * from './base';\nexport * from './request-lambda-edge.adapter';\n"],"names":[],"mappings":"kqBAAA,YAAA,CAAA,EAAA,OAAA,QAAA,aAAA,WAAA,EAAA,WAAA,YAAc,QAAd,eAAA,EAAA,OAAA,OAAA,EACA,WAAA,YAAc,QADd,0BAAA,EAAA,OAAA,OAAA,EAEA,WAAA,YAAc,QAFd,0BAAA,EAAA,OAAA,OAAA,EAGA,WAAA,YAAc,QAHd,oBAAA,EAAA,OAAA,OAAA,EAIA,WAAA,YAAc,QAJd,wBAAA,EAAA,OAAA,OAAA,EAKA,WAAA,YAAc,QALd,uBAAA,EAAA,OAAA,OAAA,EAMA,WAAA,YAAc,QANd,cAAA,EAAA,OAAA,OAAA,EAOA,WAAA,YAAc,QAPd,eAAA,EAAA,OAAA,OAAA,EAQA,WAAA,YAAc,QARd,eAAA,EAAA,OAAA,OAAA,EASA,WAAA,YAAc,QATd,QAAA,EAAA,OAAA,OAAA,EAUA,WAAA,YAAc,QAVd,+BAAA,EAAA,OAAA,OAAA"}
@@ -1,209 +0,0 @@
1
- import type { CloudFrontRequest, Context } from 'aws-lambda';
2
- import type { CloudFrontEvent, CloudFrontHeaders } from 'aws-lambda/common/cloudfront';
3
- import type { CloudFrontRequestEvent, CloudFrontRequestResult } from 'aws-lambda/trigger/cloudfront-request';
4
- import { BothValueHeaders, Concrete, SingleValueHeaders } from '../../@types';
5
- import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
6
- /**
7
- * The type alias to indicate where we get the default value of query string to create the request.
8
- *
9
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
10
- * @public
11
- */
12
- export type DefaultQueryString = CloudFrontRequestEvent['Records'][number]['cf']['request']['querystring'];
13
- /**
14
- * The type alias to indicate where we get the default value of path to create the request.
15
- *
16
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
17
- * @public
18
- */
19
- export type DefaultForwardPath = CloudFrontRequestEvent['Records'][number]['cf']['request']['uri'];
20
- /**
21
- * Represents the body of the new version of Lambda\@edge, which uses the `body` property inside `request` as the body (library) of the request.
22
- *
23
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
24
- * @public
25
- */
26
- export type NewLambdaEdgeBody = CloudFrontRequestEvent['Records'][number]['cf']['request']['body'];
27
- /**
28
- * Represents the body of the old version of Lambda\@edge supported by \@vendia/serverless-express which returns the `data` property within `body` for the body (library) of the request.
29
- *
30
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
31
- * @public
32
- */
33
- export type OldLambdaEdgeBody = Concrete<CloudFrontRequestEvent['Records'][number]['cf']['request']>['body']['data'];
34
- /**
35
- * The list was created based on {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html | these docs} in the "Disallowed Headers" section.
36
- *
37
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
38
- * @public
39
- */
40
- export declare const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS: (string | RegExp)[];
41
- /**
42
- * The default max response size in bytes of viewer request and viewer response.
43
- *
44
- * @defaultValue 1024 * 40 = 40960 = 40KB
45
- *
46
- * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
47
- *
48
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
49
- * @public
50
- */
51
- export declare const DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES: number;
52
- /**
53
- * The default max response size in bytes of origin request and origin response.
54
- *
55
- * @defaultValue 1024 * 1024 = 1048576 = 1MB
56
- *
57
- * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
58
- *
59
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
60
- * @public
61
- */
62
- export declare const DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES: number;
63
- /**
64
- * The options to customize the {@link LambdaEdgeAdapter}.
65
- *
66
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
67
- * @public
68
- */
69
- export interface LambdaEdgeAdapterOptions {
70
- /**
71
- * The max response size in bytes of viewer request and viewer response.
72
- *
73
- * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
74
- *
75
- * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}
76
- */
77
- viewerMaxResponseSizeInBytes?: number;
78
- /**
79
- * The max response size in bytes of origin request and origin response.
80
- *
81
- * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
82
- *
83
- * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}
84
- */
85
- originMaxResponseSizeInBytes?: number;
86
- /**
87
- * The function called when the response size exceed the max limits of the Lambda\@edge
88
- *
89
- * @param response - The response from framework that exceed the limit of Lambda\@edge
90
- * @defaultValue undefined
91
- */
92
- onResponseSizeExceedLimit?: (response: CloudFrontRequestResult) => CloudFrontRequestResult;
93
- /**
94
- * Return the path to be used to create a request to the framework
95
- *
96
- * @remarks You MUST append the query params from {@link DefaultQueryString}, you can use the helper {@link getPathWithQueryStringParams}.
97
- *
98
- * @param event - The event sent by the serverless
99
- * @defaultValue The value from {@link DefaultForwardPath}
100
- */
101
- getPathFromEvent?: (event: CloudFrontRequestEvent['Records'][number]) => string;
102
- /**
103
- * The headers that will be stripped from the headers object because Lambda\@edge will fail if these headers are passed in the response.
104
- *
105
- * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)
106
- *
107
- * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.
108
- */
109
- disallowedHeaders?: (string | RegExp)[];
110
- /**
111
- * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.
112
- *
113
- * @param header - The header of the response
114
- * @defaultValue The default method is implemented to test the header against the list {@link LambdaEdgeAdapterOptions.disallowedHeaders}.
115
- */
116
- shouldStripHeader?: (header: string) => boolean;
117
- /**
118
- * By default, the {@link aws-lambda#CloudFrontRequestResult} has the `headers` property, but we also have the headers sent by the framework too.
119
- * So this setting tells us how to handle this case, if you pass `true` to this property, we will use the framework headers.
120
- * Otherwise, we will forward the body back to cloudfront without modifying or trying to set the `headers` property inside {@link aws-lambda#CloudFrontRequestResult}.
121
- *
122
- * @defaultValue false
123
- */
124
- shouldUseHeadersFromFramework?: boolean;
125
- }
126
- /**
127
- * The adapter to handle requests from AWS Lambda\@Edge.
128
- *
129
- * This adapter is not fully compatible with Lambda\@edge supported by \@vendia/serverless-express, the request body was modified to return {@link NewLambdaEdgeBody} instead {@link OldLambdaEdgeBody}.
130
- * Also, the response has been modified to return entire body sent by the framework, in this form you MUST return the body from the framework in the format of {@link aws-lambda#CloudFrontRequestResult}.
131
- * And when we get an error during the forwarding to the framework, we call `resolver.fail` instead of trying to return status 500 like the old implementation was.
132
- *
133
- * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}
134
- * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}
135
- *
136
- * @example
137
- * ```typescript
138
- * const getPathFromEvent = () => '/lambda/edge'; // will forward all requests to the same endpoint
139
- * const adapter = new LambdaEdgeAdapter({ getPathFromEvent });
140
- * ```
141
- *
142
- * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
143
- * @public
144
- */
145
- export declare class LambdaEdgeAdapter implements AdapterContract<CloudFrontRequestEvent, Context, CloudFrontRequestResult> {
146
- protected readonly options?: LambdaEdgeAdapterOptions | undefined;
147
- /**
148
- * Default constructor
149
- *
150
- * @param options - The options to customize the {@link LambdaEdgeAdapter}
151
- */
152
- constructor(options?: LambdaEdgeAdapterOptions | undefined);
153
- /**
154
- * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.
155
- */
156
- protected readonly cachedDisallowedHeaders: RegExp[];
157
- /**
158
- * {@inheritDoc}
159
- */
160
- getAdapterName(): string;
161
- /**
162
- * {@inheritDoc}
163
- */
164
- canHandle(event: unknown): event is CloudFrontRequestEvent;
165
- /**
166
- * {@inheritDoc}
167
- */
168
- getRequest(event: CloudFrontRequestEvent): AdapterRequest;
169
- /**
170
- * {@inheritDoc}
171
- */
172
- getResponse(props: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult;
173
- /**
174
- * {@inheritDoc}
175
- */
176
- onErrorWhileForwarding({ error, delegatedResolver, }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void;
177
- /**
178
- * Returns the headers with the flattened (non-list) values of the cloudfront request headers
179
- *
180
- * @param cloudFrontRequest - The cloudfront request
181
- */
182
- protected getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest: CloudFrontRequest): SingleValueHeaders;
183
- /**
184
- * Returns the framework response in the format required by the Lambda\@edge.
185
- *
186
- * @param body - The body of the response
187
- * @param frameworkHeaders - The headers from the framework
188
- */
189
- protected getResponseToLambdaEdge({ body, headers: frameworkHeaders, }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult;
190
- /**
191
- * Returns headers in Cloudfront Response format.
192
- *
193
- * @param originalHeaders - The original version of the request sent by the framework
194
- */
195
- protected getHeadersForCloudfrontResponse(originalHeaders: BothValueHeaders): CloudFrontHeaders;
196
- /**
197
- * Returns the information if we should remove the response header
198
- *
199
- * @param headerKey - The header that will be tested
200
- */
201
- protected shouldStripHeader(headerKey: string): boolean;
202
- /**
203
- * Determines whether the event is from origin or is from viewer.
204
- *
205
- * @param content - The event sent by AWS or the response sent by the framework
206
- */
207
- protected isEventTypeOrigin(content: CloudFrontEvent['config']): boolean;
208
- }
209
- //# sourceMappingURL=lambda-edge.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lambda-edge.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/lambda-edge.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAElB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,YAAY,EACb,MAAM,iBAAiB,CAAC;AASzB;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC5B,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC5B,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAC3B,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CACtC,sBAAsB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAC3D,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAElB;;;;;GAKG;AACH,e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AsB,GAAG,cAAc;IA6ChE;;OAEG;IACI,WAAW,CAChB,KAAK,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,GACrD,uBAAuB;IAgC1B;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,GAClB,EAAE,YAAY,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,GAAG,IAAI;IAQvE;;;;OAIG;IACH,SAAS,CAAC,wCAAwC,CAChD,iBAAiB,EAAE,iBAAiB,GACnC,kBAAkB;IAUrB;;;;;OAKG;IACH,SAAS,CAAC,uBAAuB,CAAC,EAChC,IAAI,EACJ,OAAO,EAAE,gBAAgB,GAC1B,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,GAAG,uBAAuB;IA6B5E;;;;OAIG;IACH,SAAS,CAAC,+BAA+B,CACvC,eAAe,EAAE,gBAAgB,GAChC,iBAAiB;IA4BpB;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAevD;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,OAAO;CAKzE"}
@@ -1,2 +0,0 @@
1
- "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),lambda_edge_adapter_exports={};__export(lambda_edge_adapter_exports,{DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS:()=>DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES:()=>DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES:()=>DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,LambdaEdgeAdapter:()=>LambdaEdgeAdapter});module.exports=__toCommonJS(lambda_edge_adapter_exports);var import_core=require("../../core");const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS=["Connection","Expect","Keep-Alive","Proxy-Authenticate","Proxy-Authorization","Proxy-Connection","Trailer","Upgrade","X-Accel-Buffering","X-Accel-Charset","X-Accel-Limit-Rate","X-Accel-Redirect",/(X-Amz-Cf-)(.*)/gim,"X-Cache",/(X-Edge-)(.*)/gim,"X-Forwarded-Proto","X-Real-IP"],DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES=1024*40,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES=1024*1024;class LambdaEdgeAdapter{constructor(options){var _a;this.options=options;const disallowedHeaders=(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.disallowedHeaders,DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS);this.cachedDisallowedHeaders=disallowedHeaders.map(disallowedHeader=>disallowedHeader instanceof RegExp?disallowedHeader:new RegExp(`(${disallowedHeader})`,"gim"))}getAdapterName(){return LambdaEdgeAdapter.name}canHandle(event){var _a,_b,_c;const lambdaEdgeEvent=event;if(!Array.isArray(lambdaEdgeEvent==null?void 0:lambdaEdgeEvent.Records))return!1;const eventType=(_c=(_b=(_a=lambdaEdgeEvent.Records[0])==null?void 0:_a.cf)==null?void 0:_b.config)==null?void 0:_c.eventType;return["origin-response","origin-request","viewer-response","viewer-request"].includes(eventType)}getRequest(event){var _a;const request=event.Records[0],cloudFrontRequest=request.cf.request,method=cloudFrontRequest.method,pathFromOptions=(_a=this.options)!=null&&_a.getPathFromEvent?this.options.getPathFromEvent(request):void 0,defaultPath=(0,import_core.getPathWithQueryStringParams)(cloudFrontRequest.uri,cloudFrontRequest.querystring),path=(0,import_core.getDefaultIfUndefined)(pathFromOptions,defaultPath),remoteAddress=cloudFrontRequest.clientIp,headers=this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);let body;if(cloudFrontRequest.body){const[buffer,contentLength]=(0,import_core.getEventBodyAsBuffer)(JSON.stringify(cloudFrontRequest.body),!1);body=buffer,headers["content-length"]=contentLength.toString()}const{host}=headers;return{method,path,headers,body,remoteAddress,host,hostname:host}}getResponse(props){var _a,_b,_c;const response=this.getResponseToLambdaEdge(props),responseToServiceBytes=new TextEncoder().encode(JSON.stringify(response)).length,maxSizeInBytes=this.isEventTypeOrigin(props.event.Records[0].cf.config)?(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.originMaxResponseSizeInBytes,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES):(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.viewerMaxResponseSizeInBytes,DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES);return responseToServiceBytes<=maxSizeInBytes||((_c=this.options)!=null&&_c.onResponseSizeExceedLimit?this.options.onResponseSizeExceedLimit(response):props.log.error(`SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${responseToServiceBytes} of the max of ${maxSizeInBytes}.`)),response}onErrorWhileForwarding({error,delegatedResolver}){delegatedResolver.fail(error)}getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest){return Object.keys(cloudFrontRequest.headers).reduce((acc,headerKey)=>{const headerValue=cloudFrontRequest.headers[headerKey];return acc[headerKey]=headerValue.map(header=>header.value).join(","),acc},{})}getResponseToLambdaEdge({body,headers:frameworkHeaders}){var _a;const shouldUseHeadersFromFramework=(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.shouldUseHeadersFromFramework,!1),parsedBody=JSON.parse(body);return parsedBody.headers&&(parsedBody.headers=Object.keys(parsedBody.headers).reduce((acc,header)=>(this.shouldStripHeader(header)||(acc[header]=parsedBody.headers[header]),acc),{})),shouldUseHeadersFromFramework&&(parsedBody.headers=this.getHeadersForCloudfrontResponse(frameworkHeaders)),parsedBody}getHeadersForCloudfrontResponse(originalHeaders){return Object.keys(originalHeaders).reduce((acc,headerKey)=>{if(this.shouldStripHeader(headerKey))return acc;acc[headerKey]||(acc[headerKey]=[]);const headerValue=originalHeaders[headerKey];if(!Array.isArray(headerValue))return acc[headerKey].push({key:headerKey,value:headerValue||""}),acc;const headersArray=headerValue.map(value=>({key:headerKey,value}));return acc[headerKey].push(...headersArray),acc},{})}shouldStripHeader(headerKey){var _a;if((_a=this.options)!=null&&_a.shouldStripHeader)return this.options.shouldStripHeader(headerKey);const headerKeyLowerCase=headerKey.toLowerCase();for(const stripHeaderIf of this.cachedDisallowedHeaders)if(stripHeaderIf.test(headerKeyLowerCase))return!0;return!1}isEventTypeOrigin(content){return content.eventType.includes("origin")}}
2
- //# sourceMappingURL=lambda-edge.adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lambda-edge.adapter.js","sources":["../../../src/adapters/aws/lambda-edge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { CloudFrontRequest, Context } from 'aws-lambda';\nimport type {\n CloudFrontEvent,\n CloudFrontHeaders,\n CloudFrontResultResponse,\n} from 'aws-lambda/common/cloudfront';\nimport type {\n CloudFrontRequestEvent,\n CloudFrontRequestResult,\n} from 'aws-lambda/trigger/cloudfront-request';\nimport { BothValueHeaders, Concrete, SingleValueHeaders } from '../../@types';\nimport {\n AdapterContract,\n AdapterRequest,\n GetResponseAdapterProps,\n OnErrorProps,\n} from '../../contracts';\nimport {\n getDefaultIfUndefined,\n getEventBodyAsBuffer,\n getPathWithQueryStringParams,\n} from '../../core';\n\n//#endregion\n\n/**\n * The type alias to indicate where we get the default value of query string to create the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type DefaultQueryString =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['querystring'];\n\n/**\n * The type alias to indicate where we get the default value of path to create the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type DefaultForwardPath =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['uri'];\n\n/**\n * Represents the body of the new version of Lambda\\@edge, which uses the `body` property inside `request` as the body (library) of the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type NewLambdaEdgeBody =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['body'];\n\n/**\n * Represents the body of the old version of Lambda\\@edge supported by \\@vendia/serverless-express which returns the `data` property within `body` for the body (library) of the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type OldLambdaEdgeBody = Concrete<\n CloudFrontRequestEvent['Records'][number]['cf']['request']\n>['body']['data'];\n\n/**\n * The list was created based on {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html | these docs} in the \"Disallowed Headers\" section.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS: (string | RegExp)[] = [\n 'Connection',\n 'Expect',\n 'Keep-Alive',\n 'Proxy-Authenticate',\n 'Proxy-Authorization',\n 'Proxy-Connection',\n 'Trailer',\n 'Upgrade',\n 'X-Accel-Buffering',\n 'X-Accel-Charset',\n 'X-Accel-Limit-Rate',\n 'X-Accel-Redirect',\n /(X-Amz-Cf-)(.*)/gim,\n 'X-Cache',\n /(X-Edge-)(.*)/gim,\n 'X-Forwarded-Proto',\n 'X-Real-IP',\n];\n\n/**\n * The default max response size in bytes of viewer request and viewer response.\n *\n * @defaultValue 1024 * 40 = 40960 = 40KB\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES = 1024 * 40;\n\n/**\n * The default max response size in bytes of origin request and origin response.\n *\n * @defaultValue 1024 * 1024 = 1048576 = 1MB\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES = 1024 * 1024;\n\n/**\n * The options to customize the {@link LambdaEdgeAdapter}.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport interface LambdaEdgeAdapterOptions {\n /**\n * The max response size in bytes of viewer request and viewer response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n viewerMaxResponseSizeInBytes?: number;\n\n /**\n * The max response size in bytes of origin request and origin response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n originMaxResponseSizeInBytes?: number;\n\n /**\n * The function called when the response size exceed the max limits of the Lambda\\@edge\n *\n * @param response - The response from framework that exceed the limit of Lambda\\@edge\n * @defaultValue undefined\n */\n onResponseSizeExceedLimit?: (\n response: CloudFrontRequestResult,\n ) => CloudFrontRequestResult;\n\n /**\n * Return the path to be used to create a request to the framework\n *\n * @remarks You MUST append the query params from {@link DefaultQueryString}, you can use the helper {@link getPathWithQueryStringParams}.\n *\n * @param event - The event sent by the serverless\n * @defaultValue The value from {@link DefaultForwardPath}\n */\n getPathFromEvent?: (\n event: CloudFrontRequestEvent['Records'][number],\n ) => string;\n\n /**\n * The headers that will be stripped from the headers object because Lambda\\@edge will fail if these headers are passed in the response.\n *\n * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)\n *\n * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.\n */\n disallowedHeaders?: (string | RegExp)[];\n\n /**\n * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.\n *\n * @param header - The header of the response\n * @defaultValue The default method is implemented to test the header against the list {@link LambdaEdgeAdapterOptions.disallowedHeaders}.\n */\n shouldStripHeader?: (header: string) => boolean;\n\n /**\n * By default, the {@link aws-lambda#CloudFrontRequestResult} has the `headers` property, but we also have the headers sent by the framework too.\n * So this setting tells us how to handle this case, if you pass `true` to this property, we will use the framework headers.\n * Otherwise, we will forward the body back to cloudfront without modifying or trying to set the `headers` property inside {@link aws-lambda#CloudFrontRequestResult}.\n *\n * @defaultValue false\n */\n shouldUseHeadersFromFramework?: boolean;\n}\n\n/**\n * The adapter to handle requests from AWS Lambda\\@Edge.\n *\n * This adapter is not fully compatible with Lambda\\@edge supported by \\@vendia/serverless-express, the request body was modified to return {@link NewLambdaEdgeBody} instead {@link OldLambdaEdgeBody}.\n * Also, the response has been modified to return entire body sent by the framework, in this form you MUST return the body from the framework in the format of {@link aws-lambda#CloudFrontRequestResult}.\n * And when we get an error during the forwarding to the framework, we call `resolver.fail` instead of trying to return status 500 like the old implementation was.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}\n *\n * @example\n * ```typescript\n * const getPathFromEvent = () => '/lambda/edge'; // will forward all requests to the same endpoint\n * const adapter = new LambdaEdgeAdapter({ getPathFromEvent });\n * ```\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport class LambdaEdgeAdapter\n implements\n AdapterContract<CloudFrontRequestEvent, Context, CloudFrontRequestResult>\n{\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link LambdaEdgeAdapter}\n */\n constructor(protected readonly options?: LambdaEdgeAdapterOptions) {\n const disallowedHeaders = getDefaultIfUndefined(\n this.options?.disallowedHeaders,\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n );\n\n this.cachedDisallowedHeaders = disallowedHeaders.map(disallowedHeader => {\n if (disallowedHeader instanceof RegExp) return disallowedHeader;\n\n return new RegExp(`(${disallowedHeader})`, 'gim');\n });\n }\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.\n */\n protected readonly cachedDisallowedHeaders: RegExp[];\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return LambdaEdgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is CloudFrontRequestEvent {\n const lambdaEdgeEvent = event as Partial<CloudFrontRequestEvent>;\n\n if (!Array.isArray(lambdaEdgeEvent?.Records)) return false;\n\n const eventType = lambdaEdgeEvent.Records[0]?.cf?.config?.eventType;\n const validEventTypes: CloudFrontEvent['config']['eventType'][] = [\n 'origin-response',\n 'origin-request',\n 'viewer-response',\n 'viewer-request',\n ];\n\n return validEventTypes.includes(eventType);\n }\n\n /**\n * {@inheritDoc}\n */\n public getRequest(event: CloudFrontRequestEvent): AdapterRequest {\n const request = event.Records[0];\n const cloudFrontRequest = request.cf.request;\n\n const method = cloudFrontRequest.method;\n\n const pathFromOptions = this.options?.getPathFromEvent\n ? this.options.getPathFromEvent(request)\n : undefined;\n const defaultPath = getPathWithQueryStringParams(\n cloudFrontRequest.uri,\n cloudFrontRequest.querystring,\n );\n const path = getDefaultIfUndefined(pathFromOptions, defaultPath);\n\n const remoteAddress = cloudFrontRequest.clientIp;\n\n const headers =\n this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);\n\n let body: Buffer | undefined;\n\n if (cloudFrontRequest.body) {\n const [buffer, contentLength] = getEventBodyAsBuffer(\n JSON.stringify(cloudFrontRequest.body),\n false,\n );\n\n body = buffer;\n headers['content-length'] = contentLength.toString();\n }\n\n const { host } = headers;\n\n return {\n method,\n path,\n headers,\n body,\n remoteAddress,\n host,\n hostname: host,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public getResponse(\n props: GetResponseAdapterProps<CloudFrontRequestEvent>,\n ): CloudFrontRequestResult {\n const response = this.getResponseToLambdaEdge(props);\n const responseToServiceBytes = new TextEncoder().encode(\n JSON.stringify(response),\n ).length;\n\n const isOriginRequestOrResponse = this.isEventTypeOrigin(\n props.event.Records[0].cf.config,\n );\n const maxSizeInBytes = isOriginRequestOrResponse\n ? getDefaultIfUndefined(\n this.options?.originMaxResponseSizeInBytes,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n )\n : getDefaultIfUndefined(\n this.options?.viewerMaxResponseSizeInBytes,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n );\n\n if (responseToServiceBytes <= maxSizeInBytes) return response;\n\n if (this.options?.onResponseSizeExceedLimit)\n this.options.onResponseSizeExceedLimit(response);\n else {\n props.log.error(\n `SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${responseToServiceBytes} of the max of ${maxSizeInBytes}.`,\n );\n }\n\n return response;\n }\n\n /**\n * {@inheritDoc}\n */\n public onErrorWhileForwarding({\n error,\n delegatedResolver,\n }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void {\n delegatedResolver.fail(error);\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Returns the headers with the flattened (non-list) values of the cloudfront request headers\n *\n * @param cloudFrontRequest - The cloudfront request\n */\n protected getFlattenedHeadersFromCloudfrontRequest(\n cloudFrontRequest: CloudFrontRequest,\n ): SingleValueHeaders {\n return Object.keys(cloudFrontRequest.headers).reduce((acc, headerKey) => {\n const headerValue = cloudFrontRequest.headers[headerKey];\n\n acc[headerKey] = headerValue.map(header => header.value).join(',');\n\n return acc;\n }, {} as SingleValueHeaders);\n }\n\n /**\n * Returns the framework response in the format required by the Lambda\\@edge.\n *\n * @param body - The body of the response\n * @param frameworkHeaders - The headers from the framework\n */\n protected getResponseToLambdaEdge({\n body,\n headers: frameworkHeaders,\n }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult {\n const shouldUseHeadersFromFramework = getDefaultIfUndefined(\n this.options?.shouldUseHeadersFromFramework,\n false,\n );\n\n const parsedBody: CloudFrontResultResponse | CloudFrontRequest =\n JSON.parse(body);\n\n if (parsedBody.headers) {\n parsedBody.headers = Object.keys(parsedBody.headers).reduce(\n (acc, header) => {\n if (this.shouldStripHeader(header)) return acc;\n\n acc[header] = parsedBody.headers![header];\n\n return acc;\n },\n {} as CloudFrontHeaders,\n );\n }\n\n if (!shouldUseHeadersFromFramework) return parsedBody;\n\n parsedBody.headers = this.getHeadersForCloudfrontResponse(frameworkHeaders);\n\n return parsedBody;\n }\n\n /**\n * Returns headers in Cloudfront Response format.\n *\n * @param originalHeaders - The original version of the request sent by the framework\n */\n protected getHeadersForCloudfrontResponse(\n originalHeaders: BothValueHeaders,\n ): CloudFrontHeaders {\n return Object.keys(originalHeaders).reduce((acc, headerKey) => {\n if (this.shouldStripHeader(headerKey)) return acc;\n\n if (!acc[headerKey]) acc[headerKey] = [];\n\n const headerValue = originalHeaders[headerKey];\n\n if (!Array.isArray(headerValue)) {\n acc[headerKey].push({\n key: headerKey,\n value: headerValue || '',\n });\n\n return acc;\n }\n\n const headersArray = headerValue.map(value => ({\n key: headerKey,\n value: value,\n }));\n\n acc[headerKey].push(...headersArray);\n\n return acc;\n }, {} as CloudFrontHeaders);\n }\n\n /**\n * Returns the information if we should remove the response header\n *\n * @param headerKey - The header that will be tested\n */\n protected shouldStripHeader(headerKey: string): boolean {\n if (this.options?.shouldStripHeader)\n return this.options.shouldStripHeader(headerKey);\n\n const headerKeyLowerCase = headerKey.toLowerCase();\n\n for (const stripHeaderIf of this.cachedDisallowedHeaders) {\n if (!stripHeaderIf.test(headerKeyLowerCase)) continue;\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Determines whether the event is from origin or is from viewer.\n *\n * @param content - The event sent by AWS or the response sent by the framework\n */\n protected isEventTypeOrigin(content: CloudFrontEvent['config']): boolean {\n return content.eventType.includes('origin');\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,4BAAA,CAAA,EAAA,SAAA,4BAAA,CAAA,uCAAA,IAAA,uCAAA,0CAAA,IAAA,0CAAA,0CAAA,IAAA,0CAAA,kBAAA,IAAA,iBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,2BAAA,EAmBA,IAIO,YAAA,QAAA,YAAA,EA+CA,MAAM,uCAA8D,CACzE,aACA,SACA,aACA,qBACA,sBACA,mBACA,UACA,UACA,oBACA,kBACA,qBACA,mBACA,qBACA,UACA,mBACA,oBACA,WACF,EAYa,0CAA4C,KAAO,GAYnD,0CAA4C,KAAO,KA+FzD,MAAM,iBAGb,CAQE,YAA+B,QAAoC,QAApC,KAAA,QAAA,QAC7B,MAAM,qBAAoB,YAAA,wBACxB,QAAK,UAAL,eAAc,kBACd,sCAAA,EAGG,KAAA,wBAA0B,kBAAkB,IAAwB,kBACnE,4BAA4B,OAAe,iBAExC,IAAI,OAAO,IAAI,gBAAgB,IAAK,KAAK,CACjD,CACH,CAkBO,gBAAyB,CAC9B,OAAO,kBAAkB,IAC3B,CAKO,UAAU,MAAiD,cAChE,MAAM,gBAAkB,MAExB,GAAI,CAAC,MAAM,QAAQ,6CAAiB,OAAO,EAAU,MAAA,GAErD,MAAM,WAAY,2BAAgB,QAAQ,CAAC,IAAzB,eAA4B,KAA5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,cAAc,KAAK,kBAAkB,EAEnC,MAAA,GAGF,MAAA,EACT,CAOU,kBAAkB,QAA6C,CAChE,OAAA,QAAQ,UAAU,SAAS,QAAQ,CAC5C,CAGF"}
@@ -1,131 +0,0 @@
1
- import type { CloudFrontRequest, Context } from 'aws-lambda';
2
- import type { CloudFrontHeaders, CloudFrontResultResponse } from 'aws-lambda/common/cloudfront';
3
- import type { CloudFrontRequestEvent, CloudFrontRequestResult } from 'aws-lambda/trigger/cloudfront-request';
4
- import { BothValueHeaders, SingleValueHeaders } from '../../@types';
5
- import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
6
- import { StripBasePathFn } from '../../core';
7
- /**
8
- * The options to customize the {@link RequestLambdaEdgeAdapter}.
9
- *
10
- * @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter
11
- * @public
12
- */
13
- export interface RequestLambdaEdgeAdapterOptions {
14
- /**
15
- * Strip base path for custom paths, like `/api`.
16
- *
17
- * @defaultValue ''
18
- */
19
- stripBasePath?: string;
20
- /**
21
- * The max response size in bytes of viewer request and viewer response.
22
- *
23
- * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
24
- *
25
- * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}
26
- */
27
- viewerMaxResponseSizeInBytes?: number;
28
- /**
29
- * The max response size in bytes of origin request and origin response.
30
- *
31
- * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
32
- *
33
- * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}
34
- */
35
- originMaxResponseSizeInBytes?: number;
36
- /**
37
- * The function called when the response size exceed the max limits of the Lambda\@edge
38
- *
39
- * @param response - The response from framework that exceed the limit of Lambda\@edge
40
- * @defaultValue undefined
41
- */
42
- onResponseSizeExceedLimit?: (response: CloudFrontRequestResult) => CloudFrontRequestResult;
43
- /**
44
- * The headers that will be stripped from the headers object because Lambda\@edge will fail if these headers are passed in the response.
45
- *
46
- * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)
47
- *
48
- * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.
49
- */
50
- disallowedHeaders?: (string | RegExp)[];
51
- /**
52
- * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.
53
- *
54
- * @param header - The header of the response
55
- * @defaultValue The default method is implemented to test the header against the list {@link RequestLambdaEdgeAdapterOptions.disallowedHeaders}.
56
- */
57
- shouldStripHeader?: (header: string) => boolean;
58
- }
59
- /**
60
- * The adapter to handle requests from AWS Lambda\@Edge of the type Viewer Request.
61
- *
62
- * The idea of this Adapter is to you be able to expose your framework to the Edge, like when you build for Cloudfront.
63
- *
64
- * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}
65
- * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}
66
- *
67
- * @example
68
- * ```typescript
69
- * const stripBasePath = '/api'; // in case you have configure the cloudfront to forward the path /api to your lambda
70
- * const adapter = new RequestLambdaEdgeAdapter({ stripBasePath });
71
- * ```
72
- *
73
- * @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter
74
- * @public
75
- */
76
- export declare class RequestLambdaEdgeAdapter implements AdapterContract<CloudFrontRequestEvent, Context, CloudFrontResultResponse> {
77
- protected readonly options?: RequestLambdaEdgeAdapterOptions | undefined;
78
- /**
79
- * Default constructor
80
- *
81
- * @param options - The options to customize the {@link RequestLambdaEdgeAdapter}
82
- */
83
- constructor(options?: RequestLambdaEdgeAdapterOptions | undefined);
84
- /**
85
- * Strip base path function
86
- */
87
- protected readonly stripPathFn: StripBasePathFn;
88
- /**
89
- * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.
90
- */
91
- protected readonly cachedDisallowedHeaders: RegExp[];
92
- /**
93
- * {@inheritDoc}
94
- */
95
- getAdapterName(): string;
96
- /**
97
- * {@inheritDoc}
98
- */
99
- canHandle(event: unknown): event is CloudFrontRequestEvent;
100
- /**
101
- * {@inheritDoc}
102
- */
103
- getRequest(event: CloudFrontRequestEvent): AdapterRequest;
104
- /**
105
- * {@inheritDoc}
106
- */
107
- getResponse({ body, headers: frameworkHeaders, isBase64Encoded, statusCode, log, event, }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontResultResponse;
108
- /**
109
- * {@inheritDoc}
110
- */
111
- onErrorWhileForwarding({ error, delegatedResolver, respondWithErrors, log, event, }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void;
112
- /**
113
- * Returns the headers with the flattened (non-list) values of the cloudfront request headers
114
- *
115
- * @param cloudFrontRequest - The cloudfront request
116
- */
117
- protected getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest: CloudFrontRequest): SingleValueHeaders;
118
- /**
119
- * Returns headers in Cloudfront Response format.
120
- *
121
- * @param originalHeaders - The original version of the request sent by the framework
122
- */
123
- protected getHeadersForCloudfrontResponse(originalHeaders: BothValueHeaders): CloudFrontHeaders;
124
- /**
125
- * Returns the information if we should remove the response header
126
- *
127
- * @param headerKey - The header that will be tested
128
- */
129
- protected shouldStripHeader(headerKey: string): boolean;
130
- }
131
- //# sourceMappingURL=request-lambda-edge.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-lambda-edge.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/request-lambda-edge.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,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GAAG,cAAc;IA0ChE;;OAEG;IACI,WAAW,CAAC,EACjB,IAAI,EACJ,OAAO,EAAE,gBAAgB,EACzB,eAAe,EACf,UAAU,EACV,GAAG,EACH,KAAK,GACN,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,GAAG,wBAAwB;IAqC7E;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,GAAG,EACH,KAAK,GACN,EAAE,YAAY,CAAC,sBAAsB,EAAE,uBAAuB,CAAC,GAAG,IAAI;IAkBvE;;;;OAIG;IACH,SAAS,CAAC,wCAAwC,CAChD,iBAAiB,EAAE,iBAAiB,GACnC,kBAAkB;IAWrB;;;;OAIG;IACH,SAAS,CAAC,+BAA+B,CACvC,eAAe,EAAE,gBAAgB,GAChC,iBAAiB;IA8BpB;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAgBxD"}
@@ -1,2 +0,0 @@
1
- "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),request_lambda_edge_adapter_exports={};__export(request_lambda_edge_adapter_exports,{RequestLambdaEdgeAdapter:()=>RequestLambdaEdgeAdapter});module.exports=__toCommonJS(request_lambda_edge_adapter_exports);var import_core=require("../../core"),import_lambda_edge=require("./lambda-edge.adapter");class RequestLambdaEdgeAdapter{constructor(options){var _a,_b;this.options=options,this.stripPathFn=(0,import_core.buildStripBasePath)((_a=this.options)==null?void 0:_a.stripBasePath);const disallowedHeaders=(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.disallowedHeaders,import_lambda_edge.DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS);this.cachedDisallowedHeaders=disallowedHeaders.map(disallowedHeader=>disallowedHeader instanceof RegExp?disallowedHeader:new RegExp(`(${disallowedHeader})`,"gim"))}getAdapterName(){return RequestLambdaEdgeAdapter.name}canHandle(event){var _a,_b,_c;const lambdaEdgeEvent=event;if(!Array.isArray(lambdaEdgeEvent==null?void 0:lambdaEdgeEvent.Records))return!1;const eventType=(_c=(_b=(_a=lambdaEdgeEvent.Records[0])==null?void 0:_a.cf)==null?void 0:_b.config)==null?void 0:_c.eventType;return eventType==="viewer-request"||eventType==="origin-request"}getRequest(event){const cloudFrontRequest=event.Records[0].cf.request,method=cloudFrontRequest.method,path=this.stripPathFn((0,import_core.getPathWithQueryStringParams)(cloudFrontRequest.uri,cloudFrontRequest.querystring)),remoteAddress=cloudFrontRequest.clientIp,headers=this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);let body;if(cloudFrontRequest.body){const[buffer,contentLength]=(0,import_core.getEventBodyAsBuffer)(cloudFrontRequest.body.data,cloudFrontRequest.body.encoding==="base64");body=buffer,headers["content-length"]=contentLength.toString()}const{host}=headers;return{method,path,headers,body,remoteAddress,host,hostname:host}}getResponse({body,headers:frameworkHeaders,isBase64Encoded,statusCode,log,event}){var _a,_b,_c;const headers=this.getHeadersForCloudfrontResponse(frameworkHeaders),maxSizeInBytes=event.Records[0].cf.config.eventType==="origin-request"?(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.originMaxResponseSizeInBytes,import_lambda_edge.DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES):(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.viewerMaxResponseSizeInBytes,import_lambda_edge.DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES),response={body,status:statusCode.toString(),bodyEncoding:isBase64Encoded?"base64":"text",headers},bodyLength=body.length;return bodyLength<=maxSizeInBytes||((_c=this.options)!=null&&_c.onResponseSizeExceedLimit?this.options.onResponseSizeExceedLimit(response):log.error(`SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${bodyLength} of the max of ${maxSizeInBytes}.`)),response}onErrorWhileForwarding({error,delegatedResolver,respondWithErrors,log,event}){const body=respondWithErrors?error.stack:"",errorResponse=this.getResponse({event,statusCode:500,body:body||"",headers:{},isBase64Encoded:!1,log});delegatedResolver.succeed(errorResponse)}getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest){return Object.keys(cloudFrontRequest.headers).reduce((acc,headerKey)=>{const headerValue=cloudFrontRequest.headers[headerKey];return headerValue.length===1?acc[headerKey]=headerValue[0].value:acc[headerKey]=headerValue.map(header=>header.value).join(","),acc},{})}getHeadersForCloudfrontResponse(originalHeaders){return Object.keys(originalHeaders).reduce((acc,headerKey)=>{if(this.shouldStripHeader(headerKey))return acc;const lowercaseHeaderKey=headerKey.toLowerCase();acc[lowercaseHeaderKey]||(acc[lowercaseHeaderKey]=[]);const headerValue=originalHeaders[headerKey];if(!Array.isArray(headerValue))return acc[lowercaseHeaderKey].push({key:headerKey,value:headerValue||""}),acc;const headersArray=headerValue.map(value=>({key:headerKey,value}));return acc[lowercaseHeaderKey].push(...headersArray),acc},{})}shouldStripHeader(headerKey){var _a;if((_a=this.options)!=null&&_a.shouldStripHeader)return this.options.shouldStripHeader(headerKey);const headerKeyLowerCase=headerKey.toLowerCase();for(const stripHeaderIf of this.cachedDisallowedHeaders)if(stripHeaderIf.test(headerKeyLowerCase))return!0;return!1}}
2
- //# sourceMappingURL=request-lambda-edge.adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request-lambda-edge.adapter.js","sources":["../../../src/adapters/aws/request-lambda-edge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { CloudFrontRequest, Context } from 'aws-lambda';\nimport type {\n CloudFrontHeaders,\n CloudFrontResultResponse,\n} from 'aws-lambda/common/cloudfront';\nimport type {\n CloudFrontRequestEvent,\n CloudFrontRequestResult,\n} from 'aws-lambda/trigger/cloudfront-request';\nimport { BothValueHeaders, SingleValueHeaders } from '../../@types';\nimport {\n AdapterContract,\n AdapterRequest,\n GetResponseAdapterProps,\n OnErrorProps,\n} from '../../contracts';\nimport {\n StripBasePathFn,\n buildStripBasePath,\n getDefaultIfUndefined,\n getEventBodyAsBuffer,\n getPathWithQueryStringParams,\n} from '../../core';\nimport {\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n} from './lambda-edge.adapter';\n\n//#endregion\n\n//#endregion\n\n/**\n * The options to customize the {@link RequestLambdaEdgeAdapter}.\n *\n * @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter\n * @public\n */\nexport interface RequestLambdaEdgeAdapterOptions {\n /**\n * Strip base path for custom paths, like `/api`.\n *\n * @defaultValue ''\n */\n stripBasePath?: string;\n\n /**\n * The max response size in bytes of viewer request and viewer response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n viewerMaxResponseSizeInBytes?: number;\n\n /**\n * The max response size in bytes of origin request and origin response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n originMaxResponseSizeInBytes?: number;\n\n /**\n * The function called when the response size exceed the max limits of the Lambda\\@edge\n *\n * @param response - The response from framework that exceed the limit of Lambda\\@edge\n * @defaultValue undefined\n */\n onResponseSizeExceedLimit?: (\n response: CloudFrontRequestResult,\n ) => CloudFrontRequestResult;\n\n /**\n * The headers that will be stripped from the headers object because Lambda\\@edge will fail if these headers are passed in the response.\n *\n * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)\n *\n * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.\n */\n disallowedHeaders?: (string | RegExp)[];\n\n /**\n * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.\n *\n * @param header - The header of the response\n * @defaultValue The default method is implemented to test the header against the list {@link RequestLambdaEdgeAdapterOptions.disallowedHeaders}.\n */\n shouldStripHeader?: (header: string) => boolean;\n}\n\n/**\n * The adapter to handle requests from AWS Lambda\\@Edge of the type Viewer Request.\n *\n * The idea of this Adapter is to you be able to expose your framework to the Edge, like when you build for Cloudfront.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}\n *\n * @example\n * ```typescript\n * const stripBasePath = '/api'; // in case you have configure the cloudfront to forward the path /api to your lambda\n * const adapter = new RequestLambdaEdgeAdapter({ stripBasePath });\n * ```\n *\n * @breadcrumb Adapters / AWS / RequestLambdaEdgeAdapter\n * @public\n */\nexport class RequestLambdaEdgeAdapter\n implements\n AdapterContract<CloudFrontRequestEvent, Context, CloudFrontResultResponse>\n{\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link RequestLambdaEdgeAdapter}\n */\n constructor(protected readonly options?: RequestLambdaEdgeAdapterOptions) {\n this.stripPathFn = buildStripBasePath(this.options?.stripBasePath);\n\n const disallowedHeaders = getDefaultIfUndefined(\n this.options?.disallowedHeaders,\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n );\n\n this.cachedDisallowedHeaders = disallowedHeaders.map(disallowedHeader => {\n if (disallowedHeader instanceof RegExp) return disallowedHeader;\n\n return new RegExp(`(${disallowedHeader})`, 'gim');\n });\n }\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * Strip base path function\n */\n protected readonly stripPathFn: StripBasePathFn;\n\n /**\n * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.\n */\n protected readonly cachedDisallowedHeaders: RegExp[];\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return RequestLambdaEdgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is CloudFrontRequestEvent {\n const lambdaEdgeEvent = event as Partial<CloudFrontRequestEvent>;\n\n if (!Array.isArray(lambdaEdgeEvent?.Records)) return false;\n\n const eventType = lambdaEdgeEvent.Records[0]?.cf?.config?.eventType;\n\n return eventType === 'viewer-request' || eventType === 'origin-request';\n }\n\n /**\n * {@inheritDoc}\n */\n public getRequest(event: CloudFrontRequestEvent): AdapterRequest {\n const request = event.Records[0];\n const cloudFrontRequest = request.cf.request;\n\n const method = cloudFrontRequest.method;\n\n const path = this.stripPathFn(\n getPathWithQueryStringParams(\n cloudFrontRequest.uri,\n cloudFrontRequest.querystring,\n ),\n );\n const remoteAddress = cloudFrontRequest.clientIp;\n\n const headers =\n this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);\n\n let body: Buffer | undefined;\n\n if (cloudFrontRequest.body) {\n const [buffer, contentLength] = getEventBodyAsBuffer(\n cloudFrontRequest.body.data,\n cloudFrontRequest.body.encoding === 'base64',\n );\n\n body = buffer;\n headers['content-length'] = contentLength.toString();\n }\n\n const { host } = headers;\n\n return {\n method,\n path,\n headers,\n body,\n remoteAddress,\n host,\n hostname: host,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public getResponse({\n body,\n headers: frameworkHeaders,\n isBase64Encoded,\n statusCode,\n log,\n event,\n }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontResultResponse {\n const headers = this.getHeadersForCloudfrontResponse(frameworkHeaders);\n\n const maxSizeInBytes =\n event.Records[0].cf.config.eventType === 'origin-request'\n ? getDefaultIfUndefined(\n this.options?.originMaxResponseSizeInBytes,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n )\n : getDefaultIfUndefined(\n this.options?.viewerMaxResponseSizeInBytes,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n );\n\n const response: CloudFrontResultResponse = {\n body,\n status: statusCode.toString(),\n bodyEncoding: isBase64Encoded ? 'base64' : 'text',\n headers,\n };\n\n // probably is not correctly accurate, but it's a good approximation\n const bodyLength = body.length;\n\n if (bodyLength <= maxSizeInBytes) return response;\n\n if (this.options?.onResponseSizeExceedLimit)\n this.options.onResponseSizeExceedLimit(response);\n else {\n log.error(\n `SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${bodyLength} of the max of ${maxSizeInBytes}.`,\n );\n }\n\n return response;\n }\n\n /**\n * {@inheritDoc}\n */\n public onErrorWhileForwarding({\n error,\n delegatedResolver,\n respondWithErrors,\n log,\n event,\n }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void {\n const body = respondWithErrors ? error.stack : '';\n const errorResponse = this.getResponse({\n event,\n statusCode: 500,\n body: body || '',\n headers: {},\n isBase64Encoded: false,\n log,\n });\n\n delegatedResolver.succeed(errorResponse);\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Returns the headers with the flattened (non-list) values of the cloudfront request headers\n *\n * @param cloudFrontRequest - The cloudfront request\n */\n protected getFlattenedHeadersFromCloudfrontRequest(\n cloudFrontRequest: CloudFrontRequest,\n ): SingleValueHeaders {\n return Object.keys(cloudFrontRequest.headers).reduce((acc, headerKey) => {\n const headerValue = cloudFrontRequest.headers[headerKey];\n\n if (headerValue.length === 1) acc[headerKey] = headerValue[0].value;\n else acc[headerKey] = headerValue.map(header => header.value).join(',');\n\n return acc;\n }, {} as SingleValueHeaders);\n }\n\n /**\n * Returns headers in Cloudfront Response format.\n *\n * @param originalHeaders - The original version of the request sent by the framework\n */\n protected getHeadersForCloudfrontResponse(\n originalHeaders: BothValueHeaders,\n ): CloudFrontHeaders {\n return Object.keys(originalHeaders).reduce((acc, headerKey) => {\n if (this.shouldStripHeader(headerKey)) return acc;\n\n const lowercaseHeaderKey = headerKey.toLowerCase();\n\n if (!acc[lowercaseHeaderKey]) acc[lowercaseHeaderKey] = [];\n\n const headerValue = originalHeaders[headerKey];\n\n if (!Array.isArray(headerValue)) {\n acc[lowercaseHeaderKey].push({\n key: headerKey,\n value: headerValue || '',\n });\n\n return acc;\n }\n\n const headersArray = headerValue.map(value => ({\n key: headerKey,\n value: value,\n }));\n\n acc[lowercaseHeaderKey].push(...headersArray);\n\n return acc;\n }, {} as CloudFrontHeaders);\n }\n\n /**\n * Returns the information if we should remove the response header\n *\n * @param headerKey - The header that will be tested\n */\n protected shouldStripHeader(headerKey: string): boolean {\n if (this.options?.shouldStripHeader)\n return this.options.shouldStripHeader(headerKey);\n\n const headerKeyLowerCase = headerKey.toLowerCase();\n\n for (const stripHeaderIf of this.cachedDisallowedHeaders) {\n if (!stripHeaderIf.test(headerKeyLowerCase)) continue;\n\n return true;\n }\n\n return false;\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,oCAAA,CAAA,EAAA,SAAA,oCAAA,CAAA,yBAAA,IAAA,wBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,mCAAA,EAkBA,IAMO,YAAA,QAAA,YAAA,EAKA,mBAAA,QAAA,uBAAA,EAmFA,MAAM,wBAGb,CAQE,YAA+B,QAA2C,WAA3C,KAAA,QAAA,QAC7B,KAAK,eAAc,YAAA,qBAAmB,QAAK,UAAL,eAAc,aAAa,EAEjE,MAAM,qBAAoB,YAAA,wBACxB,QAAK,UAAL,eAAc,kBACd,mBAA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AA4B,QACtD,IAAI,QAAK,UAAL,SAAc,kBACT,OAAA,KAAK,QAAQ,kBAAkB,SAAS,EAE3C,MAAA,mBAAqB,UAAU,cAE1B,UAAA,iBAAiB,KAAK,wBAC3B,GAAC,cAAc,KAAK,kBAAkB,EAEnC,MAAA,GAGF,MAAA,EACT,CAGF"}
@@ -1,56 +0,0 @@
1
- import type { S3Event } from 'aws-lambda';
2
- import { AwsSimpleAdapter } from './base/index';
3
- /**
4
- * The options to customize the {@link S3Adapter}
5
- *
6
- * @breadcrumb Adapters / AWS / S3Adapter
7
- * @public
8
- */
9
- export interface S3AdapterOptions {
10
- /**
11
- * The path that will be used to create a request to be forwarded to the framework.
12
- *
13
- * @defaultValue /s3
14
- */
15
- s3ForwardPath?: string;
16
- /**
17
- * The http method that will be used to create a request to be forwarded to the framework.
18
- *
19
- * @defaultValue POST
20
- */
21
- s3ForwardMethod?: string;
22
- }
23
- /**
24
- * The adapter to handle requests from AWS S3.
25
- *
26
- * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
27
- *
28
- * {@link https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html | Event Reference}
29
- *
30
- * @example
31
- * ```typescript
32
- * const s3ForwardPath = '/your/route/s3'; // default /s3
33
- * const s3ForwardMethod = 'POST'; // default POST
34
- * const adapter = new S3Adapter({ s3ForwardPath, s3ForwardMethod });
35
- * ```
36
- *
37
- * @breadcrumb Adapters / AWS / S3Adapter
38
- * @public
39
- */
40
- export declare class S3Adapter extends AwsSimpleAdapter<S3Event> {
41
- /**
42
- * Default constructor
43
- *
44
- * @param options - The options to customize the {@link SNSAdapter}
45
- */
46
- constructor(options?: S3AdapterOptions);
47
- /**
48
- * {@inheritDoc}
49
- */
50
- getAdapterName(): string;
51
- /**
52
- * {@inheritDoc}
53
- */
54
- canHandle(event: unknown): event is S3Event;
55
- }
56
- //# sourceMappingURL=s3.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"s3.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/s3.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAU,SAAQ,gBAAgB,CAAC,OAAO,CAAC;IAGtD;;;;OAIG;gBACS,OAAO,CAAC,EAAE,gBAAgB;IAatC;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO;CAWnD"}
@@ -1,2 +0,0 @@
1
- "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),s3_adapter_exports={};__export(s3_adapter_exports,{S3Adapter:()=>S3Adapter});module.exports=__toCommonJS(s3_adapter_exports);var import_core=require("../../core"),import_base=require("./base/index");class S3Adapter extends import_base.AwsSimpleAdapter{constructor(options){super({forwardPath:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.s3ForwardPath,"/s3"),forwardMethod:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.s3ForwardMethod,"POST"),batch:!1,host:"s3.amazonaws.com"})}getAdapterName(){return S3Adapter.name}canHandle(event){var _a;const s3Event=event;return Array.isArray(s3Event==null?void 0:s3Event.Records)?((_a=s3Event.Records[0])==null?void 0:_a.eventSource)==="aws:s3":!1}}
2
- //# sourceMappingURL=s3.adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"s3.adapter.js","sources":["../../../src/adapters/aws/s3.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { S3Event } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link S3Adapter}\n *\n * @breadcrumb Adapters / AWS / S3Adapter\n * @public\n */\nexport interface S3AdapterOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /s3\n */\n s3ForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n s3ForwardMethod?: string;\n}\n\n/**\n * The adapter to handle requests from AWS S3.\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html | Event Reference}\n *\n * @example\n * ```typescript\n * const s3ForwardPath = '/your/route/s3'; // default /s3\n * const s3ForwardMethod = 'POST'; // default POST\n * const adapter = new S3Adapter({ s3ForwardPath, s3ForwardMethod });\n * ```\n *\n * @breadcrumb Adapters / AWS / S3Adapter\n * @public\n */\nexport class S3Adapter extends AwsSimpleAdapter<S3Event> {\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link SNSAdapter}\n */\n constructor(options?: S3AdapterOptions) {\n super({\n forwardPath: getDefaultIfUndefined(options?.s3ForwardPath, '/s3'),\n forwardMethod: getDefaultIfUndefined(options?.s3ForwardMethod, 'POST'),\n batch: false,\n host: 's3.amazonaws.com',\n });\n }\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return S3Adapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is S3Event {\n const s3Event = event as Partial<S3Event>;\n\n if (!Array.isArray(s3Event?.Records)) return false;\n\n const eventSource = s3Event.Records[0]?.eventSource;\n\n return eventSource === 'aws:s3';\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,mBAAA,CAAA,EAAA,SAAA,mBAAA,CAAA,UAAA,IAAA,SAAA,CAAA,EAAA,OAAA,QAAA,aAAA,kBAAA,EAGA,IAAsC,YAAA,QAAA,YAAA,EACL,YAAA,QAAA,cAAA,EA2C1B,MAAM,kBAAkB,YAA0B,gBAAA,CAQvD,YAAY,QAA4B,CAChC,MAAA,CACJ,eAAa,YAAA,uBAAsB,6BAAS,cAAe,KAAK,EAChE,iBAAe,YAAA,uBAAsB,6BAAS,gBAAiB,MAAM,EACrE,MAAO,GACP,KAAM,kBAAA,CACP,CACH,CASO,gBAAyB,CAC9B,OAAO,UAAU,IACnB,CAKO,UAAU,MAAkC,QACjD,MAAM,QAAU,MAEhB,OAAK,MAAM,QAAQ,6BAAS,OAAO,IAEf,WAAQ,QAAQ,CAAC,IAAjB,eAAoB,eAEjB,SAJsB,EAK/C,CAGF"}
@@ -1,56 +0,0 @@
1
- import type { SNSEvent } from 'aws-lambda';
2
- import { AwsSimpleAdapter } from './base/index';
3
- /**
4
- * The options to customize the {@link SNSAdapter}
5
- *
6
- * @breadcrumb Adapters / AWS / SNSAdapter
7
- * @public
8
- */
9
- export interface SNSAdapterOptions {
10
- /**
11
- * The path that will be used to create a request to be forwarded to the framework.
12
- *
13
- * @defaultValue /sns
14
- */
15
- snsForwardPath?: string;
16
- /**
17
- * The http method that will be used to create a request to be forwarded to the framework.
18
- *
19
- * @defaultValue POST
20
- */
21
- snsForwardMethod?: string;
22
- }
23
- /**
24
- * The adapter to handle requests from AWS SNS.
25
- *
26
- * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
27
- *
28
- * {@link https://docs.aws.amazon.com/lambda/latest/dg/with-sns.html | Event Reference}
29
- *
30
- * @example
31
- * ```typescript
32
- * const snsForwardPath = '/your/route/sns'; // default /sns
33
- * const snsForwardMethod = 'POST'; // default POST
34
- * const adapter = new SNSAdapter({ snsForwardPath, snsForwardMethod });
35
- * ```
36
- *
37
- * @breadcrumb Adapters / AWS / SNSAdapter
38
- * @public
39
- */
40
- export declare class SNSAdapter extends AwsSimpleAdapter<SNSEvent> {
41
- /**
42
- * Default constructor
43
- *
44
- * @param options - The options to customize the {@link SNSAdapter}
45
- */
46
- constructor(options?: SNSAdapterOptions);
47
- /**
48
- * {@inheritDoc}
49
- */
50
- getAdapterName(): string;
51
- /**
52
- * {@inheritDoc}
53
- */
54
- canHandle(event: unknown): event is SNSEvent;
55
- }
56
- //# sourceMappingURL=sns.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sns.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/sns.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,UAAW,SAAQ,gBAAgB,CAAC,QAAQ,CAAC;IAGxD;;;;OAIG;gBACS,OAAO,CAAC,EAAE,iBAAiB;IAavC;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ;CAWpD"}
@@ -1,2 +0,0 @@
1
- "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),sns_adapter_exports={};__export(sns_adapter_exports,{SNSAdapter:()=>SNSAdapter});module.exports=__toCommonJS(sns_adapter_exports);var import_core=require("../../core"),import_base=require("./base/index");class SNSAdapter extends import_base.AwsSimpleAdapter{constructor(options){super({forwardPath:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.snsForwardPath,"/sns"),forwardMethod:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.snsForwardMethod,"POST"),batch:!1,host:"sns.amazonaws.com"})}getAdapterName(){return SNSAdapter.name}canHandle(event){var _a;const snsEvent=event;return Array.isArray(snsEvent==null?void 0:snsEvent.Records)?((_a=snsEvent.Records[0])==null?void 0:_a.EventSource)==="aws:sns":!1}}
2
- //# sourceMappingURL=sns.adapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sns.adapter.js","sources":["../../../src/adapters/aws/sns.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { SNSEvent } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link SNSAdapter}\n *\n * @breadcrumb Adapters / AWS / SNSAdapter\n * @public\n */\nexport interface SNSAdapterOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /sns\n */\n snsForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n snsForwardMethod?: string;\n}\n\n/**\n * The adapter to handle requests from AWS SNS.\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/with-sns.html | Event Reference}\n *\n * @example\n * ```typescript\n * const snsForwardPath = '/your/route/sns'; // default /sns\n * const snsForwardMethod = 'POST'; // default POST\n * const adapter = new SNSAdapter({ snsForwardPath, snsForwardMethod });\n * ```\n *\n * @breadcrumb Adapters / AWS / SNSAdapter\n * @public\n */\nexport class SNSAdapter extends AwsSimpleAdapter<SNSEvent> {\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link SNSAdapter}\n */\n constructor(options?: SNSAdapterOptions) {\n super({\n forwardPath: getDefaultIfUndefined(options?.snsForwardPath, '/sns'),\n forwardMethod: getDefaultIfUndefined(options?.snsForwardMethod, 'POST'),\n batch: false,\n host: 'sns.amazonaws.com',\n });\n }\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return SNSAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is SNSEvent {\n const snsEvent = event as Partial<SNSEvent>;\n\n if (!Array.isArray(snsEvent?.Records)) return false;\n\n const eventSource = snsEvent.Records[0]?.EventSource;\n\n return eventSource === 'aws:sns';\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,oBAAA,CAAA,EAAA,SAAA,oBAAA,CAAA,WAAA,IAAA,UAAA,CAAA,EAAA,OAAA,QAAA,aAAA,mBAAA,EAGA,IAAsC,YAAA,QAAA,YAAA,EACL,YAAA,QAAA,cAAA,EA2C1B,MAAM,mBAAmB,YAA2B,gBAAA,CAQzD,YAAY,QAA6B,CACjC,MAAA,CACJ,eAAa,YAAA,uBAAsB,6BAAS,eAAgB,MAAM,EAClE,iBAAe,YAAA,uBAAsB,6BAAS,iBAAkB,MAAM,EACtE,MAAO,GACP,KAAM,mBAAA,CACP,CACH,CASO,gBAAyB,CAC9B,OAAO,WAAW,IACpB,CAKO,UAAU,MAAmC,QAClD,MAAM,SAAW,MAEjB,OAAK,MAAM,QAAQ,+BAAU,OAAO,IAEhB,YAAS,QAAQ,CAAC,IAAlB,eAAqB,eAElB,UAJuB,EAKhD,CAGF"}