@bluedot-innovation/models 2.0.0-alpha.13 → 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 -29
- 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
|
@@ -1,42 +1,26 @@
|
|
|
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 TimeOfDayRangeFilterSchema = new mongoose.Schema({
|
|
5
|
+
guid : { type: String, default: uuidv4 },
|
|
6
|
+
type : { type: String },
|
|
7
|
+
fromTime : { type: Number, required: [true, 'time is required. '], min: 0, max: 86400 },
|
|
8
|
+
toTime : { type: Number, required: [true, 'interval is required. '], min: 0, max: 86400, validate: validateTime }
|
|
9
|
+
},
|
|
11
10
|
{
|
|
12
|
-
_id: false,
|
|
13
|
-
versionKey: false
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
TimeOfDayRangeFilterSchema.add({
|
|
17
|
-
type:
|
|
18
|
-
{type: String, required: true}
|
|
19
|
-
})
|
|
11
|
+
_id : false,
|
|
12
|
+
versionKey : false
|
|
13
|
+
}
|
|
14
|
+
);
|
|
20
15
|
|
|
21
|
-
function validateTime
|
|
22
|
-
let
|
|
23
|
-
let fromTime = this.fromTime
|
|
16
|
+
function validateTime(toTime){
|
|
17
|
+
let fromTime = this.fromTime;
|
|
24
18
|
|
|
25
|
-
if
|
|
26
|
-
|
|
19
|
+
if(fromTime == toTime) {
|
|
20
|
+
throw new Error("fromTime and toTime cannot be same. ");
|
|
27
21
|
}
|
|
28
|
-
return magicCallback(true)
|
|
29
22
|
}
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
module.exports = (mongooseInstance) => {
|
|
33
|
-
let TimeOfDayRangeFilter
|
|
34
|
-
if (mongooseInstance) {
|
|
35
|
-
TimeOfDayRangeFilter = mongooseInstance.model('TimeOfDayRangeFilterSchema', TimeOfDayRangeFilterSchema)
|
|
36
|
-
} else {
|
|
37
|
-
TimeOfDayRangeFilter = mongoose.model('TimeOfDayRangeFilterSchema', TimeOfDayRangeFilterSchema)
|
|
38
|
-
}
|
|
24
|
+
let TimeOfDayRangeFilter = mongoose.model('TimeOfDayRangeFilter', TimeOfDayRangeFilterSchema);
|
|
39
25
|
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
module.exports.timeOfDayRangeFilterSchema = schema
|
|
26
|
+
module.exports = TimeOfDayRangeFilter;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
let mongoose = require('mongoose');
|
|
2
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum;
|
|
3
|
+
let uuidv4 = require('uuid/v4');
|
|
4
|
+
|
|
5
|
+
let URLActionSchema = new mongoose.Schema({
|
|
6
|
+
guid : { type: String, default: uuidv4 },
|
|
7
|
+
type : { type: String },
|
|
8
|
+
url : { type: String, required: [true, 'url is required. '],
|
|
9
|
+
validate : {
|
|
10
|
+
validator: validateURL
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
description : { type: String, default: '' },
|
|
14
|
+
creationTime : { type: Date, default: Date.now },
|
|
15
|
+
lastUpdateTime : { type: Date, default: Date.now },
|
|
16
|
+
state : { type: String, default : StateEnum.active, select: false }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
_id: false,
|
|
20
|
+
__v: false
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
function validateURL(url){
|
|
25
|
+
let urlRegex = new RegExp("^(http[s]?:\\/\\/(www\\.)?|ftp:\\/\\/(www\\.)?|www\\.){1}([0-9A-Za-z-\\.@:%_\+~#=]+)+((\\.[a-zA-Z]{2,3})+)(/(.)*)?(\\?(.)*)?");
|
|
26
|
+
if(!urlRegex.test(url)) {
|
|
27
|
+
console.log(`{url} is not a valid URL. `);
|
|
28
|
+
throw new Error(url + " is not a valid URL. ");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let URLAction = mongoose.model('URLAction', URLActionSchema);
|
|
33
|
+
|
|
34
|
+
module.exports = URLAction;
|
package/models/Zone.js
CHANGED
|
@@ -4,94 +4,284 @@
|
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
let mongoose
|
|
8
|
-
|
|
9
|
-
let StateEnum
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
let
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
-
let
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
let
|
|
19
|
-
let
|
|
20
|
-
let
|
|
21
|
-
let
|
|
22
|
-
let uuidv4
|
|
23
|
-
let patcher = require('mongoose-json-patch')
|
|
24
|
-
|
|
25
|
-
// ////// //
|
|
26
|
-
// Schema //
|
|
27
|
-
// ////// //
|
|
28
|
-
|
|
29
|
-
let actionSchema = new Schema({},
|
|
30
|
-
{ discriminatorKey: 'type', _id: false })
|
|
31
|
-
|
|
32
|
-
let filterSchema = new Schema({},
|
|
33
|
-
{ discriminatorKey: 'type', _id: false })
|
|
34
|
-
|
|
35
|
-
let geofeatureSchema = new Schema({},
|
|
36
|
-
{ discriminatorKey: 'type', _id: false })
|
|
7
|
+
let mongoose = require('mongoose'),
|
|
8
|
+
Schema = mongoose.Schema;
|
|
9
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum;
|
|
10
|
+
let MessageAction = require('./MessageAction');
|
|
11
|
+
let URLAction = require('./URLAction');
|
|
12
|
+
let Circle = require('./Circle');
|
|
13
|
+
let BoundingBox = require('./BoundingBox');
|
|
14
|
+
let Polyline = require('./Polyline');
|
|
15
|
+
let Polygon = require('./Polygon');
|
|
16
|
+
let Beacon = require('./Beacon');
|
|
17
|
+
let SpeedFilter = require('./SpeedFilter');
|
|
18
|
+
let BearingFilter = require('./BearingFilter');
|
|
19
|
+
let TimeOfDayRangeFilter = require('./TimeOfDayRangeFilter');
|
|
20
|
+
let CalendarDateRangeFilter = require('./CalendarDateRangeFilter');
|
|
21
|
+
let PercentageCrossedFilter = require('./PercentageCrossedFilter');
|
|
22
|
+
let uuidv4 = require('uuid/v4');
|
|
37
23
|
|
|
38
24
|
let ZoneSchema = new Schema({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
type: [
|
|
25
|
+
_id : { type : String, default: uuidv4 },
|
|
26
|
+
name : { type : String, required: [true, 'name is required'] },
|
|
27
|
+
minimumRetriggerTime : {
|
|
28
|
+
type : Number,
|
|
29
|
+
required : [ true, 'minimumRetriggerTime is required' ],
|
|
30
|
+
min : 60,
|
|
31
|
+
max : 3599940,
|
|
32
|
+
validate : { validator : Number.isInteger,
|
|
33
|
+
message : '{VALUE} is not a number'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
filter : { type : [],
|
|
37
|
+
validate : {
|
|
38
|
+
validator: validateFilters
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
actions : { type : [],
|
|
42
|
+
validate : {
|
|
43
|
+
validator: validateActions
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
geofeatures : { type : [],
|
|
47
|
+
validate : {
|
|
48
|
+
validator: validateGeofeatures
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
customData : [{ type : Schema.Types.Mixed }],
|
|
52
|
+
description : { type : String, default: '' },
|
|
53
|
+
creationTime : { type : Date, default: Date.now },
|
|
54
|
+
lastUpdateTime : { type : Date, default: Date.now },
|
|
55
|
+
applicationId : { type : String, required: [true, 'applicationId is required'] },
|
|
56
|
+
state : { type : String, default : StateEnum.active, select: false }
|
|
56
57
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
58
|
+
{ collection : 'zone' });
|
|
59
|
+
|
|
60
|
+
function validateFilters(filters){
|
|
61
|
+
let errorList = '';
|
|
62
|
+
|
|
63
|
+
filters.forEach(filter => {
|
|
64
|
+
switch(filter.type) {
|
|
65
|
+
case 'speed': {
|
|
66
|
+
let speedFilter = new SpeedFilter(filter);
|
|
67
|
+
let speedFilterErrors = speedFilter.validateSync();
|
|
68
|
+
if(speedFilterErrors) {
|
|
69
|
+
for (let key of Object.keys(speedFilterErrors.errors)) {
|
|
70
|
+
console.log(speedFilterErrors.errors[key].message);
|
|
71
|
+
errorList = errorList + speedFilterErrors.errors[key].message;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case 'bearing': {
|
|
78
|
+
let bearingFilter = new BearingFilter(filter);
|
|
79
|
+
let bearingFilterErrors = bearingFilter.validateSync();
|
|
80
|
+
if(bearingFilterErrors) {
|
|
81
|
+
for (let key of Object.keys(bearingFilterErrors.errors)) {
|
|
82
|
+
console.log(bearingFilterErrors.errors[key].message);
|
|
83
|
+
errorList = errorList + bearingFilterErrors.errors[key].message;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case 'percentageCrossed': {
|
|
90
|
+
let percentageCrossedFilter = new PercentageCrossedFilter(filter);
|
|
91
|
+
let percentageCrossedFilterErrors = percentageCrossedFilter.validateSync();
|
|
92
|
+
if(percentageCrossedFilterErrors) {
|
|
93
|
+
for (let key of Object.keys(percentageCrossedFilterErrors.errors)) {
|
|
94
|
+
console.log(percentageCrossedFilterErrors.errors[key].message);
|
|
95
|
+
errorList = errorList + percentageCrossedFilterErrors.errors[key].message;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'timeOfDayRange': {
|
|
102
|
+
let timeOfDayRangeFilter = new TimeOfDayRangeFilter(filter);
|
|
103
|
+
let timeOfDayRangeFilterErrors = timeOfDayRangeFilter.validateSync();
|
|
104
|
+
if(timeOfDayRangeFilterErrors) {
|
|
105
|
+
for (let key of Object.keys(timeOfDayRangeFilterErrors.errors)) {
|
|
106
|
+
console.log(timeOfDayRangeFilterErrors.errors[key].message);
|
|
107
|
+
errorList = errorList + timeOfDayRangeFilterErrors.errors[key].message;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case 'calendarDateRange': {
|
|
114
|
+
let calendarDateRangeFilter = new CalendarDateRangeFilter(filter);
|
|
115
|
+
let calendarDateRangeFilterErrors = calendarDateRangeFilter.validateSync();
|
|
116
|
+
if(calendarDateRangeFilterErrors) {
|
|
117
|
+
for (let key of Object.keys(calendarDateRangeFilterErrors.errors)) {
|
|
118
|
+
console.log(calendarDateRangeFilterErrors.errors[key].message);
|
|
119
|
+
errorList = errorList + calendarDateRangeFilterErrors.errors[key].message;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
default: {
|
|
126
|
+
console.log("Please enter a valid filter type.");
|
|
127
|
+
errorList = errorList + "Please enter a valid filter type. ";
|
|
128
|
+
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if(errorList != '')
|
|
135
|
+
throw new Error(errorList);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
function validateActions(actions){
|
|
140
|
+
let errorList = '';
|
|
141
|
+
|
|
142
|
+
actions.forEach(action => {
|
|
143
|
+
switch(action.type) {
|
|
144
|
+
case 'message': {
|
|
145
|
+
let messageAction = new MessageAction(action);
|
|
146
|
+
let messageErrors = messageAction.validateSync();
|
|
147
|
+
if(messageErrors) {
|
|
148
|
+
for (let key of Object.keys(messageErrors.errors)) {
|
|
149
|
+
console.log(messageErrors.errors[key].message);
|
|
150
|
+
errorList = errorList + messageErrors.errors[key].message;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case 'url': {
|
|
157
|
+
let urlAction = new URLAction(action);
|
|
158
|
+
let urlErrors = urlAction.validateSync();
|
|
159
|
+
|
|
160
|
+
if(urlErrors) {
|
|
161
|
+
for (let key of Object.keys(urlErrors.errors)) {
|
|
162
|
+
console.log(urlErrors.errors[key].message);
|
|
163
|
+
errorList = errorList + urlErrors.errors[key].message;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
default: {
|
|
170
|
+
console.log("Please enter a valid action type.");
|
|
171
|
+
errorList = errorList + "Please enter a valid action type. ";
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
if(errorList != '')
|
|
178
|
+
throw new Error(errorList);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
function validateGeofeatures(features) {
|
|
183
|
+
if(features.length == 0) {
|
|
184
|
+
throw new Error("Geofeatures cannot be empty.");
|
|
92
185
|
} else {
|
|
93
|
-
|
|
186
|
+
let errorList = '';
|
|
187
|
+
features.forEach(geofeature => {
|
|
188
|
+
switch(geofeature.type) {
|
|
189
|
+
case 'circle': {
|
|
190
|
+
let circle = new Circle(geofeature);
|
|
191
|
+
let circleErrors = circle.validateSync();
|
|
192
|
+
|
|
193
|
+
if(circleErrors) {
|
|
194
|
+
for (let key of Object.keys(circleErrors.errors)) {
|
|
195
|
+
console.log(circleErrors.errors[key].message);
|
|
196
|
+
errorList = errorList + circleErrors.errors[key].message;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
case 'boundingBox': {
|
|
203
|
+
let boundingBox = new BoundingBox(geofeature);
|
|
204
|
+
let boundingBoxErrors = boundingBox.validateSync();
|
|
205
|
+
|
|
206
|
+
if(boundingBoxErrors) {
|
|
207
|
+
for (let key of Object.keys(boundingBoxErrors.errors)) {
|
|
208
|
+
console.log(boundingBoxErrors.errors[key].message);
|
|
209
|
+
errorList = errorList + boundingBoxErrors.errors[key].message;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
case 'polygon': {
|
|
216
|
+
let polygon = new Polygon(geofeature);
|
|
217
|
+
let polygonErrors = polygon.validateSync();
|
|
218
|
+
|
|
219
|
+
if(polygonErrors) {
|
|
220
|
+
for (let key of Object.keys(polygonErrors.errors)) {
|
|
221
|
+
console.log(polygonErrors.errors[key].message);
|
|
222
|
+
errorList = errorList + polygonErrors.errors[key].message;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'polyline': {
|
|
229
|
+
let polyline = new Polyline(geofeature);
|
|
230
|
+
let polylineErrors = polyline.validateSync();
|
|
231
|
+
|
|
232
|
+
if(polylineErrors) {
|
|
233
|
+
for (let key of Object.keys(polylineErrors.errors)) {
|
|
234
|
+
console.log(polylineErrors.errors[key].message);
|
|
235
|
+
errorList = errorList + polylineErrors.errors[key].message;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
case 'beacon': {
|
|
242
|
+
|
|
243
|
+
let beacon = new Beacon(geofeature);
|
|
244
|
+
let beaconErrors = beacon.validateSync();
|
|
245
|
+
|
|
246
|
+
if(beaconErrors) {
|
|
247
|
+
for (let key of Object.keys(beaconErrors.errors)) {
|
|
248
|
+
console.log(beaconErrors.errors[key].message);
|
|
249
|
+
errorList = errorList + beaconErrors.errors[key].message;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
default: {
|
|
256
|
+
errorList = "Please enter a proper geofeature type. ";
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
if(errorList != '')
|
|
263
|
+
throw new Error(errorList);
|
|
94
264
|
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function checkPoint(point, name1, name2){
|
|
268
|
+
let pointErrors = '';
|
|
95
269
|
|
|
96
|
-
|
|
270
|
+
if(!point.latitude) {
|
|
271
|
+
pointErrors = pointErrors + name1 + " " +name2 + " should have a latitude field. ";
|
|
272
|
+
} else if(point.latitude < -90 || point.latitude > 90) {
|
|
273
|
+
pointErrors = pointErrors + name1 + " " + name2 + " latitude should be within -90 and 90. ";
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if(!point.longitude) {
|
|
277
|
+
pointErrors = pointErrors + name1 + " " +name2 + " should have a longitude field. ";
|
|
278
|
+
} else if(point.longitude < -180 || point.longitude > 180) {
|
|
279
|
+
pointErrors = pointErrors + name1 + " " + name2 + " longitude should be within -180 and 180. ";
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return pointErrors;
|
|
97
283
|
}
|
|
284
|
+
|
|
285
|
+
let Zone = mongoose.model('Zone', ZoneSchema);
|
|
286
|
+
|
|
287
|
+
module.exports = Zone;
|
package/models/ZoneUIState.js
CHANGED
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var mongoose = require('mongoose'),
|
|
7
|
+
Schema = mongoose.Schema;
|
|
8
|
+
var StateEnum = require('@bluedot-innovation/enums').StateEnum;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
{collection: 'zoneUIState'}
|
|
22
|
-
)
|
|
10
|
+
var ZoneUIStateSchema = new mongoose.Schema({
|
|
11
|
+
_id : {type: String},
|
|
12
|
+
signature : {type: String},
|
|
13
|
+
center : Schema.Types.Mixed,
|
|
14
|
+
dataSource: {type:String, select: false, default : 'openApi'},
|
|
15
|
+
zoom : {type: Number, default : 4},
|
|
16
|
+
lastUpdateTime : {type: Date, default: Date.now},
|
|
17
|
+
creationTime : {type: Date, default: Date.now},
|
|
18
|
+
state: {type: String, default : StateEnum.active, select: false},
|
|
19
|
+
zoneId: String
|
|
20
|
+
},
|
|
21
|
+
{ collection : 'zoneUIState' }
|
|
22
|
+
);
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
module.exports = ZoneUIState
|
|
24
|
+
var ZoneUIState = mongoose.model('ZoneUIState', ZoneUIStateSchema);
|
|
25
|
+
module.exports = ZoneUIState;
|
package/package.json
CHANGED
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluedot-innovation/models",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "Models.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"test": "mocha __tests__/**/*.spec.js __tests__/**/**/*.spec.js",
|
|
9
|
-
"test:coverage": "nyc mocha __tests__/**/*.spec.js __tests__/**/**/*.spec.js",
|
|
10
|
-
"test:coverage-check": "nyc check-coverage --lines 90 --functions 90 --branches 70",
|
|
11
|
-
"test:ci": "npm run lint && npm run test:coverage-check && npm test"
|
|
7
|
+
"test": "mocha __tests__/*"
|
|
12
8
|
},
|
|
13
9
|
"author": "",
|
|
14
10
|
"license": "UNLICENSED",
|
|
15
11
|
"devDependencies": {
|
|
12
|
+
"assert": "^1.4.1",
|
|
16
13
|
"chai": "^4.1.2",
|
|
17
14
|
"describe": "*",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"eslint-plugin-node": "^5.2.1",
|
|
22
|
-
"eslint-plugin-promise": "^3.6.0",
|
|
23
|
-
"eslint-plugin-standard": "^3.0.1",
|
|
24
|
-
"mocha": "^4.0.1",
|
|
25
|
-
"mockgoose": "^7.3.3",
|
|
26
|
-
"nyc": "^11.3.0",
|
|
27
|
-
"sinon": "^4.1.2"
|
|
15
|
+
"mocha": "1.8.x",
|
|
16
|
+
"should": "1.2.x",
|
|
17
|
+
"sinon": "^4.0.2"
|
|
28
18
|
},
|
|
29
19
|
"dependencies": {
|
|
30
|
-
"@bluedot-innovation/enums": "
|
|
31
|
-
"mongoose": "
|
|
32
|
-
"mongoose-error-helper": "0.0.2",
|
|
33
|
-
"mongoose-json-patch": "^1.1.1",
|
|
20
|
+
"@bluedot-innovation/enums": "*",
|
|
21
|
+
"mongoose": "4.7.6",
|
|
34
22
|
"uuid": "^3.1.0"
|
|
35
23
|
}
|
|
36
24
|
}
|
package/schemas/Point.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
let mongoose
|
|
1
|
+
let mongoose = require('mongoose');
|
|
2
2
|
|
|
3
3
|
let PointSchema = new mongoose.Schema({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
4
|
+
type : { type:String },
|
|
5
|
+
latitude : { type: Number, required: [true, 'latitude is required. '], min : -90, max : 90, },
|
|
6
|
+
longitude : { type: Number, required: [true, 'longitude is required. '], min : -180, max : 180 },
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
_id: false,
|
|
10
|
+
__v: false
|
|
11
|
+
}
|
|
12
|
+
);
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
//let Point = mongoose.model('Point', PointSchema);
|
|
15
|
+
|
|
16
|
+
module.exports = PointSchema;
|
package/.eslintrc.js
DELETED
package/.gitlab-ci.yml
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# Official framework image. Look for the different tagged releases at:
|
|
2
|
-
# https://hub.docker.com/r/library/node/tags/
|
|
3
|
-
image: node:8
|
|
4
|
-
|
|
5
|
-
before_script:
|
|
6
|
-
- npm install
|
|
7
|
-
|
|
8
|
-
# This folder is cached between builds
|
|
9
|
-
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
|
|
10
|
-
cache:
|
|
11
|
-
paths:
|
|
12
|
-
- node_modules/
|
|
13
|
-
|
|
14
|
-
test:lint:
|
|
15
|
-
tags:
|
|
16
|
-
- xcode9
|
|
17
|
-
script:
|
|
18
|
-
- npm run lint
|
|
19
|
-
|
|
20
|
-
# Supported node versions can be found here:
|
|
21
|
-
# https://github.com/nodejs/LTS#lts_schedule
|
|
22
|
-
# jest does not support node < 4
|
|
23
|
-
# https://facebook.github.io/jest/docs/troubleshooting.html#compatibility-issues
|
|
24
|
-
test:node:8:
|
|
25
|
-
tags:
|
|
26
|
-
- xcode9
|
|
27
|
-
script:
|
|
28
|
-
- npm run test:coverage-check && npm test
|
|
29
|
-
|
|
30
|
-
# Publish tagged versions to npm
|
|
31
|
-
publish:
|
|
32
|
-
stage: deploy
|
|
33
|
-
tags:
|
|
34
|
-
- xcode9
|
|
35
|
-
only:
|
|
36
|
-
- tags
|
|
37
|
-
- triggers
|
|
38
|
-
#gitlab open issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/27818
|
|
39
|
-
except:
|
|
40
|
-
- /^(?!.*(master)$).*$/
|
|
41
|
-
script:
|
|
42
|
-
- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc
|
|
43
|
-
- npm publish
|
package/.nyc_output/.gitkeep
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|