@bluedot-innovation/models 2.0.0-alpha.14 → 2.0.0-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/Models.js +9 -17
- package/__tests__/zone/checkActions.js +62 -0
- package/__tests__/zone/checkAppId.js +39 -0
- package/__tests__/zone/checkBeacon.js +44 -0
- package/__tests__/zone/checkBearingFitler.js +46 -0
- package/__tests__/zone/checkBoundingBox.js +42 -0
- package/__tests__/zone/checkCalendarDateRangeFilterFitler.js +46 -0
- package/__tests__/zone/checkCircle.js +39 -0
- package/__tests__/zone/checkMRT.js +44 -0
- package/__tests__/zone/checkPercentageCrossedFitler.js +46 -0
- package/__tests__/zone/checkPolygon.js +76 -0
- package/__tests__/zone/checkPolyline.js +76 -0
- package/__tests__/zone/checkSpeedFitler.js +46 -0
- package/__tests__/zone/checkTimeOfDayRangeFitler.js +46 -0
- package/models/AdminPortalUser.js +11 -10
- package/models/AdminUser.js +5 -6
- package/models/Application.js +30 -31
- package/models/Beacon.js +78 -91
- package/models/BeaconFilter.js +12 -27
- package/models/BearingFilter.js +23 -45
- package/models/BoundingBox.js +20 -35
- package/models/CalendarDateRangeFilter.js +19 -33
- package/models/Circle.js +18 -32
- package/models/Contract.js +38 -37
- package/models/Customer.js +31 -31
- package/models/CustomerLogin.js +10 -9
- package/models/DBEvent.js +14 -13
- package/models/DeviceRulesRequest.js +28 -27
- package/models/Fence.js +13 -12
- package/models/GeoFence.js +14 -12
- package/models/Geofeature.js +18 -16
- package/models/MessageAction.js +16 -30
- package/models/NotificationLogEntry.js +8 -7
- package/models/POILocation.js +7 -6
- package/models/POILookup.js +9 -8
- package/models/POIResult.js +8 -7
- package/models/PartnerCustomer.js +13 -12
- package/models/PartnerPasswordReset.js +9 -8
- package/models/PartnerUser.js +11 -10
- package/models/Partners.js +12 -11
- package/models/PercentageCrossedFilter.js +15 -29
- package/models/Polygon.js +19 -33
- package/models/Polyline.js +19 -34
- package/models/RuleRequestAggregation.js +15 -14
- package/models/SimpleCheckInZone.js +21 -21
- package/models/SingleUseToken.js +8 -7
- package/models/SpeedFilter.js +19 -38
- package/models/TestDevice.js +12 -11
- package/models/TestDeviceCluster.js +10 -9
- package/models/TestInstance.js +10 -9
- package/models/TestScenario.js +10 -9
- package/models/TimeOfDayRange.js +16 -16
- package/models/TimeOfDayRangeFilter.js +18 -34
- package/models/URLAction.js +34 -0
- package/models/Zone.js +274 -84
- package/models/ZoneUIState.js +18 -18
- package/package.json +8 -20
- package/schemas/Point.js +13 -10
- package/.eslintrc.js +0 -6
- package/.gitlab-ci.yml +0 -43
- package/.nyc_output/.gitkeep +0 -0
- package/.nyc_output/80d8f626b96df8cb4eed63e325b8b3c9.json +0 -1
- package/.nyc_output/84b3fbae4d070660e06ae55f15306158.json +0 -1
- package/README.MD +0 -36
- package/__tests__/action/message/messageAction.data.json +0 -5
- package/__tests__/action/message/messageAction.rules.json +0 -3
- package/__tests__/action/message/messageAction.spec.js +0 -61
- package/__tests__/action/url/urlAction.data.json +0 -4
- package/__tests__/action/url/urlAction.rules.json +0 -3
- package/__tests__/action/url/urlAction.spec.js +0 -62
- package/__tests__/dailyStats/checkDailyStats.js +0 -30
- package/__tests__/filter/beacon/beaconFilter.data.json +0 -1
- package/__tests__/filter/beacon/beaconFilter.rules.json +0 -3
- package/__tests__/filter/beacon/beaconFilter.spec.js +0 -1
- package/__tests__/filter/bearing/bearingFilter.data.json +0 -5
- package/__tests__/filter/bearing/bearingFilter.rules.json +0 -3
- package/__tests__/filter/bearing/bearingFilter.spec.js +0 -95
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.data.json +0 -5
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.rules.json +0 -3
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.spec.js +0 -62
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.data.json +0 -5
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.rules.json +0 -3
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.spec.js +0 -62
- package/__tests__/filter/speed/speedFilter.data.json +0 -5
- package/__tests__/filter/speed/speedFilter.rules.json +0 -3
- package/__tests__/filter/speed/speedFilter.spec.js +0 -73
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.data.json +0 -5
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.rules.json +0 -3
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.spec.js +0 -73
- package/__tests__/geofeature/beacon/beacon.data.json +0 -12
- package/__tests__/geofeature/beacon/beacon.rules.json +0 -13
- package/__tests__/geofeature/beacon/beacon.spec.js +0 -95
- package/__tests__/geofeature/boundingBox/boundingBox.data.json +0 -12
- package/__tests__/geofeature/boundingBox/boundingBox.rules.json +0 -3
- package/__tests__/geofeature/boundingBox/boundingBox.spec.js +0 -61
- package/__tests__/geofeature/circle/circle.data.json +0 -9
- package/__tests__/geofeature/circle/circle.rules.json +0 -3
- package/__tests__/geofeature/circle/circle.spec.js +0 -62
- package/__tests__/geofeature/polygon/polygon.data.json +0 -46
- package/__tests__/geofeature/polygon/polygon.rules.json +0 -3
- package/__tests__/geofeature/polygon/polygon.spec.js +0 -61
- package/__tests__/geofeature/polyline/polyline.data.json +0 -46
- package/__tests__/geofeature/polyline/polyline.rules.json +0 -3
- package/__tests__/geofeature/polyline/polyline.spec.js +0 -61
- package/__tests__/zone/zone.action.spec.js +0 -50
- package/__tests__/zone/zone.data.json +0 -154
- package/__tests__/zone/zone.filter.spec.js +0 -50
- package/__tests__/zone/zone.geofeatures.spec.js +0 -74
- package/__tests__/zone/zone.spec.js +0 -98
- package/models/DailyStats.js +0 -28
- package/models/UrlAction.js +0 -52
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
let assert = require('assert');
|
|
2
|
+
let Zone = require('../../models/Zone');
|
|
3
|
+
|
|
4
|
+
let zone = {
|
|
5
|
+
"name": "TDD zone",
|
|
6
|
+
"minimumRetriggerTime": "60",
|
|
7
|
+
"checkout": true,
|
|
8
|
+
"applicationId": 'c7058934-f1e6-4176-8730-a0bd28e8e0a9',
|
|
9
|
+
"filter": [
|
|
10
|
+
{
|
|
11
|
+
"type" : "timeOfDayRange",
|
|
12
|
+
"fromTime" : 112,
|
|
13
|
+
"toTime" : 552
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"actions": [],
|
|
17
|
+
"geofeatures": [{
|
|
18
|
+
"type":"circle",
|
|
19
|
+
"name":"circle with 15m radius",
|
|
20
|
+
"center": {
|
|
21
|
+
"latitude": -37.8186454,
|
|
22
|
+
"longitude": 144.979882
|
|
23
|
+
},
|
|
24
|
+
"radius": 15
|
|
25
|
+
}]
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
describe('Creating Zone ', () => {
|
|
29
|
+
it('validate TimeOfDayRangeFilter', (done) => {
|
|
30
|
+
|
|
31
|
+
let createZone = new Zone(zone);
|
|
32
|
+
createZone.validate()
|
|
33
|
+
.then((output) => {
|
|
34
|
+
console.log("validate TimeOfDayRangeFilter: ");
|
|
35
|
+
assert(true);
|
|
36
|
+
done();
|
|
37
|
+
}).catch(err => {
|
|
38
|
+
console.log("Errors found:");
|
|
39
|
+
for( let key of Object.keys(err.errors) ) {
|
|
40
|
+
console.log(err.errors[key].message);
|
|
41
|
+
}
|
|
42
|
+
assert(false);
|
|
43
|
+
done(err);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
* Copyright : Bluedot Innovations.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var mongoose = require('mongoose');
|
|
6
|
+
var Enums = require('@bluedot-innovation/enums');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
var AdminPortalUser = mongoose.model('AdminPortalUser', new mongoose.Schema(
|
|
9
9
|
{
|
|
10
10
|
emailAddress: String,
|
|
11
11
|
password: String,
|
|
12
12
|
firstName: String,
|
|
13
13
|
lastName: String,
|
|
14
|
-
state: {type:
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
state: {type:String, default: Enums.StateEnum.active},
|
|
15
|
+
"creationTime" : {type: Date, default: Date.now},
|
|
16
|
+
"dataSource" : {type:String, select: false, default : 'AdminPortal'},
|
|
17
17
|
adminId: String,
|
|
18
18
|
secret: String
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
collection: 'adminPortalUser'
|
|
22
|
-
}
|
|
23
|
-
)
|
|
21
|
+
collection : 'adminPortalUser'
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
);
|
|
24
25
|
|
|
25
|
-
module.exports = AdminPortalUser
|
|
26
|
+
module.exports = AdminPortalUser;
|
package/models/AdminUser.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
{ collection: 'AdminUser' }
|
|
9
|
-
))
|
|
10
|
-
|
|
11
|
-
module.exports = AdminUser
|
|
6
|
+
var mongoose = require('mongoose');
|
|
7
|
+
var AdminUser = mongoose.model('AdminUser', new mongoose.Schema({},
|
|
8
|
+
{ collection : 'AdminUser' }
|
|
9
|
+
));
|
|
10
|
+
module.exports = AdminUser;
|
package/models/Application.js
CHANGED
|
@@ -3,37 +3,36 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
+
var mongoose = require('mongoose');
|
|
7
|
+
var Enums = require('@bluedot-innovation/enums');
|
|
8
|
+
Schema = mongoose.Schema;
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
enabled: Boolean,
|
|
31
|
-
params: {}
|
|
10
|
+
var ApplicationSchema = new mongoose.Schema({
|
|
11
|
+
_id : {type: String},
|
|
12
|
+
_class : {type: String, default:"au.com.bluedot.application.model.client.Application"},
|
|
13
|
+
state : {type: String, default : Enums.StateEnum.active, select: false},
|
|
14
|
+
nextRuleUpdateInterval: {type: Number, select: false},
|
|
15
|
+
nextRuleUpdateIntervalFormatted: {type:String, required: true},
|
|
16
|
+
lastUpdateTime: {type: Date, select: false},
|
|
17
|
+
creationTime: {type: Date, select: false},
|
|
18
|
+
"administrator" : {type: String, select: false},
|
|
19
|
+
enableDataAnonymisation: {type: Boolean, select: false},
|
|
20
|
+
apiKey: String,
|
|
21
|
+
dataSource: {type:String, select: false, default : 'openApi'},
|
|
22
|
+
name: {type: String},
|
|
23
|
+
packageName: {type: String},
|
|
24
|
+
customerId : String,
|
|
25
|
+
firebaseApiKey: String,
|
|
26
|
+
lastPushSync: Date,
|
|
27
|
+
webhook : {
|
|
28
|
+
url: String,
|
|
29
|
+
enabled: Boolean,
|
|
30
|
+
params: {}
|
|
31
|
+
},
|
|
32
|
+
configurationParameters:{type: Schema.Types.Mixed, default: null}
|
|
32
33
|
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let Application = mongoose.model('Application', ApplicationSchema)
|
|
34
|
+
{ collection : 'application' }
|
|
35
|
+
);
|
|
36
|
+
var Application = mongoose.model('Application', ApplicationSchema);
|
|
38
37
|
|
|
39
|
-
module.exports = Application
|
|
38
|
+
module.exports = Application;
|
package/models/Beacon.js
CHANGED
|
@@ -1,106 +1,93 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let StateEnum
|
|
3
|
-
let
|
|
4
|
-
let
|
|
1
|
+
let mongoose = require('mongoose');
|
|
2
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum;
|
|
3
|
+
let uuidv4 = require('uuid/v4');
|
|
4
|
+
let Point = require('../schemas/Point');
|
|
5
5
|
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type:
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
let BeaconSchema = new mongoose.Schema({
|
|
7
|
+
guid : { type: String, default: uuidv4 },
|
|
8
|
+
type : { type: String },
|
|
9
|
+
name : { type: String, required: [true, 'name is required. '] },
|
|
10
|
+
description : { type: String, default: '' },
|
|
11
|
+
creationTime : { type: Date, default: Date.now },
|
|
12
|
+
lastUpdateTime : { type: Date, default: Date.now },
|
|
13
|
+
state : { type: String, default : StateEnum.active, select: false },
|
|
14
|
+
major : { type: Number },
|
|
15
|
+
minor : { type: Number },
|
|
16
|
+
txPower : { type: Number, default: 1 },
|
|
17
|
+
macAddress : { type: String },
|
|
18
|
+
proximityUUID : { type: String },
|
|
19
|
+
beaconType : { type: String },
|
|
20
|
+
location : { type: Point },
|
|
21
|
+
proximity : { type: String, default: 'Far', validate: validateBeacons }
|
|
13
22
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
description: {type: String, default: ''},
|
|
20
|
-
lastUpdateTime: {type: Date},
|
|
21
|
-
state: {type: String, default: StateEnum.active},
|
|
22
|
-
major: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Major needs to be within range(1-65535)'}]},
|
|
23
|
-
minor: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Minor needs to be within range(1-65535)'}]},
|
|
24
|
-
txPower: {type: Number},
|
|
25
|
-
macAddress: {type: String},
|
|
26
|
-
proximityUUID: {type: String},
|
|
27
|
-
beaconType: {
|
|
28
|
-
type: String,
|
|
29
|
-
required: true,
|
|
30
|
-
validate: {
|
|
31
|
-
isAsync: true,
|
|
32
|
-
validator: validateBeaconType,
|
|
33
|
-
msg: 'Async validation. Not used'
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
location: {type: Point},
|
|
37
|
-
proximity: {type: String, default: 'Far'}
|
|
38
|
-
}
|
|
23
|
+
{
|
|
24
|
+
_id : false,
|
|
25
|
+
versionKey : false
|
|
26
|
+
}
|
|
27
|
+
);
|
|
39
28
|
|
|
40
|
-
|
|
29
|
+
function validateBeacons() {
|
|
30
|
+
let beaconType = this.beaconType;
|
|
31
|
+
let major = this.major;
|
|
32
|
+
let minor = this.minor;
|
|
33
|
+
let macAddress = this.macAddress;
|
|
34
|
+
let proximityUUID = this.proximityUUID;
|
|
35
|
+
//let proximity = this.proximity;
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
type:
|
|
44
|
-
{type: String, required: true}
|
|
45
|
-
})
|
|
37
|
+
let errorList = '';
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
if(!beaconType) {
|
|
40
|
+
errorList = errorList + "Beacon should have a beaconType field. ";
|
|
41
|
+
} else {
|
|
42
|
+
if(beaconType == 'iOS' || beaconType == 'both') {
|
|
43
|
+
if(!proximityUUID) {
|
|
44
|
+
errorList = errorList + "Beacon should have a proximityUUID field. ";
|
|
45
|
+
}
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
47
|
+
if(!proximityUUID) {
|
|
48
|
+
errorList = errorList + "Beacon should have a proximityUUID field. ";
|
|
49
|
+
} else {
|
|
50
|
+
let proximityRegex = new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$");
|
|
51
|
+
if(!proximityRegex.test(proximityUUID)) {
|
|
52
|
+
errorList = errorList + proximityUUID + ' is not a valid ID.';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
56
|
+
if(!major) {
|
|
57
|
+
errorList = errorList + "Beacon should have a major field. ";
|
|
58
|
+
} else if (major < 0 || major > 65535) {
|
|
59
|
+
errorList = errorList + "Beacon major should be within the range 0 to 65535. ";
|
|
60
|
+
}
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
62
|
+
if(!minor) {
|
|
63
|
+
errorList = errorList + "Beacon should have a minor field. ";
|
|
64
|
+
} else if (minor < 0 || minor > 65535) {
|
|
65
|
+
errorList = errorList + "Beacon minor should be within the range 0 to 65535. ";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
if(beaconType == 'android' || beaconType == 'both') {
|
|
70
|
+
if(!macAddress) {
|
|
71
|
+
errorList = errorList + "Beacon should have macAddress field. ";
|
|
72
|
+
} else {
|
|
73
|
+
let macAddressRegex = new RegExp(/^([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})$/i);
|
|
74
|
+
if(!macAddressRegex.test(macAddress)) {
|
|
75
|
+
errorList = errorList + macAddress + ' is not a valid macAddress. ';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
/*if(proximity != 'Far' && proximity != 'Near' || proximity != 'Immediate'){
|
|
82
|
+
errorList = errorList + "";
|
|
83
|
+
}*/
|
|
83
84
|
|
|
84
|
-
if
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
magicCallback((!!minor && !!major), 'Beacon type `IOS` must have both minor and major values')
|
|
88
|
-
} else if (bothRegex.test(beaconType)) {
|
|
89
|
-
magicCallback((!!minor && !!major && !!txPower && !!macAddress), 'Beacon type `Both` must have all of minor, major, tx power, and mac address values')
|
|
90
|
-
} else {
|
|
91
|
-
magicCallback(true)
|
|
85
|
+
if(errorList != '') {
|
|
86
|
+
console.log(errorList);
|
|
87
|
+
throw new Error(errorList);
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
|
|
96
|
-
module.exports = (mongooseInstance) => {
|
|
97
|
-
let Beacon
|
|
98
|
-
if (mongooseInstance) {
|
|
99
|
-
Beacon = mongooseInstance.model('Beacon', BeaconSchema)
|
|
100
|
-
} else {
|
|
101
|
-
Beacon = mongoose.model('Beacon', BeaconSchema)
|
|
102
|
-
}
|
|
91
|
+
let Beacon = mongoose.model('Beacon', BeaconSchema);
|
|
103
92
|
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
module.exports.beaconSchema = schema
|
|
93
|
+
module.exports = Beacon;
|
package/models/BeaconFilter.js
CHANGED
|
@@ -3,36 +3,21 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
var mongoose = require('mongoose');
|
|
7
|
+
Schema = mongoose.Schema;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let BeaconFilterSchema = new mongoose.Schema(
|
|
16
|
-
schema,
|
|
9
|
+
var BeaconFilterSchema = new mongoose.Schema(
|
|
10
|
+
{
|
|
11
|
+
"_class" : {type:String, default : "au.com.bluedot.application.spring.filter.spatial.BeaconFilter"},
|
|
12
|
+
"beacon" : {},
|
|
13
|
+
"guid" : String,
|
|
14
|
+
"type" : {type:String, default: "beacon"}
|
|
15
|
+
},
|
|
17
16
|
{
|
|
18
17
|
_id: false
|
|
19
18
|
}
|
|
20
|
-
)
|
|
19
|
+
);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
type:
|
|
24
|
-
{type: String, required: true}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
// optional mongoose
|
|
28
|
-
module.exports = (mongooseInstance) => {
|
|
29
|
-
let BeaconFilter
|
|
30
|
-
if (mongooseInstance) {
|
|
31
|
-
BeaconFilter = mongooseInstance.model('BeaconFilter', BeaconFilterSchema)
|
|
32
|
-
} else {
|
|
33
|
-
BeaconFilter = mongoose.model('BeaconFilter', BeaconFilterSchema)
|
|
34
|
-
}
|
|
21
|
+
var BeaconFilter = mongoose.model('BeaconFilter', BeaconFilterSchema);
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
module.exports.beaconFilterSchema = schema
|
|
23
|
+
module.exports = BeaconFilter;
|
package/models/BearingFilter.js
CHANGED
|
@@ -1,58 +1,36 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let uuidv4
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const BearingFilterSchema = new mongoose.Schema(
|
|
11
|
-
schema,
|
|
1
|
+
let mongoose = require('mongoose');
|
|
2
|
+
let uuidv4 = require('uuid/v4');
|
|
3
|
+
|
|
4
|
+
let BearingSchema = new mongoose.Schema({
|
|
5
|
+
guid : { type: String, default: uuidv4 },
|
|
6
|
+
type : { type: String, required: true, default: "bearingFilter" },
|
|
7
|
+
fromAngle : { type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359 },
|
|
8
|
+
toAngle : { type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359, validate: validateAngles }
|
|
9
|
+
},
|
|
12
10
|
{
|
|
13
|
-
_id: false,
|
|
14
|
-
versionKey: false
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
BearingFilterSchema.add({
|
|
18
|
-
type:
|
|
19
|
-
{type: String, required: true}
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
function validateAngles (toAngle, cb) {
|
|
23
|
-
let magicCallback = cb
|
|
24
|
-
let fromAngle = this.fromAngle
|
|
25
|
-
|
|
26
|
-
if (!toAngle && toAngle !== 0) {
|
|
27
|
-
return magicCallback(false, 'toAngle is required')
|
|
11
|
+
_id : false,
|
|
12
|
+
versionKey : false
|
|
28
13
|
}
|
|
14
|
+
);
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
16
|
+
function validateAngles(toAngle){
|
|
17
|
+
let fromAngle = this.fromAngle;
|
|
33
18
|
|
|
34
19
|
if (fromAngle > toAngle) {
|
|
35
20
|
if ((fromAngle - toAngle) <= 270) {
|
|
36
|
-
|
|
21
|
+
throw new Error("From Angle and To Angle must best separated by at least 90 degrees in both directions. ");
|
|
37
22
|
}
|
|
38
|
-
}
|
|
39
|
-
if (toAngle > fromAngle) {
|
|
23
|
+
} else if (toAngle > fromAngle) {
|
|
40
24
|
if (((toAngle - fromAngle) < 90) || (((toAngle - fromAngle) > 270))) {
|
|
41
|
-
|
|
25
|
+
throw new Error("From Angle and To Angle must best separated by at least 90 degrees in both directions. ");
|
|
42
26
|
}
|
|
43
|
-
}
|
|
44
|
-
magicCallback(true)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// optional mongoose
|
|
48
|
-
module.exports = (mongooseInstance) => {
|
|
49
|
-
let BearingFilter
|
|
50
|
-
if (mongooseInstance) {
|
|
51
|
-
BearingFilter = mongooseInstance.model('BearingFilter', BearingFilterSchema)
|
|
52
27
|
} else {
|
|
53
|
-
|
|
28
|
+
throw new Error("fromAngle and toAngle cannot be same. ");
|
|
54
29
|
}
|
|
55
30
|
|
|
56
|
-
return BearingFilter
|
|
57
31
|
}
|
|
58
|
-
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
let Bearing = mongoose.model('Bearing', BearingSchema);
|
|
35
|
+
|
|
36
|
+
module.exports = Bearing;
|
package/models/BoundingBox.js
CHANGED
|
@@ -1,39 +1,24 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let StateEnum
|
|
3
|
-
let uuidv4
|
|
4
|
-
let Point
|
|
1
|
+
let mongoose = require('mongoose');
|
|
2
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum;
|
|
3
|
+
let uuidv4 = require('uuid/v4');
|
|
4
|
+
let Point = require('../schemas/Point');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const BoundingBoxSchema = new mongoose.Schema(
|
|
17
|
-
schema,
|
|
6
|
+
let BoundingBoxSchema = new mongoose.Schema({
|
|
7
|
+
guid : { type: String, default: uuidv4 },
|
|
8
|
+
type : { type: String, default: "MultiLineString" },
|
|
9
|
+
name : { type: String, required: [true, 'name is required. '] },
|
|
10
|
+
northEast : { type: Point, required: [true, 'northEast is required. '] },
|
|
11
|
+
southWest : { type: Point, required: [true, 'southWest is required. '] },
|
|
12
|
+
creationTime : { type: Date, default: Date.now },
|
|
13
|
+
lastUpdateTime : { type: Date, default: Date.now },
|
|
14
|
+
state : { type: String, default : StateEnum.active, select: false }
|
|
15
|
+
},
|
|
18
16
|
{
|
|
19
|
-
_id: false,
|
|
20
|
-
versionKey: false
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
BoundingBoxSchema.add({
|
|
24
|
-
type:
|
|
25
|
-
{type: String, required: true}
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
// optional mongoose
|
|
29
|
-
module.exports = (mongooseInstance) => {
|
|
30
|
-
let BoundingBox
|
|
31
|
-
if (mongooseInstance) {
|
|
32
|
-
BoundingBox = mongooseInstance.model('BoundingBox', BoundingBoxSchema)
|
|
33
|
-
} else {
|
|
34
|
-
BoundingBox = mongoose.model('BoundingBox', BoundingBox)
|
|
17
|
+
_id : false,
|
|
18
|
+
versionKey : false
|
|
35
19
|
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
let BoundingBox = mongoose.model('BoundingBox', BoundingBoxSchema);
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
module.exports.boundingBoxSchema = schema
|
|
24
|
+
module.exports = BoundingBox;
|
|
@@ -1,41 +1,27 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let uuidv4
|
|
1
|
+
let mongoose = require('mongoose');
|
|
2
|
+
let uuidv4 = require('uuid/v4');
|
|
3
3
|
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
schema,
|
|
4
|
+
let DateFilterSchema = new mongoose.Schema({
|
|
5
|
+
guid : { type: String, default: uuidv4 },
|
|
6
|
+
type : { type: String, required: true, default: "dateFilter" },
|
|
7
|
+
startDate : { type: Date, required: [true, 'startDate is required. '] },
|
|
8
|
+
endDate : { type: Date, required: [true, 'endDate is required. '], validate: validateDateRange }
|
|
9
|
+
},
|
|
11
10
|
{
|
|
12
|
-
_id: false,
|
|
13
|
-
versionKey: false
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
CalendarDateRangeSchema.add({
|
|
17
|
-
type:
|
|
18
|
-
{type: String, required: true}
|
|
19
|
-
})
|
|
11
|
+
_id : false,
|
|
12
|
+
versionKey : false
|
|
13
|
+
}
|
|
14
|
+
);
|
|
20
15
|
|
|
21
|
-
function validateDateRange
|
|
22
|
-
let startDate = new Date(this.startDate)
|
|
23
|
-
endDate = new Date(endDate)
|
|
16
|
+
function validateDateRange(endDate){
|
|
17
|
+
let startDate = new Date(this.startDate);
|
|
18
|
+
endDate = new Date(endDate);
|
|
24
19
|
|
|
25
|
-
if
|
|
26
|
-
throw new Error(
|
|
20
|
+
if(endDate < startDate) {
|
|
21
|
+
throw new Error("startDate has to be less than endDate. ");
|
|
27
22
|
}
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
module.exports = (mongooseInstance) => {
|
|
32
|
-
let CalendarDateRange
|
|
33
|
-
if (mongooseInstance) {
|
|
34
|
-
CalendarDateRange = mongooseInstance.model('CalendarDateRange', CalendarDateRangeSchema)
|
|
35
|
-
} else {
|
|
36
|
-
CalendarDateRange = mongoose.model('CalendarDateRange', CalendarDateRangeSchema)
|
|
37
|
-
}
|
|
25
|
+
let DateFilter = mongoose.model('DateFilter', DateFilterSchema);
|
|
38
26
|
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
module.exports.calendarDateRangeSchema = schema
|
|
27
|
+
module.exports = DateFilter;
|