@bluedot-innovation/models 5.1.52 → 6.0.0-bravo.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.52",
3
+ "version": "6.0.0-bravo.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",
@@ -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.1.2",
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": "^4.13.9",
40
- "uuid": "^3.1.0"
39
+ "mongoose": "5.7.13",
40
+ "uuid": "3.1.0"
41
41
  }
42
42
  }
@@ -36,33 +36,44 @@ const MParticleSchema = new mongoose.Schema({
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
- },
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
+ ],
43
50
  required: true
44
51
  }
45
52
  },{ _id : false });
46
53
  function apiKeyValidator(value){
47
54
  // check if the value is a non-empty string
48
55
  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
+
62
+ return isIOSApiKeyProvided === isIOSSecretProvided
63
+ }
64
+
65
+ function androidPairValidator(value){
66
+ const {androidApiKey,androidSecret} = value
67
+ const isAndroidApiKeyProvided = (androidApiKey !== undefined)
68
+ const isAndroidSecretProvided = (androidSecret !== undefined)
49
69
 
70
+ return isAndroidApiKeyProvided === isAndroidSecretProvided
50
71
  }
72
+
51
73
  function mParticleValidator(value) {
52
74
  const { androidApiKey,androidSecret, iOSApiKey,iOSSecret } = value;
53
- let isAndroidPairProvided = false
54
- let isIosPairProvided = false
55
- if((androidApiKey === undefined) !== (androidSecret ===undefined)){
56
- return false
57
- } else if((androidApiKey !== undefined)){
58
- isAndroidPairProvided=true
59
- }
60
- if((iOSApiKey === undefined) !== (iOSSecret ===undefined)){
61
- return false
62
- } else if((iOSApiKey !== undefined)){
63
- isIosPairProvided=true
64
- }
65
-
75
+ const isAndroidPairProvided = ((androidApiKey !== undefined)&&(androidSecret !==undefined))
76
+ const isIosPairProvided = ((iOSApiKey !== undefined)&&(iOSSecret !==undefined))
66
77
 
67
78
  return isIosPairProvided || isAndroidPairProvided;
68
79
  }