@bluedot-innovation/models 2.0.0-alpha1 → 2.0.0-beta.10
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/.eslintrc.js +6 -0
- package/.gitlab-ci.yml +43 -0
- package/.nyc_output/b3865a46e2cec635045d586cfc79e5c6.json +1 -0
- package/.nyc_output/d9020767349457a911ef2b431e357310.json +1 -0
- package/Models.js +48 -10
- package/README.MD +36 -0
- package/__tests__/account/account.data.json +12 -0
- package/__tests__/account/account.rules.js +8 -0
- package/__tests__/account/account.spec.js +83 -0
- package/__tests__/action/message/messageAction.data.json +5 -0
- package/__tests__/action/message/messageAction.rules.json +3 -0
- package/__tests__/action/message/messageAction.spec.js +61 -0
- package/__tests__/action/url/urlAction.data.json +4 -0
- package/__tests__/action/url/urlAction.rules.json +3 -0
- package/__tests__/action/url/urlAction.spec.js +74 -0
- package/__tests__/dailyStats/checkDailyStats.js +31 -0
- package/__tests__/filter/beacon/beaconFilter.data.json +1 -0
- package/__tests__/filter/beacon/beaconFilter.rules.json +3 -0
- package/__tests__/filter/beacon/beaconFilter.spec.js +1 -0
- package/__tests__/filter/bearing/bearingFilter.data.json +5 -0
- package/__tests__/filter/bearing/bearingFilter.rules.json +3 -0
- package/__tests__/filter/bearing/bearingFilter.spec.js +95 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.data.json +5 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.rules.json +3 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.spec.js +62 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.data.json +5 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.rules.json +3 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.spec.js +62 -0
- package/__tests__/filter/speed/speedFilter.data.json +5 -0
- package/__tests__/filter/speed/speedFilter.rules.json +3 -0
- package/__tests__/filter/speed/speedFilter.spec.js +73 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.data.json +5 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.rules.json +3 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.spec.js +73 -0
- package/__tests__/geofeature/beacon/beacon.data.json +12 -0
- package/__tests__/geofeature/beacon/beacon.rules.json +13 -0
- package/__tests__/geofeature/beacon/beacon.spec.js +95 -0
- package/__tests__/geofeature/boundingBox/boundingBox.data.json +12 -0
- package/__tests__/geofeature/boundingBox/boundingBox.rules.json +3 -0
- package/__tests__/geofeature/boundingBox/boundingBox.spec.js +62 -0
- package/__tests__/geofeature/circle/circle.data.json +9 -0
- package/__tests__/geofeature/circle/circle.rules.json +3 -0
- package/__tests__/geofeature/circle/circle.spec.js +71 -0
- package/__tests__/geofeature/polygon/polygon.data.json +46 -0
- package/__tests__/geofeature/polygon/polygon.rules.json +3 -0
- package/__tests__/geofeature/polygon/polygon.spec.js +70 -0
- package/__tests__/geofeature/polyline/polyline.data.json +46 -0
- package/__tests__/geofeature/polyline/polyline.rules.json +3 -0
- package/__tests__/geofeature/polyline/polyline.spec.js +70 -0
- package/__tests__/monthlyStats/monthlyStats.data.json +29 -0
- package/__tests__/monthlyStats/monthlyStats.spec.js +68 -0
- package/__tests__/project/project.data.json +14 -0
- package/__tests__/project/project.rules.json +9 -0
- package/__tests__/project/project.spec.js +81 -0
- package/__tests__/ruleRequestAggregation/ruleRequestAggregation.data.json +8 -0
- package/__tests__/ruleRequestAggregation/ruleRequestAggregation.spec.js +69 -0
- package/__tests__/user/user.data.js +13 -0
- package/__tests__/user/user.rules.js +8 -0
- package/__tests__/user/user.spec.js +83 -0
- package/__tests__/zone/zone.action.spec.js +50 -0
- package/__tests__/zone/zone.data.json +156 -0
- package/__tests__/zone/zone.filter.spec.js +50 -0
- package/__tests__/zone/zone.geofeatures.spec.js +74 -0
- package/__tests__/zone/zone.spec.js +107 -0
- package/helpers.js +14 -0
- package/models/Account.js +49 -0
- package/models/AdminPortalUser.js +10 -11
- package/models/Beacon.js +92 -78
- package/models/BeaconFilter.js +28 -12
- package/models/BearingFilter.js +46 -23
- package/models/BoundingBox.js +37 -20
- package/models/CalendarDateRangeFilter.js +34 -19
- package/models/Circle.js +34 -18
- package/models/Contract.js +37 -38
- package/models/CustomerLogin.js +9 -10
- package/models/DBEvent.js +13 -14
- package/models/DailyStats.js +28 -0
- package/models/DeviceRulesRequest.js +27 -28
- package/models/Fence.js +12 -13
- package/models/GeoFence.js +12 -14
- package/models/Geofeature.js +16 -18
- package/models/MessageAction.js +31 -16
- package/models/MonthlyStats.js +44 -0
- package/models/NotificationLogEntry.js +7 -8
- package/models/POILocation.js +6 -7
- package/models/POILookup.js +8 -9
- package/models/POIResult.js +7 -8
- package/models/PartnerCustomer.js +12 -13
- package/models/PartnerPasswordReset.js +8 -9
- package/models/PartnerUser.js +10 -11
- package/models/Partners.js +11 -12
- package/models/PercentageCrossedFilter.js +30 -15
- package/models/Polygon.js +35 -19
- package/models/Polyline.js +35 -19
- package/models/Project.js +54 -0
- package/models/RuleRequestAggregation.js +33 -15
- package/models/SimpleCheckInZone.js +21 -21
- package/models/SingleUseToken.js +7 -8
- package/models/SpeedFilter.js +39 -19
- package/models/TestDevice.js +11 -12
- package/models/TestDeviceCluster.js +9 -10
- package/models/TestInstance.js +9 -10
- package/models/TestScenario.js +9 -10
- package/models/TimeOfDayRange.js +16 -16
- package/models/TimeOfDayRangeFilter.js +36 -18
- package/models/UrlAction.js +54 -0
- package/models/User.js +59 -0
- package/models/Zone.js +85 -273
- package/models/ZoneUIState.js +18 -18
- package/package.json +20 -8
- package/schemas/Point.js +10 -13
- package/schemas/Webhook.js +22 -0
- package/yarn.lock +2796 -0
- package/__tests__/zone/checkActions.js +0 -64
- package/__tests__/zone/checkAppId.js +0 -41
- package/__tests__/zone/checkBeacon.js +0 -46
- package/__tests__/zone/checkBearingFitler.js +0 -48
- package/__tests__/zone/checkBoundingBox.js +0 -44
- package/__tests__/zone/checkCalendarDateRangeFilterFitler.js +0 -48
- package/__tests__/zone/checkCircle.js +0 -41
- package/__tests__/zone/checkMRT.js +0 -46
- package/__tests__/zone/checkPercentageCrossedFitler.js +0 -48
- package/__tests__/zone/checkPolygon.js +0 -78
- package/__tests__/zone/checkPolyline.js +0 -78
- package/__tests__/zone/checkSpeedFitler.js +0 -48
- package/__tests__/zone/checkTimeOfDayRangeFitler.js +0 -48
- package/models/AdminUser.js +0 -10
- package/models/Application.js +0 -38
- package/models/Customer.js +0 -38
- package/models/URLAction.js +0 -34
package/models/Polygon.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let StateEnum
|
|
3
|
-
let Point
|
|
4
|
-
let
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
+
let Point = require('../schemas/Point')
|
|
4
|
+
let uuidv4 = require('uuid/v4')
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const schema = {
|
|
7
|
+
guid: {type: String, default: uuidv4},
|
|
8
|
+
name: {type: String, required: [true, 'name is required. ']},
|
|
9
|
+
color: String,
|
|
10
|
+
vertices: {type: [Point], required: [true, 'vertices is required. ']},
|
|
11
|
+
creationTime: {type: Date, default: Date.now},
|
|
12
|
+
lastUpdateTime: {type: Date, default: Date.now},
|
|
13
|
+
state: {type: String, default: StateEnum.active, select: false}
|
|
14
|
+
}
|
|
15
|
+
const PolygonSchema = new mongoose.Schema(
|
|
16
|
+
schema,
|
|
15
17
|
{
|
|
16
|
-
_id
|
|
17
|
-
versionKey
|
|
18
|
-
}
|
|
19
|
-
|
|
18
|
+
_id: false,
|
|
19
|
+
versionKey: false
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
PolygonSchema.add({
|
|
23
|
+
type:
|
|
24
|
+
{type: String, required: true}
|
|
25
|
+
})
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
// optional mongoose
|
|
28
|
+
let model = (mongooseInstance) => {
|
|
29
|
+
let Polygon
|
|
30
|
+
if (mongooseInstance) {
|
|
31
|
+
Polygon = mongooseInstance.model('Polygon', PolygonSchema)
|
|
32
|
+
} else {
|
|
33
|
+
Polygon = mongoose.model('Polygon', PolygonSchema)
|
|
34
|
+
}
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
return Polygon
|
|
37
|
+
}
|
|
38
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
39
|
+
module.exports = { Model: model, Schema: PolygonSchema, polygonSchema: schema }
|
package/models/Polyline.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let StateEnum
|
|
3
|
-
let Point
|
|
4
|
-
let
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
+
let Point = require('../schemas/Point')
|
|
4
|
+
let uuidv4 = require('uuid/v4')
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const schema = {
|
|
7
|
+
guid: {type: String, default: uuidv4},
|
|
8
|
+
name: {type: String, required: [true, 'name is required. ']},
|
|
9
|
+
vertices: {type: [Point], required: [true, 'vertices is required. ']},
|
|
10
|
+
creationTime: {type: Date, default: Date.now},
|
|
11
|
+
lastUpdateTime: {type: Date, default: Date.now},
|
|
12
|
+
state: {type: String, default: StateEnum.active, select: false}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const PolylineSchema = new mongoose.Schema(
|
|
16
|
+
schema,
|
|
15
17
|
{
|
|
16
|
-
_id
|
|
17
|
-
versionKey
|
|
18
|
-
}
|
|
19
|
-
);
|
|
18
|
+
_id: false,
|
|
19
|
+
versionKey: false
|
|
20
|
+
})
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
PolylineSchema.add({
|
|
23
|
+
type:
|
|
24
|
+
{type: String, required: true}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// optional mongoose
|
|
28
|
+
let model = (mongooseInstance) => {
|
|
29
|
+
let Polyline
|
|
30
|
+
if (mongooseInstance) {
|
|
31
|
+
Polyline = mongooseInstance.model('Polyline', PolylineSchema)
|
|
32
|
+
} else {
|
|
33
|
+
Polyline = mongoose.model('Polyline', PolylineSchema)
|
|
34
|
+
}
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
return Polyline
|
|
37
|
+
}
|
|
38
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
39
|
+
module.exports = { Model: model, Schema: PolylineSchema, polylineSchema: schema }
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Ryan W. Kan on 14/02/2018.
|
|
3
|
+
* Copyright : Bluedot Innovations.
|
|
4
|
+
* Owner :
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
let mongoose = require('mongoose')
|
|
8
|
+
let Schema = mongoose.Schema
|
|
9
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
10
|
+
let uuidv4 = require('uuid/v4')
|
|
11
|
+
let patcher = require('mongoose-json-patch')
|
|
12
|
+
let helpers = require('../helpers')
|
|
13
|
+
|
|
14
|
+
let WebhookSchema = require('../schemas/Webhook')
|
|
15
|
+
|
|
16
|
+
let ProjectSchema = new mongoose.Schema({
|
|
17
|
+
_id: {type: String, default: uuidv4},
|
|
18
|
+
state: {type: String, default: StateEnum.active},
|
|
19
|
+
nextRuleUpdateInterval: {
|
|
20
|
+
type: Number,
|
|
21
|
+
required: [true, 'nextRuleUpdateInterval is required'],
|
|
22
|
+
min: 5,
|
|
23
|
+
max: 172800,
|
|
24
|
+
validate: {
|
|
25
|
+
validator: Number.isInteger,
|
|
26
|
+
message: '{VALUE} is not a number'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
lastUpdateTime: {type: Date, required: [true, 'lastUpdateTime is required']},
|
|
30
|
+
creationTime: {type: Date, required: [true, 'creationTime is required']},
|
|
31
|
+
name: {type: String, required: [true, 'name is required']},
|
|
32
|
+
accountId: {type: String, required: true, validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'default error message'}},
|
|
33
|
+
webhooks: [WebhookSchema],
|
|
34
|
+
configurationParameters: {type: Schema.Types.Mixed, default: null}, // http://collab.bluedot.io/display/PD/Remote+configuration
|
|
35
|
+
firebaseApiKey: {type: String} // BP-491
|
|
36
|
+
},
|
|
37
|
+
{collection: 'project'})
|
|
38
|
+
|
|
39
|
+
ProjectSchema.plugin(patcher)
|
|
40
|
+
|
|
41
|
+
// optional mongoose
|
|
42
|
+
let model = (mongooseInstance) => {
|
|
43
|
+
let Project
|
|
44
|
+
if (mongooseInstance) {
|
|
45
|
+
Project = mongooseInstance.model('Project', ProjectSchema)
|
|
46
|
+
} else {
|
|
47
|
+
Project = mongoose.model('Project', ProjectSchema)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return Project
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
54
|
+
module.exports = { Model: model, Schema: ProjectSchema }
|
|
@@ -3,20 +3,38 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const mongoose = require('mongoose')
|
|
7
|
+
const uuidv4 = require('uuid/v4')
|
|
8
|
+
const helpers = require('../helpers')
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
collection: 'ruleRequestAggregation',
|
|
17
|
-
versionKey: false
|
|
18
|
-
}
|
|
19
|
-
)
|
|
20
|
-
);
|
|
10
|
+
const schema = {
|
|
11
|
+
_id: { type: String, default: uuidv4 },
|
|
12
|
+
appplicationId: {type: String, required: [true, 'applicationId is required'], validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'invalid applicationId'}},
|
|
13
|
+
customerId: {type: String, required: [true, 'customerId is required'], validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'invalid customerId'}},
|
|
14
|
+
iosCount: {type: Number, required: [true, 'iosCount is required'], min: 0},
|
|
15
|
+
androidCount: {type: Number, required: [true, 'androidCount is required'], min: 0},
|
|
16
|
+
creationDate: { type: Date, default: Date.now }
|
|
17
|
+
}
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
const RuleRequestAggregationSchema = new mongoose.Schema(
|
|
20
|
+
schema,
|
|
21
|
+
{
|
|
22
|
+
collection: 'ruleRequestAggregation',
|
|
23
|
+
versionKey: false
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
// optional mongoose
|
|
28
|
+
let model = (mongooseInstance) => {
|
|
29
|
+
let RuleRequestAggregation
|
|
30
|
+
if (mongooseInstance) {
|
|
31
|
+
RuleRequestAggregation = mongooseInstance.model('RuleRequestAggregation', RuleRequestAggregationSchema)
|
|
32
|
+
} else {
|
|
33
|
+
RuleRequestAggregation = mongoose.model('RuleRequestAggregation', RuleRequestAggregationSchema)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return RuleRequestAggregation
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
40
|
+
module.exports = { Model: model, Schema: RuleRequestAggregationSchema }
|
|
@@ -3,27 +3,27 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let mongoose = require('mongoose')
|
|
7
|
+
let Schema = mongoose.Schema
|
|
8
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
let SimpleCheckInZoneSchema = new Schema({
|
|
11
|
+
_id: {type: String},
|
|
12
|
+
name: String,
|
|
13
|
+
description: {type: String, default: ''},
|
|
14
|
+
minimumRetriggerTime: {type: Number},
|
|
15
|
+
checkout: {type: Boolean, default: false},
|
|
16
|
+
dataSource: {type: String, select: false, default: 'openApi'},
|
|
17
|
+
conditionalActions: [],
|
|
18
|
+
spatialFilters: [],
|
|
19
|
+
creationTime: {type: Date, default: Date.now},
|
|
20
|
+
lastUpdateTime: {type: Date, default: Date.now},
|
|
21
|
+
activeTimeRange: Schema.Types.Mixed,
|
|
22
|
+
applicationId: String,
|
|
23
|
+
state: {type: String, default: StateEnum.active, select: false}
|
|
24
|
+
},
|
|
25
|
+
{collection: 'zone'})
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
let SimpleCheckInZone = mongoose.model('SimpleCheckInZone', SimpleCheckInZoneSchema)
|
|
28
28
|
|
|
29
|
-
module.exports = SimpleCheckInZone
|
|
29
|
+
module.exports = SimpleCheckInZone
|
package/models/SingleUseToken.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright : Bluedot Innovations.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
let mongoose = require('mongoose')
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
let SingleUseToken = mongoose.model('SingleUseToken', new mongoose.Schema(
|
|
7
7
|
{
|
|
8
8
|
tokenString: String,
|
|
9
9
|
customerId: String,
|
|
10
10
|
customerLoginId: String,
|
|
11
|
-
integration: {type:String, default
|
|
11
|
+
integration: {type: String, default: 'admin'},
|
|
12
12
|
expiration: Date
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
collection
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
);
|
|
15
|
+
collection: 'singleUseToken'
|
|
16
|
+
})
|
|
17
|
+
)
|
|
19
18
|
|
|
20
|
-
module.exports = SingleUseToken
|
|
19
|
+
module.exports = SingleUseToken
|
package/models/SpeedFilter.js
CHANGED
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let schema = {
|
|
5
|
+
guid: {type: String, default: uuidv4},
|
|
6
|
+
minimumSpeed: {type: Number, required: [true, 'minimumSpeed is required. '], min: 0},
|
|
7
|
+
maximumSpeed: {type: Number, required: true, validate: {isAsync: true, validator: validateMaxSpeed, msg: 'default error message'}}
|
|
8
|
+
}
|
|
9
|
+
let SpeedFilterSchema = new mongoose.Schema(
|
|
10
|
+
schema,
|
|
10
11
|
{
|
|
11
|
-
_id
|
|
12
|
-
versionKey
|
|
13
|
-
}
|
|
14
|
-
|
|
12
|
+
_id: false,
|
|
13
|
+
versionKey: false
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
SpeedFilterSchema.add({
|
|
17
|
+
type:
|
|
18
|
+
{type: String, required: true}
|
|
19
|
+
})
|
|
15
20
|
|
|
16
|
-
function
|
|
17
|
-
let
|
|
18
|
-
let
|
|
21
|
+
function validateMaxSpeed (v, cb) {
|
|
22
|
+
let magicCallback = cb
|
|
23
|
+
let minSpeed = this.minimumSpeed
|
|
24
|
+
let maxSpeed = v
|
|
25
|
+
let speedDifference = maxSpeed - minSpeed
|
|
19
26
|
|
|
20
|
-
if (
|
|
21
|
-
|
|
27
|
+
if (maxSpeed < 5) {
|
|
28
|
+
magicCallback(false, 'Maximum speed has to be at least 5 km/h')
|
|
29
|
+
} else if (speedDifference < 5) {
|
|
30
|
+
magicCallback(false, 'Maximum speed has to be at least 5 km/h greater than minimum speed')
|
|
22
31
|
}
|
|
32
|
+
magicCallback(true)
|
|
23
33
|
}
|
|
24
34
|
|
|
25
|
-
|
|
35
|
+
// optional mongoose
|
|
36
|
+
let model = (mongooseInstance) => {
|
|
37
|
+
let SpeedFilter
|
|
38
|
+
if (mongooseInstance) {
|
|
39
|
+
SpeedFilter = mongooseInstance.model('SpeedFilter', SpeedFilterSchema)
|
|
40
|
+
} else {
|
|
41
|
+
SpeedFilter = mongoose.model('SpeedFilter', SpeedFilterSchema)
|
|
42
|
+
}
|
|
26
43
|
|
|
27
|
-
|
|
44
|
+
return SpeedFilter
|
|
45
|
+
}
|
|
46
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
47
|
+
module.exports = { Model: model, Schema: SpeedFilterSchema, speedFilterSchema: schema }
|
package/models/TestDevice.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
let mongoose = require('mongoose')
|
|
7
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let TestDevice = mongoose.model('TestDevice', new mongoose.Schema(
|
|
10
10
|
{
|
|
11
11
|
name: String,
|
|
12
12
|
identifier: String,
|
|
@@ -15,21 +15,20 @@ var TestDevice = mongoose.model('TestDevice', new mongoose.Schema(
|
|
|
15
15
|
hostToken: String,
|
|
16
16
|
batteryToken: String,
|
|
17
17
|
model: String,
|
|
18
|
-
trackingDevice: {type: Boolean, default
|
|
19
|
-
creationTime
|
|
20
|
-
lastUpdateTime
|
|
18
|
+
trackingDevice: {type: Boolean, default: false},
|
|
19
|
+
creationTime: {type: Date, default: Date.now},
|
|
20
|
+
lastUpdateTime: {type: Date, default: Date.now},
|
|
21
21
|
serialNumber: String,
|
|
22
22
|
mobileNumber: String,
|
|
23
23
|
deviceType: String,
|
|
24
|
-
state: {type:String, default: StateEnum.active},
|
|
24
|
+
state: {type: String, default: StateEnum.active},
|
|
25
25
|
comments: String,
|
|
26
26
|
imei: String,
|
|
27
27
|
udid: String
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
|
-
collection
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
);
|
|
30
|
+
collection: 'testDevice'
|
|
31
|
+
})
|
|
32
|
+
)
|
|
34
33
|
|
|
35
|
-
module.exports = TestDevice
|
|
34
|
+
module.exports = TestDevice
|
|
@@ -3,22 +3,21 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
let mongoose = require('mongoose')
|
|
7
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let TestDeviceCluster = mongoose.model('TestDeviceCluster', new mongoose.Schema(
|
|
10
10
|
{
|
|
11
11
|
name: String,
|
|
12
12
|
devices: [],
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
'creationTime': {type: Date, default: Date.now},
|
|
14
|
+
'lastUpdateTime': {type: Date, default: Date.now},
|
|
15
15
|
comments: String,
|
|
16
16
|
state: {type: String, default: StateEnum.active}
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
collection
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
);
|
|
19
|
+
collection: 'testDeviceCluster'
|
|
20
|
+
})
|
|
21
|
+
)
|
|
23
22
|
|
|
24
|
-
module.exports = TestDeviceCluster
|
|
23
|
+
module.exports = TestDeviceCluster
|
package/models/TestInstance.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
let mongoose = require('mongoose')
|
|
7
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let TestInstance = mongoose.model('TestInstance', new mongoose.Schema(
|
|
10
10
|
{
|
|
11
11
|
name: String,
|
|
12
12
|
scenarioId: String,
|
|
@@ -17,17 +17,16 @@ var TestInstance = mongoose.model('TestInstance', new mongoose.Schema(
|
|
|
17
17
|
duration: Number,
|
|
18
18
|
endPoint: String,
|
|
19
19
|
trackedLocations: {type: Array, default: []},
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
'creationTime': {type: Date, default: Date.now},
|
|
21
|
+
'lastUpdateTime': {type: Date, default: Date.now},
|
|
22
22
|
state: {type: String, default: StateEnum.active},
|
|
23
23
|
comments: String,
|
|
24
24
|
isProduction: Boolean,
|
|
25
25
|
sdkVersion: String
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
|
-
collection
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
);
|
|
28
|
+
collection: 'testInstance'
|
|
29
|
+
})
|
|
30
|
+
)
|
|
32
31
|
|
|
33
|
-
module.exports = TestInstance
|
|
32
|
+
module.exports = TestInstance
|
package/models/TestScenario.js
CHANGED
|
@@ -3,27 +3,26 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
let mongoose = require('mongoose')
|
|
7
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let TestScenario = mongoose.model('TestScenario', new mongoose.Schema(
|
|
10
10
|
{
|
|
11
11
|
name: String,
|
|
12
12
|
apiKey: String,
|
|
13
13
|
customerApiKey: String,
|
|
14
14
|
email: String,
|
|
15
15
|
package: String,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
'creationTime': {type: Date, default: Date.now},
|
|
17
|
+
'lastUpdateTime': {type: Date, default: Date.now},
|
|
18
18
|
state: {type: String, default: StateEnum.active},
|
|
19
19
|
numberZones: String,
|
|
20
20
|
comments: String,
|
|
21
21
|
environment: String
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
collection
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
);
|
|
24
|
+
collection: 'testScenario'
|
|
25
|
+
})
|
|
26
|
+
)
|
|
28
27
|
|
|
29
|
-
module.exports = TestScenario
|
|
28
|
+
module.exports = TestScenario
|
package/models/TimeOfDayRange.js
CHANGED
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
var SchemaTypes = mongoose.Schema.Types;
|
|
6
|
+
let mongoose = require('mongoose')
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
))
|
|
22
|
-
|
|
8
|
+
let TimeOfDayRange = mongoose.model('TimeOfDayRange', mongoose.Schema({
|
|
9
|
+
start: {
|
|
10
|
+
'_class': {type: String, default: 'au.com.bluedot.schedule.model.value.TimeOfDay'},
|
|
11
|
+
hour: Number,
|
|
12
|
+
seconds: Number,
|
|
13
|
+
minute: Number
|
|
14
|
+
},
|
|
15
|
+
interval: Number
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
_id: false
|
|
19
|
+
}
|
|
20
|
+
))
|
|
21
|
+
|
|
22
|
+
module.exports = TimeOfDayRange
|
|
@@ -1,26 +1,44 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
let schema = {
|
|
5
|
+
guid: {type: String, default: uuidv4},
|
|
6
|
+
fromTime: {type: Number, required: [true, 'time is required. '], min: 0, max: 86400},
|
|
7
|
+
toTime: {type: Number, required: true, min: 0, max: 86400, validate: {isAsync: true, validator: validateTime}}
|
|
8
|
+
}
|
|
9
|
+
let TimeOfDayRangeFilterSchema = new mongoose.Schema(
|
|
10
|
+
schema,
|
|
10
11
|
{
|
|
11
|
-
_id
|
|
12
|
-
versionKey
|
|
13
|
-
}
|
|
14
|
-
|
|
12
|
+
_id: false,
|
|
13
|
+
versionKey: false
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
TimeOfDayRangeFilterSchema.add({
|
|
17
|
+
type:
|
|
18
|
+
{type: String, required: true}
|
|
19
|
+
})
|
|
15
20
|
|
|
16
|
-
function validateTime(toTime){
|
|
17
|
-
let
|
|
21
|
+
function validateTime (toTime, cb) {
|
|
22
|
+
let magicCallback = cb
|
|
23
|
+
let fromTime = this.fromTime
|
|
18
24
|
|
|
19
|
-
if(fromTime
|
|
20
|
-
|
|
25
|
+
if (fromTime === toTime) {
|
|
26
|
+
return magicCallback(false, 'fromTime and toTime cannot be same')
|
|
21
27
|
}
|
|
28
|
+
return magicCallback(true)
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
// optional mongoose
|
|
32
|
+
let model = (mongooseInstance) => {
|
|
33
|
+
let TimeOfDayRangeFilter
|
|
34
|
+
if (mongooseInstance) {
|
|
35
|
+
TimeOfDayRangeFilter = mongooseInstance.model('TimeOfDayRangeFilterSchema', TimeOfDayRangeFilterSchema)
|
|
36
|
+
} else {
|
|
37
|
+
TimeOfDayRangeFilter = mongoose.model('TimeOfDayRangeFilterSchema', TimeOfDayRangeFilterSchema)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return TimeOfDayRangeFilter
|
|
41
|
+
}
|
|
25
42
|
|
|
26
|
-
|
|
43
|
+
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
44
|
+
module.exports = { Model: model, Schema: TimeOfDayRangeFilterSchema, timeOfDayRangeFilterSchema: schema }
|