@bluedot-innovation/models 5.1.50 → 5.1.51
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
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
"firebaseApiKey": "88888888-4444-4444-4444-121212121212",
|
|
17
17
|
"apiKey": "88888888-4444-4444-4444-123412341234",
|
|
18
18
|
"integrations":{
|
|
19
|
-
"mParticle":{
|
|
20
|
-
"androidApiKey":"
|
|
21
|
-
"
|
|
19
|
+
"mParticle": {
|
|
20
|
+
"androidApiKey": "us1-c5e6eefe90fe704aba0a7d2daa00baaa",
|
|
21
|
+
"androidSecret": "eZqphc1Vh2dqaIQEvz4APNbErZkW_AaaRmwE8BCmYpHZFc3n_ZKajTLgJgFqLNNN",
|
|
22
|
+
"iOSApiKey": "us1-a5e6eefe90fe704aba0a7d2daa00baaa",
|
|
23
|
+
"iOSSecret": "fZqphc1Vh2dqaIQEvz4APNbErZkW_AaaRmwE8BCmYpHZFc3n_ZKajTLgJgFqLNNN"
|
|
22
24
|
}
|
|
23
25
|
}}
|
|
@@ -79,7 +79,17 @@ testCase('Project', () => {
|
|
|
79
79
|
let Project = new ProjectModel(project)
|
|
80
80
|
Project.validate((err, res) => {
|
|
81
81
|
assert.exists(err)
|
|
82
|
-
assert.match(err.message, /iOSApiKey should be
|
|
82
|
+
assert.match(err.message, /iOSApiKey should be a non-empty string/)
|
|
83
|
+
done()
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
assertions('should throw an error if the mparticle integration has a secret key with empty string ', (done) => {
|
|
87
|
+
|
|
88
|
+
project.integrations.mParticle.iOSSecret = ''
|
|
89
|
+
let Project = new ProjectModel(project)
|
|
90
|
+
Project.validate((err, res) => {
|
|
91
|
+
assert.exists(err)
|
|
92
|
+
assert.match(err.message, /iOSSecret should be a non-empty string/)
|
|
83
93
|
done()
|
|
84
94
|
})
|
|
85
95
|
})
|
|
@@ -91,13 +101,26 @@ testCase('Project', () => {
|
|
|
91
101
|
let Project = new ProjectModel(project)
|
|
92
102
|
Project.validate((err, res) => {
|
|
93
103
|
assert.exists(err)
|
|
94
|
-
assert.match(err.message, /
|
|
104
|
+
assert.match(err.message, /either of the two field combinations is mandatory/)
|
|
105
|
+
done()
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
assertions('should throw an error if the mparticle integration misses both secret keys ', (done) => {
|
|
109
|
+
|
|
110
|
+
delete project.integrations.mParticle.iOSSecret
|
|
111
|
+
delete project.integrations.mParticle.androidSecret
|
|
112
|
+
|
|
113
|
+
let Project = new ProjectModel(project)
|
|
114
|
+
Project.validate((err, res) => {
|
|
115
|
+
assert.exists(err)
|
|
116
|
+
assert.match(err.message, /either of the two field combinations is mandatory/)
|
|
95
117
|
done()
|
|
96
118
|
})
|
|
97
119
|
})
|
|
98
|
-
assertions('should validate if the mparticle integration has only
|
|
120
|
+
assertions('should validate if the mparticle integration has only Android key ', (done) => {
|
|
99
121
|
|
|
100
122
|
delete project.integrations.mParticle.androidApiKey
|
|
123
|
+
delete project.integrations.mParticle.androidSecret
|
|
101
124
|
|
|
102
125
|
let Project = new ProjectModel(project)
|
|
103
126
|
Project.validate((err, res) => {
|
package/package.json
CHANGED
package/schemas/Integration.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
let mongoose = require("mongoose");
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
const MParticleSchema = new mongoose.Schema({
|
|
5
6
|
androidApiKey: {
|
|
6
7
|
type: String,
|
|
@@ -9,11 +10,25 @@ const MParticleSchema = new mongoose.Schema({
|
|
|
9
10
|
msg:'androidApiKey should be a non-empty string, found ${VALUE}'
|
|
10
11
|
}
|
|
11
12
|
},
|
|
13
|
+
androidSecret: {
|
|
14
|
+
type: String,
|
|
15
|
+
validate:{
|
|
16
|
+
validator:apiKeyValidator,
|
|
17
|
+
msg:'androidSecret should be a non-empty string, found ${VALUE}'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
12
20
|
iOSApiKey:{
|
|
13
21
|
type:String,
|
|
14
22
|
validate:{
|
|
15
23
|
validator:apiKeyValidator,
|
|
16
|
-
msg:'iOSApiKey should be
|
|
24
|
+
msg:'iOSApiKey should be a non-empty string, found ${VALUE}'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
iOSSecret:{
|
|
28
|
+
type:String,
|
|
29
|
+
validate:{
|
|
30
|
+
validator:apiKeyValidator,
|
|
31
|
+
msg:'iOSSecret should be a non-empty string, found ${VALUE}'
|
|
17
32
|
}
|
|
18
33
|
}
|
|
19
34
|
})
|
|
@@ -23,25 +38,21 @@ const IntegrationSchema = new mongoose.Schema({
|
|
|
23
38
|
type: MParticleSchema,
|
|
24
39
|
validate: {
|
|
25
40
|
validator: mParticleValidator,
|
|
26
|
-
msg: '
|
|
41
|
+
msg: 'either of the two field combinations is mandatory: androidApiKey & androidSecret OR iOSApiKey & iOSSecret'
|
|
27
42
|
},
|
|
28
43
|
required: true
|
|
29
44
|
}
|
|
30
45
|
});
|
|
31
46
|
function apiKeyValidator(value){
|
|
32
|
-
// only one of the Api keys is required.
|
|
33
|
-
if(typeof value === 'undefined'){
|
|
34
|
-
return true
|
|
35
|
-
}
|
|
36
47
|
// check if the value is a non-empty string
|
|
37
48
|
return !(typeof value !=='string' || value.trim() === '')
|
|
38
49
|
|
|
39
50
|
}
|
|
40
51
|
function mParticleValidator(value) {
|
|
41
|
-
const { androidApiKey, iOSApiKey } = value;
|
|
52
|
+
const { androidApiKey,androidSecret, iOSApiKey,iOSSecret } = value;
|
|
42
53
|
|
|
43
|
-
const isAndroidKeyProvided = typeof androidApiKey !== "undefined"
|
|
44
|
-
const isIOSKeyProvided = typeof iOSApiKey !== "undefined"
|
|
54
|
+
const isAndroidKeyProvided = (typeof androidApiKey !== "undefined" && typeof androidSecret !=="undefined")
|
|
55
|
+
const isIOSKeyProvided = (typeof iOSApiKey !== "undefined" && typeof iOSSecret !== "undefined")
|
|
45
56
|
|
|
46
57
|
return isAndroidKeyProvided || isIOSKeyProvided;
|
|
47
58
|
}
|