Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/parser/src/envelopes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export { CloudWatchEnvelope } from './cloudwatch.js';
export { DynamoDBStreamEnvelope } from './dynamodb.js';
export { EventBridgeEnvelope } from './eventbridge.js';
export { KafkaEnvelope } from './kafka.js';
export { KinesisFirehoseEnvelope } from './kinesis-firehose.js';
export { KinesisEnvelope } from './kinesis.js';
export { KinesisFirehoseEnvelope } from './kinesis-firehose.js';
export { LambdaFunctionUrlEnvelope } from './lambda.js';
export { SnsSqsEnvelope } from './sns-sqs.js';
export { SnsEnvelope } from './sns.js';
export { SnsSqsEnvelope } from './sns-sqs.js';
export { SqsEnvelope } from './sqs.js';
export { VpcLatticeEnvelope } from './vpc-lattice.js';
export { VpcLatticeV2Envelope } from './vpc-latticev2.js';
2 changes: 1 addition & 1 deletion packages/parser/src/helpers/dynamodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const DynamoDBMarshalled = <T extends ZodTypeAny>(schema: T) =>
.transform((str, ctx) => {
try {
return unmarshallDynamoDB(str);
} catch (err) {
} catch {
ctx.addIssue({
code: 'custom',
message: 'Could not unmarshall DynamoDB stream record',
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const JSONStringified = <T extends ZodTypeAny>(schema: T) =>
.transform((str, ctx) => {
try {
return JSON.parse(str);
} catch (err) {
} catch {
ctx.addIssue({
code: 'custom',
message: 'Invalid JSON',
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { parser } from './parserDecorator.js';
export { ParseError } from './errors.js';
export { parser } from './parserDecorator.js';
11 changes: 7 additions & 4 deletions packages/parser/src/schemas/api-gateway-websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ export const APIGatewayProxyWebsocketEventSchema = z.object({
headers: z.record(z.string()),
multiValueHeaders: z.record(z.array(z.string())),
queryStringParameters: z.record(z.string()).nullable().optional(),
multiValueQueryStringParameters: z.record(z.array(z.string())).nullable().optional(),
multiValueQueryStringParameters: z
.record(z.array(z.string()))
.nullable()
.optional(),
stageVariables: z.record(z.string()).nullable().optional(),
requestContext: z.object({
routeKey: z.string(),
eventType: z.enum(["CONNECT", "DISCONNECT", "MESSAGE"]),
eventType: z.enum(['CONNECT', 'DISCONNECT', 'MESSAGE']),
extendedRequestId: z.string(),
requestTime: z.string(),
messageDirection: z.enum(["IN", "OUT"]),
messageDirection: z.enum(['IN', 'OUT']),
stage: z.string(),
connectedAt: z.number(),
requestTimeEpoch: z.number(),
Expand All @@ -89,4 +92,4 @@ export const APIGatewayProxyWebsocketEventSchema = z.object({
}),
isBase64Encoded: z.boolean(),
body: z.string().optional().nullable(),
});
});
2 changes: 1 addition & 1 deletion packages/parser/src/schemas/cloudwatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const decompressRecordToJSON = (
);

return CloudWatchLogsDecodeSchema.parse(JSON.parse(uncompressed));
} catch (error) {
} catch {
throw new DecompressError('Failed to decompress CloudWatch log data');
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/schemas/dynamodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const unmarshallDynamoDBTransform = (
try {
// @ts-expect-error
return unmarshallDynamoDB(image) as Record<string, unknown>;
} catch (err) {
} catch {
ctx.addIssue({
code: 'custom',
message: `Could not unmarshall ${imageName} in DynamoDB stream record`,
Expand Down
60 changes: 30 additions & 30 deletions packages/parser/src/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
export { AlbSchema, AlbMultiValueHeadersSchema } from './alb.js';
export { AlbMultiValueHeadersSchema, AlbSchema } from './alb.js';
export {
APIGatewayEventRequestContextSchema,
APIGatewayProxyEventSchema,
APIGatewayRequestAuthorizerEventSchema,
APIGatewayTokenAuthorizerEventSchema,
APIGatewayEventRequestContextSchema,
} from './api-gateway.js';
export { APIGatewayProxyWebsocketEventSchema } from './api-gateway-websocket.js';
export {
AppSyncResolverSchema,
APIGatewayProxyEventV2Schema,
APIGatewayRequestAuthorizerEventV2Schema,
APIGatewayRequestAuthorizerV2Schema,
APIGatewayRequestContextV2Schema,
} from './api-gatewayv2.js';
export {
AppSyncBatchResolverSchema,
AppSyncResolverSchema,
} from './appsync.js';
export {
AppSyncEventsBaseSchema,
AppSyncEventsRequestSchema,
AppSyncEventsInfoSchema,
AppSyncEventsPublishSchema,
AppSyncEventsRequestSchema,
AppSyncEventsSubscribeSchema,
} from './appsync-events.js';
export {
APIGatewayProxyEventV2Schema,
APIGatewayRequestAuthorizerEventV2Schema,
APIGatewayRequestAuthorizerV2Schema,
APIGatewayRequestContextV2Schema,
} from './api-gatewayv2.js';
export {
CloudFormationCustomResourceCreateSchema,
CloudFormationCustomResourceDeleteSchema,
Expand All @@ -34,18 +34,18 @@ export {
CloudWatchLogsSchema,
} from './cloudwatch.js';
export {
PreSignupTriggerSchema,
CreateAuthChallengeTriggerSchema,
CustomEmailSenderTriggerSchema,
CustomMessageTriggerSchema,
CustomSMSSenderTriggerSchema,
DefineAuthChallengeTriggerSchema,
MigrateUserTriggerSchema,
PostAuthenticationTriggerSchema,
PostConfirmationTriggerSchema,
PreAuthenticationTriggerSchema,
PostAuthenticationTriggerSchema,
PreSignupTriggerSchema,
PreTokenGenerationTriggerSchemaV1,
PreTokenGenerationTriggerSchemaV2AndV3,
MigrateUserTriggerSchema,
CustomMessageTriggerSchema,
CustomEmailSenderTriggerSchema,
CustomSMSSenderTriggerSchema,
DefineAuthChallengeTriggerSchema,
CreateAuthChallengeTriggerSchema,
VerifyAuthChallengeTriggerSchema,
} from './cognito.js';
export {
Expand All @@ -55,40 +55,40 @@ export {
export { EventBridgeSchema } from './eventbridge.js';
export {
KafkaMskEventSchema,
KafkaSelfManagedEventSchema,
KafkaRecordSchema,
KafkaSelfManagedEventSchema,
} from './kafka.js';
export {
KinesisDataStreamRecord,
KinesisDataStreamSchema,
KinesisDynamoDBStreamSchema,
KinesisDataStreamRecord,
} from './kinesis.js';
export {
KinesisFirehoseSchema,
KinesisFirehoseSqsSchema,
KinesisFirehoseRecordSchema,
KinesisFirehoseSchema,
KinesisFirehoseSqsRecordSchema,
KinesisFirehoseSqsSchema,
} from './kinesis-firehose.js';
export { LambdaFunctionUrlSchema } from './lambda.js';
export {
S3SqsEventNotificationSchema,
S3EventNotificationEventBridgeSchema,
S3ObjectLambdaEventSchema,
S3Schema,
S3SqsEventNotificationSchema,
} from './s3.js';
export { SesSchema, SesRecordSchema } from './ses.js';
export { SesRecordSchema, SesSchema } from './ses.js';
export {
SnsSchema,
SnsNotificationSchema,
SnsRecordSchema,
SnsSchema,
SnsSqsNotificationSchema,
SnsNotificationSchema,
} from './sns.js';
export {
SqsSchema,
SqsRecordSchema,
SqsMsgAttributeSchema,
SqsMsgAttributeDataTypeSchema,
SqsAttributesSchema,
SqsMsgAttributeDataTypeSchema,
SqsMsgAttributeSchema,
SqsRecordSchema,
SqsSchema,
} from './sqs.js';
export { TransferFamilySchema } from './transfer-family.js';
export { VpcLatticeSchema } from './vpc-lattice.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/schemas/kinesis-firehose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const KinesisFirehoseSqsRecordSchema = KinesisFireHoseRecordBase.extend({
return SqsRecordSchema.parse(
JSON.parse(Buffer.from(data, 'base64').toString('utf8'))
);
} catch (e) {
} catch {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Failed to parse SQS record',
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/src/schemas/kinesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const KinesisDataStreamRecordPayload = z.object({
try {
// If data was not compressed, try to parse it as JSON otherwise it must be string
return decompressed === data ? JSON.parse(decoded) : decompressed;
} catch (e) {
} catch {
return decoded;
}
}),
Expand All @@ -25,7 +25,7 @@ const KinesisDataStreamRecordPayload = z.object({
const decompress = (data: string): string => {
try {
return JSON.parse(gunzipSync(fromBase64(data, 'base64')).toString('utf8'));
} catch (e) {
} catch {
return data;
}
};
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export type {
APIGatewayRequestContextV2,
APIGatewayTokenAuthorizerEvent,
AppSyncBatchResolverEvent,
AppSyncResolverEvent,
AppSyncEventsPublishEvent,
AppSyncEventsSubscribeEvent,
AppSyncResolverEvent,
CloudFormationCustomResourceCreateEvent,
CloudFormationCustomResourceDeleteEvent,
CloudFormationCustomResourceUpdateEvent,
Expand All @@ -37,8 +37,8 @@ export type {
KinesisDataStreamRecordEvent,
KinesisDynamoDBStreamEvent,
KinesisFireHoseEvent,
KinesisFirehoseRecord,
KinesisFireHoseSqsEvent,
KinesisFirehoseRecord,
KinesisFirehoseSqsRecord,
LambdaFunctionUrlEvent,
S3Event,
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/src/types/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { z } from 'zod';
import type {
AlbMultiValueHeadersSchema,
AlbSchema,
APIGatewayEventRequestContextSchema,
APIGatewayProxyEventSchema,
APIGatewayProxyEventV2Schema,
Expand All @@ -8,8 +10,6 @@ import type {
APIGatewayRequestAuthorizerV2Schema,
APIGatewayRequestContextV2Schema,
APIGatewayTokenAuthorizerEventSchema,
AlbMultiValueHeadersSchema,
AlbSchema,
AppSyncBatchResolverSchema,
AppSyncEventsPublishSchema,
AppSyncEventsSubscribeSchema,
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/tests/events/alb/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
},
"body": "Test",
"isBase64Encoded": false
}
}
26 changes: 7 additions & 19 deletions packages/parser/tests/events/alb/multi-fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,16 @@
"path": "/lambda",
"multiValueQueryStringParameters": {},
"multiValueHeaders": {
"accept": [
"*/*"
],
"accept": ["*/*"],
"host": [
"alb-c-LoadB-14POFKYCLBNSF-1815800096.eu-central-1.elb.amazonaws.com"
],
"user-agent": [
"curl/7.79.1"
],
"x-amzn-trace-id": [
"Root=1-62fa9327-21cdd4da4c6db451490a5fb7"
],
"x-forwarded-for": [
"123.123.123.123"
],
"x-forwarded-port": [
"80"
],
"x-forwarded-proto": [
"http"
]
"user-agent": ["curl/7.79.1"],
"x-amzn-trace-id": ["Root=1-62fa9327-21cdd4da4c6db451490a5fb7"],
"x-forwarded-for": ["123.123.123.123"],
"x-forwarded-port": ["80"],
"x-forwarded-proto": ["http"]
},
"body": "Test",
"isBase64Encoded": false
}
}
81 changes: 40 additions & 41 deletions packages/parser/tests/events/apigw-websocket/connectEvent.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
{
"type": "REQUEST",
"methodArn": "arn:aws:execute-api:us-east-1:123456789012:abcdef123/default/$connect",
"headers": {
"Connection": "upgrade",
"content-length": "0",
"Host": "abcdef123.execute-api.us-east-1.amazonaws.com",
"Upgrade": "websocket"
"type": "REQUEST",
"methodArn": "arn:aws:execute-api:us-east-1:123456789012:abcdef123/default/$connect",
"headers": {
"Connection": "upgrade",
"content-length": "0",
"Host": "abcdef123.execute-api.us-east-1.amazonaws.com",
"Upgrade": "websocket"
},
"multiValueHeaders": {
"Connection": ["upgrade"],
"content-length": ["0"],
"Host": ["abcdef123.execute-api.us-east-1.amazonaws.com"],
"Upgrade": ["websocket"]
},
"queryStringParameters": {
"QueryString1": "queryValue1"
},
"multiValueQueryStringParameters": {
"QueryString1": ["queryValue1"]
},
"stageVariables": {},
"requestContext": {
"routeKey": "$connect",
"eventType": "CONNECT",
"extendedRequestId": "XYZ123=",
"requestTime": "10/Oct/2024:22:56:18 +0000",
"messageDirection": "IN",
"stage": "default",
"connectedAt": 1674162806344,
"requestTimeEpoch": 1674162806345,
"identity": {
"sourceIp": "192.0.2.1"
},
"multiValueHeaders": {
"Connection": ["upgrade"],
"content-length": ["0"],
"Host": ["abcdef123.execute-api.us-east-1.amazonaws.com"],
"Upgrade": ["websocket"]
},
"queryStringParameters": {
"QueryString1": "queryValue1"
},
"multiValueQueryStringParameters": {
"QueryString1": ["queryValue1"]
},
"stageVariables": {},
"requestContext": {
"routeKey": "$connect",
"eventType": "CONNECT",
"extendedRequestId": "XYZ123=",
"requestTime": "10/Oct/2024:22:56:18 +0000",
"messageDirection": "IN",
"stage": "default",
"connectedAt": 1674162806344,
"requestTimeEpoch": 1674162806345,
"identity": {
"sourceIp": "192.0.2.1"
},
"requestId": "abc123",
"domainName": "abcdef123.execute-api.us-east-1.amazonaws.com",
"connectionId": "def456",
"apiId": "abcdef123"
},
"isBase64Encoded": false,
"body": null
}

"requestId": "abc123",
"domainName": "abcdef123.execute-api.us-east-1.amazonaws.com",
"connectionId": "def456",
"apiId": "abcdef123"
},
"isBase64Encoded": false,
"body": null
}
Loading