@itleanchatbot/shared-models-js-postgres 2.7.7 → 2.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itleanchatbot/shared-models-js-postgres",
3
- "version": "2.7.7",
3
+ "version": "2.8.1",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -0,0 +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
+ };
@@ -5,6 +5,7 @@ const CHANNEL_TYPES = {
5
5
  FACEBOOK: 'facebook',
6
6
  WHATSAPP_INTERAXA: 'whatsapp_interaxa',
7
7
  WHATSAPP_GUPSHUP: 'whatsapp_gupshup',
8
+ MICROSOFT_TEAMS: 'microsoft_teams',
8
9
  }
9
10
 
10
11
  const ChannelTypesModel = (sequelize, DataTypes) => {
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+ const { CHANNEL_TYPES } = require('../models/channelTypes')
3
+ module.exports = {
4
+ up: async (queryInterface) => {
5
+ const responses = [
6
+ {"action":"text","display":"Texto"},
7
+ {"action":"image","display":"Imagem"},
8
+ {"action":"video","display":"Vídeo"},
9
+ {"action":"file","display":"Arquivo"},
10
+ {"action":"list","display":"Lista"},
11
+ {"action":"quick_replay","display":"Resposta rápida"}
12
+ ]
13
+
14
+ const microsoftTeams = {
15
+ channelName: CHANNEL_TYPES.MICROSOFT_TEAMS,
16
+ channelLabel: 'Microsoft - Teams',
17
+ responsesTypes: JSON.stringify(responses),
18
+ createdAt: new Date(),
19
+ updatedAt: new Date(),
20
+ }
21
+
22
+ return queryInterface.bulkInsert('ChannelTypes', [
23
+ microsoftTeams
24
+ ])
25
+ },
26
+
27
+ down: async (queryInterface) => {
28
+ return queryInterface.bulkDelete('ChannelTypes', [{ channelName: CHANNEL_TYPES.MICROSOFT_TEAMS }], {})
29
+ }
30
+ };
@@ -0,0 +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
+ };