@bluedot-innovation/models 7.5.8 → 7.6.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.6.0
2
+ - Add Attentive Integration to account and webhook
3
+
1
4
  ## 7.5.8
2
5
  - Add CEMD Persistencce feature
3
6
 
@@ -42,6 +42,9 @@
42
42
  "enterpriseId": 1234567,
43
43
  "organizationId": 12345,
44
44
  "allowedFields": ["example-allowed-fields"]
45
+ },
46
+ "attentive": {
47
+ "enabled": true
45
48
  }
46
49
  }
47
50
  }
@@ -450,17 +450,27 @@ describe('Project', () => {
450
450
  let Project = new ProjectModel(project)
451
451
  Project.validate((err, res) => {
452
452
  assert.exists(err)
453
- assert.match(err.message, /type "register" can only have structure "mobivity"/)
453
+ assert.match(err.message, /type "register" can only have structure "mobivity" or "attentive"/)
454
454
  done()
455
455
  })
456
456
  })
457
- it(`should not validate if the type is register and the structure is not mobivity`, (done) => {
457
+ it(`should not validate if the type is register and the structure is not mobivity or attentive`, (done) => {
458
458
  project.webhooks[0].type = "register"
459
459
  project.webhooks[0].structure = "standard"
460
460
  let Project = new ProjectModel(project)
461
461
  Project.validate((err, res) => {
462
462
  assert.exists(err)
463
- assert.match(err.message, /type "register" can only have structure "mobivity"/)
463
+ assert.match(err.message, /type "register" can only have structure "mobivity" or "attentive"/)
464
+ done()
465
+ })
466
+ })
467
+ it(`should not validate if structure is attentive and the type is not register`, (done) => {
468
+ project.webhooks[0].type = "trigger"
469
+ project.webhooks[0].structure = "attentive"
470
+ let Project = new ProjectModel(project)
471
+ Project.validate((err, res) => {
472
+ assert.exists(err)
473
+ assert.match(err.message, /type "register" can only have structure "mobivity" or "attentive"/)
464
474
  done()
465
475
  })
466
476
  })
package/models/Account.js CHANGED
@@ -7,6 +7,7 @@ let mongoose = require('mongoose')
7
7
  let StateEnum = require('@bluedot-innovation/enums').StateEnum
8
8
  let accountFeatures = require('../schemas/AccountFeatures')
9
9
  const SfmcIntegration = require('../schemas/SfmcIntegration')
10
+ const AttentiveIntegration = require('../schemas/AttentiveIntegration')
10
11
  let uuidv4 = require('uuid/v4')
11
12
  let patcher = require('@bluedot-innovation/mongoose-json-patch')
12
13
  const helpers = require('../helpers')
@@ -29,7 +30,8 @@ let AccountSchema = new mongoose.Schema({
29
30
  creationTime: {type: Date, default: Date.now},
30
31
  lastUpdateTime: {type: Date, default: Date.now},
31
32
  integrations: {
32
- sfmc: {type: SfmcIntegration}
33
+ sfmc: {type: SfmcIntegration},
34
+ attentive: {type: AttentiveIntegration}
33
35
  }
34
36
  },
35
37
  {collection: 'account'})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "7.5.8",
3
+ "version": "7.6.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",
@@ -0,0 +1,9 @@
1
+ let mongoose = require('mongoose')
2
+
3
+ let AttentiveIntegrationSchema = new mongoose.Schema({
4
+ enabled: {type: Boolean}
5
+ }, {
6
+ _id: false
7
+ })
8
+
9
+ module.exports = AttentiveIntegrationSchema
@@ -28,20 +28,20 @@ function validateMobivityRequiredFields(structure){
28
28
  }
29
29
 
30
30
  function validateTypeAndStructure(type) {
31
- if ((type === "register" && this.structure !== "mobivity")
32
- || (type !== "register" && this.structure === "mobivity")) {
31
+ if ((type === "register" && !['mobivity', 'attentive'].includes(this.structure))
32
+ || (type !== "register" && ['mobivity', 'attentive'].includes(this.structure))) {
33
33
  return false
34
34
  }
35
35
  }
36
36
 
37
37
  let WebhookSchema = new mongoose.Schema({
38
- type: {type: String, enum: ['tempo', 'wave', 'trigger', 'register'], required: [true, 'webhook type is required'], validate: {validator: validateTypeAndStructure, msg: 'type "register" can only have structure "mobivity"'}},
38
+ type: {type: String, enum: ['tempo', 'wave', 'trigger', 'register'], required: [true, 'webhook type is required'], validate: {validator: validateTypeAndStructure, msg: 'type "register" can only have structure "mobivity" or "attentive"'}},
39
39
  url: {type: String, required: [true, 'URL is required'], validate: {validator: validators.validateUrl, msg: 'Please enter a valid URL'}},
40
40
  headers: {type: mongoose.Schema.Types.Mixed, validate: [{ validator: validators.validateNonEmptyStringKeyValuePairsOnly, msg: 'webhook header keys and values must be strings' }, { validator: validators.validateNoSpacesInObjectKeys, msg: 'webhook header keys cannot contain spaces' }]},
41
41
  body: {type: mongoose.Schema.Types.Mixed, validate: [{ validator: validators.validateNonEmptyStringKeyValuePairsOnly, msg: 'webhook body keys and values must be strings' }, { validator: validators.validateNoSpacesInObjectKeys, msg: 'webhook body keys cannot contain spaces' }]},
42
42
  structure: {
43
43
  type: String,
44
- enum: ['standard', 'tealium', 'mobivity'],
44
+ enum: ['standard', 'tealium', 'mobivity', 'attentive'],
45
45
  default: 'standard',
46
46
  validate: [
47
47
  {validator: validateTealiumRequiredFields, msg: 'tealium webhooks require "tealium_account" and "tealium_profile" body fields to be present'},