@itleanchatbot/shared-models-js-postgres 2.8.1 → 2.8.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itleanchatbot/shared-models-js-postgres",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -1,21 +1,21 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- /**
6
- * Add altering commands here.
7
- *
8
- * Example:
9
- * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
10
- */
11
- },
12
-
13
- down: async (queryInterface, Sequelize) => {
14
- /**
15
- * Add reverting commands here.
16
- *
17
- * Example:
18
- * await queryInterface.dropTable('users');
19
- */
20
- }
21
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ /**
6
+ * Add altering commands here.
7
+ *
8
+ * Example:
9
+ * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
10
+ */
11
+ },
12
+
13
+ down: async (queryInterface, Sequelize) => {
14
+ /**
15
+ * Add reverting commands here.
16
+ *
17
+ * Example:
18
+ * await queryInterface.dropTable('users');
19
+ */
20
+ }
21
+ };
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.createTable('WhatsappSessions', {
6
+ id: {
7
+ allowNull: false,
8
+ defaultValue: Sequelize.literal('uuid_generate_v4()'),
9
+ primaryKey: true,
10
+ type: Sequelize.UUID,
11
+ },
12
+ SessionId: {
13
+ allowNull: true,
14
+ type: Sequelize.UUID,
15
+ references: {
16
+ model: 'Sessions',
17
+ key: 'id',
18
+ },
19
+ onDelete: 'SET NULL',
20
+ onUpdate: 'CASCADE',
21
+ },
22
+ createdAt: {
23
+ allowNull: false,
24
+ type: Sequelize.DATE,
25
+ },
26
+ updatedAt: {
27
+ allowNull: false,
28
+ type: Sequelize.DATE,
29
+ },
30
+ })
31
+ },
32
+
33
+ down: async (queryInterface) => {
34
+ await queryInterface.dropTable('WhatsappSessions')
35
+ }
36
+ };
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.dropTable('WhatsappSessions')
6
+
7
+ await queryInterface.createTable('ConversationSessions', {
8
+ id: {
9
+ allowNull: false,
10
+ defaultValue: Sequelize.literal('uuid_generate_v4()'),
11
+ primaryKey: true,
12
+ type: Sequelize.UUID,
13
+ },
14
+ SessionId: {
15
+ allowNull: true,
16
+ type: Sequelize.UUID,
17
+ references: {
18
+ model: 'Sessions',
19
+ key: 'id',
20
+ },
21
+ onDelete: 'SET NULL',
22
+ onUpdate: 'CASCADE',
23
+ },
24
+ ClientId: {
25
+ type: Sequelize.UUID,
26
+ references: {
27
+ model: 'Clients',
28
+ key: 'id',
29
+ },
30
+ allowNull: false,
31
+ onDelete: 'SET NULL',
32
+ onUpdate: 'CASCADE',
33
+ },
34
+ createdAt: {
35
+ allowNull: false,
36
+ type: Sequelize.DATE,
37
+ },
38
+ updatedAt: {
39
+ allowNull: false,
40
+ type: Sequelize.DATE,
41
+ },
42
+ })
43
+ },
44
+
45
+ down: async (queryInterface, Sequelize) => {
46
+ await queryInterface.dropTable('ConversationSessions')
47
+
48
+ await queryInterface.createTable('WhatsappSessions', {
49
+ id: {
50
+ allowNull: false,
51
+ defaultValue: Sequelize.literal('uuid_generate_v4()'),
52
+ primaryKey: true,
53
+ type: Sequelize.UUID,
54
+ },
55
+ SessionId: {
56
+ allowNull: true,
57
+ type: Sequelize.UUID,
58
+ references: {
59
+ model: 'Sessions',
60
+ key: 'id',
61
+ },
62
+ onDelete: 'SET NULL',
63
+ onUpdate: 'CASCADE',
64
+ },
65
+ createdAt: {
66
+ allowNull: false,
67
+ type: Sequelize.DATE,
68
+ },
69
+ updatedAt: {
70
+ allowNull: false,
71
+ type: Sequelize.DATE,
72
+ },
73
+ })
74
+ }
75
+ };
@@ -0,0 +1,41 @@
1
+ exports.model = (sequelize, DataType) => {
2
+ const ConversationSessions = sequelize.define('ConversationSessions', {
3
+ ClientId: {
4
+ type: DataTypes.UUID,
5
+ references: {
6
+ model: 'Clients',
7
+ key: 'id',
8
+ },
9
+ allowNull: false,
10
+ onDelete: 'SET NULL',
11
+ onUpdate: 'CASCADE',
12
+ },
13
+ SessionId: {
14
+ type: DataType.UUID,
15
+ references: {
16
+ model: 'Sessions',
17
+ key: 'id',
18
+ },
19
+ allowNull: true,
20
+ onDelete: 'SET NULL',
21
+ },
22
+ ChannelTypeId: {
23
+ type: DataTypes.UUID,
24
+ allowNull: false,
25
+ references: {
26
+ model: 'ChannelTypes',
27
+ key: 'id',
28
+ },
29
+ onDelete: 'RESTRICT',
30
+ onUpdate: 'CASCADE',
31
+ },
32
+ })
33
+
34
+ ConversationSessions.associate = (models) => {
35
+ ConversationSessions.belongsTo(models.Sessions, { onDelete: 'SET NULL' })
36
+ ConversationSessions.belongsTo(models.Client, { onDelete: 'SET NULL' })
37
+ ConversationSessions.belongsTo(models.ChannelTypes)
38
+ }
39
+
40
+ return ConversationSessions
41
+ }
@@ -1,67 +1,67 @@
1
- 'use strict';
2
-
3
- const { CHANNEL_TYPES } = require('../models/channelTypes')
4
-
5
- const configurations = [
6
- {
7
- fieldName: 'botId',
8
- fieldType: 'string',
9
- fieldLabel: 'Nome do bot',
10
- },
11
- {
12
- fieldName: 'msAppId',
13
- fieldType: 'string',
14
- fieldLabel: 'App id',
15
- },
16
- {
17
- fieldName: 'msAppPassword',
18
- fieldType: 'string',
19
- fieldLabel: 'Senha do Teams',
20
- },
21
- {
22
- fieldName: 'tenantId',
23
- fieldType: 'string',
24
- fieldLabel: 'Tenant Id',
25
- },
26
- ]
27
-
28
- module.exports = {
29
- up: async (queryInterface) => {
30
- const ChannelTypeId = await queryInterface.rawSelect(
31
- 'ChannelTypes',
32
- {
33
- where: {
34
- channelName: CHANNEL_TYPES.MICROSOFT_TEAMS,
35
- },
36
- },
37
- ['id']
38
- )
39
-
40
- const channelConfigurations = configurations.map((channel) => {
41
- return {
42
- ...channel,
43
- ChannelTypeId,
44
- createdAt: new Date(),
45
- updatedAt: new Date()
46
- }
47
- })
48
-
49
- await queryInterface.bulkInsert(
50
- 'ChannelConfigurations',
51
- channelConfigurations
52
- )
53
- },
54
-
55
- down: async (queryInterface) => {
56
- const ChannelTypeId = await queryInterface.rawSelect(
57
- 'ChannelTypes',
58
- {
59
- where: {
60
- channelName: CHANNEL_TYPES.MICROSOFT_TEAMS,
61
- },
62
- },
63
- ['id']
64
- )
65
- return queryInterface.bulkDelete('ChannelConfigurations', [{ ChannelTypeId }], {})
66
- }
67
- };
1
+ 'use strict';
2
+
3
+ const { CHANNEL_TYPES } = require('../models/channelTypes')
4
+
5
+ const configurations = [
6
+ {
7
+ fieldName: 'botId',
8
+ fieldType: 'string',
9
+ fieldLabel: 'Nome do bot',
10
+ },
11
+ {
12
+ fieldName: 'msAppId',
13
+ fieldType: 'string',
14
+ fieldLabel: 'App id',
15
+ },
16
+ {
17
+ fieldName: 'msAppPassword',
18
+ fieldType: 'string',
19
+ fieldLabel: 'Senha do Teams',
20
+ },
21
+ {
22
+ fieldName: 'tenantId',
23
+ fieldType: 'string',
24
+ fieldLabel: 'Tenant Id',
25
+ },
26
+ ]
27
+
28
+ module.exports = {
29
+ up: async (queryInterface) => {
30
+ const ChannelTypeId = await queryInterface.rawSelect(
31
+ 'ChannelTypes',
32
+ {
33
+ where: {
34
+ channelName: CHANNEL_TYPES.MICROSOFT_TEAMS,
35
+ },
36
+ },
37
+ ['id']
38
+ )
39
+
40
+ const channelConfigurations = configurations.map((channel) => {
41
+ return {
42
+ ...channel,
43
+ ChannelTypeId,
44
+ createdAt: new Date(),
45
+ updatedAt: new Date()
46
+ }
47
+ })
48
+
49
+ await queryInterface.bulkInsert(
50
+ 'ChannelConfigurations',
51
+ channelConfigurations
52
+ )
53
+ },
54
+
55
+ down: async (queryInterface) => {
56
+ const ChannelTypeId = await queryInterface.rawSelect(
57
+ 'ChannelTypes',
58
+ {
59
+ where: {
60
+ channelName: CHANNEL_TYPES.MICROSOFT_TEAMS,
61
+ },
62
+ },
63
+ ['id']
64
+ )
65
+ return queryInterface.bulkDelete('ChannelConfigurations', [{ ChannelTypeId }], {})
66
+ }
67
+ };