Skip to content

Commit 5bb4a6a

Browse files
authored
chore(parser): deprecate AlbMultiValueHeadersSchema (#3523)
1 parent 06e9975 commit 5bb4a6a

File tree

7 files changed

+192
-171
lines changed

7 files changed

+192
-171
lines changed

Diff for: packages/parser/src/schemas/alb.ts

+35-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { 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 */
7290
const 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

7796
export { AlbSchema, AlbMultiValueHeadersSchema };

Diff for: packages/parser/tests/events/albEvent.json renamed to packages/parser/tests/events/alb/base.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
},
2626
"body": "Test",
2727
"isBase64Encoded": false
28-
}
28+
}

Diff for: packages/parser/tests/events/alb/multi-fields.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"requestContext": {
3+
"elb": {
4+
"targetGroupArn": "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-279XGJDqGZ5rsrHC2Fjr/49e9d65c45c6791a"
5+
}
6+
},
7+
"httpMethod": "GET",
8+
"path": "/lambda",
9+
"multiValueQueryStringParameters": {},
10+
"multiValueHeaders": {
11+
"accept": [
12+
"*/*"
13+
],
14+
"host": [
15+
"alb-c-LoadB-14POFKYCLBNSF-1815800096.eu-central-1.elb.amazonaws.com"
16+
],
17+
"user-agent": [
18+
"curl/7.79.1"
19+
],
20+
"x-amzn-trace-id": [
21+
"Root=1-62fa9327-21cdd4da4c6db451490a5fb7"
22+
],
23+
"x-forwarded-for": [
24+
"123.123.123.123"
25+
],
26+
"x-forwarded-port": [
27+
"80"
28+
],
29+
"x-forwarded-proto": [
30+
"http"
31+
]
32+
},
33+
"body": "Test",
34+
"isBase64Encoded": false
35+
}

Diff for: packages/parser/tests/events/albEventPathTrailingSlash.json

-28
This file was deleted.

Diff for: packages/parser/tests/events/albMultiValueHeadersEvent.json

-23
This file was deleted.

0 commit comments

Comments
 (0)