@wmfs/tymly-statelint
Advanced tools
Comparing version 1.1.0 to 1.2.0
const StateLint = require('@wmfs/statelint').StateLint | ||
const extensionPath = require.resolve('./schema/TymlyExtension.j2119') | ||
const CheckTaskNodes = require('./task_node') | ||
class TymlyStateLint extends StateLint { | ||
constructor () { | ||
constructor (stateResources, logger) { | ||
super(extensionPath) | ||
this.taskNodeChecker = CheckTaskNodes(stateResources, logger) | ||
} // constructor | ||
validate (json) { | ||
const problems = super.validate(json) | ||
return this.taskNodeChecker.check(json, problems) | ||
} // validate | ||
} // TymlyStateLint | ||
module.exports = () => new TymlyStateLint() | ||
module.exports = (stateResources, logger) => new TymlyStateLint(stateResources, logger) |
{ | ||
"name": "@wmfs/tymly-statelint", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Validator for Amazon States Language with Tymly Extensions JSON.", | ||
@@ -26,3 +26,5 @@ "author": "West Midlands Fire Service", | ||
"dependencies": { | ||
"@wmfs/statelint": "1.5.0" | ||
"@wmfs/j2119": "1.6.0", | ||
"@wmfs/statelint": "1.5.0", | ||
"ajv": "6.5.4" | ||
}, | ||
@@ -29,0 +31,0 @@ "devDependencies": { |
@@ -11,17 +11,62 @@ /* eslint-env mocha */ | ||
const fixturesDir = path.dirname(require.resolve('./fixtures')) | ||
function tests (stateResources) { | ||
describe(`${stateResources ? 'With' : 'without'} state resource validation`, () => { | ||
const nullLogger = { | ||
warn: () => {}, | ||
error: () => {} | ||
} | ||
for (const file of fs.readdirSync(fixturesDir).filter(f => f.endsWith('.json'))) { | ||
it(file, () => { | ||
const linter = tymlyStateLint(stateResources, nullLogger) | ||
const json = require(path.join(fixturesDir, file)) | ||
const problems = linter.validate(json) | ||
problems.forEach(p => console.log(`P: ${p}`)) | ||
expect(problems).to.eql([]) | ||
}) | ||
} | ||
}) | ||
} | ||
const stateResources = { | ||
runFunction: { rootDirPath: '.' }, | ||
findingById: { rootDirPath: '.' }, | ||
setContextData: { rootDirPath: '.' }, | ||
awaitingHumanInput: { rootDirPath: '.' }, | ||
upserting: { rootDirPath: '.' }, | ||
refreshRanking: { rootDirPath: '.' }, | ||
deltaReindex: { rootDirPath: '.' }, | ||
timestamp: { rootDirPath: '.' } | ||
} | ||
describe('TymlyStateMachineLint', () => { | ||
const linter = tymlyStateLint() | ||
tests() | ||
tests(stateResources) | ||
describe('logger', () => { | ||
class TestLogger { | ||
constructor () { this.msgs_ = [] } | ||
get logs () { return this.msgs_ } | ||
warn (m) { this.msgs_.push(m) } | ||
error (m) { this.msgs_.push(m) } | ||
} | ||
const fixturesDir = path.dirname(require.resolve('./fixtures')) | ||
it('warning when no state resources available', () => { | ||
const logger = new TestLogger() | ||
tymlyStateLint(null, logger) | ||
for (const file of fs.readdirSync(fixturesDir).filter(f => f.endsWith('.json'))) { | ||
it(file, () => { | ||
const json = require(path.join(fixturesDir, file)) | ||
const problems = linter.validate(json) | ||
expect(logger.logs).to.eql(['State Resources not available. Will not validate Resource or ResourceConfig']) | ||
}) | ||
problems.forEach(p => console.log(`P: ${p}`)) | ||
it('warning when no state resource schema available', () => { | ||
const logger = new TestLogger() | ||
const linter = tymlyStateLint(stateResources, logger) | ||
linter.validate(require(path.join(fixturesDir, 'timestamp.json'))) | ||
expect(problems).to.eql([]) | ||
expect(logger.logs).to.eql(['No ResourceConfig schema available for timestamp']) | ||
}) | ||
} | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
27433
19
579
3
5
+ Added@wmfs/j2119@1.6.0
+ Addedajv@6.5.4
+ Addedajv@6.5.4(transitive)
+ Addedfast-deep-equal@2.0.1(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addeduri-js@4.4.1(transitive)