Gathering detailed insights and metrics for @aws-lambda-powertools/jmespath
Gathering detailed insights and metrics for @aws-lambda-powertools/jmespath
Gathering detailed insights and metrics for @aws-lambda-powertools/jmespath
Gathering detailed insights and metrics for @aws-lambda-powertools/jmespath
Powertools for AWS is a developer toolkit to implement Serverless best practices and increase developer velocity.
npm install @aws-lambda-powertools/jmespath
Typescript
Module System
Node Version
NPM Version
TypeScript (97.91%)
JavaScript (2.06%)
Dockerfile (0.03%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT-0 License
1,681 Stars
2,540 Commits
160 Forks
27 Watchers
9 Branches
83 Contributors
Updated on Jul 11, 2025
Latest Version
2.23.0
Package Id
@aws-lambda-powertools/jmespath@2.23.0
Unpacked Size
332.36 kB
Size
43.41 kB
File Count
96
NPM Version
lerna/8.1.2/node@v22.16.0+x64 (linux)
Node Version
22.16.0
Published on
Jul 02, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serverless best practices and increase developer velocity.
You can use the package in both TypeScript and JavaScript code bases.
The JMESPath utility is a high-level function to parse and extract data from JSON objects using JMESPath expressions.
To get started, install the library by running:
1npm i @aws-lambda-powertools/jmespath
At its core, the library provides a utility function to extract data from a JSON object using a JMESPath expression.
1import { search } from '@aws-lambda-powertools/jmespath'; 2import { Logger } from '@aws-lambda-powertools/logger'; 3 4const logger = new Logger(); 5 6type MyEvent = { 7 foo: { 8 bar: string; 9 }; 10} 11 12export const handler = async (event: MyEvent): Promise<void> => { 13 const result = search(event, 'foo.bar'); 14 logger.info(result); // "baz" 15};
In some cases, you may want to extract data from an envelope. The library provides a utility function to help you work with envelopes and extract data from them.
1import { extractDataFromEnvelope } from '@aws-lambda-powertools/jmespath/envelopes'; 2 3type MyEvent = { 4 body: string; // "{\"customerId\":\"dd4649e6-2484-4993-acb8-0f9123103394\"}" 5 deeplyNested: Array<{ someData: number[] }>; 6}; 7 8type MessageBody = { 9 customerId: string; 10}; 11 12export const handler = async (event: MyEvent): Promise<unknown> => { 13 const payload = extractDataFromEnvelope<MessageBody>( 14 event, 15 'powertools_json(body)' 16 ); 17 const { customerId } = payload; // now deserialized 18 19 // also works for fetching and flattening deeply nested data 20 const someData = extractDataFromEnvelope<number[]>( 21 event, 22 'deeplyNested[*].someData[]' 23 ); 24 25 return { 26 customerId, 27 message: 'success', 28 context: someData, 29 statusCode: 200, 30 }; 31};
The library provides a set of built-in envelopes to help you extract data from common event sources, such as S3, SQS, and SNS, and more.
1import { 2 extractDataFromEnvelope, 3 SQS, 4} from '@aws-lambda-powertools/jmespath/envelopes'; 5import { Logger } from '@aws-lambda-powertools/logger'; 6import type { SQSEvent } from 'aws-lambda'; 7 8const logger = new Logger(); 9 10type MessageBody = { 11 customerId: string; 12}; 13 14export const handler = async (event: SQSEvent): Promise<void> => { 15 const records = extractDataFromEnvelope<Array<MessageBody>>(event, SQS); 16 for (const record of records) { 17 // records is now a list containing the deserialized body of each message 18 const { customerId } = record; 19 logger.appendKeys({ customerId }); 20 } 21};
In addition to all the built-in JMESPath functions, the library provides custom functions to help you work with complex data structures. For example, you can use the powertools_json
function to parse a JSON string, or the powertools_base64
function to decode a base64-encoded string:
1import { extractDataFromEnvelope } from '@aws-lambda-powertools/jmespath/envelopes'; 2import { Logger } from '@aws-lambda-powertools/logger'; 3 4const logger = new Logger(); 5 6export const handler = async (event: { payload: string }): Promise<void> => { 7 const data = extractDataFromEnvelope<string>( 8 event, 9 'powertools_json(powertools_base64(payload))' 10 ); 11 12 logger.info('Decoded payload', { data }); 13};
Finally, you can also extend the library with your own custom functions. Below an example of how to create a custom function to decode a Brotli-compressed string.
1import { fromBase64 } from '@aws-lambda-powertools/commons/utils/base64'; 2import { extractDataFromEnvelope } from '@aws-lambda-powertools/jmespath/envelopes'; 3import { PowertoolsFunctions } from '@aws-lambda-powertools/jmespath/functions'; 4import { Logger } from '@aws-lambda-powertools/logger'; 5import { brotliDecompressSync } from 'node:zlib'; 6 7const logger = new Logger(); 8 9class CustomFunctions extends PowertoolsFunctions { 10 @PowertoolsFunctions.signature({ 11 argumentsSpecs: [['string']], 12 variadic: false, 13 }) 14 public funcDecodeBrotliCompression(value: string): string { 15 const encoded = fromBase64(value, 'base64'); 16 const uncompressed = brotliDecompressSync(encoded); 17 18 return uncompressed.toString(); 19 } 20} 21 22export const handler = async (event: { payload: string }): Promise<void> => { 23 const message = extractDataFromEnvelope<string>( 24 event, 25 'Records[*].decode_brotli_compression(notification) | [*].powertools_json(@).message', 26 { customFunctions: new CustomFunctions() } 27 ); 28 29 logger.info('Decoded message', { message }); 30};
If you are interested in contributing to this project, please refer to our Contributing Guidelines.
The roadmap of Powertools for AWS Lambda (TypeScript) is driven by customers’ demand.
Help us prioritize upcoming functionalities or utilities by upvoting existing RFCs and feature requests, or creating new ones, in this GitHub repository.
#typescript
- Invite linkKnowing which companies are using this library is important to help prioritize the project internally. If your company is using Powertools for AWS Lambda (TypeScript), you can request to have your name and logo added to the README file by raising a Support Powertools for AWS Lambda (TypeScript) (become a reference) issue.
The following companies, among others, use Powertools:
Share what you did with Powertools for AWS Lambda (TypeScript) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (TypeScript).
This helps us understand who uses Powertools for AWS Lambda (TypeScript) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When using Layers, you can add Powertools as a dev dependency to not impact the development process.
This library is licensed under the MIT-0 License. See the LICENSE file.
No vulnerabilities found.
Reason
update tool detected
Details
Reason
30 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
all dependencies are pinned
Details
Reason
license file detected
Details
Reason
30 out of 30 merged PRs checked by a CI test -- score normalized to 10
Reason
project has 10 contributing companies or organizations
Details
Reason
SAST tool is not run on all commits -- score normalized to 9
Details
Reason
3 existing vulnerabilities detected
Details
Reason
badge detected: Passing
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-12T09:00:58Z
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More