Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wmfs/tymly-statelint

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wmfs/tymly-statelint - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

lib/json_schema_loader.js

13

lib/index.js
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

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