amazon-states-language-service
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -23,5 +23,5 @@ "use strict"; | ||
} | ||
const node = astUtilityFunctions_1.findNodeAtLocation(rootNode, offset); | ||
const snippetsList = completeSnippets_1.default(node, offset, aslOptions); | ||
let completionList = (_a = completeStateNames_1.default(node, offset, document, aslOptions)) !== null && _a !== void 0 ? _a : jsonCompletions; | ||
const node = (0, astUtilityFunctions_1.findNodeAtLocation)(rootNode, offset); | ||
const snippetsList = (0, completeSnippets_1.default)(node, offset, aslOptions); | ||
let completionList = (_a = (0, completeStateNames_1.default)(node, offset, document, aslOptions)) !== null && _a !== void 0 ? _a : jsonCompletions; | ||
if (completionList === null || completionList === void 0 ? void 0 : completionList.items) { | ||
@@ -28,0 +28,0 @@ completionList.items = completionList.items.concat(snippetsList); |
@@ -10,2 +10,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.errorHandlingSnippets = exports.stateSnippets = void 0; | ||
const vscode_json_languageservice_1 = require("vscode-json-languageservice"); | ||
@@ -31,4 +32,4 @@ const astUtilityFunctions_1 = require("../utils/astUtilityFunctions"); | ||
let typeNode; | ||
if (astUtilityFunctions_1.isObjectNode(node)) { | ||
typeNode = astUtilityFunctions_1.findPropChildByName(node, 'Type'); | ||
if ((0, astUtilityFunctions_1.isObjectNode)(node)) { | ||
typeNode = (0, astUtilityFunctions_1.findPropChildByName)(node, 'Type'); | ||
} | ||
@@ -42,3 +43,3 @@ return ERROR_HANDLING_STATES.includes((_a = typeNode === null || typeNode === void 0 ? void 0 : typeNode.valueNode) === null || _a === void 0 ? void 0 : _a.value); | ||
// If the value of shouldShowStateSnippets is false prevent the snippets from being displayed | ||
const showStateSnippets = (options === null || options === void 0 ? void 0 : options.shouldShowStateSnippets) || ((options === null || options === void 0 ? void 0 : options.shouldShowStateSnippets) === undefined && astUtilityFunctions_1.isChildOfStates(node)); | ||
const showStateSnippets = (options === null || options === void 0 ? void 0 : options.shouldShowStateSnippets) || ((options === null || options === void 0 ? void 0 : options.shouldShowStateSnippets) === undefined && (0, astUtilityFunctions_1.isChildOfStates)(node)); | ||
if (showStateSnippets) { | ||
@@ -48,3 +49,3 @@ return exports.stateSnippets; | ||
if (errorSnippetOptionsNotDefined) { | ||
if (astUtilityFunctions_1.insideStateNode(node) && doesStateSupportErrorHandling(node)) { | ||
if ((0, astUtilityFunctions_1.insideStateNode)(node) && doesStateSupportErrorHandling(node)) { | ||
return exports.errorHandlingSnippets; | ||
@@ -51,0 +52,0 @@ } |
@@ -13,6 +13,6 @@ "use strict"; | ||
if (node.keyNode.value === 'StartAt') { | ||
if (node.parent && astUtilityFunctions_1.isObjectNode(node.parent)) { | ||
if (node.parent && (0, astUtilityFunctions_1.isObjectNode)(node.parent)) { | ||
const statesNode = node.parent.properties.find(propNode => propNode.keyNode.value === 'States'); | ||
if (statesNode) { | ||
return astUtilityFunctions_1.getListOfStateNamesFromStateNode(statesNode, options === null || options === void 0 ? void 0 : options.ignoreColonOffset); | ||
return (0, astUtilityFunctions_1.getListOfStateNamesFromStateNode)(statesNode, options === null || options === void 0 ? void 0 : options.ignoreColonOffset); | ||
} | ||
@@ -32,6 +32,6 @@ } | ||
case 'Default': { | ||
const statesNode = astUtilityFunctions_1.findClosestAncestorStateNode(node); | ||
const statesNode = (0, astUtilityFunctions_1.findClosestAncestorStateNode)(node); | ||
const stateItemNode = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent; | ||
let stateItemName; | ||
if (stateItemNode && astUtilityFunctions_1.isPropertyNode(stateItemNode)) { | ||
if (stateItemNode && (0, astUtilityFunctions_1.isPropertyNode)(stateItemNode)) { | ||
// The state name under cursor shouldn't be suggested - find the value | ||
@@ -41,7 +41,7 @@ stateItemName = stateItemNode.keyNode.value; | ||
} | ||
else if (((_c = (_b = stateItemNode === null || stateItemNode === void 0 ? void 0 : stateItemNode.parent) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.parent) && astUtilityFunctions_1.isPropertyNode(stateItemNode.parent.parent.parent)) { | ||
else if (((_c = (_b = stateItemNode === null || stateItemNode === void 0 ? void 0 : stateItemNode.parent) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.parent) && (0, astUtilityFunctions_1.isPropertyNode)(stateItemNode.parent.parent.parent)) { | ||
stateItemName = stateItemNode.parent.parent.parent.keyNode.value; | ||
} | ||
if (statesNode) { | ||
return astUtilityFunctions_1.getListOfStateNamesFromStateNode(statesNode, options === null || options === void 0 ? void 0 : options.ignoreColonOffset).filter(name => name !== stateItemName); | ||
return (0, astUtilityFunctions_1.getListOfStateNamesFromStateNode)(statesNode, options === null || options === void 0 ? void 0 : options.ignoreColonOffset).filter(name => name !== stateItemName); | ||
} | ||
@@ -60,3 +60,3 @@ return []; | ||
items: items.map(name => { | ||
const shouldWrapStateNameInQuotes = languageId === constants_1.LANGUAGE_IDS.YAML && yamlUtils_1.isStateNameReservedYamlKeyword(name); | ||
const shouldWrapStateNameInQuotes = languageId === constants_1.LANGUAGE_IDS.YAML && (0, yamlUtils_1.isStateNameReservedYamlKeyword)(name); | ||
const item = vscode_json_languageservice_1.CompletionItem.create(name); | ||
@@ -81,3 +81,3 @@ item.commitCharacters = [',']; | ||
// For property nodes | ||
if (node && astUtilityFunctions_1.isPropertyNode(node) && node.colonOffset) { | ||
if (node && (0, astUtilityFunctions_1.isPropertyNode)(node) && node.colonOffset) { | ||
const states = getListOfItems(node, options); | ||
@@ -103,5 +103,5 @@ if (states.length) { | ||
// For string nodes that have a parent that is a property node | ||
if (node && node.parent && astUtilityFunctions_1.isPropertyNode(node.parent)) { | ||
if (node && node.parent && (0, astUtilityFunctions_1.isPropertyNode)(node.parent)) { | ||
const propNode = node.parent; | ||
if (astUtilityFunctions_1.isStringNode(node)) { | ||
if ((0, astUtilityFunctions_1.isStringNode)(node)) { | ||
const states = getListOfItems(propNode, options); | ||
@@ -108,0 +108,0 @@ if (states.length) { |
@@ -7,2 +7,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FILE_EXTENSIONS = exports.LANGUAGE_IDS = void 0; | ||
exports.LANGUAGE_IDS = { | ||
@@ -9,0 +10,0 @@ YAML: 'asl-yaml', |
@@ -10,2 +10,3 @@ /*! | ||
readonly INVALID_JSON_PATH_OR_INTRINSIC: "The value for the field must be a valid JSONPath or intrinsic function expression."; | ||
readonly INVALID_JSON_PATH_OR_INTRINSIC_STRING_ONLY: "The value for the field must be a valid JSONPath or an intrinsic function expression that returns a string (ArrayGetItem, Base64Encode, Base64Decode, Format, JsonToString, Hash, or UUID)."; | ||
readonly UNREACHABLE_STATE: "The state cannot be reached. It must be referenced by at least one other state."; | ||
@@ -12,0 +13,0 @@ readonly NO_TERMINAL_STATE: "No terminal state. The state machine must have at least one terminal state (a state in which the \"End\" property is set to true)."; |
@@ -7,2 +7,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.YAML_PARSER_MESSAGES = exports.MESSAGES = void 0; | ||
exports.MESSAGES = { | ||
@@ -13,2 +14,3 @@ INVALID_NEXT: 'The value of "Next" property must be the name of an existing state.', | ||
INVALID_JSON_PATH_OR_INTRINSIC: 'The value for the field must be a valid JSONPath or intrinsic function expression.', | ||
INVALID_JSON_PATH_OR_INTRINSIC_STRING_ONLY: 'The value for the field must be a valid JSONPath or an intrinsic function expression that returns a string (ArrayGetItem, Base64Encode, Base64Decode, Format, JsonToString, Hash, or UUID).', | ||
UNREACHABLE_STATE: 'The state cannot be reached. It must be referenced by at least one other state.', | ||
@@ -15,0 +17,0 @@ NO_TERMINAL_STATE: 'No terminal state. The state machine must have at least one terminal state (a state in which the "End" property is set to true).', |
@@ -6,2 +6,16 @@ "use strict"; | ||
*/ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -16,5 +30,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -24,2 +35,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getYamlLanguageService = exports.getLanguageService = exports.doCompleteAsl = exports.ASL_SCHEMA = void 0; | ||
const vscode_json_languageservice_1 = require("vscode-json-languageservice"); | ||
@@ -32,8 +44,8 @@ const bundled_json_1 = __importDefault(require("./json-schema/bundled.json")); | ||
const aslYamlLanguageService_1 = require("./yaml/aslYamlLanguageService"); | ||
__export(require("vscode-json-languageservice")); | ||
__exportStar(require("vscode-json-languageservice"), exports); | ||
exports.ASL_SCHEMA = bundled_json_1.default; | ||
exports.doCompleteAsl = completeAsl_1.default; | ||
exports.getLanguageService = function (params) { | ||
const getLanguageService = function (params) { | ||
const builtInParams = {}; | ||
const languageService = vscode_json_languageservice_1.getLanguageService(Object.assign(Object.assign({}, params), builtInParams)); | ||
const languageService = (0, vscode_json_languageservice_1.getLanguageService)(Object.assign(Object.assign({}, params), builtInParams)); | ||
const doValidation = languageService.doValidation.bind(languageService); | ||
@@ -64,4 +76,4 @@ const doComplete = languageService.doComplete.bind(languageService); | ||
const rootNode = jsonDocument.root; | ||
if (rootNode && astUtilityFunctions_1.isObjectNode(rootNode)) { | ||
const aslDiagnostics = validateStates_1.default(rootNode, document, 0 /* Root */, params.aslOptions); | ||
if (rootNode && (0, astUtilityFunctions_1.isObjectNode)(rootNode)) { | ||
const aslDiagnostics = (0, validateStates_1.default)(rootNode, document, 0 /* RootType.Root */, params.aslOptions); | ||
return diagnostics.concat(aslDiagnostics); | ||
@@ -75,3 +87,3 @@ } | ||
const jsonCompletions = yield doComplete(document, position, doc); | ||
return completeAsl_1.default(document, position, doc, jsonCompletions, params.aslOptions); | ||
return (0, completeAsl_1.default)(document, position, doc, jsonCompletions, params.aslOptions); | ||
}); | ||
@@ -81,8 +93,10 @@ }; | ||
}; | ||
exports.getYamlLanguageService = function (params) { | ||
const aslLanguageService = exports.getLanguageService(Object.assign(Object.assign({}, params), { aslOptions: { | ||
exports.getLanguageService = getLanguageService; | ||
const getYamlLanguageService = function (params) { | ||
const aslLanguageService = (0, exports.getLanguageService)(Object.assign(Object.assign({}, params), { aslOptions: { | ||
ignoreColonOffset: true, | ||
} })); | ||
return aslYamlLanguageService_1.getLanguageService(params, exports.ASL_SCHEMA, aslLanguageService); | ||
return (0, aslYamlLanguageService_1.getLanguageService)(params, exports.ASL_SCHEMA, aslLanguageService); | ||
}; | ||
exports.getYamlLanguageService = getYamlLanguageService; | ||
//# sourceMappingURL=service.js.map |
@@ -13,3 +13,5 @@ [ | ||
"\t\t\"BackoffRate\": 2,", | ||
"\t\t\"MaxAttempts\": 2", | ||
"\t\t\"MaxAttempts\": 2,", | ||
"\t\t\"MaxDelaySeconds\": 10,", | ||
"\t\t\"JitterStrategy\": \"FULL\"", | ||
"\t},", | ||
@@ -16,0 +18,0 @@ "\t{", |
@@ -7,2 +7,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getListOfStateNamesFromStateNode = exports.findClosestAncestorStateNode = exports.findNodeAtLocation = exports.insideStateNode = exports.isChildOfStates = exports.findPropChildByName = exports.isArrayNode = exports.isObjectNode = exports.isPropertyNode = exports.isStringNode = void 0; | ||
function isStringNode(node) { | ||
@@ -9,0 +10,0 @@ return node.type === 'string'; |
@@ -23,3 +23,3 @@ "use strict"; | ||
rootNode.items.forEach(itemNode => { | ||
if (astUtilityFunctions_1.isObjectNode(itemNode)) { | ||
if ((0, astUtilityFunctions_1.isObjectNode)(itemNode)) { | ||
diagnostics = diagnostics.concat(getDiagnosticsForNode(itemNode, document, newSchemaPart)); | ||
@@ -47,3 +47,3 @@ } | ||
else if (!schemaPart[propName]) { | ||
diagnostics.push(getPropertyNodeDiagnostic_1.default(prop, document, diagnosticStrings_1.MESSAGES.INVALID_PROPERTY_NAME)); | ||
diagnostics.push((0, getPropertyNodeDiagnostic_1.default)(prop, document, diagnosticStrings_1.MESSAGES.INVALID_PROPERTY_NAME)); | ||
} | ||
@@ -54,3 +54,3 @@ }); | ||
mutuallyExclusivePropertiesPresent.forEach(oneOfProp => { | ||
diagnostics.push(getPropertyNodeDiagnostic_1.default(oneOfProp.propNode, document, diagnosticStrings_1.MESSAGES.MUTUALLY_EXCLUSIVE_CHOICE_PROPERTIES)); | ||
diagnostics.push((0, getPropertyNodeDiagnostic_1.default)(oneOfProp.propNode, document, diagnosticStrings_1.MESSAGES.MUTUALLY_EXCLUSIVE_CHOICE_PROPERTIES)); | ||
}); | ||
@@ -78,3 +78,3 @@ // if there is only one item and it is an object | ||
if (!propertySchema) { | ||
diagnostics.push(getPropertyNodeDiagnostic_1.default(prop, document, diagnosticStrings_1.MESSAGES.INVALID_PROPERTY_NAME)); | ||
diagnostics.push((0, getPropertyNodeDiagnostic_1.default)(prop, document, diagnosticStrings_1.MESSAGES.INVALID_PROPERTY_NAME)); | ||
} | ||
@@ -94,11 +94,11 @@ else if (prop.valueNode && isObject(propertySchema)) { | ||
// if it contains Fn:ArrayOf property all the other values will be ignored | ||
if (typeof arrayOfType === 'string' && astUtilityFunctions_1.isArrayNode(rootNode)) { | ||
if (typeof arrayOfType === 'string' && (0, astUtilityFunctions_1.isArrayNode)(rootNode)) { | ||
return getDiagnosticsForArrayOfSchema(rootNode, document, arrayOfType); | ||
// Fn:OneOf | ||
} | ||
else if (typeof oneOfType === 'string' && astUtilityFunctions_1.isObjectNode(rootNode)) { | ||
else if (typeof oneOfType === 'string' && (0, astUtilityFunctions_1.isObjectNode)(rootNode)) { | ||
return getDiagnosticsForOneOfSchema(rootNode, document, schemaPart, oneOfType); | ||
// Fn:ValueOf | ||
} | ||
else if (typeof valueOfType === 'string' && astUtilityFunctions_1.isObjectNode(rootNode)) { | ||
else if (typeof valueOfType === 'string' && (0, astUtilityFunctions_1.isObjectNode)(rootNode)) { | ||
const newSchemaPart = referenceTypes[valueOfType]; | ||
@@ -108,3 +108,3 @@ return getDiagnosticsForNode(rootNode, document, newSchemaPart); | ||
} | ||
else if (astUtilityFunctions_1.isObjectNode(rootNode)) { | ||
else if ((0, astUtilityFunctions_1.isObjectNode)(rootNode)) { | ||
return getDiagnosticsForRegularProperties(rootNode, document, schemaPart); | ||
@@ -111,0 +111,0 @@ } |
@@ -16,3 +16,3 @@ "use strict"; | ||
// Get the type of state | ||
const stateType = (_b = (_a = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'Type')) === null || _a === void 0 ? void 0 : _a.valueNode) === null || _b === void 0 ? void 0 : _b.value; | ||
const stateType = (_b = (_a = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'Type')) === null || _a === void 0 ? void 0 : _a.valueNode) === null || _b === void 0 ? void 0 : _b.value; | ||
const diagnostics = []; | ||
@@ -30,3 +30,3 @@ if (typeof stateType === 'string') { | ||
// tslint:disable-next-line no-unsafe-any | ||
diagnostics.push(...getDiagnosticsForNode_1.default(oneStateValueNode, document, allowedProperties)); | ||
diagnostics.push(...(0, getDiagnosticsForNode_1.default)(oneStateValueNode, document, allowedProperties)); | ||
} | ||
@@ -33,0 +33,0 @@ return diagnostics; |
@@ -18,2 +18,4 @@ "use strict"; | ||
const INTRINSIC_FUNC_REGEX = /^States\.(?:(JsonToString|Format|StringToJson|Array|ArrayContains|ArrayGetItem|ArrayLength|ArrayPartition|ArrayRange|ArrayUnique|Base64Decode|Base64Encode|Hash|JsonMerge|MathAdd|MathRandom|StringSplit)\(.+\)|(UUID)\(\))$/s; | ||
// update src/constants/diagnosticStrings INVALID_JSON_PATH_OR_INTRINSIC_STRING_ONLY when you change this regex. | ||
const INTRINSIC_FUNC_REGEX_STRING_RETURN = /^States\.(?:(JsonToString|Format|ArrayGetItem|Base64Decode|Base64Encode|Hash)\(.+\)|(UUID)\(\))$/s; | ||
function stateNameExistsInPropNode(nextPropNode, stateNames, document, message) { | ||
@@ -32,9 +34,69 @@ var _a; | ||
} | ||
/** | ||
* Evaluate whether input is an Intrinsic Function that returns string. | ||
* Intrinsic functions with return types other than string will return False. | ||
* @param text Input string. | ||
* @returns True if text is an Intrinsic Function that returns a string. | ||
*/ | ||
function isIntrinsicFunctionWithStringReturn(text) { | ||
const intrinsicText = text.trimEnd(); | ||
return INTRINSIC_FUNC_REGEX_STRING_RETURN.test(intrinsicText); | ||
} | ||
function isJsonPath(text) { | ||
return text.startsWith('$'); | ||
} | ||
/** | ||
* Validate that the field is a JsonPath or Intrinsic Function. | ||
* Only allows intrinsic functions that return strings. | ||
* @param pathField The field to evaluate. | ||
* @param document The document to evaluate. | ||
* @returns A diagnostics array of any validation issues. | ||
*/ | ||
function validatePathField(pathField, document) { | ||
const diagnostics = []; | ||
const valueNode = pathField.valueNode; | ||
const propValue = valueNode && valueNode.value; | ||
if (typeof propValue !== 'string' || !(isJsonPath(propValue) || isIntrinsicFunctionWithStringReturn(propValue))) { | ||
const { length, offset } = pathField; | ||
const range = vscode_json_languageservice_1.Range.create(document.positionAt(offset), document.positionAt(offset + length)); | ||
diagnostics.push(vscode_json_languageservice_1.Diagnostic.create(range, diagnosticStrings_1.MESSAGES.INVALID_JSON_PATH_OR_INTRINSIC_STRING_ONLY, vscode_json_languageservice_1.DiagnosticSeverity.Error)); | ||
} | ||
return diagnostics; | ||
} | ||
/** | ||
* Validates a *Path style field. | ||
* | ||
* A path-style field has two different input fields: MyField and MyFieldPath. | ||
* These fields are mutually exclusive - you cannot specify both at the same | ||
* time. | ||
* The base field ("MyField") takes a static string input. | ||
* The path-field ("MyFieldPath") lets you use JsonPath or Intrinsic Functions | ||
* to give a value to the base field ("MyField"). | ||
* | ||
* @param stateNode The node to evaluate | ||
* @param propertyName The base property name ("MyField") | ||
* @param document The document to evaluate | ||
* @returns A diagnostics array of any validation issues. | ||
*/ | ||
function validateExclusivePathTypeField(stateNode, propertyName, document) { | ||
let diagnostics = []; | ||
const pathFieldName = `${propertyName}Path`; | ||
const pathNode = (0, astUtilityFunctions_1.findPropChildByName)(stateNode, pathFieldName); | ||
if (pathNode) { | ||
const validatePathFieldDiagnostics = validatePathField(pathNode, document); | ||
diagnostics = diagnostics.concat(validatePathFieldDiagnostics); | ||
// Myfield and MyfieldPath are mutually exclusive | ||
if ((0, astUtilityFunctions_1.findPropChildByName)(stateNode, propertyName)) { | ||
const { length, offset } = pathNode; | ||
const range = vscode_json_languageservice_1.Range.create(document.positionAt(offset), document.positionAt(offset + length)); | ||
const errorMessage = `You cannot set both ${propertyName} and ${pathFieldName} at the same time.`; | ||
diagnostics.push(vscode_json_languageservice_1.Diagnostic.create(range, errorMessage, vscode_json_languageservice_1.DiagnosticSeverity.Error)); | ||
} | ||
} | ||
return diagnostics; | ||
} | ||
function validateParameters(parametersPropNode, document) { | ||
let diagnostics = []; | ||
const valueNode = parametersPropNode.valueNode; | ||
if (valueNode && astUtilityFunctions_1.isObjectNode(valueNode)) { | ||
if (valueNode && (0, astUtilityFunctions_1.isObjectNode)(valueNode)) { | ||
valueNode.properties.forEach(prop => { | ||
@@ -49,3 +111,3 @@ if (prop.valueNode && prop.keyNode.value.endsWith('.$')) { | ||
} | ||
else if (prop.valueNode && astUtilityFunctions_1.isObjectNode(prop.valueNode)) { | ||
else if (prop.valueNode && (0, astUtilityFunctions_1.isObjectNode)(prop.valueNode)) { | ||
diagnostics = diagnostics.concat(validateParameters(prop, document)); | ||
@@ -59,10 +121,10 @@ } | ||
function validateArrayNext(arrayPropName, oneStateValueNode, stateNames, document) { | ||
const arrayPropNode = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, arrayPropName); | ||
const arrayPropNode = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, arrayPropName); | ||
const diagnostics = []; | ||
const reachedStates = {}; | ||
if ((arrayPropNode === null || arrayPropNode === void 0 ? void 0 : arrayPropNode.valueNode) && astUtilityFunctions_1.isArrayNode(arrayPropNode.valueNode)) { | ||
if ((arrayPropNode === null || arrayPropNode === void 0 ? void 0 : arrayPropNode.valueNode) && (0, astUtilityFunctions_1.isArrayNode)(arrayPropNode.valueNode)) { | ||
arrayPropNode.valueNode.items.forEach(item => { | ||
var _a; | ||
if (astUtilityFunctions_1.isObjectNode(item)) { | ||
const nextProp = astUtilityFunctions_1.findPropChildByName(item, 'Next'); | ||
if ((0, astUtilityFunctions_1.isObjectNode)(item)) { | ||
const nextProp = (0, astUtilityFunctions_1.findPropChildByName)(item, 'Next'); | ||
if (nextProp) { | ||
@@ -85,10 +147,10 @@ const nextPropValue = (_a = nextProp.valueNode) === null || _a === void 0 ? void 0 : _a.value; | ||
var _a, _b; | ||
const statesNode = astUtilityFunctions_1.findPropChildByName(rootNode, 'States'); | ||
const startAtNode = astUtilityFunctions_1.findPropChildByName(rootNode, 'StartAt'); | ||
const statesNode = (0, astUtilityFunctions_1.findPropChildByName)(rootNode, 'States'); | ||
const startAtNode = (0, astUtilityFunctions_1.findPropChildByName)(rootNode, 'StartAt'); | ||
// Different schemas for root and root of nested state machine | ||
let rootSchema = validationSchema_1.default.Root; | ||
if (rootType === 1 /* Map */) { | ||
if (rootType === 1 /* RootType.Map */) { | ||
rootSchema = validationSchema_1.default.NestedMapRoot; | ||
} | ||
else if (rootType === 2 /* Parallel */) { | ||
else if (rootType === 2 /* RootType.Parallel */) { | ||
rootSchema = validationSchema_1.default.NestedParallelRoot; | ||
@@ -101,7 +163,7 @@ } | ||
if (!rootSchema[key]) { | ||
diagnostics.push(getPropertyNodeDiagnostic_1.default(prop, document, diagnosticStrings_1.MESSAGES.INVALID_PROPERTY_NAME)); | ||
diagnostics.push((0, getPropertyNodeDiagnostic_1.default)(prop, document, diagnosticStrings_1.MESSAGES.INVALID_PROPERTY_NAME)); | ||
} | ||
}); | ||
if (statesNode) { | ||
const stateNames = astUtilityFunctions_1.getListOfStateNamesFromStateNode(statesNode, options === null || options === void 0 ? void 0 : options.ignoreColonOffset); | ||
const stateNames = (0, astUtilityFunctions_1.getListOfStateNamesFromStateNode)(statesNode, options === null || options === void 0 ? void 0 : options.ignoreColonOffset); | ||
const statesValueNode = statesNode.valueNode; | ||
@@ -116,3 +178,3 @@ if (startAtNode) { | ||
} | ||
if (statesValueNode && astUtilityFunctions_1.isObjectNode(statesValueNode)) { | ||
if (statesValueNode && (0, astUtilityFunctions_1.isObjectNode)(statesValueNode)) { | ||
// keep track of reached states and unreached states to avoid multiple loops | ||
@@ -129,6 +191,6 @@ let reachedStates = {}; | ||
const oneStateValueNode = prop.valueNode; | ||
if (oneStateValueNode && astUtilityFunctions_1.isObjectNode(oneStateValueNode)) { | ||
diagnostics = diagnostics.concat(validateProperties_1.default(oneStateValueNode, document)); | ||
const nextPropNode = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'Next'); | ||
const endPropNode = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'End'); | ||
if (oneStateValueNode && (0, astUtilityFunctions_1.isObjectNode)(oneStateValueNode)) { | ||
diagnostics = diagnostics.concat((0, validateProperties_1.default)(oneStateValueNode, document)); | ||
const nextPropNode = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'Next'); | ||
const endPropNode = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'End'); | ||
const stateType = (_b = (_a = oneStateValueNode.properties | ||
@@ -147,3 +209,3 @@ .find(oneStateProp => oneStateProp.keyNode.value === 'Type')) === null || _a === void 0 ? void 0 : _a.valueNode) === null || _b === void 0 ? void 0 : _b.value; | ||
if (['Pass', 'Task', 'Parallel', 'Map'].includes(stateType)) { | ||
const parametersPropNode = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'Parameters'); | ||
const parametersPropNode = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'Parameters'); | ||
if (parametersPropNode) { | ||
@@ -157,3 +219,3 @@ const validateParametersDiagnostics = validateParameters(parametersPropNode, document); | ||
const validateCatchResult = validateArrayNext('Catch', oneStateValueNode, stateNames, document); | ||
const resultSelectorPropNode = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'ResultSelector'); | ||
const resultSelectorPropNode = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'ResultSelector'); | ||
diagnostics = diagnostics.concat(validateCatchResult.diagnostics); | ||
@@ -169,6 +231,6 @@ reachedStates = Object.assign(Object.assign({}, reachedStates), validateCatchResult.reachedStates); | ||
case 'Map': { | ||
const iteratorPropNode = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'Iterator') || astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'ItemProcessor'); | ||
if (iteratorPropNode && iteratorPropNode.valueNode && astUtilityFunctions_1.isObjectNode(iteratorPropNode.valueNode)) { | ||
const iteratorPropNode = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'Iterator') || (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'ItemProcessor'); | ||
if (iteratorPropNode && iteratorPropNode.valueNode && (0, astUtilityFunctions_1.isObjectNode)(iteratorPropNode.valueNode)) { | ||
// append the result of recursive validation to the list of diagnostics | ||
diagnostics = [...diagnostics, ...validateStates(iteratorPropNode.valueNode, document, 1 /* Map */, options)]; | ||
diagnostics = [...diagnostics, ...validateStates(iteratorPropNode.valueNode, document, 1 /* RootType.Map */, options)]; | ||
} | ||
@@ -179,8 +241,8 @@ break; | ||
case 'Parallel': { | ||
const branchesPropNode = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'Branches'); | ||
if (branchesPropNode && branchesPropNode.valueNode && astUtilityFunctions_1.isArrayNode(branchesPropNode.valueNode)) { | ||
const branchesPropNode = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'Branches'); | ||
if (branchesPropNode && branchesPropNode.valueNode && (0, astUtilityFunctions_1.isArrayNode)(branchesPropNode.valueNode)) { | ||
branchesPropNode.valueNode.children.forEach(branchItem => { | ||
if (astUtilityFunctions_1.isObjectNode(branchItem)) { | ||
if ((0, astUtilityFunctions_1.isObjectNode)(branchItem)) { | ||
// append the result of recursive validation to the list of diagnostics | ||
diagnostics = [...diagnostics, ...validateStates(branchItem, document, 2 /* Parallel */, options)]; | ||
diagnostics = [...diagnostics, ...validateStates(branchItem, document, 2 /* RootType.Parallel */, options)]; | ||
} | ||
@@ -192,3 +254,3 @@ }); | ||
case 'Choice': { | ||
const defaultNode = astUtilityFunctions_1.findPropChildByName(oneStateValueNode, 'Default'); | ||
const defaultNode = (0, astUtilityFunctions_1.findPropChildByName)(oneStateValueNode, 'Default'); | ||
if (defaultNode) { | ||
@@ -212,2 +274,6 @@ const name = (_e = defaultNode === null || defaultNode === void 0 ? void 0 : defaultNode.valueNode) === null || _e === void 0 ? void 0 : _e.value; | ||
hasTerminalState = true; | ||
const validateErrorFieldDiagnostics = validateExclusivePathTypeField(oneStateValueNode, 'Error', document); | ||
diagnostics = diagnostics.concat(validateErrorFieldDiagnostics); | ||
const validateCauseFieldDiagnostics = validateExclusivePathTypeField(oneStateValueNode, 'Cause', document); | ||
diagnostics = diagnostics.concat(validateCauseFieldDiagnostics); | ||
break; | ||
@@ -214,0 +280,0 @@ } |
@@ -74,4 +74,6 @@ /*! | ||
Properties: { | ||
Error: boolean; | ||
ErrorPath: boolean; | ||
Cause: boolean; | ||
Error: boolean; | ||
CausePath: boolean; | ||
Comment: boolean; | ||
@@ -199,2 +201,4 @@ Type: boolean; | ||
Comment: boolean; | ||
MaxDelaySeconds: boolean; | ||
JitterStrategy: boolean; | ||
}; | ||
@@ -201,0 +205,0 @@ }; |
@@ -76,4 +76,6 @@ "use strict"; | ||
Properties: { | ||
Error: true, | ||
ErrorPath: true, | ||
Cause: true, | ||
Error: true, | ||
CausePath: true, | ||
Comment: true, | ||
@@ -200,3 +202,5 @@ Type: true | ||
BackoffRate: true, | ||
Comment: true | ||
Comment: true, | ||
MaxDelaySeconds: true, | ||
JitterStrategy: true | ||
} | ||
@@ -203,0 +207,0 @@ }, |
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLanguageService = void 0; | ||
const vscode_json_languageservice_1 = require("vscode-json-languageservice"); | ||
@@ -61,5 +62,5 @@ const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument"); | ||
} | ||
exports.getLanguageService = function (params, schema, aslLanguageService) { | ||
const getLanguageService = function (params, schema, aslLanguageService) { | ||
const builtInParams = {}; | ||
const languageService = vscode_json_languageservice_1.getLanguageService(Object.assign(Object.assign({}, params), builtInParams)); | ||
const languageService = (0, vscode_json_languageservice_1.getLanguageService)(Object.assign(Object.assign({}, params), builtInParams)); | ||
const requestServiceMock = function (uri) { | ||
@@ -80,3 +81,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const yamlDocument = yamlParser07_1.parse(textDocument.getText()); | ||
const yamlDocument = (0, yamlParser07_1.parse)(textDocument.getText()); | ||
const validationResult = []; | ||
@@ -95,8 +96,8 @@ for (const currentYAMLDoc of yamlDocument.documents) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { modifiedDocText, tempPositionForCompletions, startPositionForInsertion, endPositionForInsertion, shouldPrependSpace } = yamlUtils_1.processYamlDocForCompletion(document, position); | ||
const { modifiedDocText, tempPositionForCompletions, startPositionForInsertion, endPositionForInsertion, shouldPrependSpace } = (0, yamlUtils_1.processYamlDocForCompletion)(document, position); | ||
const processedDocument = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version, modifiedDocText); | ||
const offsetIntoOriginalDocument = document.offsetAt(position); | ||
const offsetIntoProcessedDocument = processedDocument.offsetAt(tempPositionForCompletions); | ||
const processedYamlDoc = yamlParser07_1.parse(modifiedDocText); | ||
const currentDoc = arrUtils_1.matchOffsetToDocument(offsetIntoProcessedDocument, processedYamlDoc); | ||
const processedYamlDoc = (0, yamlParser07_1.parse)(modifiedDocText); | ||
const currentDoc = (0, arrUtils_1.matchOffsetToDocument)(offsetIntoProcessedDocument, processedYamlDoc); | ||
if (!currentDoc) { | ||
@@ -123,3 +124,3 @@ return { items: [], isIncomplete: false }; | ||
}); | ||
const { isDirectChildOfStates, isWithinCatchRetryState, hasCatchPropSibling, hasRetryPropSibling } = yamlUtils_1.getOffsetData(document, offsetIntoOriginalDocument); | ||
const { isDirectChildOfStates, isWithinCatchRetryState, hasCatchPropSibling, hasRetryPropSibling } = (0, yamlUtils_1.getOffsetData)(document, offsetIntoOriginalDocument); | ||
const aslOptions = { | ||
@@ -133,7 +134,7 @@ ignoreColonOffset: true, | ||
}; | ||
const aslCompletions = completeAsl_1.default(processedDocument, tempPositionForCompletions, currentDoc, yamlCompletions, aslOptions); | ||
const aslCompletions = (0, completeAsl_1.default)(processedDocument, tempPositionForCompletions, currentDoc, yamlCompletions, aslOptions); | ||
const modifiedAslCompletionItems = aslCompletions.items.map(completionItem => { | ||
const completionItemCopy = Object.assign({}, completionItem); // Copy completion to new object to avoid overwriting any snippets | ||
if (completionItemCopy.insertText && completionItemCopy.kind === vscode_json_languageservice_1.CompletionItemKind.Snippet && document.languageId === constants_1.LANGUAGE_IDS.YAML) { | ||
completionItemCopy.insertText = yamlUtils_1.convertJsonSnippetToYaml(completionItemCopy.insertText); | ||
completionItemCopy.insertText = (0, yamlUtils_1.convertJsonSnippetToYaml)(completionItemCopy.insertText); | ||
} | ||
@@ -174,5 +175,5 @@ else { | ||
languageService.doHover = function (document, position) { | ||
const doc = yamlParser07_1.parse(document.getText()); | ||
const doc = (0, yamlParser07_1.parse)(document.getText()); | ||
const offset = document.offsetAt(position); | ||
const currentDoc = arrUtils_1.matchOffsetToDocument(offset, doc); | ||
const currentDoc = (0, arrUtils_1.matchOffsetToDocument)(offset, doc); | ||
if (!currentDoc) { | ||
@@ -195,3 +196,3 @@ // tslint:disable-next-line: no-null-keyword | ||
languageService.findDocumentSymbols = function (document) { | ||
const doc = yamlParser07_1.parse(document.getText()); | ||
const doc = (0, yamlParser07_1.parse)(document.getText()); | ||
if (!doc || doc.documents.length === 0) { | ||
@@ -209,3 +210,3 @@ return []; | ||
languageService.findDocumentSymbols2 = function (document) { | ||
const doc = yamlParser07_1.parse(document.getText()); | ||
const doc = (0, yamlParser07_1.parse)(document.getText()); | ||
if (!doc || doc.documents.length === 0) { | ||
@@ -224,2 +225,3 @@ return []; | ||
}; | ||
exports.getLanguageService = getLanguageService; | ||
//# sourceMappingURL=aslYamlLanguageService.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getOffsetData = exports.convertJsonSnippetToYaml = exports.isStateNameReservedYamlKeyword = exports.processYamlDocForCompletion = void 0; | ||
/*! | ||
@@ -243,3 +244,3 @@ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// Convert to YAML with indendation of 1 space | ||
return js_yaml_1.dump(js_yaml_1.load(snippetText), { indent: 1 }) | ||
return (0, js_yaml_1.dump)((0, js_yaml_1.load)(snippetText), { indent: 1 }) | ||
// Remove quotation marks | ||
@@ -246,0 +247,0 @@ .replace(/[']/g, '') |
@@ -15,3 +15,3 @@ { | ||
"license": "MIT", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"publisher": "aws", | ||
@@ -31,10 +31,10 @@ "categories": [ | ||
"@types/js-yaml": "^4.0.5", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.11.7", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.2.5", | ||
"json-schema-ref-parser": "^7.1.3", | ||
"mocha": "^9.2.1", | ||
"mocha": "^10.2.0", | ||
"tslint": "^6.1.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"tslint-no-circular-imports": "^0.7.0", | ||
"typescript": "^3.7.5" | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -44,3 +44,3 @@ "dependencies": { | ||
"vscode-json-languageservice": "5.3.5", | ||
"vscode-languageserver": "^6.1.1", | ||
"vscode-languageserver": "^8.1.0", | ||
"vscode-languageserver-textdocument": "^1.0.0", | ||
@@ -47,0 +47,0 @@ "vscode-languageserver-types": "^3.15.1", |
Sorry, the diff of this file is too big to display
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
321558
4958
+ Addedvscode-jsonrpc@8.1.0(transitive)
+ Addedvscode-languageserver@8.1.0(transitive)
+ Addedvscode-languageserver-protocol@3.17.3(transitive)
+ Addedvscode-languageserver-types@3.17.3(transitive)
- Removedvscode-jsonrpc@8.2.0(transitive)
- Removedvscode-languageserver@6.1.1(transitive)
- Removedvscode-languageserver-protocol@3.17.5(transitive)
Updatedvscode-languageserver@^8.1.0