SnsSqsEnvelope: {
    parse<T extends ZodType>(data: unknown, schema: T): TypeOf<T>[];
    safeParse<T extends ZodType>(
        data: unknown,
        schema: T,
    ): ParsedResult<unknown, TypeOf<T>[]>;
} = ...

SNS plus SQS Envelope to extract array of Records

Published messages from SNS to SQS has a slightly different payload structure than regular SNS messages, and when sent to SQS, they are stringified into the body field of each SQS record.

To parse the Message field of the SNS notification, we need to:

  1. Parse SQS schema with incoming data
  2. JSON.parse() the SNS payload and parse against SNS Notification schema
  3. Finally, parse the payload against the provided schema

Type declaration