@bluedot-innovation/models 10.4.0 → 10.6.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 +7 -0
- package/__tests__/destination/destination.data.json +4 -0
- package/__tests__/destination/destination.spec.js +163 -0
- package/__tests__/project/project.remote.config.json +0 -57
- package/__tests__/project/project.spec.js +35 -3
- package/__tests__/zone/zone.spec.js +0 -22
- package/constants/commonConstants.js +0 -1
- package/helpers.js +2 -2
- package/models/Destination.js +9 -2
- package/package.json +1 -1
- package/schemas/AndroidConfig.js +0 -5
- package/schemas/IosConfig.js +0 -4
- package/schemas/Webhook.js +3 -3
- package/schemas/Telemetry.js +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -239,4 +239,167 @@ describe('Invalid Destination ', () => {
|
|
|
239
239
|
assert.match(err.message, /Invalid state template id/)
|
|
240
240
|
}
|
|
241
241
|
})
|
|
242
|
+
|
|
243
|
+
it('should throw an error if CustomData value is null', async () => {
|
|
244
|
+
destination.customData["name3"] = null;
|
|
245
|
+
|
|
246
|
+
let Destination = new DestinationModel(destination)
|
|
247
|
+
try {
|
|
248
|
+
await Destination.validate()
|
|
249
|
+
} catch (err) {
|
|
250
|
+
assert.exists(err, 'err object should exist')
|
|
251
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
it('should throw an error if CustomData value is undefined', async () => {
|
|
256
|
+
destination.customData["name3"] = undefined;
|
|
257
|
+
|
|
258
|
+
let Destination = new DestinationModel(destination)
|
|
259
|
+
try {
|
|
260
|
+
await Destination.validate()
|
|
261
|
+
} catch (err) {
|
|
262
|
+
assert.exists(err, 'err object should exist')
|
|
263
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
it('should throw an error if CustomData value is an empty string', async () => {
|
|
268
|
+
destination.customData["name3"] = ' ';
|
|
269
|
+
|
|
270
|
+
let Destination = new DestinationModel(destination)
|
|
271
|
+
try {
|
|
272
|
+
await Destination.validate()
|
|
273
|
+
} catch (err) {
|
|
274
|
+
assert.exists(err, 'err object should exist')
|
|
275
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
276
|
+
}
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
it('should throw an error if CustomData value is an empty object', async () => {
|
|
280
|
+
destination.customData["name3"] = {};
|
|
281
|
+
|
|
282
|
+
let Destination = new DestinationModel(destination)
|
|
283
|
+
try {
|
|
284
|
+
await Destination.validate()
|
|
285
|
+
} catch (err) {
|
|
286
|
+
assert.exists(err, 'err object should exist')
|
|
287
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it('should throw an error if CustomData value is an object', async () => {
|
|
292
|
+
destination.customData["name3"] = { key: 'value' };
|
|
293
|
+
|
|
294
|
+
let Destination = new DestinationModel(destination)
|
|
295
|
+
try {
|
|
296
|
+
await Destination.validate()
|
|
297
|
+
} catch (err) {
|
|
298
|
+
assert.exists(err, 'err object should exist')
|
|
299
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
300
|
+
}
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
it('should throw an error if CustomData value is an empty array', async () => {
|
|
304
|
+
destination.customData["name3"] = [];
|
|
305
|
+
|
|
306
|
+
let Destination = new DestinationModel(destination)
|
|
307
|
+
try {
|
|
308
|
+
await Destination.validate()
|
|
309
|
+
} catch (err) {
|
|
310
|
+
assert.exists(err, 'err object should exist')
|
|
311
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
it('should throw an error if CustomData value is an array', async () => {
|
|
316
|
+
destination.customData["name3"] = ['value1', 'value2'];
|
|
317
|
+
|
|
318
|
+
let Destination = new DestinationModel(destination)
|
|
319
|
+
try {
|
|
320
|
+
await Destination.validate()
|
|
321
|
+
} catch (err) {
|
|
322
|
+
assert.exists(err, 'err object should exist')
|
|
323
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
it('should throw an error if CustomData value is a number', async () => {
|
|
328
|
+
destination.customData["name3"] = 1;
|
|
329
|
+
|
|
330
|
+
let Destination = new DestinationModel(destination)
|
|
331
|
+
try {
|
|
332
|
+
await Destination.validate()
|
|
333
|
+
} catch (err) {
|
|
334
|
+
assert.exists(err, 'err object should exist')
|
|
335
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
it('should throw an error if CustomData value is a boolean', async () => {
|
|
340
|
+
destination.customData["name3"] = true;
|
|
341
|
+
|
|
342
|
+
let Destination = new DestinationModel(destination)
|
|
343
|
+
try {
|
|
344
|
+
await Destination.validate()
|
|
345
|
+
} catch (err) {
|
|
346
|
+
assert.exists(err, 'err object should exist')
|
|
347
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
348
|
+
}
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
it('should throw an error if CustomData value is a NaN', async () => {
|
|
352
|
+
destination.customData["name3"] = NaN;
|
|
353
|
+
|
|
354
|
+
let Destination = new DestinationModel(destination)
|
|
355
|
+
try {
|
|
356
|
+
await Destination.validate()
|
|
357
|
+
} catch (err) {
|
|
358
|
+
assert.exists(err, 'err object should exist')
|
|
359
|
+
assert.match(err.message, /(CustomData value should be a string and should not be empty)/i);
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
it('should throw an error if CustomData has more than 20 key-value pairs', async () => {
|
|
364
|
+
for (let i = 0; i < 20; i++) {
|
|
365
|
+
destination.customData[`name_extra${i}`] = `Extra custom value ${i}`;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
let Destination = new DestinationModel(destination)
|
|
369
|
+
try {
|
|
370
|
+
await Destination.validate()
|
|
371
|
+
} catch (err) {
|
|
372
|
+
assert.exists(err, 'err object should exist')
|
|
373
|
+
assert.match(err.message, /(Only 20 custom data fields are allowed to be added per destination)/i);
|
|
374
|
+
}
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
it('should throw an error if CustomData key has invalid character', async () => {
|
|
378
|
+
destination.customData[`name!@`] = `Invalid character`;
|
|
379
|
+
|
|
380
|
+
let Destination = new DestinationModel(destination)
|
|
381
|
+
try {
|
|
382
|
+
await Destination.validate()
|
|
383
|
+
} catch (err) {
|
|
384
|
+
assert.exists(err, 'err object should exist')
|
|
385
|
+
console.log(err)
|
|
386
|
+
assert.match(err.message, /(CustomData key should have alpha numeric, - and _ characters only)/i);
|
|
387
|
+
}
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
it('should throw an error if CustomData keys are duplicate', async () => {
|
|
391
|
+
destination.customData = {
|
|
392
|
+
"key1": "value1",
|
|
393
|
+
"key1": "value1",
|
|
394
|
+
"key2": "value2",
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
let Destination = new DestinationModel(destination)
|
|
398
|
+
try {
|
|
399
|
+
await Destination.validate()
|
|
400
|
+
} catch (err) {
|
|
401
|
+
assert.exists(err, 'err object should exist')
|
|
402
|
+
assert.match(err.message, /(CustomData key should be unique)/i);
|
|
403
|
+
}
|
|
404
|
+
})
|
|
242
405
|
})
|
|
@@ -21,38 +21,9 @@
|
|
|
21
21
|
"trackingOnGpsAccuracyThreshold": 200.0,
|
|
22
22
|
"checkoutTimeAccuracy": 60.0,
|
|
23
23
|
"checkoutDistanceAccuracy": 50.0,
|
|
24
|
-
"beaconReevaluationDistance": 25.0,
|
|
25
|
-
"beaconActivationCoefficient": 0.5,
|
|
26
|
-
"beaconActivationDistance": 30.0,
|
|
27
24
|
"endpointUrl": "https://www.pointapi.bluedot.com.au/pointapi-v1/",
|
|
28
25
|
"filteringEnabled": false,
|
|
29
26
|
"applicationLoggingEnabled": false,
|
|
30
|
-
"telemetry" : {
|
|
31
|
-
"telemetryLoggingEnabled" : false,
|
|
32
|
-
"telemetryBatchSize" : 25,
|
|
33
|
-
"telemetryTimeOut": 30.0,
|
|
34
|
-
"telemetryEventsBlacklist" : [
|
|
35
|
-
"location",
|
|
36
|
-
"batteryLevel",
|
|
37
|
-
"beaconDiscovered",
|
|
38
|
-
"beaconDiscoveryStarted",
|
|
39
|
-
"beaconLost",
|
|
40
|
-
"gpsAccuracyRequested",
|
|
41
|
-
"rulesDownloadRequested",
|
|
42
|
-
"rulesLoaded",
|
|
43
|
-
"zoneCheckedIntoFence",
|
|
44
|
-
"zoneCheckedIntoBeacon",
|
|
45
|
-
"zoneCheckedOutFromBeacon",
|
|
46
|
-
"zoneCheckedOutFromFence",
|
|
47
|
-
"sdkStarted",
|
|
48
|
-
"sdkStopped",
|
|
49
|
-
"noMotion",
|
|
50
|
-
"log",
|
|
51
|
-
"heading",
|
|
52
|
-
"fenceCrossed",
|
|
53
|
-
"rulesDownloadBegin",
|
|
54
|
-
"rulesDownloadEnd" ]
|
|
55
|
-
},
|
|
56
27
|
"useCaseType" : "Retail",
|
|
57
28
|
"maximumPageSize": 256,
|
|
58
29
|
"triggerEngine": "BD",
|
|
@@ -64,9 +35,6 @@
|
|
|
64
35
|
"trackingOnGpsAccuracyThreshold" : 400.0,
|
|
65
36
|
"checkoutTimeAccuracy" : 60.0,
|
|
66
37
|
"checkoutDistanceAccuracy" : 50.0,
|
|
67
|
-
"beaconReevaluationDistance" : 10.0,
|
|
68
|
-
"beaconActivationCoefficient" : 0.5,
|
|
69
|
-
"beaconActivationDistance" : 30.0,
|
|
70
38
|
"periodicPollingEnabled" : true,
|
|
71
39
|
"triggeringOnPollingLocationBasicThreshold" : 1000.0,
|
|
72
40
|
"triggeringOnPollingLocationFurtherThreshold" : 3000.0,
|
|
@@ -90,31 +58,6 @@
|
|
|
90
58
|
"starvationDetectorSecsAllowedPerMetre" : 0.0225,
|
|
91
59
|
"starvationDetectorMinAllowedStarvationTimeInterval" : 30.0
|
|
92
60
|
},
|
|
93
|
-
"telemetry" : {
|
|
94
|
-
"telemetryLoggingEnabled" : false,
|
|
95
|
-
"telemetryBatchSize" : 25,
|
|
96
|
-
"telemetryTimeOut": 30.0,
|
|
97
|
-
"telemetryEventsBlacklist" : [ "location",
|
|
98
|
-
"batteryLevel",
|
|
99
|
-
"beaconDiscovered",
|
|
100
|
-
"beaconDiscoveryStarted",
|
|
101
|
-
"beaconLost",
|
|
102
|
-
"gpsAccuracyRequested",
|
|
103
|
-
"rulesDownloadRequested",
|
|
104
|
-
"rulesLoaded",
|
|
105
|
-
"zoneCheckedIntoFence",
|
|
106
|
-
"zoneCheckedIntoBeacon",
|
|
107
|
-
"zoneCheckedOutFromBeacon",
|
|
108
|
-
"zoneCheckedOutFromFence",
|
|
109
|
-
"sdkStarted",
|
|
110
|
-
"sdkStopped",
|
|
111
|
-
"noMotion",
|
|
112
|
-
"log",
|
|
113
|
-
"heading",
|
|
114
|
-
"fenceCrossed",
|
|
115
|
-
"rulesDownloadBegin",
|
|
116
|
-
"rulesDownloadEnd" ]
|
|
117
|
-
},
|
|
118
61
|
"maximumPageSize": 256,
|
|
119
62
|
"triggerEngine": "BD",
|
|
120
63
|
"nativeCheckinAccuracyThreshold" : 101,
|
|
@@ -158,6 +158,38 @@ describe('Project', () => {
|
|
|
158
158
|
const res = await Project.validate()
|
|
159
159
|
assert.notExists(res)
|
|
160
160
|
})
|
|
161
|
+
|
|
162
|
+
it(`should validate a project when webhook structure is 2.1`, async () => {
|
|
163
|
+
project.webhooks = [
|
|
164
|
+
{
|
|
165
|
+
"type": "trigger",
|
|
166
|
+
"url": "https://webhooklistener.bluedotinnovation.com",
|
|
167
|
+
"retryEnabled": true,
|
|
168
|
+
"structure": "2.1"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"type": "tempo",
|
|
172
|
+
"url": "https://webhooklistener.bluedotinnovation.com",
|
|
173
|
+
"retryEnabled": true,
|
|
174
|
+
"structure": "2.1"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"type": "wave",
|
|
178
|
+
"url": "https://webhooklistener.bluedotinnovation.com",
|
|
179
|
+
"structure": "standard",
|
|
180
|
+
"structure": "2.1"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"type": "helloOrder",
|
|
184
|
+
"url": "https://webhooklistener.bluedotinnovation.com",
|
|
185
|
+
"structure": "standard",
|
|
186
|
+
"structure": "2.1"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
let Project = new ProjectModel(project)
|
|
190
|
+
const res = await Project.validate()
|
|
191
|
+
assert.notExists(res)
|
|
192
|
+
})
|
|
161
193
|
})
|
|
162
194
|
testCase('Valid Project ', () => {
|
|
163
195
|
assertions('should validate a valid project ', async () => {
|
|
@@ -604,7 +636,7 @@ describe('Project', () => {
|
|
|
604
636
|
}
|
|
605
637
|
})
|
|
606
638
|
|
|
607
|
-
it(`should not validate if the type is hellOrder and the structure is not default`, async () => {
|
|
639
|
+
it(`should not validate if the type is hellOrder and the structure is not default or 2.1`, async () => {
|
|
608
640
|
project.webhooks[0].type = "helloOrder"
|
|
609
641
|
project.webhooks[0].structure = "standard"
|
|
610
642
|
let Project = new ProjectModel(project)
|
|
@@ -612,7 +644,7 @@ describe('Project', () => {
|
|
|
612
644
|
await Project.validate()
|
|
613
645
|
} catch (err) {
|
|
614
646
|
assert.exists(err, 'err object should exist')
|
|
615
|
-
assert.match(err.message, /type "helloOrder" can only have structure "default"/)
|
|
647
|
+
assert.match(err.message, /type "helloOrder" can only have structure "default" or "2.1"/)
|
|
616
648
|
}
|
|
617
649
|
})
|
|
618
650
|
it(`should not validate if structure is default and the type is not helloOrder`, async () => {
|
|
@@ -623,7 +655,7 @@ describe('Project', () => {
|
|
|
623
655
|
await Project.validate()
|
|
624
656
|
} catch (err) {
|
|
625
657
|
assert.exists(err, 'err object should exist')
|
|
626
|
-
assert.match(err.message, /type "helloOrder" can only have structure "default"/)
|
|
658
|
+
assert.match(err.message, /type "helloOrder" can only have structure "default" or "2.1"/)
|
|
627
659
|
}
|
|
628
660
|
})
|
|
629
661
|
|
|
@@ -330,28 +330,6 @@ describe('Zone', () => {
|
|
|
330
330
|
}
|
|
331
331
|
})
|
|
332
332
|
|
|
333
|
-
it('should throw an error when it contains both a beacon and a travelDirection condition', async () => {
|
|
334
|
-
zone.conditions.push(require('../condition/travelDirection/travelDirection.data.json'));
|
|
335
|
-
let Zone = new ZoneModel(zone)
|
|
336
|
-
try {
|
|
337
|
-
await Zone.validate()
|
|
338
|
-
} catch (err) {
|
|
339
|
-
assert.exists(err, 'err object should exist')
|
|
340
|
-
assert(err instanceof Error, "Should throw error.")
|
|
341
|
-
}
|
|
342
|
-
})
|
|
343
|
-
|
|
344
|
-
it('should throw an error when it contains both a beacon and a speed condition', async () => {
|
|
345
|
-
zone.conditions.push(require('../condition/speed/speed.data.json'));
|
|
346
|
-
let Zone = new ZoneModel(zone)
|
|
347
|
-
try {
|
|
348
|
-
await Zone.validate()
|
|
349
|
-
} catch (err) {
|
|
350
|
-
assert.exists(err, 'err object should exist')
|
|
351
|
-
assert(err instanceof Error, "Should throw error.")
|
|
352
|
-
}
|
|
353
|
-
})
|
|
354
|
-
|
|
355
333
|
it('should throw an error when triggerOnExit is null', async () => {
|
|
356
334
|
zone.triggerOnExit = null
|
|
357
335
|
await helpers.testNullValue(zone, ZoneModel)
|
package/helpers.js
CHANGED
|
@@ -2,7 +2,7 @@ var equal = require('deep-equal');
|
|
|
2
2
|
const { clean } = require('./utils');
|
|
3
3
|
const area = require('@turf/area').default;
|
|
4
4
|
const {polygon} = require('@turf/helpers');
|
|
5
|
-
const {
|
|
5
|
+
const {LOW_ACCURACY, TRAVEL_DIRECTION, SPEED} = require('./constants/commonConstants')
|
|
6
6
|
|
|
7
7
|
let helpers = {}
|
|
8
8
|
|
|
@@ -141,7 +141,7 @@ helpers.checkValidLowAccuracyFence = function(zone, next) {
|
|
|
141
141
|
if (!zone.geofeatures || !zone.geofeatures.length) return next()
|
|
142
142
|
zone.geofeatures.forEach(geofeature => {
|
|
143
143
|
if(!geofeature) return next(new Error("Geofeature must have a type"))
|
|
144
|
-
if(geofeature.
|
|
144
|
+
if(geofeature.accuracy === LOW_ACCURACY){
|
|
145
145
|
hasLowAccuracyFence = true
|
|
146
146
|
}
|
|
147
147
|
});
|
package/models/Destination.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
const mongoose = require('mongoose')
|
|
2
|
+
const Schema = mongoose.Schema
|
|
2
3
|
const uuidv4 = require('uuid/v4')
|
|
3
4
|
const patcher = require('@bluedot-innovation/mongoose-json-patch')
|
|
4
5
|
const Point = require('../schemas/Point')
|
|
5
6
|
const DestinationHelloSchema = require('../schemas/DestinationHello')
|
|
6
7
|
const helpers = require('../helpers')
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
const customDataValidators = [
|
|
10
|
+
{validator: helpers.validateCustomData, msg: 'CustomData key should have alpha numeric, - and _ characters only'},
|
|
11
|
+
{validator: helpers.checkDuplicateKeys, msg: 'CustomData key should be unique'},
|
|
12
|
+
{validator: helpers.isCustomDataValuesNotEmptyString, msg: 'CustomData value should be a string and should not be empty'},
|
|
13
|
+
{validator: helpers.isValidCustomDataCount, msg: 'Only 20 custom data fields are allowed to be added per destination'}
|
|
14
|
+
];
|
|
9
15
|
|
|
10
16
|
const DestinationSchema = new mongoose.Schema({
|
|
11
17
|
_id: {type: String, default: uuidv4},
|
|
@@ -19,7 +25,8 @@ const DestinationSchema = new mongoose.Schema({
|
|
|
19
25
|
projectId: {type: String, required: true, validate: {validator: helpers.validateUUIDv4, msg: 'Invalid projectId'}},
|
|
20
26
|
creationTime: {type: Date, default: Date.now},
|
|
21
27
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
22
|
-
hello: DestinationHelloSchema
|
|
28
|
+
hello: DestinationHelloSchema,
|
|
29
|
+
customData: {type: Schema.Types.Mixed, validate: customDataValidators},
|
|
23
30
|
}, {collection: 'destination'})
|
|
24
31
|
|
|
25
32
|
DestinationSchema.plugin(patcher)
|
package/package.json
CHANGED
package/schemas/AndroidConfig.js
CHANGED
|
@@ -15,11 +15,6 @@ let AndroidSchema = new mongoose.Schema({
|
|
|
15
15
|
trackingOnGpsAccuracyThreshold: {type: Number, required: true},
|
|
16
16
|
checkoutTimeAccuracy: {type: Number, required: true},
|
|
17
17
|
checkoutDistanceAccuracy: {type: Number, required: true},
|
|
18
|
-
beaconReevaluationDistance: {type: Number, required: true},
|
|
19
|
-
beaconActivationCoefficient: {type: Number, required: true},
|
|
20
|
-
beaconActivationDistance: {type: Number, required: true},
|
|
21
|
-
beaconDiscoveyCycleSecs: {type: Number, required: true, default: 20}, // The typo in `Discovey` is intentional to match the SDK
|
|
22
|
-
beaconCooloffCycleSecs: {type: Number, required: true, default: 10},
|
|
23
18
|
filteringEnabled: {type: Boolean, default: false},
|
|
24
19
|
applicationLoggingEnabled: {type: Boolean, default: false}, //Local logging on the device
|
|
25
20
|
useCaseType : {type: String, enum: useCaseTypeEnum, default: "Default"},
|
package/schemas/IosConfig.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let validators = require('../utils/validators')
|
|
3
|
-
let telemetrySchema = require('./Telemetry')
|
|
4
3
|
let accuracySuppressionSchema = require('./AccuracySuppression')
|
|
5
4
|
let starvationDetectionSchema = require('./StarvationDetection')
|
|
6
5
|
let TempoConfigSchema = require('./TempoConfig')
|
|
@@ -22,9 +21,6 @@ let IosSchema = new mongoose.Schema({
|
|
|
22
21
|
trackingOnGpsAccuracyThreshold : {type: Number, required: true},
|
|
23
22
|
checkoutTimeAccuracy : {type: Number, required: true},
|
|
24
23
|
checkoutDistanceAccuracy : {type: Number, required: true},
|
|
25
|
-
beaconReevaluationDistance : {type: Number, required: true},
|
|
26
|
-
beaconActivationCoefficient : {type: Number, required: true},
|
|
27
|
-
beaconActivationDistance : {type: Number, required: true},
|
|
28
24
|
periodicPollingEnabled : {type: Boolean, default: true},
|
|
29
25
|
triggeringOnPollingLocationBasicThreshold : {type: Number, required: true},
|
|
30
26
|
triggeringOnPollingLocationFurtherThreshold : {type: Number, required: true},
|
package/schemas/Webhook.js
CHANGED
|
@@ -31,9 +31,9 @@ function validateTypeAndStructure(type) {
|
|
|
31
31
|
if ((type === "register" && !['mobivity'].includes(this.structure))
|
|
32
32
|
|| (type !== "register" && ['mobivity'].includes(this.structure))) {
|
|
33
33
|
throw new Error('type "register" can only have structure "mobivity"')
|
|
34
|
-
} else if ((type === "helloOrder" && this.structure
|
|
34
|
+
} else if ((type === "helloOrder" && !['default', '2.1'].includes(this.structure))
|
|
35
35
|
|| (type !== "helloOrder" && this.structure === 'default')) {
|
|
36
|
-
throw new Error('type "helloOrder" can only have structure "default"')
|
|
36
|
+
throw new Error('type "helloOrder" can only have structure "default" or "2.1"')
|
|
37
37
|
} else if (type !== 'trigger' && this.structure === '2.0') {
|
|
38
38
|
throw new Error('Only type "trigger" can have structure 2.0')
|
|
39
39
|
}
|
|
@@ -46,7 +46,7 @@ let WebhookSchema = new mongoose.Schema({
|
|
|
46
46
|
body: {type: mongoose.Schema.Types.Mixed, validate: [{ validator: validators.validateNonEmptyStringKeyValuePairsOnly, msg: 'webhook body keys and values must be strings' }, { validator: validators.validateNoSpacesInObjectKeys, msg: 'webhook body keys cannot contain spaces' }]},
|
|
47
47
|
structure: {
|
|
48
48
|
type: String,
|
|
49
|
-
enum: ['standard', 'tealium', 'mobivity', 'default', '2.0'],
|
|
49
|
+
enum: ['standard', 'tealium', 'mobivity', 'default', '2.0', '2.1'],
|
|
50
50
|
default: function () {
|
|
51
51
|
return this.type === 'trigger' ? '2.0' : 'standard'
|
|
52
52
|
},
|
package/schemas/Telemetry.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
let mongoose = require('mongoose')
|
|
2
|
-
|
|
3
|
-
let telemetryBlacklistEnum = {
|
|
4
|
-
values: [ "location",
|
|
5
|
-
"batteryLevel",
|
|
6
|
-
"beaconDiscovered",
|
|
7
|
-
"beaconDiscoveryStarted",
|
|
8
|
-
"beaconLost",
|
|
9
|
-
"gpsAccuracyRequested",
|
|
10
|
-
"rulesDownloadRequested",
|
|
11
|
-
"rulesLoaded",
|
|
12
|
-
"zoneCheckedIntoFence",
|
|
13
|
-
"zoneCheckedIntoBeacon",
|
|
14
|
-
"zoneCheckedOutFromBeacon",
|
|
15
|
-
"zoneCheckedOutFromFence",
|
|
16
|
-
"sdkStarted",
|
|
17
|
-
"sdkStopped",
|
|
18
|
-
"noMotion",
|
|
19
|
-
"log",
|
|
20
|
-
"heading",
|
|
21
|
-
"fenceCrossed",
|
|
22
|
-
"rulesDownloadBegin",
|
|
23
|
-
"rulesDownloadEnd",
|
|
24
|
-
"debug"],
|
|
25
|
-
message: 'enum validator failed for path `{PATH}` with value `{VALUE}`'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let TelemetrySchema = new mongoose.Schema({
|
|
29
|
-
telemetryLoggingEnabled : {type: Boolean, required: true},
|
|
30
|
-
telemetryBatchSize : {type: Number, required: true},
|
|
31
|
-
telemetryTimeOut: {type: Number, required: true},
|
|
32
|
-
telemetryEventsBlacklist : [{type: String, enum: telemetryBlacklistEnum, required: true}]
|
|
33
|
-
}, {
|
|
34
|
-
_id: false
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
module.exports = TelemetrySchema
|