@bluedot-innovation/models 9.0.0 → 9.0.1

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
+ ## 9.0.1
2
+ - Add geo-trigger report
3
+
1
4
  ## 9.0.0
2
5
  - BREAKING CHANGE - Move destination hello properties stateTemplateId, waitTime to hello object and add consolidationAlert
3
6
 
@@ -869,7 +869,22 @@ describe('Project', () => {
869
869
  let Project = new ProjectModel(project)
870
870
  Project.validate((err, res) => {
871
871
  assert.exists(err)
872
- assert.match(err.message, /Only one report type per project is allowed/)
872
+ assert.match(err.message, /Multiple reports of the same type are not allowed/)
873
+ done()
874
+ })
875
+ })
876
+
877
+ it('Should be successfull when there are multiple report types per project', (done) => {
878
+ project.reportConfigurations.push({
879
+ "type": "geo-trigger",
880
+ "frequency": "monthly",
881
+ "reportDay": 1,
882
+ "timezone": "Australia/Sydney",
883
+ "recipients": "xyz@example.com"
884
+ })
885
+ let Project = new ProjectModel(project)
886
+ Project.validate((err, res) => {
887
+ assert.notExists(err)
873
888
  done()
874
889
  })
875
890
  })
package/models/Project.js CHANGED
@@ -26,7 +26,7 @@ let webhooksValidators = [
26
26
 
27
27
  const reportConfigurationsValidators = [
28
28
  {validator: helpers.validateNotNull},
29
- {validator: helpers.validateNoDuplicateReportConfigurations, msg: "Only one report type per project is allowed"}
29
+ {validator: helpers.validateNoDuplicateReportConfigurations, msg: "Multiple reports of the same type are not allowed"}
30
30
  ]
31
31
 
32
32
  let ProjectSchema = new mongoose.Schema({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "9.0.0",
3
+ "version": "9.0.1",
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",
@@ -34,7 +34,7 @@ function validateRecipients(value) {
34
34
  }
35
35
 
36
36
  let ReportConfigurationSchema = new mongoose.Schema({
37
- type: {type: String, enum: ['hello'], required: true},
37
+ type: {type: String, enum: ['hello', 'geo-trigger'], required: true},
38
38
  frequency: {type: String, enum: ['daily', 'weekly', 'monthly'], required: true},
39
39
  reportDay: {type: Number, validate: {validator: validateReportDay}},
40
40
  timezone: {type: String, required: true, validate: { validator: validateTimeZone, msg: 'Invalid timezone'}},