@bluedot-innovation/models 5.1.49 → 5.1.50
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
|
@@ -14,5 +14,10 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"firebaseApiKey": "88888888-4444-4444-4444-121212121212",
|
|
17
|
-
"apiKey": "88888888-4444-4444-4444-123412341234"
|
|
18
|
-
|
|
17
|
+
"apiKey": "88888888-4444-4444-4444-123412341234",
|
|
18
|
+
"integrations":{
|
|
19
|
+
"mParticle":{
|
|
20
|
+
"androidApiKey":"3e5b8fa2-913f-414f-8c36-f0d312a55b6c",
|
|
21
|
+
"iOSApiKey": "e655040b-c9e8-41a0-8faa-ff21d7f6afc8"
|
|
22
|
+
}
|
|
23
|
+
}}
|
|
@@ -61,6 +61,51 @@ testCase('Project', () => {
|
|
|
61
61
|
done()
|
|
62
62
|
})
|
|
63
63
|
})
|
|
64
|
+
testCase('mparticle integration check', () => {
|
|
65
|
+
assertions('should throw an error if the mparticle integration has empty key ', (done) => {
|
|
66
|
+
|
|
67
|
+
project.integrations.mParticle.androidApiKey = null
|
|
68
|
+
|
|
69
|
+
let Project = new ProjectModel(project)
|
|
70
|
+
Project.validate((err, res) => {
|
|
71
|
+
assert.exists(err)
|
|
72
|
+
assert.match(err.message, /androidApiKey should be a non-empty string/)
|
|
73
|
+
done()
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
assertions('should throw an error if the mparticle integration has a key with empty string ', (done) => {
|
|
77
|
+
|
|
78
|
+
project.integrations.mParticle.iOSApiKey = ''
|
|
79
|
+
let Project = new ProjectModel(project)
|
|
80
|
+
Project.validate((err, res) => {
|
|
81
|
+
assert.exists(err)
|
|
82
|
+
assert.match(err.message, /iOSApiKey should be an non-empty string/)
|
|
83
|
+
done()
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
assertions('should throw an error if the mparticle integration misses both keys ', (done) => {
|
|
87
|
+
|
|
88
|
+
delete project.integrations.mParticle.iOSApiKey
|
|
89
|
+
delete project.integrations.mParticle.androidApiKey
|
|
90
|
+
|
|
91
|
+
let Project = new ProjectModel(project)
|
|
92
|
+
Project.validate((err, res) => {
|
|
93
|
+
assert.exists(err)
|
|
94
|
+
assert.match(err.message, /should at least have androidApiKey or iOSApiKey/)
|
|
95
|
+
done()
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
assertions('should validate if the mparticle integration has only Ios key ', (done) => {
|
|
99
|
+
|
|
100
|
+
delete project.integrations.mParticle.androidApiKey
|
|
101
|
+
|
|
102
|
+
let Project = new ProjectModel(project)
|
|
103
|
+
Project.validate((err, res) => {
|
|
104
|
+
assert.notExists(res)
|
|
105
|
+
done()
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
64
109
|
testCase('recursive property check', () => {
|
|
65
110
|
let requiredFields = rules.requiredFields
|
|
66
111
|
requiredFields.map((i) => {
|
package/models/Project.js
CHANGED
|
@@ -11,6 +11,7 @@ let uuidv4 = require('uuid/v4')
|
|
|
11
11
|
let patcher = require('@bluedot-innovation/mongoose-json-patch')
|
|
12
12
|
let helpers = require('../helpers')
|
|
13
13
|
|
|
14
|
+
let IntegrationSchema = require('../schemas/Integration')
|
|
14
15
|
let WebhookSchema = require('../schemas/Webhook')
|
|
15
16
|
let iosConfig = require('../schemas/IosConfig')
|
|
16
17
|
let androidConfig = require('../schemas/AndroidConfig')
|
|
@@ -39,7 +40,7 @@ let ProjectSchema = new mongoose.Schema({
|
|
|
39
40
|
}, // http://collab.bluedot.io/display/PD/Remote+configuration => https://bluedotinnovation.atlassian.net/wiki/spaces/ENG/pages/223150126/Remote+Config+details
|
|
40
41
|
firebaseApiKey: {type: String, validate: helpers.validateNotNull},
|
|
41
42
|
apiKey: {type: String},
|
|
42
|
-
integrations:
|
|
43
|
+
integrations: IntegrationSchema
|
|
43
44
|
},
|
|
44
45
|
{collection: 'project'})
|
|
45
46
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
let mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const MParticleSchema = new mongoose.Schema({
|
|
5
|
+
androidApiKey: {
|
|
6
|
+
type: String,
|
|
7
|
+
validate:{
|
|
8
|
+
validator:apiKeyValidator,
|
|
9
|
+
msg:'androidApiKey should be a non-empty string, found ${VALUE}'
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
iOSApiKey:{
|
|
13
|
+
type:String,
|
|
14
|
+
validate:{
|
|
15
|
+
validator:apiKeyValidator,
|
|
16
|
+
msg:'iOSApiKey should be an non-empty string, found ${VALUE}'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const IntegrationSchema = new mongoose.Schema({
|
|
22
|
+
mParticle: {
|
|
23
|
+
type: MParticleSchema,
|
|
24
|
+
validate: {
|
|
25
|
+
validator: mParticleValidator,
|
|
26
|
+
msg: 'mParticle integration should at least have androidApiKey or iOSApiKey'
|
|
27
|
+
},
|
|
28
|
+
required: true
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function apiKeyValidator(value){
|
|
32
|
+
// only one of the Api keys is required.
|
|
33
|
+
if(typeof value === 'undefined'){
|
|
34
|
+
return true
|
|
35
|
+
}
|
|
36
|
+
// check if the value is a non-empty string
|
|
37
|
+
return !(typeof value !=='string' || value.trim() === '')
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
function mParticleValidator(value) {
|
|
41
|
+
const { androidApiKey, iOSApiKey } = value;
|
|
42
|
+
|
|
43
|
+
const isAndroidKeyProvided = typeof androidApiKey !== "undefined"
|
|
44
|
+
const isIOSKeyProvided = typeof iOSApiKey !== "undefined"
|
|
45
|
+
|
|
46
|
+
return isAndroidKeyProvided || isIOSKeyProvided;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = IntegrationSchema
|