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: provide custom functions for JMESPath expressions #1298

Closed
1 of 2 tasks
saragerion opened this issue Feb 17, 2023 · 5 comments · Fixed by #2364
Closed
1 of 2 tasks

Feature request: provide custom functions for JMESPath expressions #1298

saragerion opened this issue Feb 17, 2023 · 5 comments · Fixed by #2364
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 jmespath This item relates to the JMESPath Utility

Comments

@saragerion
Copy link
Contributor

saragerion commented Feb 17, 2023

Use case

When making their functions idempotent, users can apply JMESPath selectors that will be used to filter the event payload and/or perform validations.

In Powertools for Python, the Idempotency utility features some helper functions that allow to extend the JMESPath spec and apply transformations to the result of a selection:

image

The functions are defined here and used in the search here. Powertools for Python also exposes a number of common payload expressions which require the functions and are related to AWS Lambda events.

Solution/User Experience

N/A

Alternative solutions

No response

Acknowledgment

@saragerion saragerion 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 Feb 17, 2023
@saragerion saragerion added this to the Idempotency - Beta release milestone Feb 17, 2023
@saragerion saragerion added the idempotency This item relates to the Idempotency Utility label Feb 17, 2023
@dreamorosi dreamorosi changed the title Feature request (idempotency): Custom Config - JMESPath options to be included when filtering expr Feature request: Custom Config - JMESPath options to be included when filtering expr Feb 17, 2023
@dreamorosi dreamorosi 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 Feb 17, 2023
@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation and removed discussing The issue needs to be discussed, elaborated, or refined labels Mar 20, 2023
@dreamorosi
Copy link
Contributor

The module used to implement JMESPath functions introduced in #1376 (jmespath) doesn't support passing options / using custom functions:
jmespath/jmespath.js#30
jmespath/jmespath.js#25

There is however another package called @metrichor/jmespath that appears to be a spec-compliant rewrite of the project made in TS and that supports custom functions. This version appears to be more similar to the Python implementation as it also allows to precompile expressions for later usage.

We should evaluate how important this feature is and consider potentially this alternative library.

@dreamorosi dreamorosi added discussing The issue needs to be discussed, elaborated, or refined need-more-information Requires more information before making any calls and removed confirmed The scope is clear, ready for implementation labels Mar 20, 2023
@dreamorosi dreamorosi changed the title Feature request: Custom Config - JMESPath options to be included when filtering expr Feature request: provide custom functions for JMSPath expressions Mar 20, 2023
@dreamorosi dreamorosi changed the title Feature request: provide custom functions for JMSPath expressions Feature request: provide custom functions for JMESPath expressions Mar 30, 2023
@dreamorosi
Copy link
Contributor

While addressing this issue, consider testing different inputs for the isMissingIdempotencyKey function that is part of the BasePersistenceLayer. This function tests the output of a JMESPath search and we should make sure that it works correctly.

@dreamorosi dreamorosi self-assigned this Sep 13, 2023
@dreamorosi dreamorosi added on-hold This item is on-hold and will be revisited in the future and removed discussing The issue needs to be discussed, elaborated, or refined need-more-information Requires more information before making any calls labels Sep 13, 2023
@dreamorosi dreamorosi removed this from the Idempotency - GA Release milestone Sep 13, 2023
@dreamorosi dreamorosi added jmespath This item relates to the JMESPath Utility and removed idempotency This item relates to the Idempotency Utility labels Sep 13, 2023
@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation and removed on-hold This item is on-hold and will be revisited in the future labels Sep 26, 2023
@dreamorosi dreamorosi added this to the Version 2.0 milestone Sep 26, 2023
@gabrielleandro0801
Copy link

Hi!

As I mentioned in #2029, I'm also interested in this feature. It would be very useful to have these custom helper functions in Typescript so that we could customize our idempotency validations.

Thanks!

@dreamorosi dreamorosi linked a pull request Feb 24, 2024 that will close this issue
9 tasks
@dreamorosi dreamorosi removed this from the Version 2.0 milestone Apr 4, 2024
@dreamorosi dreamorosi linked a pull request Apr 15, 2024 that will close this issue
9 tasks
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 confirmed The scope is clear, ready for implementation labels Apr 16, 2024
Copy link
Contributor

This is now released under v2.1.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 Apr 18, 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 jmespath This item relates to the JMESPath Utility
Projects
3 participants