Repository: ChristopheBougere/asl-validator (ts)

Issue:
nested maps generate an error due to bad path expression in validator
**Describe the bug**
I'm getting this error with an ASL with a nested map.

```
Parse error on line 1:
    $.['Next','Default']
```

It's due to the newly merged state-transitions.js code.

**To Reproduce**
Please provide a complete state machine definition:
```json
{
  "StartAt": "Map",
  "States": {
    "Map": {
      "Type": "Map",
      "Next": "Final State",
      "Iterator": {
        "StartAt": "Map2",
        "States": {
          "Map2": {
            "Type": "Map",
            "End": true,
            "Iterator": {
              "StartAt": "Wait 20s",
              "States": {
                "Wait 20s": {
                  "Type": "Wait",
                  "Seconds": 20,
                  "End": true
                }
              }
            }
          }
        }
      }
    },
    "Final State": {
      "Type": "Succeed"
    }
  }
}
```

**Expected behavior**
no error

**Version:** 2.1.0

**Additional context**
I was missing a test case for a nested map so it wasn't hitting this path in the code. The migration to jsonpath-plus will fix this but it could also be fixed with the existing `jsonpath` library. 


Pull request:
fix: bad jsonpath in nextAndDefaultTargets function
fixes #84 

Patch:
diff --git a/src/lib/state-transitions.js b/src/lib/state-transitions.js
index 2cf29a5..30dc833 100644
--- a/src/lib/state-transitions.js
+++ b/src/lib/state-transitions.js
@@ -14,7 +14,7 @@ module.exports = (definition) => {
     Object.keys(nestedStateMachine.States).forEach((stateName) => {
       const nestedState = nestedStateMachine.States[stateName];
       const isContainer = ['Map', 'Parallel'].indexOf(nestedState.Type) >= 0;
-      const path = isContainer ? '$.[\'Next\',\'Default\']' : '$..[\'Next\',\'Default\']';
+      const path = isContainer ? '$.*[?(\'Next\',\'Default\')]' : '$..[\'Next\',\'Default\']';
       states.push(...jp.query(nestedState, path));
     });
     return states;


Test patch:
diff --git a/src/__tests__/definitions/valid-map-nested.json b/src/__tests__/definitions/valid-map-nested.json
new file mode 100644
index 0000000..de14a85
--- /dev/null
+++ b/src/__tests__/definitions/valid-map-nested.json
@@ -0,0 +1,31 @@
+{
+  "StartAt": "Map",
+  "States": {
+    "Map": {
+      "Type": "Map",
+      "Next": "Final State",
+      "Iterator": {
+        "StartAt": "Map2",
+        "States": {
+          "Map2": {
+            "Type": "Map",
+            "End": true,
+            "Iterator": {
+              "StartAt": "Wait 20s",
+              "States": {
+                "Wait 20s": {
+                  "Type": "Wait",
+                  "Seconds": 20,
+                  "End": true
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "Final State": {
+      "Type": "Succeed"
+    }
+  }
+}