@bluedot-innovation/models 8.2.0 → 8.2.2

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
+ ## 8.2.2
2
+ - Remove domain from helloSso featture
3
+
4
+ ## 8.2.1
5
+ - Add Hello SSO feature to Account model and helloSsoCode to Destinnation model
6
+
1
7
  ## 8.2.0
2
8
  - BREAKING CHANGE - remove Zone actions
3
9
 
@@ -36,6 +36,10 @@
36
36
  },
37
37
  "nowReadyConfiguration": {
38
38
  "enabled": true
39
+ },
40
+ "helloSso": {
41
+ "enabled": true,
42
+ "identityProvider": "coles-screens"
39
43
  }
40
44
  },
41
45
  "integrations": {
@@ -14,5 +14,6 @@
14
14
  "waitTime": {
15
15
  "goal": 300,
16
16
  "alert": 240
17
- }
17
+ },
18
+ "helloSsoCode": "HGDUS69SDJJ0"
18
19
  }
@@ -58,6 +58,16 @@ describe('Valid Destination ', () => {
58
58
  done()
59
59
  })
60
60
  })
61
+
62
+ it('should validate a valid destination without helloSsoCode', (done) => {
63
+ delete destination.helloSsoCode
64
+ let Destination = new DestinationModel(destination)
65
+ Destination.validate((err, res) => {
66
+ assert.notExists(res)
67
+ assert(err === null, 'err equals null')
68
+ done()
69
+ })
70
+ })
61
71
  })
62
72
 
63
73
  describe('Invalid Destination ', () => {
@@ -188,4 +198,52 @@ describe('Invalid Destination ', () => {
188
198
  done()
189
199
  })
190
200
  })
201
+
202
+ it("should throw an error if helloSsoCode is shorter than 12 characters", (done) => {
203
+ destination.helloSsoCode = "HGDUS69SD"
204
+ let Destination = new DestinationModel(destination)
205
+ Destination.validate((err, res) => {
206
+ assert.notExists(res)
207
+ assert.exists(err)
208
+ console.log(err.message)
209
+ assert.match(err.message, /Hello SSO code must be a 12 character capital alphanumeric text/)
210
+ done()
211
+ })
212
+ })
213
+
214
+ it("should throw an error if helloSsoCode is longer than 12 characters", (done) => {
215
+ destination.helloSsoCode = "HGDUS69SDASLDKJSFDHWUER7Y"
216
+ let Destination = new DestinationModel(destination)
217
+ Destination.validate((err, res) => {
218
+ assert.notExists(res)
219
+ assert.exists(err)
220
+ console.log(err.message)
221
+ assert.match(err.message, /Hello SSO code must be a 12 character capital alphanumeric text/)
222
+ done()
223
+ })
224
+ })
225
+
226
+ it("should throw an error if helloSsoCode include lowercase characters", (done) => {
227
+ destination.helloSsoCode = "3HgDUs69SD95"
228
+ let Destination = new DestinationModel(destination)
229
+ Destination.validate((err, res) => {
230
+ assert.notExists(res)
231
+ assert.exists(err)
232
+ console.log(err.message)
233
+ assert.match(err.message, /Hello SSO code must be a 12 character capital alphanumeric text/)
234
+ done()
235
+ })
236
+ })
237
+
238
+ it("should throw an error if helloSsoCode is empty", (done) => {
239
+ destination.helloSsoCode = ""
240
+ let Destination = new DestinationModel(destination)
241
+ Destination.validate((err, res) => {
242
+ assert.notExists(res)
243
+ assert.exists(err)
244
+ console.log(err.message)
245
+ assert.match(err.message, /Hello SSO code must be a 12 character capital alphanumeric text/)
246
+ done()
247
+ })
248
+ })
191
249
  })
package/helpers.js CHANGED
@@ -247,4 +247,10 @@ helpers.validateLongitude = function(longitude){
247
247
  return longitude >= -180 && longitude <= 180
248
248
  }
249
249
 
250
+ helpers.validateHelloSsoCode = function(code){
251
+ const expression = '^[A-Z0-9]{12}$'
252
+ const regex = new RegExp(expression)
253
+ return regex.test(code)
254
+ }
255
+
250
256
  module.exports = helpers
@@ -17,7 +17,8 @@ const DestinationSchema = new mongoose.Schema({
17
17
  projectId: {type: String, required: true, validate: {validator: helpers.validateUUIDv4, msg: 'Invalid projectId'}},
18
18
  creationTime: {type: Date, default: Date.now},
19
19
  lastUpdateTime: {type: Date, default: Date.now},
20
- waitTime: { type: WaitTime }
20
+ waitTime: { type: WaitTime },
21
+ helloSsoCode: {type: String, validate: {validator: helpers.validateHelloSsoCode, msg: 'Hello SSO code must be a 12 character capital alphanumeric text'}}
21
22
  }, {collection: 'destination'})
22
23
 
23
24
  DestinationSchema.plugin(patcher)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
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",
@@ -3,6 +3,7 @@ let AccountTempoSchema = require('./AccountTempo')
3
3
  let AccountBasicFeatureSchema = require('./AccountBasicFeature')
4
4
  let AccountScreensSchema = require('./AccountScreens')
5
5
  let AccountCemdPersistenceSchema = require('./AccountCemdPersistence')
6
+ let HelloSsoSchema = require('./HelloSso')
6
7
 
7
8
  let AccountFeaturesSchema = new mongoose.Schema({
8
9
  tempo: AccountTempoSchema,
@@ -12,7 +13,8 @@ let AccountFeaturesSchema = new mongoose.Schema({
12
13
  cemdPersistence: AccountCemdPersistenceSchema,
13
14
  hideStores: AccountBasicFeatureSchema,
14
15
  automaticDestinationCreation: AccountBasicFeatureSchema,
15
- nowReadyConfiguration: AccountBasicFeatureSchema
16
+ nowReadyConfiguration: AccountBasicFeatureSchema,
17
+ helloSso: HelloSsoSchema
16
18
  }, {
17
19
  _id: false
18
20
  })
@@ -0,0 +1,10 @@
1
+ let mongoose = require('mongoose')
2
+
3
+ let HelloSsoSchema = new mongoose.Schema({
4
+ enabled: {type: Boolean, default: true},
5
+ identityProvider: {type: String, required: true}
6
+ }, {
7
+ _id: false
8
+ })
9
+
10
+ module.exports = HelloSsoSchema
@@ -53,6 +53,18 @@ const indexes = {
53
53
  options: {
54
54
  name: "geometry_index"
55
55
  }
56
+ },
57
+ {
58
+ fields: {
59
+ helloSsoCode: 1
60
+ },
61
+ options: {
62
+ name: "helloSsoCode_index",
63
+ unique: true,
64
+ partialFilterExpression: {
65
+ helloSsoCode: { $type: "string" }
66
+ }
67
+ }
56
68
  }
57
69
  ]
58
70
  }