@itleanchatbot/shared-models-js-postgres 2.2.1 → 2.4.0

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.2.1",
3
+ "version": "2.4.0",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -1,4 +1,3 @@
1
- const models = require('./../models')
2
1
  const profiles = [
3
2
  {
4
3
  name: 'Master',
@@ -54,10 +53,11 @@ module.exports = {
54
53
  ['id']
55
54
  )
56
55
 
57
- const per = await queryInterface.select(
58
- models.Permissions,
59
- 'Permissions',
60
- { where: { permissionCode: prof.permissions } }
56
+ const per = await queryInterface.sequelize.query(
57
+ `SELECT id FROM "Permissions" where "permissionCode" IN (${prof.permissions.map(item => `'${item}'`).join(',')})`,
58
+ {
59
+ type: queryInterface.sequelize.QueryTypes.SELECT
60
+ }
61
61
  )
62
62
 
63
63
  prof_per = prof_per.concat(
@@ -74,7 +74,7 @@ module.exports = {
74
74
 
75
75
  return queryInterface.bulkInsert('Profiles_Permissions', prof_per)
76
76
  },
77
- down: async (queryInterface, Sequelize) => {
77
+ down: async (queryInterface) => {
78
78
  return queryInterface.bulkDelete('Profiles_Permissions', null, {})
79
79
  },
80
80
  }
@@ -1,5 +1,3 @@
1
- const models = require('../models')
2
-
3
1
  const configurations = {
4
2
  webchat: [
5
3
  {
@@ -112,10 +110,12 @@ const configurations = {
112
110
  }
113
111
 
114
112
  module.exports = {
115
- up: async (queryInterface, Sequelize) => {
116
- const channelTypes = await queryInterface.select(
117
- models.ChannelTypes,
118
- 'ChannelTypes'
113
+ up: async (queryInterface) => {
114
+ const channelTypes = await queryInterface.sequelize.query(
115
+ `SELECT * FROM "ChannelTypes"`,
116
+ {
117
+ type: queryInterface.sequelize.QueryTypes.SELECT
118
+ }
119
119
  )
120
120
 
121
121
  let channelConfigurations = []
@@ -140,7 +140,7 @@ module.exports = {
140
140
  channelConfigurations
141
141
  )
142
142
  },
143
- down: async (queryInterface, Sequelize) => {
143
+ down: async (queryInterface) => {
144
144
  return queryInterface.bulkDelete('ChannelConfigurations', null, {})
145
145
  },
146
146
  }
@@ -1,5 +1,3 @@
1
- const models = require('../models')
2
-
3
1
  const configurations = {
4
2
  whatsapp_gupshup: [
5
3
  {
@@ -11,10 +9,12 @@ const configurations = {
11
9
  }
12
10
 
13
11
  module.exports = {
14
- up: async (queryInterface, Sequelize) => {
15
- const channelTypes = await queryInterface.select(
16
- models.ChannelTypes,
17
- 'ChannelTypes'
12
+ up: async (queryInterface) => {
13
+ const channelTypes = await queryInterface.sequelize.query(
14
+ `SELECT * FROM "ChannelTypes"`,
15
+ {
16
+ type: queryInterface.sequelize.QueryTypes.SELECT
17
+ }
18
18
  )
19
19
 
20
20
  let channelConfigurations = []
@@ -39,7 +39,7 @@ module.exports = {
39
39
  channelConfigurations
40
40
  )
41
41
  },
42
- down: async (queryInterface, Sequelize) => {
42
+ down: async (queryInterface) => {
43
43
  return queryInterface.bulkDelete('ChannelConfigurations', null, {})
44
44
  },
45
45
  }
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- up: async (queryInterface, Sequelize) => {
2
+ up: async (queryInterface) => {
3
3
  const [intention, entity, dialogNodes, apis] =
4
4
  await queryInterface.bulkInsert(
5
5
  'Permissions',
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- up: async (queryInterface, Sequelize) => {
2
+ up: async (queryInterface) => {
3
3
  const [skill, botIterables] = await queryInterface.bulkInsert(
4
4
  'Permissions',
5
5
  [
@@ -0,0 +1,37 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const ibmIntelligenceId = await queryInterface.rawSelect(
6
+ 'Intelligences',
7
+ {
8
+ where: {
9
+ providerType: 'ibm',
10
+ },
11
+ },
12
+ ['id']
13
+ )
14
+
15
+ if (ibmIntelligenceId) {
16
+ await queryInterface.bulkInsert('IbmProviders', [
17
+ {
18
+ id: '473da11f-79c5-49a9-bce6-2f7d8ec76daf',
19
+ IntelligenceId: ibmIntelligenceId,
20
+ url:
21
+ 'https://api.us-east.assistant.watson.cloud.ibm.com/instances/ba1e38a7-e378-4966-9b9a-8915956c8424',
22
+ token: 'qnAHwH_wZ0Mw7Fs1TMbWLKTEggSM21h0xeN6kmLANxcF',
23
+ active: true,
24
+ EnterpriseId: null,
25
+ apiVersion: 'v1',
26
+ version: '2018-09-20',
27
+ createdAt: Sequelize.literal('now()'),
28
+ updatedAt: Sequelize.literal('now()'),
29
+ },
30
+ ])
31
+ }
32
+ },
33
+
34
+ down: async (queryInterface, Sequelize) => {
35
+ await queryInterface.bulkDelete('IbmProviders', null, {})
36
+ },
37
+ }
@@ -0,0 +1,41 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const ibmIntelligenceId = await queryInterface.rawSelect(
6
+ 'Intelligences',
7
+ {
8
+ where: {
9
+ providerType: 'ibm',
10
+ },
11
+ },
12
+ ['id']
13
+ )
14
+
15
+ const ibmProviderId = '473da11f-79c5-49a9-bce6-2f7d8ec76daf'
16
+
17
+ if (ibmIntelligenceId) {
18
+ await queryInterface.bulkInsert('Skills', [
19
+ {
20
+ id: '148d1182-9f28-4b30-8fc3-70b650672f73',
21
+ IntelligenceId: ibmIntelligenceId,
22
+ AwsProviderId: null,
23
+ ItleanProviderId: null,
24
+ IbmProviderId: ibmProviderId,
25
+ name: 'Skill Seed',
26
+ description: 'skill created by seeders',
27
+ lang: 'pt-br',
28
+ externalIbmId: '1c6e2489-6675-4c08-aa89-fdac4bc50de3',
29
+ createdAt: Sequelize.literal('now()'),
30
+ updatedAt: Sequelize.literal('now()'),
31
+ },
32
+ ])
33
+ }
34
+ },
35
+
36
+ down: async (queryInterface) => {
37
+ await queryInterface.bulkDelete('Skills', null, {
38
+ id: '148d1182-9f28-4b30-8fc3-70b650672f73',
39
+ })
40
+ },
41
+ }
@@ -0,0 +1,62 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const channelTypeIdWebChat = await queryInterface.rawSelect(
6
+ 'ChannelTypes',
7
+ {
8
+ where: {
9
+ channelName: 'webchat',
10
+ },
11
+ },
12
+ ['id']
13
+ )
14
+
15
+ const channelTypeIdWhatsapp = await queryInterface.rawSelect(
16
+ 'ChannelTypes',
17
+ {
18
+ where: {
19
+ channelName: 'whatsapp_interaxa',
20
+ },
21
+ },
22
+ ['id']
23
+ )
24
+
25
+ const skillId = '148d1182-9f28-4b30-8fc3-70b650672f73'
26
+
27
+ await queryInterface.bulkInsert(
28
+ 'Channels',
29
+ [
30
+ {
31
+ name: 'webchat',
32
+ SkillId: skillId,
33
+ ChannelTypeId: channelTypeIdWebChat,
34
+ configurations: JSON.stringify({
35
+ serverId: 'd348e005-c280-43fa-a949-657804425d92',
36
+ }),
37
+ createdAt: Sequelize.literal('now()'),
38
+ updatedAt: Sequelize.literal('now()'),
39
+ },
40
+ {
41
+ name: 'whatsapp',
42
+ SkillId: skillId,
43
+ ChannelTypeId: channelTypeIdWhatsapp,
44
+ configurations: JSON.stringify({
45
+ serverId: 'd348e005-c280-43fa-a949-657804425d92',
46
+ urlApi: 'https://waap-api.h3rmes.com/api/v2',
47
+ apiUser: 'itlean',
48
+ apiPassword: '1tl3an',
49
+ }),
50
+ createdAt: Sequelize.literal('now()'),
51
+ updatedAt: Sequelize.literal('now()'),
52
+ },
53
+ ],
54
+ {}
55
+ )
56
+ },
57
+
58
+ down: async (queryInterface) => {
59
+ await queryInterface.bulkDelete('Sessions', null, {})
60
+ await queryInterface.bulkDelete('Channels', null, {})
61
+ },
62
+ }
@@ -1,26 +1,24 @@
1
1
  'use strict'
2
2
 
3
- const apiId = '7b62d509-9634-4c09-ab82-d753b12ebe9c'
4
-
5
- const apiBodyId = '5c55f6c5-b4b2-4c0c-94b7-e241ed534f45'
6
-
7
- const apiResourceId = '2ea2a347-bfdf-4209-b51f-7cacfa511299'
8
-
9
3
  module.exports = {
10
4
  up: async (queryInterface, Sequelize) => {
5
+ const skillId = '148d1182-9f28-4b30-8fc3-70b650672f73'
6
+
7
+ const apiId = '36a3e2b0-66d1-491e-aa5b-04bc45465a18'
8
+
11
9
  await queryInterface.bulkInsert('Apis', [
12
10
  {
13
11
  id: apiId,
14
12
  baseUrl: JSON.stringify([
15
13
  {
16
- url: 'https://leanbot.api.dev.itlean.com.br',
14
+ url: 'http://localhost:3000',
17
15
  type: 'apiKey',
16
+ environment: 'test',
18
17
  auth: {
19
18
  key: 'x-api-key',
20
19
  value: 'key',
21
20
  addTo: 'header',
22
21
  },
23
- environment: 'test',
24
22
  },
25
23
  ]),
26
24
  type: 'json',
@@ -32,6 +30,8 @@ module.exports = {
32
30
  },
33
31
  ])
34
32
 
33
+ const apiBodyId = 'e92ad0ec-3acf-4845-80af-d80753580e60'
34
+
35
35
  await queryInterface.bulkInsert('ApiResourcesBodies', [
36
36
  {
37
37
  id: apiBodyId,
@@ -46,6 +46,7 @@ module.exports = {
46
46
  },
47
47
  ])
48
48
 
49
+ const apiResourceId = '7756e862-61bc-41ee-b8ce-0b8a646c7de0'
49
50
  const resourcePathParamToReplaceKey = '$lang'
50
51
 
51
52
  await queryInterface.bulkInsert('ApiResources', [
@@ -64,7 +65,7 @@ module.exports = {
64
65
 
65
66
  await queryInterface.bulkInsert('ApiResourcesHeaders', [
66
67
  {
67
- id: '61b94d90-149c-4b82-b354-6b06c1e654c7',
68
+ id: '2b06c987-0a53-48f1-bd2c-45130f4aa761',
68
69
  ApiResourceId: apiResourceId,
69
70
  value: 'en',
70
71
  type: 'Accept-Language',
@@ -75,7 +76,7 @@ module.exports = {
75
76
 
76
77
  await queryInterface.bulkInsert('ApiResourcesPathParams', [
77
78
  {
78
- id: '715f4fd0-4920-4503-92ee-e27eb568bc1d',
79
+ id: '2b06c987-0a53-48f1-bd2c-45130f4aa761',
79
80
  ApiResourceId: apiResourceId,
80
81
  key: resourcePathParamToReplaceKey,
81
82
  value: 'en',
@@ -86,7 +87,7 @@ module.exports = {
86
87
 
87
88
  await queryInterface.bulkInsert('ApiResourcesQueryStringParams', [
88
89
  {
89
- id: '18de7724-a4d9-4f7b-88d3-06865f685659',
90
+ id: '2b06c987-0a53-48f1-bd2c-45130f4aa761',
90
91
  ApiResourceId: apiResourceId,
91
92
  key: 'lang',
92
93
  type: 'string',
@@ -97,18 +98,12 @@ module.exports = {
97
98
  ])
98
99
  },
99
100
 
100
- down: async (queryInterface) => {
101
- await queryInterface.bulkDelete('ApiResourcesQueryStringParams', [
102
- { ApiResourceId: apiResourceId },
103
- ])
104
- await queryInterface.bulkDelete('ApiResourcesPathParams', [
105
- { ApiResourceId: apiResourceId },
106
- ])
107
- await queryInterface.bulkDelete('ApiResourcesHeaders', [
108
- { ApiResourceId: apiResourceId },
109
- ])
110
- await queryInterface.bulkDelete('ApiResources', [{ id: apiResourceId }])
111
- await queryInterface.bulkDelete('ApiResourcesBodies', [{ id: apiBodyId }])
112
- await queryInterface.bulkDelete('Apis', [{ id: apiId }])
101
+ down: async (queryInterface, Sequelize) => {
102
+ await queryInterface.bulkDelete('ApiResourcesQueryStringParams', null, {})
103
+ await queryInterface.bulkDelete('ApiResourcesPathParams', null, {})
104
+ await queryInterface.bulkDelete('ApiResourcesHeaders', null, {})
105
+ await queryInterface.bulkDelete('ApiResources', null, {})
106
+ await queryInterface.bulkDelete('ApiResourcesBodies', null, {})
107
+ await queryInterface.bulkDelete('Apis', null, {})
113
108
  },
114
109
  }
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const skillId = '148d1182-9f28-4b30-8fc3-70b650672f73'
6
+
7
+ await queryInterface.bulkInsert('Entities', [
8
+ {
9
+ id: 'a7c39ff2-de36-45fe-851c-19bf3b068b37',
10
+ SkillId: skillId,
11
+ name: 'Seed Entity',
12
+ createdAt: Sequelize.literal('now()'),
13
+ updatedAt: Sequelize.literal('now()'),
14
+ },
15
+ ])
16
+ },
17
+
18
+ down: async (queryInterface, Sequelize) => {
19
+ await queryInterface.bulkDelete('Entities', null, {})
20
+ },
21
+ }
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const entityId = 'a7c39ff2-de36-45fe-851c-19bf3b068b37'
6
+
7
+ await queryInterface.bulkInsert('EntityValues', [
8
+ {
9
+ id: '34e44961-4994-405e-a121-834ed5848eac',
10
+ EntityId: entityId,
11
+ name: 'Seed Entity Value',
12
+ createdAt: Sequelize.literal('now()'),
13
+ updatedAt: Sequelize.literal('now()'),
14
+ },
15
+ ])
16
+ },
17
+
18
+ down: async (queryInterface, Sequelize) => {
19
+ await queryInterface.bulkDelete('EntityValues', null, {})
20
+ },
21
+ }
@@ -0,0 +1,22 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const skillId = '148d1182-9f28-4b30-8fc3-70b650672f73'
6
+
7
+ await queryInterface.bulkInsert('Intentions', [
8
+ {
9
+ id: '4b206b12-d4e2-4b65-80d7-a0e8233588a0',
10
+ SkillId: skillId,
11
+ name: 'Seed Intention',
12
+ description: 'Created by seeders',
13
+ createdAt: Sequelize.literal('now()'),
14
+ updatedAt: Sequelize.literal('now()'),
15
+ },
16
+ ])
17
+ },
18
+
19
+ down: async (queryInterface, Sequelize) => {
20
+ await queryInterface.bulkDelete('Intentions', null, {})
21
+ },
22
+ }
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const intentionId = '4b206b12-d4e2-4b65-80d7-a0e8233588a0'
6
+
7
+ await queryInterface.bulkInsert('IntentionValues', [
8
+ {
9
+ id: 'a2dd17df-0480-4616-88ac-41ead918a458',
10
+ IntentionId: intentionId,
11
+ name: 'Seed Intention Value',
12
+ createdAt: Sequelize.literal('now()'),
13
+ updatedAt: Sequelize.literal('now()'),
14
+ },
15
+ ])
16
+ },
17
+
18
+ down: async (queryInterface, Sequelize) => {
19
+ await queryInterface.bulkDelete('IntentionValues', null, {})
20
+ },
21
+ }
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const entityValueId = '34e44961-4994-405e-a121-834ed5848eac'
6
+ const entityId = 'a7c39ff2-de36-45fe-851c-19bf3b068b37'
7
+
8
+ await queryInterface.bulkInsert('Synonyms', [
9
+ {
10
+ id: 'a2dd17df-0480-4616-88ac-41ead918a458',
11
+ EntityValueId: entityValueId,
12
+ EntityId: entityId,
13
+ name: 'Seed Synonym',
14
+ type: 'synonyms',
15
+ createdAt: Sequelize.literal('now()'),
16
+ updatedAt: Sequelize.literal('now()'),
17
+ },
18
+ ])
19
+ },
20
+
21
+ down: async (queryInterface, Sequelize) => {
22
+ await queryInterface.bulkDelete('Synonyms', null, {})
23
+ },
24
+ }
@@ -0,0 +1,44 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ const skillId = '148d1182-9f28-4b30-8fc3-70b650672f73'
6
+ const dialogNodeId = '9f023259-fd70-4724-9ab2-e11ce5555d77'
7
+ const apiResourceId = '7756e862-61bc-41ee-b8ce-0b8a646c7de0'
8
+
9
+ await queryInterface.bulkInsert('DialogNodes', [
10
+ {
11
+ id: dialogNodeId,
12
+ contexts: '[]',
13
+ name: 'Seeder Dialog Node',
14
+ condition: 'test || test',
15
+ step: '1',
16
+ replayWait: true,
17
+ type: 'node',
18
+ isMultipleResponse: false,
19
+ SkillId: skillId,
20
+ JumpToDialogNodeId: null,
21
+ JumpToSkillId: null,
22
+ DialogNodeFolderId: null,
23
+ createdAt: Sequelize.literal('now()'),
24
+ updatedAt: Sequelize.literal('now()'),
25
+ },
26
+ ])
27
+
28
+ await queryInterface.bulkInsert('DialogNodes_ApiResources', [
29
+ {
30
+ id: '395b05f4-e91f-445a-8be1-2ab199ea4824',
31
+ DialogNodeId: dialogNodeId,
32
+ ApiResourceId: apiResourceId,
33
+ response: 'apiTest',
34
+ createdAt: Sequelize.literal('now()'),
35
+ updatedAt: Sequelize.literal('now()'),
36
+ },
37
+ ])
38
+ },
39
+
40
+ down: async (queryInterface, Sequelize) => {
41
+ await queryInterface.bulkDelete('DialogNodes_ApiResources', null, {})
42
+ await queryInterface.bulkDelete('DialogNodes', null, {})
43
+ },
44
+ }