asl-path-validator
Advanced tools
Comparing version 0.11.0 to 0.12.0
@@ -1,2 +0,2 @@ | ||
import Ajv from "ajv"; | ||
import type Ajv from "ajv"; | ||
export declare const AslPathValidatorConfig: { | ||
@@ -18,1 +18,2 @@ format_names: { | ||
}) => void; | ||
//# sourceMappingURL=ajv.d.ts.map |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.registerAll = exports.AslPathValidatorConfig = void 0; | ||
var index_1 = require("./index"); | ||
var types_1 = require("./types"); | ||
const index_1 = require("./index"); | ||
const types_1 = require("./types"); | ||
exports.AslPathValidatorConfig = { | ||
format_names: (_a = {}, | ||
_a[types_1.AslPathContext.PATH] = "asl_path", | ||
_a[types_1.AslPathContext.REFERENCE_PATH] = "asl_ref_path", | ||
_a[types_1.AslPathContext.PAYLOAD_TEMPLATE] = "asl_payload_template", | ||
_a), | ||
format_names: { | ||
[types_1.AslPathContext.PATH]: "asl_path", | ||
[types_1.AslPathContext.REFERENCE_PATH]: "asl_ref_path", | ||
[types_1.AslPathContext.PAYLOAD_TEMPLATE]: "asl_payload_template", | ||
}, | ||
silent: true, | ||
}; | ||
var registerAll = function (ajv, config) { | ||
if (config === void 0) { config = exports.AslPathValidatorConfig; } | ||
var validateAdapter = function (path, pathType) { | ||
var result = (0, index_1.validatePath)(path, pathType); | ||
const registerAll = (ajv, config = exports.AslPathValidatorConfig) => { | ||
const validateAdapter = (path, pathType) => { | ||
const result = (0, index_1.validatePath)(path, pathType); | ||
if (!config.silent && !result.isValid) { | ||
ajv.logger.error("asl_path_validator: code:".concat(result.code, ". pathType:").concat(pathType, ". input: ").concat(path)); | ||
ajv.logger.error(`asl_path_validator: code:${result.code}. pathType:${pathType}. input: ${path}`); | ||
} | ||
return result.isValid; | ||
}; | ||
ajv.addFormat(config.format_names[types_1.AslPathContext.REFERENCE_PATH], function (path) { | ||
ajv.addFormat(config.format_names[types_1.AslPathContext.REFERENCE_PATH], (path) => { | ||
return validateAdapter(path, types_1.AslPathContext.REFERENCE_PATH); | ||
}); | ||
ajv.addFormat(config.format_names[types_1.AslPathContext.PATH], function (path) { | ||
ajv.addFormat(config.format_names[types_1.AslPathContext.PATH], (path) => { | ||
return validateAdapter(path, types_1.AslPathContext.PATH); | ||
}); | ||
ajv.addFormat(config.format_names[types_1.AslPathContext.PAYLOAD_TEMPLATE], function (path) { | ||
ajv.addFormat(config.format_names[types_1.AslPathContext.PAYLOAD_TEMPLATE], (path) => { | ||
return validateAdapter(path, types_1.AslPathContext.PAYLOAD_TEMPLATE); | ||
@@ -35,1 +33,2 @@ }); | ||
exports.registerAll = registerAll; | ||
//# sourceMappingURL=ajv.js.map |
export declare type Must = <T>(nullable?: T) => asserts nullable; | ||
export declare const must: Must; | ||
//# sourceMappingURL=assertions.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.must = void 0; | ||
var must = function (nullable) { | ||
const must = (nullable) => { | ||
if (!nullable) { | ||
@@ -10,1 +10,2 @@ throw Error("T must be truthy"); | ||
exports.must = must; | ||
//# sourceMappingURL=assertions.js.map |
export declare const referencePathChecks: (ast: unknown) => boolean; | ||
export declare const hasFunctions: (ast: unknown) => boolean; | ||
//# sourceMappingURL=ast.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasFunctions = exports.referencePathChecks = void 0; | ||
var jsonpath_plus_1 = require("jsonpath-plus"); | ||
var find = function (path, ast) { | ||
var results = (0, jsonpath_plus_1.JSONPath)({ | ||
path: path, | ||
const jsonpath_plus_1 = require("jsonpath-plus"); | ||
const find = (path, ast) => { | ||
const results = (0, jsonpath_plus_1.JSONPath)({ | ||
path, | ||
json: ast, | ||
@@ -12,9 +12,10 @@ }); | ||
}; | ||
var referencePathChecks = function (ast) { | ||
const referencePathChecks = (ast) => { | ||
return !find("$..[atmark,wildcard,negOffset,slice,recursiveDescent,multipleIndex,filter]", ast); | ||
}; | ||
exports.referencePathChecks = referencePathChecks; | ||
var hasFunctions = function (ast) { | ||
const hasFunctions = (ast) => { | ||
return find("$..[func]", ast); | ||
}; | ||
exports.hasFunctions = hasFunctions; | ||
//# sourceMappingURL=ast.js.map |
@@ -11,1 +11,2 @@ declare function peg$SyntaxError(message: any, expected: any, found: any, location: any): Error; | ||
export { peg$SyntaxError as SyntaxError, peg$parse as parse }; | ||
//# sourceMappingURL=aslPaths.d.ts.map |
import { AslPathContext, ValidationResult } from "./types"; | ||
export declare const validatePath: (path: string, context: AslPathContext) => ValidationResult; | ||
export * from "./ajv"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -18,9 +18,7 @@ "use strict"; | ||
exports.validatePath = void 0; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
var aslPaths_1 = require("./generated/aslPaths"); | ||
var types_1 = require("./types"); | ||
var ast_1 = require("./ast"); | ||
var validatePath = function (path, context) { | ||
var ast = null; | ||
const aslPaths_1 = require("./generated/aslPaths"); | ||
const types_1 = require("./types"); | ||
const ast_1 = require("./ast"); | ||
const validatePath = (path, context) => { | ||
let ast = null; | ||
try { | ||
@@ -69,3 +67,3 @@ ast = (0, aslPaths_1.parse)(path); | ||
default: { | ||
var invalid = context; | ||
const invalid = context; | ||
throw Error(invalid); | ||
@@ -78,1 +76,2 @@ } | ||
__exportStar(require("./ajv"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -18,1 +18,2 @@ export declare enum AslPathContext { | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -16,1 +16,2 @@ "use strict"; | ||
})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {})); | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "asl-path-validator", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"description": "Validates the path expressions for the Amazon States Language", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
/* Custom settings */ | ||
"outDir": "dist", | ||
"allowJs": true, | ||
"checkJs": false, | ||
"declaration": true | ||
/* Visit https://aka.ms/tsconfig.json to read more about this file */ | ||
/* Projects */ | ||
"incremental": false /* Enable incremental compilation */, | ||
"composite": false /* Enable constraints that allow a TypeScript project to be used with project references. */, | ||
"disableSourceOfProjectReferenceRedirect": false /* Disable preferring source files instead of declaration files when referencing composite projects */, | ||
/* Language and Environment */ | ||
"target": "es6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, | ||
"lib": [ | ||
"es6" | ||
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */, | ||
"experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */, | ||
"emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */, | ||
/* Modules */ | ||
"module": "commonjs" /* Specify what module code is generated. */, | ||
/*"moduleResolution": "Node16"*/ /* Specify how TypeScript looks up a file from a given module specifier. */ | ||
"resolveJsonModule": true /* Enable importing .json files */, | ||
/* Emit */ | ||
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, | ||
"declarationMap": true /* Create sourcemaps for d.ts files. */, | ||
"sourceMap": true /* Create source map files for emitted JavaScript files. */, | ||
"removeComments": true /* Disable emitting comments. */, | ||
"noEmit": false, /* Disable emitting files from a compilation. */ | ||
"importsNotUsedAsValues": "error", /* Specify emit/checking behavior for imports that are only used for types. */ | ||
"noEmitOnError": true /* Disable emitting files if any type checking errors are reported. */, | ||
/* Interop Constraints */ | ||
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, | ||
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, | ||
/* Type Checking */ | ||
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ | ||
"strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ | ||
"strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ | ||
"strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ | ||
"strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ | ||
"noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ | ||
"useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ | ||
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ | ||
"noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ | ||
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ | ||
"exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ | ||
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ | ||
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ | ||
"noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ | ||
"noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ | ||
"noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ | ||
"allowUnusedLabels": false, /* Disable error reporting for unused labels. */ | ||
"allowUnreachableCode": false, /* Disable error reporting for unreachable code. */ | ||
/* Completeness */ | ||
"skipLibCheck": true /* Skip type checking all .d.ts files. */, | ||
}, | ||
"include": [ | ||
"./bin", | ||
"./src" | ||
"./src/**/*.ts" | ||
] | ||
} | ||
} |
Sorry, the diff of this file is too big to display
252759
33
4709