Skip to content

Feature request: Add named type for values parsed by DynamoDBStreamRecord[Schema] #4784

@benthorner

Description

@benthorner

Use case

There's no named type for values parsed by DynamoDBStreamRecord (the schema) 1:

const DynamoDBStreamRecord = z.object({...

Conversely, there is a named type for the overall Stream (Event) 2:

type DynamoDBStreamEvent = z.infer<typeof DynamoDBStreamSchema>;

While the documentation encourages overriding the schemas 3, in our app we want to defer this and therefore pass values conforming to the original "raw" or "base" DynamoDBStreamRecord schema. Hence wanting to import a type for values parsed by the schema.

Although this is just a one-liner, it would be nice not to have to write it in our app.

Solution/User Experience

Add the following in packages/parser/src/types/schema.ts:

import { DynamoDBStreamRecord as DynamoDBStreamRecordSchema } from '../schemas/index.js'

...

type DynamoDBStreamRecord = z.infer<typeof DynamoDBStreamRecordSchema>;

Alternative solutions

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Footnotes

  1. https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/packages/parser/src/schemas/dynamodb.ts

  2. https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/packages/parser/src/types/schema.ts#L104

  3. https://docs.aws.amazon.com/powertools/typescript/latest/features/parser/#dynamodb-stream-event-parsing

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityparserThis item relates to the Parser Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions