@bluedot-innovation/models 2.0.9-alpha.1 → 2.0.10-alpha.2
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/CHANGELOG.md +5 -0
- package/models/Account.js +1 -0
- package/models/Beacon.js +16 -11
- package/models/BearingFilter.js +4 -7
- package/models/Project.js +1 -0
- package/models/Zone.js +1 -1
- package/models/ZoneBeacon.js +3 -2
- package/package.json +2 -3
- package/models/Fence.js +0 -20
- package/models/GeoFence.js +0 -21
- package/models/Geofeature.js +0 -24
package/CHANGELOG.md
CHANGED
package/models/Account.js
CHANGED
|
@@ -12,6 +12,7 @@ const helpers = require('../helpers')
|
|
|
12
12
|
|
|
13
13
|
let AccountSchema = new mongoose.Schema({
|
|
14
14
|
_id: {type: String, default: uuidv4},
|
|
15
|
+
customerApiKey: {type: String, default: uuidv4}, // Backwards compatability
|
|
15
16
|
name: {type: String, required: true},
|
|
16
17
|
createdBy: {
|
|
17
18
|
// type: Schema.Types.ObjectId,
|
package/models/Beacon.js
CHANGED
|
@@ -7,7 +7,6 @@ let patcher = require('mongoose-json-patch')
|
|
|
7
7
|
|
|
8
8
|
let schema = {
|
|
9
9
|
_id: {type: String, default: uuidv4},
|
|
10
|
-
geometry: {type: PointGeometry},
|
|
11
10
|
name: {type: String, required: [true, 'name is required.']},
|
|
12
11
|
description: {type: String, default: ''},
|
|
13
12
|
creationTime: {type: Date, default: Date.now},
|
|
@@ -23,9 +22,8 @@ let schema = {
|
|
|
23
22
|
}
|
|
24
23
|
},
|
|
25
24
|
location: {type: Point, required: true},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
25
|
+
geometry: {type: PointGeometry},
|
|
26
|
+
accountId: {type: String, required: true},
|
|
29
27
|
// These must be unique
|
|
30
28
|
major: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Major needs to be within range(1-65535)'}]},
|
|
31
29
|
minor: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Minor needs to be within range(1-65535)'}]},
|
|
@@ -34,7 +32,14 @@ let schema = {
|
|
|
34
32
|
proximityUUID: {type: String}
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
let BeaconSchema = new mongoose.Schema(schema, {collection: 'beacon'})
|
|
35
|
+
let BeaconSchema = new mongoose.Schema(schema, {collection: 'beacon', autoIndex: false})
|
|
36
|
+
|
|
37
|
+
BeaconSchema.index({ macAddress: 1 })
|
|
38
|
+
BeaconSchema.index({ proximityUUID: 1, major: 1, minor: 1 })
|
|
39
|
+
BeaconSchema.index({ accountId: 1, geometry: '2dsphere' })
|
|
40
|
+
|
|
41
|
+
// accountId: 1, geometry: "2dsphere"
|
|
42
|
+
|
|
38
43
|
BeaconSchema.plugin(patcher)
|
|
39
44
|
|
|
40
45
|
// mongoose validator helper plugin
|
|
@@ -74,12 +79,12 @@ function validateBeaconType (v, magicCallback) {
|
|
|
74
79
|
|
|
75
80
|
// optional mongoose
|
|
76
81
|
let model = (mongooseInstance) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
82
|
+
const instance = mongooseInstance || mongoose
|
|
83
|
+
let Beacon = instance.model('Beacon', BeaconSchema)
|
|
84
|
+
|
|
85
|
+
Beacon.on('index', function (error) {
|
|
86
|
+
console.log(error.message)
|
|
87
|
+
})
|
|
83
88
|
|
|
84
89
|
return Beacon
|
|
85
90
|
}
|
package/models/BearingFilter.js
CHANGED
|
@@ -7,15 +7,12 @@ const schema = {
|
|
|
7
7
|
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {isAsync: true, validator: validateAngles, msg: 'default error message'}}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const BearingFilterSchema = new mongoose.Schema(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
versionKey: false
|
|
14
|
-
})
|
|
10
|
+
const BearingFilterSchema = new mongoose.Schema(schema, {
|
|
11
|
+
versionKey: false
|
|
12
|
+
})
|
|
15
13
|
|
|
16
14
|
BearingFilterSchema.add({
|
|
17
|
-
type:
|
|
18
|
-
{type: String, required: true}
|
|
15
|
+
type: {type: String, required: true}
|
|
19
16
|
})
|
|
20
17
|
|
|
21
18
|
function validateAngles (toAngle, magicCallback) {
|
package/models/Project.js
CHANGED
|
@@ -15,6 +15,7 @@ let WebhookSchema = require('../schemas/Webhook')
|
|
|
15
15
|
|
|
16
16
|
let ProjectSchema = new mongoose.Schema({
|
|
17
17
|
_id: {type: String, default: uuidv4},
|
|
18
|
+
apiKey: {type: String, default: uuidv4}, // Backwards compatability
|
|
18
19
|
state: {type: String, default: StateEnum.active},
|
|
19
20
|
nextRuleUpdateInterval: {
|
|
20
21
|
type: Number,
|
package/models/Zone.js
CHANGED
package/models/ZoneBeacon.js
CHANGED
|
@@ -14,8 +14,9 @@ schema.proximity = {
|
|
|
14
14
|
const ZoneBeaconSchema = new mongoose.Schema(schema)
|
|
15
15
|
|
|
16
16
|
// optional mongoose
|
|
17
|
-
let model = (mongooseInstance
|
|
18
|
-
|
|
17
|
+
let model = (mongooseInstance) => {
|
|
18
|
+
const instance = mongooseInstance || mongoose
|
|
19
|
+
return instance.model('ZoneBeacon', ZoneBeaconSchema)
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluedot-innovation/models",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "Models.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,13 +22,12 @@
|
|
|
22
22
|
"eslint-plugin-promise": "^3.6.0",
|
|
23
23
|
"eslint-plugin-standard": "^3.0.1",
|
|
24
24
|
"mocha": "^4.0.1",
|
|
25
|
-
"mockgoose": "^7.3.3",
|
|
26
25
|
"nyc": "^11.3.0",
|
|
27
26
|
"sinon": "^4.1.2"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
29
|
"@bluedot-innovation/enums": "2.0.2",
|
|
31
|
-
"lodash.clonedeep": "
|
|
30
|
+
"lodash.clonedeep": "4.5.0",
|
|
32
31
|
"mongoose": "^4.13.9",
|
|
33
32
|
"mongoose-error-helper": "0.0.2",
|
|
34
33
|
"mongoose-json-patch": "^1.1.1",
|
package/models/Fence.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Arun on 10/09/2014.
|
|
3
|
-
* Copyright : Bluedot Innovations.
|
|
4
|
-
* Owner :
|
|
5
|
-
*/
|
|
6
|
-
let mongoose = require('mongoose')
|
|
7
|
-
const Schema = mongoose.Schema
|
|
8
|
-
|
|
9
|
-
let FenceSchema = new mongoose.Schema({
|
|
10
|
-
'_id': {type: String},
|
|
11
|
-
'creationTime': {type: Date, default: Date.now},
|
|
12
|
-
'lastUpdateTime': {type: Date, default: Date.now},
|
|
13
|
-
'type': {type: String, default: 'Feature'},
|
|
14
|
-
'dataSource': {type: String, select: false, default: 'openApi'},
|
|
15
|
-
'geometry': {type: Schema.Types.Mixed, default: {}}
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
let Fence = mongoose.model('Fence', FenceSchema)
|
|
19
|
-
|
|
20
|
-
module.exports = Fence
|
package/models/GeoFence.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Arun on 10/09/2014.
|
|
3
|
-
* Copyright : Bluedot Innovations.
|
|
4
|
-
* Owner :
|
|
5
|
-
*/
|
|
6
|
-
let mongoose = require('mongoose')
|
|
7
|
-
|
|
8
|
-
let FenceSchema = new mongoose.Schema({
|
|
9
|
-
_id: {type: String},
|
|
10
|
-
'geometry': {
|
|
11
|
-
'type': { type: String, required: true },
|
|
12
|
-
'coordinates': {type: Array, required: true}
|
|
13
|
-
},
|
|
14
|
-
'fenceId': String,
|
|
15
|
-
'fenceName': String
|
|
16
|
-
},
|
|
17
|
-
{collection: 'GeoFence'})
|
|
18
|
-
|
|
19
|
-
let GeoFence = mongoose.model('GeoFence', FenceSchema)
|
|
20
|
-
|
|
21
|
-
module.exports = GeoFence
|
package/models/Geofeature.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Andrew on 7/06/2016.
|
|
3
|
-
* Copyright : Bluedot Innovations.
|
|
4
|
-
* Owner :
|
|
5
|
-
*/
|
|
6
|
-
let mongoose = require('mongoose')
|
|
7
|
-
let Schema = mongoose.Schema
|
|
8
|
-
|
|
9
|
-
let GeofeatureSchema = new Schema({
|
|
10
|
-
geometry: Schema.Types.Mixed,
|
|
11
|
-
referenceId: String,
|
|
12
|
-
apiKey: String,
|
|
13
|
-
zoneId: String,
|
|
14
|
-
type: String,
|
|
15
|
-
name: String,
|
|
16
|
-
beaconType: String,
|
|
17
|
-
creationTime: {type: Date, default: Date.now},
|
|
18
|
-
lastUpdateTime: {type: Date, default: Date.now}
|
|
19
|
-
},
|
|
20
|
-
{ collection: 'geofeature' })
|
|
21
|
-
|
|
22
|
-
let Geofeature = mongoose.model('Geofeature', GeofeatureSchema)
|
|
23
|
-
|
|
24
|
-
module.exports = Geofeature
|