@bluedot-innovation/models 5.1.14 → 5.1.15-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,3 +1,6 @@
1
+ ## 5.1.15
2
+ - Updated TMP and Blueconnect models to latest file structure
3
+
1
4
  ## 5.1.14
2
5
  - Validate Mac address against 64-bit Mac Address format
3
6
 
package/Models.js CHANGED
@@ -30,19 +30,19 @@ Models.Speed = require('./models/conditions/Speed').Model
30
30
  Models.TravelDirection = require('./models/conditions/TravelDirection').Model
31
31
 
32
32
  // Test Management Portal
33
- Models.TestDevice = require('./models/TestDevice')
34
- Models.TestDeviceCluster = require('./models/TestDeviceCluster')
35
- Models.TestInstance = require('./models/TestInstance')
36
- Models.TestScenario = require('./models/TestScenario')
33
+ Models.TestDevice = require('./models/TestDevice').Model
34
+ Models.TestDeviceCluster = require('./models/TestDeviceCluster').Model
35
+ Models.TestInstance = require('./models/TestInstance').Model
36
+ Models.TestScenario = require('./models/TestScenario').Model
37
37
 
38
38
  // Blue Connect
39
- Models.AdminPortalUser = require('./models/AdminPortalUser')
40
- Models.CustomerLogin = require('./models/CustomerLogin')
41
- Models.NotificationLogEntry = require('./models/NotificationLogEntry')
42
- Models.DBEvent = require('./models/DBEvent')
43
- Models.SingleUseToken = require('./models/SingleUseToken')
44
- Models.Contract = require('./models/Contract')
45
- Models.DailyStats = require('./models/DailyStats')
39
+ Models.AdminPortalUser = require('./models/AdminPortalUser').Model
40
+ Models.CustomerLogin = require('./models/CustomerLogin').Model
41
+ Models.NotificationLogEntry = require('./models/NotificationLogEntry').Model
42
+ Models.DBEvent = require('./models/DBEvent').Model
43
+ Models.SingleUseToken = require('./models/SingleUseToken').Model
44
+ Models.Contract = require('./models/Contract').Model
45
+ Models.DailyStats = require('./models/DailyStats').Model
46
46
 
47
47
  let Schemas = {}
48
48
 
@@ -5,21 +5,31 @@
5
5
  let mongoose = require('mongoose')
6
6
  let Enums = require('@bluedot-innovation/enums')
7
7
 
8
- let AdminPortalUser = mongoose.model('AdminPortalUser', new mongoose.Schema(
8
+ let AdminPortalUserSchema = new mongoose.Schema(
9
9
  {
10
10
  emailAddress: String,
11
11
  password: String,
12
12
  firstName: String,
13
13
  lastName: String,
14
14
  state: {type: String, default: Enums.StateEnum.ACTIVE},
15
- 'creationTime': {type: Date, default: Date.now},
16
- 'dataSource': {type: String, select: false, default: 'AdminPortal'},
15
+ creationTime: {type: Date, default: Date.now},
16
+ dataSource: {type: String, select: false, default: 'AdminPortal'},
17
17
  adminId: String,
18
18
  secret: String
19
19
  },
20
- {
21
- collection: 'adminPortalUser'
22
- })
20
+ { collection: 'adminPortalUser' }
23
21
  )
24
22
 
25
- module.exports = AdminPortalUser
23
+ // optional mongoose
24
+ let model = (mongooseInstance) => {
25
+ let AdminPortalUser
26
+ if (mongooseInstance) {
27
+ AdminPortalUser = mongooseInstance.model('AdminPortalUser', AdminPortalUserSchema)
28
+ } else {
29
+ AdminPortalUser = mongoose.model('AdminPortalUser', AdminPortalUserSchema)
30
+ }
31
+
32
+ return AdminPortalUser
33
+ }
34
+
35
+ module.exports = { Model: model, Schema: AdminPortalUserSchema }
@@ -5,7 +5,7 @@
5
5
  */
6
6
  let mongoose = require('mongoose')
7
7
 
8
- let Contract = mongoose.model('Contract', new mongoose.Schema(
8
+ let ContractSchema = new mongoose.Schema(
9
9
  {
10
10
  customerId: String,
11
11
  organisationName: String,
@@ -36,9 +36,19 @@ let Contract = mongoose.model('Contract', new mongoose.Schema(
36
36
  lastUpdateTime: {type: Date, default: Date.now},
37
37
  dataSource: {type: String, select: false, default: 'adminPortal'}
38
38
  },
39
- {
40
- collection: 'contract'
41
- })
39
+ { collection: 'contract' }
42
40
  )
43
41
 
44
- module.exports = Contract
42
+ // optional mongoose
43
+ let model = (mongooseInstance) => {
44
+ let Contract
45
+ if (mongooseInstance) {
46
+ Contract = mongooseInstance.model('Contract', ContractSchema)
47
+ } else {
48
+ Contract = mongoose.model('Contract', ContractSchema)
49
+ }
50
+
51
+ return Contract
52
+ }
53
+
54
+ module.exports = { Model: model, Schema: ContractSchema }
@@ -5,7 +5,7 @@
5
5
  var mongoose = require('mongoose')
6
6
  var StateEnum = require('@bluedot-innovation/enums').StateEnum
7
7
 
8
- var CustomerLogin = mongoose.model('CustomerLogin', new mongoose.Schema(
8
+ var CustomerLoginSchema = new mongoose.Schema(
9
9
  {
10
10
  _id: String,
11
11
  customerId: String,
@@ -25,9 +25,19 @@ var CustomerLogin = mongoose.model('CustomerLogin', new mongoose.Schema(
25
25
  createdBy: String,
26
26
  lastUpdatedBy: String
27
27
  },
28
- {
29
- collection: 'customerLogin'
30
- })
31
- )
28
+ { collection: 'customerLogin' }
29
+ )
30
+
31
+ // optional mongoose
32
+ let model = (mongooseInstance) => {
33
+ let CustomerLogin
34
+ if (mongooseInstance) {
35
+ CustomerLogin = mongooseInstance.model('CustomerLogin', CustomerLoginSchema)
36
+ } else {
37
+ CustomerLogin = mongoose.model('CustomerLogin', CustomerLoginSchema)
38
+ }
39
+
40
+ return CustomerLogin
41
+ }
32
42
 
33
- module.exports = CustomerLogin
43
+ module.exports = { Model: model, Schema: CustomerLoginSchema }
package/models/DBEvent.js CHANGED
@@ -5,16 +5,28 @@
5
5
  */
6
6
  let mongoose = require('mongoose')
7
7
 
8
- let DBEventSchema = new mongoose.Schema({
9
- _class: {type: String, default: 'au.com.bluedot.application.spring.DBEvent'},
10
- customerId: String,
11
- customerEmail: String,
12
- actionName: String,
13
- referenceId: String,
14
- creationTime: {type: Date, select: false, default: Date.now}
15
- },
16
- {collection: 'dbevent'}
8
+ let DBEventSchema = new mongoose.Schema(
9
+ {
10
+ _class: {type: String, default: 'au.com.bluedot.application.spring.DBEvent'},
11
+ customerId: String,
12
+ customerEmail: String,
13
+ actionName: String,
14
+ referenceId: String,
15
+ creationTime: {type: Date, select: false, default: Date.now}
16
+ },
17
+ { collection: 'dbevent' }
17
18
  )
18
- let DBEvent = mongoose.model('DBEvent', DBEventSchema)
19
19
 
20
- module.exports = DBEvent
20
+ // optional mongoose
21
+ let model = (mongooseInstance) => {
22
+ let DBEvent
23
+ if (mongooseInstance) {
24
+ DBEvent = mongooseInstance.model('DBEvent', DBEventSchema)
25
+ } else {
26
+ DBEvent = mongoose.model('DBEvent', DBEventSchema)
27
+ }
28
+
29
+ return DBEvent
30
+ }
31
+
32
+ module.exports = { Model: model, Schema: DBEventSchema }
@@ -8,21 +8,30 @@ const mongoose = require('mongoose')
8
8
  const Schema = mongoose.Schema
9
9
  const uuidv4 = require('uuid/v4')
10
10
 
11
- const DailyStats = mongoose.model(
12
- 'DailyStats',
13
- new Schema(
14
- {
15
- _id: {type: String, default: uuidv4},
16
- totalEndUsers: Number,
17
- totalIos: Number,
18
- totalAndroid: Number,
19
- creationDate: {type: Date, default: Date.now}
20
- },
21
- {
22
- collection: 'dailyStats',
23
- versionKey: false
24
- }
25
- )
11
+ const DailyStatsSchema = new Schema(
12
+ {
13
+ _id: {type: String, default: uuidv4},
14
+ totalEndUsers: Number,
15
+ totalIos: Number,
16
+ totalAndroid: Number,
17
+ creationDate: {type: Date, default: Date.now}
18
+ },
19
+ {
20
+ collection: 'dailyStats',
21
+ versionKey: false
22
+ }
26
23
  )
27
24
 
28
- module.exports = DailyStats
25
+ // optional mongoose
26
+ let model = (mongooseInstance) => {
27
+ let DailyStats
28
+ if (mongooseInstance) {
29
+ DailyStats = mongooseInstance.model('DailyStats', DailyStatsSchema)
30
+ } else {
31
+ DailyStats = mongoose.model('DailyStats', DailyStatsSchema)
32
+ }
33
+
34
+ return DailyStats
35
+ }
36
+
37
+ module.exports = { Model: model, Schema: DailyStatsSchema }
@@ -5,14 +5,25 @@
5
5
  */
6
6
  let mongoose = require('mongoose')
7
7
 
8
- let NotificationLogEntry = mongoose.model('NotificationLogEntry', new mongoose.Schema(
8
+ let NotificationLogEntrySchema = new mongoose.Schema(
9
9
  {
10
10
  _id: String,
11
11
  'notification.zoneId': String,
12
12
  creationTime: {type: Date}
13
13
  },
14
- {
15
- collection: 'notificationLogEntry'
14
+ { collection: 'notificationLogEntry' }
15
+ )
16
+
17
+ // optional mongoose
18
+ let model = (mongooseInstance) => {
19
+ let NotificationLogEntry
20
+ if (mongooseInstance) {
21
+ NotificationLogEntry = mongooseInstance.model('NotificationLogEntry', NotificationLogEntrySchema)
22
+ } else {
23
+ NotificationLogEntry = mongoose.model('NotificationLogEntry', NotificationLogEntrySchema)
16
24
  }
17
- ))
18
- module.exports = NotificationLogEntry
25
+
26
+ return NotificationLogEntry
27
+ }
28
+
29
+ module.exports = { Model: model, Schema: NotificationLogEntrySchema }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  let mongoose = require('mongoose')
5
5
 
6
- let SingleUseToken = mongoose.model('SingleUseToken', new mongoose.Schema(
6
+ let SingleUseTokenSchema = new mongoose.Schema(
7
7
  {
8
8
  tokenString: String,
9
9
  customerId: String,
@@ -11,9 +11,19 @@ let SingleUseToken = mongoose.model('SingleUseToken', new mongoose.Schema(
11
11
  integration: {type: String, default: 'admin'},
12
12
  expiration: Date
13
13
  },
14
- {
15
- collection: 'singleUseToken'
16
- })
14
+ { collection: 'singleUseToken' }
17
15
  )
18
16
 
19
- module.exports = SingleUseToken
17
+ // optional mongoose
18
+ let model = (mongooseInstance) => {
19
+ let SingleUseToken
20
+ if (mongooseInstance) {
21
+ SingleUseToken = mongooseInstance.model('SingleUseToken', SingleUseTokenSchema)
22
+ } else {
23
+ SingleUseToken = mongoose.model('SingleUseToken', SingleUseTokenSchema)
24
+ }
25
+
26
+ return SingleUseToken
27
+ }
28
+
29
+ module.exports = { Model: model, Schema: SingleUseTokenSchema }
@@ -6,29 +6,37 @@
6
6
  let mongoose = require('mongoose')
7
7
  let StateEnum = require('@bluedot-innovation/enums').StateEnum
8
8
 
9
- let TestDevice = mongoose.model('TestDevice', new mongoose.Schema(
10
- {
11
- name: String,
12
- identifier: String,
13
- os: String,
14
- osVersion: String,
15
- hostToken: String,
16
- batteryToken: String,
17
- model: String,
18
- trackingDevice: {type: Boolean, default: false},
19
- creationTime: {type: Date, default: Date.now},
20
- lastUpdateTime: {type: Date, default: Date.now},
21
- serialNumber: String,
22
- mobileNumber: String,
23
- deviceType: String,
24
- state: {type: String, default: StateEnum.ACTIVE},
25
- comments: String,
26
- imei: String,
27
- udid: String
28
- },
29
- {
30
- collection: 'testDevice'
31
- })
32
- )
9
+ let TestDeviceSchema = new mongoose.Schema({
10
+ name: String,
11
+ identifier: String,
12
+ os: String,
13
+ osVersion: String,
14
+ hostToken: String,
15
+ batteryToken: String,
16
+ model: String,
17
+ trackingDevice: {type: Boolean, default: false},
18
+ creationTime: {type: Date, default: Date.now},
19
+ lastUpdateTime: {type: Date, default: Date.now},
20
+ serialNumber: String,
21
+ mobileNumber: String,
22
+ deviceType: String,
23
+ state: {type: String, default: StateEnum.ACTIVE},
24
+ comments: String,
25
+ imei: String,
26
+ udid: String
27
+ },
28
+ { collection: 'testDevice'})
33
29
 
34
- module.exports = TestDevice
30
+ // optional mongoose
31
+ let model = (mongooseInstance) => {
32
+ let TestDevice
33
+ if (mongooseInstance) {
34
+ TestDevice = mongooseInstance.model('TestDevice', TestDeviceSchema)
35
+ } else {
36
+ TestDevice = mongoose.model('TestDevice', TestDeviceSchema)
37
+ }
38
+
39
+ return TestDevice
40
+ }
41
+
42
+ module.exports = { Model: model, Schema: TestDeviceSchema }
@@ -5,18 +5,28 @@
5
5
  let mongoose = require('mongoose')
6
6
  let StateEnum = require('@bluedot-innovation/enums').StateEnum
7
7
 
8
- let TestDeviceCluster = mongoose.model('TestDeviceCluster', new mongoose.Schema(
8
+ let TestDeviceClusterSchema = new mongoose.Schema(
9
9
  {
10
10
  name: String,
11
11
  devices: [],
12
- 'creationTime': {type: Date, default: Date.now},
13
- 'lastUpdateTime': {type: Date, default: Date.now},
12
+ creationTime: {type: Date, default: Date.now},
13
+ lastUpdateTime: {type: Date, default: Date.now},
14
14
  comments: String,
15
15
  state: {type: String, default: StateEnum.ACTIVE}
16
16
  },
17
- {
18
- collection: 'testDeviceCluster'
19
- })
17
+ { collection: 'testDeviceCluster' }
20
18
  )
21
19
 
22
- module.exports = TestDeviceCluster
20
+ // optional mongoose
21
+ let model = (mongooseInstance) => {
22
+ let TestDeviceCluster
23
+ if (mongooseInstance) {
24
+ TestDeviceCluster = mongooseInstance.model('TestDeviceCluster', TestDeviceClusterSchema)
25
+ } else {
26
+ TestDeviceCluster = mongoose.model('TestDeviceCluster', TestDeviceClusterSchema)
27
+ }
28
+
29
+ return TestDeviceCluster
30
+ }
31
+
32
+ module.exports = { Model: model, Schema: TestDeviceClusterSchema }
@@ -5,7 +5,7 @@
5
5
  let mongoose = require('mongoose')
6
6
  let StateEnum = require('@bluedot-innovation/enums').StateEnum
7
7
 
8
- let TestInstance = mongoose.model('TestInstance', new mongoose.Schema(
8
+ let TestInstanceSchema = new mongoose.Schema(
9
9
  {
10
10
  name: String,
11
11
  scenarioId: String,
@@ -16,17 +16,27 @@ let TestInstance = mongoose.model('TestInstance', new mongoose.Schema(
16
16
  duration: Number,
17
17
  endPoint: String,
18
18
  trackedLocations: {type: Array, default: []},
19
- 'creationTime': {type: Date, default: Date.now},
20
- 'lastUpdateTime': {type: Date, default: Date.now},
19
+ creationTime: {type: Date, default: Date.now},
20
+ lastUpdateTime: {type: Date, default: Date.now},
21
21
  state: {type: String, default: StateEnum.ACTIVE},
22
22
  isValid: {type: Boolean, default: true},
23
23
  comments: String,
24
24
  isProduction: Boolean,
25
25
  sdkVersion: String
26
26
  },
27
- {
28
- collection: 'testInstance'
29
- })
27
+ { collection: 'testInstance' }
30
28
  )
31
29
 
32
- module.exports = TestInstance
30
+ // optional mongoose
31
+ let model = (mongooseInstance) => {
32
+ let TestInstance
33
+ if (mongooseInstance) {
34
+ TestInstance = mongooseInstance.model('TestInstance', TestInstanceSchema)
35
+ } else {
36
+ TestInstance = mongoose.model('TestInstance', TestInstanceSchema)
37
+ }
38
+
39
+ return TestInstance
40
+ }
41
+
42
+ module.exports = { Model: model, Schema: TestInstanceSchema }
@@ -6,22 +6,32 @@
6
6
  let mongoose = require('mongoose')
7
7
  let StateEnum = require('@bluedot-innovation/enums').StateEnum
8
8
 
9
- let TestScenario = mongoose.model('TestScenario', new mongoose.Schema(
9
+ let TestScenarioSchema = new mongoose.Schema(
10
10
  {
11
11
  name: String,
12
12
  apiKey: String,
13
13
  customerApiKey: String,
14
14
  email: String,
15
- 'creationTime': {type: Date, default: Date.now},
16
- 'lastUpdateTime': {type: Date, default: Date.now},
15
+ creationTime: {type: Date, default: Date.now},
16
+ lastUpdateTime: {type: Date, default: Date.now},
17
17
  state: {type: String, default: StateEnum.ACTIVE},
18
18
  numberZones: String,
19
19
  comments: String,
20
20
  environment: String
21
21
  },
22
- {
23
- collection: 'testScenario'
24
- })
22
+ { collection: 'testScenario' }
25
23
  )
26
24
 
27
- module.exports = TestScenario
25
+ // optional mongoose
26
+ let model = (mongooseInstance) => {
27
+ let TestScenario
28
+ if (mongooseInstance) {
29
+ TestScenario = mongooseInstance.model('TestScenario', TestScenarioSchema)
30
+ } else {
31
+ TestScenario = mongoose.model('TestScenario', TestScenarioSchema)
32
+ }
33
+
34
+ return TestScenario
35
+ }
36
+
37
+ module.exports = { Model: model, Schema: TestScenarioSchema }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "5.1.14",
3
+ "version": "5.1.15-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",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@bluedot-innovation/enums": "2.1.4",
32
- "@bluedot-innovation/mongoose-json-patch": "0.0.6",
32
+ "@bluedot-innovation/mongoose-json-patch": "0.0.7-alpha-1",
33
33
  "deep-equal": "^1.0.1",
34
34
  "fast-deep-equal": "^2.0.1",
35
35
  "lodash.clonedeep": "4.5.0",