@bluedot-innovation/models 2.0.0-alpha.9 → 2.0.0-beta.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/.npmignore +3 -0
- package/.nyc_output/295801a153bad60b994d5c6b5a8016d9.json +1 -0
- package/.nyc_output/2963e30f6030a94b16dd86e7b5594ebe.json +1 -0
- package/.nyc_output/5fc62324d665599db6649363a937708e.json +1 -0
- package/.nyc_output/95eec4b77e4566b36a6300f0cf8bea0b.json +1 -0
- package/Models.js +34 -8
- package/__tests__/action/message/messageAction.spec.js +1 -1
- package/__tests__/action/url/urlAction.spec.js +1 -1
- package/__tests__/filter/bearing/bearingFilter.spec.js +1 -1
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.spec.js +1 -1
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.spec.js +1 -1
- package/__tests__/filter/speed/speedFilter.spec.js +1 -1
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.spec.js +1 -1
- package/__tests__/geofeature/beacon/beacon.spec.js +1 -1
- package/__tests__/geofeature/boundingBox/boundingBox.spec.js +1 -1
- package/__tests__/geofeature/circle/circle.spec.js +1 -1
- package/__tests__/geofeature/polygon/polygon.spec.js +1 -1
- package/__tests__/geofeature/polyline/polyline.spec.js +1 -1
- package/__tests__/monthlyStats/monthlyStats.data.json +29 -0
- package/__tests__/monthlyStats/monthlyStats.spec.js +40 -0
- package/__tests__/zone/zone.action.spec.js +1 -1
- package/__tests__/zone/zone.filter.spec.js +1 -1
- package/__tests__/zone/zone.geofeatures.spec.js +1 -1
- package/__tests__/zone/zone.spec.js +1 -1
- package/models/Beacon.js +6 -5
- package/models/BeaconFilter.js +3 -5
- package/models/BearingFilter.js +4 -3
- package/models/BoundingBox.js +4 -3
- package/models/CalendarDateRangeFilter.js +9 -8
- package/models/Circle.js +3 -2
- package/models/MessageAction.js +3 -2
- package/models/MonthlyStats.js +39 -0
- package/models/PercentageCrossedFilter.js +3 -2
- package/models/Polygon.js +3 -2
- package/models/Polyline.js +3 -2
- package/models/SpeedFilter.js +4 -3
- package/models/TimeOfDayRangeFilter.js +5 -3
- package/models/UrlAction.js +5 -2
- package/models/Zone.js +5 -3
- package/package-lock.json +3503 -0
- package/package.json +4 -5
- package/.nyc_output/.gitkeep +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let MonthlyStatsModel = require('../../models/MonthlyStats')(mongoose)
|
|
6
|
+
let testCase = require('mocha').describe
|
|
7
|
+
let assertions = require('mocha').it
|
|
8
|
+
let chai = require('chai')
|
|
9
|
+
|
|
10
|
+
let assert = chai.assert
|
|
11
|
+
let mocha = require('mocha')
|
|
12
|
+
let beforeEach = mocha.beforeEach
|
|
13
|
+
|
|
14
|
+
let monthlyStats
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
monthlyStats = JSON.parse(JSON.stringify(require('./monthlyStats.data.json')))
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
testCase('MonthlyStats', () => {
|
|
21
|
+
testCase('Valid MonthlyStats document', () => {
|
|
22
|
+
assertions('should validate a valid MonthlyStats document ', (done) => {
|
|
23
|
+
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
24
|
+
MonthlyStats.validate((err, res) => {
|
|
25
|
+
assert.notExists(res)
|
|
26
|
+
assert(err === null, 'err should equals null')
|
|
27
|
+
done()
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
assertions('should accept a valid customerId', (done) => {
|
|
31
|
+
monthlyStats.customerId = '23a01af0-232a-4518-9c0e-323fb773f5ef'
|
|
32
|
+
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
33
|
+
MonthlyStats.validate((err, res) => {
|
|
34
|
+
assert.notExists(res)
|
|
35
|
+
assert(err === null, 'err should equals null')
|
|
36
|
+
done()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -2,7 +2,7 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
|
|
3
3
|
mongoose.Promise = global.Promise
|
|
4
4
|
|
|
5
|
-
let ZoneModel = require('../../models/Zone')(mongoose)
|
|
5
|
+
let ZoneModel = require('../../models/Zone').Zone(mongoose)
|
|
6
6
|
let testCase = require('mocha').describe
|
|
7
7
|
let assertions = require('mocha').it
|
|
8
8
|
let chai = require('chai')
|
|
@@ -2,7 +2,7 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
|
|
3
3
|
mongoose.Promise = global.Promise
|
|
4
4
|
|
|
5
|
-
let ZoneModel = require('../../models/Zone')(mongoose)
|
|
5
|
+
let ZoneModel = require('../../models/Zone').Zone(mongoose)
|
|
6
6
|
let testCase = require('mocha').describe
|
|
7
7
|
let assertions = require('mocha').it
|
|
8
8
|
let chai = require('chai')
|
|
@@ -2,7 +2,7 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
|
|
3
3
|
mongoose.Promise = global.Promise
|
|
4
4
|
|
|
5
|
-
let ZoneModel = require('../../models/Zone')(mongoose)
|
|
5
|
+
let ZoneModel = require('../../models/Zone').Zone(mongoose)
|
|
6
6
|
let testCase = require('mocha').describe
|
|
7
7
|
let assertions = require('mocha').it
|
|
8
8
|
let chai = require('chai')
|
|
@@ -2,7 +2,7 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
|
|
3
3
|
mongoose.Promise = global.Promise
|
|
4
4
|
|
|
5
|
-
let ZoneModel = require('../../models/Zone')(mongoose)
|
|
5
|
+
let ZoneModel = require('../../models/Zone').Zone(mongoose)
|
|
6
6
|
let testCase = require('mocha').describe
|
|
7
7
|
let assertions = require('mocha').it
|
|
8
8
|
let chai = require('chai')
|
package/models/Beacon.js
CHANGED
|
@@ -82,18 +82,18 @@ function validateBeaconType (v, cb) {
|
|
|
82
82
|
let bothRegex = new RegExp(/(both)/ig)
|
|
83
83
|
|
|
84
84
|
if (androidRegex.test(beaconType)) {
|
|
85
|
-
magicCallback((!!macAddress && !!txPower), 'Beacon type
|
|
85
|
+
magicCallback((!!macAddress && !!txPower), 'Beacon type `Android` must have both mac address and tx power values')
|
|
86
86
|
} else if (iosRegex.test(beaconType)) {
|
|
87
|
-
magicCallback((!!minor && !!major), 'Beacon type
|
|
87
|
+
magicCallback((!!minor && !!major), 'Beacon type `IOS` must have both minor and major values')
|
|
88
88
|
} else if (bothRegex.test(beaconType)) {
|
|
89
|
-
magicCallback((!!minor && !!major && !!txPower && !!macAddress), 'Beacon type
|
|
89
|
+
magicCallback((!!minor && !!major && !!txPower && !!macAddress), 'Beacon type `Both` must have all of minor, major, tx power, and mac address values')
|
|
90
90
|
} else {
|
|
91
91
|
magicCallback(true)
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// optional mongoose
|
|
96
|
-
|
|
96
|
+
let model = (mongooseInstance) => {
|
|
97
97
|
let Beacon
|
|
98
98
|
if (mongooseInstance) {
|
|
99
99
|
Beacon = mongooseInstance.model('Beacon', BeaconSchema)
|
|
@@ -103,4 +103,5 @@ module.exports = (mongooseInstance) => {
|
|
|
103
103
|
|
|
104
104
|
return Beacon
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
107
|
+
module.exports = { Beacon: model, Schema: BeaconSchema, beaconSchema: schema }
|
package/models/BeaconFilter.js
CHANGED
|
@@ -24,10 +24,8 @@ BeaconFilterSchema.add({
|
|
|
24
24
|
{type: String, required: true}
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
let BeaconFilter = mongoose.model('BeaconFilter', BeaconFilterSchema)
|
|
28
|
-
|
|
29
27
|
// optional mongoose
|
|
30
|
-
|
|
28
|
+
let model = (mongooseInstance) => {
|
|
31
29
|
let BeaconFilter
|
|
32
30
|
if (mongooseInstance) {
|
|
33
31
|
BeaconFilter = mongooseInstance.model('BeaconFilter', BeaconFilterSchema)
|
|
@@ -37,5 +35,5 @@ module.exports = (mongooseInstance) => {
|
|
|
37
35
|
|
|
38
36
|
return BeaconFilter
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
module.exports
|
|
38
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
39
|
+
module.exports = { BeaconFilter: model, Schema: BeaconFilterSchema, beaconFilterSchema: schema }
|
package/models/BearingFilter.js
CHANGED
|
@@ -4,7 +4,7 @@ let uuidv4 = require('uuid/v4')
|
|
|
4
4
|
const schema = {
|
|
5
5
|
guid: {type: String, default: uuidv4},
|
|
6
6
|
fromAngle: {type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359},
|
|
7
|
-
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {validator: validateAngles, msg: 'default error message'}}
|
|
7
|
+
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {isAsync: true, validator: validateAngles, msg: 'default error message'}}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const BearingFilterSchema = new mongoose.Schema(
|
|
@@ -45,7 +45,7 @@ function validateAngles (toAngle, cb) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// optional mongoose
|
|
48
|
-
|
|
48
|
+
let model = (mongooseInstance) => {
|
|
49
49
|
let BearingFilter
|
|
50
50
|
if (mongooseInstance) {
|
|
51
51
|
BearingFilter = mongooseInstance.model('BearingFilter', BearingFilterSchema)
|
|
@@ -55,4 +55,5 @@ module.exports = (mongooseInstance) => {
|
|
|
55
55
|
|
|
56
56
|
return BearingFilter
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
59
|
+
module.exports = { BearingFilter: model, Schema: BearingFilterSchema, bearingFilterSchema: schema }
|
package/models/BoundingBox.js
CHANGED
|
@@ -26,14 +26,15 @@ BoundingBoxSchema.add({
|
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
// optional mongoose
|
|
29
|
-
|
|
29
|
+
let model = (mongooseInstance) => {
|
|
30
30
|
let BoundingBox
|
|
31
31
|
if (mongooseInstance) {
|
|
32
32
|
BoundingBox = mongooseInstance.model('BoundingBox', BoundingBoxSchema)
|
|
33
33
|
} else {
|
|
34
|
-
BoundingBox = mongoose.model('BoundingBox',
|
|
34
|
+
BoundingBox = mongoose.model('BoundingBox', BoundingBoxSchema)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return BoundingBox
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
40
|
+
module.exports = { BoundingBox: model, Schema: BoundingBoxSchema, boundingBoxSchema: schema }
|
|
@@ -6,14 +6,14 @@ let schema = {
|
|
|
6
6
|
startDate: {type: Date, required: [true, 'startDate is required. ']},
|
|
7
7
|
endDate: {type: Date, required: [true, 'endDate is required. '], validate: validateDateRange}
|
|
8
8
|
}
|
|
9
|
-
let
|
|
9
|
+
let CalendarDateRangeFilterSchema = new mongoose.Schema(
|
|
10
10
|
schema,
|
|
11
11
|
{
|
|
12
12
|
_id: false,
|
|
13
13
|
versionKey: false
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
CalendarDateRangeFilterSchema.add({
|
|
17
17
|
type:
|
|
18
18
|
{type: String, required: true}
|
|
19
19
|
})
|
|
@@ -28,14 +28,15 @@ function validateDateRange (endDate) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// optional mongoose
|
|
31
|
-
|
|
32
|
-
let
|
|
31
|
+
let model = (mongooseInstance) => {
|
|
32
|
+
let CalendarDateRangeFilter
|
|
33
33
|
if (mongooseInstance) {
|
|
34
|
-
|
|
34
|
+
CalendarDateRangeFilter = mongooseInstance.model('CalendarDateRange', CalendarDateRangeFilterSchema)
|
|
35
35
|
} else {
|
|
36
|
-
|
|
36
|
+
CalendarDateRangeFilter = mongoose.model('CalendarDateRange', CalendarDateRangeFilterSchema)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
return
|
|
39
|
+
return CalendarDateRangeFilter
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
42
|
+
module.exports = { CalendarDateRangeFilter: model, Schema: CalendarDateRangeFilterSchema, calendarDateRangeFilterSchema: schema }
|
package/models/Circle.js
CHANGED
|
@@ -26,7 +26,7 @@ CircleSchema.add({
|
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
// optional mongoose
|
|
29
|
-
|
|
29
|
+
let model = (mongooseInstance) => {
|
|
30
30
|
let Circle
|
|
31
31
|
if (mongooseInstance) {
|
|
32
32
|
Circle = mongooseInstance.model('Circle', CircleSchema)
|
|
@@ -36,4 +36,5 @@ module.exports = (mongooseInstance) => {
|
|
|
36
36
|
|
|
37
37
|
return Circle
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
40
|
+
module.exports = { Circle: model, Schema: CircleSchema, circleSchema: schema }
|
package/models/MessageAction.js
CHANGED
|
@@ -23,7 +23,7 @@ MessageActionSchema.add({
|
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
// optional mongoose
|
|
26
|
-
|
|
26
|
+
let model = (mongooseInstance) => {
|
|
27
27
|
let MessageAction
|
|
28
28
|
if (mongooseInstance) {
|
|
29
29
|
MessageAction = mongooseInstance.model('MessageAction', MessageActionSchema)
|
|
@@ -33,4 +33,5 @@ module.exports = (mongooseInstance) => {
|
|
|
33
33
|
|
|
34
34
|
return MessageAction
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
37
|
+
module.exports = { MessageAction: model, Schema: MessageActionSchema, messageActionSchema: schema }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Daniel on 08/02/2018.
|
|
3
|
+
* Copyright : Bluedot Innovations.
|
|
4
|
+
* Owner :
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const mongoose = require('mongoose')
|
|
8
|
+
const uuidv4 = require('uuid/v4')
|
|
9
|
+
|
|
10
|
+
const schema = {
|
|
11
|
+
_id: { type: String, default: uuidv4 },
|
|
12
|
+
customerId: String,
|
|
13
|
+
totalMonthlyUsers: Number,
|
|
14
|
+
applications: [],
|
|
15
|
+
countMonth: { type: Date, default: Date.now },
|
|
16
|
+
creationDate: { type: Date, default: Date.now }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const MonthlyStatsSchema = new mongoose.Schema(
|
|
20
|
+
schema,
|
|
21
|
+
{
|
|
22
|
+
collection: 'monthlyStats',
|
|
23
|
+
versionKey: false
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
// optional mongoose
|
|
28
|
+
module.exports = (mongooseInstance) => {
|
|
29
|
+
let MonthlyStats
|
|
30
|
+
if (mongooseInstance) {
|
|
31
|
+
MonthlyStats = mongooseInstance.model('MonthlyStats', MonthlyStatsSchema)
|
|
32
|
+
} else {
|
|
33
|
+
MonthlyStats = mongoose.model('MonthlyStats', MonthlyStats)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return MonthlyStats
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports.monthlyStatsSchema = schema
|
|
@@ -20,7 +20,7 @@ PercentageCrossedFilterSchema.add({
|
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
// optional mongoose
|
|
23
|
-
|
|
23
|
+
let model = (mongooseInstance) => {
|
|
24
24
|
let PercentageCrossedFilter
|
|
25
25
|
if (mongooseInstance) {
|
|
26
26
|
PercentageCrossedFilter = mongooseInstance.model('PercentageCrossedFilter', PercentageCrossedFilterSchema)
|
|
@@ -30,4 +30,5 @@ module.exports = (mongooseInstance) => {
|
|
|
30
30
|
|
|
31
31
|
return PercentageCrossedFilter
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
34
|
+
module.exports = { PercentageCrossedFilter: model, Schema: PercentageCrossedFilterSchema, percentageCrossedFilterSchema: schema }
|
package/models/Polygon.js
CHANGED
|
@@ -24,7 +24,7 @@ PolygonSchema.add({
|
|
|
24
24
|
})
|
|
25
25
|
|
|
26
26
|
// optional mongoose
|
|
27
|
-
|
|
27
|
+
let model = (mongooseInstance) => {
|
|
28
28
|
let Polygon
|
|
29
29
|
if (mongooseInstance) {
|
|
30
30
|
Polygon = mongooseInstance.model('Polygon', PolygonSchema)
|
|
@@ -34,4 +34,5 @@ module.exports = (mongooseInstance) => {
|
|
|
34
34
|
|
|
35
35
|
return Polygon
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
38
|
+
module.exports = { Polygon: model, Schema: PolygonSchema, polygonSchema: schema }
|
package/models/Polyline.js
CHANGED
|
@@ -25,7 +25,7 @@ PolylineSchema.add({
|
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
// optional mongoose
|
|
28
|
-
|
|
28
|
+
let model = (mongooseInstance) => {
|
|
29
29
|
let Polyline
|
|
30
30
|
if (mongooseInstance) {
|
|
31
31
|
Polyline = mongooseInstance.model('Polyline', PolylineSchema)
|
|
@@ -35,4 +35,5 @@ module.exports = (mongooseInstance) => {
|
|
|
35
35
|
|
|
36
36
|
return Polyline
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
39
|
+
module.exports = { Polyline: model, Schema: PolylineSchema, polylineSchema: schema }
|
package/models/SpeedFilter.js
CHANGED
|
@@ -4,7 +4,7 @@ let uuidv4 = require('uuid/v4')
|
|
|
4
4
|
let schema = {
|
|
5
5
|
guid: {type: String, default: uuidv4},
|
|
6
6
|
minimumSpeed: {type: Number, required: [true, 'minimumSpeed is required. '], min: 0},
|
|
7
|
-
maximumSpeed: {type: Number, required: true, validate: {validator: validateMaxSpeed, msg: 'default error message'}}
|
|
7
|
+
maximumSpeed: {type: Number, required: true, validate: {isAsync: true, validator: validateMaxSpeed, msg: 'default error message'}}
|
|
8
8
|
}
|
|
9
9
|
let SpeedFilterSchema = new mongoose.Schema(
|
|
10
10
|
schema,
|
|
@@ -33,7 +33,7 @@ function validateMaxSpeed (v, cb) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// optional mongoose
|
|
36
|
-
|
|
36
|
+
let model = (mongooseInstance) => {
|
|
37
37
|
let SpeedFilter
|
|
38
38
|
if (mongooseInstance) {
|
|
39
39
|
SpeedFilter = mongooseInstance.model('SpeedFilter', SpeedFilterSchema)
|
|
@@ -43,4 +43,5 @@ module.exports = (mongooseInstance) => {
|
|
|
43
43
|
|
|
44
44
|
return SpeedFilter
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
47
|
+
module.exports = { SpeedFilter: model, Schema: SpeedFilterSchema, speedFilterSchema: schema }
|
|
@@ -4,7 +4,7 @@ let uuidv4 = require('uuid/v4')
|
|
|
4
4
|
let schema = {
|
|
5
5
|
guid: {type: String, default: uuidv4},
|
|
6
6
|
fromTime: {type: Number, required: [true, 'time is required. '], min: 0, max: 86400},
|
|
7
|
-
toTime: {type: Number, required: true, min: 0, max: 86400, validate: validateTime}
|
|
7
|
+
toTime: {type: Number, required: true, min: 0, max: 86400, validate: {isAsync: true, validator: validateTime}}
|
|
8
8
|
}
|
|
9
9
|
let TimeOfDayRangeFilterSchema = new mongoose.Schema(
|
|
10
10
|
schema,
|
|
@@ -29,7 +29,7 @@ function validateTime (toTime, cb) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// optional mongoose
|
|
32
|
-
|
|
32
|
+
let model = (mongooseInstance) => {
|
|
33
33
|
let TimeOfDayRangeFilter
|
|
34
34
|
if (mongooseInstance) {
|
|
35
35
|
TimeOfDayRangeFilter = mongooseInstance.model('TimeOfDayRangeFilterSchema', TimeOfDayRangeFilterSchema)
|
|
@@ -39,4 +39,6 @@ module.exports = (mongooseInstance) => {
|
|
|
39
39
|
|
|
40
40
|
return TimeOfDayRangeFilter
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
44
|
+
module.exports = { TimeOfDayRangeFilter: model, Schema: TimeOfDayRangeFilterSchema, timeOfDayRangeFilterSchema: schema }
|
package/models/UrlAction.js
CHANGED
|
@@ -8,6 +8,7 @@ let schema = {
|
|
|
8
8
|
type: String,
|
|
9
9
|
required: [true, 'url is required. '],
|
|
10
10
|
validate: {
|
|
11
|
+
isAsync: true,
|
|
11
12
|
validator: validateURL
|
|
12
13
|
}
|
|
13
14
|
},
|
|
@@ -38,7 +39,7 @@ function validateURL (url, cb) {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
// optional mongoose
|
|
41
|
-
|
|
42
|
+
const model = (mongooseInstance) => {
|
|
42
43
|
let Urlaction
|
|
43
44
|
if (mongooseInstance) {
|
|
44
45
|
Urlaction = mongooseInstance.model('Urlaction', URLActionSchema)
|
|
@@ -48,4 +49,6 @@ module.exports = (mongooseInstance) => {
|
|
|
48
49
|
|
|
49
50
|
return Urlaction
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
|
|
53
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
54
|
+
module.exports = { UrlAction: model, Schema: URLActionSchema, urlActionSchema: schema }
|
package/models/Zone.js
CHANGED
|
@@ -17,7 +17,7 @@ let beaconSchema = require('./Beacon').beaconSchema
|
|
|
17
17
|
let speedFilterSchema = require('./SpeedFilter').speedFilterSchema
|
|
18
18
|
let bearingFilterSchema = require('./BearingFilter').bearingFilterSchema
|
|
19
19
|
let timeOfDayRangeFilterSchema = require('./TimeOfDayRangeFilter').timeOfDayRangeFilterSchema
|
|
20
|
-
let calendarDateRangeFilterSchema = require('./CalendarDateRangeFilter').
|
|
20
|
+
let calendarDateRangeFilterSchema = require('./CalendarDateRangeFilter').calendarDateRangeFilterSchema
|
|
21
21
|
let percentageCrossedFilterSchema = require('./PercentageCrossedFilter').percentageCrossedFilterSchema
|
|
22
22
|
let uuidv4 = require('uuid/v4')
|
|
23
23
|
let patcher = require('mongoose-json-patch')
|
|
@@ -56,7 +56,7 @@ let ZoneSchema = new Schema({
|
|
|
56
56
|
},
|
|
57
57
|
geofeatures: {
|
|
58
58
|
type: [geofeatureSchema],
|
|
59
|
-
required:
|
|
59
|
+
required: true
|
|
60
60
|
},
|
|
61
61
|
customData: [{type: Schema.Types.Mixed}],
|
|
62
62
|
description: {type: String, default: ''},
|
|
@@ -85,7 +85,7 @@ ZoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSche
|
|
|
85
85
|
ZoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema))
|
|
86
86
|
|
|
87
87
|
// optional mongoose
|
|
88
|
-
|
|
88
|
+
const model = (mongooseInstance) => {
|
|
89
89
|
let Zone
|
|
90
90
|
if (mongooseInstance) {
|
|
91
91
|
Zone = mongooseInstance.model('Zone', ZoneSchema)
|
|
@@ -95,3 +95,5 @@ module.exports = (mongooseInstance) => {
|
|
|
95
95
|
|
|
96
96
|
return Zone
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
module.exports = { Zone: model, Schema: ZoneSchema }
|