@bluedot-innovation/models 5.1.17 → 5.1.19

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,3 +1,9 @@
1
+ ## 5.1.19
2
+ - Lowercase incoming tags and remove duplicates
3
+
4
+ ## 5.1.18
5
+ - Add status field to TestInstance
6
+
1
7
  ## 5.1.17
2
8
  - Add validation for `txPower` to Beacon collection
3
9
 
@@ -85,6 +85,18 @@ describe('Zone', () => {
85
85
  done()
86
86
  })
87
87
  })
88
+
89
+ it('should set tags to lowercase and remove the duplicated tag', (done) => {
90
+ zone.tags = ["TAG", 1, "TaG", 1]
91
+
92
+ let Zone = new ZoneModel(zone)
93
+ assert.exists(Zone._doc)
94
+ assert.exists(Zone._doc.tags)
95
+ assert.strictEqual(Zone._doc.tags.length, 2)
96
+ assert.strictEqual(Zone._doc.tags[0], "tag")
97
+ assert.strictEqual(Zone._doc.tags[1], "1")
98
+ done()
99
+ })
88
100
  })
89
101
 
90
102
  describe('Invalid Zone ', () => {
@@ -4,6 +4,7 @@
4
4
  */
5
5
  let mongoose = require('mongoose')
6
6
  let StateEnum = require('@bluedot-innovation/enums').StateEnum
7
+ let TestStatusEnum = require('@bluedot-innovation/enums').TestStatusEnum
7
8
 
8
9
  let TestInstanceSchema = new mongoose.Schema(
9
10
  {
@@ -19,6 +20,7 @@ let TestInstanceSchema = new mongoose.Schema(
19
20
  creationTime: {type: Date, default: Date.now},
20
21
  lastUpdateTime: {type: Date, default: Date.now},
21
22
  state: {type: String, default: StateEnum.ACTIVE},
23
+ status: {type: String, default: TestStatusEnum.PLANNED},
22
24
  isValid: {type: Boolean, default: true},
23
25
  comments: String,
24
26
  isProduction: Boolean,
package/models/Zone.js CHANGED
@@ -37,6 +37,10 @@ let customDataValidators = [
37
37
  {validator: helpers.isValidCustomDataCount, msg: 'Only 5 custom data fields are allowed to be added per zone'}
38
38
  ];
39
39
 
40
+ const tagsFormation = (tags) => {
41
+ return [...new Set(tags.map(tag => typeof tag === 'string' ? tag.toLowerCase(): tag))]
42
+ }
43
+
40
44
  let actionSchema = new Schema({},
41
45
  { discriminatorKey: 'type', _id: false })
42
46
 
@@ -59,7 +63,7 @@ let zoneSchema = new Schema({
59
63
  message: '{VALUE} is not a number'
60
64
  }
61
65
  },
62
- tags: {type: [String], validate: helpers.validateNotNull},
66
+ tags: {type: [String], set : tagsFormation, validate: helpers.validateNotNull},
63
67
  conditions: {
64
68
  type: [conditionSchema]
65
69
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.17",
3
+ "version": "5.1.19",
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",
@@ -28,7 +28,7 @@
28
28
  "sinon": "^4.1.2"
29
29
  },
30
30
  "dependencies": {
31
- "@bluedot-innovation/enums": "2.1.4",
31
+ "@bluedot-innovation/enums": "2.1.5",
32
32
  "@bluedot-innovation/mongoose-json-patch": "0.0.6",
33
33
  "deep-equal": "^1.0.1",
34
34
  "fast-deep-equal": "^2.0.1",