@bluedot-innovation/models 2.0.19-alpha.12 → 2.0.19-alpha.14

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.
@@ -9,7 +9,7 @@ beforeEach(() => {
9
9
 
10
10
  describe('Zone', () => {
11
11
  describe('Valid Zone ', () => {
12
- it.only('should validate a valid zone ', (done) => {
12
+ it('should validate a valid zone ', (done) => {
13
13
  let Zone = new ZoneModel(zone)
14
14
  Zone.validate((err, res) => {
15
15
  assert.notExists(res)
package/models/Zone.js CHANGED
@@ -9,11 +9,11 @@ let Schema = mongoose.Schema
9
9
  let StateEnum = require('@bluedot-innovation/enums').StateEnum
10
10
  let messageActionSchema = require('./MessageAction').messageActionSchema
11
11
  let urlActionSchema = require('./UrlAction').urlActionSchema
12
- let circleSchema = require('./geofeatures/Circle').Schema
13
- let boundingBoxSchema = require('./geofeatures/BoundingBox').boundingBoxSchema
14
- let polylineSchema = require('./geofeatures/Polyline').polylineSchema
15
- let polygonSchema = require('./geofeatures/Polygon').polygonSchema
16
- let beaconSchema = require('./ZoneBeacon').beaconSchema
12
+ let circleSchema = require('./geofeatures/Circle').rawSchema
13
+ let boundingBoxSchema = require('./geofeatures/BoundingBox').rawSchema
14
+ let polylineSchema = require('./geofeatures/Polyline').rawSchema
15
+ let polygonSchema = require('./geofeatures/Polygon').rawSchema
16
+ let beaconSchema = require('./ZoneBeacon').rawSchema
17
17
  let speedFilterSchema = require('./SpeedFilter').speedFilterSchema
18
18
  let bearingFilterSchema = require('./BearingFilter').bearingFilterSchema
19
19
  let timeOfDayRangeFilterSchema = require('./TimeOfDayRangeFilter').timeOfDayRangeFilterSchema
@@ -83,11 +83,11 @@ zoneSchema.path('filters').discriminator('percentageCrossed', new Schema(percent
83
83
  zoneSchema.path('filters').discriminator('speed', new Schema(speedFilterSchema))
84
84
  zoneSchema.path('filters').discriminator('timeOfDayRange', new Schema(timeOfDayRangeFilterSchema))
85
85
 
86
- zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema))
87
- zoneSchema.path('geofeatures').discriminator('circle', circleSchema)
88
- zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema))
89
- zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema))
90
- zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema))
86
+ zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema).plugin(mongooseHidden))
87
+ zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema).plugin(mongooseHidden))
88
+ zoneSchema.path('geofeatures').discriminator('circle', new Schema(circleSchema).plugin(mongooseHidden))
89
+ zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema).plugin(mongooseHidden))
90
+ zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema).plugin(mongooseHidden))
91
91
 
92
92
  // optional mongoose
93
93
  const model = (mongooseInstance) => {
@@ -1,6 +1,6 @@
1
1
  const cloneDeep = require('lodash.clonedeep')
2
2
  const mongoose = require('mongoose')
3
- const beaconSchema = require('./geofeatures/Beacon').beaconSchema
3
+ const beaconSchema = require('./geofeatures/Beacon').rawSchema
4
4
  const BeaconEnum = require('@bluedot-innovation/enums').BeaconEnum
5
5
 
6
6
  const schema = cloneDeep(beaconSchema)
@@ -20,4 +20,4 @@ let model = (mongooseInstance) => {
20
20
  }
21
21
 
22
22
  // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
23
- module.exports = { Model: model, Schema: ZoneBeaconSchema, beaconSchema: schema }
23
+ module.exports = { Model: model, Schema: ZoneBeaconSchema, rawSchema: schema }
@@ -91,4 +91,4 @@ let model = (mongooseInstance) => {
91
91
  return Beacon
92
92
  }
93
93
  // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
94
- module.exports = { Model: model, Schema: BeaconSchema, beaconSchema: schema }
94
+ module.exports = { Model: model, Schema: BeaconSchema, rawSchema: schema }
@@ -17,16 +17,15 @@ const schema = {
17
17
  state: {type: String, default: StateEnum.active, select: false}
18
18
  }
19
19
 
20
- const boundingBoxSchema = new mongoose.Schema(
21
- schema,
22
- {
23
- _id: false,
24
- versionKey: false
25
- })
20
+ const boundingBoxSchema = new mongoose.Schema(schema, {
21
+ _id: false,
22
+ versionKey: false
23
+ })
26
24
 
25
+ // Adding type after, because we need to export the rawSchema without type,
26
+ // since the zone discriminator needs the schema without it
27
27
  boundingBoxSchema.add({
28
- type:
29
- {type: String, required: true}
28
+ type: {type: String, required: true}
30
29
  })
31
30
 
32
31
  boundingBoxSchema.plugin(mongooseHidden)
@@ -44,4 +43,4 @@ let model = (mongooseInstance) => {
44
43
  return BoundingBox
45
44
  }
46
45
  // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
47
- module.exports = { Model: model, Schema: boundingBoxSchema, boundingBoxSchema: schema }
46
+ module.exports = { Model: model, Schema: boundingBoxSchema, rawSchema: schema }
@@ -24,6 +24,8 @@ let circleSchema = new mongoose.Schema(
24
24
  __v: false
25
25
  })
26
26
 
27
+ // Adding type after, because we need to export the rawSchema without type,
28
+ // since the zone discriminator needs the schema without it
27
29
  circleSchema.add({
28
30
  type: {type: String, required: true}
29
31
  })
@@ -42,4 +44,4 @@ let model = (mongooseInstance) => {
42
44
  return Circle
43
45
  }
44
46
  // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
45
- module.exports = { Model: model, Schema: circleSchema, circleSchema: schema }
47
+ module.exports = { Model: model, Schema: circleSchema, rawSchema: schema }
@@ -41,4 +41,4 @@ let model = (mongooseInstance) => {
41
41
  return Polygon
42
42
  }
43
43
  // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
44
- module.exports = { Model: model, Schema: polygonSchema, polygonSchema: schema }
44
+ module.exports = { Model: model, Schema: polygonSchema, rawSchema: schema }
@@ -15,13 +15,13 @@ const schema = {
15
15
  state: {type: String, default: StateEnum.active, select: false}
16
16
  }
17
17
 
18
- const polylineSchema = new mongoose.Schema(
19
- schema,
20
- {
21
- _id: false,
22
- versionKey: false
23
- })
18
+ const polylineSchema = new mongoose.Schema(schema, {
19
+ _id: false,
20
+ versionKey: false
21
+ })
24
22
 
23
+ // Adding type after, because we need to export the rawSchema without type,
24
+ // since the zone discriminator needs the schema without it
25
25
  polylineSchema.add({
26
26
  type: {type: String, required: true}
27
27
  })
@@ -40,4 +40,4 @@ let model = (mongooseInstance) => {
40
40
  return Polyline
41
41
  }
42
42
  // Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
43
- module.exports = { Model: model, Schema: polylineSchema, polylineSchema: schema }
43
+ module.exports = { Model: model, Schema: polylineSchema, rawSchema: schema }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "2.0.19-alpha.12",
3
+ "version": "2.0.19-alpha.14",
4
4
  "description": "",
5
5
  "main": "Models.js",
6
6
  "scripts": {