Skip to content
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

Feature request: allow parser set event type of handler with middy #2407

Closed
2 tasks done
yamatatsu opened this issue Apr 21, 2024 · 3 comments · Fixed by #2786
Closed
2 tasks done

Feature request: allow parser set event type of handler with middy #2407

yamatatsu opened this issue Apr 21, 2024 · 3 comments · Fixed by #2786
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility parser This item relates to the Parser Utility

Comments

@yamatatsu
Copy link
Contributor

Use case

middy can pass event type like as this. So we can pass inferred event type from zod schema to handler.

Solution/User Experience

const detailSchema = z.object({
	date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
	message: z.string(),
});

export const handler = middy()
	// when using parser
	.use(parser({ schema: detailSchema, envelope: EventBridgeEnvelope }))
	// handler will get event type already inferred without type annotation.
	.handler(async (event) => {
		logger.inf(event.detail.message)
	});

Alternative solutions

No response

Acknowledgment

Future readers

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

@yamatatsu yamatatsu added triage This item has not been triaged by a maintainer, please wait feature-request This item refers to a feature request for an existing or new utility labels Apr 21, 2024
@yamatatsu yamatatsu changed the title Feature request: allow parser set event type of handler with meddy Feature request: allow parser set event type of handler with middy Apr 21, 2024
@am29d
Copy link
Contributor

am29d commented Apr 22, 2024

Hey @yamatatsu, thanks for raising the issue.

In your example, I think you missed the types in the middy() call. Can you modify the solution code block to reflect that? In the meantime, I will investigate how we could add event types to middy call.

Edit: now that Andrea pointed out to me, I got your point more clearly. You want to infer the type in the handler if it comes after the parser. I'd need to investigate a bit more what it will take to implement it.

@am29d am29d added discussing The issue needs to be discussed, elaborated, or refined and removed triage This item has not been triaged by a maintainer, please wait labels Apr 22, 2024
@dreamorosi dreamorosi added this to the Parser - GA Release milestone Apr 22, 2024
@dreamorosi dreamorosi added the parser This item relates to the Parser Utility label Jun 3, 2024
@heitorlessa heitorlessa added the help-wanted We would really appreciate some support from community for this one label Jun 11, 2024
@heitorlessa heitorlessa removed this from the Parser - GA Release milestone Jun 11, 2024
@dreamorosi dreamorosi added this to the Parser - GA Release milestone Jul 9, 2024
@dreamorosi dreamorosi assigned dreamorosi and am29d and unassigned dreamorosi Jul 9, 2024
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added pending-release This item has been merged and will be released soon and removed help-wanted We would really appreciate some support from community for this one discussing The issue needs to be discussed, elaborated, or refined labels Jul 22, 2024
Copy link
Contributor

This is now released under v2.6.0 version!

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility parser This item relates to the Parser Utility
Projects
4 participants