@h4ad/serverless-adapter 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) 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 +6 -0
  4. package/lib/adapters/apollo-server/index.cjs.map +1 -0
  5. package/lib/adapters/apollo-server/index.d.cts +61 -0
  6. package/lib/adapters/apollo-server/index.d.ts +61 -0
  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 +6 -0
  10. package/lib/adapters/aws/index.cjs.map +1 -0
  11. package/lib/adapters/aws/index.d.cts +928 -0
  12. package/lib/adapters/aws/index.d.ts +928 -0
  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 +6 -0
  16. package/lib/adapters/azure/index.cjs.map +1 -0
  17. package/lib/adapters/azure/index.d.cts +86 -0
  18. package/lib/adapters/azure/index.d.ts +86 -0
  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 +6 -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 -0
  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 +6 -0
  28. package/lib/adapters/dummy/index.cjs.map +1 -0
  29. package/lib/adapters/dummy/index.d.cts +37 -0
  30. package/lib/adapters/dummy/index.d.ts +37 -0
  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 +6 -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 -0
  37. package/lib/adapters/huawei/index.mjs +2 -0
  38. package/lib/adapters/huawei/index.mjs.map +1 -0
  39. package/lib/base-handler-fYEk59Xq.d.ts +35 -0
  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-57ZKWTH4.mjs +2 -0
  44. package/lib/chunk-57ZKWTH4.mjs.map +1 -0
  45. package/lib/chunk-OYOJMOFP.mjs +2 -0
  46. package/lib/chunk-OYOJMOFP.mjs.map +1 -0
  47. package/lib/chunk-PQDB5AVF.mjs +12 -0
  48. package/lib/chunk-PQDB5AVF.mjs.map +1 -0
  49. package/lib/chunk-VPGUOREQ.mjs +2 -0
  50. package/lib/chunk-VPGUOREQ.mjs.map +1 -0
  51. package/lib/constants-0cgQlFSV.d.cts +32 -0
  52. package/lib/constants-0cgQlFSV.d.ts +32 -0
  53. package/lib/framework.contract-YnJ-fl1w.d.cts +20 -0
  54. package/lib/framework.contract-YnJ-fl1w.d.ts +20 -0
  55. package/lib/frameworks/apollo-server/index.cjs +6 -0
  56. package/lib/frameworks/apollo-server/index.cjs.map +1 -0
  57. package/lib/frameworks/apollo-server/index.d.cts +72 -0
  58. package/lib/frameworks/apollo-server/index.d.ts +72 -0
  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 +6 -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 -0
  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 +7 -0
  68. package/lib/frameworks/cors/index.cjs.map +1 -0
  69. package/lib/frameworks/cors/index.d.cts +79 -0
  70. package/lib/frameworks/cors/index.d.ts +79 -0
  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 +6 -0
  74. package/lib/frameworks/deepkit/index.cjs.map +1 -0
  75. package/lib/frameworks/deepkit/index.d.cts +21 -0
  76. package/lib/frameworks/deepkit/index.d.ts +21 -0
  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/index.d.cts +18 -0
  82. package/lib/frameworks/express/index.d.ts +18 -0
  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/index.d.cts +18 -0
  88. package/lib/frameworks/fastify/index.d.ts +18 -0
  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/index.d.cts +18 -0
  94. package/lib/frameworks/hapi/index.d.ts +18 -0
  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/index.d.cts +18 -0
  100. package/lib/frameworks/koa/index.d.ts +18 -0
  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 +6 -0
  104. package/lib/frameworks/lazy/index.cjs.map +1 -0
  105. package/lib/frameworks/lazy/index.d.cts +57 -0
  106. package/lib/frameworks/lazy/index.d.ts +57 -0
  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 +6 -0
  110. package/lib/frameworks/trpc/index.cjs.map +1 -0
  111. package/lib/frameworks/trpc/index.d.cts +154 -0
  112. package/lib/frameworks/trpc/index.d.ts +154 -0
  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 +12 -0
  118. package/lib/handlers/aws/index.cjs.map +1 -0
  119. package/lib/handlers/aws/index.d.cts +96 -0
  120. package/lib/handlers/aws/index.d.ts +96 -0
  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 +6 -0
  124. package/lib/handlers/azure/index.cjs.map +1 -0
  125. package/lib/handlers/azure/index.d.cts +53 -0
  126. package/lib/handlers/azure/index.d.ts +53 -0
  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 +6 -0
  130. package/lib/handlers/default/index.cjs.map +1 -0
  131. package/lib/handlers/default/index.d.cts +95 -0
  132. package/lib/handlers/default/index.d.ts +95 -0
  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 +6 -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 -0
  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 +6 -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 -0
  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 +6 -0
  148. package/lib/handlers/gcp/index.cjs.map +1 -0
  149. package/lib/handlers/gcp/index.d.cts +33 -0
  150. package/lib/handlers/gcp/index.d.ts +33 -0
  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 +6 -0
  154. package/lib/handlers/huawei/index.cjs.map +1 -0
  155. package/lib/handlers/huawei/index.d.cts +62 -0
  156. package/lib/handlers/huawei/index.d.ts +62 -0
  157. package/lib/handlers/huawei/index.mjs +2 -0
  158. package/lib/handlers/huawei/index.mjs.map +1 -0
  159. package/lib/headers-K2qbcurv.d.cts +38 -0
  160. package/lib/headers-K2qbcurv.d.ts +38 -0
  161. package/lib/index.cjs +12 -0
  162. package/lib/index.cjs.map +1 -0
  163. package/lib/index.d.cts +439 -0
  164. package/lib/index.d.ts +439 -0
  165. package/lib/index.mjs +2 -0
  166. package/lib/index.mjs.map +1 -0
  167. package/lib/logger-9me5n48P.d.cts +65 -0
  168. package/lib/logger-9me5n48P.d.ts +65 -0
  169. package/lib/path-yBwCb8C1.d.cts +64 -0
  170. package/lib/path-yBwCb8C1.d.ts +64 -0
  171. package/lib/raw-request-B2vPjAfE.d.cts +32 -0
  172. package/lib/raw-request-b6AYnkxd.d.ts +32 -0
  173. package/lib/request-DNNIV9ub.d.cts +44 -0
  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/index.d.cts +25 -0
  178. package/lib/resolvers/aws-context/index.d.ts +25 -0
  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/index.d.cts +29 -0
  184. package/lib/resolvers/callback/index.d.ts +29 -0
  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 -0
  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 -0
  197. package/lib/resolvers/promise/index.mjs +2 -0
  198. package/lib/resolvers/promise/index.mjs.map +1 -0
  199. package/package.json +1 -1
@@ -0,0 +1,439 @@
1
+ import { B as BinarySettings, H as HandlerContract, S as ServerlessHandler } from './handler.contract-TQk8iM8f.cjs';
2
+ export { b as BinarySettingsContentHeaders, a as BinarySettingsFunction } from './handler.contract-TQk8iM8f.cjs';
3
+ import { B as BothValueHeaders } from './headers-K2qbcurv.cjs';
4
+ export { M as MultiValueHeaders, S as SingleValueHeaders } from './headers-K2qbcurv.cjs';
5
+ export { C as Concrete, S as StripBasePathFn, b as buildStripBasePath, g as getPathWithQueryStringParams, a as getQueryParamsStringFromRecord } from './path-yBwCb8C1.cjs';
6
+ import { A as AdapterContract, R as ResolverContract } from './adapter.contract-y5xSjOjo.cjs';
7
+ export { a as AdapterRequest, D as DelegatedResolver, G as GetResponseAdapterProps, O as OnErrorProps, c as Resolver, b as ResolverProps, S as ServerlessResponse, d as ServerlessResponseProps } from './adapter.contract-y5xSjOjo.cjs';
8
+ import { F as FrameworkContract } from './framework.contract-YnJ-fl1w.cjs';
9
+ export { B as BaseHandler } from './base-handler-peEBoKtZ.cjs';
10
+ export { a as DEFAULT_BINARY_CONTENT_TYPES, D as DEFAULT_BINARY_ENCODINGS, E as EmptyResponse, I as IEmptyResponse } from './constants-0cgQlFSV.cjs';
11
+ import { I as ILogger } from './logger-9me5n48P.cjs';
12
+ export { L as LogLevels, b as LoggerFN, a as LoggerOptions, c as createDefaultLogger, i as isInternalLogger } from './logger-9me5n48P.cjs';
13
+ import { Writable, Readable } from 'node:stream';
14
+ export { S as ServerlessRequest, a as ServerlessRequestProps } from './request-DNNIV9ub.cjs';
15
+ import { ServerResponse } from 'node:http';
16
+ import 'http';
17
+
18
+ /**
19
+ * The properties to create a {@link ServerlessStreamResponse}.
20
+ *
21
+ * @breadcrumb Network / ServerlessStreamResponse
22
+ * @public
23
+ */
24
+ interface ServerlessStreamResponseProps {
25
+ /**
26
+ * The HTTP Method from request
27
+ */
28
+ method?: string;
29
+ /**
30
+ * The callback to receive the headers when they are written to the stream
31
+ * You need to return a writable stream be able to continue writing the response
32
+ *
33
+ * @param statusCode - The status code of the response
34
+ * @param headers - The headers of the response
35
+ */
36
+ onReceiveHeaders: (statusCode: number, headers: BothValueHeaders) => Writable;
37
+ /**
38
+ * Instance of the logger
39
+ */
40
+ log: ILogger;
41
+ }
42
+ /**
43
+ * The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request.
44
+ * This response is specially built to deal with transfer-encoding: chunked
45
+ *
46
+ * @breadcrumb Network / ServerlessStreamResponse
47
+ * @public
48
+ */
49
+ declare class ServerlessStreamResponse extends ServerResponse {
50
+ constructor({ method, onReceiveHeaders, log, }: ServerlessStreamResponseProps);
51
+ }
52
+
53
+ /**
54
+ * Get the data from a buffer, string, or Uint8Array
55
+ *
56
+ * @breadcrumb Network
57
+ * @param data - The data that was written inside the stream
58
+ */
59
+ declare function getString(data: Buffer | string | unknown): string;
60
+
61
+ /**
62
+ * The type that represents the object that handles the references to the event created by the serverless trigger or context created by the serverless environment.
63
+ *
64
+ * @breadcrumb Core / Current Invoke
65
+ * @public
66
+ */
67
+ type CurrentInvoke<TEvent, TContext> = {
68
+ /**
69
+ * The event created by the serverless trigger
70
+ *
71
+ * @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.
72
+ */
73
+ event: TEvent | null;
74
+ /**
75
+ * The context created by the serverless environment
76
+ *
77
+ * @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.
78
+ */
79
+ context: TContext | null;
80
+ };
81
+ /**
82
+ * Get the reference to the event created by the serverless trigger or context created by the serverless environment.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * import type { ALBEvent, Context } from 'aws-lambda';
87
+ *
88
+ * // inside the method that handles the aws alb request.
89
+ * const { event, context } = getCurrentInvoke<ALBEvent, Context>();
90
+ * ```
91
+ *
92
+ * @breadcrumb Core / Current Invoke
93
+ * @public
94
+ */
95
+ declare function getCurrentInvoke<TEvent = any, TContext = any>(): CurrentInvoke<TEvent, TContext>;
96
+ /**
97
+ * Method that saves to the event created by the serverless trigger or context created by the serverless environment.
98
+ *
99
+ * @remarks This method MUST NOT be called by you, this method MUST only be used internally in this library.
100
+ *
101
+ * @param event - The event created by the serverless trigger
102
+ * @param context - The context created by the serverless environment
103
+ *
104
+ * @breadcrumb Core / Current Invoke
105
+ * @public
106
+ */
107
+ declare function setCurrentInvoke<TEvent = any, TContext = any>({ event, context, }: CurrentInvoke<TEvent, TContext>): void;
108
+
109
+ /**
110
+ * Get the event body as buffer from body string with content length
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const body = '{}';
115
+ * const [buffer, contentLength] = getEventBodyAsBuffer(body, false);
116
+ * console.log(buffer);
117
+ * // <Buffer 7b 7d>
118
+ * console.log(contentLength);
119
+ * // 2
120
+ * ```
121
+ *
122
+ * @param body - The body string that can be encoded or not
123
+ * @param isBase64Encoded - Tells if body string is encoded in base64
124
+ *
125
+ * @breadcrumb Core
126
+ * @public
127
+ */
128
+ declare function getEventBodyAsBuffer(body: string, isBase64Encoded: boolean): [body: Buffer, contentLength: number];
129
+
130
+ /**
131
+ * Transform a header map and make sure the value is not an array
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };
136
+ * const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);
137
+ * console.log(flattenedHeaders);
138
+ * // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }
139
+ * ```
140
+ *
141
+ * @param headersMap - The initial headers
142
+ * @param separator - The separator used when we join the array of header's value
143
+ * @param lowerCaseKey - Should put all keys in lowercase
144
+ *
145
+ * @breadcrumb Core / Headers
146
+ * @public
147
+ */
148
+ declare function getFlattenedHeadersMap(headersMap: BothValueHeaders, separator?: string, lowerCaseKey?: boolean): Record<string, string>;
149
+ /**
150
+ * Transforms a header map into a multi-value map header.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };
155
+ * const multiValueHeaders = getMultiValueHeadersMap(headers);
156
+ * console.log(multiValueHeaders);
157
+ * // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }
158
+ * ```
159
+ *
160
+ * @param headersMap - The initial headers
161
+ *
162
+ * @breadcrumb Core / Headers
163
+ * @public
164
+ */
165
+ declare function getMultiValueHeadersMap(headersMap: BothValueHeaders): Record<string, string[]>;
166
+ /**
167
+ * The wrapper that holds the information about single value headers and cookies
168
+ *
169
+ * @breadcrumb Core / Headers
170
+ * @public
171
+ */
172
+ type FlattenedHeadersAndCookies = {
173
+ /**
174
+ * Just the single value headers
175
+ */
176
+ headers: Record<string, string>;
177
+ /**
178
+ * The list of cookies
179
+ */
180
+ cookies: string[];
181
+ };
182
+ /**
183
+ * Transforms a header map into a single value headers and cookies
184
+ *
185
+ * @param headersMap - The initial headers
186
+ *
187
+ * @breadcrumb Core / Headers
188
+ * @public
189
+ */
190
+ declare function getFlattenedHeadersMapAndCookies(headersMap: BothValueHeaders): FlattenedHeadersAndCookies;
191
+ /**
192
+ * Parse HTTP Raw Headers
193
+ * Attribution to {@link https://github.com/kesla/parse-headers/blob/master/parse-headers.js}
194
+ *
195
+ * @param headers - The raw headers
196
+ *
197
+ * @breadcrumb Core / Headers
198
+ * @public
199
+ */
200
+ declare function parseHeaders(headers: string): Record<string, string | string[]>;
201
+
202
+ /**
203
+ * The function that determines by the content encoding whether the response should be treated as binary
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const headers = { 'content-encoding': 'gzip' };
208
+ * const isBinary = isContentEncodingBinary(headers, ['gzip']);
209
+ * console.log(isBinary);
210
+ * // true
211
+ * ```
212
+ *
213
+ * @param headers - The headers of the response
214
+ * @param binaryEncodingTypes - The list of content encodings that will be treated as binary
215
+ *
216
+ * @breadcrumb Core / isBinary
217
+ * @public
218
+ */
219
+ declare function isContentEncodingBinary(headers: BothValueHeaders, binaryEncodingTypes: string[]): boolean;
220
+ /**
221
+ * The function that returns the content type of headers
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * const headers = { 'content-type': 'application/json' };
226
+ * const contentType = getContentType(headers);
227
+ * console.log(contentType);
228
+ * // application/json
229
+ * ```
230
+ *
231
+ * @param headers - The headers of the response
232
+ *
233
+ * @breadcrumb Core / isBinary
234
+ * @public
235
+ */
236
+ declare function getContentType(headers: BothValueHeaders): string;
237
+ /**
238
+ * The function that determines by the content type whether the response should be treated as binary
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * const headers = { 'content-type': 'image/png' };
243
+ * const isBinary = isContentTypeBinary(headers, new Map([['image/png', true]]));
244
+ * console.log(isBinary);
245
+ * // true
246
+ * ```
247
+ *
248
+ * @param headers - The headers of the response
249
+ * @param binaryContentTypes - The list of content types that will be treated as binary
250
+ *
251
+ * @breadcrumb Core / isBinary
252
+ * @public
253
+ */
254
+ declare function isContentTypeBinary(headers: BothValueHeaders, binaryContentTypes: string[]): boolean;
255
+ /**
256
+ * The function used to determine from the headers and the binary settings if a response should be encoded or not
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * const headers = { 'content-type': 'image/png', 'content-encoding': 'gzip' };
261
+ * const isContentBinary = isBinary(headers, { contentEncodings: ['gzip'], contentTypes: ['image/png'] });
262
+ * console.log(isContentBinary);
263
+ * // true
264
+ * ```
265
+ *
266
+ * @param headers - The headers of the response
267
+ * @param binarySettings - The settings for the validation
268
+ *
269
+ * @breadcrumb Core / isBinary
270
+ * @public
271
+ */
272
+ declare function isBinary(headers: BothValueHeaders, binarySettings: BinarySettings): boolean;
273
+
274
+ /**
275
+ * No operation function is used when we need to pass a function, but we don't want to specify any behavior.
276
+ *
277
+ * @breadcrumb Core
278
+ * @public
279
+ */
280
+ declare const NO_OP: (...args: any[]) => any;
281
+
282
+ /**
283
+ * Return the defaultValue whether the value is undefined, otherwise, return the value.
284
+ *
285
+ * @example
286
+ * ```typescript
287
+ * const value1 = getDefaultIfUndefined(undefined, true);
288
+ * const value2 = getDefaultIfUndefined(false, true);
289
+ *
290
+ * console.log(value1);
291
+ * // true
292
+ * console.log(value2);
293
+ * // false
294
+ * ```
295
+ *
296
+ * @param value - The value to be checked
297
+ * @param defaultValue - The default value when value is undefined
298
+ *
299
+ * @breadcrumb Core
300
+ * @public
301
+ */
302
+ declare function getDefaultIfUndefined<T>(value: T | undefined, defaultValue: T): T;
303
+
304
+ /**
305
+ * Check if stream already ended
306
+ *
307
+ * @param stream - The stream
308
+ *
309
+ * @breadcrumb Core / Stream
310
+ * @public
311
+ */
312
+ declare function isStreamEnded(stream: Readable | Writable): boolean;
313
+ /**
314
+ * Wait asynchronous the stream to complete
315
+ *
316
+ * @param stream - The stream
317
+ *
318
+ * @breadcrumb Core / Stream
319
+ * @public
320
+ */
321
+ declare function waitForStreamComplete<TStream extends Readable | Writable>(stream: TStream): Promise<TStream>;
322
+
323
+ /**
324
+ * The class used to build the serverless handler.
325
+ *
326
+ * @example
327
+ * ```typescript
328
+ * const app = express();
329
+ * export const handler = ServerlessAdapter.new(app)
330
+ * .setFramework(new ExpressFramework())
331
+ * .setHandler(new DefaultHandler())
332
+ * .setResolver(new PromiseResolver())
333
+ * .setRespondWithErrors(true)
334
+ * .addAdapter(new AlbAdapter())
335
+ * .addAdapter(new SQSAdapter())
336
+ * .addAdapter(new SNSAdapter())
337
+ * .build();
338
+ * ```
339
+ *
340
+ * @breadcrumb ServerlessAdapter
341
+ * @public
342
+ */
343
+ declare class ServerlessAdapter<TApp, TEvent, TContext, TCallback, TResponse, TReturn> {
344
+ /**
345
+ * Default constructor
346
+ */
347
+ private constructor();
348
+ /**
349
+ * The instance of the app (express, hapi, koa, etc...)
350
+ */
351
+ protected app: TApp;
352
+ /**
353
+ * Settings for whether the response should be treated as binary or not
354
+ *
355
+ * @defaultValue `contentEncodings` and `contentTypes` are set with {@link DEFAULT_BINARY_ENCODINGS} and {@link DEFAULT_BINARY_CONTENT_TYPES}, respectively.
356
+ */
357
+ protected binarySettings: BinarySettings;
358
+ /**
359
+ * Indicates whether the error stack should be included in the response or not
360
+ *
361
+ * @remarks These errors will only be included when an error occurs while forwarding the event to the framework
362
+ * @defaultValue True when NODE_ENV is equal to `development`
363
+ */
364
+ protected respondWithErrors: boolean;
365
+ /**
366
+ * The instance of the logger service
367
+ */
368
+ protected log: ILogger;
369
+ /**
370
+ * The list of adapters used to handle an event's request and response
371
+ */
372
+ protected adapters: AdapterContract<TEvent, TContext, TResponse>[];
373
+ /**
374
+ * The framework that will process requests
375
+ */
376
+ protected framework?: FrameworkContract<TApp>;
377
+ /**
378
+ * The resolver that aims to resolve the response to serverless and stop its execution when the request ends
379
+ */
380
+ protected resolver?: ResolverContract<TEvent, TContext, TCallback, TResponse, TReturn>;
381
+ /**
382
+ * The handler that will get the event, context and callback and pass it to the adapter and framework
383
+ */
384
+ protected handler?: HandlerContract<TApp, TEvent, TContext, TCallback, TResponse, TReturn>;
385
+ /**
386
+ * Creates a new instance of the builder with app (express, hapi, koa, etc...)
387
+ *
388
+ * @param app - The instance of the app
389
+ */
390
+ static new<TApp, TEvent, TContext = any, TCallback = any, TResponse = any, TReturn = any>(app: TApp): ServerlessAdapter<TApp, TEvent, TContext, TCallback, TResponse, TReturn>;
391
+ /**
392
+ * Defines the handler that will get the event, context and callback and pass it to the adapter and framework
393
+ *
394
+ * @param handler - The implementation of the handler contract
395
+ */
396
+ setHandler(handler: HandlerContract<TApp, TEvent, TContext, TCallback, TResponse, TReturn>): Omit<this, 'setHandler'>;
397
+ /**
398
+ * Defines the resolver that aims to resolve the response to serverless and stop its execution when the request ends
399
+ *
400
+ * @param resolver - The implementation of the resolver contract
401
+ */
402
+ setResolver(resolver: ResolverContract<TEvent, TContext, TCallback, TResponse, TReturn>): Omit<this, 'setResolver'>;
403
+ /**
404
+ * Defines the framework that will process requests
405
+ *
406
+ * @param framework - The implementation of the framework contract
407
+ */
408
+ setFramework(framework: FrameworkContract<TApp>): Omit<this, 'setFramework'>;
409
+ /**
410
+ * Defines the logger service used during the execution of the handler
411
+ *
412
+ * @param logger - The implementation of the logger
413
+ */
414
+ setLogger(logger: ILogger): Omit<this, 'setLogger'>;
415
+ /**
416
+ * Defines the binary settings for whether the response should be treated as binary or not
417
+ *
418
+ * @param binarySettings - The binary settings
419
+ */
420
+ setBinarySettings(binarySettings: BinarySettings): Omit<this, 'setBinarySettings'>;
421
+ /**
422
+ * Defines the responseWithErrors, a property that indicates whether the error stack should be included in the response or not
423
+ *
424
+ * @param respondWithErrors - Should include or not the errors in response
425
+ */
426
+ setRespondWithErrors(respondWithErrors: boolean): Omit<this, 'setRespondWithErrors'>;
427
+ /**
428
+ * Add an adapter to the adapters list to handle the event coming from any serverless event source
429
+ *
430
+ * @param adapter - The implementation of the adapter contract
431
+ */
432
+ addAdapter(adapter: AdapterContract<TEvent, TContext, TResponse>): Pick<this, 'addAdapter' | 'build'>;
433
+ /**
434
+ * The builder method that returns the handler function to be exported for serverless consumption
435
+ */
436
+ build(): ServerlessHandler<TReturn>;
437
+ }
438
+
439
+ export { AdapterContract, BinarySettings, BothValueHeaders, type CurrentInvoke, type FlattenedHeadersAndCookies, FrameworkContract, HandlerContract, ILogger, NO_OP, ResolverContract, ServerlessAdapter, ServerlessHandler, ServerlessStreamResponse, type ServerlessStreamResponseProps, getContentType, getCurrentInvoke, getDefaultIfUndefined, getEventBodyAsBuffer, getFlattenedHeadersMap, getFlattenedHeadersMapAndCookies, getMultiValueHeadersMap, getString, isBinary, isContentEncodingBinary, isContentTypeBinary, isStreamEnded, parseHeaders, setCurrentInvoke, waitForStreamComplete };