@bluedot-innovation/models 2.0.19-alpha.12 → 2.0.19-alpha.14
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/__tests__/zone/zone.spec.js +1 -1
- package/models/Zone.js +10 -10
- package/models/ZoneBeacon.js +2 -2
- package/models/geofeatures/Beacon.js +1 -1
- package/models/geofeatures/BoundingBox.js +8 -9
- package/models/geofeatures/Circle.js +3 -1
- package/models/geofeatures/Polygon.js +1 -1
- package/models/geofeatures/Polyline.js +7 -7
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ beforeEach(() => {
|
|
|
9
9
|
|
|
10
10
|
describe('Zone', () => {
|
|
11
11
|
describe('Valid Zone ', () => {
|
|
12
|
-
it
|
|
12
|
+
it('should validate a valid zone ', (done) => {
|
|
13
13
|
let Zone = new ZoneModel(zone)
|
|
14
14
|
Zone.validate((err, res) => {
|
|
15
15
|
assert.notExists(res)
|
package/models/Zone.js
CHANGED
|
@@ -9,11 +9,11 @@ let Schema = mongoose.Schema
|
|
|
9
9
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
10
10
|
let messageActionSchema = require('./MessageAction').messageActionSchema
|
|
11
11
|
let urlActionSchema = require('./UrlAction').urlActionSchema
|
|
12
|
-
let circleSchema = require('./geofeatures/Circle').
|
|
13
|
-
let boundingBoxSchema = require('./geofeatures/BoundingBox').
|
|
14
|
-
let polylineSchema = require('./geofeatures/Polyline').
|
|
15
|
-
let polygonSchema = require('./geofeatures/Polygon').
|
|
16
|
-
let beaconSchema = require('./ZoneBeacon').
|
|
12
|
+
let circleSchema = require('./geofeatures/Circle').rawSchema
|
|
13
|
+
let boundingBoxSchema = require('./geofeatures/BoundingBox').rawSchema
|
|
14
|
+
let polylineSchema = require('./geofeatures/Polyline').rawSchema
|
|
15
|
+
let polygonSchema = require('./geofeatures/Polygon').rawSchema
|
|
16
|
+
let beaconSchema = require('./ZoneBeacon').rawSchema
|
|
17
17
|
let speedFilterSchema = require('./SpeedFilter').speedFilterSchema
|
|
18
18
|
let bearingFilterSchema = require('./BearingFilter').bearingFilterSchema
|
|
19
19
|
let timeOfDayRangeFilterSchema = require('./TimeOfDayRangeFilter').timeOfDayRangeFilterSchema
|
|
@@ -83,11 +83,11 @@ zoneSchema.path('filters').discriminator('percentageCrossed', new Schema(percent
|
|
|
83
83
|
zoneSchema.path('filters').discriminator('speed', new Schema(speedFilterSchema))
|
|
84
84
|
zoneSchema.path('filters').discriminator('timeOfDayRange', new Schema(timeOfDayRangeFilterSchema))
|
|
85
85
|
|
|
86
|
-
zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema))
|
|
87
|
-
zoneSchema.path('geofeatures').discriminator('
|
|
88
|
-
zoneSchema.path('geofeatures').discriminator('
|
|
89
|
-
zoneSchema.path('geofeatures').discriminator('
|
|
90
|
-
zoneSchema.path('geofeatures').discriminator('
|
|
86
|
+
zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema).plugin(mongooseHidden))
|
|
87
|
+
zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema).plugin(mongooseHidden))
|
|
88
|
+
zoneSchema.path('geofeatures').discriminator('circle', new Schema(circleSchema).plugin(mongooseHidden))
|
|
89
|
+
zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema).plugin(mongooseHidden))
|
|
90
|
+
zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema).plugin(mongooseHidden))
|
|
91
91
|
|
|
92
92
|
// optional mongoose
|
|
93
93
|
const model = (mongooseInstance) => {
|
package/models/ZoneBeacon.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const cloneDeep = require('lodash.clonedeep')
|
|
2
2
|
const mongoose = require('mongoose')
|
|
3
|
-
const beaconSchema = require('./geofeatures/Beacon').
|
|
3
|
+
const beaconSchema = require('./geofeatures/Beacon').rawSchema
|
|
4
4
|
const BeaconEnum = require('@bluedot-innovation/enums').BeaconEnum
|
|
5
5
|
|
|
6
6
|
const schema = cloneDeep(beaconSchema)
|
|
@@ -20,4 +20,4 @@ let model = (mongooseInstance) => {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
23
|
-
module.exports = { Model: model, Schema: ZoneBeaconSchema,
|
|
23
|
+
module.exports = { Model: model, Schema: ZoneBeaconSchema, rawSchema: schema }
|
|
@@ -91,4 +91,4 @@ let model = (mongooseInstance) => {
|
|
|
91
91
|
return Beacon
|
|
92
92
|
}
|
|
93
93
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
94
|
-
module.exports = { Model: model, Schema: BeaconSchema,
|
|
94
|
+
module.exports = { Model: model, Schema: BeaconSchema, rawSchema: schema }
|
|
@@ -17,16 +17,15 @@ const schema = {
|
|
|
17
17
|
state: {type: String, default: StateEnum.active, select: false}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const boundingBoxSchema = new mongoose.Schema(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
versionKey: false
|
|
25
|
-
})
|
|
20
|
+
const boundingBoxSchema = new mongoose.Schema(schema, {
|
|
21
|
+
_id: false,
|
|
22
|
+
versionKey: false
|
|
23
|
+
})
|
|
26
24
|
|
|
25
|
+
// Adding type after, because we need to export the rawSchema without type,
|
|
26
|
+
// since the zone discriminator needs the schema without it
|
|
27
27
|
boundingBoxSchema.add({
|
|
28
|
-
type:
|
|
29
|
-
{type: String, required: true}
|
|
28
|
+
type: {type: String, required: true}
|
|
30
29
|
})
|
|
31
30
|
|
|
32
31
|
boundingBoxSchema.plugin(mongooseHidden)
|
|
@@ -44,4 +43,4 @@ let model = (mongooseInstance) => {
|
|
|
44
43
|
return BoundingBox
|
|
45
44
|
}
|
|
46
45
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
47
|
-
module.exports = { Model: model, Schema: boundingBoxSchema,
|
|
46
|
+
module.exports = { Model: model, Schema: boundingBoxSchema, rawSchema: schema }
|
|
@@ -24,6 +24,8 @@ let circleSchema = new mongoose.Schema(
|
|
|
24
24
|
__v: false
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
+
// Adding type after, because we need to export the rawSchema without type,
|
|
28
|
+
// since the zone discriminator needs the schema without it
|
|
27
29
|
circleSchema.add({
|
|
28
30
|
type: {type: String, required: true}
|
|
29
31
|
})
|
|
@@ -42,4 +44,4 @@ let model = (mongooseInstance) => {
|
|
|
42
44
|
return Circle
|
|
43
45
|
}
|
|
44
46
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
45
|
-
module.exports = { Model: model, Schema: circleSchema,
|
|
47
|
+
module.exports = { Model: model, Schema: circleSchema, rawSchema: schema }
|
|
@@ -41,4 +41,4 @@ let model = (mongooseInstance) => {
|
|
|
41
41
|
return Polygon
|
|
42
42
|
}
|
|
43
43
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
44
|
-
module.exports = { Model: model, Schema: polygonSchema,
|
|
44
|
+
module.exports = { Model: model, Schema: polygonSchema, rawSchema: schema }
|
|
@@ -15,13 +15,13 @@ const schema = {
|
|
|
15
15
|
state: {type: String, default: StateEnum.active, select: false}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const polylineSchema = new mongoose.Schema(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
versionKey: false
|
|
23
|
-
})
|
|
18
|
+
const polylineSchema = new mongoose.Schema(schema, {
|
|
19
|
+
_id: false,
|
|
20
|
+
versionKey: false
|
|
21
|
+
})
|
|
24
22
|
|
|
23
|
+
// Adding type after, because we need to export the rawSchema without type,
|
|
24
|
+
// since the zone discriminator needs the schema without it
|
|
25
25
|
polylineSchema.add({
|
|
26
26
|
type: {type: String, required: true}
|
|
27
27
|
})
|
|
@@ -40,4 +40,4 @@ let model = (mongooseInstance) => {
|
|
|
40
40
|
return Polyline
|
|
41
41
|
}
|
|
42
42
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
43
|
-
module.exports = { Model: model, Schema: polylineSchema,
|
|
43
|
+
module.exports = { Model: model, Schema: polylineSchema, rawSchema: schema }
|