@bluedot-innovation/models 10.7.0 → 10.9.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,9 @@
1
+ ## 10.8.0
2
+ - Add dashboardIdentityProvider to HelloSSO model
3
+
4
+ ## 10.8.0
5
+ - Add insightsConfiguration to Project model
6
+
1
7
  ## 10.7.0
2
8
  - Add liveUpdateEnabled to IosConfig
3
9
 
@@ -39,7 +39,8 @@
39
39
  },
40
40
  "helloSso": {
41
41
  "enabled": true,
42
- "identityProvider": "coles-screens"
42
+ "identityProvider": "coles-screens",
43
+ "dashboardIdentityProvider": "coles-dashboard"
43
44
  },
44
45
  "canvasSso": {
45
46
  "enabled": true,
@@ -48,6 +48,14 @@ testCase('Account', () => {
48
48
  const res = await Account.validate()
49
49
  assert.notExists(res)
50
50
  })
51
+
52
+ it('Should valid the account when helloSso is undefined', async () => {
53
+ account = JSON.parse(JSON.stringify(account))
54
+ delete account.features.helloSso
55
+ const Account = new AccountModel(account)
56
+ const res = await Account.validate()
57
+ assert.notExists(res)
58
+ })
51
59
  })
52
60
 
53
61
  testCase('Invalid Account', () => {
@@ -69,6 +77,20 @@ testCase('Account', () => {
69
77
  })
70
78
  })
71
79
 
80
+ assertions('should throw an error when Account has helloSso enabled but none of providers is provided', async () => {
81
+ account = JSON.parse(JSON.stringify(account))
82
+ delete account.features.helloSso.identityProvider
83
+ delete account.features.helloSso.dashboardIdentityProvider
84
+ let Account = new AccountModel(account)
85
+ try {
86
+ await Account.validate()
87
+ } catch (err) {
88
+ assert.exists(err, 'err object should exist')
89
+ assert.isObject(err.errors)
90
+ assert.match(err.message, /When the feature is enbaled, at leat one of provider need to be provided./)
91
+ }
92
+ })
93
+
72
94
  assertions('should throw an error when Account has invalid type', async () => {
73
95
  let Account = new AccountModel(account)
74
96
  Account.type = "Invalid"
@@ -135,5 +135,8 @@
135
135
  "timezone": "Australia/Melbourne",
136
136
  "recipients": "abc@example.com"
137
137
  }
138
- ]
138
+ ],
139
+ "insightsConfiguration": {
140
+ "volumeGroupByKeys": ["Operational State", "Store Number", "City"]
141
+ }
139
142
  }
package/models/Project.js CHANGED
@@ -18,6 +18,7 @@ let androidConfig = require('../schemas/AndroidConfig')
18
18
  let projectTempoSchema = require('../schemas/ProjectTempo')
19
19
  let projectHelloSchema = require('../schemas/ProjectHello')
20
20
  let reportConfigurationSchema = require('../schemas/ReportConfiguration')
21
+ let insightsConfigurationSchema = require('../schemas/InsightsConfiguration')
21
22
 
22
23
  let webhooksValidators = [
23
24
  {validator: helpers.validateNotNull},
@@ -57,7 +58,8 @@ let ProjectSchema = new mongoose.Schema({
57
58
  integrations: IntegrationSchema,
58
59
  tempo: projectTempoSchema,
59
60
  hello: projectHelloSchema,
60
- reportConfigurations: {type: [reportConfigurationSchema], validate: reportConfigurationsValidators}
61
+ reportConfigurations: {type: [reportConfigurationSchema], validate: reportConfigurationsValidators},
62
+ insightsConfiguration: insightsConfigurationSchema
61
63
  },
62
64
  {collection: 'project'})
63
65
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "10.7.0",
3
+ "version": "10.9.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",
@@ -6,6 +6,14 @@ let AccountCemdPersistenceSchema = require('./AccountCemdPersistence')
6
6
  let HelloSsoSchema = require('./HelloSso')
7
7
  const CanvasSsoSchema = require('./CanvasSsoFeature')
8
8
 
9
+ function helloSsoValidator (value) {
10
+ const { enabled, identityProvider, dashboardIdentityProvider } = value
11
+ if (enabled && !identityProvider && !dashboardIdentityProvider) {
12
+ return false
13
+ }
14
+ return true
15
+ }
16
+
9
17
  let AccountFeaturesSchema = new mongoose.Schema({
10
18
  tempo: AccountTempoSchema,
11
19
  realTimeDashboard: AccountBasicFeatureSchema,
@@ -15,7 +23,7 @@ let AccountFeaturesSchema = new mongoose.Schema({
15
23
  hideStores: AccountBasicFeatureSchema,
16
24
  automaticDestinationCreation: AccountBasicFeatureSchema,
17
25
  nowReadyConfiguration: AccountBasicFeatureSchema,
18
- helloSso: HelloSsoSchema,
26
+ helloSso: { type: HelloSsoSchema, validate: { validator: helloSsoValidator, msg: 'When the feature is enbaled, at leat one of provider need to be provided.' } },
19
27
  canvasSso: CanvasSsoSchema,
20
28
  helloStateTemplates: AccountBasicFeatureSchema,
21
29
  }, {
@@ -2,7 +2,8 @@ let mongoose = require('mongoose')
2
2
 
3
3
  let HelloSsoSchema = new mongoose.Schema({
4
4
  enabled: {type: Boolean, default: true},
5
- identityProvider: {type: String, required: true}
5
+ identityProvider: {type: String, required: false},
6
+ dashboardIdentityProvider: {type: String, required: false}
6
7
  }, {
7
8
  _id: false
8
9
  })
@@ -0,0 +1,9 @@
1
+ let mongoose = require('mongoose')
2
+
3
+ let InsightsConfigurationSchema = new mongoose.Schema({
4
+ volumeGroupByKeys: {type: [String]}
5
+ }, {
6
+ _id: false
7
+ })
8
+
9
+ module.exports = InsightsConfigurationSchema