@itleanchatbot/shared-models-js-postgres 2.8.14 → 2.8.16

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.14",
3
+ "version": "2.8.16",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -1,16 +1,16 @@
1
- 'use strict';
2
- module.exports = {
3
- async up (queryInterface, Sequelize) {
4
- await queryInterface.changeColumn('TranshipConversations', 'mimetype', {
5
- type: Sequelize.STRING(255),
6
- allowNull: true,
7
- })
8
- },
9
-
10
- async down (queryInterface, Sequelize) {
11
- await queryInterface.changeColumn('TranshipConversations', 'mimetype', {
12
- type: Sequelize.STRING(50),
13
- allowNull: true,
14
- })
15
- }
16
- };
1
+ 'use strict';
2
+ module.exports = {
3
+ async up (queryInterface, Sequelize) {
4
+ await queryInterface.changeColumn('TranshipConversations', 'mimetype', {
5
+ type: Sequelize.STRING(255),
6
+ allowNull: true,
7
+ })
8
+ },
9
+
10
+ async down (queryInterface, Sequelize) {
11
+ await queryInterface.changeColumn('TranshipConversations', 'mimetype', {
12
+ type: Sequelize.STRING(50),
13
+ allowNull: true,
14
+ })
15
+ }
16
+ };
@@ -6,6 +6,7 @@ const CHANNEL_TYPES = {
6
6
  WHATSAPP_INTERAXA: 'whatsapp_interaxa',
7
7
  WHATSAPP_GUPSHUP: 'whatsapp_gupshup',
8
8
  MICROSOFT_TEAMS: 'microsoft_teams',
9
+ FACEBOOK_MESSENGER: 'facebook_messenger',
9
10
  }
10
11
 
11
12
  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.FACEBOOK_MESSENGER,
16
+ channelLabel: 'Facebook - Messenger',
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.FACEBOOK_MESSENGER }], {})
29
+ }
30
+ };
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ const { CHANNEL_TYPES } = require('../models/channelTypes')
4
+
5
+ const configurations = [
6
+ {
7
+ fieldName: 'appId',
8
+ fieldType: 'string',
9
+ fieldLabel: 'ID do aplicativo',
10
+ },
11
+ {
12
+ fieldName: 'pageId',
13
+ fieldType: 'string',
14
+ fieldLabel: 'ID da página',
15
+ },
16
+ {
17
+ fieldName: 'accessToken',
18
+ fieldType: 'string',
19
+ fieldLabel: 'Token de acesso',
20
+ },
21
+ ]
22
+
23
+ module.exports = {
24
+ up: async (queryInterface) => {
25
+ const ChannelTypeId = await queryInterface.rawSelect(
26
+ 'ChannelTypes',
27
+ {
28
+ where: {
29
+ channelName: CHANNEL_TYPES.FACEBOOK_MESSENGER,
30
+ },
31
+ },
32
+ ['id']
33
+ )
34
+
35
+ const channelConfigurations = configurations.map((channel) => {
36
+ return {
37
+ ...channel,
38
+ ChannelTypeId,
39
+ createdAt: new Date(),
40
+ updatedAt: new Date()
41
+ }
42
+ })
43
+
44
+ await queryInterface.bulkInsert(
45
+ 'ChannelConfigurations',
46
+ channelConfigurations
47
+ )
48
+ },
49
+
50
+ down: async (queryInterface) => {
51
+ const ChannelTypeId = await queryInterface.rawSelect(
52
+ 'ChannelTypes',
53
+ {
54
+ where: {
55
+ channelName: CHANNEL_TYPES.FACEBOOK_MESSENGER,
56
+ },
57
+ },
58
+ ['id']
59
+ )
60
+ return queryInterface.bulkDelete('ChannelConfigurations', [{ ChannelTypeId }], {})
61
+ }
62
+ };