New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

asl-validator

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asl-validator - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

dist/src/checks/exactlyOneOfProperty.js

30

dist/src/checks/terminalStateWithNext.js

@@ -5,3 +5,3 @@ "use strict";

var types_1 = require("../types");
var get_states_1 = require("./get-states");
var exactlyOneOfProperty_1 = require("./exactlyOneOfProperty");
// performs the check that non-Terminal states do not contain a `Next` field.

@@ -15,22 +15,14 @@ // This replaces the following schema snippet:

var terminalStateWithNext = function (definition) {
var errorMessages = [];
(0, get_states_1.getStatesContainer)(definition).forEach(function (states) {
(0, get_states_1.getStates)(states).forEach(function (_a) {
var stateName = _a.stateName, state = _a.state;
// Terminal fields don't need this check
if (state.Type === 'Succeed' || state.Type === 'Fail' || state.Type === 'Choice') {
return;
}
if ('End' in state && 'Next' in state) {
errorMessages.push({
"Error code": types_1.StateMachineErrorCode.TerminalStateWithNextError,
// Use of JSONPath within the error message is unnecessary
// since the state names are unique.
Message: "State \"".concat(stateName, "\" contains both \"End\" and \"Next\" fields."),
});
}
});
return (0, exactlyOneOfProperty_1.exactlyOneOfPropertyWorkflow)({
props: ['End', 'Next'],
errorCode: types_1.StateMachineErrorCode.TerminalStateWithNextError,
definition: definition,
filter: function (_a) {
var state = _a.state;
return state.Type !== 'Succeed' &&
state.Type !== 'Fail' &&
state.Type !== 'Choice';
}
});
return errorMessages;
};
exports.terminalStateWithNext = terminalStateWithNext;

@@ -61,17 +61,4 @@ {

]
},
"_asl_payload_template": {
"oneOf": [
{
"$ref": "#/definitions/_payload_template_object"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/_asl_payload_template"
}
}
]
}
}
}

@@ -15,2 +15,3 @@ "use strict";

StateMachineErrorCode["TerminalStateWithNextError"] = "TERMINAL_STATE_WITH_NEXT";
StateMachineErrorCode["WaitDurationError"] = "WAIT_DURATION";
})(StateMachineErrorCode = exports.StateMachineErrorCode || (exports.StateMachineErrorCode = {}));

@@ -9,2 +9,3 @@ "use strict";

var terminalStateWithNext_1 = require("./checks/terminalStateWithNext");
var waitDuration_1 = require("./checks/waitDuration");
var DefaultOptions = {

@@ -24,2 +25,3 @@ checkPaths: true,

errors.push.apply(errors, (0, terminalStateWithNext_1.terminalStateWithNext)(definition, options));
errors.push.apply(errors, (0, waitDuration_1.waitDuration)(definition, options));
}

@@ -26,0 +28,0 @@ return {

{
"name": "asl-validator",
"version": "3.2.0",
"version": "3.3.0",
"description": "Amazon States Language validator",

@@ -5,0 +5,0 @@ "main": "./dist/src/validator.js",

@@ -11,3 +11,5 @@ import {State, StateMachine, States} from "../types";

export const getStates = (states: States): Array<{stateName: string, state: State & {Type: string}}> => {
export type StateEntry = {stateName: string, state: State & {Type: string}}
export const getStates = (states: States): Array<StateEntry> => {
return Object.keys(states).map((stateName) => {

@@ -14,0 +16,0 @@ const state = states[stateName]

@@ -1,3 +0,3 @@

import {AslChecker, StateMachineError, StateMachineErrorCode} from "../types";
import {getStates, getStatesContainer} from "./get-states";
import {AslChecker, StateMachineErrorCode} from "../types";
import {exactlyOneOfPropertyWorkflow} from "./exactlyOneOfProperty";

@@ -12,20 +12,12 @@ // performs the check that non-Terminal states do not contain a `Next` field.

export const terminalStateWithNext: AslChecker = (definition) => {
const errorMessages: StateMachineError[] = [];
getStatesContainer(definition).forEach((states) => {
getStates(states).forEach(({stateName, state}) => {
// Terminal fields don't need this check
if (state.Type === 'Succeed' || state.Type === 'Fail' || state.Type === 'Choice') {
return
}
if ('End' in state && 'Next' in state) {
errorMessages.push({
"Error code": StateMachineErrorCode.TerminalStateWithNextError,
// Use of JSONPath within the error message is unnecessary
// since the state names are unique.
Message: `State "${stateName}" contains both "End" and "Next" fields.`,
})
}
})
return exactlyOneOfPropertyWorkflow({
props: ['End', 'Next'],
errorCode: StateMachineErrorCode.TerminalStateWithNextError,
definition,
filter: ({state}) => {
return state.Type !== 'Succeed' &&
state.Type !== 'Fail' &&
state.Type !== 'Choice'
}
})
return errorMessages;
}

@@ -61,17 +61,4 @@ {

]
},
"_asl_payload_template": {
"oneOf": [
{
"$ref": "#/definitions/_payload_template_object"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/_asl_payload_template"
}
}
]
}
}
}

@@ -16,2 +16,3 @@ export type State = Record<string, unknown>;

TerminalStateWithNextError = 'TERMINAL_STATE_WITH_NEXT',
WaitDurationError = 'WAIT_DURATION',
}

@@ -18,0 +19,0 @@ export type StateMachineError = {

@@ -11,2 +11,3 @@ import {ErrorObject} from 'ajv';

import {terminalStateWithNext} from "./checks/terminalStateWithNext";
import {waitDuration} from "./checks/waitDuration";

@@ -32,2 +33,3 @@ const DefaultOptions: ValidationOptions = {

errors.push(...terminalStateWithNext(definition, options));
errors.push(...waitDuration(definition, options));
}

@@ -34,0 +36,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc