generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 174
Closed
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityparserThis item relates to the Parser UtilityThis item relates to the Parser Utility
Milestone
Description
Use case
Similar to the python implementation we want to have reusable envelopes that we can extend with custom schema.
Solution/User Experience
Envelopes encapsulate the provided custom model in a built-in schema. This means that they parse specific part of the event detail
for EventBridge or body
for SQS.
const eventBridgeEnvelope = (<T extends ZodSchema>(data: unknown, schema: T) => {
return schema.parse(EventBridgeSchema.parse(data).detail);
});
This will allow us to bring your own custom schema:
const customSchema = z.object({
foo: z.string()
})
type CustomSchema = z.infer<typeof customSchema>;
const customEventBridgeEvent: CustomSchema = eventBridgeEnvelope({foo: 'bar'}, customSchema);
While is a one line, it'd be great to provide a bit more debug logs around both calls. It's worth emphasise that envelopes do not return schemas, but the parsed object of the custom schema.
Alternative solutions
No response
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
completedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilityThis item refers to a feature request for an existing or new utilityparserThis item relates to the Parser UtilityThis item relates to the Parser Utility
Type
Projects
Status
Shipped