powertools-lambda-typescript icon indicating copy to clipboard operation
powertools-lambda-typescript copied to clipboard

Feature request: provide custom functions for JMESPath expressions

Open saragerion opened this issue 2 years ago • 3 comments

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 avatar Feb 17 '23 13:02 saragerion

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 avatar Mar 20 '23 00:03 dreamorosi

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 avatar Mar 30 '23 16:03 dreamorosi

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!

gabrielleandro0801 avatar Feb 07 '24 12:02 gabrielleandro0801

⚠️ 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[bot] avatar Apr 16 '24 15:04 github-actions[bot]

This is now released under v2.1.0 version!

github-actions[bot] avatar Apr 18 '24 09:04 github-actions[bot]