@bluedot-innovation/models 3.1.0 → 3.1.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,3 +1,7 @@
1
+
2
+ ## 3.1.1
3
+ - Rename `Polyline` to `Geoline`
4
+
1
5
  ## 3.1.0
2
6
  - Rename `filters` to `conditions`
3
7
 
package/Models.js CHANGED
@@ -19,7 +19,7 @@ Models.Zone = require('./models/Zone').Model
19
19
  Models.BoundingBox = require('./models/geofeatures/BoundingBox').Model
20
20
  Models.Circle = require('./models/geofeatures/Circle').Model
21
21
  Models.Polygon = require('./models/geofeatures/Polygon').Model
22
- Models.Polyline = require('./models/geofeatures/Polyline').Model
22
+ Models.Geoline = require('./models/geofeatures/Geoline').Model
23
23
  Models.ZoneBeacon = require('./models/geofeatures/ZoneBeacon').Model
24
24
 
25
25
  // Conditions
@@ -45,7 +45,7 @@ Schemas.Zone = require('./models/Zone').Schema
45
45
  Schemas.BoundingBox = require('./models/geofeatures/BoundingBox').Schema
46
46
  Schemas.Circle = require('./models/geofeatures/Circle').Schema
47
47
  Schemas.Polygon = require('./models/geofeatures/Polygon').Schema
48
- Schemas.Polyline = require('./models/geofeatures/Polyline').Schema
48
+ Schemas.Geoline = require('./models/geofeatures/Geoline').Schema
49
49
  Schemas.ZoneBeacon = require('./models/geofeatures/ZoneBeacon').Schema
50
50
 
51
51
  // Conditions
@@ -1,6 +1,6 @@
1
1
  {
2
- "type": "polyline",
3
- "name": "Test Polygon",
2
+ "type": "geoline",
3
+ "name": "Test geoline",
4
4
  "vertices": [
5
5
  {
6
6
  "latitude": -37.81902680201739,
@@ -43,4 +43,4 @@
43
43
  "longitude": 144.9821037054062
44
44
  }
45
45
  ]
46
- }
46
+ }
@@ -2,8 +2,8 @@ let mongoose = require('mongoose')
2
2
 
3
3
  mongoose.Promise = global.Promise
4
4
 
5
- let PolylineModel = require('../../../Models').Polyline(mongoose)
6
- let PolylineModelBuiltInMongoose = require('../../../Models').Polyline()
5
+ let GeolineModel = require('../../../Models').Geoline(mongoose)
6
+ let GeolineModelBuiltInMongoose = require('../../../Models').Geoline()
7
7
  let testCase = require('mocha').describe
8
8
  let assertions = require('mocha').it
9
9
  let chai = require('chai')
@@ -12,26 +12,26 @@ let assert = chai.assert
12
12
  let mocha = require('mocha')
13
13
  let beforeEach = mocha.beforeEach
14
14
 
15
- let rules = require('./polyline.rules.json')
15
+ let rules = require('./geoline.rules.json')
16
16
 
17
- let polyline
17
+ let geoline
18
18
 
19
19
  beforeEach(() => {
20
- polyline = JSON.parse(JSON.stringify(require('./polyline.data.json')))
20
+ geoline = JSON.parse(JSON.stringify(require('./geoline.data.json')))
21
21
  })
22
- testCase('Polyline', () => {
23
- testCase('Valid Polyline', () => {
24
- assertions('should validate a valid polyline ', (done) => {
25
- let Polyline = new PolylineModel(polyline)
26
- Polyline.validate((err, res) => {
22
+ testCase('Geoline', () => {
23
+ testCase('Valid Geoline', () => {
24
+ assertions('should validate a valid geoline ', (done) => {
25
+ let Geoline = new GeolineModel(geoline)
26
+ Geoline.validate((err, res) => {
27
27
  assert.notExists(res)
28
28
  assert(err === null, 'err should equals null')
29
29
  done()
30
30
  })
31
31
  })
32
- assertions('should validate a valid polyline (built in mongoose)', (done) => {
33
- let Polyline = new PolylineModelBuiltInMongoose(polyline)
34
- Polyline.validate((err, res) => {
32
+ assertions('should validate a valid geoline (built in mongoose)', (done) => {
33
+ let Geoline = new GeolineModelBuiltInMongoose(geoline)
34
+ Geoline.validate((err, res) => {
35
35
  assert.notExists(res)
36
36
  assert(err === null, 'err should equals null')
37
37
  done()
@@ -39,11 +39,11 @@ testCase('Polyline', () => {
39
39
  })
40
40
  })
41
41
 
42
- testCase('Invalid Polyline', () => {
43
- assertions('should not validate a polyline with invalid polyline', (done) => {
44
- delete polyline[rules.requiredFields[0]]
45
- let Polyline = new PolylineModel(polyline)
46
- Polyline.validate((err, res) => {
42
+ testCase('Invalid Geoline', () => {
43
+ assertions('should not validate a geoline with invalid geoline', (done) => {
44
+ delete geoline[rules.requiredFields[0]]
45
+ let Geoline = new GeolineModel(geoline)
46
+ Geoline.validate((err, res) => {
47
47
  assert.exists(err, 'err object should exist')
48
48
  assert.isObject(err)
49
49
  done()
@@ -53,10 +53,10 @@ testCase('Polyline', () => {
53
53
  let requiredFields = rules.requiredFields
54
54
  requiredFields.map((i) => {
55
55
  assertions(`should throw an error with property '${i}' if '${i}' is not present`, (done) => {
56
- // delete i from geofeatures' polyline child
57
- delete polyline[i]
58
- let Polyline = new PolylineModel(polyline)
59
- Polyline.validate((err, res) => {
56
+ // delete i from geofeatures' geoline child
57
+ delete geoline[i]
58
+ let Geoline = new GeolineModel(geoline)
59
+ Geoline.validate((err, res) => {
60
60
  assert.notExists(res)
61
61
  assert.exists(err, 'err object should exist')
62
62
  assert.isObject(err)
@@ -109,8 +109,8 @@
109
109
  }
110
110
  ]
111
111
  },{
112
- "type": "polyline",
113
- "name": "Test Polygon",
112
+ "type": "geoline",
113
+ "name": "Test Geoline",
114
114
  "vertices": [
115
115
  {
116
116
  "latitude": -37.81902680201739,
@@ -57,8 +57,8 @@ describe('Zone', () => {
57
57
  })
58
58
  })
59
59
 
60
- it('should instantiate a polyline', (done) => {
61
- zone.geofeatures = zone.geofeatures.filter(gf => gf.type.match(/^polyline$/))
60
+ it('should instantiate a geoline', (done) => {
61
+ zone.geofeatures = zone.geofeatures.filter(gf => gf.type.match(/^geoline$/))
62
62
  let Zone = new ZoneModel(zone)
63
63
  Zone.validate((err, res) => {
64
64
  assert.notExists(res)
package/models/Zone.js CHANGED
@@ -11,7 +11,7 @@ let messageActionSchema = require('./MessageAction').messageActionSchema
11
11
  let urlActionSchema = require('./UrlAction').urlActionSchema
12
12
  let circleSchema = require('./geofeatures/Circle').circleSchema
13
13
  let boundingBoxSchema = require('./geofeatures/BoundingBox').boundingBoxSchema
14
- let polylineSchema = require('./geofeatures/Polyline').polylineSchema
14
+ let geolineSchema = require('./geofeatures/Geoline').geolineSchema
15
15
  let polygonSchema = require('./geofeatures/Polygon').polygonSchema
16
16
  let beaconSchema = require('./geofeatures/ZoneBeacon').beaconSchema
17
17
 
@@ -92,7 +92,7 @@ zoneSchema.path('conditions').discriminator('travelPath', new Schema(travelPathR
92
92
  zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema))
93
93
  zoneSchema.path('geofeatures').discriminator('circle', new Schema(circleSchema))
94
94
  zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema))
95
- zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema))
95
+ zoneSchema.path('geofeatures').discriminator('geoline', new Schema(geolineSchema))
96
96
  zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema))
97
97
 
98
98
  zoneSchema.pre('validate', function(next) {
@@ -7,28 +7,28 @@ const schema = {
7
7
  _id: {type: String, default: uuidv4},
8
8
  geometry: {type: {}},
9
9
  name: {type: String, required: [true, 'name is required. ']},
10
- vertices: {type: [Point], required: [true, 'vertices is required. ']}
10
+ vertices: {type: [Point], required: [true, 'vertices are required. ']}
11
11
  }
12
12
 
13
- const PolylineSchema = new mongoose.Schema(schema, {
13
+ const GeolineSchema = new mongoose.Schema(schema, {
14
14
  _id: false,
15
15
  versionKey: false
16
16
  })
17
17
 
18
- PolylineSchema.add({
18
+ GeolineSchema.add({
19
19
  type: {type: String, required: true}
20
20
  })
21
21
 
22
22
  // optional mongoose
23
23
  let model = (mongooseInstance) => {
24
- let Polyline
24
+ let Geoline
25
25
  if (mongooseInstance) {
26
- Polyline = mongooseInstance.model('Polyline', PolylineSchema)
26
+ Geoline = mongooseInstance.model('Geoline', GeolineSchema)
27
27
  } else {
28
- Polyline = mongoose.model('Polyline', PolylineSchema)
28
+ Geoline = mongoose.model('Geoline', GeolineSchema)
29
29
  }
30
30
 
31
- return Polyline
31
+ return Geoline
32
32
  }
33
33
  // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
34
- module.exports = { Model: model, Schema: PolylineSchema, polylineSchema: schema }
34
+ module.exports = { Model: model, Schema: GeolineSchema, geolineSchema: schema }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "3.1.0",
3
+ "version": "3.1.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",
@@ -4,7 +4,7 @@ const { notSameThreeInARow, trimDecimals } = require('../utils');
4
4
  /**
5
5
  * checkDistanceBetweenVertices -
6
6
  * Returns boolean signalling whether or not enough space between points in
7
- * polygons and polylines. Checks closeness by checking if the same when trimmed
7
+ * polygons and geolines. Checks closeness by checking if the same when trimmed
8
8
  * to 6 decimal places
9
9
  */
10
10
  const checkDistanceBetweenVertices = function(vertices) {