@bluedot-innovation/models 7.0.5 → 7.0.6-alpha.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/CHANGELOG.md CHANGED
@@ -1,8 +1,14 @@
1
- ## 7.0.4
1
+ ## 7.0.6
2
+ - Removed tempo webhooks array for post wave migration deployment
3
+ - Removed tempo destinationId for post wave migration deployment
4
+
5
+ ## 7.0.5
2
6
  - Re-added Circle radius to be > 5m
3
7
 
8
+ ## 7.0.4 (deprecated)
9
+
4
10
  ## 7.0.3
5
- - Reverted changes on 7.0.2 for renaming of doorbell premigration
11
+ - Reverted changes on 7.0.2 for removing of tempo webhooks array and tempo destinationId for doorbell premigration
6
12
  - Renamed doorbell trigger type to wave
7
13
 
8
14
  ## 7.0.2
@@ -20,7 +26,7 @@
20
26
  - BREAKING CHANGE - Moved zone destinationId to object root and removed tempo object from zone
21
27
  - Added 'doorbell' type to project webhooks
22
28
 
23
- ## 6.2.12
29
+ ## 6.2.12 (deprecated)
24
30
  - Re-added Circle radius to be > 5m
25
31
 
26
32
  ## 6.2.11
@@ -40,16 +40,6 @@
40
40
  }
41
41
  },
42
42
  "tempo": {
43
- "isochroneBracketInterval": [60, 120, 300],
44
- "webhooks": [
45
- {
46
- "type": "tempo",
47
- "url": "https://webhooklistener.bluedotinnovation.com",
48
- "headers" : {
49
- "securityToken" : "value"
50
- }
51
- }
52
- ]
53
-
43
+ "isochroneBracketInterval": [60, 120, 300]
54
44
  }
55
45
  }
@@ -91,7 +91,6 @@ testCase('Project', () => {
91
91
  })
92
92
  })
93
93
 
94
- // TODO: Remove trigger type after migration
95
94
  assertions(`should not validate if one of webhooks have a type other than 'tempo', 'wave' or 'trigger'`, (done) => {
96
95
  project.webhooks.push({
97
96
  "type": "sandwich",
@@ -302,23 +301,6 @@ testCase('Project', () => {
302
301
  })
303
302
  })
304
303
 
305
- // TODO: Remove this test after migration
306
- assertions(`should not validate if one of tempo webhooks have a type other than 'tempo'`, (done) => {
307
- project.tempo.webhooks.push({
308
- "type": "trigger",
309
- "url": "https://webhooklistener.bluedotinnovation.com",
310
- "headers" : {
311
- "securityToken" : "value"
312
- }
313
- })
314
- let Project = new ProjectModel(project)
315
- Project.validate((err, res) => {
316
- assert.exists(err)
317
- assert.match(err.message, /tempo.webhooks should contain tempo webhooks only/)
318
- done()
319
- })
320
- })
321
-
322
304
 
323
305
  describe('should throw an error when any of the values of the array contains a falsy value', () => {
324
306
  let arrayTypeFields = rules.arrayTypeFields
@@ -450,77 +450,4 @@ describe('Zone', () => {
450
450
  })
451
451
  })
452
452
  })
453
-
454
- // TODO: Remove all tests in below describe block after migration
455
- describe("tempo.destinationId tests", () => {
456
- it('should save without errors when tempo.destinationId is null', (done) => {
457
- zone.tempo = {
458
- destinationId: null
459
- }
460
- let Zone = new ZoneModel(zone)
461
- Zone.validate((err, res) => {
462
- assert.notExists(res)
463
- assert.notExists(err)
464
- done()
465
- })
466
- })
467
-
468
- const validTempoGeofeatureTypes = ['boundingBox', 'circle', 'polygon']
469
-
470
- validTempoGeofeatureTypes.map(type => {
471
- it(`should save without errors when tempo.destinationId is set and there is a single ${type} geofeature`, (done) => {
472
- zone.tempo = {
473
- "destinationId": "test-destination-id"
474
- }
475
- zone.geofeatures = zone.geofeatures.filter(gf => gf.type.match(new RegExp(type)))
476
- let Zone = new ZoneModel(zone)
477
- Zone.validate((err, res) => {
478
- assert.notExists(res)
479
- assert.notExists(err)
480
- done()
481
- })
482
- })
483
- })
484
-
485
- it('should throw an error when tempo.destinationId is longer than 128 characters', (done) => {
486
- zone.tempo = {
487
- "destinationId": 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s'
488
- }
489
- let Zone = new ZoneModel(zone)
490
- Zone.validate((err, res) => {
491
- assert.exists(err, 'err object should exist')
492
- assert.match(err.message, /(destinationId must be less than 129 characters long)/i)
493
- done()
494
- })
495
- })
496
-
497
- const invalidTempoGeofeatures = ['geoline', 'beacon']
498
-
499
- invalidTempoGeofeatures.map(type => {
500
- it(`should throw an error when tempo.destinationId is set and there is a single ${type} geofeature`, (done) => {
501
- zone.tempo = {
502
- "destinationId": "test-destination-id"
503
- }
504
- zone.geofeatures = zone.geofeatures.filter(gf => gf.type.match(new RegExp(type)))
505
- let Zone = new ZoneModel(zone)
506
- Zone.validate((err, res) => {
507
- assert.exists(err, 'err object should exist')
508
- assert.match(err.message, /(destinationId cannot be set on zones with a geoline or beacon)/i)
509
- done()
510
- })
511
- })
512
- })
513
-
514
- it('should throw an error when tempo.destinationId is set and there is more than one geofeature', (done) => {
515
- zone.tempo = {
516
- "destinationId": "test-destination-id"
517
- }
518
- let Zone = new ZoneModel(zone)
519
- Zone.validate((err, res) => {
520
- assert.exists(err, 'err object should exist')
521
- assert.match(err.message, /(destinationId can only be set on zones with a single geofeature)/i)
522
- done()
523
- })
524
- })
525
- })
526
453
  })
package/helpers.js CHANGED
@@ -281,32 +281,5 @@ helpers.validateNoDuplicateWebhookTypes = function(webhookArray) {
281
281
  return !duplicateFound;
282
282
  }
283
283
 
284
- // TODO: Remove below three methods after migration
285
- helpers.validateTempoWebhooks = function(webhooks) {
286
- const notTempo = webhooks.some(webhook => {
287
- return webhook.type && webhook.type != 'tempo'
288
- })
289
- return !notTempo
290
- }
291
-
292
- helpers.validateTempoDestinationSingleGeofeature = function(destinationId) {
293
- if(destinationId){
294
- const geofeatures = this.ownerDocument().geofeatures
295
- if(!geofeatures.length){
296
- return false
297
- }
298
- return geofeatures.length === 1
299
- }
300
- return true
301
- }
302
-
303
- helpers.validateTempoDestinationIdGeofeatureType = function(destinationId) {
304
- const geofeatures = this.ownerDocument().geofeatures
305
- if(destinationId && geofeatures.length){
306
- return !(geofeatures[0].type === 'geoline' || geofeatures[0].type === 'beacon')
307
- }
308
- return true
309
- }
310
-
311
284
 
312
285
  module.exports = helpers
package/models/Zone.js CHANGED
@@ -22,8 +22,6 @@ let travelDirectionRawSchema = require('./conditions/TravelDirection').rawSchema
22
22
  let travelPathRawSchema = require('./conditions/TravelPath').rawSchema
23
23
  let timeActiveRawSchema = require('./conditions/TimeActive').rawSchema
24
24
 
25
- let zoneTempoSchema = require('../schemas/ZoneTempo')
26
-
27
25
  let uuidv4 = require('uuid/v4')
28
26
  let patcher = require('@bluedot-innovation/mongoose-json-patch')
29
27
  let helpers = require('../helpers')
@@ -125,8 +123,6 @@ let zoneSchema = new Schema({
125
123
  { validator: helpers.validateDestinationSingleGeofeature, msg: 'destinationId can only be set on zones with a single geofeature' },
126
124
  { validator: helpers.validateDestinationIdGeofeatureType, msg: 'destinationId cannot be set on zones with a geoline or beacon' }
127
125
  ]},
128
- // TODO: Remove tempo object after migration
129
- tempo: zoneTempoSchema
130
126
  }, {collection: 'zone', autoIndex: false})
131
127
 
132
128
  zoneSchema.index(
@@ -140,18 +136,6 @@ zoneSchema.index(
140
136
  name: "destinationUniqueWithinProject"
141
137
  })
142
138
 
143
- // TODO: Remove below index after migration
144
- zoneSchema.index(
145
- {
146
- projectId: 1,
147
- 'tempo.destinationId': 1
148
- },
149
- {
150
- unique: true,
151
- partialFilterExpression: { 'tempo.destinationId': { $exists:true, $type:"string" } },
152
- name: "tempoDestinationUniqueWithinProject"
153
- })
154
-
155
139
  // Mongoose-json-patch
156
140
  // https://www.npmjs.com/package/mongoose-json-patch
157
141
  // plugin for PATCH operations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "7.0.5",
3
+ "version": "7.0.6-alpha.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",
@@ -1,7 +1,4 @@
1
1
  let mongoose = require('mongoose')
2
- // TODO: Remove below imports after migration
3
- let WebhookSchema = require('./Webhook')
4
- let helpers = require('../helpers')
5
2
 
6
3
  function validateIsochroneBracketInterval (brackets) {
7
4
  const isInteger = brackets.every((bracket) => {
@@ -11,16 +8,8 @@ function validateIsochroneBracketInterval (brackets) {
11
8
  return isInteger
12
9
  }
13
10
 
14
- // TODO: Remove below validators after migration
15
- let webhooksValidators = [
16
- {validator: helpers.validateNotNull},
17
- {validator: helpers.validateTempoWebhooks, msg: 'tempo.webhooks should contain tempo webhooks only'}
18
- ];
19
-
20
11
  let ProjectTempoSchema = new mongoose.Schema({
21
12
  isochroneBracketInterval: {type: [Number], validate: { validator: validateIsochroneBracketInterval, msg: 'tempo.isochroneBracketInterval should contain integer numbers only' }},
22
- // TODO: Remove webhooks after migration
23
- webhooks: {type:[WebhookSchema], validate: webhooksValidators}
24
13
  }, {
25
14
  _id: false
26
15
  })
@@ -17,18 +17,6 @@ const indexes = {
17
17
  partialFilterExpression: { destinationId: { $exists:true, $type:"string" } },
18
18
  name: "destinationUniqueWithinProject"
19
19
  }
20
- },
21
- // TODO: Remove below index after migration
22
- {
23
- fields: {
24
- projectId: 1,
25
- 'tempo.destinationId': 1
26
- },
27
- options: {
28
- unique: true,
29
- partialFilterExpression: { 'tempo.destinationId': { $exists:true, $type:"string" } },
30
- name: "tempoDestinationUniqueWithinProject"
31
- }
32
20
  }
33
21
  ]
34
22
  }
@@ -1,15 +0,0 @@
1
- // TODO: Remove this file after migration
2
- let mongoose = require('mongoose')
3
- let helpers = require('../helpers')
4
-
5
- let ZoneTempoSchema = new mongoose.Schema({
6
- destinationId: {type: String, validate: [
7
- { validator: helpers.validateDestinationIdLength, msg: 'destinationId must be less than 129 characters long' },
8
- { validator: helpers.validateTempoDestinationSingleGeofeature, msg: 'destinationId can only be set on zones with a single geofeature' },
9
- { validator: helpers.validateTempoDestinationIdGeofeatureType, msg: 'destinationId cannot be set on zones with a geoline or beacon' }
10
- ]}
11
- }, {
12
- _id: false
13
- })
14
-
15
- module.exports = ZoneTempoSchema