From 27f1608df705219445c1afa09b348b2beefb1ddd Mon Sep 17 00:00:00 2001 From: markford Date: Wed, 7 May 2025 23:20:19 -0400 Subject: [PATCH 1/3] test: add new unit test for nested paths --- src/__tests__/validatePath.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/__tests__/validatePath.test.ts b/src/__tests__/validatePath.test.ts index c2b4545..e05222d 100644 --- a/src/__tests__/validatePath.test.ts +++ b/src/__tests__/validatePath.test.ts @@ -216,6 +216,10 @@ describe("unit tests for the parser", () => { { path: "$.book[?(@.author =~ /.*REES/i)]", valid_in: None }, { path: "$..*", valid_in: NoRefPaths }, { path: "..book.length()", valid_in: None }, + { + path: "$[?(@.key1 == pass)].key1.thing2", + valid_in: [AslPathContext.PATH, AslPathContext.PAYLOAD_TEMPLATE], + }, ]; interface TestInputForContext { path: string; From 7fddd3d50b83d246ee91173f5391b8b40785322a Mon Sep 17 00:00:00 2001 From: markford Date: Thu, 8 May 2025 09:30:55 -0400 Subject: [PATCH 2/3] fix: expand predicate to support non-numeric comparisons --- src/__tests__/validatePath.test.ts | 4 ++++ src/aslPaths.pegjs | 1 + 2 files changed, 5 insertions(+) diff --git a/src/__tests__/validatePath.test.ts b/src/__tests__/validatePath.test.ts index e05222d..7f470d8 100644 --- a/src/__tests__/validatePath.test.ts +++ b/src/__tests__/validatePath.test.ts @@ -220,6 +220,10 @@ describe("unit tests for the parser", () => { path: "$[?(@.key1 == pass)].key1.thing2", valid_in: [AslPathContext.PATH, AslPathContext.PAYLOAD_TEMPLATE], }, + { + path: "$[?(@.key1.thing1 == pass)]", + valid_in: [AslPathContext.PATH, AslPathContext.PAYLOAD_TEMPLATE], + }, ]; interface TestInputForContext { path: string; diff --git a/src/aslPaths.pegjs b/src/aslPaths.pegjs index 5ce7094..e3bcdb5 100644 --- a/src/aslPaths.pegjs +++ b/src/aslPaths.pegjs @@ -115,6 +115,7 @@ expression expression_ = PAREN_LEFT _ exp:expression _ PAREN_RIGHT {return {exp}} / path:jsonpath__ _ op:comparison_op _ minus:MINUS? val:NUMBER {return {path, op, val: minus==='-'?-val:val}} + / path:jsonpath__ _ op:comparison_op _ ID {return {path, op}} / path:jsonpath__ comparison_op From e6829a17db0a4f820be2eb5b5b2b1afe127f0504 Mon Sep 17 00:00:00 2001 From: markford Date: Mon, 19 May 2025 22:21:27 -0400 Subject: [PATCH 3/3] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4fba2f0..3391b14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asl-path-validator", - "version": "0.16.1", + "version": "0.17.0", "description": "Validates the path expressions for the Amazon States Language", "main": "./dist/index.js", "scripts": {