@bluedot-innovation/models 2.0.0-alpha.2 → 2.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +6 -0
- package/.gitlab-ci.yml +40 -0
- package/.nyc_output/35cf8a0cc73b518d0684cad2d4dfc679.json +1 -0
- package/.nyc_output/bd25154d8c33e81a68c3281fc3007b9c.json +1 -0
- package/Models.js +8 -8
- package/README.MD +18 -0
- package/__tests__/action/message/messageAction.data.json +5 -0
- package/__tests__/action/message/messageAction.rules.json +3 -0
- package/__tests__/action/message/messageAction.spec.js +61 -0
- package/__tests__/action/url/urlAction.data.json +4 -0
- package/__tests__/action/url/urlAction.rules.json +3 -0
- package/__tests__/action/url/urlAction.spec.js +62 -0
- package/__tests__/dailyStats/checkDailyStats.js +30 -0
- package/__tests__/filter/bearing/bearingFilter.data.json +5 -0
- package/__tests__/filter/bearing/bearingFilter.rules.json +3 -0
- package/__tests__/filter/bearing/bearingFilter.spec.js +95 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.data.json +5 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.rules.json +3 -0
- package/__tests__/filter/calendarDateRange/calendarDateRangeFilter.spec.js +62 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.data.json +5 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.rules.json +3 -0
- package/__tests__/filter/percentageCrossed/percentageCrossedFilter.spec.js +62 -0
- package/__tests__/filter/speed/speedFilter.data.json +5 -0
- package/__tests__/filter/speed/speedFilter.rules.json +3 -0
- package/__tests__/filter/speed/speedFilter.spec.js +73 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.data.json +5 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.rules.json +3 -0
- package/__tests__/filter/timeOfDayRange/timeOfDayRange.spec.js +73 -0
- package/__tests__/zone/beacon.spec.js +95 -0
- package/__tests__/zone/boundingBox.spec.js +61 -0
- package/__tests__/zone/circle.spec.js +71 -0
- package/__tests__/zone/data/beacon.data.json +12 -0
- package/__tests__/zone/data/boundingBox.data.json +12 -0
- package/__tests__/zone/data/polygon.data.json +46 -0
- package/__tests__/zone/data/polyline.data.json +46 -0
- package/__tests__/zone/data/zone-with-invalid-circle.json +34 -0
- package/__tests__/zone/data/zone.data.json +154 -0
- package/__tests__/zone/polygon.spec.js +61 -0
- package/__tests__/zone/polyline.spec.js +61 -0
- package/__tests__/zone/rules/beacon.rules.json +13 -0
- package/__tests__/zone/rules/boundingBox.rules.json +3 -0
- package/__tests__/zone/rules/circle.rules.json +3 -0
- package/__tests__/zone/rules/polygon.rules.json +3 -0
- package/__tests__/zone/rules/polyline.rules.json +3 -0
- package/__tests__/zone/zone.spec.js +101 -0
- package/models/AdminPortalUser.js +10 -11
- package/models/AdminUser.js +6 -5
- package/models/Application.js +31 -30
- package/models/Beacon.js +93 -78
- package/models/BeaconFilter.js +9 -10
- package/models/BearingFilter.js +38 -23
- package/models/BoundingBox.js +28 -20
- package/models/CalendarDateRangeFilter.js +28 -20
- package/models/Circle.js +28 -21
- package/models/Contract.js +37 -38
- package/models/Customer.js +31 -31
- package/models/CustomerLogin.js +9 -10
- package/models/DBEvent.js +13 -14
- package/models/DailyStats.js +28 -0
- package/models/DeviceRulesRequest.js +27 -28
- package/models/Fence.js +12 -13
- package/models/GeoFence.js +12 -14
- package/models/Geofeature.js +18 -18
- package/models/MessageAction.js +26 -18
- package/models/NotificationLogEntry.js +7 -8
- package/models/POILocation.js +6 -7
- package/models/POILookup.js +8 -9
- package/models/POIResult.js +7 -8
- package/models/PartnerCustomer.js +12 -13
- package/models/PartnerPasswordReset.js +8 -9
- package/models/PartnerUser.js +10 -11
- package/models/Partners.js +11 -12
- package/models/PercentageCrossedFilter.js +23 -15
- package/models/Polygon.js +26 -19
- package/models/Polyline.js +25 -19
- package/models/RuleRequestAggregation.js +14 -15
- package/models/SimpleCheckInZone.js +21 -21
- package/models/SingleUseToken.js +7 -8
- package/models/SpeedFilter.js +31 -19
- package/models/TestDevice.js +11 -12
- package/models/TestDeviceCluster.js +9 -10
- package/models/TestInstance.js +9 -10
- package/models/TestScenario.js +9 -10
- package/models/TimeOfDayRange.js +16 -16
- package/models/TimeOfDayRangeFilter.js +27 -18
- package/models/UrlAction.js +45 -0
- package/models/Zone.js +191 -266
- package/models/ZoneUIState.js +18 -18
- package/package.json +15 -6
- package/schemas/Point.js +10 -13
- package/__tests__/zone/checkActions.js +0 -62
- package/__tests__/zone/checkBearingFitler.js +0 -46
- package/__tests__/zone/checkBoundingBox.js +0 -42
- package/__tests__/zone/checkCalendarDateRangeFilterFitler.js +0 -46
- package/__tests__/zone/checkCircle.js +0 -39
- package/__tests__/zone/checkPercentageCrossedFitler.js +0 -46
- package/__tests__/zone/checkPolygon.js +0 -76
- package/__tests__/zone/checkPolyline.js +0 -76
- package/__tests__/zone/checkSpeedFitler.js +0 -46
- package/__tests__/zone/checkTimeOfDayRangeFitler.js +0 -46
- package/models/URLAction.js +0 -34
package/models/Beacon.js
CHANGED
|
@@ -1,93 +1,108 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let StateEnum
|
|
3
|
-
let uuidv4
|
|
4
|
-
let 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
6
|
let BeaconSchema = new mongoose.Schema({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
txPower : { type: Number, default: 1 },
|
|
17
|
-
macAddress : { type: String },
|
|
18
|
-
proximityUUID : { type: String },
|
|
19
|
-
beaconType : { type: String },
|
|
20
|
-
location : { type: Point },
|
|
21
|
-
proximity : { type: String, default: 'Far', validate: validateBeacons }
|
|
7
|
+
customerApiKey: {type: String, validate: [{validator: validateKey, msg: 'Customer API Key is required'}]},
|
|
8
|
+
apiKey: {type: String, validate: [{validator: validateKey, msg: 'API Key is required'}]},
|
|
9
|
+
guid: {type: String, default: uuidv4},
|
|
10
|
+
type: {type: String},
|
|
11
|
+
name: {type: String, required: [true, 'name is required. ']},
|
|
12
|
+
longitude: {
|
|
13
|
+
type: Number,
|
|
14
|
+
required: true,
|
|
15
|
+
validate: [{validator: validateLongitude, msg: 'Longitude is required (insert format here)'}]
|
|
22
16
|
},
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
latitude: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: true,
|
|
20
|
+
validate: [{validator: validateLatitude, msg: 'Latitude is required (insert format here)'}]
|
|
21
|
+
},
|
|
22
|
+
description: {type: String, default: ''},
|
|
23
|
+
lastUpdateTime: {type: Date},
|
|
24
|
+
state: {type: String, default: StateEnum.active},
|
|
25
|
+
major: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Major needs to be within range(1-65535)'}]},
|
|
26
|
+
minor: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Minor needs to be within range(1-65535)'}]},
|
|
27
|
+
txPower: {type: Number},
|
|
28
|
+
macAddress: {type: String},
|
|
29
|
+
proximityUUID: {type: String},
|
|
30
|
+
beaconType: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
validate: {
|
|
34
|
+
isAsync: true,
|
|
35
|
+
validator: validateBeaconType,
|
|
36
|
+
msg: 'Async validation. Not used'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
location: {type: Point},
|
|
40
|
+
proximity: {type: String, default: 'Far'}
|
|
41
|
+
})
|
|
28
42
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//let proximity = this.proximity;
|
|
43
|
+
// mongoose validator helper plugin
|
|
44
|
+
BeaconSchema.post('validate', function (doc) {
|
|
45
|
+
console.debug('Beacon Schema post validate hook')
|
|
46
|
+
this.lastUpdateTime = Date.now()
|
|
47
|
+
Object.assign(this.errors || {}, this.errors || {}, this.customErrors)
|
|
48
|
+
})
|
|
36
49
|
|
|
37
|
-
|
|
50
|
+
function validateMajorMinor (v) {
|
|
51
|
+
'use strict'
|
|
52
|
+
return v >= 1 && v <= 65535
|
|
53
|
+
}
|
|
38
54
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
errorList = errorList + "Beacon should have a proximityUUID field. ";
|
|
45
|
-
}
|
|
55
|
+
function validateLatitude (longitude) {
|
|
56
|
+
'use strict'
|
|
57
|
+
let regex = new RegExp(/^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?)$/gi)
|
|
58
|
+
return regex.test(longitude)
|
|
59
|
+
}
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
errorList = errorList + proximityUUID + ' is not a valid ID.';
|
|
53
|
-
}
|
|
54
|
-
}
|
|
61
|
+
function validateLongitude (latitude) {
|
|
62
|
+
'use strict'
|
|
63
|
+
let regex = new RegExp(/^[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/gi)
|
|
64
|
+
return regex.test(latitude)
|
|
65
|
+
}
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
function validateBeaconType (v, cb) {
|
|
68
|
+
'use strict'
|
|
69
|
+
let magicCallback = cb
|
|
70
|
+
const beaconType = v
|
|
71
|
+
const minor = this.minor
|
|
72
|
+
const major = this.major
|
|
73
|
+
const macAddress = this.macAddress
|
|
74
|
+
const txPower = this.txPower
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
errorList = errorList + "Beacon minor should be within the range 0 to 65535. ";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
76
|
+
let androidRegex = new RegExp(/(android)/ig)
|
|
77
|
+
let iosRegex = new RegExp(/(ios)/ig)
|
|
78
|
+
let bothRegex = new RegExp(/(both)/ig)
|
|
68
79
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
}
|
|
80
|
+
if (androidRegex.test(beaconType)) {
|
|
81
|
+
magicCallback((!!macAddress && !!txPower), 'Beacon type "Android" must have both mac address and tx power values')
|
|
82
|
+
} else if (iosRegex.test(beaconType)) {
|
|
83
|
+
magicCallback((!!minor && !!major), 'Beacon type "IOS" must have both minor and major values')
|
|
84
|
+
} else if (bothRegex.test(beaconType)) {
|
|
85
|
+
magicCallback((!!minor && !!major && !!txPower && !!macAddress), 'Beacon type "Both" must have all of minor, major, tx power, and mac address values')
|
|
86
|
+
} else {
|
|
87
|
+
magicCallback(true)
|
|
79
88
|
}
|
|
89
|
+
}
|
|
80
90
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
console.log(errorList);
|
|
87
|
-
throw new Error(errorList);
|
|
88
|
-
}
|
|
91
|
+
function validateKey (apiKey) {
|
|
92
|
+
// todo beacon can be added via zone or individually. so decide whether we need to validate apikey/ customerapikey, or log in function will solve that
|
|
93
|
+
'use strict'
|
|
94
|
+
let regex = new RegExp(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)
|
|
95
|
+
return !!regex.test(apiKey)
|
|
89
96
|
}
|
|
90
97
|
|
|
91
|
-
|
|
98
|
+
// optional mongoose
|
|
99
|
+
module.exports = (mongooseInstance) => {
|
|
100
|
+
let Beacon
|
|
101
|
+
if (mongooseInstance) {
|
|
102
|
+
Beacon = mongooseInstance.model('Beacon', BeaconSchema)
|
|
103
|
+
} else {
|
|
104
|
+
Beacon = mongoose.model('Beacon', BeaconSchema)
|
|
105
|
+
}
|
|
92
106
|
|
|
93
|
-
|
|
107
|
+
return Beacon
|
|
108
|
+
}
|
package/models/BeaconFilter.js
CHANGED
|
@@ -3,21 +3,20 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
Schema = mongoose.Schema;
|
|
6
|
+
let mongoose = require('mongoose')
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
let BeaconFilterSchema = new mongoose.Schema(
|
|
10
9
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
'_class': {type: String, default: 'au.com.bluedot.application.spring.filter.spatial.BeaconFilter'},
|
|
11
|
+
'beacon': {},
|
|
12
|
+
'guid': String,
|
|
13
|
+
'type': {type: String, default: 'beacon'}
|
|
15
14
|
},
|
|
16
15
|
{
|
|
17
16
|
_id: false
|
|
18
17
|
}
|
|
19
|
-
)
|
|
18
|
+
)
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
let BeaconFilter = mongoose.model('BeaconFilter', BeaconFilterSchema)
|
|
22
21
|
|
|
23
|
-
module.exports = BeaconFilter
|
|
22
|
+
module.exports = BeaconFilter
|
package/models/BearingFilter.js
CHANGED
|
@@ -1,36 +1,51 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let uuidv4
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
let BearingFilterSchema = new mongoose.Schema({
|
|
5
|
+
guid: {type: String, default: uuidv4},
|
|
6
|
+
type: {type: String, required: true},
|
|
7
|
+
fromAngle: {type: Number, required: [true, 'fromAngle is required. '], min: 0, max: 359},
|
|
8
|
+
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {validator: validateAngles, msg: 'default error message'}}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
_id: false,
|
|
12
|
+
versionKey: false
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
function validateAngles (toAngle, cb) {
|
|
17
|
+
let magicCallback = cb
|
|
18
|
+
let fromAngle = this.fromAngle
|
|
19
|
+
|
|
20
|
+
if (!toAngle && toAngle !== 0) {
|
|
21
|
+
return magicCallback(false, 'toAngle is required')
|
|
13
22
|
}
|
|
14
|
-
);
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
if (toAngle === fromAngle) {
|
|
25
|
+
return magicCallback(false, 'fromAngle and toAngle cannot be the same')
|
|
26
|
+
}
|
|
18
27
|
|
|
19
28
|
if (fromAngle > toAngle) {
|
|
20
29
|
if ((fromAngle - toAngle) <= 270) {
|
|
21
|
-
|
|
30
|
+
return magicCallback(false, 'From Angle and To Angle must best separated by at least 90 degrees in both directions')
|
|
22
31
|
}
|
|
23
|
-
}
|
|
32
|
+
}
|
|
33
|
+
if (toAngle > fromAngle) {
|
|
24
34
|
if (((toAngle - fromAngle) < 90) || (((toAngle - fromAngle) > 270))) {
|
|
25
|
-
|
|
35
|
+
return magicCallback(false, 'From Angle and To Angle must best separated by at least 90 degrees in both directions')
|
|
26
36
|
}
|
|
27
|
-
} else {
|
|
28
|
-
throw new Error("fromAngle and toAngle cannot be same. ");
|
|
29
37
|
}
|
|
30
|
-
|
|
38
|
+
magicCallback(true)
|
|
31
39
|
}
|
|
32
40
|
|
|
41
|
+
// optional mongoose
|
|
42
|
+
module.exports = (mongooseInstance) => {
|
|
43
|
+
let BearingFilter
|
|
44
|
+
if (mongooseInstance) {
|
|
45
|
+
BearingFilter = mongooseInstance.model('BearingFilter', BearingFilterSchema)
|
|
46
|
+
} else {
|
|
47
|
+
BearingFilter = mongoose.model('BearingFilter', BearingFilterSchema)
|
|
48
|
+
}
|
|
33
49
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
module.exports = Bearing;
|
|
50
|
+
return BearingFilter
|
|
51
|
+
}
|
package/models/BoundingBox.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let StateEnum
|
|
3
|
-
let uuidv4
|
|
4
|
-
let 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
6
|
let BoundingBoxSchema = new mongoose.Schema({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
7
|
+
guid: {type: String, default: uuidv4},
|
|
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
|
+
},
|
|
16
|
+
{
|
|
17
|
+
_id: false,
|
|
18
|
+
versionKey: false
|
|
19
|
+
}
|
|
20
|
+
)
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// optional mongoose
|
|
23
|
+
module.exports = (mongooseInstance) => {
|
|
24
|
+
let BoundingBox
|
|
25
|
+
if (mongooseInstance) {
|
|
26
|
+
BoundingBox = mongooseInstance.model('BoundingBox', BoundingBoxSchema)
|
|
27
|
+
} else {
|
|
28
|
+
BoundingBox = mongoose.model('BoundingBox', BoundingBox)
|
|
29
|
+
}
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
return BoundingBox
|
|
32
|
+
}
|
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let uuidv4
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
let uuidv4 = require('uuid/v4')
|
|
3
3
|
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
4
|
+
let CalendarDateRangeSchema = new mongoose.Schema({
|
|
5
|
+
guid: {type: String, default: uuidv4},
|
|
6
|
+
type: {type: String, required: true},
|
|
7
|
+
startDate: {type: Date, required: [true, 'startDate is required. ']},
|
|
8
|
+
endDate: {type: Date, required: [true, 'endDate is required. '], validate: validateDateRange}
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
_id: false,
|
|
12
|
+
versionKey: false
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
15
|
|
|
16
|
-
function validateDateRange(endDate){
|
|
17
|
-
let startDate = new Date(this.startDate)
|
|
18
|
-
endDate = new Date(endDate)
|
|
16
|
+
function validateDateRange (endDate) {
|
|
17
|
+
let startDate = new Date(this.startDate)
|
|
18
|
+
endDate = new Date(endDate)
|
|
19
19
|
|
|
20
|
-
if(endDate < startDate) {
|
|
21
|
-
throw new Error(
|
|
20
|
+
if (endDate < startDate) {
|
|
21
|
+
throw new Error('startDate has to be less than endDate. ')
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// optional mongoose
|
|
26
|
+
module.exports = (mongooseInstance) => {
|
|
27
|
+
let CalendarDateRange
|
|
28
|
+
if (mongooseInstance) {
|
|
29
|
+
CalendarDateRange = mongooseInstance.model('CalendarDateRange', CalendarDateRangeSchema)
|
|
30
|
+
} else {
|
|
31
|
+
CalendarDateRange = mongoose.model('CalendarDateRange', CalendarDateRangeSchema)
|
|
32
|
+
}
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
return CalendarDateRange
|
|
35
|
+
}
|
package/models/Circle.js
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
let mongoose
|
|
2
|
-
let StateEnum
|
|
3
|
-
let Point
|
|
4
|
-
let uuidv4
|
|
5
|
-
|
|
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')
|
|
6
5
|
|
|
7
6
|
let CircleSchema = new mongoose.Schema({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
7
|
+
guid: {type: String, default: uuidv4},
|
|
8
|
+
type: {type: String, default: 'MultiLineString'},
|
|
9
|
+
name: {type: String, required: [true, 'name is required. ']},
|
|
10
|
+
radius: {type: Number, required: [true, 'radius is required. '], min: 5},
|
|
11
|
+
center: {type: Point, required: [true, 'center 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
|
+
},
|
|
16
|
+
{
|
|
17
|
+
_id: false,
|
|
18
|
+
__v: false
|
|
19
|
+
}
|
|
20
|
+
)
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
// optional mongoose
|
|
23
|
+
module.exports = (mongooseInstance) => {
|
|
24
|
+
let Circle
|
|
25
|
+
if (mongooseInstance) {
|
|
26
|
+
Circle = mongooseInstance.model('Circle', CircleSchema)
|
|
27
|
+
} else {
|
|
28
|
+
Circle = mongoose.model('Circle', CircleSchema)
|
|
29
|
+
}
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
return Circle
|
|
32
|
+
}
|
package/models/Contract.js
CHANGED
|
@@ -3,43 +3,42 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
let mongoose = require('mongoose')
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
collection
|
|
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
|
package/models/Customer.js
CHANGED
|
@@ -3,36 +3,36 @@
|
|
|
3
3
|
* Copyright : Bluedot Innovations.
|
|
4
4
|
* Owner :
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
let mongoose = require('mongoose')
|
|
7
|
+
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
8
|
+
let Schema = mongoose.Schema
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
collection
|
|
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
|
package/models/CustomerLogin.js
CHANGED
|
@@ -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
|
|
24
|
-
lastUpdateTime
|
|
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
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
);
|
|
29
|
+
collection: 'customerLogin'
|
|
30
|
+
})
|
|
31
|
+
)
|
|
33
32
|
|
|
34
|
-
module.exports = CustomerLogin
|
|
33
|
+
module.exports = CustomerLogin
|