@bluedot-innovation/models 7.4.0 → 7.5.0

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,6 @@
1
+ ## 7.5.0
2
+ - Added Hello Configuration to screens feature
3
+
1
4
  ## 7.4.0
2
5
  - Added mfaRequired flag to user model
3
6
 
@@ -14,7 +14,10 @@
14
14
  "enabled": true
15
15
  },
16
16
  "screens": {
17
- "enabled": true
17
+ "enabled": true,
18
+ "configuration": {
19
+ "userTokenLength": 7
20
+ }
18
21
  },
19
22
  "insights": {
20
23
  "enabled": true
@@ -102,4 +102,18 @@ testCase('Account', () => {
102
102
  })
103
103
  })
104
104
  })
105
+
106
+ testCase('Configure userToken length', () => {
107
+ assertions('should throw error when modifying userToken length with Screens feature disabled', (done) => {
108
+ account.features.screens.enabled = false
109
+ let Account = new AccountModel(account)
110
+
111
+ Account.validate((err, res) => {
112
+ assert.notExists(res)
113
+ assert.exists(err, 'Screens feature needs to be enabled to modify this configuration')
114
+ done()
115
+ })
116
+ })
117
+
118
+ })
105
119
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "7.4.0",
3
+ "version": "7.5.0",
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",
@@ -1,11 +1,12 @@
1
1
  let mongoose = require('mongoose')
2
2
  let AccountTempoSchema = require('./AccountTempo')
3
3
  let AccountBasicFeatureSchema = require('./AccountBasicFeature')
4
+ let AccountScreensSchema = require('./AccountScreens')
4
5
 
5
6
  let AccountFeaturesSchema = new mongoose.Schema({
6
7
  tempo: AccountTempoSchema,
7
8
  realTimeDashboard: AccountBasicFeatureSchema,
8
- screens: AccountBasicFeatureSchema,
9
+ screens: AccountScreensSchema,
9
10
  insights: AccountBasicFeatureSchema
10
11
  }, {
11
12
  _id: false
@@ -0,0 +1,15 @@
1
+ let mongoose = require('mongoose')
2
+ const HelloConfigurationSchema = require('./HelloConfiguration')
3
+
4
+ function validateScreensFeatureState() {
5
+ return this.enabled
6
+ }
7
+
8
+ let AccountScreensSchema = new mongoose.Schema({
9
+ enabled: {type: Boolean},
10
+ configuration: {type: HelloConfigurationSchema, validate: {validator: validateScreensFeatureState, msg: 'Screens feature needs to be enabled to modify this configuration'}}
11
+ }, {
12
+ _id: false
13
+ })
14
+
15
+ module.exports = AccountScreensSchema
@@ -0,0 +1,9 @@
1
+ let mongoose = require('mongoose')
2
+
3
+ let HelloConfigurationSchema = new mongoose.Schema({
4
+ userTokenLength: {type: Number, default: 7, min: 7, max: 20}
5
+ }, {
6
+ _id: false
7
+ })
8
+
9
+ module.exports = HelloConfigurationSchema