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

@wmfs/j2119

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wmfs/j2119 - npm Package Compare versions

Comparing version 1.9.0 to 1.10.0

17

CHANGELOG.md

@@ -0,1 +1,18 @@

# [1.10.0](https://github.com/wmfs/j2119/compare/v1.9.0...v1.10.0) (2020-01-27)
### 🛠 Builds
* **deps:** bump luxon from 1.21.3 to 1.22.0 ([f204a5f](https://github.com/wmfs/j2119/commit/f204a5f0292ce59fc1df91da383b81b0d8f09371))
* **deps-dev:** bump codecov from 3.6.1 to 3.6.2 ([50d2ed5](https://github.com/wmfs/j2119/commit/50d2ed51f3fb14e5518a26a555c44767c9a2bbca))
* **deps-dev:** bump conventional-changelog-metahub from 3.0.0 to 4.0.0 ([caef555](https://github.com/wmfs/j2119/commit/caef55521c0faa9c802cedd119d62bd622957484))
* **deps-dev:** bump mocha from 7.0.0 to 7.0.1 ([ffcc2e4](https://github.com/wmfs/j2119/commit/ffcc2e48ed455fad04cd2f990f514c4ebf33c945))
* **deps-dev:** update standard requirement from 12.0.1 to 14.3.1 ([49c2c14](https://github.com/wmfs/j2119/commit/49c2c1416a0da64f59e952610f464319eb2ddb4e))
### 💎 Styles
* standard --fix ([0986b50](https://github.com/wmfs/j2119/commit/0986b50048a82decedc7894d72581fd4d6752634))
* Unexpected lexical declaration in case block ([c7b90f1](https://github.com/wmfs/j2119/commit/c7b90f19dd1bffb6a7a172aa5de2b22b64f7a720))
# [1.9.0](https://github.com/wmfs/j2119/compare/v1.8.0...v1.9.0) (2020-01-06)

@@ -2,0 +19,0 @@

2

lib/index.js

@@ -22,3 +22,3 @@ const fs = require('fs')

if (Array.isArray(json) || (typeof json !== 'object')) {
return [ 'Not a JSON object' ]
return ['Not a JSON object']
}

@@ -25,0 +25,0 @@

class AllowedFields {
constructor () {
this.allowed = new Map()
this.any = [ ]
this.any = []
} // constructor

@@ -6,0 +6,0 @@

@@ -16,23 +16,23 @@ const oxford = require('./oxford')

assignRoles (assertion) {
if (assertion['val_match_present']) {
if (assertion.val_match_present) {
this.roles.addFieldValueRole(
assertion['role'],
assertion['fieldtomatch'],
assertion['valtomatch'],
assertion['newrole']
assertion.role,
assertion.fieldtomatch,
assertion.valtomatch,
assertion.newrole
)
this.matcher.addRole(assertion['newrole'])
} else if (assertion['with_a_field']) {
this.matcher.addRole(assertion.newrole)
} else if (assertion.with_a_field) {
this.roles.addFieldPresenceRole(
assertion['role'],
assertion['with_a_field'],
assertion['newrole']
assertion.role,
assertion.with_a_field,
assertion.newrole
)
this.matcher.addRole(assertion['newrole'])
this.matcher.addRole(assertion.newrole)
} else {
this.roles.addIsARole(
assertion['role'],
assertion['newrole']
assertion.role,
assertion.newrole
)
this.matcher.addRole(assertion['newrole'])
this.matcher.addRole(assertion.newrole)
}

@@ -42,4 +42,4 @@ } // assignRoles

assignOnlyOneOf (assertion) {
const role = assertion['role']
const values = oxford.breakStringList(assertion['field_list'])
const role = assertion.role
const values = oxford.breakStringList(assertion.field_list)
this.addConstraint(role, constraint.onlyOneOf(values), null)

@@ -49,15 +49,15 @@ } // assignOnlyOneOf

assignConstraints (assertion) {
const role = assertion['role']
const modal = assertion['modal']
const type = assertion['type']
const fieldName = assertion['field_name']
const fieldListString = assertion['field_list']
const relation = assertion['relation']
const target = assertion['target']
const strings = assertion['strings']
const role = assertion.role
const modal = assertion.modal
const type = assertion.type
const fieldName = assertion.field_name
const fieldListString = assertion.field_list
const relation = assertion.relation
const target = assertion.target
const strings = assertion.strings
// watch out for conditionals
let condition = null
if (assertion['excluded']) {
const excludedRoles = oxford.breakRoleList(this.matcher, assertion['excluded'])
if (assertion.excluded) {
const excludedRoles = oxford.breakRoleList(this.matcher, assertion.excluded)
condition = conditional.roleNotPresent(excludedRoles)

@@ -102,5 +102,5 @@ }

// there can be role defs there too
const childType = assertion['child_type']
const childType = assertion.child_type
if (childType) {
const childRole = assertion['child_role']
const childRole = assertion.child_role
this.matcher.addRole(childRole)

@@ -107,0 +107,0 @@ if (childType === 'value') {

@@ -64,3 +64,3 @@ const DateTime = require('luxon').DateTime

super()
this.names = Array.isArray(names) ? names : [ names ]
this.names = Array.isArray(names) ? names : [names]
} // constructor

@@ -168,6 +168,7 @@

break
case TYPES.timestamp:
case TYPES.timestamp: {
const ts = DateTime.fromISO(value)
if (!ts.isValid) report('an ISO8601 timestamp') // Spec actually says RFC3339, but close enough
break
}
case TYPES.URI:

@@ -254,3 +255,3 @@ if ((typeof value !== 'string') || (!value.match(/^[a-z]+:/))) report('a URI')

const obj = { }
for (const [ k, v ] of strMap) {
for (const [k, v] of strMap) {
// We don’t escape the key '__proto__'

@@ -257,0 +258,0 @@ // which can cause problems on older engines

@@ -7,4 +7,4 @@ // Tried use jsonpath to do this, but it couldn't distinguish between

const INITIAL_NAME_CLASSES = [ 'Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl' ]
const NON_INITIAL_NAME_CLASSES = [ 'Mn', 'Mc', 'Nd', 'Pc' ]
const INITIAL_NAME_CLASSES = ['Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl']
const NON_INITIAL_NAME_CLASSES = ['Mn', 'Mc', 'Nd', 'Pc']
const FOLLOWING_NAME_CLASSES = [...INITIAL_NAME_CLASSES, ...NON_INITIAL_NAME_CLASSES]

@@ -11,0 +11,0 @@ const DOT_SEPARATOR = '\\.\\.?'

@@ -49,3 +49,3 @@ const XRegExp = require('xregexp')

// so patch result across if present
if (constraint['child_type_each']) constraint['child_type'] = constraint['child_type_each']
if (constraint.child_type_each) constraint.child_type = constraint.child_type_each
return constraint

@@ -60,4 +60,4 @@ } // buildConstraint

const eachesLine = XRegExp.exec(line, this.eachOfMatch)
const eaches = oxford.breakRoleList(this, eachesLine['each_of'])
return eaches.map(e => `A ${e} ${eachesLine['trailer']}`)
const eaches = oxford.breakRoleList(this, eachesLine.each_of)
return eaches.map(e => `A ${e} ${eachesLine.trailer}`)
} // buildEachOfs

@@ -64,0 +64,0 @@

@@ -5,3 +5,3 @@ const XRegExp = require('xregexp')

function re (particle, options = { }) {
let [ hasCapture, inter, hasConnector, last ] = BASIC.split('X')
let [hasCapture, inter, hasConnector, last] = BASIC.split('X')

@@ -18,3 +18,3 @@ if (options.connector) {

return [ hasCapture, inter, hasConnector, last ].join(particle)
return [hasCapture, inter, hasConnector, last].join(particle)
} // re

@@ -27,3 +27,3 @@

for (let m = list.match(stringBreaker); m !== null; m = list.match(stringBreaker)) {
const [ consumed, matched ] = m
const [consumed, matched] = m
pieces.push(matched)

@@ -41,3 +41,3 @@ list = list.substring(consumed.length)

for (let m = list.match(roleBreaker); m !== null; m = list.match(roleBreaker)) {
const [ consumed, matched ] = m
const [consumed, matched] = m
pieces.push(matched)

@@ -44,0 +44,0 @@ list = list.substring(consumed.length)

@@ -15,3 +15,3 @@ class RoleConstraints {

? this.constraints.get(role)
: [ ]
: []
} // getConstraints

@@ -18,0 +18,0 @@

@@ -17,3 +17,3 @@ const TYPES = {

TYPES['includes'] = function (value) {
TYPES.includes = function (value) {
for (const e of AllTypes) {

@@ -20,0 +20,0 @@ if (e === value) {

{
"name": "@wmfs/j2119",
"version": "1.9.0",
"version": "1.10.0",
"description": "A general-purpose validator generator that uses RFC2119-style assertions as input.",

@@ -21,3 +21,3 @@ "author": "West Midlands Fire Service",

"dependencies": {
"luxon": "1.21.3",
"luxon": "1.22.0",
"n-readlines": "1.0.0",

@@ -30,10 +30,10 @@ "xregexp": "4.2.4"

"chai": "4.2.0",
"codecov": "3.6.1",
"conventional-changelog-metahub": "3.0.0",
"codecov": "3.6.2",
"conventional-changelog-metahub": "4.0.0",
"cz-conventional-changelog": "3.0.2",
"dirty-chai": "2.0.1",
"mocha": "7.0.0",
"mocha": "7.0.1",
"nyc": "15.0.0",
"semantic-release": "15.14.0",
"standard": "12.0.1"
"standard": "14.3.1"
},

@@ -40,0 +40,0 @@ "scripts": {

@@ -13,4 +13,4 @@ /* eslint-env mocha */

cut.setAllowed('foo', 'bar')
expect(cut.isAllowed([ 'foo' ], 'bar')).to.be.true()
expect(cut.isAllowed([ 'bar', 'baz', 'foo' ], 'bar')).to.be.true()
expect(cut.isAllowed(['foo'], 'bar')).to.be.true()
expect(cut.isAllowed(['bar', 'baz', 'foo'], 'bar')).to.be.true()
})

@@ -21,4 +21,4 @@

cut.setAllowed('foo', 'bar')
expect(cut.isAllowed([ 'foo' ], 'baz')).to.be.false()
expect(cut.isAllowed([ 'bar', 'baz', 'foo' ], 'baz')).to.be.false()
expect(cut.isAllowed(['foo'], 'baz')).to.be.false()
expect(cut.isAllowed(['bar', 'baz', 'foo'], 'baz')).to.be.false()
})

@@ -29,5 +29,5 @@

cut.setAllowed('foo', 'bar')
expect(!cut.isAllowed([ 'boo' ], 'baz')).to.be.true()
expect(!cut.isAllowed([ ], 'baz')).to.be.true()
expect(!cut.isAllowed(['boo'], 'baz')).to.be.true()
expect(!cut.isAllowed([], 'baz')).to.be.true()
})
})

@@ -16,8 +16,8 @@ /* eslint-env mocha */

const assertion = {
'role': 'R',
'modal': 'MUST',
'field_name': 'foo',
'excluded': 'an A, a B, or a C'
role: 'R',
modal: 'MUST',
field_name: 'foo',
excluded: 'an A, a B, or a C'
}
const roles = [ 'A', 'B', 'C' ]
const roles = ['A', 'B', 'C']
const constraints = roleConstraints()

@@ -34,7 +34,7 @@ const rf = roleFinder()

const c = retrieved[0]
const json = { 'a': 1 }
const json = { a: 1 }
roles.forEach(role =>
expect(c.applies(json, [ role ])).to.be.false()
expect(c.applies(json, [role])).to.be.false()
)
expect(c.applies(json, [ 'foo' ])).to.be.true()
expect(c.applies(json, ['foo'])).to.be.true()
})

@@ -44,8 +44,8 @@

const assertion = {
'role': 'R',
'modal': 'MAY',
'type': 'nonnegative-integer',
'field_name': 'MaxAttempts',
'relation': 'less than',
'target': '99999999'
role: 'R',
modal: 'MAY',
type: 'nonnegative-integer',
field_name: 'MaxAttempts',
relation: 'less than',
target: '99999999'
}

@@ -68,4 +68,4 @@ const constraints = roleConstraints()

const assertion = {
'role': 'R',
'field_list': '"foo", "bar", and "baz"'
role: 'R',
field_list: '"foo", "bar", and "baz"'
}

@@ -86,5 +86,5 @@ const constraints = roleConstraints()

const assertion = {
'role': 'R',
'modal': 'MUST',
'field_name': 'foo'
role: 'R',
modal: 'MUST',
field_name: 'foo'
}

@@ -105,5 +105,5 @@ const constraints = roleConstraints()

const assertion = {
'role': 'R',
'modal': 'MUST NOT',
'field_name': 'foo'
role: 'R',
modal: 'MUST NOT',
field_name: 'foo'
}

@@ -124,6 +124,6 @@ const constraints = roleConstraints()

const assertion = {
'role': 'R',
'modal': 'MUST',
'field_name': 'foo',
'type': 'nonnegative-float'
role: 'R',
modal: 'MUST',
field_name: 'foo',
type: 'nonnegative-float'
}

@@ -146,8 +146,8 @@ const constraints = roleConstraints()

const assertion = {
'role': 'R',
'modal': 'MUST',
'field_name': 'foo',
'type': 'nonnegative-float',
'relation': 'less than',
'target': '1000'
role: 'R',
modal: 'MUST',
field_name: 'foo',
type: 'nonnegative-float',
relation: 'less than',
target: '1000'
}

@@ -171,4 +171,4 @@ const constraints = roleConstraints()

const assertion = {
'role': 'R',
'newrole': 'S'
role: 'R',
newrole: 'S'
}

@@ -181,6 +181,6 @@ const rf = roleFinder()

cut.assignRoles(assertion)
const json = { 'a': 3 }
const roles = [ 'R' ]
const json = { a: 3 }
const roles = ['R']
rf.findMoreRoles(json, roles)
expect(roles).to.eql([ 'R', 'S' ])
expect(roles).to.eql(['R', 'S'])
})

@@ -190,7 +190,7 @@

const assertion = {
'role': 'R',
'fieldtomatch': 'f1',
'valtomatch': '33',
'newrole': 'S',
'val_match_present': true
role: 'R',
fieldtomatch: 'f1',
valtomatch: '33',
newrole: 'S',
val_match_present: true
}

@@ -203,4 +203,4 @@ const constraints = roleConstraints()

cut.assignRoles(assertion)
const json = { 'f1': 33 }
const roles = [ 'R' ]
const json = { f1: 33 }
const roles = ['R']
rf.findMoreRoles(json, roles)

@@ -212,7 +212,7 @@ expect(roles).to.eql(['R', 'S'])

const assertion = {
'role': 'R',
'modal': 'MUST',
'field_name': 'a',
'child_type': 'field',
'child_role': 'bar'
role: 'R',
modal: 'MUST',
field_name: 'a',
child_type: 'field',
child_role: 'bar'
}

@@ -225,6 +225,6 @@ const constraints = roleConstraints()

cut.assignConstraints(assertion)
const roles = [ 'R' ]
const roles = ['R']
const fieldRoles = rf.findGrandchildRoles(roles, 'a')
expect(fieldRoles).to.eql([ 'bar' ])
expect(fieldRoles).to.eql(['bar'])
})
})

@@ -12,3 +12,3 @@ /* eslint-env mocha */

const cut = condition.roleNotPresent(['foo', 'bar'])
const json = { 'bar': 1 }
const json = { bar: 1 }

@@ -20,5 +20,5 @@ expect(cut.constraintApplies(json, ['foo'])).to.be.false()

const cut = condition.roleNotPresent(['foo', 'bar'])
const json = { 'bar': 1 }
const json = { bar: 1 }
expect(cut.constraintApplies(json, ['baz'])).to.be.true()
})
})

@@ -14,3 +14,3 @@ /* eslint-env mocha */

const cut = constraint.hasField('foo')
const json = { 'bar': 1 }
const json = { bar: 1 }
expect(cut.applies(json, 'foo')).to.be.true()

@@ -28,3 +28,3 @@

const cut = constraint.hasField('foo')
const json = { 'bar': 1 }
const json = { bar: 1 }
const problems = []

@@ -37,3 +37,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.hasField('bar')
const json = { 'bar': 1 }
const json = { bar: 1 }
const problems = []

@@ -48,3 +48,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.nonEmpty('foo')
const json = { 'bar': 1 }
const json = { bar: 1 }
const problems = []

@@ -57,3 +57,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.nonEmpty('foo')
const json = { 'foo': 1 }
const json = { foo: 1 }
const problems = []

@@ -66,3 +66,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.nonEmpty('foo')
const json = { 'foo': [ 1 ] }
const json = { foo: [1] }
const problems = []

@@ -75,3 +75,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.nonEmpty('foo')
const json = { 'foo': [ ] }
const json = { foo: [] }
const problems = []

@@ -86,3 +86,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.doesNotHaveField('foo')
const json = { 'foo': 1 }
const json = { foo: 1 }
const problems = []

@@ -95,3 +95,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.doesNotHaveField('bar')
const json = { 'foo': 1 }
const json = { foo: 1 }
const problems = []

@@ -106,3 +106,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.fieldValue('foo', {})
const json = { 'foo': 1 }
const json = { foo: 1 }
const problems = []

@@ -114,4 +114,4 @@ cut.check(json, 'a.b.c', problems)

it('should detect a violation of enum policy', () => {
const cut = constraint.fieldValue('foo', { enum: [ 1, 2, 3 ] })
let json = { 'foo': 3 }
const cut = constraint.fieldValue('foo', { enum: [1, 2, 3] })
let json = { foo: 3 }
const problems = []

@@ -121,3 +121,3 @@ cut.check(json, 'a.b.c', problems)

json = { 'foo': 5 }
json = { foo: 5 }
cut.check(json, 'a.b.c', problems)

@@ -129,7 +129,7 @@ expect(problems.length).to.equal(1)

const cut = constraint.fieldValue('foo', { equal: 12 })
let json = { 'foo': 12 }
let json = { foo: 12 }
const problems = []
cut.check(json, 'a.b.c', problems)
expect(problems.length).to.equal(0)
json = { 'foo': 3 }
json = { foo: 3 }
cut.check(json, 'a.b.c', problems)

@@ -142,7 +142,7 @@ expect(problems.length).to.equal(1)

const problems = []
let json = { 'foo': 1 }
let json = { foo: 1 }
cut.check(json, 'a.b.c', problems)
expect(problems.length).to.equal(0)
json = { 'foo': 0 }
json = { foo: 0 }
cut.check(json, 'a.b.c', problems)

@@ -154,3 +154,3 @@ expect(problems.length).to.equal(1)

const cut = constraint.fieldValue('foo', { floor: 1 })
const json = { 'foo': 1 }
const json = { foo: 1 }
const problems = []

@@ -164,7 +164,7 @@ cut.check(json, 'a.b.c', problems)

const problems = []
let json = { 'foo': 2 }
let json = { foo: 2 }
cut.check(json, 'a.b.c', problems)
expect(problems.length).to.equal(0)
json = { 'foo': 3 }
json = { foo: 3 }
cut.check(json, 'a.b.c', problems)

@@ -176,3 +176,3 @@ expect(problems.length).to.equal(1)

const cut = constraint.fieldValue('foo', { max: 3 })
let json = { 'foo': 3 }
let json = { foo: 3 }
const problems = []

@@ -182,3 +182,3 @@ cut.check(json, 'a.b.c', problems)

json = { 'foo': 4 }
json = { foo: 4 }
cut.check(json, 'a.b.c', problems)

@@ -190,3 +190,3 @@ expect(problems.length).to.equal(1)

const cut = constraint.fieldValue('foo', { min: 0, max: 3 })
const json = { 'foo': 1 }
const json = { foo: 1 }
const problems = []

@@ -202,7 +202,7 @@ cut.check(json, 'a.b.c', problems)

const problems = []
let json = { 'foo': 1 }
let json = { foo: 1 }
cut.check(json, 'a.b.c', problems)
expect(problems.length).to.equal(0)
json = { 'foo': 1, 'bar': 2 }
json = { foo: 1, bar: 2 }
cut.check(json, 'a.b.c', problems)

@@ -216,3 +216,3 @@ expect(problems.length).to.equal(1)

const cut = constraint.fieldType('foo', 'integer', false, false)
const json = { 'bar': 1 }
const json = { bar: 1 }
const problems = []

@@ -231,3 +231,3 @@ cut.check(json, 'a.b.c', problems)

object: { a: 1 },
array: [ 3, 4 ],
array: [3, 4],
JSONPath: '$.a.c[2,3]',

@@ -250,3 +250,3 @@ referencePath: '$.a[\'b\'].d[3]',

const cut = constraint.fieldType('a', 'integer', false, false)
const json = { 'a': [ 1, 2, 'foo', 4 ] }
const json = { a: [1, 2, 'foo', 4] }
const problems = []

@@ -281,3 +281,3 @@ cut.check(json, 'a.b.c', problems)

it('should handle nullable correctly', () => {
const json = { 'a': null }
const json = { a: null }
let cut = constraint.fieldType('a', 'string', false, false)

@@ -305,3 +305,3 @@ let problems = []

const cut = constraint.fieldType('foo', 'integer', true, false)
const json = { foo: [ 'bar' ] }
const json = { foo: ['bar'] }
const problems = []

@@ -314,3 +314,3 @@ cut.check(json, 'a.b.c', problems)

const cut = constraint.fieldType('foo', 'integer', true, false)
const json = { foo: [ 1 ] }
const json = { foo: [1] }
const problems = []

@@ -317,0 +317,0 @@ cut.check(json, 'a.b.c', problems)

@@ -37,4 +37,4 @@ /* eslint-env mocha */

expect(m).to.be.ok()
expect(m['role']).to.eql('x')
const s = m['field_list']
expect(m.role).to.eql('x')
const s = m.field_list
const l = oxford.breakStringList(s)

@@ -105,7 +105,7 @@ expect(l).to.contain('Seconds', 'SecondsPath', 'Timestamp', 'TimestampPath')

const m = XRegExp.exec(VALUE_BASED_ROLE_DEFS[0], cut.roledefMatch)
expect(m['role']).to.eql('State')
expect(m['fieldtomatch']).to.eql('End')
expect(m['valtomatch']).to.eql('true')
expect(m['newrole']).to.eql('Terminal State')
expect(m['val_match_present']).to.be.ok()
expect(m.role).to.eql('State')
expect(m.fieldtomatch).to.eql('End')
expect(m.valtomatch).to.eql('true')
expect(m.newrole).to.eql('Terminal State')
expect(m.val_match_present).to.be.ok()
})

@@ -115,7 +115,7 @@

const m = XRegExp.exec(VALUE_BASED_ROLE_DEFS[1], cut.roledefMatch)
expect(m['role']).to.eql('State')
expect(m['fieldtomatch']).to.eql('Comment')
expect(m['valtomatch']).to.eql('"Hi"')
expect(m['newrole']).to.eql('Frobble')
expect(m['val_match_present']).to.be.ok()
expect(m.role).to.eql('State')
expect(m.fieldtomatch).to.eql('Comment')
expect(m.valtomatch).to.eql('"Hi"')
expect(m.newrole).to.eql('Frobble')
expect(m.val_match_present).to.be.ok()
})

@@ -125,5 +125,5 @@

const m = XRegExp.exec(VALUE_BASED_ROLE_DEFS[2], cut.roledefMatch)
expect(m['role']).to.eql('State')
expect(m['newrole']).to.eql('Bar')
expect(m['with_a_field']).to.be.ok()
expect(m.role).to.eql('State')
expect(m.newrole).to.eql('Bar')
expect(m.with_a_field).to.be.ok()
})

@@ -141,3 +141,3 @@ })

const c = cut.buildRoleDef('A Foo is a "Bar".')
expect(c['val_match_present']).to.be.null()
expect(c.val_match_present).to.be.null()
})

@@ -149,6 +149,6 @@

const c = cut.buildRoleDef(VALUE_BASED_ROLE_DEFS[0])
expect(c['role']).to.eql('State')
expect(c['fieldtomatch']).to.eql('End')
expect(c['valtomatch']).to.eql('true')
expect(c['newrole']).to.eql('Terminal State')
expect(c.role).to.eql('State')
expect(c.fieldtomatch).to.eql('End')
expect(c.valtomatch).to.eql('true')
expect(c.newrole).to.eql('Terminal State')
})

@@ -158,6 +158,6 @@

const c = cut.buildRoleDef(VALUE_BASED_ROLE_DEFS[1])
expect(c['role']).to.eql('State')
expect(c['fieldtomatch']).to.eql('Comment')
expect(c['valtomatch']).to.eql('"Hi"')
expect(c['newrole']).to.eql('Frobble')
expect(c.role).to.eql('State')
expect(c.fieldtomatch).to.eql('Comment')
expect(c.valtomatch).to.eql('"Hi"')
expect(c.newrole).to.eql('Frobble')
})

@@ -214,3 +214,3 @@ })

const m = XRegExp.exec(line, cut.constraintMatch)
expect(m['excluded']).to.eql(excludes.shift())
expect(m.excluded).to.eql(excludes.shift())
})

@@ -239,9 +239,9 @@ )

const c = cut.buildConstraint(s)
expect(c['role']).to.eql('State')
expect(c['modal']).to.eql('MUST')
expect(c['type']).to.eql('string')
expect(c['field_name']).to.eql('Type')
expect(c['relation']).to.be.null()
expect(c['strings']).to.eql('"Pass", "Succeed", "Fail", "Task", "Choice", "Wait", or "Parallel"')
expect(c['child_type']).to.be.null()
expect(c.role).to.eql('State')
expect(c.modal).to.eql('MUST')
expect(c.type).to.eql('string')
expect(c.field_name).to.eql('Type')
expect(c.relation).to.be.null()
expect(c.strings).to.eql('"Pass", "Succeed", "Fail", "Task", "Choice", "Wait", or "Parallel"')
expect(c.child_type).to.be.null()
})

@@ -253,10 +253,10 @@

const c = cut.buildConstraint(s)
expect(c['role']).to.eql('Retrier')
expect(c['modal']).to.eql('MAY')
expect(c['type']).to.eql('nonnegative-integer')
expect(c['field_name']).to.eql('MaxAttempts')
expect(c['strings']).to.be.null()
expect(c['relation']).to.eql('less than')
expect(c['target']).to.eql('99999999')
expect(c['child_type']).to.be.null()
expect(c.role).to.eql('Retrier')
expect(c.modal).to.eql('MAY')
expect(c.type).to.eql('nonnegative-integer')
expect(c.field_name).to.eql('MaxAttempts')
expect(c.strings).to.be.null()
expect(c.relation).to.eql('less than')
expect(c.target).to.eql('99999999')
expect(c.child_type).to.be.null()
})

@@ -270,8 +270,8 @@

const c = cut.buildConstraint(s)
expect(c['role']).to.eql('State Machine')
expect(c['modal']).to.eql('MUST')
expect(c['type']).to.eql('object')
expect(c['field_name']).to.eql('States')
expect(c['child_type']).to.eql('field')
expect(c['child_role']).to.eql('State')
expect(c.role).to.eql('State Machine')
expect(c.modal).to.eql('MUST')
expect(c.type).to.eql('object')
expect(c.field_name).to.eql('States')
expect(c.child_type).to.eql('field')
expect(c.child_role).to.eql('State')
})

@@ -284,9 +284,9 @@

const c = cut.buildConstraint(line)
expect(c['role']).to.eql('State Machine')
expect(c['modal']).to.eql('MAY')
expect(c['type']).to.eql('object')
expect(c['field_name']).to.eql('Not')
expect(c['child_role']).to.eql('FOO')
expect(c.role).to.eql('State Machine')
expect(c.modal).to.eql('MAY')
expect(c.type).to.eql('object')
expect(c.field_name).to.eql('Not')
expect(c.child_role).to.eql('FOO')
})
})
})

@@ -58,7 +58,7 @@ /* eslint-env mocha */

const OXFORD_LISTS = [
[ 'an R2', [ 'R2' ] ],
[ 'an R2 or an R3', [ 'R2', 'R3' ] ],
[ 'an R2, an R3, or an R4', [ 'R2', 'R3', 'R4' ] ]
['an R2', ['R2']],
['an R2 or an R3', ['R2', 'R3']],
['an R2, an R3, or an R4', ['R2', 'R3', 'R4']]
]
const roles = [ 'R2', 'R3', 'R4' ]
const roles = ['R2', 'R3', 'R4']
describe('should properly break up a role list', () => {

@@ -75,5 +75,5 @@ const matcher = lineMatcher('R1')

const STRING_LISTS = [
[ '"R2"', [ 'R2' ] ],
[ '"R2" or "R3"', [ 'R2', 'R3' ] ],
[ '"R2", "R3", or "R4"', [ 'R2', 'R3', 'R4' ] ]
['"R2"', ['R2']],
['"R2" or "R3"', ['R2', 'R3']],
['"R2", "R3", or "R4"', ['R2', 'R3', 'R4']]
]

@@ -80,0 +80,0 @@ describe('should properly break up a string list', () => {

@@ -213,19 +213,19 @@ /* eslint-env mocha */

task.Retry = [ 1 ]
task.Retry = [1]
runTest(v, obj, 1)
task.Retry = [ { MaxAttempts: 0 }, { BackoffRate: 1.5 } ]
task.Retry = [{ MaxAttempts: 0 }, { BackoffRate: 1.5 }]
runTest(v, obj, 2)
task.Retry = [ { ErrorEquals: 1 }, { ErrorEquals: true } ]
task.Retry = [{ ErrorEquals: 1 }, { ErrorEquals: true }]
runTest(v, obj, 2)
task.Retry = [ { ErrorEquals: [ 1 ] }, { ErrorEquals: [ true ] } ]
task.Retry = [{ ErrorEquals: [1] }, { ErrorEquals: [true] }]
runTest(v, obj, 2)
task.Retry = [ { ErrorEquals: [ 'foo' ] }, { ErrorEquals: [ 'bar' ] } ]
task.Retry = [{ ErrorEquals: ['foo'] }, { ErrorEquals: ['bar'] }]
runTest(v, obj, 0)
const rt = {
ErrorEquals: [ 'foo' ],
ErrorEquals: ['foo'],
IntervalSeconds: 'bar',

@@ -235,3 +235,3 @@ MaxAttempts: true,

}
task.Retry = [ rt ]
task.Retry = [rt]
runTest(v, obj, 3)

@@ -252,4 +252,4 @@

const catchExpr = { ErrorEquals: [ 'foo' ], Next: 'n' }
task.Catch = [ catchExpr ]
const catchExpr = { ErrorEquals: ['foo'], Next: 'n' }
task.Catch = [catchExpr]
runTest(v, obj, 0)

@@ -270,6 +270,6 @@

catchExpr.ErrorEquals = [ 3 ]
catchExpr.ErrorEquals = [3]
runTest(v, obj, 1)
catchExpr.ErrorEquals = [ 'x' ]
catchExpr.ErrorEquals = ['x']
})

@@ -294,3 +294,3 @@

obj.States['choice'] = choice
obj.States.choice = choice
runTest(v, obj, 0)

@@ -535,3 +535,3 @@

States: {
'p1': {
p1: {
Type: 'Pass',

@@ -559,6 +559,6 @@ End: true

para.Branches = [ 3 ]
para.Branches = [3]
runTest(v, obj, 1)
para.Branches = [ { } ]
para.Branches = [{ }]
runTest(v, obj, 2)

@@ -570,3 +570,3 @@

States: {
'p1': {
p1: {
Type: 'foo',

@@ -585,3 +585,3 @@ End: true

States: {
'p1': {
p1: {
Type: 'Pass',

@@ -588,0 +588,0 @@ End: true

@@ -14,3 +14,3 @@ /* eslint-env mocha */

cut.addIsARole('OneRole', 'AnotherRole')
const roles = [ 'OneRole' ]
const roles = ['OneRole']
cut.findMoreRoles(json, roles)

@@ -25,3 +25,3 @@ expect(roles.length).to.equal(2)

cut.addFieldValueRole('MyRole', 'a', '3', 'NewRole')
const roles = [ 'MyRole' ]
const roles = ['MyRole']
cut.findMoreRoles(json, roles)

@@ -36,3 +36,3 @@ expect(roles.length).to.equal(2)

cut.addFieldPresenceRole('MyRole', 'a', 'NewRole')
const roles = [ 'MyRole' ]
const roles = ['MyRole']
cut.findMoreRoles(json, roles)

@@ -46,3 +46,3 @@ expect(roles.length).to.equal(2)

cut.addGrandchildRole('MyRole', 'a', 'NewRole')
const roles = [ 'MyRole' ]
const roles = ['MyRole']
const grandchildRoles = cut.findGrandchildRoles(roles, 'a')

@@ -56,3 +56,3 @@ expect(grandchildRoles.length).to.equal(1)

cut.addChildRole('MyRole', 'a', 'NewRole')
const roles = [ 'MyRole' ]
const roles = ['MyRole']
const childRoles = cut.findChildRoles(roles, 'a')

@@ -59,0 +59,0 @@ expect(childRoles.length).to.equal(1)

@@ -171,3 +171,3 @@ /* eslint-env mocha */

const v = validator(SCHEMA)
const p = v.validate([ STATE_MACHINE ])
const p = v.validate([STATE_MACHINE])
expect(p.length).to.eql(1)

@@ -174,0 +174,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