@bluedot-innovation/models 6.1.0 → 6.1.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/CHANGELOG.md +4 -0
- package/__tests__/user/user.spec.js +0 -11
- package/__tests__/zone/zone.spec.js +12 -0
- package/helpers.js +4 -0
- package/models/Project.js +1 -1
- package/models/Zone.js +4 -1
- package/package.json +1 -1
- package/schemas/AccountEta.js +9 -0
- package/schemas/AccountFeatures.js +2 -1
- package/schemas/ZoneEta.js +10 -0
- package/yarn.lock +2796 -0
package/CHANGELOG.md
CHANGED
|
@@ -40,17 +40,6 @@ describe('User', () => {
|
|
|
40
40
|
done()
|
|
41
41
|
})
|
|
42
42
|
})
|
|
43
|
-
|
|
44
|
-
it('should validate a user without a phone number', (done) => {
|
|
45
|
-
delete user.phoneNumber;
|
|
46
|
-
let User = new UserModelBuiltInMongoose(user)
|
|
47
|
-
|
|
48
|
-
User.validate((err, res) => {
|
|
49
|
-
assert.notExists(res)
|
|
50
|
-
assert(err === null, 'err equals null')
|
|
51
|
-
done()
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
43
|
})
|
|
55
44
|
|
|
56
45
|
describe('Invalid User', () => {
|
|
@@ -389,5 +389,17 @@ describe('Zone', () => {
|
|
|
389
389
|
done()
|
|
390
390
|
})
|
|
391
391
|
})
|
|
392
|
+
|
|
393
|
+
it('should throw an error when eta.destinationId is longer than 128 characters', (done) => {
|
|
394
|
+
zone.eta = {
|
|
395
|
+
"destinationId": 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s'
|
|
396
|
+
}
|
|
397
|
+
let Zone = new ZoneModel(zone)
|
|
398
|
+
Zone.validate((err, res) => {
|
|
399
|
+
assert.exists(err, 'err object should exist')
|
|
400
|
+
assert.match(err.message, /(destinationId must be no more than 128 characters long)/i)
|
|
401
|
+
done()
|
|
402
|
+
})
|
|
403
|
+
})
|
|
392
404
|
})
|
|
393
405
|
})
|
package/helpers.js
CHANGED
|
@@ -240,6 +240,10 @@ helpers.ensureNonEmptyGeofeatures = function(zone, next){
|
|
|
240
240
|
next()
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
helpers.validateEtaDestinationId = function(etaDestinationId) {
|
|
244
|
+
return !(etaDestinationId.length > 128)
|
|
245
|
+
}
|
|
246
|
+
|
|
243
247
|
helpers.validateTriggerWebhooks = function(webhooks) {
|
|
244
248
|
const notTrigger = webhooks.some(webhook => {
|
|
245
249
|
return webhook.type && webhook.type != 'trigger'
|
package/models/Project.js
CHANGED
|
@@ -47,7 +47,7 @@ let ProjectSchema = new mongoose.Schema({
|
|
|
47
47
|
firebaseApiKey: {type: String, validate: helpers.validateNotNull},
|
|
48
48
|
apiKey: {type: String},
|
|
49
49
|
integrations: IntegrationSchema,
|
|
50
|
-
eta:
|
|
50
|
+
eta: projectEtaSchema
|
|
51
51
|
},
|
|
52
52
|
{collection: 'project'})
|
|
53
53
|
|
package/models/Zone.js
CHANGED
|
@@ -22,6 +22,8 @@ let travelDirectionRawSchema = require('./conditions/TravelDirection').rawSchema
|
|
|
22
22
|
let travelPathRawSchema = require('./conditions/TravelPath').rawSchema
|
|
23
23
|
let timeActiveRawSchema = require('./conditions/TimeActive').rawSchema
|
|
24
24
|
|
|
25
|
+
let zoneEtaSchema = require('../schemas/ZoneEta')
|
|
26
|
+
|
|
25
27
|
let uuidv4 = require('uuid/v4')
|
|
26
28
|
let patcher = require('@bluedot-innovation/mongoose-json-patch')
|
|
27
29
|
let helpers = require('../helpers')
|
|
@@ -117,7 +119,8 @@ let zoneSchema = new Schema({
|
|
|
117
119
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
118
120
|
projectId: {type: String, required: true, validate: {validator: helpers.validateUUIDv4, message: 'Invalid Project Id.'}},
|
|
119
121
|
state: {type: String, default: StateEnum.ACTIVE, select: false},
|
|
120
|
-
accountId: {type: String, required: true, validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'default error message'}}
|
|
122
|
+
accountId: {type: String, required: true, validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'default error message'}},
|
|
123
|
+
eta: zoneEtaSchema
|
|
121
124
|
}, {collection: 'zone'})
|
|
122
125
|
|
|
123
126
|
// Mongoose-json-patch
|
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
let mongoose = require('mongoose')
|
|
2
|
+
let helpers = require('../helpers')
|
|
3
|
+
|
|
4
|
+
let ZoneEtaSchema = new mongoose.Schema({
|
|
5
|
+
destinationId: {type: String, validate: { validator: helpers.validateEtaDestinationId, msg: 'destinationId must be no more than 128 characters long' }}
|
|
6
|
+
}, {
|
|
7
|
+
_id: false
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
module.exports = ZoneEtaSchema
|