@stone-js/aws-lambda-http-adapter 0.3.1 → 0.8.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.
@@ -0,0 +1,85 @@
1
+ import { RawHttpResponse, AwsLambdaContext, AwsLambdaHttpEvent, AwsLambdaHttpAdapterContext, AwsLambdaEventHandlerFunction } from './declarations';
2
+ import { Adapter, IBlueprint } from '@stone-js/core';
3
+ import { IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse } from '@stone-js/http-core';
4
+ /**
5
+ * AWS Lambda HTTP Adapter for Stone.js.
6
+ *
7
+ * The `AwsLambdaHttpAdapter` extends the functionality of the Stone.js `Adapter`
8
+ * to provide seamless integration with AWS Lambda for HTTP-based events. This adapter
9
+ * transforms incoming HTTP events from AWS Lambda into `IncomingHttpEvent` instances
10
+ * and produces a `RawHttpResponse` as output.
11
+ *
12
+ * This adapter simplifies the process of handling HTTP events within AWS Lambda
13
+ * while adhering to the Stone.js framework's event-driven architecture.
14
+ *
15
+ * @template AwsLambdaHttpEvent - The type of the raw HTTP event from AWS Lambda.
16
+ * @template RawHttpResponse - The type of the raw HTTP response to send back.
17
+ * @template AwsLambdaContext - The AWS Lambda execution context type.
18
+ * @template IncomingHttpEvent - The type of the processed incoming HTTP event.
19
+ * @template IncomingHttpEventOptions - Options used to create an incoming HTTP event.
20
+ * @template OutgoingHttpResponse - The type of the outgoing HTTP response after processing.
21
+ * @template AwsLambdaHttpAdapterContext - Context type specific to the HTTP adapter.
22
+ *
23
+ * @extends Adapter
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * import { AwsLambdaHttpAdapter } from '@stone-js/aws-lambda-http-adapter';
28
+ *
29
+ * const adapter = AwsLambdaHttpAdapter.create({...});
30
+ *
31
+ * const handler = await adapter.run();
32
+ *
33
+ * export { handler };
34
+ * ```
35
+ *
36
+ * @see {@link https://stone-js.com/docs Stone.js Documentation}
37
+ * @see {@link https://docs.aws.amazon.com/lambda/latest/dg/ AWS Lambda Documentation}
38
+ */
39
+ export declare class AwsLambdaHttpAdapter extends Adapter<AwsLambdaHttpEvent, RawHttpResponse, AwsLambdaContext, IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse, AwsLambdaHttpAdapterContext> {
40
+ /**
41
+ * Creates an instance of the `AwsLambdaHttpAdapter`.
42
+ *
43
+ * @param blueprint - The application blueprint.
44
+ * @returns A new instance of `AwsLambdaHttpAdapter`.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const adapter = AwsLambdaHttpAdapter.create(blueprint);
49
+ * await adapter.run();
50
+ * ```
51
+ */
52
+ static create(blueprint: IBlueprint): AwsLambdaHttpAdapter;
53
+ /**
54
+ * Executes the adapter and provides an AWS Lambda-compatible HTTP handler function.
55
+ *
56
+ * This method initializes the adapter and returns a handler function that can
57
+ * process HTTP events in AWS Lambda. It transforms raw events into `IncomingHttpEvent`
58
+ * instances and produces `RawHttpResponse` objects as output.
59
+ *
60
+ * @template ExecutionResultType - The type representing the AWS Lambda event handler function.
61
+ * @returns A promise resolving to the AWS Lambda HTTP handler function.
62
+ * @throws {AwsLambdaHttpAdapterError} If used outside the AWS Lambda environment.
63
+ */
64
+ run<ExecutionResultType = AwsLambdaEventHandlerFunction<RawHttpResponse>>(): Promise<ExecutionResultType>;
65
+ /**
66
+ * Initializes the adapter and validates its execution context.
67
+ *
68
+ * Ensures that the adapter is running in an AWS Lambda environment. Throws an error
69
+ * if it detects that the adapter is being used in an unsupported environment (e.g., a browser).
70
+ *
71
+ * @throws {AwsLambdaHttpAdapterError} If executed outside an AWS Lambda environment.
72
+ */
73
+ protected onStart(): Promise<void>;
74
+ /**
75
+ * Processes an incoming AWS Lambda HTTP event.
76
+ *
77
+ * Converts a raw AWS Lambda HTTP event into an `IncomingHttpEvent`, processes it through
78
+ * the Stone.js pipeline, and generates a `RawHttpResponse` to send back.
79
+ *
80
+ * @param rawEvent - The raw HTTP event received from AWS Lambda.
81
+ * @param executionContext - The AWS Lambda execution context associated with the event.
82
+ * @returns A promise resolving to the processed `RawHttpResponse`.
83
+ */
84
+ protected eventListener(rawEvent: AwsLambdaHttpEvent, executionContext: AwsLambdaContext): Promise<RawHttpResponse>;
85
+ }
@@ -0,0 +1,28 @@
1
+ import { IBlueprint, AdapterErrorContext, IAdapterErrorHandler, AdapterEventBuilderType } from '@stone-js/core';
2
+ import { AwsLambdaContext, AwsLambdaHttpEvent, RawHttpResponse } from './declarations';
3
+ /**
4
+ * AwsLambdaHttpErrorHandler options.
5
+ */
6
+ export interface AwsLambdaHttpErrorHandlerOptions {
7
+ blueprint: IBlueprint;
8
+ }
9
+ /**
10
+ * Class representing an AwsLambdaHttpErrorHandler.
11
+ */
12
+ export declare class AwsLambdaHttpErrorHandler implements IAdapterErrorHandler<AwsLambdaHttpEvent, RawHttpResponse, AwsLambdaContext> {
13
+ private readonly logger;
14
+ /**
15
+ * Create an NodeHttpErrorHandler.
16
+ *
17
+ * @param options - NodeHttpErrorHandler options.
18
+ */
19
+ constructor({ blueprint }: AwsLambdaHttpErrorHandlerOptions);
20
+ /**
21
+ * Handle an error.
22
+ *
23
+ * @param error - The error to handle.
24
+ * @param context - The context of the adapter.
25
+ * @returns The raw response builder.
26
+ */
27
+ handle(error: Error, context: AdapterErrorContext<AwsLambdaHttpEvent, RawHttpResponse, AwsLambdaContext>): AdapterEventBuilderType<RawHttpResponse>;
28
+ }
@@ -0,0 +1,69 @@
1
+ import { IRawResponseWrapper } from '@stone-js/core';
2
+ import { RawHttpResponse, RawHttpResponseOptions } from './declarations';
3
+ /**
4
+ * Wrapper for HTTP raw responses in AWS Lambda.
5
+ *
6
+ * The `RawHttpResponseWrapper` is responsible for constructing and returning
7
+ * a raw HTTP response that conforms to the expected structure for AWS Lambda.
8
+ * It implements the `IRawResponseWrapper` interface, ensuring compatibility
9
+ * with the Stone.js framework.
10
+ */
11
+ export declare class RawHttpResponseWrapper implements IRawResponseWrapper<RawHttpResponse> {
12
+ private readonly options;
13
+ /**
14
+ * Factory method to create an instance of `RawHttpResponseWrapper`.
15
+ *
16
+ * This method accepts partial response options, allowing the user to configure
17
+ * only the required fields. It initializes the wrapper with these options.
18
+ *
19
+ * @param options - Partial options to configure the HTTP response.
20
+ * @returns A new instance of `RawHttpResponseWrapper`.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const responseWrapper = RawHttpResponseWrapper.create({
25
+ * statusCode: 200,
26
+ * body: { message: 'Success' },
27
+ * headers: { 'Content-Type': 'application/json' }
28
+ * });
29
+ *
30
+ * const response = responseWrapper.respond();
31
+ * console.log(response); // { statusCode: 200, body: '{"message":"Success"}', headers: { 'Content-Type': 'application/json' } }
32
+ * ```
33
+ */
34
+ static create(options: Partial<RawHttpResponseOptions>): RawHttpResponseWrapper;
35
+ /**
36
+ * Constructs an instance of `RawHttpResponseWrapper`.
37
+ *
38
+ * This constructor is private and should not be called directly.
39
+ * Use the `create` method to initialize an instance.
40
+ *
41
+ * @param options - Partial options for configuring the HTTP response.
42
+ */
43
+ private constructor();
44
+ /**
45
+ * Constructs and returns the raw HTTP response.
46
+ *
47
+ * The `respond` method generates a `RawHttpResponse` object based on the
48
+ * provided options. If any required fields are missing, it assigns default values:
49
+ * - `statusCode`: Defaults to `500`.
50
+ *
51
+ * @returns A `RawHttpResponse` object.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const responseWrapper = RawHttpResponseWrapper.create({ body: 'Hello, world!', statusCode: 200 });
56
+ * const response = responseWrapper.respond();
57
+ * console.log(response); // { statusCode: 500, statusMessage: '', body: 'Hello, world!', headers: undefined }
58
+ * ```
59
+ */
60
+ respond(): RawHttpResponse;
61
+ /**
62
+ * Extract all `Set-Cookie` values from a Headers instance, tolerant of runtimes without
63
+ * `getSetCookie()`.
64
+ *
65
+ * @param headers - The response headers.
66
+ * @returns The raw `Set-Cookie` strings.
67
+ */
68
+ private extractSetCookies;
69
+ }
@@ -0,0 +1,38 @@
1
+ import { ClassType } from '@stone-js/core';
2
+ import { AwsLambdaHttpAdapterAdapterConfig } from '../../options/AwsLambdaHttpAdapterBlueprint';
3
+ /**
4
+ * Configuration options for the `AwsLambdaHttp` decorator.
5
+ * These options extend the default AWS Lambda HTTP adapter configuration.
6
+ */
7
+ export interface AwsLambdaHttpOptions extends Partial<AwsLambdaHttpAdapterAdapterConfig> {
8
+ }
9
+ /**
10
+ * A Stone.js decorator that integrates the AWS Lambda HTTP Adapter with a class.
11
+ *
12
+ * This decorator modifies the class to seamlessly enable AWS Lambda HTTP as the
13
+ * execution environment for a Stone.js application. By applying this decorator,
14
+ * the class is automatically configured with the necessary blueprint for AWS Lambda HTTP.
15
+ *
16
+ * NB: This decorator is stubbed for browser environments compatibility and does not
17
+ * perform any actual functionality in the browser. It is intended for use in Node.js environments
18
+ * where the Node.js HTTP adapter is applicable.
19
+ *
20
+ * @template T - The type of the class being decorated. Defaults to `ClassType`.
21
+ * @param options - Optional configuration to customize the AWS Lambda HTTP Adapter.
22
+ *
23
+ * @returns A class decorator that applies the AWS Lambda HTTP adapter configuration.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * import { AwsLambdaHttp } from '@stone-js/aws-lambda-http-adapter';
28
+ *
29
+ * @AwsLambdaHttp({
30
+ * alias: 'MyAwsLambdaHttpAdapter',
31
+ * current: true,
32
+ * })
33
+ * class App {
34
+ * // Your application logic here
35
+ * }
36
+ * ```
37
+ */
38
+ export declare const AwsLambdaHttp: <T extends ClassType = ClassType>(_options?: AwsLambdaHttpOptions) => ClassDecorator;
@@ -0,0 +1,13 @@
1
+ import { AwsLambdaHttpAdapterBlueprint } from '../../options/AwsLambdaHttpAdapterBlueprint';
2
+ /**
3
+ * Default blueprint configuration for the AWS Lambda Http Adapter.
4
+ *
5
+ * This blueprint defines the initial configuration for the AWS Lambda Http adapter
6
+ * within the Stone.js framework. It includes:
7
+ * - An alias for the AWS Lambda platform (`AWS_LAMBDA_HTTP_PLATFORM`).
8
+ * - A default resolver function (currently a placeholder).
9
+ * - Middleware, hooks, and state flags (`current`, `default`, `preferred`).
10
+ *
11
+ * NB: This is a stub for browser environments and does not perform any actual functionality in the browser.
12
+ */
13
+ export declare const awsLambdaHttpAdapterBlueprint: AwsLambdaHttpAdapterBlueprint;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A constant representing the AWS Lambda HTTP platform identifier.
3
+ *
4
+ * This constant is used as an alias for the AWS Lambda HTTP Adapter within the Stone.js framework.
5
+ * It helps in identifying and configuring platform-specific adapters or components for handling
6
+ * HTTP requests and responses.
7
+ */
8
+ export declare const AWS_LAMBDA_HTTP_PLATFORM = "aws_lambda_http";
@@ -0,0 +1,124 @@
1
+ import { RawHttpResponseWrapper } from './RawHttpResponseWrapper';
2
+ import { AdapterContext, IAdapterEventBuilder, RawResponseOptions } from '@stone-js/core';
3
+ import { IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse } from '@stone-js/http-core';
4
+ /**
5
+ * Represents a raw HTTP response, extending from `RawHttpResponseOptions`.
6
+ */
7
+ export type RawHttpResponse = RawHttpResponseOptions;
8
+ /**
9
+ * Represents the AWS Lambda execution context as a key-value pair.
10
+ */
11
+ export type AwsLambdaContext = Record<string, unknown>;
12
+ /**
13
+ * Represents an AWS Lambda event handler function.
14
+ *
15
+ * @template RawResponseType - The type of the response returned by the handler.
16
+ * @param rawEvent - The raw event received by the AWS Lambda function.
17
+ * @param context - The AWS Lambda execution context.
18
+ * @returns A promise resolving to the response of type `RawResponseType`.
19
+ */
20
+ export type AwsLambdaEventHandlerFunction<RawResponseType = RawHttpResponse> = (rawEvent: AwsLambdaHttpEvent, context: AwsLambdaContext) => Promise<RawResponseType>;
21
+ /**
22
+ * Represents the response builder for the AWS Lambda http Adapter.
23
+ */
24
+ export type AwsLambdaHttpAdapterResponseBuilder = IAdapterEventBuilder<RawHttpResponseOptions, RawHttpResponseWrapper>;
25
+ /**
26
+ * Represents the structure of an AWS Lambda HTTP event across every supported trigger:
27
+ * API Gateway REST (payload v1), API Gateway HTTP API and Lambda Function URLs (payload v2),
28
+ * and Application Load Balancer (ALB). Every field is optional because each trigger populates a
29
+ * different subset; use {@link normalizeHttpEvent} to reduce it to a canonical shape.
30
+ */
31
+ export interface AwsLambdaHttpEvent extends Record<string, unknown> {
32
+ /** Payload format version, e.g. `'1.0'` (REST) or `'2.0'` (HTTP API / Function URL). */
33
+ version?: string;
34
+ /** The path of the HTTP request (v1/ALB). */
35
+ path?: string;
36
+ /** The body of the HTTP request. */
37
+ body?: unknown;
38
+ /** The encoding format of the body, such as `base64`. */
39
+ encoding?: string;
40
+ /** The raw path of the HTTP request (v2). */
41
+ rawPath?: string;
42
+ /** The raw query string, without leading `?` (v2). */
43
+ rawQueryString?: string;
44
+ /** Indicates whether the request body is base64-encoded. */
45
+ isBase64Encoded?: boolean;
46
+ /** The headers of the HTTP request as key-value pairs (may be null/absent on some triggers). */
47
+ headers?: Record<string, string> | null;
48
+ /** Multi-value headers (v1 / ALB with multi-value enabled). */
49
+ multiValueHeaders?: Record<string, string[]>;
50
+ /** Raw cookie strings (v2 / Function URLs). */
51
+ cookies?: string[];
52
+ /** The HTTP method of the request (v1/ALB). */
53
+ httpMethod?: string;
54
+ /** The single-value query string parameters. */
55
+ queryStringParameters?: Record<string, string> | null;
56
+ /** The multi-value query string parameters (v1 / ALB with multi-value enabled). */
57
+ multiValueQueryStringParameters?: Record<string, string[]>;
58
+ /** The request context, whose shape varies by trigger. */
59
+ requestContext?: {
60
+ elb?: unknown;
61
+ identity?: {
62
+ sourceIp?: string;
63
+ };
64
+ httpMethod?: string;
65
+ http?: {
66
+ path?: string;
67
+ method?: string;
68
+ sourceIp?: string;
69
+ };
70
+ };
71
+ }
72
+ /**
73
+ * Represents the context for the AWS Lambda HTTP Adapter.
74
+ *
75
+ * This interface extends `AdapterContext` and includes additional properties specific
76
+ * to HTTP events in AWS Lambda.
77
+ */
78
+ export interface AwsLambdaHttpAdapterContext extends AdapterContext<AwsLambdaHttpEvent, RawHttpResponse, AwsLambdaContext, IncomingHttpEvent, IncomingHttpEventOptions, OutgoingHttpResponse> {
79
+ /**
80
+ * The raw HTTP response associated with the current context.
81
+ */
82
+ rawResponse: RawHttpResponse;
83
+ }
84
+ /**
85
+ * Represents options for configuring a raw HTTP response.
86
+ *
87
+ * Extends the `RawResponseOptions` interface to include additional properties
88
+ * for managing response content, headers, status codes, and streaming files.
89
+ */
90
+ export interface RawHttpResponseOptions extends RawResponseOptions {
91
+ /**
92
+ * The body of the HTTP response. Can be of any type, including strings, objects, or buffers.
93
+ */
94
+ body?: unknown;
95
+ /**
96
+ * The HTTP status code of the response (e.g., `200`, `404`).
97
+ */
98
+ statusCode: number;
99
+ /**
100
+ * The status message accompanying the HTTP status code (e.g., `OK`, `Not Found`).
101
+ */
102
+ statusMessage?: string;
103
+ /**
104
+ * Headers to include in the HTTP response. May be a `Headers` instance (from http-core) or a
105
+ * plain record; the wrapper normalizes it and lifts out `Set-Cookie`.
106
+ */
107
+ headers?: Headers | Record<string, string>;
108
+ /**
109
+ * Multi-value response headers (used by API Gateway REST v1 / ALB to emit multiple `Set-Cookie`).
110
+ */
111
+ multiValueHeaders?: Record<string, string[]>;
112
+ /**
113
+ * Response cookies as raw `Set-Cookie` strings (used by API Gateway HTTP API v2 / Function URLs).
114
+ */
115
+ cookies?: string[];
116
+ /**
117
+ * The detected trigger family, used to choose the correct multi-cookie response shape.
118
+ */
119
+ version?: 'v1' | 'v2' | 'alb';
120
+ /**
121
+ * The encoding format of the response body, such as `base64`.
122
+ */
123
+ isBase64Encoded?: boolean;
124
+ }
@@ -0,0 +1,34 @@
1
+ import { ClassType } from '@stone-js/core';
2
+ import { AwsLambdaHttpAdapterAdapterConfig } from '../options/AwsLambdaHttpAdapterBlueprint';
3
+ /**
4
+ * Configuration options for the `AwsLambdaHttp` decorator.
5
+ * These options extend the default AWS Lambda HTTP adapter configuration.
6
+ */
7
+ export interface AwsLambdaHttpOptions extends Partial<AwsLambdaHttpAdapterAdapterConfig> {
8
+ }
9
+ /**
10
+ * A Stone.js decorator that integrates the AWS Lambda HTTP Adapter with a class.
11
+ *
12
+ * This decorator modifies the class to seamlessly enable AWS Lambda HTTP as the
13
+ * execution environment for a Stone.js application. By applying this decorator,
14
+ * the class is automatically configured with the necessary blueprint for AWS Lambda HTTP.
15
+ *
16
+ * @template T - The type of the class being decorated. Defaults to `ClassType`.
17
+ * @param options - Optional configuration to customize the AWS Lambda HTTP Adapter.
18
+ *
19
+ * @returns A class decorator that applies the AWS Lambda HTTP adapter configuration.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { AwsLambdaHttp } from '@stone-js/aws-lambda-http-adapter';
24
+ *
25
+ * @AwsLambdaHttp({
26
+ * alias: 'MyAwsLambdaHttpAdapter',
27
+ * current: true,
28
+ * })
29
+ * class App {
30
+ * // Your application logic here
31
+ * }
32
+ * ```
33
+ */
34
+ export declare const AwsLambdaHttp: <T extends ClassType = ClassType>(options?: AwsLambdaHttpOptions) => ClassDecorator;
@@ -0,0 +1,7 @@
1
+ import { ErrorOptions, IntegrationError } from '@stone-js/core';
2
+ /**
3
+ * Custom error for AWS Lambda adapter operations.
4
+ */
5
+ export declare class AwsLambdaHttpAdapterError extends IntegrationError {
6
+ constructor(message: string, options?: ErrorOptions);
7
+ }
@@ -0,0 +1,110 @@
1
+ import { AwsLambdaHttpEvent } from './declarations';
2
+ /**
3
+ * Platform-agnostic normalization of the many AWS "HTTP" Lambda event shapes.
4
+ *
5
+ * A single Lambda function can be fronted by very different integrations, each with its own
6
+ * event schema: API Gateway REST (payload v1), API Gateway HTTP API and Lambda Function URLs
7
+ * (payload v2), and Application Load Balancer (ALB). This module reduces all of them to one
8
+ * canonical {@link NormalizedHttpEvent} so the rest of the adapter never branches on the trigger.
9
+ *
10
+ * References:
11
+ * - v1 (REST): `httpMethod`, `path`, `queryStringParameters` + `multiValueQueryStringParameters`,
12
+ * `headers` + `multiValueHeaders`, cookies in the `Cookie` header, `requestContext.identity.sourceIp`.
13
+ * - v2 (HTTP API / Function URLs): `version:'2.0'`, `requestContext.http.{method,sourceIp,path}`,
14
+ * `rawPath`, `rawQueryString`, `headers`, `cookies: string[]`.
15
+ * - ALB: `requestContext.elb`, `httpMethod`, `path`, either `queryStringParameters` or
16
+ * `multiValueQueryStringParameters` (depending on the target group's multi-value setting).
17
+ */
18
+ /**
19
+ * The detected AWS HTTP trigger family.
20
+ */
21
+ export type AwsHttpEventVersion = 'v1' | 'v2' | 'alb';
22
+ /**
23
+ * A canonical HTTP request derived from any AWS HTTP Lambda event.
24
+ */
25
+ export interface NormalizedHttpEvent {
26
+ /** The detected trigger family. */
27
+ version: AwsHttpEventVersion;
28
+ /** The HTTP method (upper-case). */
29
+ method: string;
30
+ /** The request path (no query string). */
31
+ path: string;
32
+ /** The raw query string (without leading `?`), fidelity-preserving. */
33
+ rawQueryString: string;
34
+ /** Lower-cased headers; multi-value headers joined with `, `. */
35
+ headers: Record<string, string>;
36
+ /** Raw cookie strings (e.g. `['a=1', 'b=2']`). */
37
+ cookies: string[];
38
+ /** The best-effort client source IP. */
39
+ sourceIp: string;
40
+ /** Whether {@link body} is base64-encoded. */
41
+ isBase64Encoded: boolean;
42
+ /** The raw request body as delivered by AWS (string or undefined). */
43
+ body?: string;
44
+ }
45
+ /**
46
+ * Detect which AWS HTTP trigger produced the event.
47
+ *
48
+ * @param event - The raw Lambda event.
49
+ * @returns The trigger family.
50
+ */
51
+ export declare function detectEventVersion(event: AwsLambdaHttpEvent): AwsHttpEventVersion;
52
+ /**
53
+ * Normalize headers to lower-cased keys, merging single and multi-value headers.
54
+ *
55
+ * @param event - The raw Lambda event.
56
+ * @returns Lower-cased headers with multi-value entries joined by `, `.
57
+ */
58
+ export declare function normalizeHeaders(event: AwsLambdaHttpEvent): Record<string, string>;
59
+ /**
60
+ * Build the raw query string from whichever representation the trigger provides.
61
+ *
62
+ * v2 gives the fidelity-preserving `rawQueryString`. v1/ALB give an object (single value) and
63
+ * optionally `multiValueQueryStringParameters` (preferred, preserves repeated keys). Values are
64
+ * URL-encoded so repeated/array values survive.
65
+ *
66
+ * @param event - The raw Lambda event.
67
+ * @param version - The detected trigger family.
68
+ * @returns The raw query string (no leading `?`).
69
+ */
70
+ export declare function buildRawQueryString(event: AwsLambdaHttpEvent, version: AwsHttpEventVersion): string;
71
+ /**
72
+ * Collect the raw cookie strings, regardless of trigger.
73
+ *
74
+ * v2 delivers `event.cookies: string[]`. v1/ALB deliver a single `Cookie` header (already merged
75
+ * into {@link NormalizedHttpEvent.headers}).
76
+ *
77
+ * @param event - The raw Lambda event.
78
+ * @param headers - The normalized headers.
79
+ * @returns The raw cookie strings.
80
+ */
81
+ export declare function collectCookies(event: AwsLambdaHttpEvent, headers: Record<string, string>): string[];
82
+ /**
83
+ * Resolve the client source IP across triggers.
84
+ *
85
+ * @param event - The raw Lambda event.
86
+ * @param version - The detected trigger family.
87
+ * @param headers - The normalized headers.
88
+ * @returns The source IP (empty string if unknown).
89
+ */
90
+ export declare function resolveSourceIp(event: AwsLambdaHttpEvent, version: AwsHttpEventVersion, headers: Record<string, string>): string;
91
+ /**
92
+ * Normalize any AWS HTTP Lambda event into the canonical {@link NormalizedHttpEvent}.
93
+ *
94
+ * @param event - The raw Lambda event.
95
+ * @returns The normalized request.
96
+ */
97
+ export declare function normalizeHttpEvent(event: AwsLambdaHttpEvent): NormalizedHttpEvent;
98
+ /**
99
+ * Extract the raw request body exactly as received, decoding base64 to a Buffer when needed.
100
+ *
101
+ * This is what the adapter exposes as `metadata.rawBody`: the untouched payload the client sent,
102
+ * available to consumers even when no body-parsing middleware is installed. Binary payloads are
103
+ * returned as a `Buffer` (never a lossy UTF-8 round-trip); text payloads as a string. A
104
+ * non-string, non-base64 body (e.g. a pre-parsed object from a test/custom integration) is
105
+ * returned as-is.
106
+ *
107
+ * @param event - The raw Lambda event.
108
+ * @returns The raw body as a Buffer, string, the original value, or undefined.
109
+ */
110
+ export declare function getRawBody(event: AwsLambdaHttpEvent): Buffer | string | unknown;