Skip to content

Commit

Permalink
fix(parser): lambda function url cognitoIdentity and principalOrgId n…
Browse files Browse the repository at this point in the history
…ullable (#2430)

* fix(parser): change to nullable values

* sometimes it's optional, sometimes nullable

* soften the requirement with nullish
  • Loading branch information
am29d authored Apr 24, 2024
1 parent 100e223 commit 3c3e393
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/parser/src/schemas/apigwv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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().nullish(),
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(),
})
.nullish(),
})
.optional(),
lambda: z.record(z.string(), z.any()).optional(),
Expand All @@ -42,7 +44,7 @@ const RequestContextV2 = z.object({
.object({
clientCert: APIGatewayCert.optional(),
})
.optional(),
.nullish(),
domainName: z.string(),
domainPrefix: z.string(),
http: RequestContextV2Http,
Expand Down
6 changes: 6 additions & 0 deletions packages/parser/tests/unit/schema/lambda.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ describe('Lambda ', () => {
lambdaFunctionUrlEvent
);
});

it('should parse url IAM event', () => {
const urlIAMEvent = TestEvents.lambdaFunctionUrlIAMEvent;

expect(LambdaFunctionUrlSchema.parse(urlIAMEvent)).toEqual(urlIAMEvent);
});
});

0 comments on commit 3c3e393

Please sign in to comment.