@bluedot-innovation/models 6.0.0-bravo.1 → 6.0.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,9 +1,3 @@
1
- ## 5.1.53
2
- - change validation mesages of mParticle
3
-
4
- ## 5.1.52
5
- - fix secret keys validation of mParticle
6
-
7
1
  ## 5.1.51
8
2
  - Add secret keys to mParticle
9
3
 
@@ -93,17 +93,6 @@ testCase('Project', () => {
93
93
  done()
94
94
  })
95
95
  })
96
- assertions('should throw an error if the mparticle integration misses all keys ', (done) => {
97
-
98
- project.integrations.mParticle = {}
99
-
100
- let Project = new ProjectModel(project)
101
- Project.validate((err, res) => {
102
- assert.exists(err)
103
- assert.match(err.message, /either of the two field combinations is mandatory/)
104
- done()
105
- })
106
- })
107
96
  assertions('should throw an error if the mparticle integration misses both keys ', (done) => {
108
97
 
109
98
  delete project.integrations.mParticle.iOSApiKey
@@ -128,28 +117,6 @@ testCase('Project', () => {
128
117
  done()
129
118
  })
130
119
  })
131
- assertions('should throw an error if the mparticle integration has valid android key pair, but no Ios secret ', (done) => {
132
-
133
- delete project.integrations.mParticle.iOSSecret
134
-
135
- let Project = new ProjectModel(project)
136
- Project.validate((err, res) => {
137
- assert.exists(err)
138
- assert.match(err.message, /both iOSSecret and iOSApiKey are required/)
139
- done()
140
- })
141
- })
142
- assertions('should throw an error if the mparticle integration has valid Ios key pair, but no android secret ', (done) => {
143
-
144
- delete project.integrations.mParticle.androidSecret
145
-
146
- let Project = new ProjectModel(project)
147
- Project.validate((err, res) => {
148
- assert.exists(err)
149
- assert.match(err.message, /both androidSecret and androidApiKey are required/)
150
- done()
151
- })
152
- })
153
120
  assertions('should validate if the mparticle integration has only Android key ', (done) => {
154
121
 
155
122
  delete project.integrations.mParticle.androidApiKey
@@ -21,7 +21,7 @@ describe('Zone', () => {
21
21
  let Zone = new ZoneModel(zone)
22
22
  Zone.validate((err, res) => {
23
23
  assert.notExists(res)
24
- assert.notExists(err)
24
+ // assert.notExists(err)
25
25
  done()
26
26
  })
27
27
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "6.0.0-bravo.1",
3
+ "version": "6.0.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",
@@ -11,32 +11,32 @@
11
11
  },
12
12
  "license": "UNLICENSED",
13
13
  "devDependencies": {
14
- "babel-eslint": "8.2.3",
15
- "chai": "4.1.2",
14
+ "babel-eslint": "^8.2.3",
15
+ "chai": "^4.1.2",
16
16
  "describe": "*",
17
- "eslint": "4.12.0",
18
- "eslint-config-prettier": "2.9.0",
19
- "eslint-config-standard": "10.2.1",
20
- "eslint-plugin-import": "2.8.0",
21
- "eslint-plugin-node": "5.2.1",
22
- "eslint-plugin-prettier": "2.6.0",
23
- "eslint-plugin-promise": "3.6.0",
24
- "eslint-plugin-standard": "3.0.1",
25
- "mocha": "4.0.1",
26
- "nyc": "11.3.0",
27
- "prettier": "1.13.5",
28
- "sinon": "4.1.2"
17
+ "eslint": "^4.12.0",
18
+ "eslint-config-prettier": "^2.9.0",
19
+ "eslint-config-standard": "^10.2.1",
20
+ "eslint-plugin-import": "^2.8.0",
21
+ "eslint-plugin-node": "^5.2.1",
22
+ "eslint-plugin-prettier": "^2.6.0",
23
+ "eslint-plugin-promise": "^3.6.0",
24
+ "eslint-plugin-standard": "^3.0.1",
25
+ "mocha": "^4.0.1",
26
+ "nyc": "^11.3.0",
27
+ "prettier": "^1.13.5",
28
+ "sinon": "^4.1.2"
29
29
  },
30
30
  "dependencies": {
31
- "@bluedot-innovation/enums": "2.1.5",
31
+ "@bluedot-innovation/enums": "^2.1.5",
32
32
  "@bluedot-innovation/mongoose-json-patch": "0.0.8",
33
- "@mongoosejs/double": "0.2.0",
34
- "@turf/area": "6.0.1",
35
- "@turf/helpers": "6.1.4",
36
- "deep-equal": "1.0.1",
37
- "fast-deep-equal": "2.0.1",
33
+ "@mongoosejs/double": "^0.2.0",
34
+ "@turf/area": "^6.0.1",
35
+ "@turf/helpers": "^6.1.4",
36
+ "deep-equal": "^1.0.1",
37
+ "fast-deep-equal": "^2.0.1",
38
38
  "lodash.clonedeep": "4.5.0",
39
- "mongoose": "5.7.13",
40
- "uuid": "3.1.0"
39
+ "mongoose": "^5.7.13",
40
+ "uuid": "^3.1.0"
41
41
  }
42
42
  }
@@ -31,51 +31,30 @@ const MParticleSchema = new mongoose.Schema({
31
31
  msg:'iOSSecret should be a non-empty string, found ${VALUE}'
32
32
  }
33
33
  }
34
- },{ _id : false })
34
+ })
35
35
 
36
36
  const IntegrationSchema = new mongoose.Schema({
37
37
  mParticle: {
38
38
  type: MParticleSchema,
39
- validate: [{
39
+ validate: {
40
40
  validator: mParticleValidator,
41
41
  msg: 'either of the two field combinations is mandatory: androidApiKey & androidSecret OR iOSApiKey & iOSSecret'
42
- },{
43
- validator:iOSPairValidator,
44
- msg: 'both iOSSecret and iOSApiKey are required'
45
- },{
46
- validator:androidPairValidator,
47
- msg: 'both androidSecret and androidApiKey are required'
48
- }
49
- ],
42
+ },
50
43
  required: true
51
44
  }
52
- },{ _id : false });
45
+ });
53
46
  function apiKeyValidator(value){
54
47
  // check if the value is a non-empty string
55
48
  return !(typeof value !=='string' || value.trim() === '')
56
- }
57
- function iOSPairValidator(value){
58
- const {iOSApiKey,iOSSecret} = value
59
- const isIOSApiKeyProvided = (iOSApiKey !== undefined)
60
- const isIOSSecretProvided = (iOSSecret !== undefined)
61
49
 
62
- return isIOSApiKeyProvided === isIOSSecretProvided
63
50
  }
64
-
65
- function androidPairValidator(value){
66
- const {androidApiKey,androidSecret} = value
67
- const isAndroidApiKeyProvided = (androidApiKey !== undefined)
68
- const isAndroidSecretProvided = (androidSecret !== undefined)
69
-
70
- return isAndroidApiKeyProvided === isAndroidSecretProvided
71
- }
72
-
73
51
  function mParticleValidator(value) {
74
52
  const { androidApiKey,androidSecret, iOSApiKey,iOSSecret } = value;
75
- const isAndroidPairProvided = ((androidApiKey !== undefined)&&(androidSecret !==undefined))
76
- const isIosPairProvided = ((iOSApiKey !== undefined)&&(iOSSecret !==undefined))
77
53
 
78
- return isIosPairProvided || isAndroidPairProvided;
54
+ const isAndroidKeyProvided = (typeof androidApiKey !== "undefined" && typeof androidSecret !=="undefined")
55
+ const isIOSKeyProvided = (typeof iOSApiKey !== "undefined" && typeof iOSSecret !== "undefined")
56
+
57
+ return isAndroidKeyProvided || isIOSKeyProvided;
79
58
  }
80
59
 
81
60
  module.exports = IntegrationSchema