Skip to content

Commit c5bcdab

Browse files
committed
fixed return type to array for specific envelopes
1 parent 3cedd9f commit c5bcdab

File tree

7 files changed

+8
-12
lines changed

7 files changed

+8
-12
lines changed

packages/parser/src/envelopes/cloudwatch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class CloudWatchEnvelope extends Envelope {
1717
public static parse<T extends ZodSchema>(
1818
data: unknown,
1919
schema: T
20-
): z.infer<T> {
20+
): z.infer<T>[] {
2121
const parsedEnvelope = CloudWatchLogsSchema.parse(data);
2222

2323
return parsedEnvelope.awslogs.data.logEvents.map((record) => {

packages/parser/src/envelopes/dynamodb.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { DynamoDBStreamSchema } from '../schemas/index.js';
33
import type { ParsedResult, ParsedResultError } from '../types/index.js';
44
import { Envelope } from './envelope.js';
55
import { ParseError } from '../errors.js';
6-
7-
type DynamoDBStreamEnvelopeResponse<T extends ZodSchema> = {
8-
NewImage: z.infer<T>;
9-
OldImage: z.infer<T>;
10-
};
6+
import type { DynamoDBStreamEnvelopeResponse } from '../types/envelope.js';
117

128
/**
139
* DynamoDB Stream Envelope to extract data within NewImage/OldImage

packages/parser/src/envelopes/kafka.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class KafkaEnvelope extends Envelope {
2020
public static parse<T extends ZodSchema>(
2121
data: unknown,
2222
schema: T
23-
): z.infer<T> {
23+
): z.infer<T>[] {
2424
// manually fetch event source to deside between Msk or SelfManaged
2525
const eventSource = (data as KafkaMskEvent)['eventSource'];
2626

packages/parser/src/envelopes/kinesis-firehose.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class KinesisFirehoseEnvelope extends Envelope {
2020
public static parse<T extends ZodSchema>(
2121
data: unknown,
2222
schema: T
23-
): z.infer<T> {
23+
): z.infer<T>[] {
2424
const parsedEnvelope = KinesisFirehoseSchema.parse(data);
2525

2626
return parsedEnvelope.records.map((record) => {

packages/parser/src/envelopes/kinesis.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class KinesisEnvelope extends Envelope {
1818
public static parse<T extends ZodSchema>(
1919
data: unknown,
2020
schema: T
21-
): z.infer<T> {
21+
): z.infer<T>[] {
2222
const parsedEnvelope = KinesisDataStreamSchema.parse(data);
2323

2424
return parsedEnvelope.Records.map((record) => {

packages/parser/src/envelopes/sns.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class SnsEnvelope extends Envelope {
1818
public static parse<T extends ZodSchema>(
1919
data: unknown,
2020
schema: T
21-
): z.infer<T> {
21+
): z.infer<T>[] {
2222
const parsedEnvelope = SnsSchema.parse(data);
2323

2424
return parsedEnvelope.Records.map((record) => {

packages/parser/src/envelopes/sqs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import { ParseError } from '../errors.js';
99
*
1010
* The record's body parameter is a string, though it can also be a JSON encoded string.
1111
* Regardless of its type it'll be parsed into a BaseModel object.
12-
*
12+
*w
1313
* Note: Records will be parsed the same way so if model is str,
1414
* all items in the list will be parsed as str and npt as JSON (and vice versa)
1515
*/
1616
export class SqsEnvelope extends Envelope {
1717
public static parse<T extends ZodSchema>(
1818
data: unknown,
1919
schema: T
20-
): z.infer<T> {
20+
): z.infer<T>[] {
2121
const parsedEnvelope = SqsSchema.parse(data);
2222

2323
return parsedEnvelope.Records.map((record) => {

0 commit comments

Comments
 (0)