-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(parser): DynamoDBMarshalled
helper to parse DynamoDB data structure
#3442
base: main
Are you sure you want to change the base?
feat(parser): DynamoDBMarshalled
helper to parse DynamoDB data structure
#3442
Conversation
Quality Gate passedIssues Measures |
*/ | ||
const DynamoDBMarshalled = <T extends ZodTypeAny>(schema: T) => | ||
z | ||
.record(z.string(), z.custom<AttributeValue>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would appreciate suggestions on using this type.
Setting the type to unknown
causes a TypeScript error. The @aws-sdk/util-dynamodb
package has a peer dependency on @aws-sdk/client-dynamodb
and we are using the AttributeValue
type from @aws-sdk/client-dynamodb
. Should we also declare @aws-sdk/client-dynamodb
as a peer dependency?
Alternatively, we could set the type to unknown
and suppress the TypeScript error using biome-ignore
, though I would prefer to avoid this approach.
Summary
When working with Amazon DynamoDB Stream events, the service sends the DynamoDB items in the database-specific format rather than regular JSON objects.
For example, a string might be represented as { "S": "foo" } rather than just foo. This makes parsing the actual changes within an event hard to parse and validate since it requires customers writing a Zod schema with this in mind.
This PR introduces a helper function
DynamoDBMarshalled
to work this structureChanges
Issue number: #3194
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.