@bluedot-innovation/models 2.0.0-alpha.8 → 2.0.0-alpha1
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 +8 -8
- package/__tests__/zone/checkActions.js +64 -0
- package/__tests__/zone/checkAppId.js +41 -0
- package/__tests__/zone/checkBeacon.js +46 -0
- package/__tests__/zone/checkBearingFitler.js +48 -0
- package/__tests__/zone/checkBoundingBox.js +44 -0
- package/__tests__/zone/checkCalendarDateRangeFilterFitler.js +48 -0
- package/__tests__/zone/checkCircle.js +41 -0
- package/__tests__/zone/checkMRT.js +46 -0
- package/__tests__/zone/checkPercentageCrossedFitler.js +48 -0
- package/__tests__/zone/checkPolygon.js +78 -0
- package/__tests__/zone/checkPolyline.js +78 -0
- package/__tests__/zone/checkSpeedFitler.js +48 -0
- package/__tests__/zone/checkTimeOfDayRangeFitler.js +48 -0
- package/models/AdminPortalUser.js +11 -10
- package/models/AdminUser.js +5 -6
- package/models/Application.js +30 -31
- package/models/Beacon.js +78 -89
- package/models/BeaconFilter.js +12 -30
- 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 -18
- 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 +7 -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/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 -51
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "TDD zone",
|
|
3
|
-
"minimumRetriggerTime": "60",
|
|
4
|
-
"checkout": true,
|
|
5
|
-
"applicationId": "c7058934-f1e6-4176-8730-a0bd28e8e0a9",
|
|
6
|
-
"customData": [
|
|
7
|
-
{
|
|
8
|
-
"name1": "A Custom action1"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name2": "A Custom action2"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"actions": [
|
|
15
|
-
{
|
|
16
|
-
"type": "message",
|
|
17
|
-
"message": "hello",
|
|
18
|
-
"title": "hello"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"type": "url",
|
|
22
|
-
"url": "https://www.google.com"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"filters": [
|
|
26
|
-
{
|
|
27
|
-
"type" : "calendarDateRange",
|
|
28
|
-
"startDate" : "2017-11-14",
|
|
29
|
-
"endDate" : "2017-11-15"
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"geofeatures": [{
|
|
33
|
-
"type": "beacon",
|
|
34
|
-
"name": "create beacon",
|
|
35
|
-
"proximityUUID": "23a01af0-232a-4518-9c0e-323fb773f5ef",
|
|
36
|
-
"latitude": -37.8159544565362,
|
|
37
|
-
"longitude": 144.9723565578461,
|
|
38
|
-
"beaconType": "Both",
|
|
39
|
-
"major": 10000,
|
|
40
|
-
"phone": 123123123123,
|
|
41
|
-
"minor": 56466,
|
|
42
|
-
"txPower": -77,
|
|
43
|
-
"macAddress": "01:17:c5:31:84:19"
|
|
44
|
-
},{
|
|
45
|
-
"type": "circle",
|
|
46
|
-
"name": "Test Circle",
|
|
47
|
-
"radius": 10,
|
|
48
|
-
"center": {
|
|
49
|
-
"latitude": -37.8159544565362,
|
|
50
|
-
"longitude": 144.9723565578461
|
|
51
|
-
}
|
|
52
|
-
},{
|
|
53
|
-
"type": "boundingBox",
|
|
54
|
-
"name": "Test BoundingBox",
|
|
55
|
-
"northEast": {
|
|
56
|
-
"latitude": -37.81794619852986,
|
|
57
|
-
"longitude": 144.97999548912048
|
|
58
|
-
},
|
|
59
|
-
"southWest": {
|
|
60
|
-
"latitude": -37.81846319511329,
|
|
61
|
-
"longitude": 144.97921228408813
|
|
62
|
-
}
|
|
63
|
-
},{
|
|
64
|
-
"type": "polygon",
|
|
65
|
-
"name": "Test Polygon",
|
|
66
|
-
"vertices": [
|
|
67
|
-
{
|
|
68
|
-
"latitude": -37.81902680201739,
|
|
69
|
-
"longitude": 144.9821037054062
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"latitude": -37.8196878692931,
|
|
73
|
-
"longitude": 144.98161554336548
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"latitude": -37.82052267015026,
|
|
77
|
-
"longitude": 144.9816906452179
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"latitude": -37.82128118660006,
|
|
81
|
-
"longitude": 144.98312830924988
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"latitude": -37.82102693614463,
|
|
85
|
-
"longitude": 144.98458743095398
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"latitude": -37.820196378553405,
|
|
89
|
-
"longitude": 144.98524725437164
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"latitude": -37.81895899991077,
|
|
93
|
-
"longitude": 144.9847161769867
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"latitude": -37.81865812731128,
|
|
97
|
-
"longitude": 144.9839222431183
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"latitude": -37.81866660261256,
|
|
101
|
-
"longitude": 144.98308539390564
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"latitude": -37.81902680201739,
|
|
105
|
-
"longitude": 144.9821037054062
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
},{
|
|
109
|
-
"type": "polyline",
|
|
110
|
-
"name": "Test Polygon",
|
|
111
|
-
"vertices": [
|
|
112
|
-
{
|
|
113
|
-
"latitude": -37.81902680201739,
|
|
114
|
-
"longitude": 144.9821037054062
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"latitude": -37.8196878692931,
|
|
118
|
-
"longitude": 144.98161554336548
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"latitude": -37.82052267015026,
|
|
122
|
-
"longitude": 144.9816906452179
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
"latitude": -37.82128118660006,
|
|
126
|
-
"longitude": 144.98312830924988
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"latitude": -37.82102693614463,
|
|
130
|
-
"longitude": 144.98458743095398
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"latitude": -37.820196378553405,
|
|
134
|
-
"longitude": 144.98524725437164
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"latitude": -37.81895899991077,
|
|
138
|
-
"longitude": 144.9847161769867
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
"latitude": -37.81865812731128,
|
|
142
|
-
"longitude": 144.9839222431183
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"latitude": -37.81866660261256,
|
|
146
|
-
"longitude": 144.98308539390564
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
"latitude": -37.81902680201739,
|
|
150
|
-
"longitude": 144.9821037054062
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
}]
|
|
154
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
let mongoose = require('mongoose')
|
|
2
|
-
|
|
3
|
-
mongoose.Promise = global.Promise
|
|
4
|
-
|
|
5
|
-
let ZoneModel = require('../../models/Zone')(mongoose)
|
|
6
|
-
let testCase = require('mocha').describe
|
|
7
|
-
let assertions = require('mocha').it
|
|
8
|
-
let chai = require('chai')
|
|
9
|
-
let assert = chai.assert
|
|
10
|
-
let mocha = require('mocha')
|
|
11
|
-
let beforeEach = mocha.beforeEach
|
|
12
|
-
|
|
13
|
-
let zone
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
zone = JSON.parse(JSON.stringify(require('./zone.data.json')))
|
|
17
|
-
// remove actions as it's not tested
|
|
18
|
-
delete zone.actions
|
|
19
|
-
// remove all but 1 geofeatures as geofeatures are required
|
|
20
|
-
zone.geofeatures = zone.geofeatures.filter(x => x.type.match(/circle/i))
|
|
21
|
-
// remove customData
|
|
22
|
-
delete zone.customData
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
testCase('Zone - Filter', () => {
|
|
26
|
-
testCase('Valid Zone - Filter', () => {
|
|
27
|
-
assertions('should not throw an error when a valid filter is instantiated within a zone', (done) => {
|
|
28
|
-
let Zone = new ZoneModel(zone)
|
|
29
|
-
Zone.validate((err, res) => {
|
|
30
|
-
assert.notExists(res)
|
|
31
|
-
assert(err === null, 'err equals null')
|
|
32
|
-
done()
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
testCase('Invalid Zone - Filter', () => {
|
|
38
|
-
assertions('should throw an error when an invalid filter is instantiated within a zone', (done) => {
|
|
39
|
-
delete zone.filters[0].startDate
|
|
40
|
-
let Zone = new ZoneModel(zone)
|
|
41
|
-
Zone.validate((err, res) => {
|
|
42
|
-
assert.exists(err, 'err object should exist')
|
|
43
|
-
assert.isObject(err)
|
|
44
|
-
assert('filters.0.startDate' in err.errors)
|
|
45
|
-
assert.notNestedProperty(err, `errors.geofeatures`, 'error should have a url property')
|
|
46
|
-
done()
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
})
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
let mongoose = require('mongoose')
|
|
2
|
-
|
|
3
|
-
mongoose.Promise = global.Promise
|
|
4
|
-
|
|
5
|
-
let ZoneModel = require('../../models/Zone')(mongoose)
|
|
6
|
-
let testCase = require('mocha').describe
|
|
7
|
-
let assertions = require('mocha').it
|
|
8
|
-
let chai = require('chai')
|
|
9
|
-
let assert = chai.assert
|
|
10
|
-
let mocha = require('mocha')
|
|
11
|
-
let beforeEach = mocha.beforeEach
|
|
12
|
-
|
|
13
|
-
let zone
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
zone = JSON.parse(JSON.stringify(require('./zone.data.json')))
|
|
17
|
-
// remove filters as it's not tested
|
|
18
|
-
delete zone.filters
|
|
19
|
-
|
|
20
|
-
// geofeatures are tested individually so we only need to try one in Zones' test
|
|
21
|
-
zone.geofeatures = zone.geofeatures.filter(x => x.type.match(/beacon/i))
|
|
22
|
-
|
|
23
|
-
// remove customData
|
|
24
|
-
delete zone.customData
|
|
25
|
-
|
|
26
|
-
// remove actions
|
|
27
|
-
delete zone.actions
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
testCase('Zone - Action', () => {
|
|
31
|
-
testCase('Valid Zone - Action', () => {
|
|
32
|
-
assertions('should not throw an error when a valid geofeature is instantiated within a zone', (done) => {
|
|
33
|
-
let Zone = new ZoneModel(zone)
|
|
34
|
-
Zone.validate((err, res) => {
|
|
35
|
-
assert.notExists(res)
|
|
36
|
-
assert(err === null, 'err equals null')
|
|
37
|
-
done()
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
testCase('Invalid Zone - Action', () => {
|
|
43
|
-
assertions('should throw an error when an invalid geofeature is instantiated within a zone', (done) => {
|
|
44
|
-
delete zone.geofeatures[0].name
|
|
45
|
-
let Zone = new ZoneModel(zone)
|
|
46
|
-
Zone.validate((err, res) => {
|
|
47
|
-
assert.exists(err, 'err object should exist')
|
|
48
|
-
assert.isObject(err)
|
|
49
|
-
assert('geofeatures.0.name' in err.errors)
|
|
50
|
-
done()
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
assertions('should throw an error when an invalid geofeature (complex validation) is instantiated within a zone', (done) => {
|
|
54
|
-
delete zone.geofeatures[0].minor
|
|
55
|
-
let Zone = new ZoneModel(zone)
|
|
56
|
-
Zone.validate((err, res) => {
|
|
57
|
-
assert.exists(err, 'err object should exist')
|
|
58
|
-
assert.isObject(err)
|
|
59
|
-
assert('geofeatures.0.beaconType' in err.errors)
|
|
60
|
-
done()
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
assertions('should throw an error when an no geofeature is instantiated within a zone', (done) => {
|
|
64
|
-
zone.geofeatures = []
|
|
65
|
-
let Zone = new ZoneModel(zone)
|
|
66
|
-
Zone.validate((err, res) => {
|
|
67
|
-
assert.exists(err, 'err object should exist')
|
|
68
|
-
assert.isObject(err)
|
|
69
|
-
assert('geofeatures' in err.errors)
|
|
70
|
-
done()
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
})
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
let mongoose = require('mongoose')
|
|
2
|
-
|
|
3
|
-
mongoose.Promise = global.Promise
|
|
4
|
-
|
|
5
|
-
let ZoneModel = require('../../models/Zone')(mongoose)
|
|
6
|
-
let testCase = require('mocha').describe
|
|
7
|
-
let assertions = require('mocha').it
|
|
8
|
-
let chai = require('chai')
|
|
9
|
-
let assert = chai.assert
|
|
10
|
-
let mocha = require('mocha')
|
|
11
|
-
let beforeEach = mocha.beforeEach
|
|
12
|
-
|
|
13
|
-
let zone
|
|
14
|
-
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
zone = JSON.parse(JSON.stringify(require('./zone.data.json')))
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
testCase('Zone', () => {
|
|
20
|
-
testCase('Valid Zone ', () => {
|
|
21
|
-
assertions('should validate a valid zone ', (done) => {
|
|
22
|
-
let Zone = new ZoneModel(zone)
|
|
23
|
-
Zone.validate((err, res) => {
|
|
24
|
-
assert.notExists(res)
|
|
25
|
-
assert(err === null, 'err equals null')
|
|
26
|
-
done()
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
assertions('should instantiate a circle', (done) => {
|
|
30
|
-
zone.geofeatures = zone.geofeatures.filter(gf => gf.type.match(/^circle$/))
|
|
31
|
-
let Zone = new ZoneModel(zone)
|
|
32
|
-
Zone.validate((err, res) => {
|
|
33
|
-
assert.notExists(res)
|
|
34
|
-
assert(err === null, 'err equals null')
|
|
35
|
-
done()
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
assertions('should instantiate a bounding box', (done) => {
|
|
39
|
-
zone.geofeatures = zone.geofeatures.filter(gf => gf.type.match(/^boundingBox$/))
|
|
40
|
-
let Zone = new ZoneModel(zone)
|
|
41
|
-
Zone.validate((err, res) => {
|
|
42
|
-
assert.notExists(res)
|
|
43
|
-
assert(err === null, 'err equals null')
|
|
44
|
-
done()
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
assertions('should instantiate a polygon', (done) => {
|
|
48
|
-
zone.geofeatures = zone.geofeatures.filter(gf => gf.type.match(/^polygon$/))
|
|
49
|
-
let Zone = new ZoneModel(zone)
|
|
50
|
-
Zone.validate((err, res) => {
|
|
51
|
-
assert.notExists(res)
|
|
52
|
-
assert(err === null, 'err equals null')
|
|
53
|
-
done()
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
assertions('should instantiate a polyline', (done) => {
|
|
57
|
-
zone.geofeatures = zone.geofeatures.filter(gf => gf.type.match(/^polyline$/))
|
|
58
|
-
let Zone = new ZoneModel(zone)
|
|
59
|
-
Zone.validate((err, res) => {
|
|
60
|
-
assert.notExists(res)
|
|
61
|
-
assert(err === null, 'err equals null')
|
|
62
|
-
done()
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
testCase('Invalid Zone ', () => {
|
|
68
|
-
assertions('should throw an error when validating an invalid zone ', (done) => {
|
|
69
|
-
delete zone.name
|
|
70
|
-
let Zone = new ZoneModel(zone)
|
|
71
|
-
Zone.validate((err, res) => {
|
|
72
|
-
assert.exists(err, 'err object should exist')
|
|
73
|
-
assert.isObject(err)
|
|
74
|
-
done()
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
assertions('should throw an error when action is invalid', (done) => {
|
|
78
|
-
delete zone.actions[1].url
|
|
79
|
-
let Zone = new ZoneModel(zone)
|
|
80
|
-
Zone.validate((err, res) => {
|
|
81
|
-
assert.exists(err, 'err object should exist')
|
|
82
|
-
assert.isObject(err)
|
|
83
|
-
assert('actions.1.url' in err.errors, `errors should have a 'actions.1.url' property`)
|
|
84
|
-
done()
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
assertions('should throw an error when a filter is invalid', (done) => {
|
|
88
|
-
delete zone.filters[0].startDate
|
|
89
|
-
let Zone = new ZoneModel(zone)
|
|
90
|
-
Zone.validate((err, res) => {
|
|
91
|
-
assert.exists(err, 'err object should exist')
|
|
92
|
-
assert.isObject(err)
|
|
93
|
-
assert('filters.0.startDate' in err.errors, `errors should have a 'filters.0.startDate' property`)
|
|
94
|
-
done()
|
|
95
|
-
})
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
})
|
package/models/DailyStats.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Created by Daniel on 23/11/2017.
|
|
3
|
-
* Copyright : Bluedot Innovations.
|
|
4
|
-
* Owner :
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const mongoose = require('mongoose')
|
|
8
|
-
const Schema = mongoose.Schema
|
|
9
|
-
const uuidv4 = require('uuid/v4')
|
|
10
|
-
|
|
11
|
-
const DailyStats = mongoose.model(
|
|
12
|
-
'DailyStats',
|
|
13
|
-
new Schema(
|
|
14
|
-
{
|
|
15
|
-
_id: {type: String, default: uuidv4},
|
|
16
|
-
totalEndUsers: Number,
|
|
17
|
-
totalIos: Number,
|
|
18
|
-
totalAndroid: Number,
|
|
19
|
-
creationDate: {type: Date, default: Date.now}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
collection: 'dailyStats',
|
|
23
|
-
versionKey: false
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
module.exports = DailyStats
|
package/models/UrlAction.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
let mongoose = require('mongoose')
|
|
2
|
-
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
-
let uuidv4 = require('uuid/v4')
|
|
4
|
-
|
|
5
|
-
let schema = {
|
|
6
|
-
guid: {type: String, default: uuidv4},
|
|
7
|
-
url: {
|
|
8
|
-
type: String,
|
|
9
|
-
required: [true, 'url is required. '],
|
|
10
|
-
validate: {
|
|
11
|
-
validator: validateURL
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
description: {type: String, default: ''},
|
|
15
|
-
creationTime: {type: Date, default: Date.now},
|
|
16
|
-
lastUpdateTime: {type: Date, default: Date.now},
|
|
17
|
-
state: {type: String, default: StateEnum.active, select: false}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let URLActionSchema = new mongoose.Schema(schema,
|
|
21
|
-
{
|
|
22
|
-
_id: false,
|
|
23
|
-
__v: false
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
URLActionSchema.add({
|
|
27
|
-
type:
|
|
28
|
-
{type: String, required: true}
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
function validateURL (url, cb) {
|
|
32
|
-
let magicCallback = cb
|
|
33
|
-
let urlRegex = new RegExp('^(http[s]?:\\/\\/(www\\.)?|ftp:\\/\\/(www\\.)?|www\\.){1}([0-9A-Za-z-\\.@:%_+~#=]+)+((\\.[a-zA-Z]{2,3})+)(/(.)*)?(\\?(.)*)?')
|
|
34
|
-
if (!urlRegex.test(url)) {
|
|
35
|
-
return magicCallback(false, `${url} is not a valid URL`)
|
|
36
|
-
}
|
|
37
|
-
magicCallback(true)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// optional mongoose
|
|
41
|
-
module.exports = (mongooseInstance) => {
|
|
42
|
-
let Urlaction
|
|
43
|
-
if (mongooseInstance) {
|
|
44
|
-
Urlaction = mongooseInstance.model('Urlaction', URLActionSchema)
|
|
45
|
-
} else {
|
|
46
|
-
Urlaction = mongoose.model('Urlaction', URLActionSchema)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return Urlaction
|
|
50
|
-
}
|
|
51
|
-
module.exports.urlActionSchema = schema
|