@bluedot-innovation/models 2.0.0-alpha.14 → 2.0.0-alpha.3
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/.gitlab-ci.yml +1 -4
- package/.nyc_output/35cf8a0cc73b518d0684cad2d4dfc679.json +1 -0
- package/Models.js +8 -16
- package/README.MD +3 -21
- package/__tests__/{geofeature/beacon → zone}/beacon.spec.js +3 -3
- package/__tests__/{geofeature/boundingBox → zone}/boundingBox.spec.js +3 -3
- package/__tests__/zone/checkAppId.js +39 -0
- package/__tests__/zone/checkBeacon.js +44 -0
- package/__tests__/zone/checkMRT.js +44 -0
- package/__tests__/{geofeature/circle → zone}/circle.spec.js +24 -15
- package/__tests__/zone/data/zone-with-invalid-circle.json +34 -0
- package/__tests__/{geofeature/polygon → zone}/polygon.spec.js +3 -3
- package/__tests__/{geofeature/polyline → zone}/polyline.spec.js +3 -3
- package/__tests__/zone/zone.spec.js +8 -5
- package/models/Beacon.js +15 -13
- package/models/BeaconFilter.js +8 -24
- package/models/BearingFilter.js +8 -15
- package/models/BoundingBox.js +7 -14
- package/models/CalendarDateRangeFilter.js +7 -13
- package/models/Circle.js +7 -14
- package/models/Geofeature.js +2 -0
- package/models/MessageAction.js +7 -13
- package/models/PercentageCrossedFilter.js +7 -13
- package/models/Polygon.js +6 -13
- package/models/Polyline.js +6 -15
- package/models/SpeedFilter.js +7 -14
- package/models/TimeOfDayRangeFilter.js +7 -14
- package/models/UrlAction.js +7 -14
- package/models/Zone.js +160 -45
- package/package.json +5 -8
- package/.nyc_output/.gitkeep +0 -0
- package/.nyc_output/84b3fbae4d070660e06ae55f15306158.json +0 -1
- package/__tests__/filter/beacon/beaconFilter.data.json +0 -1
- package/__tests__/filter/beacon/beaconFilter.rules.json +0 -3
- package/__tests__/filter/beacon/beaconFilter.spec.js +0 -1
- package/__tests__/geofeature/circle/circle.data.json +0 -9
- package/__tests__/zone/zone.action.spec.js +0 -50
- package/__tests__/zone/zone.filter.spec.js +0 -50
- package/__tests__/zone/zone.geofeatures.spec.js +0 -74
- /package/.nyc_output/{80d8f626b96df8cb4eed63e325b8b3c9.json → bd25154d8c33e81a68c3281fc3007b9c.json} +0 -0
- /package/__tests__/{geofeature/beacon → zone/data}/beacon.data.json +0 -0
- /package/__tests__/{geofeature/boundingBox → zone/data}/boundingBox.data.json +0 -0
- /package/__tests__/{geofeature/polygon → zone/data}/polygon.data.json +0 -0
- /package/__tests__/{geofeature/polyline → zone/data}/polyline.data.json +0 -0
- /package/__tests__/zone/{zone.data.json → data/zone.data.json} +0 -0
- /package/__tests__/{geofeature/beacon → zone/rules}/beacon.rules.json +0 -0
- /package/__tests__/{geofeature/boundingBox → zone/rules}/boundingBox.rules.json +0 -0
- /package/__tests__/{geofeature/circle → zone/rules}/circle.rules.json +0 -0
- /package/__tests__/{geofeature/polygon → zone/rules}/polygon.rules.json +0 -0
- /package/__tests__/{geofeature/polyline → zone/rules}/polyline.rules.json +0 -0
|
@@ -11,9 +11,11 @@ let mocha = require('mocha')
|
|
|
11
11
|
let beforeEach = mocha.beforeEach
|
|
12
12
|
|
|
13
13
|
let zone
|
|
14
|
+
let invalidZone
|
|
14
15
|
|
|
15
16
|
beforeEach(() => {
|
|
16
|
-
zone = JSON.parse(JSON.stringify(require('./zone.data.json')))
|
|
17
|
+
zone = JSON.parse(JSON.stringify(require('./data/zone.data.json')))
|
|
18
|
+
invalidZone = JSON.parse(JSON.stringify(require('./data/zone-with-invalid-circle.json')))
|
|
17
19
|
})
|
|
18
20
|
|
|
19
21
|
testCase('Zone', () => {
|
|
@@ -66,8 +68,7 @@ testCase('Zone', () => {
|
|
|
66
68
|
|
|
67
69
|
testCase('Invalid Zone ', () => {
|
|
68
70
|
assertions('should throw an error when validating an invalid zone ', (done) => {
|
|
69
|
-
|
|
70
|
-
let Zone = new ZoneModel(zone)
|
|
71
|
+
let Zone = new ZoneModel(invalidZone)
|
|
71
72
|
Zone.validate((err, res) => {
|
|
72
73
|
assert.exists(err, 'err object should exist')
|
|
73
74
|
assert.isObject(err)
|
|
@@ -80,7 +81,8 @@ testCase('Zone', () => {
|
|
|
80
81
|
Zone.validate((err, res) => {
|
|
81
82
|
assert.exists(err, 'err object should exist')
|
|
82
83
|
assert.isObject(err)
|
|
83
|
-
assert(
|
|
84
|
+
assert.nestedProperty(err, `errors.url`, 'error should have a url property')
|
|
85
|
+
assert.notNestedProperty(err, `errors.geofeatures`, 'error should have a url property')
|
|
84
86
|
done()
|
|
85
87
|
})
|
|
86
88
|
})
|
|
@@ -90,7 +92,8 @@ testCase('Zone', () => {
|
|
|
90
92
|
Zone.validate((err, res) => {
|
|
91
93
|
assert.exists(err, 'err object should exist')
|
|
92
94
|
assert.isObject(err)
|
|
93
|
-
assert(
|
|
95
|
+
assert.nestedProperty(err, `errors.calendarDateRange`, 'error should have a url property')
|
|
96
|
+
assert.notNestedProperty(err, `errors.geofeatures`, 'error should have a url property')
|
|
94
97
|
done()
|
|
95
98
|
})
|
|
96
99
|
})
|
package/models/Beacon.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
-
let Point = require('../schemas/Point')
|
|
4
3
|
let uuidv4 = require('uuid/v4')
|
|
4
|
+
let Point = require('../schemas/Point')
|
|
5
5
|
|
|
6
|
-
let
|
|
6
|
+
let BeaconSchema = new mongoose.Schema({
|
|
7
|
+
customerApiKey: {type: String, validate: [{validator: validateKey, msg: 'Customer API Key is required'}]},
|
|
8
|
+
apiKey: {type: String, validate: [{validator: validateKey, msg: 'API Key is required'}]},
|
|
7
9
|
guid: {type: String, default: uuidv4},
|
|
10
|
+
type: {type: String},
|
|
8
11
|
name: {type: String, required: [true, 'name is required. ']},
|
|
9
12
|
longitude: {
|
|
10
13
|
type: Number,
|
|
@@ -35,13 +38,6 @@ let schema = {
|
|
|
35
38
|
},
|
|
36
39
|
location: {type: Point},
|
|
37
40
|
proximity: {type: String, default: 'Far'}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let BeaconSchema = new mongoose.Schema(schema)
|
|
41
|
-
|
|
42
|
-
BeaconSchema.add({
|
|
43
|
-
type:
|
|
44
|
-
{type: String, required: true}
|
|
45
41
|
})
|
|
46
42
|
|
|
47
43
|
// mongoose validator helper plugin
|
|
@@ -82,16 +78,23 @@ function validateBeaconType (v, cb) {
|
|
|
82
78
|
let bothRegex = new RegExp(/(both)/ig)
|
|
83
79
|
|
|
84
80
|
if (androidRegex.test(beaconType)) {
|
|
85
|
-
magicCallback((!!macAddress && !!txPower), 'Beacon type
|
|
81
|
+
magicCallback((!!macAddress && !!txPower), 'Beacon type "Android" must have both mac address and tx power values')
|
|
86
82
|
} else if (iosRegex.test(beaconType)) {
|
|
87
|
-
magicCallback((!!minor && !!major), 'Beacon type
|
|
83
|
+
magicCallback((!!minor && !!major), 'Beacon type "IOS" must have both minor and major values')
|
|
88
84
|
} else if (bothRegex.test(beaconType)) {
|
|
89
|
-
magicCallback((!!minor && !!major && !!txPower && !!macAddress), 'Beacon type
|
|
85
|
+
magicCallback((!!minor && !!major && !!txPower && !!macAddress), 'Beacon type "Both" must have all of minor, major, tx power, and mac address values')
|
|
90
86
|
} else {
|
|
91
87
|
magicCallback(true)
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
90
|
|
|
91
|
+
function validateKey (apiKey) {
|
|
92
|
+
// todo beacon can be added via zone or individually. so decide whether we need to validate apikey/ customerapikey, or log in function will solve that
|
|
93
|
+
'use strict'
|
|
94
|
+
let regex = new RegExp(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)
|
|
95
|
+
return !!regex.test(apiKey)
|
|
96
|
+
}
|
|
97
|
+
|
|
95
98
|
// optional mongoose
|
|
96
99
|
module.exports = (mongooseInstance) => {
|
|
97
100
|
let Beacon
|
|
@@ -103,4 +106,3 @@ module.exports = (mongooseInstance) => {
|
|
|
103
106
|
|
|
104
107
|
return Beacon
|
|
105
108
|
}
|
|
106
|
-
module.exports.beaconSchema = schema
|
package/models/BeaconFilter.js
CHANGED
|
@@ -5,34 +5,18 @@
|
|
|
5
5
|
*/
|
|
6
6
|
let mongoose = require('mongoose')
|
|
7
7
|
|
|
8
|
-
let schema = {
|
|
9
|
-
'_class': {type: String, default: 'au.com.bluedot.application.spring.filter.spatial.BeaconFilter'},
|
|
10
|
-
'beacon': {},
|
|
11
|
-
'guid': String,
|
|
12
|
-
'type': {type: String, default: 'beacon'}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
8
|
let BeaconFilterSchema = new mongoose.Schema(
|
|
16
|
-
|
|
9
|
+
{
|
|
10
|
+
'_class': {type: String, default: 'au.com.bluedot.application.spring.filter.spatial.BeaconFilter'},
|
|
11
|
+
'beacon': {},
|
|
12
|
+
'guid': String,
|
|
13
|
+
'type': {type: String, default: 'beacon'}
|
|
14
|
+
},
|
|
17
15
|
{
|
|
18
16
|
_id: false
|
|
19
17
|
}
|
|
20
18
|
)
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
type:
|
|
24
|
-
{type: String, required: true}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
// optional mongoose
|
|
28
|
-
module.exports = (mongooseInstance) => {
|
|
29
|
-
let BeaconFilter
|
|
30
|
-
if (mongooseInstance) {
|
|
31
|
-
BeaconFilter = mongooseInstance.model('BeaconFilter', BeaconFilterSchema)
|
|
32
|
-
} else {
|
|
33
|
-
BeaconFilter = mongoose.model('BeaconFilter', BeaconFilterSchema)
|
|
34
|
-
}
|
|
20
|
+
let BeaconFilter = mongoose.model('BeaconFilter', BeaconFilterSchema)
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
module.exports.beaconFilterSchema = schema
|
|
22
|
+
module.exports = BeaconFilter
|
package/models/BearingFilter.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
let BearingFilterSchema = new mongoose.Schema({
|
|
5
5
|
guid: {type: String, default: uuidv4},
|
|
6
|
+
type: {type: String, required: true},
|
|
6
7
|
fromAngle: {type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359},
|
|
7
|
-
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {
|
|
8
|
+
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {validator: validateAngles, msg: 'default error message'}}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
_id: false,
|
|
12
|
+
versionKey: false
|
|
8
13
|
}
|
|
9
|
-
|
|
10
|
-
const BearingFilterSchema = new mongoose.Schema(
|
|
11
|
-
schema,
|
|
12
|
-
{
|
|
13
|
-
_id: false,
|
|
14
|
-
versionKey: false
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
BearingFilterSchema.add({
|
|
18
|
-
type:
|
|
19
|
-
{type: String, required: true}
|
|
20
|
-
})
|
|
14
|
+
)
|
|
21
15
|
|
|
22
16
|
function validateAngles (toAngle, cb) {
|
|
23
17
|
let magicCallback = cb
|
|
@@ -55,4 +49,3 @@ module.exports = (mongooseInstance) => {
|
|
|
55
49
|
|
|
56
50
|
return BearingFilter
|
|
57
51
|
}
|
|
58
|
-
module.exports.bearingFilterSchema = schema
|
package/models/BoundingBox.js
CHANGED
|
@@ -3,27 +3,21 @@ let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
|
3
3
|
let uuidv4 = require('uuid/v4')
|
|
4
4
|
let Point = require('../schemas/Point')
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
let BoundingBoxSchema = new mongoose.Schema({
|
|
7
7
|
guid: {type: String, default: uuidv4},
|
|
8
|
+
type: {type: String, default: 'MultiLineString'},
|
|
8
9
|
name: {type: String, required: [true, 'name is required. ']},
|
|
9
10
|
northEast: {type: Point, required: [true, 'northEast is required. ']},
|
|
10
11
|
southWest: {type: Point, required: [true, 'southWest is required. ']},
|
|
11
12
|
creationTime: {type: Date, default: Date.now},
|
|
12
13
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
13
14
|
state: {type: String, default: StateEnum.active, select: false}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
_id: false,
|
|
18
|
+
versionKey: false
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
const BoundingBoxSchema = new mongoose.Schema(
|
|
17
|
-
schema,
|
|
18
|
-
{
|
|
19
|
-
_id: false,
|
|
20
|
-
versionKey: false
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
BoundingBoxSchema.add({
|
|
24
|
-
type:
|
|
25
|
-
{type: String, required: true}
|
|
26
|
-
})
|
|
20
|
+
)
|
|
27
21
|
|
|
28
22
|
// optional mongoose
|
|
29
23
|
module.exports = (mongooseInstance) => {
|
|
@@ -36,4 +30,3 @@ module.exports = (mongooseInstance) => {
|
|
|
36
30
|
|
|
37
31
|
return BoundingBox
|
|
38
32
|
}
|
|
39
|
-
module.exports.boundingBoxSchema = schema
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let CalendarDateRangeSchema = new mongoose.Schema({
|
|
5
5
|
guid: {type: String, default: uuidv4},
|
|
6
|
+
type: {type: String, required: true},
|
|
6
7
|
startDate: {type: Date, required: [true, 'startDate is required. ']},
|
|
7
8
|
endDate: {type: Date, required: [true, 'endDate is required. '], validate: validateDateRange}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
_id: false,
|
|
12
|
+
versionKey: false
|
|
8
13
|
}
|
|
9
|
-
|
|
10
|
-
schema,
|
|
11
|
-
{
|
|
12
|
-
_id: false,
|
|
13
|
-
versionKey: false
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
CalendarDateRangeSchema.add({
|
|
17
|
-
type:
|
|
18
|
-
{type: String, required: true}
|
|
19
|
-
})
|
|
14
|
+
)
|
|
20
15
|
|
|
21
16
|
function validateDateRange (endDate) {
|
|
22
17
|
let startDate = new Date(this.startDate)
|
|
@@ -38,4 +33,3 @@ module.exports = (mongooseInstance) => {
|
|
|
38
33
|
|
|
39
34
|
return CalendarDateRange
|
|
40
35
|
}
|
|
41
|
-
module.exports.calendarDateRangeSchema = schema
|
package/models/Circle.js
CHANGED
|
@@ -3,27 +3,21 @@ let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
|
3
3
|
let Point = require('../schemas/Point')
|
|
4
4
|
let uuidv4 = require('uuid/v4')
|
|
5
5
|
|
|
6
|
-
let
|
|
6
|
+
let CircleSchema = new mongoose.Schema({
|
|
7
7
|
guid: {type: String, default: uuidv4},
|
|
8
|
+
type: {type: String, default: 'MultiLineString'},
|
|
8
9
|
name: {type: String, required: [true, 'name is required. ']},
|
|
9
10
|
radius: {type: Number, required: [true, 'radius is required. '], min: 5},
|
|
10
11
|
center: {type: Point, required: [true, 'center is required. ']},
|
|
11
12
|
creationTime: {type: Date, default: Date.now},
|
|
12
13
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
13
14
|
state: {type: String, default: StateEnum.active, select: false}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
_id: false,
|
|
18
|
+
__v: false
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
let CircleSchema = new mongoose.Schema(
|
|
17
|
-
schema,
|
|
18
|
-
{
|
|
19
|
-
_id: false,
|
|
20
|
-
__v: false
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
CircleSchema.add({
|
|
24
|
-
type:
|
|
25
|
-
{type: String, required: true}
|
|
26
|
-
})
|
|
20
|
+
)
|
|
27
21
|
|
|
28
22
|
// optional mongoose
|
|
29
23
|
module.exports = (mongooseInstance) => {
|
|
@@ -36,4 +30,3 @@ module.exports = (mongooseInstance) => {
|
|
|
36
30
|
|
|
37
31
|
return Circle
|
|
38
32
|
}
|
|
39
|
-
module.exports.circleSchema = schema
|
package/models/Geofeature.js
CHANGED
|
@@ -7,6 +7,8 @@ let mongoose = require('mongoose')
|
|
|
7
7
|
let Schema = mongoose.Schema
|
|
8
8
|
|
|
9
9
|
let GeofeatureSchema = new Schema({
|
|
10
|
+
_id: Schema.Types.ObjectId,
|
|
11
|
+
_class: {type: String, default: 'au.com.bluedot.application.spring.GeoFeature'},
|
|
10
12
|
geometry: Schema.Types.Mixed,
|
|
11
13
|
referenceId: String,
|
|
12
14
|
apiKey: String,
|
package/models/MessageAction.js
CHANGED
|
@@ -2,25 +2,20 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
3
|
let uuidv4 = require('uuid/v4')
|
|
4
4
|
|
|
5
|
-
let
|
|
5
|
+
let MessageActionSchema = new mongoose.Schema({
|
|
6
6
|
guid: {type: String, default: uuidv4},
|
|
7
|
+
type: {type: String},
|
|
7
8
|
title: {type: String, required: [true, 'title is required. ']},
|
|
8
9
|
message: {type: String, required: [true, 'message is required. ']},
|
|
9
10
|
creationTime: {type: Date, default: Date.now},
|
|
10
11
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
11
12
|
state: {type: String, default: StateEnum.active, select: false}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
_id: false,
|
|
16
|
+
__v: false
|
|
12
17
|
}
|
|
13
|
-
|
|
14
|
-
let MessageActionSchema = new mongoose.Schema(schema,
|
|
15
|
-
{
|
|
16
|
-
_id: false,
|
|
17
|
-
__v: false
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
MessageActionSchema.add({
|
|
21
|
-
type:
|
|
22
|
-
{type: String, required: true}
|
|
23
|
-
})
|
|
18
|
+
)
|
|
24
19
|
|
|
25
20
|
// optional mongoose
|
|
26
21
|
module.exports = (mongooseInstance) => {
|
|
@@ -33,4 +28,3 @@ module.exports = (mongooseInstance) => {
|
|
|
33
28
|
|
|
34
29
|
return MessageAction
|
|
35
30
|
}
|
|
36
|
-
module.exports.messageActionSchema = schema
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let PercentageCrossedFilterSchema = new mongoose.Schema({
|
|
5
5
|
guid: {type: String, default: uuidv4},
|
|
6
|
+
type: {type: String},
|
|
6
7
|
percentage: {type: Number, required: [true, 'percentage is required. '], min: 1, max: 100},
|
|
7
8
|
timeOutSeconds: {type: Number, required: [true, 'timeOutSeconds is required. '], min: 60, max: 86400},
|
|
8
9
|
sequential: {type: Boolean, default: false}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
_id: false,
|
|
13
|
+
versionKey: false
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
schema,
|
|
12
|
-
{
|
|
13
|
-
_id: false,
|
|
14
|
-
versionKey: false
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
PercentageCrossedFilterSchema.add({
|
|
18
|
-
type:
|
|
19
|
-
{type: String, required: true}
|
|
20
|
-
})
|
|
15
|
+
)
|
|
21
16
|
|
|
22
17
|
// optional mongoose
|
|
23
18
|
module.exports = (mongooseInstance) => {
|
|
@@ -30,4 +25,3 @@ module.exports = (mongooseInstance) => {
|
|
|
30
25
|
|
|
31
26
|
return PercentageCrossedFilter
|
|
32
27
|
}
|
|
33
|
-
module.exports.percentageCrossedFilterSchema = schema
|
package/models/Polygon.js
CHANGED
|
@@ -3,24 +3,18 @@ let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
|
3
3
|
let Point = require('../schemas/Point')
|
|
4
4
|
let uuidv4 = require('uuid/v4')
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
let PolygonSchema = new mongoose.Schema({
|
|
7
7
|
guid: {type: String, default: uuidv4},
|
|
8
|
+
type: {type: String, required: true},
|
|
8
9
|
name: {type: String, required: [true, 'name is required. ']},
|
|
9
10
|
vertices: {type: [Point], required: [true, 'vertices is required. ']},
|
|
10
11
|
creationTime: {type: Date, default: Date.now},
|
|
11
12
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
12
13
|
state: {type: String, default: StateEnum.active, select: false}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_id: false,
|
|
18
|
-
versionKey: false
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
PolygonSchema.add({
|
|
22
|
-
type:
|
|
23
|
-
{type: String, required: true}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
_id: false,
|
|
17
|
+
versionKey: false
|
|
24
18
|
})
|
|
25
19
|
|
|
26
20
|
// optional mongoose
|
|
@@ -34,4 +28,3 @@ module.exports = (mongooseInstance) => {
|
|
|
34
28
|
|
|
35
29
|
return Polygon
|
|
36
30
|
}
|
|
37
|
-
module.exports.polygonSchema = schema
|
package/models/Polyline.js
CHANGED
|
@@ -3,27 +3,19 @@ let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
|
3
3
|
let Point = require('../schemas/Point')
|
|
4
4
|
let uuidv4 = require('uuid/v4')
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
let PolylineSchema = new mongoose.Schema({
|
|
7
7
|
guid: {type: String, default: uuidv4},
|
|
8
|
+
type: {type: String, required: true},
|
|
8
9
|
name: {type: String, required: [true, 'name is required. ']},
|
|
9
10
|
vertices: {type: [Point], required: [true, 'vertices is required. ']},
|
|
10
11
|
creationTime: {type: Date, default: Date.now},
|
|
11
12
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
12
13
|
state: {type: String, default: StateEnum.active, select: false}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
_id: false,
|
|
19
|
-
versionKey: false
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
PolylineSchema.add({
|
|
23
|
-
type:
|
|
24
|
-
{type: String, required: true}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
_id: false,
|
|
17
|
+
versionKey: false
|
|
25
18
|
})
|
|
26
|
-
|
|
27
19
|
// optional mongoose
|
|
28
20
|
module.exports = (mongooseInstance) => {
|
|
29
21
|
let Polyline
|
|
@@ -35,4 +27,3 @@ module.exports = (mongooseInstance) => {
|
|
|
35
27
|
|
|
36
28
|
return Polyline
|
|
37
29
|
}
|
|
38
|
-
module.exports.polylineSchema = schema
|
package/models/SpeedFilter.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let SpeedFilterSchema = new mongoose.Schema({
|
|
5
5
|
guid: {type: String, default: uuidv4},
|
|
6
|
+
type: {type: String},
|
|
6
7
|
minimumSpeed: {type: Number, required: [true, 'minimumSpeed is required. '], min: 0},
|
|
7
|
-
maximumSpeed: {type: Number, required: true, validate: {
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_id: false,
|
|
13
|
-
versionKey: false
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
SpeedFilterSchema.add({
|
|
17
|
-
type:
|
|
18
|
-
{type: String, required: true}
|
|
8
|
+
maximumSpeed: {type: Number, required: true, validate: {validator: validateMaxSpeed, msg: 'default error message'}}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
_id: false,
|
|
12
|
+
versionKey: false
|
|
19
13
|
})
|
|
20
14
|
|
|
21
15
|
function validateMaxSpeed (v, cb) {
|
|
@@ -43,4 +37,3 @@ module.exports = (mongooseInstance) => {
|
|
|
43
37
|
|
|
44
38
|
return SpeedFilter
|
|
45
39
|
}
|
|
46
|
-
module.exports.speedFilterSchema = schema
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
let
|
|
4
|
+
let TimeOfDayRangeFilterSchema = new mongoose.Schema({
|
|
5
5
|
guid: {type: String, default: uuidv4},
|
|
6
|
+
type: {type: String},
|
|
6
7
|
fromTime: {type: Number, required: [true, 'time is required. '], min: 0, max: 86400},
|
|
7
|
-
toTime: {type: Number, required: true, min: 0, max: 86400, validate:
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
_id: false,
|
|
13
|
-
versionKey: false
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
TimeOfDayRangeFilterSchema.add({
|
|
17
|
-
type:
|
|
18
|
-
{type: String, required: true}
|
|
8
|
+
toTime: {type: Number, required: true, min: 0, max: 86400, validate: validateTime}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
_id: false,
|
|
12
|
+
versionKey: false
|
|
19
13
|
})
|
|
20
14
|
|
|
21
15
|
function validateTime (toTime, cb) {
|
|
@@ -39,4 +33,3 @@ module.exports = (mongooseInstance) => {
|
|
|
39
33
|
|
|
40
34
|
return TimeOfDayRangeFilter
|
|
41
35
|
}
|
|
42
|
-
module.exports.timeOfDayRangeFilterSchema = schema
|
package/models/UrlAction.js
CHANGED
|
@@ -2,13 +2,13 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
3
|
let uuidv4 = require('uuid/v4')
|
|
4
4
|
|
|
5
|
-
let
|
|
5
|
+
let URLActionSchema = new mongoose.Schema({
|
|
6
6
|
guid: {type: String, default: uuidv4},
|
|
7
|
+
type: {type: String},
|
|
7
8
|
url: {
|
|
8
9
|
type: String,
|
|
9
10
|
required: [true, 'url is required. '],
|
|
10
11
|
validate: {
|
|
11
|
-
isAsync: true,
|
|
12
12
|
validator: validateURL
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -16,18 +16,12 @@ let schema = {
|
|
|
16
16
|
creationTime: {type: Date, default: Date.now},
|
|
17
17
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
18
18
|
state: {type: String, default: StateEnum.active, select: false}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
_id: false,
|
|
22
|
+
__v: false
|
|
19
23
|
}
|
|
20
|
-
|
|
21
|
-
let URLActionSchema = new mongoose.Schema(schema,
|
|
22
|
-
{
|
|
23
|
-
_id: false,
|
|
24
|
-
__v: false
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
URLActionSchema.add({
|
|
28
|
-
type:
|
|
29
|
-
{type: String, required: true}
|
|
30
|
-
})
|
|
24
|
+
)
|
|
31
25
|
|
|
32
26
|
function validateURL (url, cb) {
|
|
33
27
|
let magicCallback = cb
|
|
@@ -49,4 +43,3 @@ module.exports = (mongooseInstance) => {
|
|
|
49
43
|
|
|
50
44
|
return Urlaction
|
|
51
45
|
}
|
|
52
|
-
module.exports.urlActionSchema = schema
|