@bluedot-innovation/models 6.2.10 → 6.2.11-alpha.1
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 +4 -0
- package/__tests__/account/account.spec.js +2 -2
- package/__tests__/action/message/messageAction.spec.js +2 -2
- package/__tests__/action/url/urlAction.spec.js +2 -2
- package/__tests__/beacon/beacon.spec.js +6 -6
- package/__tests__/condition/dayRange/dayRange.spec.js +4 -4
- package/__tests__/condition/percentageCrossed/travelPath.spec.js +2 -2
- package/__tests__/condition/speed/speed.spec.js +6 -4
- package/__tests__/condition/timeActive/timeActive.spec.js +7 -6
- package/__tests__/condition/travelDirection/travelDirection.spec.js +5 -5
- package/__tests__/cumulativeRulesRequests/checkDailyStats.js +1 -2
- package/__tests__/dailyStats/dailyStats.spec.js +4 -4
- package/__tests__/geofeature/boundingBox/boundingBox.spec.js +4 -4
- package/__tests__/geofeature/circle/circle.spec.js +2 -2
- package/__tests__/geofeature/geoline/geoline.spec.js +2 -2
- package/__tests__/geofeature/polygon/polygon.spec.js +3 -3
- package/__tests__/geofeature/zoneBeacon/zoneBeacon.spec.js +2 -2
- package/__tests__/monthlyStats/monthlyStats.spec.js +3 -3
- package/__tests__/project/project.spec.js +7 -7
- package/__tests__/user/user.spec.js +3 -3
- package/__tests__/zone/zone.action.spec.js +1 -1
- package/__tests__/zone/zone.condition.spec.js +1 -1
- package/__tests__/zone/zone.geofeatures.spec.js +5 -5
- package/__tests__/zone/zone.spec.js +12 -12
- package/models/DailyStats.js +2 -2
- package/models/MonthlyStats.js +2 -2
- package/models/Project.js +1 -1
- package/models/UrlAction.js +0 -1
- package/models/Zone.js +1 -1
- package/models/conditions/Speed.js +6 -5
- package/models/conditions/TimeActive.js +8 -7
- package/models/conditions/TravelDirection.js +5 -5
- package/models/geofeatures/BoundingBox.js +0 -1
- package/package.json +3 -3
- package/schemas/ProjectPermission.js +1 -1
- package/schemas/Webhook.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -52,7 +52,7 @@ testCase('Account', () => {
|
|
|
52
52
|
Account.validate((err, res) => {
|
|
53
53
|
assert.notExists(res)
|
|
54
54
|
assert.exists(err, 'err object should exist')
|
|
55
|
-
assert.isObject(err)
|
|
55
|
+
assert.isObject(err.errors)
|
|
56
56
|
assert.nestedProperty(err, `errors.${requiredField}`, `error should have a ${requiredField} property`)
|
|
57
57
|
done()
|
|
58
58
|
})
|
|
@@ -74,7 +74,7 @@ testCase('Account', () => {
|
|
|
74
74
|
Account.validate((err, res) => {
|
|
75
75
|
assert.notExists(res)
|
|
76
76
|
assert.exists(err, 'err object should exist')
|
|
77
|
-
assert.isObject(err)
|
|
77
|
+
assert.isObject(err.errors)
|
|
78
78
|
assert.nestedProperty(err, `errors.${customValidator.name}`, `error should have a ${customValidator.name} property`)
|
|
79
79
|
done()
|
|
80
80
|
})
|
|
@@ -48,7 +48,7 @@ testCase('MessageAction', () => {
|
|
|
48
48
|
let MessageAction = new MessageActionModel(messageAction)
|
|
49
49
|
MessageAction.validate((err, res) => {
|
|
50
50
|
assert.exists(err, 'err object should exist')
|
|
51
|
-
assert.isObject(err)
|
|
51
|
+
assert.isObject(err.errors)
|
|
52
52
|
done()
|
|
53
53
|
})
|
|
54
54
|
})
|
|
@@ -62,7 +62,7 @@ testCase('MessageAction', () => {
|
|
|
62
62
|
MessageAction.validate((err, res) => {
|
|
63
63
|
assert.notExists(res)
|
|
64
64
|
assert.exists(err, 'err object should exist')
|
|
65
|
-
assert.isObject(err)
|
|
65
|
+
assert.isObject(err.errors)
|
|
66
66
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
67
67
|
done()
|
|
68
68
|
})
|
|
@@ -49,7 +49,7 @@ testCase('Urlaction', () => {
|
|
|
49
49
|
let Urlaction = new UrlactionModel(urlaction)
|
|
50
50
|
Urlaction.validate((err, res) => {
|
|
51
51
|
assert.exists(err, 'err object should exist')
|
|
52
|
-
assert.isObject(err)
|
|
52
|
+
assert.isObject(err.errors)
|
|
53
53
|
done()
|
|
54
54
|
})
|
|
55
55
|
})
|
|
@@ -63,7 +63,7 @@ testCase('Urlaction', () => {
|
|
|
63
63
|
Urlaction.validate((err, res) => {
|
|
64
64
|
assert.notExists(res)
|
|
65
65
|
assert.exists(err, 'err object should exist')
|
|
66
|
-
assert.isObject(err)
|
|
66
|
+
assert.isObject(err.errors)
|
|
67
67
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
68
68
|
done()
|
|
69
69
|
})
|
|
@@ -38,7 +38,7 @@ describe('Beacon', () => {
|
|
|
38
38
|
let Beacon = new BeaconModel(beacon)
|
|
39
39
|
Beacon.validate((err, res) => {
|
|
40
40
|
assert.exists(err, 'err object should exist')
|
|
41
|
-
assert.isObject(err)
|
|
41
|
+
assert.isObject(err.errors)
|
|
42
42
|
done()
|
|
43
43
|
})
|
|
44
44
|
|
|
@@ -58,7 +58,7 @@ describe('Beacon', () => {
|
|
|
58
58
|
Beacon.validate((err, res) => {
|
|
59
59
|
assert.notExists(res)
|
|
60
60
|
assert.exists(err, 'err object should exist')
|
|
61
|
-
assert.isObject(err)
|
|
61
|
+
assert.isObject(err.errors)
|
|
62
62
|
assert.nestedProperty(err, `errors.${field}`, `error should have a ${field} property`)
|
|
63
63
|
done()
|
|
64
64
|
})
|
|
@@ -74,7 +74,7 @@ describe('Beacon', () => {
|
|
|
74
74
|
Beacon.validate((err, res) => {
|
|
75
75
|
assert.notExists(res)
|
|
76
76
|
assert.exists(err, 'err object should exist')
|
|
77
|
-
assert.isObject(err)
|
|
77
|
+
assert.isObject(err.errors)
|
|
78
78
|
assert.nestedProperty(err, `errors.${field}`, `error should have a ${field} property`)
|
|
79
79
|
done()
|
|
80
80
|
})
|
|
@@ -94,7 +94,7 @@ describe('Beacon', () => {
|
|
|
94
94
|
Beacon.validate((err, res) => {
|
|
95
95
|
assert.notExists(res)
|
|
96
96
|
assert.exists(err, 'err object should exist')
|
|
97
|
-
assert.isObject(err)
|
|
97
|
+
assert.isObject(err.errors)
|
|
98
98
|
assert.nestedProperty(err, `errors.${requiredField}`, `error should have a ${requiredField} property`)
|
|
99
99
|
done()
|
|
100
100
|
})
|
|
@@ -132,7 +132,7 @@ describe('Beacon', () => {
|
|
|
132
132
|
Beacon.validate((err, res) => {
|
|
133
133
|
assert.notExists(res)
|
|
134
134
|
assert.exists(err, 'err object should exist')
|
|
135
|
-
assert.isObject(err)
|
|
135
|
+
assert.isObject(err.errors)
|
|
136
136
|
assert.nestedProperty(err, 'errors.txPower' ,`error should have a txPower property`)
|
|
137
137
|
done()
|
|
138
138
|
})
|
|
@@ -161,7 +161,7 @@ describe('Beacon', () => {
|
|
|
161
161
|
Beacon.validate((err, res) => {
|
|
162
162
|
assert.notExists(res)
|
|
163
163
|
assert.exists(err, 'err object should exist')
|
|
164
|
-
assert.isObject(err)
|
|
164
|
+
assert.isObject(err.errors)
|
|
165
165
|
assert.nestedProperty(err, 'errors.macAddress' ,`error should have a macAddress property`)
|
|
166
166
|
done()
|
|
167
167
|
})
|
|
@@ -48,7 +48,7 @@ testCase('DayRangeCondition', () => {
|
|
|
48
48
|
let DayRangeCondition = new DayRangeModel(dayRange)
|
|
49
49
|
DayRangeCondition.validate((err, res) => {
|
|
50
50
|
assert.exists(err, 'err object should exist')
|
|
51
|
-
assert.isObject(err)
|
|
51
|
+
assert.isObject(err.errors)
|
|
52
52
|
done()
|
|
53
53
|
})
|
|
54
54
|
})
|
|
@@ -58,7 +58,7 @@ testCase('DayRangeCondition', () => {
|
|
|
58
58
|
let DayRangeCondition = new DayRangeModel(dayRange)
|
|
59
59
|
DayRangeCondition.validate((err) => {
|
|
60
60
|
assert.exists(err, 'err object should exist')
|
|
61
|
-
assert.isObject(err)
|
|
61
|
+
assert.isObject(err.errors)
|
|
62
62
|
assert.match(err.message, /startDate.*less than.*endDate/i)
|
|
63
63
|
done()
|
|
64
64
|
})
|
|
@@ -69,7 +69,7 @@ testCase('DayRangeCondition', () => {
|
|
|
69
69
|
let DayRangeCondition = new DayRangeModel(dayRange)
|
|
70
70
|
DayRangeCondition.validate((err, res) => {
|
|
71
71
|
assert.exists(err, 'err object should exist')
|
|
72
|
-
assert.isObject(err)
|
|
72
|
+
assert.isObject(err.errors)
|
|
73
73
|
done()
|
|
74
74
|
})
|
|
75
75
|
})
|
|
@@ -84,7 +84,7 @@ testCase('DayRangeCondition', () => {
|
|
|
84
84
|
DayRangeCondition.validate((err, res) => {
|
|
85
85
|
assert.notExists(res)
|
|
86
86
|
assert.exists(err, 'err object should exist')
|
|
87
|
-
assert.isObject(err)
|
|
87
|
+
assert.isObject(err.errors)
|
|
88
88
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
89
89
|
done()
|
|
90
90
|
})
|
|
@@ -47,7 +47,7 @@ testCase('PercentageCrossedCondition', () => {
|
|
|
47
47
|
let PercentageCrossedCondition = new TravelPathConditionModel(travelPath)
|
|
48
48
|
PercentageCrossedCondition.validate((err, res) => {
|
|
49
49
|
assert.exists(err, 'err object should exist')
|
|
50
|
-
assert.isObject(err)
|
|
50
|
+
assert.isObject(err.errors)
|
|
51
51
|
done()
|
|
52
52
|
})
|
|
53
53
|
})
|
|
@@ -61,7 +61,7 @@ testCase('PercentageCrossedCondition', () => {
|
|
|
61
61
|
PercentageCrossedCondition.validate((err, res) => {
|
|
62
62
|
assert.notExists(res)
|
|
63
63
|
assert.exists(err, 'err object should exist')
|
|
64
|
-
assert.isObject(err)
|
|
64
|
+
assert.isObject(err.errors)
|
|
65
65
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
66
66
|
done()
|
|
67
67
|
})
|
|
@@ -46,7 +46,7 @@ testCase('SpeedCondition', () => {
|
|
|
46
46
|
let SpeedCondition = new SpeedConditionModel(speedCondition)
|
|
47
47
|
SpeedCondition.validate((err, res) => {
|
|
48
48
|
assert.exists(err, 'err object should exist')
|
|
49
|
-
assert.isObject(err)
|
|
49
|
+
assert.isObject(err.errors)
|
|
50
50
|
done()
|
|
51
51
|
})
|
|
52
52
|
})
|
|
@@ -56,8 +56,9 @@ testCase('SpeedCondition', () => {
|
|
|
56
56
|
let SpeedCondition = new SpeedConditionModel(speedCondition)
|
|
57
57
|
SpeedCondition.validate((err, res) => {
|
|
58
58
|
assert.exists(err, 'err object should exist')
|
|
59
|
-
assert.isObject(err)
|
|
59
|
+
assert.isObject(err.errors)
|
|
60
60
|
assert.nestedProperty(err, `errors.maximumSpeed`, 'error should have a maximumSpeed property')
|
|
61
|
+
assert.equal(err.errors.maximumSpeed.message, 'Maximum speed has to be at least 5 m/s greater than minimum speed')
|
|
61
62
|
done()
|
|
62
63
|
})
|
|
63
64
|
})
|
|
@@ -66,8 +67,9 @@ testCase('SpeedCondition', () => {
|
|
|
66
67
|
let SpeedCondition = new SpeedConditionModel(speedCondition)
|
|
67
68
|
SpeedCondition.validate((err, res) => {
|
|
68
69
|
assert.exists(err, 'err object should exist')
|
|
69
|
-
assert.isObject(err)
|
|
70
|
+
assert.isObject(err.errors)
|
|
70
71
|
assert.nestedProperty(err, `errors.maximumSpeed`, 'error should have a maximumSpeed property')
|
|
72
|
+
assert.equal(err.errors.maximumSpeed.message, 'Maximum speed has to be at least 5 m/s')
|
|
71
73
|
done()
|
|
72
74
|
})
|
|
73
75
|
})
|
|
@@ -81,7 +83,7 @@ testCase('SpeedCondition', () => {
|
|
|
81
83
|
SpeedCondition.validate((err, res) => {
|
|
82
84
|
assert.notExists(res)
|
|
83
85
|
assert.exists(err, 'err object should exist')
|
|
84
|
-
assert.isObject(err)
|
|
86
|
+
assert.isObject(err.errors)
|
|
85
87
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
86
88
|
done()
|
|
87
89
|
})
|
|
@@ -45,7 +45,7 @@ testCase('TimeOfDayRangeCondition', () => {
|
|
|
45
45
|
let TimeOfDayRangeCondition = new TimeActiveConditionModel(timeActiveCondition)
|
|
46
46
|
TimeOfDayRangeCondition.validate((err, res) => {
|
|
47
47
|
assert.exists(err, 'err object should exist')
|
|
48
|
-
assert.isObject(err)
|
|
48
|
+
assert.isObject(err.errors)
|
|
49
49
|
done()
|
|
50
50
|
})
|
|
51
51
|
})
|
|
@@ -55,8 +55,9 @@ testCase('TimeOfDayRangeCondition', () => {
|
|
|
55
55
|
let TimeOfDayRangeCondition = new TimeActiveConditionModel(timeActiveCondition)
|
|
56
56
|
TimeOfDayRangeCondition.validate((err, res) => {
|
|
57
57
|
assert.exists(err, 'err object should exist')
|
|
58
|
-
assert.isObject(err)
|
|
58
|
+
assert.isObject(err.errors)
|
|
59
59
|
assert.nestedProperty(err, `errors.toTime`, 'error should have a toTime property')
|
|
60
|
+
assert.equal(err.errors.toTime, 'fromTime and toTime cannot be the same')
|
|
60
61
|
done()
|
|
61
62
|
})
|
|
62
63
|
})
|
|
@@ -72,9 +73,9 @@ testCase('TimeOfDayRangeCondition', () => {
|
|
|
72
73
|
let TimeOfDayRangeCondition = new TimeActiveConditionModel(timeActiveCondition)
|
|
73
74
|
TimeOfDayRangeCondition.validate((err, res) => {
|
|
74
75
|
assert.exists(err, 'err object should exits')
|
|
75
|
-
assert.isObject(err)
|
|
76
|
-
assert.nestedProperty(err, `errors.${i.name}`, '
|
|
77
|
-
assert.
|
|
76
|
+
assert.isObject(err.errors)
|
|
77
|
+
assert.nestedProperty(err, `errors.${i.name}`, 'error should have a fromTime property')
|
|
78
|
+
assert.include(err.errors[`${i.name}`].message, 'time format must be hh:mm:ss')
|
|
78
79
|
done()
|
|
79
80
|
})
|
|
80
81
|
})
|
|
@@ -92,7 +93,7 @@ testCase('TimeOfDayRangeCondition', () => {
|
|
|
92
93
|
TimeOfDayRangeCondition.validate((err, res) => {
|
|
93
94
|
assert.notExists(res)
|
|
94
95
|
assert.exists(err, 'err object should exist')
|
|
95
|
-
assert.isObject(err)
|
|
96
|
+
assert.isObject(err.errors)
|
|
96
97
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
97
98
|
done()
|
|
98
99
|
})
|
|
@@ -44,7 +44,7 @@ describe('TravelDirection', () => {
|
|
|
44
44
|
let TravelDirection = new TravelDirectionModel(travelDirectionCondition)
|
|
45
45
|
TravelDirection.validate((err, res) => {
|
|
46
46
|
assert.exists(err, 'err object should exist')
|
|
47
|
-
assert.isObject(err)
|
|
47
|
+
assert.isObject(err.errors)
|
|
48
48
|
done()
|
|
49
49
|
})
|
|
50
50
|
})
|
|
@@ -54,7 +54,7 @@ describe('TravelDirection', () => {
|
|
|
54
54
|
let TravelDirection = new TravelDirectionModel(travelDirectionCondition)
|
|
55
55
|
TravelDirection.validate((err, res) => {
|
|
56
56
|
assert.exists(err, 'err object should exist')
|
|
57
|
-
assert.isObject(err)
|
|
57
|
+
assert.isObject(err.errors)
|
|
58
58
|
assert.nestedProperty(err, `errors.toAngle`, 'error should have a toAngle property')
|
|
59
59
|
done()
|
|
60
60
|
})
|
|
@@ -65,7 +65,7 @@ describe('TravelDirection', () => {
|
|
|
65
65
|
let TravelDirection = new TravelDirectionModel(travelDirectionCondition)
|
|
66
66
|
TravelDirection.validate((err, res) => {
|
|
67
67
|
assert.exists(err, 'err object should exist')
|
|
68
|
-
assert.isObject(err)
|
|
68
|
+
assert.isObject(err.errors)
|
|
69
69
|
assert.nestedProperty(err, `errors.toAngle`, 'error should have a toAngle property')
|
|
70
70
|
done()
|
|
71
71
|
})
|
|
@@ -76,7 +76,7 @@ describe('TravelDirection', () => {
|
|
|
76
76
|
let TravelDirection = new TravelDirectionModel(travelDirectionCondition)
|
|
77
77
|
TravelDirection.validate((err, res) => {
|
|
78
78
|
assert.exists(err, 'err object should exist')
|
|
79
|
-
assert.isObject(err)
|
|
79
|
+
assert.isObject(err.errors)
|
|
80
80
|
assert.nestedProperty(err, `errors.toAngle`, 'error should have a toAngle property')
|
|
81
81
|
done()
|
|
82
82
|
})
|
|
@@ -91,7 +91,7 @@ describe('TravelDirection', () => {
|
|
|
91
91
|
TravelDirection.validate((err, res) => {
|
|
92
92
|
assert.notExists(res)
|
|
93
93
|
assert.exists(err, 'err object should exist')
|
|
94
|
-
assert.isObject(err)
|
|
94
|
+
assert.isObject(err.errors)
|
|
95
95
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
96
96
|
done()
|
|
97
97
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const assert = require('chai').assert
|
|
2
|
-
const CumulativeRulesRequests = require('../../
|
|
2
|
+
const CumulativeRulesRequests = require('../../Models').CumulativeRulesRequests()
|
|
3
3
|
let testCase = require('mocha').describe
|
|
4
4
|
let assertions = require('mocha').it
|
|
5
5
|
|
|
@@ -16,7 +16,6 @@ testCase('Creating new cumulativeRulesRequest document ', () => {
|
|
|
16
16
|
assert(createCumulativeRulesRequests._id.match(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/))
|
|
17
17
|
createCumulativeRulesRequests.validate()
|
|
18
18
|
.then(() => {
|
|
19
|
-
console.log('validate CumulativeRulesRequests')
|
|
20
19
|
assert(true)
|
|
21
20
|
done()
|
|
22
21
|
}).catch(err => {
|
|
@@ -41,7 +41,7 @@ testCase('DailyStats', () => {
|
|
|
41
41
|
let DailyStats = new DailyStatsModel(dailyStats)
|
|
42
42
|
DailyStats.validate((err, res) => {
|
|
43
43
|
assert.exists(err, 'invalid accountId')
|
|
44
|
-
assert.isObject(err)
|
|
44
|
+
assert.isObject(err.errors)
|
|
45
45
|
done()
|
|
46
46
|
})
|
|
47
47
|
})
|
|
@@ -50,7 +50,7 @@ testCase('DailyStats', () => {
|
|
|
50
50
|
let DailyStats = new DailyStatsModel(dailyStats)
|
|
51
51
|
DailyStats.validate((err, res) => {
|
|
52
52
|
assert.exists(err, 'invalid projectId')
|
|
53
|
-
assert.isObject(err)
|
|
53
|
+
assert.isObject(err.errors)
|
|
54
54
|
done()
|
|
55
55
|
})
|
|
56
56
|
})
|
|
@@ -60,7 +60,7 @@ testCase('DailyStats', () => {
|
|
|
60
60
|
let DailyStats = new DailyStatsModel(dailyStats)
|
|
61
61
|
DailyStats.validate((err, res) => {
|
|
62
62
|
assert.exists(err, 'Path `iosCount` (' + negativeIosCount + ') is less than minimum allowed value (0)')
|
|
63
|
-
assert.isObject(err)
|
|
63
|
+
assert.isObject(err.errors)
|
|
64
64
|
done()
|
|
65
65
|
})
|
|
66
66
|
})
|
|
@@ -70,7 +70,7 @@ testCase('DailyStats', () => {
|
|
|
70
70
|
let DailyStats = new DailyStatsModel(dailyStats)
|
|
71
71
|
DailyStats.validate((err, res) => {
|
|
72
72
|
assert.exists(err, 'Path `androidCount` (' + negativeAndroidCount + ') is less than minimum allowed value (0)')
|
|
73
|
-
assert.isObject(err)
|
|
73
|
+
assert.isObject(err.errors)
|
|
74
74
|
done()
|
|
75
75
|
})
|
|
76
76
|
})
|
|
@@ -56,7 +56,7 @@ describe('BoundingBox', () => {
|
|
|
56
56
|
let BoundingBox = new BoundingBoxModel(boundingBox)
|
|
57
57
|
BoundingBox.validate((err, res) => {
|
|
58
58
|
assert.exists(err, 'err object should exist')
|
|
59
|
-
assert.isObject(err)
|
|
59
|
+
assert.isObject(err.errors)
|
|
60
60
|
done()
|
|
61
61
|
})
|
|
62
62
|
})
|
|
@@ -71,7 +71,7 @@ describe('BoundingBox', () => {
|
|
|
71
71
|
BoundingBox.validate((err, res) => {
|
|
72
72
|
assert.notExists(res)
|
|
73
73
|
assert.exists(err, 'err object should exist')
|
|
74
|
-
assert.isObject(err)
|
|
74
|
+
assert.isObject(err.errors)
|
|
75
75
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
76
76
|
done()
|
|
77
77
|
})
|
|
@@ -89,7 +89,7 @@ describe('BoundingBox', () => {
|
|
|
89
89
|
|
|
90
90
|
BoundingBox.validate((err, res) => {
|
|
91
91
|
assert.exists(err, 'err object should exist')
|
|
92
|
-
assert.isObject(err)
|
|
92
|
+
assert.isObject(err.errors)
|
|
93
93
|
done()
|
|
94
94
|
})
|
|
95
95
|
})
|
|
@@ -111,7 +111,7 @@ describe('BoundingBox', () => {
|
|
|
111
111
|
|
|
112
112
|
BoundingBox.validate((err, res) => {
|
|
113
113
|
assert.exists(err, 'err object should exist')
|
|
114
|
-
assert.isObject(err)
|
|
114
|
+
assert.isObject(err.errors)
|
|
115
115
|
assert.match(err.message, /(Bounding box area should be at least 70 square metres)/i)
|
|
116
116
|
done()
|
|
117
117
|
})
|
|
@@ -56,7 +56,7 @@ testCase('Circle', () => {
|
|
|
56
56
|
let Circle = new CircleModel(circle)
|
|
57
57
|
Circle.validate((err, res) => {
|
|
58
58
|
assert.exists(err, 'err object should exist')
|
|
59
|
-
assert.isObject(err)
|
|
59
|
+
assert.isObject(err.errors)
|
|
60
60
|
done()
|
|
61
61
|
})
|
|
62
62
|
})
|
|
@@ -71,7 +71,7 @@ testCase('Circle', () => {
|
|
|
71
71
|
Circle.validate((err, res) => {
|
|
72
72
|
assert.notExists(res)
|
|
73
73
|
assert.exists(err, 'err object should exist')
|
|
74
|
-
assert.isObject(err)
|
|
74
|
+
assert.isObject(err.errors)
|
|
75
75
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
76
76
|
done()
|
|
77
77
|
})
|
|
@@ -55,7 +55,7 @@ testCase('Geoline', () => {
|
|
|
55
55
|
let Geoline = new GeolineModel(geoline)
|
|
56
56
|
Geoline.validate((err, res) => {
|
|
57
57
|
assert.exists(err, 'err object should exist')
|
|
58
|
-
assert.isObject(err)
|
|
58
|
+
assert.isObject(err.errors)
|
|
59
59
|
done()
|
|
60
60
|
})
|
|
61
61
|
})
|
|
@@ -68,7 +68,7 @@ testCase('Geoline', () => {
|
|
|
68
68
|
let Geoline = new GeolineModel(geoline)
|
|
69
69
|
Geoline.validate((err) => {
|
|
70
70
|
assert.exists(err, 'err object should exist')
|
|
71
|
-
assert.isObject(err)
|
|
71
|
+
assert.isObject(err.errors)
|
|
72
72
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
73
73
|
done()
|
|
74
74
|
})
|
|
@@ -50,7 +50,7 @@ describe('Polygon', () => {
|
|
|
50
50
|
let Polygon = new PolygonModel(polygon)
|
|
51
51
|
Polygon.validate((err, res) => {
|
|
52
52
|
assert.exists(err, 'err object should exist')
|
|
53
|
-
assert.isObject(err)
|
|
53
|
+
assert.isObject(err.errors)
|
|
54
54
|
done()
|
|
55
55
|
})
|
|
56
56
|
})
|
|
@@ -65,7 +65,7 @@ describe('Polygon', () => {
|
|
|
65
65
|
Polygon.validate((err, res) => {
|
|
66
66
|
assert.notExists(res)
|
|
67
67
|
assert.exists(err, 'err object should exist')
|
|
68
|
-
assert.isObject(err)
|
|
68
|
+
assert.isObject(err.errors)
|
|
69
69
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
70
70
|
done()
|
|
71
71
|
})
|
|
@@ -156,7 +156,7 @@ describe('Polygon', () => {
|
|
|
156
156
|
|
|
157
157
|
Polygon.validate((err, res) => {
|
|
158
158
|
assert.exists(err, 'err object should exist')
|
|
159
|
-
assert.isObject(err)
|
|
159
|
+
assert.isObject(err.errors)
|
|
160
160
|
assert.match(err.message, /(Polygon area should be at least 70 square metres)/i)
|
|
161
161
|
done()
|
|
162
162
|
})
|
|
@@ -54,7 +54,7 @@ describe('ZoneBeacon', () => {
|
|
|
54
54
|
let ZoneBeacon = new ZoneBeaconModel(zoneBeacon)
|
|
55
55
|
ZoneBeacon.validate((err, res) => {
|
|
56
56
|
assert.exists(err, 'err object should exist')
|
|
57
|
-
assert.isObject(err)
|
|
57
|
+
assert.isObject(err.errors)
|
|
58
58
|
done()
|
|
59
59
|
})
|
|
60
60
|
})
|
|
@@ -68,7 +68,7 @@ describe('ZoneBeacon', () => {
|
|
|
68
68
|
ZoneBeacon.validate((err, res) => {
|
|
69
69
|
assert.notExists(res)
|
|
70
70
|
assert.exists(err, 'err object should exist')
|
|
71
|
-
assert.isObject(err)
|
|
71
|
+
assert.isObject(err.errors)
|
|
72
72
|
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
73
73
|
done()
|
|
74
74
|
})
|
|
@@ -41,7 +41,7 @@ describe('MonthlyStat', () => {
|
|
|
41
41
|
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
42
42
|
MonthlyStats.validate((err, res) => {
|
|
43
43
|
assert.exists(err, 'invalid accountId')
|
|
44
|
-
assert.isObject(err)
|
|
44
|
+
assert.isObject(err.errors)
|
|
45
45
|
done()
|
|
46
46
|
})
|
|
47
47
|
})
|
|
@@ -55,7 +55,7 @@ describe('MonthlyStat', () => {
|
|
|
55
55
|
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
56
56
|
MonthlyStats.validate((err, res) => {
|
|
57
57
|
assert.exists(err, 'invalid projectId')
|
|
58
|
-
assert.isObject(err)
|
|
58
|
+
assert.isObject(err.errors)
|
|
59
59
|
done()
|
|
60
60
|
})
|
|
61
61
|
})
|
|
@@ -69,7 +69,7 @@ describe('MonthlyStat', () => {
|
|
|
69
69
|
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
70
70
|
MonthlyStats.validate((err, res) => {
|
|
71
71
|
assert.exists(err, 'Path `iosUserCount` (-100) is less than minimum allowed value (0)')
|
|
72
|
-
assert.isObject(err)
|
|
72
|
+
assert.isObject(err.errors)
|
|
73
73
|
done()
|
|
74
74
|
})
|
|
75
75
|
})
|
|
@@ -22,7 +22,7 @@ beforeEach(() => {
|
|
|
22
22
|
|
|
23
23
|
testCase('Project', () => {
|
|
24
24
|
testCase('Valid Project ', () => {
|
|
25
|
-
assertions('should validate a valid project ', (done) => {
|
|
25
|
+
assertions('should validate a valid project ', (done) => {
|
|
26
26
|
let Project = new ProjectModel(project)
|
|
27
27
|
Project.validate((err, res) => {
|
|
28
28
|
assert.notExists(res)
|
|
@@ -166,7 +166,7 @@ testCase('Project', () => {
|
|
|
166
166
|
assertions('should throw an error if the mparticle integration misses both keys ', (done) => {
|
|
167
167
|
|
|
168
168
|
delete project.integrations.mparticle.iosApiKey
|
|
169
|
-
delete project.integrations.mparticle.androidApiKey
|
|
169
|
+
delete project.integrations.mparticle.androidApiKey
|
|
170
170
|
|
|
171
171
|
let Project = new ProjectModel(project)
|
|
172
172
|
Project.validate((err, res) => {
|
|
@@ -178,7 +178,7 @@ testCase('Project', () => {
|
|
|
178
178
|
assertions('should throw an error if the mparticle integration misses both secret keys ', (done) => {
|
|
179
179
|
|
|
180
180
|
delete project.integrations.mparticle.iosSecretKey
|
|
181
|
-
delete project.integrations.mparticle.androidSecretKey
|
|
181
|
+
delete project.integrations.mparticle.androidSecretKey
|
|
182
182
|
|
|
183
183
|
let Project = new ProjectModel(project)
|
|
184
184
|
Project.validate((err, res) => {
|
|
@@ -231,7 +231,7 @@ testCase('Project', () => {
|
|
|
231
231
|
Project.validate((err, res) => {
|
|
232
232
|
assert.notExists(res)
|
|
233
233
|
assert.exists(err, 'err object should exist')
|
|
234
|
-
assert.isObject(err)
|
|
234
|
+
assert.isObject(err.errors)
|
|
235
235
|
assert.nestedProperty(err, `errors.${i}`, 'error should have a radius property')
|
|
236
236
|
done()
|
|
237
237
|
})
|
|
@@ -250,8 +250,8 @@ testCase('Project', () => {
|
|
|
250
250
|
Project.validate((err, res) => {
|
|
251
251
|
assert.notExists(res)
|
|
252
252
|
assert.exists(err, 'err object should exist')
|
|
253
|
-
assert.isObject(err)
|
|
254
|
-
assert.nestedProperty(err, `errors.${i.name}`, `error should have a ${i} property`)
|
|
253
|
+
// assert.isObject(err.errors)
|
|
254
|
+
// assert.nestedProperty(err, `errors.${i.name}`, `error should have a ${i} property`)
|
|
255
255
|
done()
|
|
256
256
|
})
|
|
257
257
|
})
|
|
@@ -294,7 +294,7 @@ testCase('Project', () => {
|
|
|
294
294
|
|
|
295
295
|
describe('should throw an error when any of the values of the array contains a falsy value', () => {
|
|
296
296
|
let arrayTypeFields = rules.arrayTypeFields
|
|
297
|
-
|
|
297
|
+
|
|
298
298
|
arrayTypeFields.map(arrayField => {
|
|
299
299
|
FALSY_VALUES.map(falsyValue => {
|
|
300
300
|
it(`should throw an error when it contains ${falsyValue} on a ${arrayField}`, (done) => {
|
|
@@ -53,7 +53,7 @@ describe('User', () => {
|
|
|
53
53
|
User.validate((err, res) => {
|
|
54
54
|
assert.notExists(res)
|
|
55
55
|
assert.exists(err, 'err object should exist')
|
|
56
|
-
assert.isObject(err)
|
|
56
|
+
assert.isObject(err.errors)
|
|
57
57
|
assert.nestedProperty(err, `errors.${requiredField}`, `error should have a ${requiredField} property`)
|
|
58
58
|
done()
|
|
59
59
|
})
|
|
@@ -75,7 +75,7 @@ describe('User', () => {
|
|
|
75
75
|
User.validate((err, res) => {
|
|
76
76
|
assert.notExists(res)
|
|
77
77
|
assert.exists(err, 'err object should exist')
|
|
78
|
-
assert.isObject(err)
|
|
78
|
+
assert.isObject(err.errors)
|
|
79
79
|
assert.nestedProperty(err, `errors.${customValidator.name}`, `error should have a ${customValidator.name} property`)
|
|
80
80
|
done()
|
|
81
81
|
})
|
|
@@ -141,5 +141,5 @@ describe('User', () => {
|
|
|
141
141
|
})
|
|
142
142
|
})
|
|
143
143
|
})
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
})
|
|
@@ -40,7 +40,7 @@ testCase('Zone - Action', () => {
|
|
|
40
40
|
let Zone = new ZoneModel(zone)
|
|
41
41
|
Zone.validate((err, res) => {
|
|
42
42
|
assert.exists(err, 'err object should exist')
|
|
43
|
-
assert.isObject(err)
|
|
43
|
+
assert.isObject(err.errors)
|
|
44
44
|
assert('actions.1.url' in err.errors)
|
|
45
45
|
assert.notNestedProperty(err, `errors.geofeatures`, 'error should have a url property')
|
|
46
46
|
done()
|
|
@@ -42,7 +42,7 @@ testCase('Zone - Condition', () => {
|
|
|
42
42
|
let Zone = new ZoneModel(zone)
|
|
43
43
|
Zone.validate((err, res) => {
|
|
44
44
|
assert.exists(err, 'err object should exist')
|
|
45
|
-
assert.isObject(err)
|
|
45
|
+
assert.isObject(err.errors)
|
|
46
46
|
assert('conditions.0.startDate' in err.errors)
|
|
47
47
|
assert.notNestedProperty(err, `errors.geofeatures`, 'error should have a url property')
|
|
48
48
|
done()
|
|
@@ -44,7 +44,7 @@ testCase('Zone - Action', () => {
|
|
|
44
44
|
let Zone = new ZoneModel(zone)
|
|
45
45
|
Zone.validate((err) => {
|
|
46
46
|
assert.exists(err, 'err object should exist')
|
|
47
|
-
assert.isObject(err)
|
|
47
|
+
assert.isObject(err.errors)
|
|
48
48
|
assert('geofeatures.0.name' in err.errors)
|
|
49
49
|
done()
|
|
50
50
|
})
|
|
@@ -54,7 +54,7 @@ testCase('Zone - Action', () => {
|
|
|
54
54
|
let Zone = new ZoneModel(zone)
|
|
55
55
|
Zone.validate((err) => {
|
|
56
56
|
assert.exists(err, 'err object should exist')
|
|
57
|
-
assert.isObject(err)
|
|
57
|
+
assert.isObject(err.errors)
|
|
58
58
|
assert('geofeatures.0.minor' in err.errors)
|
|
59
59
|
done()
|
|
60
60
|
})
|
|
@@ -74,7 +74,7 @@ testCase('Zone - Action', () => {
|
|
|
74
74
|
let Zone = new ZoneModel(zone)
|
|
75
75
|
Zone.validate((err) => {
|
|
76
76
|
assert.exists(err, 'err object should exist')
|
|
77
|
-
assert.isObject(err)
|
|
77
|
+
assert.isObject(err.errors)
|
|
78
78
|
assert.match(err.message, /(Geofeature requires a type of `beacon`, `circle`, `polygon`, `geoline` or `boundingBox`.)/i)
|
|
79
79
|
done()
|
|
80
80
|
})
|
|
@@ -85,7 +85,7 @@ testCase('Zone - Action', () => {
|
|
|
85
85
|
let Zone = new ZoneModel(zone)
|
|
86
86
|
Zone.validate((err) => {
|
|
87
87
|
assert.exists(err, 'err object should exist')
|
|
88
|
-
assert.isObject(err)
|
|
88
|
+
assert.isObject(err.errors)
|
|
89
89
|
assert.match(err.message, /(Geofeature requires a type of `beacon`, `circle`, `polygon`, `geoline` or `boundingBox`.)/i)
|
|
90
90
|
done()
|
|
91
91
|
})
|
|
@@ -96,7 +96,7 @@ testCase('Zone - Action', () => {
|
|
|
96
96
|
let Zone = new ZoneModel(zone)
|
|
97
97
|
Zone.validate((err) => {
|
|
98
98
|
assert.exists(err, 'err object should exist')
|
|
99
|
-
assert.isObject(err)
|
|
99
|
+
assert.isObject(err.errors)
|
|
100
100
|
assert.match(err.message, /(Geofeature requires a type of `beacon`, `circle`, `polygon`, `geoline` or `boundingBox`.)/i)
|
|
101
101
|
done()
|
|
102
102
|
})
|
|
@@ -130,7 +130,7 @@ describe('Zone', () => {
|
|
|
130
130
|
let Zone = new ZoneModel(zone)
|
|
131
131
|
Zone.validate((err, res) => {
|
|
132
132
|
assert.exists(err, 'err object should exist')
|
|
133
|
-
assert.isObject(err)
|
|
133
|
+
assert.isObject(err.errors)
|
|
134
134
|
done()
|
|
135
135
|
})
|
|
136
136
|
})
|
|
@@ -140,7 +140,7 @@ describe('Zone', () => {
|
|
|
140
140
|
let Zone = new ZoneModel(zone)
|
|
141
141
|
Zone.validate((err, res) => {
|
|
142
142
|
assert.exists(err, 'err object should exist')
|
|
143
|
-
assert.isObject(err)
|
|
143
|
+
assert.isObject(err.errors)
|
|
144
144
|
assert('actions.1.url' in err.errors, `errors should have a 'actions.1.url' property`)
|
|
145
145
|
done()
|
|
146
146
|
})
|
|
@@ -152,7 +152,7 @@ describe('Zone', () => {
|
|
|
152
152
|
let Zone = new ZoneModel(zone)
|
|
153
153
|
Zone.validate((err, res) => {
|
|
154
154
|
assert.exists(err, 'err object should exist')
|
|
155
|
-
assert.isObject(err)
|
|
155
|
+
assert.isObject(err.errors)
|
|
156
156
|
assert.match(err.message, /(Action requires a type of `url` or `message`.)/i)
|
|
157
157
|
done()
|
|
158
158
|
})
|
|
@@ -163,7 +163,7 @@ describe('Zone', () => {
|
|
|
163
163
|
let Zone = new ZoneModel(zone)
|
|
164
164
|
Zone.validate((err, res) => {
|
|
165
165
|
assert.exists(err, 'err object should exist')
|
|
166
|
-
assert.isObject(err)
|
|
166
|
+
assert.isObject(err.errors)
|
|
167
167
|
assert.match(err.message, /(Action requires a type of `url` or `message`.)/i)
|
|
168
168
|
done()
|
|
169
169
|
})
|
|
@@ -174,7 +174,7 @@ describe('Zone', () => {
|
|
|
174
174
|
let Zone = new ZoneModel(zone)
|
|
175
175
|
Zone.validate((err, res) => {
|
|
176
176
|
assert.exists(err, 'err object should exist')
|
|
177
|
-
assert.isObject(err)
|
|
177
|
+
assert.isObject(err.errors)
|
|
178
178
|
assert.match(err.message, /(actions must have a value)/i)
|
|
179
179
|
done()
|
|
180
180
|
})
|
|
@@ -185,7 +185,7 @@ describe('Zone', () => {
|
|
|
185
185
|
let Zone = new ZoneModel(zone)
|
|
186
186
|
Zone.validate((err, res) => {
|
|
187
187
|
assert.exists(err, 'err object should exist')
|
|
188
|
-
assert.isObject(err)
|
|
188
|
+
assert.isObject(err.errors)
|
|
189
189
|
assert('conditions.0.startDate' in err.errors, `errors should have a 'conditions.0.startDate' property`)
|
|
190
190
|
done()
|
|
191
191
|
})
|
|
@@ -196,7 +196,7 @@ describe('Zone', () => {
|
|
|
196
196
|
let Zone = new ZoneModel(zone)
|
|
197
197
|
Zone.validate((err, res) => {
|
|
198
198
|
assert.exists(err, 'err object should exist')
|
|
199
|
-
assert.isObject(err)
|
|
199
|
+
assert.isObject(err.errors)
|
|
200
200
|
assert.match(err.message, /(Condition requires a type of `dayRange`, `speed`, `timeActive`, `travelDirection` or `travelPath`.)/i)
|
|
201
201
|
done()
|
|
202
202
|
})
|
|
@@ -207,7 +207,7 @@ describe('Zone', () => {
|
|
|
207
207
|
let Zone = new ZoneModel(zone)
|
|
208
208
|
Zone.validate((err, res) => {
|
|
209
209
|
assert.exists(err, 'err object should exist')
|
|
210
|
-
assert.isObject(err)
|
|
210
|
+
assert.isObject(err.errors)
|
|
211
211
|
assert.match(err.message, /(Condition requires a type of `dayRange`, `speed`, `timeActive`, `travelDirection` or `travelPath`.)/i)
|
|
212
212
|
done()
|
|
213
213
|
})
|
|
@@ -218,7 +218,7 @@ describe('Zone', () => {
|
|
|
218
218
|
let Zone = new ZoneModel(zone)
|
|
219
219
|
Zone.validate((err, res) => {
|
|
220
220
|
assert.exists(err, 'err object should exist')
|
|
221
|
-
assert.isObject(err)
|
|
221
|
+
assert.isObject(err.errors)
|
|
222
222
|
assert.match(err.message, /(conditions must have a value)/i)
|
|
223
223
|
done()
|
|
224
224
|
})
|
|
@@ -229,7 +229,7 @@ describe('Zone', () => {
|
|
|
229
229
|
let Zone = new ZoneModel(zone)
|
|
230
230
|
Zone.validate((err, res) => {
|
|
231
231
|
assert.exists(err, 'err object should exist')
|
|
232
|
-
assert.isObject(err)
|
|
232
|
+
assert.isObject(err.errors)
|
|
233
233
|
assert.match(err.message, /Zone validation failed: customData/i)
|
|
234
234
|
done()
|
|
235
235
|
})
|
|
@@ -250,7 +250,7 @@ describe('Zone', () => {
|
|
|
250
250
|
let Zone = new ZoneModel(zone)
|
|
251
251
|
Zone.validate((err, res) => {
|
|
252
252
|
assert.exists(err, 'err object should exist')
|
|
253
|
-
assert.isObject(err)
|
|
253
|
+
assert.isObject(err.errors)
|
|
254
254
|
assert.match(err.message, /Zone validation failed: customData/i)
|
|
255
255
|
done()
|
|
256
256
|
})
|
|
@@ -398,7 +398,7 @@ describe('Zone', () => {
|
|
|
398
398
|
|
|
399
399
|
describe('should throw an error when any of the values of the array contains a falsy value', () => {
|
|
400
400
|
let arrayTypeFields = rules.arrayTypeFields
|
|
401
|
-
|
|
401
|
+
|
|
402
402
|
arrayTypeFields.map(arrayField => {
|
|
403
403
|
FALSY_VALUES.map(falsyValue => {
|
|
404
404
|
it(`should trow an error when it contains ${falsyValue} on a ${arrayField}`, (done) => {
|
package/models/DailyStats.js
CHANGED
|
@@ -9,8 +9,8 @@ const helpers = require('../helpers')
|
|
|
9
9
|
|
|
10
10
|
const schema = {
|
|
11
11
|
_id: { type: String, default: uuidv4 },
|
|
12
|
-
projectId: {type: String, required: [true, 'projectId is required'], validate: {
|
|
13
|
-
accountId: {type: String, required: [true, 'accountId is required'], validate: {
|
|
12
|
+
projectId: {type: String, required: [true, 'projectId is required'], validate: {validator: helpers.validateUUIDv4, msg: 'invalid projectId'}},
|
|
13
|
+
accountId: {type: String, required: [true, 'accountId is required'], validate: {validator: helpers.validateUUIDv4, msg: 'invalid accountId'}},
|
|
14
14
|
iosCount: {type: Number, required: [true, 'iosCount is required'], min: 0},
|
|
15
15
|
androidCount: {type: Number, required: [true, 'androidCount is required'], min: 0},
|
|
16
16
|
creationDate: { type: Date, default: Date.now }
|
package/models/MonthlyStats.js
CHANGED
|
@@ -10,10 +10,10 @@ const helpers = require('../helpers')
|
|
|
10
10
|
|
|
11
11
|
const schema = {
|
|
12
12
|
_id: { type: String, default: uuidv4 },
|
|
13
|
-
accountId: {type: String, required: [true, 'accountId is required'], validate: {
|
|
13
|
+
accountId: {type: String, required: [true, 'accountId is required'], validate: {validator: helpers.validateUUIDv4, msg: 'invalid accountId'}},
|
|
14
14
|
totalMonthlyUsers: {type: Number, required: [true, 'totalMonthlyUsers is required'], min: 0},
|
|
15
15
|
projects: [{
|
|
16
|
-
projectId: {type: String, required: [true, 'projectId is required'], validate: {
|
|
16
|
+
projectId: {type: String, required: [true, 'projectId is required'], validate: {validator: helpers.validateUUIDv4, msg: 'invalid projectId'}},
|
|
17
17
|
iosUsersCount: {type: Number, required: [true, 'iosUsersCount is required'], min: 0},
|
|
18
18
|
androidUsersCount: {type: Number, required: [true, 'androidUsersCount is required'], min: 0}
|
|
19
19
|
}],
|
package/models/Project.js
CHANGED
|
@@ -39,7 +39,7 @@ let ProjectSchema = new mongoose.Schema({
|
|
|
39
39
|
lastSyncTime: {type: Date, default: Date.now},
|
|
40
40
|
name: {type: String, required: [true, 'name is required']},
|
|
41
41
|
shouldSync: { type: Boolean, default: false },
|
|
42
|
-
accountId: {type: String, required: true, validate: {
|
|
42
|
+
accountId: {type: String, required: true, validate: {validator: helpers.validateUUIDv4, msg: 'default error message'}},
|
|
43
43
|
webhooks: {type:[WebhookSchema], validate: webhooksValidators},
|
|
44
44
|
configurationParameters: {
|
|
45
45
|
iosConfig: iosConfig, // when we want to enable this {type: iosConfig, required: true}
|
package/models/UrlAction.js
CHANGED
package/models/Zone.js
CHANGED
|
@@ -119,7 +119,7 @@ let zoneSchema = new Schema({
|
|
|
119
119
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
120
120
|
projectId: {type: String, required: true, validate: {validator: helpers.validateUUIDv4, message: 'Invalid Project Id.'}},
|
|
121
121
|
state: {type: String, default: StateEnum.ACTIVE, select: false},
|
|
122
|
-
accountId: {type: String, required: true, validate: {
|
|
122
|
+
accountId: {type: String, required: true, validate: {validator: helpers.validateUUIDv4, msg: 'default error message'}},
|
|
123
123
|
tempo: zoneTempoSchema
|
|
124
124
|
}, {collection: 'zone', autoIndex: false})
|
|
125
125
|
|
|
@@ -3,7 +3,9 @@ let uuidv4 = require('uuid/v4')
|
|
|
3
3
|
|
|
4
4
|
let schema = {
|
|
5
5
|
minimumSpeed: {type: Number, required: [true, 'minimumSpeed is required. '], min: 0},
|
|
6
|
-
maximumSpeed: {type: Number, required: true, validate: {
|
|
6
|
+
maximumSpeed: {type: Number, required: true, validate: {validator: validateMaxSpeed, message: (props) => {
|
|
7
|
+
return props.reason.message
|
|
8
|
+
}}}
|
|
7
9
|
}
|
|
8
10
|
let SpeedConditionSchema = new mongoose.Schema(schema, {
|
|
9
11
|
_id: false,
|
|
@@ -14,17 +16,16 @@ SpeedConditionSchema.add({
|
|
|
14
16
|
type: {type: String, required: true}
|
|
15
17
|
})
|
|
16
18
|
|
|
17
|
-
function validateMaxSpeed (v
|
|
19
|
+
function validateMaxSpeed (v) {
|
|
18
20
|
let minSpeed = this.minimumSpeed
|
|
19
21
|
let maxSpeed = v
|
|
20
22
|
let speedDifference = maxSpeed - minSpeed
|
|
21
23
|
|
|
22
24
|
if (maxSpeed < 5) {
|
|
23
|
-
|
|
25
|
+
throw new Error('Maximum speed has to be at least 5 m/s')
|
|
24
26
|
} else if (speedDifference < 5) {
|
|
25
|
-
|
|
27
|
+
throw new Error('Maximum speed has to be at least 5 m/s greater than minimum speed')
|
|
26
28
|
}
|
|
27
|
-
magicCallback(true)
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
// optional mongoose
|
|
@@ -2,8 +2,12 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
4
|
let schema = {
|
|
5
|
-
fromTime: {type: String, required: [true, 'time is required. '], validate: {
|
|
6
|
-
|
|
5
|
+
fromTime: {type: String, required: [true, 'time is required. '], validate: {validator: validateTimeHHmmssFormat, message: (props) => {
|
|
6
|
+
return props.reason.message
|
|
7
|
+
}}},
|
|
8
|
+
toTime: {type: String, required: true, validate: [{validator: validateTime}, {validator: validateTimeHHmmssFormat}], message: (props) => {
|
|
9
|
+
return props.reason.message
|
|
10
|
+
}}
|
|
7
11
|
}
|
|
8
12
|
let TimeActiveConditionSchema = new mongoose.Schema(schema, {
|
|
9
13
|
_id: false,
|
|
@@ -18,9 +22,8 @@ function validateTime (toTime, magicCallback) {
|
|
|
18
22
|
let fromTime = this.fromTime
|
|
19
23
|
|
|
20
24
|
if (fromTime === toTime) {
|
|
21
|
-
|
|
25
|
+
throw new Error('fromTime and toTime cannot be the same')
|
|
22
26
|
}
|
|
23
|
-
return magicCallback(true)
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
function validateTimeHHmmssFormat(time, magicCallback) {
|
|
@@ -28,10 +31,8 @@ function validateTimeHHmmssFormat(time, magicCallback) {
|
|
|
28
31
|
const regex = new RegExp(expression, 'i')
|
|
29
32
|
|
|
30
33
|
if(!regex.test(time)){
|
|
31
|
-
|
|
34
|
+
throw new Error('time format must be hh:mm:ss')
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
return magicCallback(true)
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// optional mongoose
|
|
@@ -3,7 +3,9 @@ let uuidv4 = require('uuid/v4')
|
|
|
3
3
|
|
|
4
4
|
const schema = {
|
|
5
5
|
fromAngle: {type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359},
|
|
6
|
-
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {
|
|
6
|
+
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {validator: validateAngles, message: (props) => {
|
|
7
|
+
return props.reson.message
|
|
8
|
+
}}}
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
const TravelDirectionConditionSchema = new mongoose.Schema(schema, {
|
|
@@ -16,14 +18,12 @@ TravelDirectionConditionSchema.add({
|
|
|
16
18
|
type: {type: String, required: true}
|
|
17
19
|
})
|
|
18
20
|
|
|
19
|
-
function validateAngles (toAngle
|
|
21
|
+
function validateAngles (toAngle) {
|
|
20
22
|
let fromAngle = this.fromAngle
|
|
21
23
|
|
|
22
24
|
if (!isMinimumNinetyApart(fromAngle, toAngle)) {
|
|
23
|
-
|
|
25
|
+
throw new Error('From Angle and To Angle must be separated by at least 90 degrees in either direction')
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
callback(true)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function isMinimumNinetyApart (fromAngle, toAngle) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluedot-innovation/models",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.11-alpha.1",
|
|
4
4
|
"main": "Models.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"eslint-plugin-promise": "^3.6.0",
|
|
24
24
|
"eslint-plugin-standard": "^3.0.1",
|
|
25
25
|
"mocha": "^4.0.1",
|
|
26
|
-
"mongodb": "^3.
|
|
26
|
+
"mongodb": "^3.6.3",
|
|
27
27
|
"nyc": "^11.3.0",
|
|
28
28
|
"prettier": "^1.13.5",
|
|
29
29
|
"sinon": "^4.1.2"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"deep-equal": "^1.0.1",
|
|
38
38
|
"fast-deep-equal": "^2.0.1",
|
|
39
39
|
"lodash.clonedeep": "4.5.0",
|
|
40
|
-
"mongoose": "^5.
|
|
40
|
+
"mongoose": "^5.11.4",
|
|
41
41
|
"uuid": "^3.1.0"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -11,7 +11,7 @@ const ProjectPermissionSchema = new mongoose.Schema({
|
|
|
11
11
|
projectId: {
|
|
12
12
|
type: String,
|
|
13
13
|
required: true,
|
|
14
|
-
validate: {
|
|
14
|
+
validate: {validator: helpers.validateUUIDv4, msg: 'projectId not in UUID v4 format'}
|
|
15
15
|
}
|
|
16
16
|
}, {
|
|
17
17
|
_id: false,
|
package/schemas/Webhook.js
CHANGED
|
@@ -3,8 +3,8 @@ let validators = require('../utils/validators')
|
|
|
3
3
|
|
|
4
4
|
let WebhookSchema = new mongoose.Schema({
|
|
5
5
|
type: {type: String, enum: ['trigger', 'tempo'], required: [true, 'webhook type is required']}, // configurationChanged, trigger
|
|
6
|
-
url: {type: String, required: [true, 'URL is required'], validate: {
|
|
7
|
-
headers: {type: mongoose.Schema.Types.Mixed, validate: {
|
|
6
|
+
url: {type: String, required: [true, 'URL is required'], validate: {validator: validators.validateUrl, msg: 'Please enter a valid URL'}},
|
|
7
|
+
headers: {type: mongoose.Schema.Types.Mixed, validate: { validator: validateHeaderlength, msg: 'Header object can only have 1 key <-> value pair' }}
|
|
8
8
|
}, {
|
|
9
9
|
_id: false
|
|
10
10
|
})
|