11import { z } from 'zod' ;
22
33/**
4- * Zod schema for Application load balancer event
4+ * Zod schema for Application Load Balancer events.
55 *
66 * @example
77 * ```json
@@ -33,6 +33,32 @@ import { z } from 'zod';
3333 * }
3434 * ```
3535 *
36+ * With multi-value headers and multi-value query string parameters:
37+ *
38+ * @example
39+ * ```json
40+ * {
41+ * "requestContext": {
42+ * "elb": {
43+ * "targetGroupArn": "arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-group/6d0ecf831eec9f09"
44+ * }
45+ * },
46+ * "httpMethod": "GET",
47+ * "path": "/",
48+ * "multiValueHeaders": {
49+ * "Set-cookie": [
50+ * "cookie-name=cookie-value;Domain=myweb.com;Secure;HttpOnly",
51+ * "cookie-name=cookie-value;Expires=May 8, 2019"
52+ * ],
53+ * "Content-Type": [
54+ * "application/json"
55+ * ]
56+ * },
57+ * "isBase64Encoded": false,
58+ * "body": "request_body"
59+ * }
60+ * ```
61+ *
3662 * @see {@link types.ALBEvent | ALBEvent }
3763 * @see {@link https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html }
3864 * @see {@link https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html }
@@ -43,7 +69,11 @@ const AlbSchema = z.object({
4369 body : z . string ( ) ,
4470 isBase64Encoded : z . boolean ( ) ,
4571 headers : z . record ( z . string ( ) , z . string ( ) ) . optional ( ) ,
72+ multiValueHeaders : z . record ( z . string ( ) , z . array ( z . string ( ) ) ) . optional ( ) ,
4673 queryStringParameters : z . record ( z . string ( ) , z . string ( ) ) . optional ( ) ,
74+ multiValueQueryStringParameters : z
75+ . record ( z . string ( ) , z . array ( z . string ( ) ) )
76+ . optional ( ) ,
4777 requestContext : z . object ( {
4878 elb : z . object ( {
4979 targetGroupArn : z . string ( ) ,
@@ -52,26 +82,15 @@ const AlbSchema = z.object({
5282} ) ;
5383
5484/**
55- * Zod schema for Application load balancer event with multi-value headers
85+ * @deprecated Use `AlbSchema` instead, which handles both types of headers & querystring parameters.
5686 *
57- * @example
58- * ```json
59- * {
60- * "multiValueHeaders": {
61- * "Set-cookie": [
62- * "cookie-name=cookie-value;Domain=myweb.com;Secure;HttpOnly",
63- * "cookie-name=cookie-value;Expires=May 8, 2019"
64- * ],
65- * "Content-Type": [
66- * "application/json"
67- * ]
68- * }
69- * }
70- * ```
87+ * This schema will be removed in a future major release.
7188 */
89+ /* v8 ignore start */
7290const AlbMultiValueHeadersSchema = AlbSchema . extend ( {
7391 multiValueHeaders : z . record ( z . string ( ) , z . array ( z . string ( ) ) ) ,
7492 multiValueQueryStringParameters : z . record ( z . string ( ) , z . array ( z . string ( ) ) ) ,
7593} ) ;
94+ /* v8 ignore stop */
7695
7796export { AlbSchema , AlbMultiValueHeadersSchema } ;
0 commit comments