@bluedot-innovation/models 5.1.53 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.53",
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",
@@ -30,13 +30,13 @@
30
30
  "dependencies": {
31
31
  "@bluedot-innovation/enums": "^2.1.5",
32
32
  "@bluedot-innovation/mongoose-json-patch": "0.0.8",
33
- "@mongoosejs/double": "^0.1.2",
33
+ "@mongoosejs/double": "^0.2.0",
34
34
  "@turf/area": "^6.0.1",
35
35
  "@turf/helpers": "^6.1.4",
36
36
  "deep-equal": "^1.0.1",
37
37
  "fast-deep-equal": "^2.0.1",
38
38
  "lodash.clonedeep": "4.5.0",
39
- "mongoose": "^4.13.9",
39
+ "mongoose": "^5.7.13",
40
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