@bluedot-innovation/models 6.0.4 → 6.0.8

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 CHANGED
@@ -1,3 +1,12 @@
1
+ ## 6.0.8
2
+ - Increase zone custom data to 20 fields
3
+
4
+ ## 6.0.7
5
+ - Add features.etaEnabled to the account model
6
+
7
+ ## 6.0.6
8
+ - Add validations to User fields
9
+
1
10
  ## 6.0.4
2
11
  - Update mparticle fieldnames
3
12
 
@@ -1,7 +1,9 @@
1
1
  module.exports = {
2
2
  requiredFields: ['username', 'firstName', 'lastName', 'isAdmin', 'accountId'],
3
3
  customValidators: [
4
- {name: 'phoneNumber', invalidInputs: ['409203492039284232034398']},
4
+ {name: 'phoneNumber', invalidInputs: ['409203492039284232034398','1','1234']},
5
+ {name: 'firstName', invalidInputs: ['F']},
6
+ {name: 'lastName', invalidInputs: ['L']},
5
7
  {name: 'creationTime', invalidInputs: ['21/07/2017', 'thursday']},
6
8
  {name: 'lastUpdateTime', invalidInputs: ['21/07/2017', 'saturday']}
7
9
  ],
@@ -236,15 +236,14 @@ describe('Zone', () => {
236
236
  })
237
237
  })
238
238
 
239
- it('should throw an error if custom data keys count is greater than 5 ', (done) => {
240
- zone.customData["name3"] = true;
241
- zone.customData["name4"] = 1;
242
- zone.customData["name5"] = "Action value 5";
243
- zone.customData["name6"] = "Action Value 6";
239
+ it('should throw an error if custom data keys count is greater than 20 ', (done) => {
240
+ for (let i = 0; i <= 21; i++) {
241
+ zone.customData[`key${i}`] = `value ${i}`
242
+ }
244
243
 
245
244
  let Zone = new ZoneModel(zone)
246
245
  Zone.validate((err, res) => {
247
- assert.match(err.message, /(Only 5 custom data fields are allowed to be added per zone)/i)
246
+ assert.match(err.message, /(Only 20 custom data fields are allowed to be added per zone)/i)
248
247
  done()
249
248
  })
250
249
  })
package/helpers.js CHANGED
@@ -79,7 +79,7 @@ helpers.isValidCustomDataCount = function (data) {
79
79
  }
80
80
  const customDataKeysSize = Object.keys(data).length;
81
81
 
82
- return !(customDataKeysSize > 5)
82
+ return !(customDataKeysSize > 20)
83
83
  }
84
84
 
85
85
  helpers.checkIsDifferent = function(propertyName) {
package/models/Account.js CHANGED
@@ -6,6 +6,7 @@
6
6
  let mongoose = require('mongoose')
7
7
  // let Schema = mongoose.Schema
8
8
  let StateEnum = require('@bluedot-innovation/enums').StateEnum
9
+ let accountFeatures = require('../schemas/AccountFeatures')
9
10
  let uuidv4 = require('uuid/v4')
10
11
  let patcher = require('@bluedot-innovation/mongoose-json-patch')
11
12
  const helpers = require('../helpers')
@@ -26,7 +27,7 @@ let AccountSchema = new mongoose.Schema({
26
27
  state: {type: String, default: StateEnum.ACTIVE},
27
28
  poiCredits: Number,
28
29
  integrations: Object,
29
- features: Object,
30
+ features: accountFeatures,
30
31
  creationTime: {type: Date, default: Date.now},
31
32
  lastUpdateTime: {type: Date, default: Date.now}
32
33
  },
package/models/User.js CHANGED
@@ -26,9 +26,9 @@ let UserSchema = new mongoose.Schema({
26
26
  message: '{VALUE} is not a valid email'
27
27
  }
28
28
  },
29
- firstName: {type: String, required: true},
30
- lastName: {type: String, required: true},
31
- phoneNumber: {type: String, maxlength: 20, validate: helpers.validateNotNull},
29
+ firstName: {type: String, required: true, minlength:2, maxlength:120},
30
+ lastName: {type: String, required: true, minlength:2, maxlength:120},
31
+ phoneNumber: {type: String, minlength:8, maxlength: 20, validate: helpers.validateNotNull},
32
32
  state: {type: String, default: StateEnum.ACTIVE},
33
33
  creationTime: {type: Date, default: Date.now},
34
34
  lastUpdateTime: {type: Date, default: Date.now},
package/models/Zone.js CHANGED
@@ -34,7 +34,7 @@ let customDataValidators = [
34
34
  {validator: helpers.validateCustomData, msg: 'CustomData key should have alpha numeric, - and _ characters only'},
35
35
  {validator: helpers.checkDuplicateKeys, msg: 'CustomData key should be unique'},
36
36
  {validator: helpers.isCustomDataValuesNotEmpty, msg: 'CustomData value should not be empty'},
37
- {validator: helpers.isValidCustomDataCount, msg: 'Only 5 custom data fields are allowed to be added per zone'}
37
+ {validator: helpers.isValidCustomDataCount, msg: 'Only 20 custom data fields are allowed to be added per zone'}
38
38
  ];
39
39
 
40
40
  const tagsFormation = (zone) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "6.0.4",
3
+ "version": "6.0.8",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",
@@ -0,0 +1,9 @@
1
+ let mongoose = require('mongoose')
2
+
3
+ let AccountFeaturesSchema = new mongoose.Schema({
4
+ etaEnabled: {type: Boolean}
5
+ }, {
6
+ _id: false
7
+ })
8
+
9
+ module.exports = AccountFeaturesSchema