@wmfs/asl-choice-processor 1.22.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,55 @@
1
+ # [1.23.0](https://github.com/wmfs/asl-choice-processor/compare/v1.22.0...v1.23.0) (2022-08-12)
2
+
3
+
4
+ ### ✨ Features
5
+
6
+ * added IsPresent support ([a4329d9](https://github.com/wmfs/asl-choice-processor/commit/a4329d9d073a978164ecf9af60c0e61c404e6360))
7
+
8
+
9
+ ### 🛠 Builds
10
+
11
+ * **deps-dev:** bump codecov from 3.8.2 to 3.8.3 ([712bddd](https://github.com/wmfs/asl-choice-processor/commit/712bddd2ba73ce27d34a1c51efff23c1ee74fe9a))
12
+ * **deps-dev:** bump mocha from 8.4.0 to 9.0.0 ([64aa3d0](https://github.com/wmfs/asl-choice-processor/commit/64aa3d08cfb596ef4a41e4387a9fb1124231945a))
13
+ * **deps-dev:** bump mocha from 9.0.0 to 9.0.1 ([050993c](https://github.com/wmfs/asl-choice-processor/commit/050993c781b17c04ff1d69f3a12e442ac3cbfed2))
14
+ * **deps-dev:** bump mocha from 9.0.1 to 9.0.2 ([a40efde](https://github.com/wmfs/asl-choice-processor/commit/a40efde5d8b8337819ff24e04eb9ddeba3454a73))
15
+ * **deps-dev:** bump mocha from 9.0.2 to 9.0.3 ([e6a16c0](https://github.com/wmfs/asl-choice-processor/commit/e6a16c0d192f0ea5fab80d4f74af606b09fbb8a1))
16
+ * **deps-dev:** bump semantic-release from 17.4.2 to 17.4.3 ([5c714e4](https://github.com/wmfs/asl-choice-processor/commit/5c714e436c8a6a2654cdc0a4ea3cc4b4c4f200ed))
17
+ * **deps-dev:** bump semantic-release from 17.4.3 to 17.4.4 ([afc6af8](https://github.com/wmfs/asl-choice-processor/commit/afc6af89d2d1a1c0b20afee7f36a0fa38ab32a68))
18
+ * **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/changelog to v6 ([a2f795f](https://github.com/wmfs/asl-choice-processor/commit/a2f795f42a99e1cc120acce816733b7da5100cf2))
19
+ * **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/git to v10 ([d986753](https://github.com/wmfs/asl-choice-processor/commit/d986753b02758935c5dc42c39b581e9e0057a687))
20
+ * **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/git to v9.0.1 ([16b753d](https://github.com/wmfs/asl-choice-processor/commit/16b753d1ab1cebed3ba839213f1336ed23397127))
21
+ * **deps-dev:** update dependency chai to v4.3.5 ([2f3103c](https://github.com/wmfs/asl-choice-processor/commit/2f3103cc87e410ce47bd7fa27817ff3cb0fa7a7a))
22
+ * **deps-dev:** update dependency chai to v4.3.6 ([2ad7add](https://github.com/wmfs/asl-choice-processor/commit/2ad7add962a0b60b483f3b81357bd5b367702e9f))
23
+ * **deps-dev:** update dependency mocha to v10 ([2233142](https://github.com/wmfs/asl-choice-processor/commit/2233142a3925884e4826a79cdebf6e59b3486177))
24
+ * **deps-dev:** update dependency mocha to v9.1.0 ([fc4b92f](https://github.com/wmfs/asl-choice-processor/commit/fc4b92f4ba0d78f36db2bd1f880ca77b2c29ed5b))
25
+ * **deps-dev:** update dependency mocha to v9.1.1 ([0ad11d8](https://github.com/wmfs/asl-choice-processor/commit/0ad11d8c5ce49fbf681fd2a9b2a97a074ed91bdf))
26
+ * **deps-dev:** update dependency mocha to v9.1.2 ([932f4f4](https://github.com/wmfs/asl-choice-processor/commit/932f4f4583a107e700474acb533b8ec8df7afe8e))
27
+ * **deps-dev:** update dependency mocha to v9.1.3 ([47ce905](https://github.com/wmfs/asl-choice-processor/commit/47ce90568f29cfb435144cec6fa0ad6dbe42b001))
28
+ * **deps-dev:** update dependency mocha to v9.1.4 ([0402f9a](https://github.com/wmfs/asl-choice-processor/commit/0402f9aa14fcbdf4f2ff5e7c7bb22ca224609bf0))
29
+ * **deps-dev:** update dependency mocha to v9.2.0 ([1566cb7](https://github.com/wmfs/asl-choice-processor/commit/1566cb75fffa6f2a37a6ca2c08ab79b5795d0365))
30
+ * **deps-dev:** update dependency mocha to v9.2.1 ([764cec8](https://github.com/wmfs/asl-choice-processor/commit/764cec85cb4dbcadd3c0b1c65624e0b4c0ec6ac1))
31
+ * **deps-dev:** update dependency mocha to v9.2.2 ([49f264e](https://github.com/wmfs/asl-choice-processor/commit/49f264e9a9e4d588ff649d42793027c7785f13b2))
32
+ * **deps-dev:** update dependency semantic-release to v17.4.5 ([d5847a0](https://github.com/wmfs/asl-choice-processor/commit/d5847a0ae6fe34f87157271645d09219980bf33d))
33
+ * **deps-dev:** update dependency semantic-release to v17.4.6 ([9e1eae6](https://github.com/wmfs/asl-choice-processor/commit/9e1eae62e7b59526d68054069a757c4a486dcc49))
34
+ * **deps-dev:** update dependency semantic-release to v17.4.7 ([3cc6787](https://github.com/wmfs/asl-choice-processor/commit/3cc6787c40a2410c6e7d979ae1b99528fe99f63d))
35
+ * **deps-dev:** update dependency semantic-release to v18 ([a2637ad](https://github.com/wmfs/asl-choice-processor/commit/a2637ad438cf3562130918cedefc67bb20994c26))
36
+ * **deps-dev:** update dependency semantic-release to v18.0.1 ([4fba981](https://github.com/wmfs/asl-choice-processor/commit/4fba9817255c605ffcdee3f39704bb5932aa2693))
37
+ * **deps-dev:** update dependency semantic-release to v19 ([5c5442f](https://github.com/wmfs/asl-choice-processor/commit/5c5442f7421dcaeab81c2de3d8aee113b02639ef))
38
+ * **deps-dev:** update dependency semantic-release to v19.0.3 ([a6747df](https://github.com/wmfs/asl-choice-processor/commit/a6747dfdc80b51e34b9b52427c52a4e09bf87f8f))
39
+ * **deps-dev:** update dependency standard to v16.0.4 ([d760224](https://github.com/wmfs/asl-choice-processor/commit/d760224bb33f2a964ed173a33c51fa290f60a9b8))
40
+ * **deps-dev:** update dependency standard to v17 ([56d5e3f](https://github.com/wmfs/asl-choice-processor/commit/56d5e3f059839530235ba16b657b7272e91b988b))
41
+ * **deps-dev:** update semantic-release monorepo ([bc62bcd](https://github.com/wmfs/asl-choice-processor/commit/bc62bcd1f225747199d6510f39a8cf46bfb238e6))
42
+
43
+
44
+ ### ♻️ Chores
45
+
46
+ * add renovate config [ch6600] ([9de7776](https://github.com/wmfs/asl-choice-processor/commit/9de77760c6fa816550069d4f496d3cf68e23b086))
47
+
48
+
49
+ ### 💎 Styles
50
+
51
+ * standard ([86c9d94](https://github.com/wmfs/asl-choice-processor/commit/86c9d9421b88b6463e91682d52497eb1e82a5e8a))
52
+
1
53
  # [1.22.0](https://github.com/wmfs/asl-choice-processor/compare/v1.21.0...v1.22.0) (2021-05-11)
2
54
 
3
55
 
@@ -3,6 +3,7 @@ module.exports = {
3
3
  Includes: require('./includes'),
4
4
  IsUndefined: require('./is-undefined'),
5
5
  IsNull: require('./is-null'),
6
+ IsPresent: require('./is-present'),
6
7
  NumericEquals: require('./numeric-equals'),
7
8
  NumericGreaterThan: require('./numeric-greater-than'),
8
9
  NumericGreaterThanEquals: require('./numeric-greater-than-equals'),
@@ -0,0 +1,6 @@
1
+ 'use strict'
2
+
3
+ module.exports = function isPresentOperator (inputValue, comparisonValue, candidateStateName, cache) {
4
+ const IsUndefined = require('./is-undefined')
5
+ return IsUndefined(inputValue, !comparisonValue, candidateStateName, cache)
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wmfs/asl-choice-processor",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "For determining the next state given an Amazon States Language 'Choices' definition and a set of values.",
5
5
  "author": "West Midlands Fire Service",
6
6
  "homepage": "https://github.com/wmfs/asl-choice-processor#readme",
@@ -23,16 +23,16 @@
23
23
  "lodash": "4.17.21"
24
24
  },
25
25
  "devDependencies": {
26
- "chai": "4.3.4",
27
- "codecov": "3.8.2",
26
+ "chai": "4.3.6",
27
+ "codecov": "3.8.3",
28
28
  "conventional-changelog-metahub": "4.0.1",
29
29
  "cz-conventional-changelog": "3.3.0",
30
- "mocha": "8.4.0",
30
+ "mocha": "10.0.0",
31
31
  "nyc": "15.1.0",
32
- "semantic-release": "17.4.2",
33
- "standard": "16.0.3",
34
- "@semantic-release/changelog": "5.0.1",
35
- "@semantic-release/git": "9.0.0"
32
+ "semantic-release": "19.0.3",
33
+ "standard": "17.0.0",
34
+ "@semantic-release/changelog": "6.0.1",
35
+ "@semantic-release/git": "10.0.1"
36
36
  },
37
37
  "scripts": {
38
38
  "lint": "standard",
package/renovate.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ],
5
+ "dependencyDashboard": true,
6
+ "enabledManagers": ["npm"],
7
+ "packageRules": [
8
+ {
9
+ "matchDepTypes": ["devDependencies"],
10
+ "automerge": true,
11
+ "semanticCommitType": "build",
12
+ "semanticCommitScope": "deps-dev",
13
+ "labels": ["devDependencies"]
14
+ },
15
+ {
16
+ "matchDepTypes": ["dependencies"],
17
+ "semanticCommitType": "build",
18
+ "semanticCommitScope": "deps",
19
+ "labels": ["dependencies"],
20
+ "reviewers": ["team:tymly-reviewers"]
21
+ }
22
+ ],
23
+ "vulnerabilityAlerts": {
24
+ "labels": ["security"]
25
+ }
26
+ }
@@ -0,0 +1,162 @@
1
+ /* eslint-env mocha */
2
+
3
+ 'use strict'
4
+
5
+ const chai = require('chai')
6
+ const expect = chai.expect
7
+
8
+ const choiceProcessor = require('./../lib')
9
+
10
+ const tests = {
11
+ Not: [
12
+ {
13
+ choices: {
14
+ Choices: [
15
+ {
16
+ Not: {
17
+ Variable: '$.notPresent',
18
+ IsPresent: true
19
+ },
20
+ Next: 'NextState'
21
+ }
22
+ ],
23
+ Default: 'DefaultState'
24
+ },
25
+ input: { type: 'Public' },
26
+ expected: 'NextState'
27
+ },
28
+ {
29
+ choices: {
30
+ Choices: [
31
+ {
32
+ Not: {
33
+ Variable: '$.type',
34
+ IsPresent: false
35
+ },
36
+ Next: 'NextState'
37
+ }
38
+ ],
39
+ Default: 'DefaultState'
40
+ },
41
+ input: { type: 'Public' },
42
+ expected: 'NextState'
43
+ }
44
+ ],
45
+ And: [
46
+ {
47
+ choices: {
48
+ Choices: [
49
+ {
50
+ And: [
51
+ {
52
+ Variable: '$.value',
53
+ IsPresent: true
54
+ },
55
+ {
56
+ Variable: '$.name',
57
+ IsPresent: true
58
+ }
59
+ ],
60
+ Next: 'NextState'
61
+ }
62
+ ],
63
+ Default: 'DefaultState'
64
+ },
65
+ input: { value: 21, name: 'age' },
66
+ expected: 'NextState'
67
+ }
68
+ ],
69
+ Or: [
70
+ {
71
+ choices: {
72
+ Choices: [
73
+ {
74
+ Or: [
75
+ {
76
+ Variable: '$.value',
77
+ IsPresent: true
78
+ },
79
+ {
80
+ Variable: '$.name',
81
+ IsPresent: true
82
+ }
83
+ ],
84
+ Next: 'NextState'
85
+ }
86
+ ],
87
+ Default: 'DefaultState'
88
+ },
89
+ input: { value: 22 },
90
+ expected: 'NextState'
91
+ },
92
+ {
93
+ choices: {
94
+ Choices: [
95
+ {
96
+ Or: [
97
+ {
98
+ Variable: '$.value',
99
+ NumericGreaterThan: 22
100
+ },
101
+ {
102
+ Variable: '$.value',
103
+ NumericLessThan: 25
104
+ }
105
+ ],
106
+ Next: 'NextState'
107
+ }
108
+ ],
109
+ Default: 'DefaultState'
110
+ },
111
+ input: { value: 25 },
112
+ expected: 'NextState'
113
+ }
114
+ ],
115
+ Mixed: [
116
+ {
117
+ choices: {
118
+ Choices: [
119
+ {
120
+ Not: {
121
+ Variable: '$.type',
122
+ StringEquals: 'Private'
123
+ },
124
+ Next: 'Public'
125
+ },
126
+ {
127
+ And: [
128
+ {
129
+ Variable: '$.value',
130
+ IsPresent: true
131
+ },
132
+ {
133
+ Variable: '$.type',
134
+ IsPresent: true
135
+ }
136
+ ],
137
+ Next: 'ValueInTwenties'
138
+ }
139
+ ],
140
+ Default: 'RecordEvent'
141
+ },
142
+ input: { type: 'Private', value: 22 },
143
+ expected: 'ValueInTwenties'
144
+ }
145
+ ]
146
+ }
147
+
148
+ describe('IsPresent expression', () => {
149
+ for (const [operator, t] of Object.entries(tests)) {
150
+ describe(operator, () => {
151
+ let i = 0
152
+ for (const { choices, input, expected } of t) {
153
+ i++
154
+ it(`${i}`, () => {
155
+ const calculateNextState = choiceProcessor(choices)
156
+ const result = calculateNextState(input)
157
+ expect(result).to.eql(expected)
158
+ })
159
+ }
160
+ })
161
+ }
162
+ })