@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
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"extends" : [
|
|
3
|
+
"prettier"
|
|
4
|
+
],
|
|
5
|
+
"plugins": [
|
|
6
|
+
"prettier"
|
|
7
|
+
],
|
|
8
|
+
"parser": "babel-eslint",
|
|
9
|
+
"parserOptions": {
|
|
10
|
+
"ecmaVersion": 2015,
|
|
11
|
+
"sourceType": "module",
|
|
12
|
+
"ecmaFeatures": {
|
|
13
|
+
"jsx": true
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"rules": {
|
|
17
|
+
"indent": [
|
|
18
|
+
2,
|
|
19
|
+
4,
|
|
20
|
+
{"SwitchCase": 1}
|
|
21
|
+
],
|
|
22
|
+
"no-underscore-dangle": 0,
|
|
23
|
+
"import/prefer-default-export": false,
|
|
24
|
+
"arrow-body-style": 0
|
|
25
|
+
},
|
|
26
|
+
"env": {
|
|
27
|
+
"es6": true,
|
|
28
|
+
"browser": true,
|
|
29
|
+
"node": true,
|
|
30
|
+
"jest": true
|
|
31
|
+
},
|
|
32
|
+
"settings": {
|
|
33
|
+
"import/resolver": {
|
|
34
|
+
"webpack": {
|
|
35
|
+
"config": "./webpack.config.js"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"globals": {
|
|
40
|
+
"google": true
|
|
41
|
+
}
|
|
42
|
+
}
|
package/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
- infrastructure
|
|
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
|
+
- infrastructure
|
|
27
|
+
script:
|
|
28
|
+
- mkdir .nyc_output
|
|
29
|
+
- npm run test:coverage-check && npm test
|
|
30
|
+
|
|
31
|
+
# Publish tagged versions to npm
|
|
32
|
+
publish:
|
|
33
|
+
stage: deploy
|
|
34
|
+
tags:
|
|
35
|
+
- xcode9
|
|
36
|
+
only:
|
|
37
|
+
- tags
|
|
38
|
+
- triggers
|
|
39
|
+
#gitlab open issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/27818
|
|
40
|
+
except:
|
|
41
|
+
- /^(?!.*(master)$).*$/
|
|
42
|
+
script:
|
|
43
|
+
- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc
|
|
44
|
+
- npm publish
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
|
|
2
|
+
## 4.0.0
|
|
3
|
+
- Webhooks schema no longer allow headers of more than 1 key- value pair
|
|
4
|
+
- Webhooks no longer require enabled field
|
|
5
|
+
|
|
6
|
+
## 3.1.1
|
|
7
|
+
- Rename `Polyline` to `Geoline`
|
|
8
|
+
|
|
9
|
+
## 3.1.0
|
|
10
|
+
- Rename `filters` to `conditions`
|
|
11
|
+
|
|
12
|
+
## 3.0.16
|
|
13
|
+
- `timeActive` - Changed validations order
|
|
14
|
+
|
|
15
|
+
## 3.0.15
|
|
16
|
+
- `webhooks` - Fixed webhooks validations
|
|
17
|
+
|
|
18
|
+
## 3.0.13
|
|
19
|
+
- `Polygon` and `Polyline` "same vertices" check measures accurate to 6 decimal places only.
|
|
20
|
+
|
|
21
|
+
## 3.0.12
|
|
22
|
+
- Enforce `beaconType` capitalization on `Beacon` model
|
|
23
|
+
|
|
24
|
+
## 3.0.11
|
|
25
|
+
- Added `lastSyncTime` to the `project` model
|
|
26
|
+
|
|
27
|
+
## 3.0.10
|
|
28
|
+
- Remove validations on `geometry`'s
|
|
29
|
+
- Geofeatures moved to own separate folder
|
|
30
|
+
|
|
31
|
+
## 3.0.9
|
|
32
|
+
- `dayRange` fixed validation issue
|
|
33
|
+
|
|
34
|
+
## 3.0.7
|
|
35
|
+
- `proximityUUID` is now mandatory
|
|
36
|
+
|
|
37
|
+
## 3.0.6
|
|
38
|
+
- `txPower` no longer mandatory
|
|
39
|
+
|
|
40
|
+
## 3.0.5
|
|
41
|
+
- `User` - Remove password field
|
|
42
|
+
|
|
43
|
+
## 3.0.4
|
|
44
|
+
- `Polygon` - disallow a vertices next 2 being the same
|
|
45
|
+
|
|
46
|
+
## 3.0.3
|
|
47
|
+
- `BoundingBox` - disallow same values for `northEast` and `southWest`
|
|
48
|
+
- `Polygon` - disallow a vertices next vertice being the same
|
|
49
|
+
|
|
50
|
+
## 3.0.2
|
|
51
|
+
- Remove `_id`'s on the actions and filters (for real this time)
|
|
52
|
+
|
|
53
|
+
## 3.0.1
|
|
54
|
+
- `DayRange` must have at least startTime or endTime or both
|
|
55
|
+
|
|
56
|
+
## 3.0.0
|
|
57
|
+
|
|
58
|
+
- Breaking changes:
|
|
59
|
+
- `bearing` -> `travelDirection`
|
|
60
|
+
- `percentageCrossed` -> `travelPath`
|
|
61
|
+
- `percentage.percentage` -> `travelPath.minimumGeofeaturesCrossed`
|
|
62
|
+
- `timeOfDayRange` -> `timeActive`
|
|
63
|
+
- `calendarDateRange` -> `dayRange`
|
|
64
|
+
- Remove `state` from all subdocuments
|
|
65
|
+
- Remove `creationTime` from all subdocuments
|
|
66
|
+
- Remove `lastUpdateTime` from all subdocuments
|
|
67
|
+
- Remove `_id` from all subdocuments EXCEPT geofeatures
|
|
68
|
+
- Remove `description` from all subdocuments
|
|
69
|
+
- Remove `__v` from all subdocuments
|
|
70
|
+
|
|
71
|
+
## 2.0.22
|
|
72
|
+
|
|
73
|
+
- Allow 0 Major and Minor
|
|
74
|
+
|
|
75
|
+
## 2.0.21
|
|
76
|
+
|
|
77
|
+
- Validation: Polygon needs 3 or more vertices
|
|
78
|
+
|
|
79
|
+
## 2.0.20
|
|
80
|
+
- Added customData validation in helpers so that it can be imported in the UI
|
|
81
|
+
|
|
82
|
+
## 2.0.19
|
|
83
|
+
- Added validations for keys in customData
|
|
84
|
+
|
|
85
|
+
## 2.0.18
|
|
86
|
+
- `password` on `user` model no longer required. We will rely on cognito to throw an error
|
|
87
|
+
|
|
88
|
+
## 2.0.17
|
|
89
|
+
- Tag model added
|
|
90
|
+
|
|
91
|
+
## 2.0.16
|
|
92
|
+
- Don't enforce in `CalendarDateRangeFilter` that `endDate` is later than current date.
|
|
93
|
+
|
|
94
|
+
## 2.0.15
|
|
95
|
+
- Update `bearingFilter` with new business logic.
|
|
96
|
+
|
|
97
|
+
## 2.0.14
|
|
98
|
+
- Remove `password` from user model
|
|
99
|
+
|
|
100
|
+
## 2.0.13
|
|
101
|
+
- Republish to bring changes from 2.0.11
|
|
102
|
+
|
|
103
|
+
## 2.0.12
|
|
104
|
+
- Update `bearingFilter` to allow wrap around angles (e.g. 315deg & 45deg)
|
|
105
|
+
|
|
106
|
+
## 2.0.11
|
|
107
|
+
- Added uuid as `_id` for user
|
|
108
|
+
|
|
109
|
+
## 2.0.10
|
|
110
|
+
- Added indexes on beacons model
|
|
111
|
+
- Added `apiKey` to project model (for backwards compatibility)
|
|
112
|
+
- Added `customerApiKey` to account model (for backwards compatibility)
|
|
113
|
+
|
|
114
|
+
## 2.0.9
|
|
115
|
+
- Validation on `projectPermissions` in user model
|
|
116
|
+
|
|
117
|
+
## 2.0.8
|
|
118
|
+
- Removed `description` from `zone` model.
|
|
119
|
+
- Added `triggerOnExit` to `zone` model.
|
|
120
|
+
|
|
121
|
+
## 2.0.7
|
|
122
|
+
- All `guid`'s changed to `_id`'s
|
|
123
|
+
|
|
124
|
+
## 2.0.6
|
|
125
|
+
- Added `geometry` to geofeature models
|
|
126
|
+
|
|
127
|
+
## 2.0.5
|
|
128
|
+
- Beacon using a `location` property instead of `latitude` and `longitude` on the root
|
|
129
|
+
- ZoneBeacon model inheriting from Beacon, adds `proximity` and `type`
|
|
130
|
+
- Zone will use ZoneBeacon instead of Beacon model
|
|
131
|
+
- Removed `proximity` from Beacon
|
|
132
|
+
|
|
133
|
+
## 2.0.4
|
|
134
|
+
- customData no longer an array
|
|
135
|
+
- add accountId to zones
|
|
136
|
+
|
|
137
|
+
## 2.0.3-alpha.1
|
|
138
|
+
- Moved beacon back into geofeatures
|
|
139
|
+
- Changed all geofeatures guids to id's
|
|
140
|
+
- Updated creationTime/lastUpdateTime code on all models
|
|
141
|
+
|
|
142
|
+
## 2.0.2
|
|
143
|
+
- Added patcher to beacon model
|
|
144
|
+
|
|
145
|
+
## 2.0.1
|
|
146
|
+
- Beacon model: guid -> id
|
|
147
|
+
|
|
148
|
+
## 2.0.0-beta.14
|
|
149
|
+
- Beacon model: Removed console.debug breaking lambda execution
|
|
150
|
+
|
|
151
|
+
## 2.0.0-beta.13
|
|
152
|
+
- Beacon model: Added accountId
|
|
153
|
+
- Zone model: Added beacons
|
|
154
|
+
|
|
155
|
+
## 2.0.0-beta.12
|
|
156
|
+
- User model: `emailAddress` changed to `email`
|
package/Models.js
CHANGED
|
@@ -2,13 +2,58 @@
|
|
|
2
2
|
* Created by andrewstirling on 22/12/16.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
let Models = {}
|
|
6
|
+
|
|
7
|
+
Models.Account = require('./models/Account').Model
|
|
8
|
+
Models.Beacon = require('./models/Beacon').Model
|
|
9
|
+
|
|
10
|
+
Models.MessageAction = require('./models/MessageAction').Model
|
|
11
|
+
Models.MonthlyStat = require('./models/MonthlyStats').Model
|
|
12
|
+
Models.Project = require('./models/Project').Model
|
|
13
|
+
Models.RuleRequestAggregation = require('./models/RuleRequestAggregation').Model
|
|
14
|
+
Models.UrlAction = require('./models/UrlAction').Model
|
|
15
|
+
Models.User = require('./models/User').Model
|
|
16
|
+
Models.Zone = require('./models/Zone').Model
|
|
17
|
+
|
|
18
|
+
// Geofeatures
|
|
19
|
+
Models.BoundingBox = require('./models/geofeatures/BoundingBox').Model
|
|
20
|
+
Models.Circle = require('./models/geofeatures/Circle').Model
|
|
21
|
+
Models.Polygon = require('./models/geofeatures/Polygon').Model
|
|
22
|
+
Models.Geoline = require('./models/geofeatures/Geoline').Model
|
|
23
|
+
Models.ZoneBeacon = require('./models/geofeatures/ZoneBeacon').Model
|
|
24
|
+
|
|
25
|
+
// Conditions
|
|
26
|
+
Models.DayRange = require('./models/conditions/DayRange').Model
|
|
27
|
+
Models.TimeActive = require('./models/conditions/TimeActive').Model
|
|
28
|
+
Models.TravelPath = require('./models/conditions/TravelPath').Model
|
|
29
|
+
Models.Speed = require('./models/conditions/Speed').Model
|
|
30
|
+
Models.TravelDirection = require('./models/conditions/TravelDirection').Model
|
|
31
|
+
|
|
32
|
+
let Schemas = {}
|
|
33
|
+
|
|
34
|
+
Schemas.Account = require('./models/Account').Schema
|
|
35
|
+
Schemas.Beacon = require('./models/Beacon').Schema
|
|
36
|
+
Schemas.MessageAction = require('./models/MessageAction').Schema
|
|
37
|
+
Schemas.MonthlyStat = require('./models/MonthlyStats').Schema
|
|
38
|
+
Schemas.Project = require('./models/Project').Schema
|
|
39
|
+
Schemas.RuleRequestAggregation = require('./models/RuleRequestAggregation').Schema
|
|
40
|
+
Schemas.UrlAction = require('./models/UrlAction').Schema
|
|
41
|
+
Schemas.User = require('./models/User').Schema
|
|
42
|
+
Schemas.Zone = require('./models/Zone').Schema
|
|
43
|
+
|
|
44
|
+
// Geofeatures
|
|
45
|
+
Schemas.BoundingBox = require('./models/geofeatures/BoundingBox').Schema
|
|
46
|
+
Schemas.Circle = require('./models/geofeatures/Circle').Schema
|
|
47
|
+
Schemas.Polygon = require('./models/geofeatures/Polygon').Schema
|
|
48
|
+
Schemas.Geoline = require('./models/geofeatures/Geoline').Schema
|
|
49
|
+
Schemas.ZoneBeacon = require('./models/geofeatures/ZoneBeacon').Schema
|
|
50
|
+
|
|
51
|
+
// Conditions
|
|
52
|
+
Schemas.DayRange = require('./models/conditions/DayRange').Schema
|
|
53
|
+
Schemas.Speed = require('./models/conditions/Speed').Schema
|
|
54
|
+
Schemas.TimeActive = require('./models/conditions/TimeActive').Schema
|
|
55
|
+
Schemas.TravelPath = require('./models/conditions/TravelPath').Schema
|
|
56
|
+
Schemas.TravelDirection = require('./models/conditions/TravelDirection').Schema
|
|
57
|
+
|
|
58
|
+
Models.Schemas = Schemas
|
|
59
|
+
module.exports = Models
|
package/README.MD
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#### Bluedot Innovation Public API
|
|
2
|
+
```
|
|
3
|
+
Created by: Andrew Stirling
|
|
4
|
+
Last update by: Ryan Kan / 0421772600 / ryan@bluedotinnovation.com
|
|
5
|
+
Last updated: 4th December 2017
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
Styleguide link [JSS Standard Javascript](https://standardjs.com/),
|
|
9
|
+
implemented with [ESLint](https://github.com/standard/eslint-config-standard)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Minimum test coverage enforced:
|
|
13
|
+
|
|
14
|
+
````--lines 90 --functions 90 --branches 70````
|
|
15
|
+
|
|
16
|
+
To check test coverage:
|
|
17
|
+
|
|
18
|
+
run `npm test:coverage`
|
|
19
|
+
|
|
20
|
+
To lint:
|
|
21
|
+
|
|
22
|
+
run `npm run lint`
|
|
23
|
+
|
|
24
|
+
To check if your code will pass CI pipeline:
|
|
25
|
+
|
|
26
|
+
run `npm run test:ci`
|
|
27
|
+
aws apigateway put-integration \
|
|
28
|
+
--rest-api-id api-id \
|
|
29
|
+
--resource-id resource-id \
|
|
30
|
+
--http-method POST \
|
|
31
|
+
--type AWS \
|
|
32
|
+
--integration-http-method POST \
|
|
33
|
+
--uri arn:aws:apigateway:aws-region:lambda:path/2015-03-31/functions/arn:aws:lambda:aws-region:aws-acct-id:function:your-lambda-function-name/invocations
|
|
34
|
+
To publish:
|
|
35
|
+
|
|
36
|
+
run `npm version x.x.x`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"state": "ACTIVE",
|
|
3
|
+
"lastUpdateTime": "2018-02-14T04:12:02.103Z",
|
|
4
|
+
"creationTime": "2018-02-14T04:12:02.103Z",
|
|
5
|
+
"name": "ABC Company",
|
|
6
|
+
"createdBy": "b0824b76-ce73-4fcf-81f8-1b63edb1114e",
|
|
7
|
+
"poiCredits": 23,
|
|
8
|
+
"features": {
|
|
9
|
+
"tags": true,
|
|
10
|
+
"beacons": false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
requiredFields: ['name'],
|
|
3
|
+
customValidators: [
|
|
4
|
+
{name: 'poiCredits', invalidInputs: ['a string']},
|
|
5
|
+
{name: 'creationTime', invalidInputs: ['21/07/2017', 'thursday']},
|
|
6
|
+
{name: 'lastUpdateTime', invalidInputs: ['21/07/2017', 'saturday']}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
let AccountModel = require('../../Models').Account(mongoose)
|
|
4
|
+
let AccountModelBuiltInMongoose = require('../../Models').Account()
|
|
5
|
+
let testCase = require('mocha').describe
|
|
6
|
+
let assertions = require('mocha').it
|
|
7
|
+
let rules = require('./account.rules.js')
|
|
8
|
+
let chai = require('chai')
|
|
9
|
+
let assert = chai.assert
|
|
10
|
+
let mocha = require('mocha')
|
|
11
|
+
let beforeEach = mocha.beforeEach
|
|
12
|
+
|
|
13
|
+
let account
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
account = JSON.parse(JSON.stringify(require('./account.data.json')))
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
testCase('Account', () => {
|
|
20
|
+
testCase('Valid Account ', () => {
|
|
21
|
+
assertions('should validate a valid account when initializing the model with an external mongoose instance', (done) => {
|
|
22
|
+
let Account = new AccountModel(account)
|
|
23
|
+
|
|
24
|
+
Account.validate((err, res) => {
|
|
25
|
+
assert.notExists(res)
|
|
26
|
+
assert(err === null, 'err equals null')
|
|
27
|
+
done()
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
assertions('should validate a valid account', (done) => {
|
|
32
|
+
let Account = new AccountModelBuiltInMongoose(account)
|
|
33
|
+
|
|
34
|
+
Account.validate((err, res) => {
|
|
35
|
+
assert.notExists(res)
|
|
36
|
+
assert(err === null, 'err equals null')
|
|
37
|
+
done()
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
testCase('Invalid Account', () => {
|
|
43
|
+
testCase('recursive property check', () => {
|
|
44
|
+
let requiredFields = rules.requiredFields
|
|
45
|
+
requiredFields.forEach((requiredField) => {
|
|
46
|
+
assertions(`should throw an error with property '${requiredField}' if '${requiredField}' is not present`, (done) => {
|
|
47
|
+
account = JSON.parse(JSON.stringify(account))
|
|
48
|
+
delete account[requiredField]
|
|
49
|
+
let Account = new AccountModel(account)
|
|
50
|
+
Account.validate((err, res) => {
|
|
51
|
+
assert.notExists(res)
|
|
52
|
+
assert.exists(err, 'err object should exist')
|
|
53
|
+
assert.isObject(err)
|
|
54
|
+
assert.nestedProperty(err, `errors.${requiredField}`, `error should have a ${requiredField} property`)
|
|
55
|
+
done()
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
testCase('recursive invalid entry check', () => {
|
|
63
|
+
const { customValidators } = rules
|
|
64
|
+
|
|
65
|
+
customValidators.forEach((customValidator) => {
|
|
66
|
+
customValidator.invalidInputs.forEach((invalidInput) => {
|
|
67
|
+
assertions(`should throw an error with property '${customValidator.name}' if '${customValidator.name}' is invalid => ${customValidator.name} = ${invalidInput}`, (done) => {
|
|
68
|
+
account = JSON.parse(JSON.stringify(account))
|
|
69
|
+
account[customValidator.name] = invalidInput
|
|
70
|
+
let Account = new AccountModel(account)
|
|
71
|
+
|
|
72
|
+
Account.validate((err, res) => {
|
|
73
|
+
assert.notExists(res)
|
|
74
|
+
assert.exists(err, 'err object should exist')
|
|
75
|
+
assert.isObject(err)
|
|
76
|
+
assert.nestedProperty(err, `errors.${customValidator.name}`, `error should have a ${customValidator.name} property`)
|
|
77
|
+
done()
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let MessageActionModel = require('../../../Models').MessageAction(mongoose)
|
|
6
|
+
let MessageActionModelBuiltInMongoose = require('../../../Models').MessageAction()
|
|
7
|
+
|
|
8
|
+
let testCase = require('mocha').describe
|
|
9
|
+
let assertions = require('mocha').it
|
|
10
|
+
let chai = require('chai')
|
|
11
|
+
|
|
12
|
+
let assert = chai.assert
|
|
13
|
+
let mocha = require('mocha')
|
|
14
|
+
let beforeEach = mocha.beforeEach
|
|
15
|
+
let rules = require('./messageAction.rules.json')
|
|
16
|
+
|
|
17
|
+
let messageAction
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
messageAction = JSON.parse(JSON.stringify(require('./messageAction.data.json')))
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
testCase('MessageAction', () => {
|
|
24
|
+
testCase('Valid MessageAction', () => {
|
|
25
|
+
assertions('should validate a valid messageAction ', (done) => {
|
|
26
|
+
let MessageAction = new MessageActionModel(messageAction)
|
|
27
|
+
MessageAction.validate((err, res) => {
|
|
28
|
+
assert.notExists(res)
|
|
29
|
+
assert(err === null, 'err should equals null')
|
|
30
|
+
done()
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
testCase('Valid MessageAction', () => {
|
|
35
|
+
assertions('should validate a valid messageAction ', (done) => {
|
|
36
|
+
let MessageAction = new MessageActionModelBuiltInMongoose(messageAction)
|
|
37
|
+
MessageAction.validate((err, res) => {
|
|
38
|
+
assert.notExists(res)
|
|
39
|
+
assert(err === null, 'err should equals null')
|
|
40
|
+
done()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
testCase('Invalid MessageAction', () => {
|
|
46
|
+
assertions('should not validate a messageAction with invalid MessageAction', (done) => {
|
|
47
|
+
delete messageAction[rules.requiredFields[0]]
|
|
48
|
+
let MessageAction = new MessageActionModel(messageAction)
|
|
49
|
+
MessageAction.validate((err, res) => {
|
|
50
|
+
assert.exists(err, 'err object should exist')
|
|
51
|
+
assert.isObject(err)
|
|
52
|
+
done()
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
testCase('check each required property of the model and validate that it is present', () => {
|
|
56
|
+
let requiredFields = rules.requiredFields
|
|
57
|
+
requiredFields.map((i) => {
|
|
58
|
+
assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
|
|
59
|
+
// delete i from geofeatures' messageAction child
|
|
60
|
+
delete messageAction[i]
|
|
61
|
+
let MessageAction = new MessageActionModel(messageAction)
|
|
62
|
+
MessageAction.validate((err, res) => {
|
|
63
|
+
assert.notExists(res)
|
|
64
|
+
assert.exists(err, 'err object should exist')
|
|
65
|
+
assert.isObject(err)
|
|
66
|
+
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
67
|
+
done()
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
mongoose.Promise = global.Promise
|
|
4
|
+
|
|
5
|
+
let UrlactionModel = require('../../../Models').UrlAction(mongoose)
|
|
6
|
+
let UrlactionModelBuiltInMongoose = require('../../../Models').UrlAction()
|
|
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 rules = require('./urlAction.rules.json')
|
|
16
|
+
|
|
17
|
+
let urlaction
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
urlaction = JSON.parse(JSON.stringify(require('./urlAction.data.json')))
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
testCase('Urlaction', () => {
|
|
24
|
+
testCase('Valid Urlaction', () => {
|
|
25
|
+
assertions('should validate a valid urlaction ', (done) => {
|
|
26
|
+
let Urlaction = new UrlactionModel(urlaction)
|
|
27
|
+
Urlaction.validate((err, res) => {
|
|
28
|
+
assert.notExists(res)
|
|
29
|
+
assert(err === null, 'err should equals null')
|
|
30
|
+
done()
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
testCase('Valid Urlaction (Built in mongoose)', () => {
|
|
36
|
+
assertions('should validate a valid urlaction ', (done) => {
|
|
37
|
+
let Urlaction = new UrlactionModelBuiltInMongoose(urlaction)
|
|
38
|
+
Urlaction.validate((err, res) => {
|
|
39
|
+
assert.notExists(res)
|
|
40
|
+
assert(err === null, 'err should equals null')
|
|
41
|
+
done()
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
testCase('Invalid Urlaction', () => {
|
|
47
|
+
assertions('should not validate a urlaction with invalid Urlaction', (done) => {
|
|
48
|
+
delete urlaction[rules.requiredFields[0]]
|
|
49
|
+
let Urlaction = new UrlactionModel(urlaction)
|
|
50
|
+
Urlaction.validate((err, res) => {
|
|
51
|
+
assert.exists(err, 'err object should exist')
|
|
52
|
+
assert.isObject(err)
|
|
53
|
+
done()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
testCase('check each required property of the model and validate that it is present', () => {
|
|
57
|
+
let requiredFields = rules.requiredFields
|
|
58
|
+
requiredFields.map((i) => {
|
|
59
|
+
assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
|
|
60
|
+
// delete i from geofeatures' urlaction child
|
|
61
|
+
delete urlaction[i]
|
|
62
|
+
let Urlaction = new UrlactionModel(urlaction)
|
|
63
|
+
Urlaction.validate((err, res) => {
|
|
64
|
+
assert.notExists(res)
|
|
65
|
+
assert.exists(err, 'err object should exist')
|
|
66
|
+
assert.isObject(err)
|
|
67
|
+
assert.nestedProperty(err, `errors.${i}`, `error should have a ${i} property`)
|
|
68
|
+
done()
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
"macAddress": "01:17:c5:31:84:19",
|
|
14
|
+
"accountId": "90a2ed18-86be-48e7-948b-393b8b679ef6"
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"requiredFields":["name", "location", "beaconType"],
|
|
3
|
+
"dependentRequiredFields": [
|
|
4
|
+
{
|
|
5
|
+
"property": "beaconType",
|
|
6
|
+
"pairings": [
|
|
7
|
+
{"value": "IOS", "requiredFields": ["proximityUUID", "major", "minor"]},
|
|
8
|
+
{"value": "Android", "requiredFields": ["macAddress"]},
|
|
9
|
+
{"value": "Both", "requiredFields": ["proximityUUID", "major", "minor", "macAddress"]}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|