@bluedot-innovation/models 2.0.19-alpha.20 → 2.0.19-alpha.22
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/Models.js +11 -11
- package/__tests__/filter/bearing/bearingFilter.spec.js +1 -1
- package/models/{geofeatures/Beacon.js → Beacon.js} +7 -8
- package/models/{geofeatures/BoundingBox.js → BoundingBox.js} +15 -18
- package/models/{geofeatures/Circle.js → Circle.js} +9 -13
- package/models/{geofeatures/Polygon.js → Polygon.js} +6 -10
- package/models/{geofeatures/Polyline.js → Polyline.js} +14 -16
- package/models/Zone.js +6 -6
- package/models/{geofeatures/ZoneBeacon.js → ZoneBeacon.js} +5 -9
- package/package.json +1 -1
- package/utils/mongooseHidden.js +1 -2
package/Models.js
CHANGED
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
let Models = {}
|
|
6
6
|
|
|
7
7
|
Models.Account = require('./models/Account').Model
|
|
8
|
-
Models.Beacon = require('./models/
|
|
8
|
+
Models.Beacon = require('./models/Beacon').Model
|
|
9
9
|
Models.BeaconFilter = require('./models/BeaconFilter').Model
|
|
10
10
|
Models.BearingFilter = require('./models/BearingFilter').Model
|
|
11
|
-
Models.BoundingBox = require('./models/
|
|
11
|
+
Models.BoundingBox = require('./models/BoundingBox').Model
|
|
12
12
|
Models.CalendarDateRangeFilter = require('./models/CalendarDateRangeFilter').Model
|
|
13
|
-
Models.Circle = require('./models/
|
|
13
|
+
Models.Circle = require('./models/Circle').Model
|
|
14
14
|
Models.MessageAction = require('./models/MessageAction').Model
|
|
15
15
|
Models.MonthlyStat = require('./models/MonthlyStats').Model
|
|
16
16
|
Models.PercentageCrossedFilter = require('./models/PercentageCrossedFilter').Model
|
|
17
|
-
Models.Polygon = require('./models/
|
|
18
|
-
Models.Polyline = require('./models/
|
|
17
|
+
Models.Polygon = require('./models/Polygon').Model
|
|
18
|
+
Models.Polyline = require('./models/Polyline').Model
|
|
19
19
|
Models.Project = require('./models/Project').Model
|
|
20
20
|
Models.RuleRequestAggregation = require('./models/RuleRequestAggregation').Model
|
|
21
21
|
Models.SpeedFilter = require('./models/SpeedFilter').Model
|
|
@@ -23,22 +23,22 @@ Models.TimeOfDayRangeFilter = require('./models/TimeOfDayRangeFilter').Model
|
|
|
23
23
|
Models.UrlAction = require('./models/UrlAction').Model
|
|
24
24
|
Models.User = require('./models/User').Model
|
|
25
25
|
Models.Zone = require('./models/Zone').Model
|
|
26
|
-
Models.ZoneBeacon = require('./models/
|
|
26
|
+
Models.ZoneBeacon = require('./models/ZoneBeacon').Model
|
|
27
27
|
|
|
28
28
|
let Schemas = {}
|
|
29
29
|
|
|
30
30
|
Schemas.Account = require('./models/Account').Schema
|
|
31
|
-
Schemas.Beacon = require('./models/
|
|
31
|
+
Schemas.Beacon = require('./models/Beacon').Schema
|
|
32
32
|
Schemas.BeaconFilter = require('./models/BeaconFilter').Schema
|
|
33
33
|
Schemas.BearingFilter = require('./models/BearingFilter').Schema
|
|
34
|
-
Schemas.BoundingBox = require('./models/
|
|
34
|
+
Schemas.BoundingBox = require('./models/BoundingBox').Schema
|
|
35
35
|
Schemas.CalendarDateRangeFilter = require('./models/CalendarDateRangeFilter').Schema
|
|
36
|
-
Schemas.Circle = require('./models/
|
|
36
|
+
Schemas.Circle = require('./models/Circle').Schema
|
|
37
37
|
Schemas.MessageAction = require('./models/MessageAction').Schema
|
|
38
38
|
Schemas.MonthlyStat = require('./models/MonthlyStats').Schema
|
|
39
39
|
Schemas.PercentageCrossedFilter = require('./models/PercentageCrossedFilter').Schema
|
|
40
|
-
Schemas.Polygon = require('./models/
|
|
41
|
-
Schemas.Polyline = require('./models/
|
|
40
|
+
Schemas.Polygon = require('./models/Polygon').Schema
|
|
41
|
+
Schemas.Polyline = require('./models/Polyline').Schema
|
|
42
42
|
Schemas.Project = require('./models/Project').Schema
|
|
43
43
|
Schemas.RuleRequestAggregation = require('./models/RuleRequestAggregation').Schema
|
|
44
44
|
Schemas.SpeedFilter = require('./models/SpeedFilter').Schema
|
|
@@ -2,7 +2,7 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
mongoose.Promise = global.Promise
|
|
3
3
|
|
|
4
4
|
const BearingFilterModel = require('../../../Models').BearingFilter(mongoose)
|
|
5
|
-
const { isMinimumNinetyApart } = require('
|
|
5
|
+
const { isMinimumNinetyApart } = require.main.require('models/BearingFilter')
|
|
6
6
|
const describe = require('mocha').describe
|
|
7
7
|
const it = require('mocha').it
|
|
8
8
|
const chai = require('chai')
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
2
|
-
const patcher = require('mongoose-json-patch')
|
|
3
1
|
const mongoose = require('mongoose')
|
|
2
|
+
const StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
+
const Point = require('../schemas/Point')
|
|
4
|
+
const PointGeometry = require('../schemas/PointGeometry')
|
|
4
5
|
const uuidv4 = require('uuid/v4')
|
|
5
|
-
const
|
|
6
|
-
const mongooseHidden = require('
|
|
7
|
-
const Point = require('../../schemas/Point')
|
|
6
|
+
const patcher = require('mongoose-json-patch')
|
|
7
|
+
const mongooseHidden = require('../utils/mongooseHidden')
|
|
8
8
|
|
|
9
9
|
let schema = {
|
|
10
10
|
_id: {type: String, default: uuidv4},
|
|
@@ -80,7 +80,7 @@ function validateBeaconType (v, magicCallback) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// optional mongoose
|
|
83
|
-
let
|
|
83
|
+
let model = (mongooseInstance) => {
|
|
84
84
|
const instance = mongooseInstance || mongoose
|
|
85
85
|
let Beacon = instance.model('Beacon', BeaconSchema)
|
|
86
86
|
|
|
@@ -90,6 +90,5 @@ let BeaconModel = (mongooseInstance) => {
|
|
|
90
90
|
|
|
91
91
|
return Beacon
|
|
92
92
|
}
|
|
93
|
-
|
|
94
93
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
95
|
-
module.exports = { Model:
|
|
94
|
+
module.exports = { Model: model, Schema: BeaconSchema, beaconSchema: schema }
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
2
1
|
let mongoose = require('mongoose')
|
|
2
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
3
|
let uuidv4 = require('uuid/v4')
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const mongooseHidden = require('../../utils/mongooseHidden')
|
|
4
|
+
let Point = require('../schemas/Point')
|
|
5
|
+
let PolygonGeometry = require('../schemas/PolygonGeometry')
|
|
7
6
|
|
|
8
7
|
const schema = {
|
|
9
8
|
_id: {type: String, default: uuidv4},
|
|
@@ -17,30 +16,28 @@ const schema = {
|
|
|
17
16
|
state: {type: String, default: StateEnum.active, select: false}
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const BoundingBoxSchema = new mongoose.Schema(
|
|
20
|
+
schema,
|
|
21
|
+
{
|
|
22
|
+
_id: false,
|
|
23
|
+
versionKey: false
|
|
24
|
+
})
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type: {type: String, required: true}
|
|
26
|
+
BoundingBoxSchema.add({
|
|
27
|
+
type:
|
|
28
|
+
{type: String, required: true}
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
-
boundingBoxSchema.plugin(mongooseHidden)
|
|
32
|
-
|
|
33
|
-
|
|
34
31
|
// optional mongoose
|
|
35
32
|
let model = (mongooseInstance) => {
|
|
36
33
|
let BoundingBox
|
|
37
34
|
if (mongooseInstance) {
|
|
38
|
-
BoundingBox = mongooseInstance.model('BoundingBox',
|
|
35
|
+
BoundingBox = mongooseInstance.model('BoundingBox', BoundingBoxSchema)
|
|
39
36
|
} else {
|
|
40
|
-
BoundingBox = mongoose.model('BoundingBox',
|
|
37
|
+
BoundingBox = mongoose.model('BoundingBox', BoundingBoxSchema)
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
return BoundingBox
|
|
44
41
|
}
|
|
45
42
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
46
|
-
module.exports = { Model: model, Schema:
|
|
43
|
+
module.exports = { Model: model, Schema: BoundingBoxSchema, boundingBoxSchema: schema }
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
+
let Point = require('../schemas/Point')
|
|
3
4
|
let uuidv4 = require('uuid/v4')
|
|
4
|
-
|
|
5
|
-
const mongooseHidden = require('../../utils/mongooseHidden')
|
|
6
|
-
const Point = require('../../schemas/Point')
|
|
5
|
+
let PolygonGeometry = require('../schemas/PolygonGeometry')
|
|
7
6
|
|
|
8
7
|
let schema = {
|
|
9
8
|
_id: {type: String, default: uuidv4},
|
|
@@ -17,31 +16,28 @@ let schema = {
|
|
|
17
16
|
state: {type: String, default: StateEnum.active, select: false}
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
let
|
|
19
|
+
let CircleSchema = new mongoose.Schema(
|
|
21
20
|
schema,
|
|
22
21
|
{
|
|
23
22
|
_id: false,
|
|
24
23
|
__v: false
|
|
25
24
|
})
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type: {type: String, required: true}
|
|
26
|
+
CircleSchema.add({
|
|
27
|
+
type:
|
|
28
|
+
{type: String, required: true}
|
|
31
29
|
})
|
|
32
30
|
|
|
33
|
-
circleSchema.plugin(mongooseHidden)
|
|
34
|
-
|
|
35
31
|
// optional mongoose
|
|
36
32
|
let model = (mongooseInstance) => {
|
|
37
33
|
let Circle
|
|
38
34
|
if (mongooseInstance) {
|
|
39
|
-
Circle = mongooseInstance.model('Circle',
|
|
35
|
+
Circle = mongooseInstance.model('Circle', CircleSchema)
|
|
40
36
|
} else {
|
|
41
|
-
Circle = mongoose.model('Circle',
|
|
37
|
+
Circle = mongoose.model('Circle', CircleSchema)
|
|
42
38
|
}
|
|
43
39
|
|
|
44
40
|
return Circle
|
|
45
41
|
}
|
|
46
42
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
47
|
-
module.exports = { Model: model, Schema:
|
|
43
|
+
module.exports = { Model: model, Schema: CircleSchema, circleSchema: schema }
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
-
|
|
4
|
-
const Point = require('../../schemas/Point')
|
|
3
|
+
let Point = require('../schemas/Point')
|
|
5
4
|
let uuidv4 = require('uuid/v4')
|
|
6
5
|
|
|
7
6
|
const schema = {
|
|
@@ -14,31 +13,28 @@ const schema = {
|
|
|
14
13
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
15
14
|
state: {type: String, default: StateEnum.active, select: false}
|
|
16
15
|
}
|
|
17
|
-
const
|
|
16
|
+
const PolygonSchema = new mongoose.Schema(
|
|
18
17
|
schema,
|
|
19
18
|
{
|
|
20
19
|
_id: false,
|
|
21
20
|
versionKey: false
|
|
22
21
|
})
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
PolygonSchema.add({
|
|
25
24
|
type:
|
|
26
25
|
{type: String, required: true}
|
|
27
26
|
})
|
|
28
27
|
|
|
29
|
-
polygonSchema.plugin(mongooseHidden)
|
|
30
|
-
|
|
31
|
-
|
|
32
28
|
// optional mongoose
|
|
33
29
|
let model = (mongooseInstance) => {
|
|
34
30
|
let Polygon
|
|
35
31
|
if (mongooseInstance) {
|
|
36
|
-
Polygon = mongooseInstance.model('Polygon',
|
|
32
|
+
Polygon = mongooseInstance.model('Polygon', PolygonSchema)
|
|
37
33
|
} else {
|
|
38
|
-
Polygon = mongoose.model('Polygon',
|
|
34
|
+
Polygon = mongoose.model('Polygon', PolygonSchema)
|
|
39
35
|
}
|
|
40
36
|
|
|
41
37
|
return Polygon
|
|
42
38
|
}
|
|
43
39
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
44
|
-
module.exports = { Model: model, Schema:
|
|
40
|
+
module.exports = { Model: model, Schema: PolygonSchema, polygonSchema: schema }
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
-
|
|
3
|
+
let Point = require('../schemas/Point')
|
|
4
4
|
let uuidv4 = require('uuid/v4')
|
|
5
|
-
|
|
6
|
-
const mongooseHidden = require('../../utils/mongooseHidden')
|
|
5
|
+
let MultiLineStringGeometry = require('../schemas/MultiLineStringGeometry')
|
|
7
6
|
|
|
8
7
|
const schema = {
|
|
9
8
|
_id: {type: String, default: uuidv4},
|
|
@@ -15,29 +14,28 @@ const schema = {
|
|
|
15
14
|
state: {type: String, default: StateEnum.active, select: false}
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const PolylineSchema = new mongoose.Schema(
|
|
18
|
+
schema,
|
|
19
|
+
{
|
|
20
|
+
_id: false,
|
|
21
|
+
versionKey: false
|
|
22
|
+
})
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
type: {type: String, required: true}
|
|
24
|
+
PolylineSchema.add({
|
|
25
|
+
type:
|
|
26
|
+
{type: String, required: true}
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
polylineSchema.plugin(mongooseHidden)
|
|
30
|
-
|
|
31
29
|
// optional mongoose
|
|
32
30
|
let model = (mongooseInstance) => {
|
|
33
31
|
let Polyline
|
|
34
32
|
if (mongooseInstance) {
|
|
35
|
-
Polyline = mongooseInstance.model('Polyline',
|
|
33
|
+
Polyline = mongooseInstance.model('Polyline', PolylineSchema)
|
|
36
34
|
} else {
|
|
37
|
-
Polyline = mongoose.model('Polyline',
|
|
35
|
+
Polyline = mongoose.model('Polyline', PolylineSchema)
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
return Polyline
|
|
41
39
|
}
|
|
42
40
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
43
|
-
module.exports = { Model: model, Schema:
|
|
41
|
+
module.exports = { Model: model, Schema: PolylineSchema, polylineSchema: schema }
|
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('./
|
|
13
|
-
let boundingBoxSchema = require('./
|
|
14
|
-
let polylineSchema = require('./
|
|
15
|
-
let polygonSchema = require('./
|
|
16
|
-
let beaconSchema = require('./
|
|
12
|
+
let circleSchema = require('./Circle').circleSchema
|
|
13
|
+
let boundingBoxSchema = require('./BoundingBox').boundingBoxSchema
|
|
14
|
+
let polylineSchema = require('./Polyline').polylineSchema
|
|
15
|
+
let polygonSchema = require('./Polygon').polygonSchema
|
|
16
|
+
let beaconSchema = require('./ZoneBeacon').beaconSchema
|
|
17
17
|
let speedFilterSchema = require('./SpeedFilter').speedFilterSchema
|
|
18
18
|
let bearingFilterSchema = require('./BearingFilter').bearingFilterSchema
|
|
19
19
|
let timeOfDayRangeFilterSchema = require('./TimeOfDayRangeFilter').timeOfDayRangeFilterSchema
|
|
@@ -84,10 +84,10 @@ zoneSchema.path('filters').discriminator('speed', new Schema(speedFilterSchema))
|
|
|
84
84
|
zoneSchema.path('filters').discriminator('timeOfDayRange', new Schema(timeOfDayRangeFilterSchema))
|
|
85
85
|
|
|
86
86
|
zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema).plugin(mongooseHidden))
|
|
87
|
-
zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema).plugin(mongooseHidden))
|
|
88
87
|
zoneSchema.path('geofeatures').discriminator('circle', new Schema(circleSchema).plugin(mongooseHidden))
|
|
89
88
|
zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema).plugin(mongooseHidden))
|
|
90
89
|
zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema).plugin(mongooseHidden))
|
|
90
|
+
zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema).plugin(mongooseHidden))
|
|
91
91
|
|
|
92
92
|
// optional mongoose
|
|
93
93
|
const model = (mongooseInstance) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const cloneDeep = require('lodash.clonedeep')
|
|
2
2
|
const mongoose = require('mongoose')
|
|
3
|
-
const beaconSchema = require('./Beacon').
|
|
3
|
+
const beaconSchema = require('./Beacon').beaconSchema
|
|
4
4
|
const BeaconEnum = require('@bluedot-innovation/enums').BeaconEnum
|
|
5
5
|
|
|
6
6
|
const schema = cloneDeep(beaconSchema)
|
|
@@ -11,17 +11,13 @@ schema.proximity = {
|
|
|
11
11
|
enum: [BeaconEnum.NEAR, BeaconEnum.FAR]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
zoneBeaconSchema.add({
|
|
17
|
-
type: {type: String, required: true}
|
|
18
|
-
})
|
|
14
|
+
const ZoneBeaconSchema = new mongoose.Schema(schema)
|
|
19
15
|
|
|
20
16
|
// optional mongoose
|
|
21
|
-
let
|
|
17
|
+
let model = (mongooseInstance) => {
|
|
22
18
|
const instance = mongooseInstance || mongoose
|
|
23
|
-
return instance.model('ZoneBeacon',
|
|
19
|
+
return instance.model('ZoneBeacon', ZoneBeaconSchema)
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
27
|
-
module.exports = { Model:
|
|
23
|
+
module.exports = { Model: model, Schema: ZoneBeaconSchema, beaconSchema: schema }
|
package/package.json
CHANGED