@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 +6 -0
- package/__tests__/account/account.data.json +2 -1
- package/__tests__/account/account.spec.js +22 -0
- package/__tests__/project/project.data.json +4 -1
- package/models/Project.js +3 -1
- package/package.json +1 -1
- package/schemas/AccountFeatures.js +9 -1
- package/schemas/HelloSso.js +2 -1
- package/schemas/InsightsConfiguration.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -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"
|
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
|
@@ -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
|
}, {
|
package/schemas/HelloSso.js
CHANGED
|
@@ -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:
|
|
5
|
+
identityProvider: {type: String, required: false},
|
|
6
|
+
dashboardIdentityProvider: {type: String, required: false}
|
|
6
7
|
}, {
|
|
7
8
|
_id: false
|
|
8
9
|
})
|