API Reference
    Preparing search index...
    • Parse the data using the provided schema and optional envelope.

      Type Parameters

      • T extends StandardSchemaV1<unknown, unknown>

      Parameters

      • data: unknown

        the data to parse

      • envelope: undefined

        optional envelope to use when parsing the data

      • schema: T

        the schema to use

      • OptionalsafeParse: false

        whether to throw on error, if true it will return a ParsedResult with the original event if the parsing fails

      Returns InferOutput<T>

      import { z } from 'zod';
      import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
      import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
      import { parse } from '@aws-lambda-powertools/parser';

      const Order = z.object({
      orderId: z.string(),
      description: z.string(),
      });

      const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
      const parsedEvent = parse(event, SqsEnvelope, Order);
      }
    • Parse the data using the provided schema and optional envelope.

      Type Parameters

      • T extends StandardSchemaV1<unknown, unknown>

      Parameters

      • data: unknown

        the data to parse

      • envelope: undefined

        optional envelope to use when parsing the data

      • schema: T

        the schema to use

      • safeParse: true

        whether to throw on error, if true it will return a ParsedResult with the original event if the parsing fails

      Returns ParsedResult<unknown, InferOutput<T>>

      import { z } from 'zod';
      import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
      import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
      import { parse } from '@aws-lambda-powertools/parser';

      const Order = z.object({
      orderId: z.string(),
      description: z.string(),
      });

      const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
      const parsedEvent = parse(event, SqsEnvelope, Order);
      }
    • Parse the data using the provided schema and optional envelope.

      Type Parameters

      • T extends StandardSchemaV1<unknown, unknown>

      Parameters

      • data: unknown

        the data to parse

      • envelope: undefined

        optional envelope to use when parsing the data

      • schema: T

        the schema to use

      • safeParse: boolean

        whether to throw on error, if true it will return a ParsedResult with the original event if the parsing fails

      Returns InferOutput<T> | ParsedResult<unknown, InferOutput<T>>

      import { z } from 'zod';
      import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
      import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
      import { parse } from '@aws-lambda-powertools/parser';

      const Order = z.object({
      orderId: z.string(),
      description: z.string(),
      });

      const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
      const parsedEvent = parse(event, SqsEnvelope, Order);
      }
    • Parse the data using the provided schema and optional envelope.

      Type Parameters

      • T extends StandardSchemaV1<unknown, unknown>
      • E extends Envelope

      Parameters

      • data: unknown

        the data to parse

      • envelope: E

        optional envelope to use when parsing the data

      • schema: T

        the schema to use

      • OptionalsafeParse: false

        whether to throw on error, if true it will return a ParsedResult with the original event if the parsing fails

      Returns E extends DynamoDBArrayEnvelope
          ? DynamoDBStreamEnvelopeResponse<InferOutput<T>>[]
          : E extends ArrayEnvelope ? InferOutput<T>[] : InferOutput<T>

      import { z } from 'zod';
      import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
      import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
      import { parse } from '@aws-lambda-powertools/parser';

      const Order = z.object({
      orderId: z.string(),
      description: z.string(),
      });

      const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
      const parsedEvent = parse(event, SqsEnvelope, Order);
      }
    • Parse the data using the provided schema and optional envelope.

      Type Parameters

      • T extends StandardSchemaV1<unknown, unknown>
      • E extends Envelope

      Parameters

      • data: unknown

        the data to parse

      • envelope: E

        optional envelope to use when parsing the data

      • schema: T

        the schema to use

      • safeParse: true

        whether to throw on error, if true it will return a ParsedResult with the original event if the parsing fails

      Returns E extends DynamoDBArrayEnvelope
          ? ParsedResult<
              unknown,
              DynamoDBStreamEnvelopeResponse<InferOutput<T>>[],
          >
          : E extends ArrayEnvelope
              ? ParsedResult<unknown, InferOutput<T>[]>
              : ParsedResult<unknown, InferOutput<T>>

      import { z } from 'zod';
      import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
      import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
      import { parse } from '@aws-lambda-powertools/parser';

      const Order = z.object({
      orderId: z.string(),
      description: z.string(),
      });

      const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
      const parsedEvent = parse(event, SqsEnvelope, Order);
      }
    • Parse the data using the provided schema and optional envelope.

      Type Parameters

      • T extends StandardSchemaV1<unknown, unknown>

      Parameters

      • data: unknown

        the data to parse

      • envelope: undefined

        optional envelope to use when parsing the data

      • schema: T

        the schema to use

      • OptionalsafeParse: boolean

        whether to throw on error, if true it will return a ParsedResult with the original event if the parsing fails

      Returns InferOutput<T> | ParsedResult<unknown, InferOutput<T>>

      import { z } from 'zod';
      import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
      import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
      import { parse } from '@aws-lambda-powertools/parser';

      const Order = z.object({
      orderId: z.string(),
      description: z.string(),
      });

      const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
      const parsedEvent = parse(event, SqsEnvelope, Order);
      }
    • Parse the data using the provided schema and optional envelope.

      Type Parameters

      • T extends StandardSchemaV1<unknown, unknown>
      • E extends Envelope

      Parameters

      • data: unknown

        the data to parse

      • envelope: E

        optional envelope to use when parsing the data

      • schema: T

        the schema to use

      • OptionalsafeParse: boolean

        whether to throw on error, if true it will return a ParsedResult with the original event if the parsing fails

      Returns E extends DynamoDBArrayEnvelope
          ? | DynamoDBStreamEnvelopeResponse<InferOutput<T>>[]
          | ParsedResult<unknown, DynamoDBStreamEnvelopeResponse<InferOutput<T>>[]>
          : E extends ArrayEnvelope
              ? InferOutput<T>[]
              | ParsedResult<unknown, InferOutput<T>[]>
              : InferOutput<T> | ParsedResult<unknown, InferOutput<T>>

      import { z } from 'zod';
      import type { SqsEvent, ParsedResult } from '@aws-lambda-powertools/parser/types';
      import { SqsEnvelope } from '@aws-lambda-powertools/parser/types/envelopes';
      import { parse } from '@aws-lambda-powertools/parser';

      const Order = z.object({
      orderId: z.string(),
      description: z.string(),
      });

      const handler = async (event: SqsEvent, context: unknown): Promise<unknown> => {
      const parsedEvent = parse(event, SqsEnvelope, Order);
      }