@bluedot-innovation/models 2.0.0-alpha1 → 2.0.0-beta.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.
Files changed (117) hide show
  1. package/.eslintrc.js +6 -0
  2. package/.gitlab-ci.yml +43 -0
  3. package/.npmignore +3 -0
  4. package/.nyc_output/295801a153bad60b994d5c6b5a8016d9.json +1 -0
  5. package/.nyc_output/2963e30f6030a94b16dd86e7b5594ebe.json +1 -0
  6. package/.nyc_output/5fc62324d665599db6649363a937708e.json +1 -0
  7. package/.nyc_output/95eec4b77e4566b36a6300f0cf8bea0b.json +1 -0
  8. package/Models.js +36 -10
  9. package/README.MD +36 -0
  10. package/__tests__/action/message/messageAction.data.json +5 -0
  11. package/__tests__/action/message/messageAction.rules.json +3 -0
  12. package/__tests__/action/message/messageAction.spec.js +61 -0
  13. package/__tests__/action/url/urlAction.data.json +4 -0
  14. package/__tests__/action/url/urlAction.rules.json +3 -0
  15. package/__tests__/action/url/urlAction.spec.js +62 -0
  16. package/__tests__/dailyStats/checkDailyStats.js +30 -0
  17. package/__tests__/filter/beacon/beaconFilter.data.json +1 -0
  18. package/__tests__/filter/beacon/beaconFilter.rules.json +3 -0
  19. package/__tests__/filter/beacon/beaconFilter.spec.js +1 -0
  20. package/__tests__/filter/bearing/bearingFilter.data.json +5 -0
  21. package/__tests__/filter/bearing/bearingFilter.rules.json +3 -0
  22. package/__tests__/filter/bearing/bearingFilter.spec.js +95 -0
  23. package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.data.json +5 -0
  24. package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.rules.json +3 -0
  25. package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.spec.js +62 -0
  26. package/__tests__/filter/percentageCrossed/percentageCrossedFilter.data.json +5 -0
  27. package/__tests__/filter/percentageCrossed/percentageCrossedFilter.rules.json +3 -0
  28. package/__tests__/filter/percentageCrossed/percentageCrossedFilter.spec.js +62 -0
  29. package/__tests__/filter/speed/speedFilter.data.json +5 -0
  30. package/__tests__/filter/speed/speedFilter.rules.json +3 -0
  31. package/__tests__/filter/speed/speedFilter.spec.js +73 -0
  32. package/__tests__/filter/timeOfDayRange/timeOfDayRange.data.json +5 -0
  33. package/__tests__/filter/timeOfDayRange/timeOfDayRange.rules.json +3 -0
  34. package/__tests__/filter/timeOfDayRange/timeOfDayRange.spec.js +73 -0
  35. package/__tests__/geofeature/beacon/beacon.data.json +12 -0
  36. package/__tests__/geofeature/beacon/beacon.rules.json +13 -0
  37. package/__tests__/geofeature/beacon/beacon.spec.js +95 -0
  38. package/__tests__/geofeature/boundingBox/boundingBox.data.json +12 -0
  39. package/__tests__/geofeature/boundingBox/boundingBox.rules.json +3 -0
  40. package/__tests__/geofeature/boundingBox/boundingBox.spec.js +61 -0
  41. package/__tests__/geofeature/circle/circle.data.json +9 -0
  42. package/__tests__/geofeature/circle/circle.rules.json +3 -0
  43. package/__tests__/geofeature/circle/circle.spec.js +62 -0
  44. package/__tests__/geofeature/polygon/polygon.data.json +46 -0
  45. package/__tests__/geofeature/polygon/polygon.rules.json +3 -0
  46. package/__tests__/geofeature/polygon/polygon.spec.js +61 -0
  47. package/__tests__/geofeature/polyline/polyline.data.json +46 -0
  48. package/__tests__/geofeature/polyline/polyline.rules.json +3 -0
  49. package/__tests__/geofeature/polyline/polyline.spec.js +61 -0
  50. package/__tests__/monthlyStats/monthlyStats.data.json +29 -0
  51. package/__tests__/monthlyStats/monthlyStats.spec.js +40 -0
  52. package/__tests__/zone/zone.action.spec.js +50 -0
  53. package/__tests__/zone/zone.data.json +154 -0
  54. package/__tests__/zone/zone.filter.spec.js +50 -0
  55. package/__tests__/zone/zone.geofeatures.spec.js +74 -0
  56. package/__tests__/zone/zone.spec.js +98 -0
  57. package/models/AdminPortalUser.js +10 -11
  58. package/models/AdminUser.js +6 -5
  59. package/models/Application.js +31 -30
  60. package/models/Beacon.js +92 -78
  61. package/models/BeaconFilter.js +28 -12
  62. package/models/BearingFilter.js +46 -23
  63. package/models/BoundingBox.js +36 -20
  64. package/models/CalendarDateRangeFilter.js +34 -19
  65. package/models/Circle.js +33 -18
  66. package/models/Contract.js +37 -38
  67. package/models/Customer.js +31 -31
  68. package/models/CustomerLogin.js +9 -10
  69. package/models/DBEvent.js +13 -14
  70. package/models/DailyStats.js +28 -0
  71. package/models/DeviceRulesRequest.js +27 -28
  72. package/models/Fence.js +12 -13
  73. package/models/GeoFence.js +12 -14
  74. package/models/Geofeature.js +16 -18
  75. package/models/MessageAction.js +31 -16
  76. package/models/MonthlyStats.js +39 -0
  77. package/models/NotificationLogEntry.js +7 -8
  78. package/models/POILocation.js +6 -7
  79. package/models/POILookup.js +8 -9
  80. package/models/POIResult.js +7 -8
  81. package/models/PartnerCustomer.js +12 -13
  82. package/models/PartnerPasswordReset.js +8 -9
  83. package/models/PartnerUser.js +10 -11
  84. package/models/Partners.js +11 -12
  85. package/models/PercentageCrossedFilter.js +30 -15
  86. package/models/Polygon.js +34 -19
  87. package/models/Polyline.js +35 -19
  88. package/models/RuleRequestAggregation.js +14 -15
  89. package/models/SimpleCheckInZone.js +21 -21
  90. package/models/SingleUseToken.js +7 -8
  91. package/models/SpeedFilter.js +39 -19
  92. package/models/TestDevice.js +11 -12
  93. package/models/TestDeviceCluster.js +9 -10
  94. package/models/TestInstance.js +9 -10
  95. package/models/TestScenario.js +9 -10
  96. package/models/TimeOfDayRange.js +16 -16
  97. package/models/TimeOfDayRangeFilter.js +36 -18
  98. package/models/UrlAction.js +54 -0
  99. package/models/Zone.js +85 -273
  100. package/models/ZoneUIState.js +18 -18
  101. package/package-lock.json +3503 -0
  102. package/package.json +20 -8
  103. package/schemas/Point.js +10 -13
  104. package/__tests__/zone/checkActions.js +0 -64
  105. package/__tests__/zone/checkAppId.js +0 -41
  106. package/__tests__/zone/checkBeacon.js +0 -46
  107. package/__tests__/zone/checkBearingFitler.js +0 -48
  108. package/__tests__/zone/checkBoundingBox.js +0 -44
  109. package/__tests__/zone/checkCalendarDateRangeFilterFitler.js +0 -48
  110. package/__tests__/zone/checkCircle.js +0 -41
  111. package/__tests__/zone/checkMRT.js +0 -46
  112. package/__tests__/zone/checkPercentageCrossedFitler.js +0 -48
  113. package/__tests__/zone/checkPolygon.js +0 -78
  114. package/__tests__/zone/checkPolyline.js +0 -78
  115. package/__tests__/zone/checkSpeedFitler.js +0 -48
  116. package/__tests__/zone/checkTimeOfDayRangeFitler.js +0 -48
  117. package/models/URLAction.js +0 -34
@@ -1,36 +1,59 @@
1
- let mongoose = require('mongoose');
2
- let uuidv1 = require('uuid/v1');
3
-
4
- let BearingSchema = new mongoose.Schema({
5
- guid : { type: String, default: uuidv1 },
6
- type : { type: String, required: true, default: "bearingFilter" },
7
- fromAngle : { type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359 },
8
- toAngle : { type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359, validate: validateAngles }
9
- },
1
+ let mongoose = require('mongoose')
2
+ let uuidv4 = require('uuid/v4')
3
+
4
+ const schema = {
5
+ guid: {type: String, default: uuidv4},
6
+ fromAngle: {type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359},
7
+ toAngle: {type: Number, required: true, min: 0, max: 359, validate: {isAsync: true, validator: validateAngles, msg: 'default error message'}}
8
+ }
9
+
10
+ const BearingFilterSchema = new mongoose.Schema(
11
+ schema,
10
12
  {
11
- _id : false,
12
- versionKey : false
13
+ _id: false,
14
+ versionKey: false
15
+ })
16
+
17
+ BearingFilterSchema.add({
18
+ type:
19
+ {type: String, required: true}
20
+ })
21
+
22
+ function validateAngles (toAngle, cb) {
23
+ let magicCallback = cb
24
+ let fromAngle = this.fromAngle
25
+
26
+ if (!toAngle && toAngle !== 0) {
27
+ return magicCallback(false, 'toAngle is required')
13
28
  }
14
- );
15
29
 
16
- function validateAngles(toAngle){
17
- let fromAngle = this.fromAngle;
30
+ if (toAngle === fromAngle) {
31
+ return magicCallback(false, 'fromAngle and toAngle cannot be the same')
32
+ }
18
33
 
19
34
  if (fromAngle > toAngle) {
20
35
  if ((fromAngle - toAngle) <= 270) {
21
- throw new Error("From Angle and To Angle must best separated by at least 90 degrees in both directions. ");
36
+ return magicCallback(false, 'From Angle and To Angle must best separated by at least 90 degrees in both directions')
22
37
  }
23
- } else if (toAngle > fromAngle) {
38
+ }
39
+ if (toAngle > fromAngle) {
24
40
  if (((toAngle - fromAngle) < 90) || (((toAngle - fromAngle) > 270))) {
25
- throw new Error("From Angle and To Angle must best separated by at least 90 degrees in both directions. ");
41
+ return magicCallback(false, 'From Angle and To Angle must best separated by at least 90 degrees in both directions')
26
42
  }
27
- } else {
28
- throw new Error("fromAngle and toAngle cannot be same. ");
29
43
  }
30
-
44
+ magicCallback(true)
31
45
  }
32
46
 
47
+ // optional mongoose
48
+ let model = (mongooseInstance) => {
49
+ let BearingFilter
50
+ if (mongooseInstance) {
51
+ BearingFilter = mongooseInstance.model('BearingFilter', BearingFilterSchema)
52
+ } else {
53
+ BearingFilter = mongoose.model('BearingFilter', BearingFilterSchema)
54
+ }
33
55
 
34
- let Bearing = mongoose.model('Bearing', BearingSchema);
35
-
36
- module.exports = Bearing;
56
+ return BearingFilter
57
+ }
58
+ // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
59
+ module.exports = { BearingFilter: model, Schema: BearingFilterSchema, bearingFilterSchema: schema }
@@ -1,24 +1,40 @@
1
- let mongoose = require('mongoose');
2
- let StateEnum = require('@bluedot-innovation/enums').StateEnum;
3
- let uuidv1 = require('uuid/v1');
4
- let Point = require('../schemas/Point');
1
+ let mongoose = require('mongoose')
2
+ let StateEnum = require('@bluedot-innovation/enums').StateEnum
3
+ let uuidv4 = require('uuid/v4')
4
+ let Point = require('../schemas/Point')
5
5
 
6
- let BoundingBoxSchema = new mongoose.Schema({
7
- guid : { type: String, default: uuidv1 },
8
- type : { type: String, default: "MultiLineString" },
9
- name : { type: String, required: [true, 'name is required. '] },
10
- northEast : { type: Point, required: [true, 'northEast is required. '] },
11
- southWest : { type: Point, required: [true, 'southWest is required. '] },
12
- creationTime : { type: Date, default: Date.now },
13
- lastUpdateTime : { type: Date, default: Date.now },
14
- state : { type: String, default : StateEnum.active, select: false }
15
- },
6
+ const schema = {
7
+ guid: {type: String, default: uuidv4},
8
+ name: {type: String, required: [true, 'name is required. ']},
9
+ northEast: {type: Point, required: [true, 'northEast is required. ']},
10
+ southWest: {type: Point, required: [true, 'southWest 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
+
16
+ const BoundingBoxSchema = new mongoose.Schema(
17
+ schema,
16
18
  {
17
- _id : false,
18
- versionKey : false
19
- }
20
- );
19
+ _id: false,
20
+ versionKey: false
21
+ })
21
22
 
22
- let BoundingBox = mongoose.model('BoundingBox', BoundingBoxSchema);
23
+ BoundingBoxSchema.add({
24
+ type:
25
+ {type: String, required: true}
26
+ })
27
+
28
+ // optional mongoose
29
+ let model = (mongooseInstance) => {
30
+ let BoundingBox
31
+ if (mongooseInstance) {
32
+ BoundingBox = mongooseInstance.model('BoundingBox', BoundingBoxSchema)
33
+ } else {
34
+ BoundingBox = mongoose.model('BoundingBox', BoundingBoxSchema)
35
+ }
23
36
 
24
- module.exports = BoundingBox;
37
+ return BoundingBox
38
+ }
39
+ // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
40
+ module.exports = { BoundingBox: model, Schema: BoundingBoxSchema, boundingBoxSchema: schema }
@@ -1,27 +1,42 @@
1
- let mongoose = require('mongoose');
2
- let uuidv1 = require('uuid/v1');
1
+ let mongoose = require('mongoose')
2
+ let uuidv4 = require('uuid/v4')
3
3
 
4
- let DateFilterSchema = new mongoose.Schema({
5
- guid : { type: String, default: uuidv1 },
6
- type : { type: String, required: true, default: "dateFilter" },
7
- startDate : { type: Date, required: [true, 'startDate is required. '] },
8
- endDate : { type: Date, required: [true, 'endDate is required. '], validate: validateDateRange }
9
- },
4
+ let schema = {
5
+ guid: {type: String, default: uuidv4},
6
+ startDate: {type: Date, required: [true, 'startDate is required. ']},
7
+ endDate: {type: Date, required: [true, 'endDate is required. '], validate: validateDateRange}
8
+ }
9
+ let CalendarDateRangeFilterSchema = new mongoose.Schema(
10
+ schema,
10
11
  {
11
- _id : false,
12
- versionKey : false
13
- }
14
- );
12
+ _id: false,
13
+ versionKey: false
14
+ })
15
+
16
+ CalendarDateRangeFilterSchema.add({
17
+ type:
18
+ {type: String, required: true}
19
+ })
15
20
 
16
- function validateDateRange(endDate){
17
- let startDate = new Date(this.startDate);
18
- endDate = new Date(endDate);
21
+ function validateDateRange (endDate) {
22
+ let startDate = new Date(this.startDate)
23
+ endDate = new Date(endDate)
19
24
 
20
- if(endDate < startDate) {
21
- throw new Error("startDate has to be less than endDate. ");
25
+ if (endDate < startDate) {
26
+ throw new Error('startDate has to be less than endDate. ')
22
27
  }
23
28
  }
24
29
 
25
- let DateFilter = mongoose.model('DateFilter', DateFilterSchema);
30
+ // optional mongoose
31
+ let model = (mongooseInstance) => {
32
+ let CalendarDateRangeFilter
33
+ if (mongooseInstance) {
34
+ CalendarDateRangeFilter = mongooseInstance.model('CalendarDateRange', CalendarDateRangeFilterSchema)
35
+ } else {
36
+ CalendarDateRangeFilter = mongoose.model('CalendarDateRange', CalendarDateRangeFilterSchema)
37
+ }
26
38
 
27
- module.exports = DateFilter;
39
+ return CalendarDateRangeFilter
40
+ }
41
+ // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
42
+ module.exports = { CalendarDateRangeFilter: model, Schema: CalendarDateRangeFilterSchema, calendarDateRangeFilterSchema: schema }
package/models/Circle.js CHANGED
@@ -1,25 +1,40 @@
1
- let mongoose = require('mongoose');
2
- let StateEnum = require('@bluedot-innovation/enums').StateEnum;
3
- let Point = require('../schemas/Point');
4
- let uuidv1 = require('uuid/v1');
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
+ let schema = {
7
+ guid: {type: String, default: uuidv4},
8
+ name: {type: String, required: [true, 'name is required. ']},
9
+ radius: {type: Number, required: [true, 'radius is required. '], min: 5},
10
+ center: {type: Point, required: [true, 'center 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
+ }
6
15
 
7
- let CircleSchema = new mongoose.Schema({
8
- guid : { type: String, default: uuidv1 },
9
- type : { type: String, default: "MultiLineString" },
10
- name : { type: String, required: [true, 'name is required. '] },
11
- radius : { type: Number, required: [true, 'radius is required. '], min: 5 },
12
- center : { type: Point, required: [true, 'center is required. '] },
13
- creationTime : { type: Date, default: Date.now },
14
- lastUpdateTime : { type: Date, default: Date.now },
15
- state : { type: String, default : StateEnum.active, select: false }
16
- },
16
+ let CircleSchema = new mongoose.Schema(
17
+ schema,
17
18
  {
18
19
  _id: false,
19
20
  __v: false
20
- }
21
- );
21
+ })
22
+
23
+ CircleSchema.add({
24
+ type:
25
+ {type: String, required: true}
26
+ })
22
27
 
23
- let Circle = mongoose.model('Circle', CircleSchema);
28
+ // optional mongoose
29
+ let model = (mongooseInstance) => {
30
+ let Circle
31
+ if (mongooseInstance) {
32
+ Circle = mongooseInstance.model('Circle', CircleSchema)
33
+ } else {
34
+ Circle = mongoose.model('Circle', CircleSchema)
35
+ }
24
36
 
25
- module.exports = Circle;
37
+ return Circle
38
+ }
39
+ // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
40
+ module.exports = { Circle: model, Schema: CircleSchema, circleSchema: schema }
@@ -3,43 +3,42 @@
3
3
  * Copyright : Bluedot Innovations.
4
4
  * Owner :
5
5
  */
6
- var mongoose = require('mongoose');
6
+ let mongoose = require('mongoose')
7
7
 
8
- var Contract = mongoose.model('Contract', new mongoose.Schema(
9
- {
10
- customerId: String,
11
- organisationName: String,
12
- addressLine1: String,
13
- addressLine2: String,
14
- addressCity: String,
15
- addressRegion: String,
16
- addressPostcode: String,
17
- addressCountry: String,
18
- billingFirstName: String,
19
- billingLastName: String,
20
- billingTaxNumber: String,
21
- billingEmail: String,
22
- tradingName: String,
23
- salesforceUrl: String,
24
- startDate : {type: Date, default: Date.now},
25
- endDate : {type: Date, default: Date.now},
26
- frequency : mongoose.Schema.Types.Number,
27
- monthEntries: [],
28
- currency: {type: String, default: "USD"},
29
- currencyRate: Number,
30
- template: String,
31
- addedBy: String,
32
- lastEditedBy: String,
33
- xeroContactId: String,
34
- state: String,
35
- creationTime : {type: Date, default: Date.now},
36
- lastUpdateTime : {type: Date, default: Date.now},
37
- dataSource : {type:String, select: false, default : 'adminPortal'}
38
- },
39
- {
40
- collection : 'contract'
41
- }
42
- )
43
- );
8
+ let Contract = mongoose.model('Contract', new mongoose.Schema(
9
+ {
10
+ customerId: String,
11
+ organisationName: String,
12
+ addressLine1: String,
13
+ addressLine2: String,
14
+ addressCity: String,
15
+ addressRegion: String,
16
+ addressPostcode: String,
17
+ addressCountry: String,
18
+ billingFirstName: String,
19
+ billingLastName: String,
20
+ billingTaxNumber: String,
21
+ billingEmail: String,
22
+ tradingName: String,
23
+ salesforceUrl: String,
24
+ startDate: {type: Date, default: Date.now},
25
+ endDate: {type: Date, default: Date.now},
26
+ frequency: mongoose.Schema.Types.Number,
27
+ monthEntries: [],
28
+ currency: {type: String, default: 'USD'},
29
+ currencyRate: Number,
30
+ template: String,
31
+ addedBy: String,
32
+ lastEditedBy: String,
33
+ xeroContactId: String,
34
+ state: String,
35
+ creationTime: {type: Date, default: Date.now},
36
+ lastUpdateTime: {type: Date, default: Date.now},
37
+ dataSource: {type: String, select: false, default: 'adminPortal'}
38
+ },
39
+ {
40
+ collection: 'contract'
41
+ })
42
+ )
44
43
 
45
- module.exports = Contract;
44
+ module.exports = Contract
@@ -3,36 +3,36 @@
3
3
  * Copyright : Bluedot Innovations.
4
4
  * Owner :
5
5
  */
6
- var mongoose = require('mongoose');
7
- var StateEnum = require('@bluedot-innovation/enums').StateEnum;
6
+ let mongoose = require('mongoose')
7
+ let StateEnum = require('@bluedot-innovation/enums').StateEnum
8
+ let Schema = mongoose.Schema
8
9
 
9
- var Customer = mongoose.model('Customer', new mongoose.Schema(
10
- {
11
- _id: String,
12
- customerApiKey: String,
13
- email: String,
14
- password: String,
15
- name: String,
16
- userName: String,
17
- state: {type:String, default: StateEnum.active},
18
- "creationTime" : {type: Date, default: Date.now},
19
- "lastUpdateTime" : {type: Date, default: Date.now},
20
- "dataSource" : {type:String, select: false, default : 'openApi'},
21
- integrations: Schema.Types.Mixed,
22
- firstName: String,
23
- lastName: String,
24
- oldPassword: String,
25
- organisationWebsite: String,
26
- organisationName: String,
27
- phoneNumber: String,
28
- createdBy: String,
29
- poiCredits: {type: Number, default: 0},
30
- address: []
31
- },
32
- {
33
- collection : 'customer'
34
- }
35
- )
36
- );
10
+ let Customer = mongoose.model('Customer', new mongoose.Schema(
11
+ {
12
+ _id: String,
13
+ customerApiKey: String,
14
+ email: String,
15
+ password: String,
16
+ name: String,
17
+ userName: String,
18
+ state: {type: String, default: StateEnum.active},
19
+ 'creationTime': {type: Date, default: Date.now},
20
+ 'lastUpdateTime': {type: Date, default: Date.now},
21
+ 'dataSource': {type: String, select: false, default: 'openApi'},
22
+ integrations: Schema.Types.Mixed,
23
+ firstName: String,
24
+ lastName: String,
25
+ oldPassword: String,
26
+ organisationWebsite: String,
27
+ organisationName: String,
28
+ phoneNumber: String,
29
+ createdBy: String,
30
+ poiCredits: {type: Number, default: 0},
31
+ address: []
32
+ },
33
+ {
34
+ collection: 'customer'
35
+ })
36
+ )
37
37
 
38
- module.exports = Customer;
38
+ module.exports = Customer
@@ -2,8 +2,8 @@
2
2
  * Created by andrewstirling on 20/6/17.
3
3
  */
4
4
 
5
- var mongoose = require('mongoose');
6
- var StateEnum = require('@bluedot-innovation/enums').StateEnum;
5
+ var mongoose = require('mongoose')
6
+ var StateEnum = require('@bluedot-innovation/enums').StateEnum
7
7
 
8
8
  var CustomerLogin = mongoose.model('CustomerLogin', new mongoose.Schema(
9
9
  {
@@ -19,16 +19,15 @@ var CustomerLogin = mongoose.model('CustomerLogin', new mongoose.Schema(
19
19
  integrations: {},
20
20
  resetToken: String,
21
21
  lastLoginTime: Date,
22
- state: {type:String, default: StateEnum.active},
23
- creationTime : {type: Date, default: Date.now},
24
- lastUpdateTime : {type: Date, default: Date.now},
22
+ state: {type: String, default: StateEnum.active},
23
+ creationTime: {type: Date, default: Date.now},
24
+ lastUpdateTime: {type: Date, default: Date.now},
25
25
  createdBy: String,
26
26
  lastUpdatedBy: String
27
27
  },
28
28
  {
29
- collection : 'customerLogin'
30
- }
31
- )
32
- );
29
+ collection: 'customerLogin'
30
+ })
31
+ )
33
32
 
34
- module.exports = CustomerLogin;
33
+ module.exports = CustomerLogin
package/models/DBEvent.js CHANGED
@@ -3,19 +3,18 @@
3
3
  * Copyright : Bluedot Innovations.
4
4
  * Owner :
5
5
  */
6
- var mongoose = require('mongoose');
7
- Schema = mongoose.Schema;
6
+ let mongoose = require('mongoose')
8
7
 
9
- var DBEventSchema = new mongoose.Schema({
10
- _class : {type: String, default:"au.com.bluedot.application.spring.DBEvent"},
11
- customerId : String,
12
- customerEmail : String,
13
- actionName : String,
14
- referenceId: String,
15
- creationTime: {type: Date, select: false, default: Date.now},
16
- },
17
- { collection : 'dbevent' }
18
- );
19
- var DBEvent = mongoose.model('DBEvent', DBEventSchema);
8
+ let DBEventSchema = new mongoose.Schema({
9
+ _class: {type: String, default: 'au.com.bluedot.application.spring.DBEvent'},
10
+ customerId: String,
11
+ customerEmail: String,
12
+ actionName: String,
13
+ referenceId: String,
14
+ creationTime: {type: Date, select: false, default: Date.now}
15
+ },
16
+ {collection: 'dbevent'}
17
+ )
18
+ let DBEvent = mongoose.model('DBEvent', DBEventSchema)
20
19
 
21
- module.exports = DBEvent;
20
+ module.exports = DBEvent
@@ -0,0 +1,28 @@
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
@@ -3,35 +3,34 @@
3
3
  * Copyright : Bluedot Innovations.
4
4
  * Owner :
5
5
  */
6
- var mongoose = require('mongoose');
6
+ var mongoose = require('mongoose')
7
7
 
8
8
  var DeviceRulesRequest = mongoose.model('DeviceRulesRequest', new mongoose.Schema(
9
- {
10
- _id : String,
11
- _class : {type: String, default:"au.com.bluedot.application.model.client.DeviceRulesRequest"},
12
- currentDeviceLocation : {
13
- "longitude" : Number,
14
- "latitude" : Number,
15
- "geometryType" : String
16
- },
17
- installationReference : String,
18
- apiKey : String,
19
- packageName : String,
20
- clientEmail : String,
21
- batteryStatus : String,
22
- deviceType : String,
23
- locationMethod : String,
24
- platform : String,
25
- sdkVersion : String,
26
- osVersion : String,
27
- speed : Number,
28
- creationTime : { type: Date, default: Date.now },
29
- lastUpdateTime : { type: Date, default: Date.now }
9
+ {
10
+ _id: String,
11
+ _class: {type: String, default: 'au.com.bluedot.application.model.client.DeviceRulesRequest'},
12
+ currentDeviceLocation: {
13
+ 'longitude': Number,
14
+ 'latitude': Number,
15
+ 'geometryType': String
30
16
  },
31
- {
32
- collection: 'deviceRulesRequest'
33
- }
34
- )
35
- );
17
+ installationReference: String,
18
+ apiKey: String,
19
+ packageName: String,
20
+ clientEmail: String,
21
+ batteryStatus: String,
22
+ deviceType: String,
23
+ locationMethod: String,
24
+ platform: String,
25
+ sdkVersion: String,
26
+ osVersion: String,
27
+ speed: Number,
28
+ creationTime: { type: Date, default: Date.now },
29
+ lastUpdateTime: { type: Date, default: Date.now }
30
+ },
31
+ {
32
+ collection: 'deviceRulesRequest'
33
+ })
34
+ )
36
35
 
37
- module.exports = DeviceRulesRequest;
36
+ module.exports = DeviceRulesRequest
package/models/Fence.js CHANGED
@@ -3,19 +3,18 @@
3
3
  * Copyright : Bluedot Innovations.
4
4
  * Owner :
5
5
  */
6
- var mongoose = require('mongoose');
7
- Schema = mongoose.Schema;
6
+ let mongoose = require('mongoose')
7
+ const Schema = mongoose.Schema
8
8
 
9
- var FenceSchema = new mongoose.Schema({
10
- "_id" : {type: String},
11
- "creationTime" : {type: Date, default: Date.now},
12
- "lastUpdateTime" : {type: Date, default: Date.now},
13
- "type" : {type:String, default: "Feature"},
14
- "dataSource" : {type:String, select: false, default : 'openApi'},
15
- "geometry" : {type: Schema.Types.Mixed, default: {}}
16
- }
17
- );
9
+ let FenceSchema = new mongoose.Schema({
10
+ '_id': {type: String},
11
+ 'creationTime': {type: Date, default: Date.now},
12
+ 'lastUpdateTime': {type: Date, default: Date.now},
13
+ 'type': {type: String, default: 'Feature'},
14
+ 'dataSource': {type: String, select: false, default: 'openApi'},
15
+ 'geometry': {type: Schema.Types.Mixed, default: {}}
16
+ })
18
17
 
19
- var Fence = mongoose.model('Fence', FenceSchema);
18
+ let Fence = mongoose.model('Fence', FenceSchema)
20
19
 
21
- module.exports = Fence;
20
+ module.exports = Fence
@@ -3,21 +3,19 @@
3
3
  * Copyright : Bluedot Innovations.
4
4
  * Owner :
5
5
  */
6
- var mongoose = require('mongoose');
7
- Schema = mongoose.Schema;
6
+ let mongoose = require('mongoose')
8
7
 
9
- var FenceSchema = new mongoose.Schema({
10
- _id : {type: String},
11
- "geometry": {
12
- "type": { type: String, required: true },
13
- "coordinates": { type: Array, required: true}
14
- },
15
- "fenceId" : String,
16
- "fenceName" : String
8
+ let FenceSchema = new mongoose.Schema({
9
+ _id: {type: String},
10
+ 'geometry': {
11
+ 'type': { type: String, required: true },
12
+ 'coordinates': {type: Array, required: true}
17
13
  },
18
- { collection : 'GeoFence' }
19
- );
14
+ 'fenceId': String,
15
+ 'fenceName': String
16
+ },
17
+ {collection: 'GeoFence'})
20
18
 
21
- var GeoFence = mongoose.model('GeoFence', FenceSchema);
19
+ let GeoFence = mongoose.model('GeoFence', FenceSchema)
22
20
 
23
- module.exports = GeoFence;
21
+ module.exports = GeoFence