Skip to content

Commit 1f106bd

Browse files
committed
Merge branch 'chore/esm_e2e_test' of github.com:aws-powertools/powertools-lambda-typescript into chore/esm_e2e_test
2 parents 7e964c0 + c166d05 commit 1f106bd

File tree

11 files changed

+75
-19
lines changed

11 files changed

+75
-19
lines changed

.github/actions/cached-node-modules/action.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ runs:
3434
- name: Build packages
3535
# Regardless of whether the cache was hit or not, we need to build the packages, unless the caller says otherwise
3636
if: inputs.build == 'true'
37-
# We build the shared package first, then the others in parallel to speed up the process
37+
# We build the commons and jmspath packages first, then the others in parallel to speed up the process
3838
# even though we could just run `npm run build` in the root folder and build them in
3939
# sequence, but still in the correct order.
4040
run: |
41-
npm run build -w packages/commons
41+
npm run build -w packages/commons
4242
npm run build -w packages/jmespath
4343
npm run build -w packages/logger & \
4444
npm run build -w packages/tracer & \
4545
npm run build -w packages/metrics & \
4646
npm run build -w packages/parameters & \
4747
npm run build -w packages/idempotency & \
4848
npm run build -w packages/batch & \
49-
npm run build -w packages/testing
49+
npm run build -w packages/testing & \
50+
npm run build -w packages/parser
5051
shell: bash

.github/scripts/release_patch_package_json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (process.argv.length < 3) {
1818
const basePath = resolve(process.argv[2]);
1919
const packageJsonPath = join(basePath, 'package.json');
2020
const alphaPackages = [];
21-
const betaPackages = [];
21+
const betaPackages = ['@aws-lambda-powertools/parser'];
2222

2323
(() => {
2424
try {

.github/workflows/reusable-run-linting-check-and-unit-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
with:
2929
nodeVersion: ${{ matrix.version }}
3030
- name: Run linting
31-
run: npm run lint -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics -w packages/parameters -w packages/idempotency -w packages/batch -w packages/jmespath
31+
run: npm run lint -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics -w packages/parameters -w packages/idempotency -w packages/batch -w packages/jmespath -w packages/parser
3232
- name: Run unit tests
33-
run: npm t -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics -w packages/parameters -w packages/idempotency -w packages/batch -w packages/jmespath
33+
run: npm t -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics -w packages/parameters -w packages/idempotency -w packages/batch -w packages/jmespath -w packages/parser
3434
check-examples:
3535
runs-on: ubuntu-latest
3636
env:

docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# version 9.5.2
2-
FROM squidfunk/mkdocs-material@sha256:6b124e13728a591607e0f087920763e405fc18861736a997896d0b253867a7b7
2+
FROM squidfunk/mkdocs-material@sha256:521644b58bc0c806083ef66e8b1027861bd3e98c433b251c436c5c0cc7733603
33

44
ADD requirements.txt /tmp/
55
RUN pip install --require-hashes -r /tmp/requirements.txt

docs/requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
mike==1.1.2
2-
mkdocs-material==9.5.17
2+
mkdocs-material==9.5.18
33
mkdocs-git-revision-date-plugin==0.3.2
44
mkdocs-exclude==1.0.2

docs/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ mkdocs-exclude==1.0.2 \
229229
mkdocs-git-revision-date-plugin==0.3.2 \
230230
--hash=sha256:2e67956cb01823dd2418e2833f3623dee8604cdf223bddd005fe36226a56f6ef
231231
# via -r requirements.in
232-
mkdocs-material==9.5.17 \
233-
--hash=sha256:06ae1275a72db1989cf6209de9e9ecdfbcfdbc24c58353877b2bb927dbe413e4 \
234-
--hash=sha256:14a2a60119a785e70e765dd033e6211367aca9fc70230e577c1cf6a326949571
232+
mkdocs-material==9.5.18 \
233+
--hash=sha256:1e0e27fc9fe239f9064318acf548771a4629d5fd5dfd45444fd80a953fe21eb4 \
234+
--hash=sha256:a43f470947053fa2405c33995f282d24992c752a50114f23f30da9d8d0c57e62
235235
# via -r requirements.in
236236
mkdocs-material-extensions==1.3.1 \
237237
--hash=sha256:10c9511cea88f568257f960358a467d12b970e1f7b2c0e5fb2bb48cab1928443 \

lerna.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"packages/batch",
1010
"packages/testing",
1111
"packages/jmespath",
12+
"packages/parser",
1213
"examples/app",
1314
"layers",
1415
"docs/snippets"

packages/jmespath/src/Functions.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ import { arityCheck, typeCheck } from './utils.js';
4848
* ```
4949
*/
5050
class Functions {
51+
/**
52+
* A set of all the custom functions available in this and all child classes.
53+
*/
5154
public methods: Set<string> = new Set();
55+
5256
/**
5357
* Get the absolute value of the provided number.
5458
*
@@ -528,14 +532,32 @@ class Functions {
528532
return Object.values(arg);
529533
}
530534

535+
/**
536+
* Lazily introspects the methods of the class instance and all child classes
537+
* to get the names of the methods that correspond to JMESPath functions.
538+
*
539+
* This method is used to get the names of the custom functions that are available
540+
* in the class instance and all child classes. The names of the functions are used
541+
* to create the custom function map that is passed to the JMESPath search function.
542+
*
543+
* The method traverses the inheritance chain going from the leaf class to the root class
544+
* and stops when it reaches the `Functions` class, which is the root class.
545+
*
546+
* In doing so, it collects the names of the methods that start with `func` and adds them
547+
* to the `methods` set. Finally, when the recursion collects back to the current instance,
548+
* it adds the collected methods to the `this.methods` set so that they can be accessed later.
549+
*
550+
* @param scope The scope of the class instance to introspect
551+
*/
531552
public introspectMethods(scope?: Functions): Set<string> {
532553
const prototype = Object.getPrototypeOf(this);
533-
const ownName = prototype.constructor.name;
534554
const methods = new Set<string>();
535-
if (ownName !== 'Functions') {
555+
if (this instanceof Functions) {
536556
for (const method of prototype.introspectMethods(scope)) {
537557
methods.add(method);
538558
}
559+
} else {
560+
return methods;
539561
}
540562

541563
// This block is executed for every class in the inheritance chain

packages/jmespath/tests/unit/index.test.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ describe('Coverage tests', () => {
351351
it('uses the custom function extending the powertools custom functions', () => {
352352
// Prepare
353353
class CustomFunctions extends PowertoolsFunctions {
354-
public constructor() {
355-
super();
356-
}
357354
@PowertoolsFunctions.signature({
358355
argumentsSpecs: [['string']],
359356
})
@@ -384,5 +381,26 @@ describe('Coverage tests', () => {
384381
// Assess
385382
expect(messages).toStrictEqual(['hello world']);
386383
});
384+
385+
it('correctly registers all the custom functions', () => {
386+
// Prepare
387+
class CustomFunctions extends PowertoolsFunctions {
388+
@PowertoolsFunctions.signature({
389+
argumentsSpecs: [['string']],
390+
})
391+
public funcPassThrough(value: string): string {
392+
return value;
393+
}
394+
}
395+
396+
// Act
397+
const customFunctions = new CustomFunctions();
398+
search('pass_through(foo)', { foo: 'bar' }, { customFunctions });
399+
400+
// Assess
401+
expect(customFunctions.methods.size).toBeGreaterThan(
402+
new PowertoolsFunctions().methods.size
403+
);
404+
});
387405
});
388406
});

packages/parser/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Powertools for AWS Lambda (TypeScript) - Parser Utility <!-- omit in toc -->
22

3+
4+
| ⚠️ **WARNING: Do not use this utility in production just yet!** ⚠️ |
5+
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
6+
| This AWS Lambda Powertools for TypeScript utility is currently released as beta developer preview and is intended strictly for feedback and testing purposes only. <br/>This version is not stable, and significant breaking changes might incur before going [before the GA release](https://github.com/aws-powertools/powertools-lambda-typescript/milestone/16). | _ |
7+
8+
9+
310
Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda/typescript/latest/#features).
411

512
You can use the package in both TypeScript and JavaScript code bases.

packages/parser/package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://aws.amazon.com"
88
},
99
"publishConfig": {
10-
"access": "restricted"
10+
"access": "public"
1111
},
1212
"scripts": {
1313
"test": "npm run test:unit",
@@ -91,9 +91,16 @@
9191
"aws",
9292
"lambda",
9393
"powertools",
94-
"batch",
95-
"batch-processing",
94+
"parser",
95+
"zod",
96+
"parse",
97+
"events",
98+
"payloads",
99+
"inputs",
100+
"validate",
101+
"validation",
96102
"serverless",
103+
"typescript",
97104
"nodejs"
98105
],
99106
"peerDependencies": {

0 commit comments

Comments
 (0)