asl-validator
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -14,24 +14,7 @@ "use strict"; | ||
var errorMessages = []; | ||
var valuesToInspect = []; | ||
try { | ||
valuesToInspect = (0, jsonpath_plus_1.JSONPath)({ | ||
json: definition, | ||
// this uses some extensions to the original JSONPath spec supported by the lib | ||
// | ||
// extension 1: @property.match enables matching on the matched property name. | ||
// This finds and selects all nodes with a name ending in .$ | ||
// extension 2: ^ operator twice at the end selects the parent node instead of the value for the node | ||
// | ||
// also, don't miss the array offset [0] before selecting the grandparent. | ||
// There may be multiple fields within a node that could be in conflict. | ||
// We're checking all the keys in the parent node, so we only need a single | ||
// result for that parent. | ||
path: "$..[Parameters,ResultSelector]..*[?(@property.match(/^.+\\.\\$$/))][0]^^" | ||
}); | ||
} | ||
catch (err) { | ||
// need to revisit this since the JSONPath lib throws an error when it encounters an array | ||
// Error: jsonPath: _$_property.match is not a function: _$_property.match(/^.+\.\$$/) | ||
} | ||
valuesToInspect.forEach(function (parent) { | ||
var valuesToInspect = (0, jsonpath_plus_1.JSONPath)({ | ||
json: definition, | ||
path: "$..[Parameters,ResultSelector]" | ||
}); | ||
var inspectKeys = function (parent) { | ||
var keys = {}; | ||
@@ -48,6 +31,10 @@ Object.keys(parent).forEach(function (key) { | ||
keys[keyPostEval] = current ? current + 1 : 1; | ||
if (typeof parent[key] === "object") { | ||
inspectKeys(parent[key]); | ||
} | ||
}); | ||
}); | ||
}; | ||
valuesToInspect.forEach(function (parent) { return inspectKeys(parent); }); | ||
return errorMessages; | ||
}; | ||
exports.mustNotHaveDuplicateFieldNamesAfterEvaluation = mustNotHaveDuplicateFieldNamesAfterEvaluation; |
{ | ||
"name": "asl-validator", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Amazon States Language validator", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/validator.js", |
@@ -12,24 +12,8 @@ import {JSONPath} from 'jsonpath-plus'; | ||
const errorMessages: StateMachineError[] = []; | ||
let valuesToInspect: Record<string, unknown>[] = []; | ||
try { | ||
valuesToInspect = JSONPath<Record<string, unknown>[]>({ | ||
json: definition, | ||
// this uses some extensions to the original JSONPath spec supported by the lib | ||
// | ||
// extension 1: @property.match enables matching on the matched property name. | ||
// This finds and selects all nodes with a name ending in .$ | ||
// extension 2: ^ operator twice at the end selects the parent node instead of the value for the node | ||
// | ||
// also, don't miss the array offset [0] before selecting the grandparent. | ||
// There may be multiple fields within a node that could be in conflict. | ||
// We're checking all the keys in the parent node, so we only need a single | ||
// result for that parent. | ||
path: `$..[Parameters,ResultSelector]..*[?(@property.match(/^.+\\.\\$$/))][0]^^` | ||
}) | ||
} catch (err: unknown) { | ||
// need to revisit this since the JSONPath lib throws an error when it encounters an array | ||
// Error: jsonPath: _$_property.match is not a function: _$_property.match(/^.+\.\$$/) | ||
} | ||
const valuesToInspect: Record<string, unknown>[] = JSONPath<Record<string, unknown>[]>({ | ||
json: definition, | ||
path: `$..[Parameters,ResultSelector]` | ||
}) | ||
valuesToInspect.forEach((parent) => { | ||
const inspectKeys = (parent: Record<string, unknown>): void => { | ||
const keys: Record<string, number> = {}; | ||
@@ -46,5 +30,10 @@ Object.keys(parent).forEach((key) => { | ||
keys[keyPostEval] = current ? current + 1 : 1; | ||
if (typeof parent[key] === "object") { | ||
inspectKeys(parent[key] as Record<string, unknown>); | ||
} | ||
}); | ||
}); | ||
} | ||
valuesToInspect.forEach((parent) => inspectKeys(parent)); | ||
return errorMessages; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105015
2784