@itleanchatbot/shared-models-js-postgres 1.1.27 → 1.1.29
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/index.js +3 -1
- package/package.json +1 -1
- package/src/client.js +24 -0
- package/src/dialogNodes.js +1 -6
- package/src/sessions.js +11 -0
package/index.js
CHANGED
|
@@ -43,6 +43,7 @@ const dialogNodes_apiResources = require('./src/dialogNodes_apiResources')
|
|
|
43
43
|
const response_DialogNodes = require('./src/response_DialogNodes')
|
|
44
44
|
const responses = require('./src/responses')
|
|
45
45
|
const responsesBoxes = require('./src/responsesBoxes')
|
|
46
|
+
const client = require('./src/client')
|
|
46
47
|
|
|
47
48
|
module.exports = {
|
|
48
49
|
attendances,
|
|
@@ -89,5 +90,6 @@ module.exports = {
|
|
|
89
90
|
dialogNodes_apiResources,
|
|
90
91
|
response_DialogNodes,
|
|
91
92
|
responses,
|
|
92
|
-
responsesBoxes
|
|
93
|
+
responsesBoxes,
|
|
94
|
+
client
|
|
93
95
|
}
|
package/package.json
CHANGED
package/src/client.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
exports.ClientModel = (sequelize, DataType) => {
|
|
2
|
+
const Client = sequelize.define('Client', {
|
|
3
|
+
clientId: {
|
|
4
|
+
type: DataType.STRING,
|
|
5
|
+
allowNull: true,
|
|
6
|
+
validate: {
|
|
7
|
+
notEmpty: false,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
serverId: {
|
|
11
|
+
type: DataType.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
validate: {
|
|
14
|
+
notEmpty: true,
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
Client.associate = (models) => {
|
|
20
|
+
Client.hasMany(models.Sessions)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return Client
|
|
24
|
+
}
|
package/src/dialogNodes.js
CHANGED
|
@@ -75,14 +75,9 @@ const DialogNodesModel = (sequelize, Sequelize) => {
|
|
|
75
75
|
defaultValue: true,
|
|
76
76
|
},
|
|
77
77
|
contexts: {
|
|
78
|
-
type: Sequelize.ARRAY(Sequelize.
|
|
78
|
+
type: Sequelize.ARRAY(Sequelize.JSON),
|
|
79
79
|
allowNull: false,
|
|
80
80
|
defaultValue: [],
|
|
81
|
-
set(value, field) {
|
|
82
|
-
this.setDataValue(field,
|
|
83
|
-
value.map(item => JSON.stringify(item))
|
|
84
|
-
)
|
|
85
|
-
},
|
|
86
81
|
get(field) {
|
|
87
82
|
const value = this.getDataValue(field)
|
|
88
83
|
if (value.length) {
|
package/src/sessions.js
CHANGED
|
@@ -10,6 +10,16 @@ exports.SessionsModel = (sequelize, DataTypes) => {
|
|
|
10
10
|
onDelete: 'RESTRICT',
|
|
11
11
|
onUpdate: 'CASCADE',
|
|
12
12
|
},
|
|
13
|
+
ClientId: {
|
|
14
|
+
type: DataTypes.UUID,
|
|
15
|
+
references: {
|
|
16
|
+
model: 'Clients',
|
|
17
|
+
key: 'id',
|
|
18
|
+
},
|
|
19
|
+
allowNull: false,
|
|
20
|
+
onDelete: 'CASCADE',
|
|
21
|
+
onUpdate: 'CASCADE',
|
|
22
|
+
},
|
|
13
23
|
context: {
|
|
14
24
|
type: DataTypes.JSON,
|
|
15
25
|
allowNull: true,
|
|
@@ -39,6 +49,7 @@ exports.SessionsModel = (sequelize, DataTypes) => {
|
|
|
39
49
|
Sessions.belongsTo(models.Channels)
|
|
40
50
|
Sessions.hasOne(models.Attendances)
|
|
41
51
|
Sessions.hasOne(models.SocketClients)
|
|
52
|
+
Sessions.belongsTo(models.Client)
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
return Sessions
|