@bluedot-innovation/models 4.0.0 → 5.0.1
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 +42 -0
- package/.gitlab-ci.yml +44 -0
- package/CHANGELOG.md +156 -0
- package/Models.js +55 -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 +73 -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__/beacon/beacon.data.json +15 -0
- package/__tests__/beacon/beacon.rules.json +13 -0
- package/__tests__/beacon/beacon.spec.js +104 -0
- package/__tests__/condition/beacon/beaconFilter.data.json +1 -0
- package/__tests__/condition/beacon/beaconFilter.rules.json +3 -0
- package/__tests__/condition/beacon/beaconFilter.spec.js +1 -0
- package/__tests__/condition/dayRange/dayRange.data.json +5 -0
- package/__tests__/condition/dayRange/dayRange.rules.json +3 -0
- package/__tests__/condition/dayRange/dayRange.spec.js +95 -0
- package/__tests__/condition/percentageCrossed/travelPath.data.json +5 -0
- package/__tests__/condition/percentageCrossed/travelPath.rules.json +3 -0
- package/__tests__/condition/percentageCrossed/travelPath.spec.js +72 -0
- package/__tests__/condition/speed/speed.data.json +5 -0
- package/__tests__/condition/speed/speed.rules.json +3 -0
- package/__tests__/condition/speed/speed.spec.js +92 -0
- package/__tests__/condition/timeActive/timeActive.data.json +5 -0
- package/__tests__/condition/timeActive/timeActive.rules.json +14 -0
- package/__tests__/condition/timeActive/timeActive.spec.js +103 -0
- package/__tests__/condition/travelDirection/travelDirection.data.json +5 -0
- package/__tests__/condition/travelDirection/travelDirection.rules.json +3 -0
- package/__tests__/condition/travelDirection/travelDirection.spec.js +141 -0
- package/__tests__/dailyStats/checkDailyStats.js +31 -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 +87 -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/geoline/geoline.data.json +46 -0
- package/__tests__/geofeature/geoline/geoline.rules.json +3 -0
- package/__tests__/geofeature/geoline/geoline.spec.js +70 -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 +132 -0
- package/__tests__/geofeature/zoneBeacon/zoneBeacon.data.json +16 -0
- package/__tests__/geofeature/zoneBeacon/zoneBeacon.rules.json +13 -0
- package/__tests__/geofeature/zoneBeacon/zoneBeacon.spec.js +71 -0
- package/__tests__/monthlyStats/monthlyStats.data.json +29 -0
- package/__tests__/monthlyStats/monthlyStats.spec.js +75 -0
- package/__tests__/project/project.data.json +18 -0
- package/__tests__/project/project.remote.config.json +122 -0
- package/__tests__/project/project.rules.json +9 -0
- package/__tests__/project/project.spec.js +100 -0
- package/__tests__/ruleRequestAggregation/ruleRequestAggregation.data.json +8 -0
- package/__tests__/ruleRequestAggregation/ruleRequestAggregation.spec.js +78 -0
- package/__tests__/setup.js +7 -0
- package/__tests__/user/user.data.js +19 -0
- package/__tests__/user/user.rules.js +8 -0
- package/__tests__/user/user.spec.js +130 -0
- package/__tests__/utils/utils.spec.js +26 -0
- package/__tests__/zone/zone.action.spec.js +50 -0
- package/__tests__/zone/zone.condition.spec.js +94 -0
- package/__tests__/zone/zone.data.json +157 -0
- package/__tests__/zone/zone.geofeatures.spec.js +75 -0
- package/__tests__/zone/zone.spec.js +140 -0
- package/constants/errorMessages.js +2 -0
- package/helpers.js +117 -0
- package/models/Account.js +50 -0
- package/models/AdminPortalUser.js +10 -11
- package/models/Beacon.js +84 -32
- package/models/Contract.js +37 -38
- package/models/CustomerLogin.js +9 -10
- package/models/DBEvent.js +13 -14
- package/models/DailyStats.js +7 -7
- package/models/DeviceRulesRequest.js +27 -28
- package/models/MessageAction.js +26 -26
- package/models/MonthlyStats.js +35 -19
- 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/Project.js +63 -0
- package/models/RuleRequestAggregation.js +33 -17
- package/models/SingleUseToken.js +7 -8
- 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/UrlAction.js +37 -0
- package/models/User.js +61 -0
- package/models/Zone.js +126 -0
- package/models/ZoneUIState.js +18 -18
- package/models/conditions/DayRange.js +44 -0
- package/models/conditions/Speed.js +42 -0
- package/models/conditions/TimeActive.js +50 -0
- package/models/conditions/TravelDirection.js +59 -0
- package/models/conditions/TravelPath.js +36 -0
- package/models/geofeatures/BoundingBox.js +44 -0
- package/models/geofeatures/Circle.js +39 -0
- package/models/geofeatures/Geoline.js +34 -0
- package/models/geofeatures/Polygon.js +45 -0
- package/models/geofeatures/ZoneBeacon.js +28 -0
- package/package.json +30 -6
- package/schemas/AccuracySuppression.js +14 -0
- package/schemas/AndroidConfig.js +35 -0
- package/schemas/IosConfig.js +38 -0
- package/schemas/MultiLineStringGeometry.js +14 -0
- package/schemas/Point.js +13 -0
- package/schemas/PointGeometry.js +14 -0
- package/schemas/PolygonGeometry.js +14 -0
- package/schemas/ProjectPermission.js +21 -0
- package/schemas/StarvationDetection.js +11 -0
- package/schemas/Telemetry.js +36 -0
- package/schemas/Webhook.js +22 -0
- package/utils/index.js +39 -0
- package/utils/validators.js +6 -0
- package/validators/checkDistanceBetweenVertices.js +21 -0
- package/yarn.lock +2796 -0
- package/models/AdminUser.js +0 -10
- package/models/Application.js +0 -38
- package/models/ApplicationNotificationAction.js +0 -30
- package/models/ApplicationUsage.js +0 -11
- package/models/BeaconFilter.js +0 -23
- package/models/BearingFilter.js +0 -19
- package/models/BoundingBox.js +0 -17
- package/models/Circle.js +0 -21
- package/models/ConfigurationParameters.js +0 -20
- package/models/Customer.js +0 -38
- package/models/DateRangeFilter.js +0 -20
- package/models/Fence.js +0 -21
- package/models/FormattedBeacon.js +0 -16
- package/models/FormattedCircle.js +0 -12
- package/models/FormattedConditions.js +0 -11
- package/models/FormattedDateRange.js +0 -11
- package/models/FormattedPercentageCrossed.js +0 -12
- package/models/FormattedPoint.js +0 -10
- package/models/FormattedPolygon.js +0 -11
- package/models/FormattedPolyline.js +0 -11
- package/models/FormattedRectangle.js +0 -12
- package/models/FormattedTimeActive.js +0 -17
- package/models/FormattedZone.js +0 -28
- package/models/GeoFence.js +0 -23
- package/models/Geofeature.js +0 -26
- package/models/PercentageCrossedFilter.js +0 -19
- package/models/Point.js +0 -20
- package/models/Polygon.js +0 -18
- package/models/Polyline.js +0 -18
- package/models/PropertyMapping.js +0 -17
- package/models/Reference.js +0 -19
- package/models/SequenceFilter.js +0 -18
- package/models/SimpleCheckInZone.js +0 -29
- package/models/SoundAction.js +0 -28
- package/models/SpeedFilter.js +0 -19
- package/models/TimeOfDayRangeFilter.js +0 -19
- package/models/URLAction.js +0 -31
- package/models/VibrationAction.js +0 -28
- package/models/property.js +0 -25
- package/package-lock.json.bak +0 -170
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "beacon",
|
|
3
|
+
"name": "create beacon",
|
|
4
|
+
"proximityUUID": "23a01af0-232a-4518-9c0e-323fb773f5ef",
|
|
5
|
+
"location": {
|
|
6
|
+
"latitude": -37.8159544565362,
|
|
7
|
+
"longitude": 144.9723565578461
|
|
8
|
+
},
|
|
9
|
+
"beaconType": "Both",
|
|
10
|
+
"major": 10000,
|
|
11
|
+
"minor": 56466,
|
|
12
|
+
"txPower": -77,
|
|
13
|
+
"proximity": "Near",
|
|
14
|
+
"macAddress": "01:17:c5:31:84:19",
|
|
15
|
+
"accountId": "90a2ed18-86be-48e7-948b-393b8b679ef6"
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"requiredFields":["name", "location", "beaconType"],
|
|
3
|
+
"dependentRequiredFields": [
|
|
4
|
+
{
|
|
5
|
+
"property": "beaconType",
|
|
6
|
+
"pairings": [
|
|
7
|
+
{"value": "ios", "requiredFields": ["major", "minor"]},
|
|
8
|
+
{"value": "android", "requiredFields": ["txPower", "macAddress"]},
|
|
9
|
+
{"value": "both", "requiredFields": ["major", "minor", "txPower", "macAddress"]}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let ZoneBeaconModel = require('../../../Models').ZoneBeacon(mongoose)
|
|
6
|
+
let ZoneBeaconModelBuiltInMongoose = require('../../../Models').ZoneBeacon()
|
|
7
|
+
let describe = require('mocha').describe
|
|
8
|
+
let it = require('mocha').it
|
|
9
|
+
let chai = require('chai')
|
|
10
|
+
|
|
11
|
+
let assert = chai.assert
|
|
12
|
+
let mocha = require('mocha')
|
|
13
|
+
let beforeEach = mocha.beforeEach
|
|
14
|
+
|
|
15
|
+
let rules = require('./zoneBeacon.rules.json')
|
|
16
|
+
|
|
17
|
+
let zoneBeacon
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
zoneBeacon = JSON.parse(JSON.stringify(require('./zoneBeacon.data.json')))
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
describe('ZoneBeacon', () => {
|
|
24
|
+
describe('Valid ZoneBeacon', () => {
|
|
25
|
+
it('should validate a valid zoneBeacon ', (done) => {
|
|
26
|
+
const ZoneBeacon = new ZoneBeaconModel(zoneBeacon)
|
|
27
|
+
ZoneBeacon.validate((err, res) => {
|
|
28
|
+
assert.notExists(res)
|
|
29
|
+
assert(err === null, 'err should equals null')
|
|
30
|
+
done()
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
it('should validate a valid zoneBeacon ', (done) => {
|
|
34
|
+
const ZoneBeacon = new ZoneBeaconModelBuiltInMongoose(zoneBeacon)
|
|
35
|
+
ZoneBeacon.validate((err, res) => {
|
|
36
|
+
assert.notExists(res)
|
|
37
|
+
assert(err === null, 'err should equals null')
|
|
38
|
+
done()
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
describe('Invalid ZoneBeacon', () => {
|
|
44
|
+
it('should not validate a zoneBeacon with invalid ZoneBeacon', (done) => {
|
|
45
|
+
delete zoneBeacon[rules.requiredFields[0]]
|
|
46
|
+
let ZoneBeacon = new ZoneBeaconModel(zoneBeacon)
|
|
47
|
+
ZoneBeacon.validate((err, res) => {
|
|
48
|
+
assert.exists(err, 'err object should exist')
|
|
49
|
+
assert.isObject(err)
|
|
50
|
+
done()
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
describe('check each required property of the model and validate that it is present', () => {
|
|
54
|
+
let requiredFields = rules.requiredFields
|
|
55
|
+
requiredFields.map((i) => {
|
|
56
|
+
it(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
|
|
57
|
+
// delete i from geofeatures' zoneBeacon child
|
|
58
|
+
delete zoneBeacon[i]
|
|
59
|
+
let ZoneBeacon = new ZoneBeaconModel(zoneBeacon)
|
|
60
|
+
ZoneBeacon.validate((err, res) => {
|
|
61
|
+
assert.notExists(res)
|
|
62
|
+
assert.exists(err, 'err object should exist')
|
|
63
|
+
assert.isObject(err)
|
|
64
|
+
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
65
|
+
done()
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_id": "709aa8f4-3c53-496d-8824-73cb73ce6963",
|
|
3
|
+
"creationTime": "2017-12-31T23:17:30.658Z",
|
|
4
|
+
"monthOfCount": "2017-12-31T23:17:30.658Z",
|
|
5
|
+
"customerId": "313ff409-0bb7-4af5-8cc9-9d0ff3631b9f",
|
|
6
|
+
"totalMonthlyUsers": 23,
|
|
7
|
+
"applications": [
|
|
8
|
+
{
|
|
9
|
+
"applicationId": "d49fdf10-3744-462c-84f8-abad444d7044",
|
|
10
|
+
"monthlyUsers": 3
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"applicationId": "d26b75ad-42ca-401c-b526-d745105886cd",
|
|
14
|
+
"monthlyUsers": 12
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"applicationId": "6a2d898f-6894-41b8-8e7b-3445872f27d3",
|
|
18
|
+
"monthlyUsers": 3
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"applicationId": "df9dd8a9-e6f1-417b-88c4-6d314a64ab80",
|
|
22
|
+
"monthlyUsers": 4
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"applicationId": "ab45514e-0d66-47dd-9508-b19c8cad1c4e",
|
|
26
|
+
"monthlyUsers": 1
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let MonthlyStatsModel = require('../../Models').MonthlyStat(mongoose)
|
|
6
|
+
let MonthlyStatsModelBuiltInMongoose = require('../../Models').MonthlyStat()
|
|
7
|
+
let describe = require('mocha').describe
|
|
8
|
+
let it = require('mocha').it
|
|
9
|
+
let chai = require('chai')
|
|
10
|
+
|
|
11
|
+
let assert = chai.assert
|
|
12
|
+
let mocha = require('mocha')
|
|
13
|
+
let beforeEach = mocha.beforeEach
|
|
14
|
+
|
|
15
|
+
let monthlyStats
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
monthlyStats = JSON.parse(JSON.stringify(require('./monthlyStats.data.json')))
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('MonthlyStat', () => {
|
|
22
|
+
describe('Valid MonthlyStat document', () => {
|
|
23
|
+
it('should validate a valid MonthlyStat document ', (done) => {
|
|
24
|
+
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
25
|
+
MonthlyStats.validate((err, res) => {
|
|
26
|
+
assert.notExists(res)
|
|
27
|
+
assert(err === null, 'err should equals null')
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
it('should validate a valid MonthlyStat document ', (done) => {
|
|
32
|
+
let MonthlyStats = new MonthlyStatsModelBuiltInMongoose(monthlyStats)
|
|
33
|
+
MonthlyStats.validate((err, res) => {
|
|
34
|
+
assert.notExists(res)
|
|
35
|
+
assert(err === null, 'err should equals null')
|
|
36
|
+
done()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
it('should not accept a invalid customerId', (done) => {
|
|
40
|
+
monthlyStats.customerId = 'invalid-customerId'
|
|
41
|
+
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
42
|
+
MonthlyStats.validate((err, res) => {
|
|
43
|
+
assert.exists(err, 'invalid customerId')
|
|
44
|
+
assert.isObject(err)
|
|
45
|
+
done()
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
it('should not accept a invalid applicationId', (done) => {
|
|
49
|
+
const invalidAppId = {
|
|
50
|
+
applicationId: 'invalid-applicationId',
|
|
51
|
+
monthlyUsers: 0
|
|
52
|
+
}
|
|
53
|
+
monthlyStats.applications.push(invalidAppId)
|
|
54
|
+
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
55
|
+
MonthlyStats.validate((err, res) => {
|
|
56
|
+
assert.exists(err, 'invalid customerId')
|
|
57
|
+
assert.isObject(err)
|
|
58
|
+
done()
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
it('should not accept a negative monthlyUsers value', (done) => {
|
|
62
|
+
const invalidAppId = {
|
|
63
|
+
applicationId: 'd49fdf10-3744-462c-84f8-abad444d7044',
|
|
64
|
+
monthlyUsers: -100
|
|
65
|
+
}
|
|
66
|
+
monthlyStats.applications.push(invalidAppId)
|
|
67
|
+
let MonthlyStats = new MonthlyStatsModel(monthlyStats)
|
|
68
|
+
MonthlyStats.validate((err, res) => {
|
|
69
|
+
assert.exists(err, 'Path `monthlyUsers` (-100) is less than minimum allowed value (0)')
|
|
70
|
+
assert.isObject(err)
|
|
71
|
+
done()
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"state": "ACTIVE",
|
|
3
|
+
"nextRuleUpdateInterval": 3600,
|
|
4
|
+
"lastUpdateTime": "2018-02-14T04:12:02.103Z",
|
|
5
|
+
"creationTime": "2018-02-14T04:12:02.103Z",
|
|
6
|
+
"name": "A New Project",
|
|
7
|
+
"accountId":"b0824b76-ce73-4fcf-81f8-1b63edb1114e",
|
|
8
|
+
"webhooks": {
|
|
9
|
+
"type": "trigger",
|
|
10
|
+
"url": "https://webhooklistener.bluedotinnovation.com",
|
|
11
|
+
"enabled": true,
|
|
12
|
+
"headers" : {
|
|
13
|
+
"securityToken" : "value"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"firebaseApiKey": "88888888-4444-4444-4444-121212121212",
|
|
17
|
+
"apiKey": "88888888-4444-4444-4444-123412341234"
|
|
18
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"state": "ACTIVE",
|
|
3
|
+
"nextRuleUpdateInterval": 3600,
|
|
4
|
+
"lastUpdateTime": "2018-02-14T04:12:02.103Z",
|
|
5
|
+
"creationTime": "2018-02-14T04:12:02.103Z",
|
|
6
|
+
"name": "A New Project",
|
|
7
|
+
"accountId":"b0824b76-ce73-4fcf-81f8-1b63edb1114e",
|
|
8
|
+
"webhooks": {
|
|
9
|
+
"type": "trigger",
|
|
10
|
+
"url": "https://webhooklistener.bluedotinnovation.com",
|
|
11
|
+
"enabled": true,
|
|
12
|
+
"headers" : {
|
|
13
|
+
"securityToken" : "value"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"firebaseApiKey": "88888888-4444-4444-4444-121212121212",
|
|
17
|
+
"apiKey": "88888888-4444-4444-4444-123412341234",
|
|
18
|
+
"configurationParameters": {
|
|
19
|
+
"androidConfig": {
|
|
20
|
+
"triggeringOnWifiAccuracyThreshold": 100.0,
|
|
21
|
+
"triggeringOnGpsAccuracyThreshold": 20.0,
|
|
22
|
+
"trackingOnGpsAccuracyThreshold": 200.0,
|
|
23
|
+
"checkoutTimeAccuracy": 60.0,
|
|
24
|
+
"checkoutDistanceAccuracy": 50.0,
|
|
25
|
+
"beaconReevaluationDistance": 25.0,
|
|
26
|
+
"beaconActivationCoefficient": 0.5,
|
|
27
|
+
"beaconActivationDistance": 30.0,
|
|
28
|
+
"endpointUrl": "https://www.pointapi.bluedot.com.au/pointapi-v1/",
|
|
29
|
+
"filteringEnabled": false,
|
|
30
|
+
"applicationLoggingEnabled": false,
|
|
31
|
+
"telemetry" : {
|
|
32
|
+
"telemetryLoggingEnabled" : false,
|
|
33
|
+
"telemetryBatchSize" : 25,
|
|
34
|
+
"telemetryTimeOut": 30.0,
|
|
35
|
+
"telemetryEventsBlacklist" : [
|
|
36
|
+
"location",
|
|
37
|
+
"batteryLevel",
|
|
38
|
+
"beaconDiscovered",
|
|
39
|
+
"beaconDiscoveryStarted",
|
|
40
|
+
"beaconLost",
|
|
41
|
+
"gpsAccuracyRequested",
|
|
42
|
+
"rulesDownloadRequested",
|
|
43
|
+
"rulesLoaded",
|
|
44
|
+
"zoneCheckedIntoFence",
|
|
45
|
+
"zoneCheckedIntoBeacon",
|
|
46
|
+
"zoneCheckedOutFromBeacon",
|
|
47
|
+
"zoneCheckedOutFromFence",
|
|
48
|
+
"sdkStarted",
|
|
49
|
+
"sdkStopped",
|
|
50
|
+
"noMotion",
|
|
51
|
+
"log",
|
|
52
|
+
"heading",
|
|
53
|
+
"fenceCrossed",
|
|
54
|
+
"rulesDownloadBegin",
|
|
55
|
+
"rulesDownloadEnd" ]
|
|
56
|
+
},
|
|
57
|
+
"useCaseType" : "Retail",
|
|
58
|
+
"maximumPageSize": 256,
|
|
59
|
+
"triggerEngine": "BD"
|
|
60
|
+
},
|
|
61
|
+
"iosConfig": {
|
|
62
|
+
"triggeringOnWifiAccuracyThreshold" : 70.0,
|
|
63
|
+
"triggeringOnGpsAccuracyThreshold" : 30.0,
|
|
64
|
+
"trackingOnGpsAccuracyThreshold" : 400.0,
|
|
65
|
+
"checkoutTimeAccuracy" : 60.0,
|
|
66
|
+
"checkoutDistanceAccuracy" : 50.0,
|
|
67
|
+
"beaconReevaluationDistance" : 10.0,
|
|
68
|
+
"beaconActivationCoefficient" : 0.5,
|
|
69
|
+
"beaconActivationDistance" : 30.0,
|
|
70
|
+
"periodicPollingEnabled" : true,
|
|
71
|
+
"triggeringOnPollingLocationBasicThreshold" : 1000.0,
|
|
72
|
+
"triggeringOnPollingLocationFurtherThreshold" : 3000.0,
|
|
73
|
+
"triggeringOnPollingLocationFarthestThreshold" : 5000.0,
|
|
74
|
+
"focalDistanceAccuracyCoefficient" : 0.9,
|
|
75
|
+
"accelerometerEnablementThreshold" : 1000.0,
|
|
76
|
+
"endpointUrl" : "https://www.pointapi.bluedot.com.au/pointapi-v1/",
|
|
77
|
+
"filteringEnabled" : false,
|
|
78
|
+
"applicationLoggingEnabled" : false,
|
|
79
|
+
"useCaseType" : "Retail",
|
|
80
|
+
"accuracySuppression" : {
|
|
81
|
+
"accuracySuppressionEnabled" : false,
|
|
82
|
+
"accuracySuppressionMaxAccuracy" : 5.0,
|
|
83
|
+
"accuracySuppressionMaxAccuracyTimeInterval": 30.0,
|
|
84
|
+
"accuracySuppressionMinAccuracy" : 3000.0,
|
|
85
|
+
"accuracySuppressionMinAccuracyTimeInterval" : 60.0,
|
|
86
|
+
"accuracySuppressionGracePeriod" : 600.0
|
|
87
|
+
},
|
|
88
|
+
"starvationDetector" : {
|
|
89
|
+
"starvationDetectorEnabled" : false,
|
|
90
|
+
"starvationDetectorSecsAllowedPerMetre" : 0.0225,
|
|
91
|
+
"starvationDetectorMinAllowedStarvationTimeInterval" : 30.0
|
|
92
|
+
},
|
|
93
|
+
"telemetry" : {
|
|
94
|
+
"telemetryLoggingEnabled" : false,
|
|
95
|
+
"telemetryBatchSize" : 25,
|
|
96
|
+
"telemetryTimeOut": 30.0,
|
|
97
|
+
"telemetryEventsBlacklist" : [ "location",
|
|
98
|
+
"batteryLevel",
|
|
99
|
+
"beaconDiscovered",
|
|
100
|
+
"beaconDiscoveryStarted",
|
|
101
|
+
"beaconLost",
|
|
102
|
+
"gpsAccuracyRequested",
|
|
103
|
+
"rulesDownloadRequested",
|
|
104
|
+
"rulesLoaded",
|
|
105
|
+
"zoneCheckedIntoFence",
|
|
106
|
+
"zoneCheckedIntoBeacon",
|
|
107
|
+
"zoneCheckedOutFromBeacon",
|
|
108
|
+
"zoneCheckedOutFromFence",
|
|
109
|
+
"sdkStarted",
|
|
110
|
+
"sdkStopped",
|
|
111
|
+
"noMotion",
|
|
112
|
+
"log",
|
|
113
|
+
"heading",
|
|
114
|
+
"fenceCrossed",
|
|
115
|
+
"rulesDownloadBegin",
|
|
116
|
+
"rulesDownloadEnd" ]
|
|
117
|
+
},
|
|
118
|
+
"maximumPageSize": 256,
|
|
119
|
+
"triggerEngine": "BD"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"requiredFields": ["name", "nextRuleUpdateInterval", "accountId"],
|
|
3
|
+
"customValidators": [
|
|
4
|
+
{"name": "nextRuleUpdateInterval", "invalidInput": [5000.5556]},
|
|
5
|
+
{"name": "lastUpdateTime", "invalidInput": ["21/07/2017", "saturday"]},
|
|
6
|
+
{"name": "creationTime", "invalidInput": ["21/07/2017", "thursday"]},
|
|
7
|
+
{"name": "accountId", "invalidInput": ["21/07/2017", 21072017, "qwe123-21321-ad"]}
|
|
8
|
+
]
|
|
9
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let ProjectModel = require('../../Models').Project(mongoose)
|
|
6
|
+
let ProjectModelBuiltInMongoose = require('../../Models').Project()
|
|
7
|
+
let testCase = require('mocha').describe
|
|
8
|
+
let assertions = require('mocha').it
|
|
9
|
+
let chai = require('chai')
|
|
10
|
+
let assert = chai.assert
|
|
11
|
+
let mocha = require('mocha')
|
|
12
|
+
let beforeEach = mocha.beforeEach
|
|
13
|
+
let rules = require('./project.rules.json')
|
|
14
|
+
|
|
15
|
+
let project
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
project = JSON.parse(JSON.stringify(require('./project.data.json')))
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
testCase('Project', () => {
|
|
22
|
+
testCase('Valid Project ', () => {
|
|
23
|
+
assertions('should validate a valid project ', (done) => {
|
|
24
|
+
let Project = new ProjectModel(project)
|
|
25
|
+
Project.validate((err, res) => {
|
|
26
|
+
assert.notExists(res)
|
|
27
|
+
assert(err === null, 'err equals null')
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
assertions('should validate a valid project with android config', (done) => {
|
|
32
|
+
let project = JSON.parse(JSON.stringify(require('./project.remote.config.json')))
|
|
33
|
+
let Project = new ProjectModel(project)
|
|
34
|
+
Project.validate((err, res) => {
|
|
35
|
+
assert.notExists(err)
|
|
36
|
+
done()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
testCase('Valid Project ', () => {
|
|
41
|
+
assertions('should validate a valid project ', (done) => {
|
|
42
|
+
let Project = new ProjectModelBuiltInMongoose(project)
|
|
43
|
+
Project.validate((err, res) => {
|
|
44
|
+
assert.notExists(res)
|
|
45
|
+
assert(err === null, 'err equals null')
|
|
46
|
+
done()
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
testCase('Invalid Project ', () => {
|
|
51
|
+
assertions('should not validate if webhook headers have more than 1 key value pair ', (done) => {
|
|
52
|
+
|
|
53
|
+
project.webhooks.headers.anotherKey = 'anotherValue'
|
|
54
|
+
|
|
55
|
+
let Project = new ProjectModel(project)
|
|
56
|
+
Project.validate((err, res) => {
|
|
57
|
+
assert.exists(err)
|
|
58
|
+
assert.match(err.message, /1 key <-> value pair/)
|
|
59
|
+
done()
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
testCase('recursive property check', () => {
|
|
63
|
+
let requiredFields = rules.requiredFields
|
|
64
|
+
requiredFields.map((i) => {
|
|
65
|
+
assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
|
|
66
|
+
project = JSON.parse(JSON.stringify(project))
|
|
67
|
+
delete project[i]
|
|
68
|
+
let Project = new ProjectModel(project)
|
|
69
|
+
Project.validate((err, res) => {
|
|
70
|
+
assert.notExists(res)
|
|
71
|
+
assert.exists(err, 'err object should exist')
|
|
72
|
+
assert.isObject(err)
|
|
73
|
+
assert.nestedProperty(err, `errors.${i}`, 'error should have a radius property')
|
|
74
|
+
done()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
testCase('recursive invalid entry check', () => {
|
|
81
|
+
let invalidProps = rules.customValidators
|
|
82
|
+
invalidProps.map((i) => {
|
|
83
|
+
i.invalidInput.map((j) => {
|
|
84
|
+
assertions(`should throw an error with property '${i.name}' if '${i.name}' is invalid => ${i.name} = ${j}`, (done) => {
|
|
85
|
+
project = JSON.parse(JSON.stringify(project))
|
|
86
|
+
project[i.name] = j
|
|
87
|
+
let Project = new ProjectModel(project)
|
|
88
|
+
Project.validate((err, res) => {
|
|
89
|
+
assert.notExists(res)
|
|
90
|
+
assert.exists(err, 'err object should exist')
|
|
91
|
+
assert.isObject(err)
|
|
92
|
+
assert.nestedProperty(err, `errors.${i.name}`, `error should have a ${i} property`)
|
|
93
|
+
done()
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let RuleRequestAggregationModel = require('../../Models').RuleRequestAggregation(mongoose)
|
|
6
|
+
let RuleRequestAggregationModelBuiltInMongoose = require('../../Models').RuleRequestAggregation()
|
|
7
|
+
let testCase = require('mocha').describe
|
|
8
|
+
let assertions = require('mocha').it
|
|
9
|
+
let chai = require('chai')
|
|
10
|
+
|
|
11
|
+
let assert = chai.assert
|
|
12
|
+
let mocha = require('mocha')
|
|
13
|
+
let beforeEach = mocha.beforeEach
|
|
14
|
+
|
|
15
|
+
let ruleRequestAggregation
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
ruleRequestAggregation = JSON.parse(JSON.stringify(require('./ruleRequestAggregation.data.json')))
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
testCase('RuleRequestAggregation', () => {
|
|
22
|
+
testCase('Valid RuleRequestAggregation document', () => {
|
|
23
|
+
assertions('should validate a valid RuleRequestAggregation document ', (done) => {
|
|
24
|
+
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
25
|
+
RuleRequestAggregation.validate((err, res) => {
|
|
26
|
+
assert.notExists(res)
|
|
27
|
+
assert(err === null, 'err should equals null')
|
|
28
|
+
done()
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
assertions('should validate a valid RuleRequestAggregation document ', (done) => {
|
|
32
|
+
let RuleRequestAggregation = new RuleRequestAggregationModelBuiltInMongoose(ruleRequestAggregation)
|
|
33
|
+
RuleRequestAggregation.validate((err, res) => {
|
|
34
|
+
assert.notExists(res)
|
|
35
|
+
assert(err === null, 'err should equals null')
|
|
36
|
+
done()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
assertions('should not accept a invalid customerId', (done) => {
|
|
40
|
+
ruleRequestAggregation.customerId = 'invalid-customerId'
|
|
41
|
+
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
42
|
+
RuleRequestAggregation.validate((err, res) => {
|
|
43
|
+
assert.exists(err, 'invalid customerId')
|
|
44
|
+
assert.isObject(err)
|
|
45
|
+
done()
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
assertions('should not accept a invalid applicationId', (done) => {
|
|
49
|
+
ruleRequestAggregation.applicationId = 'invalid-applicationId'
|
|
50
|
+
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
51
|
+
RuleRequestAggregation.validate((err, res) => {
|
|
52
|
+
assert.exists(err, 'invalid applicationId')
|
|
53
|
+
assert.isObject(err)
|
|
54
|
+
done()
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
assertions('should not accept a negative iosCount value', (done) => {
|
|
58
|
+
const negativeIosCount = -100
|
|
59
|
+
ruleRequestAggregation.iosCount = negativeIosCount
|
|
60
|
+
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
61
|
+
RuleRequestAggregation.validate((err, res) => {
|
|
62
|
+
assert.exists(err, 'Path `androidCount` (' + negativeIosCount + ') is less than minimum allowed value (0)')
|
|
63
|
+
assert.isObject(err)
|
|
64
|
+
done()
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
assertions('should not accept a negative androidCount value', (done) => {
|
|
68
|
+
const negativeAndroidCount = -100
|
|
69
|
+
ruleRequestAggregation.androidCount = negativeAndroidCount
|
|
70
|
+
let RuleRequestAggregation = new RuleRequestAggregationModel(ruleRequestAggregation)
|
|
71
|
+
RuleRequestAggregation.validate((err, res) => {
|
|
72
|
+
assert.exists(err, 'Path `androidCount` (' + negativeAndroidCount + ') is less than minimum allowed value (0)')
|
|
73
|
+
assert.isObject(err)
|
|
74
|
+
done()
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
username: 'test@bluedot.io',
|
|
3
|
+
email: 'test@bluedot.io',
|
|
4
|
+
password: 'jfmamjasond',
|
|
5
|
+
firstName: 'John',
|
|
6
|
+
lastName: 'Citizen',
|
|
7
|
+
phoneNumber: '23429384',
|
|
8
|
+
state: 'ACTIVE',
|
|
9
|
+
lastUpdateTime: '2018-02-14T04:12:02.103Z',
|
|
10
|
+
creationTime: '2018-02-14T04:12:02.103Z',
|
|
11
|
+
isAdmin: true,
|
|
12
|
+
accountId: '37ac5be3-60ec-4fb7-9f88-a4f6e8895f81',
|
|
13
|
+
projectPermissions: [
|
|
14
|
+
{
|
|
15
|
+
permissionLevel: 'READ_WRITE',
|
|
16
|
+
projectId: '1dc621a1-7980-410b-839b-4bed63600139'
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
requiredFields: ['username', 'firstName', 'lastName', 'isAdmin', 'accountId'],
|
|
3
|
+
customValidators: [
|
|
4
|
+
{name: 'phoneNumber', invalidInputs: ['409203492039284232034398']},
|
|
5
|
+
{name: 'creationTime', invalidInputs: ['21/07/2017', 'thursday']},
|
|
6
|
+
{name: 'lastUpdateTime', invalidInputs: ['21/07/2017', 'saturday']}
|
|
7
|
+
]
|
|
8
|
+
}
|