API Reference
    Preparing search index...
    DynamoDBStreamToKinesisRecord: ZodObject<
        Omit<
            extendShape<
                {
                    awsRegion: ZodString;
                    dynamodb: ZodEffects<
                        ZodObject<
                            {
                                ApproximateCreationDateTime: ZodOptional<ZodNumber>;
                                Keys: ZodRecord<ZodString, ZodRecord<ZodString, ZodAny>>;
                                NewImage: ZodOptional<ZodRecord<ZodString, ZodAny>>;
                                OldImage: ZodOptional<ZodRecord<ZodString, ZodAny>>;
                                SequenceNumber: ZodString;
                                SizeBytes: ZodNumber;
                                StreamViewType: ZodEnum<
                                    ["NEW_IMAGE", "OLD_IMAGE", "NEW_AND_OLD_IMAGES", "KEYS_ONLY"],
                                >;
                            },
                            "strip",
                            ZodTypeAny,
                            {
                                ApproximateCreationDateTime?: number;
                                Keys: Record<string, Record<string, any>>;
                                NewImage?: Record<string, any>;
                                OldImage?: Record<string, any>;
                                SequenceNumber: string;
                                SizeBytes: number;
                                StreamViewType:
                                    | "NEW_IMAGE"
                                    | "OLD_IMAGE"
                                    | "NEW_AND_OLD_IMAGES"
                                    | "KEYS_ONLY";
                            },
                            {
                                ApproximateCreationDateTime?: number;
                                Keys: Record<string, Record<string, any>>;
                                NewImage?: Record<string, any>;
                                OldImage?: Record<string, any>;
                                SequenceNumber: string;
                                SizeBytes: number;
                                StreamViewType:
                                    | "NEW_IMAGE"
                                    | "OLD_IMAGE"
                                    | "NEW_AND_OLD_IMAGES"
                                    | "KEYS_ONLY";
                            },
                        >,
                        {
                            ApproximateCreationDateTime?: number;
                            Keys: Record<string, Record<string, any>>;
                            NewImage?: Record<string, any>;
                            OldImage?: Record<string, any>;
                            SizeBytes: number;
                        },
                        {
                            ApproximateCreationDateTime?: number;
                            Keys: Record<string, Record<string, any>>;
                            NewImage?: Record<string, any>;
                            OldImage?: Record<string, any>;
                            SequenceNumber: string;
                            SizeBytes: number;
                            StreamViewType:
                                | "NEW_IMAGE"
                                | "OLD_IMAGE"
                                | "NEW_AND_OLD_IMAGES"
                                | "KEYS_ONLY";
                        },
                    >;
                    eventID: ZodString;
                    eventName: ZodEnum<["INSERT", "MODIFY", "REMOVE"]>;
                    eventSource: ZodLiteral<"aws:dynamodb">;
                    eventSourceARN: ZodString;
                    eventVersion: ZodString;
                    userIdentity: ZodOptional<
                        ZodObject<
                            {
                                principalId: ZodLiteral<"dynamodb.amazonaws.com">;
                                type: ZodEnum<["Service"]>;
                            },
                            "strip",
                            ZodTypeAny,
                            { principalId: "dynamodb.amazonaws.com"; type: "Service" },
                            { principalId: "dynamodb.amazonaws.com"; type: "Service" },
                        >,
                    >;
                },
                {
                    dynamodb: ZodEffects<
                        ZodObject<
                            Omit<
                                {
                                    ApproximateCreationDateTime: ZodOptional<ZodNumber>;
                                    Keys: ZodRecord<ZodString, ZodRecord<ZodString, ZodAny>>;
                                    NewImage: ZodOptional<ZodRecord<ZodString, ZodAny>>;
                                    OldImage: ZodOptional<ZodRecord<ZodString, ZodAny>>;
                                    SequenceNumber: ZodString;
                                    SizeBytes: ZodNumber;
                                    StreamViewType: ZodEnum<
                                        ["NEW_IMAGE", "OLD_IMAGE", "NEW_AND_OLD_IMAGES", "KEYS_ONLY"],
                                    >;
                                },
                                "SequenceNumber"
                                | "StreamViewType",
                            >,
                            "strip",
                            ZodTypeAny,
                            {
                                ApproximateCreationDateTime?: number;
                                Keys: Record<string, Record<string, any>>;
                                NewImage?: Record<string, any>;
                                OldImage?: Record<string, any>;
                                SizeBytes: number;
                            },
                            {
                                ApproximateCreationDateTime?: number;
                                Keys: Record<string, Record<string, any>>;
                                NewImage?: Record<string, any>;
                                OldImage?: Record<string, any>;
                                SizeBytes: number;
                            },
                        >,
                        {
                            ApproximateCreationDateTime?: number;
                            Keys: Record<string, Record<string, any>>;
                            NewImage?: Record<string, any>;
                            OldImage?: Record<string, any>;
                            SizeBytes: number;
                        },
                        {
                            ApproximateCreationDateTime?: number;
                            Keys: Record<string, Record<string, any>>;
                            NewImage?: Record<string, any>;
                            OldImage?: Record<string, any>;
                            SizeBytes: number;
                        },
                    >;
                    recordFormat: ZodLiteral<"application/json">;
                    tableName: ZodString;
                    userIdentity: ZodOptional<
                        ZodNullable<
                            ZodObject<
                                {
                                    principalId: ZodLiteral<"dynamodb.amazonaws.com">;
                                    type: ZodEnum<["Service"]>;
                                },
                                "strip",
                                ZodTypeAny,
                                { principalId: "dynamodb.amazonaws.com"; type: "Service" },
                                { principalId: "dynamodb.amazonaws.com"; type: "Service" },
                            >,
                        >,
                    >;
                },
            >,
            "eventVersion"
            | "eventSourceARN",
        >,
        "strip",
        ZodTypeAny,
        {
            awsRegion: string;
            dynamodb: {
                ApproximateCreationDateTime?: number;
                Keys: Record<string, Record<string, any>>;
                NewImage?: Record<string, any>;
                OldImage?: Record<string, any>;
                SizeBytes: number;
            };
            eventID: string;
            eventName: "INSERT"
            | "MODIFY"
            | "REMOVE";
            eventSource: "aws:dynamodb";
            recordFormat: "application/json";
            tableName: string;
            userIdentity?:
                | null
                | { principalId: "dynamodb.amazonaws.com"; type: "Service" };
        },
        {
            awsRegion: string;
            dynamodb: {
                ApproximateCreationDateTime?: number;
                Keys: Record<string, Record<string, any>>;
                NewImage?: Record<string, any>;
                OldImage?: Record<string, any>;
                SizeBytes: number;
            };
            eventID: string;
            eventName: "INSERT"
            | "MODIFY"
            | "REMOVE";
            eventSource: "aws:dynamodb";
            recordFormat: "application/json";
            tableName: string;
            userIdentity?:
                | null
                | { principalId: "dynamodb.amazonaws.com"; type: "Service" };
        },
    > = ...

    Zod schema for Amazon DynamoDB Stream event sent to an Amazon Kinesis Stream.

    This schema is best used in conjunction with the KinesisEnvelope when you want to work with the DynamoDB stream event coming from an Amazon Kinesis Stream.

    By default, we unmarshall the dynamodb.Keys, dynamodb.NewImage, and dynamodb.OldImage fields for you.

    If you want to extend the schema and provide your own Zod schema for any of these fields, you can use the DynamoDBMarshalled helper. In that case, we won't unmarshall the other fields.

    To extend the schema, you can use the DynamoDBStreamToKinesisRecord child schema and the DynamoDBMarshalled helper together.

    import {
    DynamoDBStreamToKinesisRecord,
    DynamoDBStreamToKinesisChangeRecord,
    } from '@aws-lambda-powertools/parser/schemas/dynamodb';
    import { KinesisEnvelope } from '@aws-lambda-powertools/parser/envelopes/dynamodb';
    import { DynamoDBMarshalled } from '@aws-lambda-powertools/parser/helpers/dynamodb';

    const CustomSchema = DynamoDBStreamToKinesisRecord.extend({
    dynamodb: DynamoDBStreamToKinesisChangeRecord.extend({
    NewImage: DynamoDBMarshalled(
    z.object({
    id: z.string(),
    attribute: z.number(),
    stuff: z.array(z.string()),
    })
    ),
    // Add the lines below only if you want these keys to be unmarshalled
    Keys: DynamoDBMarshalled(z.unknown()),
    OldImage: DynamoDBMarshalled(z.unknown()),
    }),
    });

    type CustomEvent = z.infer<typeof CustomSchema>;