From f732b885edb5f81e9535d4e60afa961e1b0871bf Mon Sep 17 00:00:00 2001 From: Alexander Schueren Date: Wed, 24 Apr 2024 11:48:05 +0200 Subject: [PATCH 1/3] fix(parser): change to nullable values --- packages/parser/src/schemas/apigwv2.ts | 16 +++++++++------- packages/parser/tests/unit/schema/lambda.test.ts | 6 ++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/parser/src/schemas/apigwv2.ts b/packages/parser/src/schemas/apigwv2.ts index ec5cfb6156..b5779c6214 100644 --- a/packages/parser/src/schemas/apigwv2.ts +++ b/packages/parser/src/schemas/apigwv2.ts @@ -13,14 +13,16 @@ const RequestContextV2Authorizer = z.object({ accessKey: z.string().optional(), accountId: z.string().optional(), callerId: z.string().optional(), - principalOrgId: z.string().optional(), + principalOrgId: z.string().nullable(), userArn: z.string().optional(), userId: z.string().optional(), - cognitoIdentity: z.object({ - amr: z.array(z.string()), - identityId: z.string(), - identityPoolId: z.string(), - }), + cognitoIdentity: z + .object({ + amr: z.array(z.string()), + identityId: z.string(), + identityPoolId: z.string(), + }) + .nullable(), }) .optional(), lambda: z.record(z.string(), z.any()).optional(), @@ -42,7 +44,7 @@ const RequestContextV2 = z.object({ .object({ clientCert: APIGatewayCert.optional(), }) - .optional(), + .nullable(), domainName: z.string(), domainPrefix: z.string(), http: RequestContextV2Http, diff --git a/packages/parser/tests/unit/schema/lambda.test.ts b/packages/parser/tests/unit/schema/lambda.test.ts index cfef867657..e9b0a3449b 100644 --- a/packages/parser/tests/unit/schema/lambda.test.ts +++ b/packages/parser/tests/unit/schema/lambda.test.ts @@ -15,4 +15,10 @@ describe('Lambda ', () => { lambdaFunctionUrlEvent ); }); + + it('should parse url IAM event', () => { + const urlIAMEvent = TestEvents.lambdaFunctionUrlIAMEvent; + + expect(LambdaFunctionUrlSchema.parse(urlIAMEvent)).toEqual(urlIAMEvent); + }); }); From 3bebc7cb293bd37c24191643d08b53e6a7cbd373 Mon Sep 17 00:00:00 2001 From: Alexander Schueren Date: Wed, 24 Apr 2024 11:50:18 +0200 Subject: [PATCH 2/3] sometimes it's optional, sometimes nullable --- packages/parser/src/schemas/apigwv2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/parser/src/schemas/apigwv2.ts b/packages/parser/src/schemas/apigwv2.ts index b5779c6214..67017dac6b 100644 --- a/packages/parser/src/schemas/apigwv2.ts +++ b/packages/parser/src/schemas/apigwv2.ts @@ -44,7 +44,7 @@ const RequestContextV2 = z.object({ .object({ clientCert: APIGatewayCert.optional(), }) - .nullable(), + .nullish(), domainName: z.string(), domainPrefix: z.string(), http: RequestContextV2Http, From 2c218264aab25533f0fbbe4429e70844a76e22fe Mon Sep 17 00:00:00 2001 From: Alexander Schueren Date: Wed, 24 Apr 2024 12:18:34 +0200 Subject: [PATCH 3/3] soften the requirement with nullish --- packages/parser/src/schemas/apigwv2.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/parser/src/schemas/apigwv2.ts b/packages/parser/src/schemas/apigwv2.ts index 67017dac6b..77491d4864 100644 --- a/packages/parser/src/schemas/apigwv2.ts +++ b/packages/parser/src/schemas/apigwv2.ts @@ -13,7 +13,7 @@ const RequestContextV2Authorizer = z.object({ accessKey: z.string().optional(), accountId: z.string().optional(), callerId: z.string().optional(), - principalOrgId: z.string().nullable(), + principalOrgId: z.string().nullish(), userArn: z.string().optional(), userId: z.string().optional(), cognitoIdentity: z @@ -22,7 +22,7 @@ const RequestContextV2Authorizer = z.object({ identityId: z.string(), identityPoolId: z.string(), }) - .nullable(), + .nullish(), }) .optional(), lambda: z.record(z.string(), z.any()).optional(),