@bluedot-innovation/models 2.0.5-alpha.1 → 2.0.5-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/models/Beacon.js +0 -12
- package/models/Zone.js +1 -2
- package/models/ZoneBeacon.js +15 -9
- package/package.json +2 -2
package/models/Beacon.js
CHANGED
|
@@ -47,18 +47,6 @@ function validateMajorMinor (v) {
|
|
|
47
47
|
return v >= 1 && v <= 65535
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function validateLatitude (longitude) {
|
|
51
|
-
'use strict'
|
|
52
|
-
let regex = new RegExp(/^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?)$/gi)
|
|
53
|
-
return regex.test(longitude)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function validateLongitude (latitude) {
|
|
57
|
-
'use strict'
|
|
58
|
-
let regex = new RegExp(/^[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/gi)
|
|
59
|
-
return regex.test(latitude)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
50
|
function validateBeaconType (v, cb) {
|
|
63
51
|
'use strict'
|
|
64
52
|
let magicCallback = cb
|
package/models/Zone.js
CHANGED
|
@@ -13,8 +13,7 @@ let circleSchema = require('./Circle').circleSchema
|
|
|
13
13
|
let boundingBoxSchema = require('./BoundingBox').boundingBoxSchema
|
|
14
14
|
let polylineSchema = require('./Polyline').polylineSchema
|
|
15
15
|
let polygonSchema = require('./Polygon').polygonSchema
|
|
16
|
-
|
|
17
|
-
let beaconSchema = require('./ZoneBeacon').Schema.obj
|
|
16
|
+
let beaconSchema = require('./ZoneBeacon').beaconSchema
|
|
18
17
|
let speedFilterSchema = require('./SpeedFilter').speedFilterSchema
|
|
19
18
|
let bearingFilterSchema = require('./BearingFilter').bearingFilterSchema
|
|
20
19
|
let timeOfDayRangeFilterSchema = require('./TimeOfDayRangeFilter').timeOfDayRangeFilterSchema
|
package/models/ZoneBeacon.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const mongoose = require('mongoose')
|
|
2
|
+
const beaconSchema = require('./Beacon').beaconSchema
|
|
3
|
+
const BeaconEnum = require('@bluedot-innovation/enums').BeaconEnum
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ZoneBeaconSchema = new mongoose.Schema({
|
|
5
|
+
const schema = {
|
|
6
|
+
...beaconSchema,
|
|
7
7
|
proximity: {type: String, default: 'Far'},
|
|
8
|
-
|
|
9
|
-
}
|
|
8
|
+
enum: [BeaconEnum.NEAR, BeaconEnum.FAR]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ZoneBeaconSchema = new mongoose.Schema(schema)
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
// optional mongoose
|
|
14
|
+
let model = (mongooseInstance = mongoose) => {
|
|
15
|
+
return mongooseInstance.model('ZoneBeacon', ZoneBeaconSchema)
|
|
16
|
+
}
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
19
|
+
module.exports = { Model: model, Schema: ZoneBeaconSchema, beaconSchema: schema }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluedot-innovation/models",
|
|
3
|
-
"version": "2.0.5-alpha.
|
|
3
|
+
"version": "2.0.5-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "Models.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"sinon": "^4.1.2"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@bluedot-innovation/enums": "2.0.
|
|
30
|
+
"@bluedot-innovation/enums": "2.0.2",
|
|
31
31
|
"mongoose": "^4.13.9",
|
|
32
32
|
"mongoose-error-helper": "0.0.2",
|
|
33
33
|
"mongoose-json-patch": "^1.1.1",
|