@itleanchatbot/shared-models-js-postgres 2.7.0 → 2.7.2

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.0",
3
+ "version": "2.7.2",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -1,66 +1,66 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- await queryInterface.createTable('ApiPreRequests', {
6
- id: {
7
- allowNull: false,
8
- defaultValue: Sequelize.literal('uuid_generate_v4()'),
9
- primaryKey: true,
10
- type: Sequelize.UUID,
11
- },
12
- ApiId: {
13
- allowNull: true,
14
- defaultValue: null,
15
- type: Sequelize.UUID,
16
- references: {
17
- model: 'Apis',
18
- key: 'id',
19
- },
20
- onDelete: 'SET NULL',
21
- onUpdate: 'CASCADE',
22
- },
23
- ApiResourceId: {
24
- allowNull: true,
25
- defaultValue: null,
26
- type: Sequelize.UUID,
27
- references: {
28
- model: 'ApiResources',
29
- key: 'id',
30
- },
31
- onDelete: 'SET NULL',
32
- onUpdate: 'CASCADE',
33
- },
34
- PreApiResourceId: {
35
- allowNull: false,
36
- type: Sequelize.UUID,
37
- references: {
38
- model: 'ApiResources',
39
- key: 'id',
40
- },
41
- onDelete: 'SET NULL',
42
- onUpdate: 'CASCADE',
43
- },
44
- result: {
45
- allowNull: false,
46
- type: Sequelize.STRING,
47
- },
48
- delayForNewRequest: {
49
- allowNull: false,
50
- type: Sequelize.STRING,
51
- },
52
- createdAt: {
53
- allowNull: false,
54
- type: Sequelize.DATE,
55
- },
56
- updatedAt: {
57
- allowNull: false,
58
- type: Sequelize.DATE,
59
- },
60
- })
61
- },
62
-
63
- down: async (queryInterface) => {
64
- await queryInterface.dropTable('ApiPreRequests')
65
- }
66
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.createTable('ApiPreRequests', {
6
+ id: {
7
+ allowNull: false,
8
+ defaultValue: Sequelize.literal('uuid_generate_v4()'),
9
+ primaryKey: true,
10
+ type: Sequelize.UUID,
11
+ },
12
+ ApiId: {
13
+ allowNull: true,
14
+ defaultValue: null,
15
+ type: Sequelize.UUID,
16
+ references: {
17
+ model: 'Apis',
18
+ key: 'id',
19
+ },
20
+ onDelete: 'SET NULL',
21
+ onUpdate: 'CASCADE',
22
+ },
23
+ ApiResourceId: {
24
+ allowNull: true,
25
+ defaultValue: null,
26
+ type: Sequelize.UUID,
27
+ references: {
28
+ model: 'ApiResources',
29
+ key: 'id',
30
+ },
31
+ onDelete: 'SET NULL',
32
+ onUpdate: 'CASCADE',
33
+ },
34
+ PreApiResourceId: {
35
+ allowNull: false,
36
+ type: Sequelize.UUID,
37
+ references: {
38
+ model: 'ApiResources',
39
+ key: 'id',
40
+ },
41
+ onDelete: 'SET NULL',
42
+ onUpdate: 'CASCADE',
43
+ },
44
+ result: {
45
+ allowNull: false,
46
+ type: Sequelize.STRING,
47
+ },
48
+ delayForNewRequest: {
49
+ allowNull: false,
50
+ type: Sequelize.STRING,
51
+ },
52
+ createdAt: {
53
+ allowNull: false,
54
+ type: Sequelize.DATE,
55
+ },
56
+ updatedAt: {
57
+ allowNull: false,
58
+ type: Sequelize.DATE,
59
+ },
60
+ })
61
+ },
62
+
63
+ down: async (queryInterface) => {
64
+ await queryInterface.dropTable('ApiPreRequests')
65
+ }
66
+ };
@@ -0,0 +1,40 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.createTable('Publications', {
6
+ id: {
7
+ allowNull: false,
8
+ defaultValue: Sequelize.literal('uuid_generate_v4()'),
9
+ primaryKey: true,
10
+ type: Sequelize.UUID,
11
+ },
12
+ SkillId: {
13
+ allowNull: false,
14
+ type: Sequelize.UUID,
15
+ },
16
+ status: {
17
+ type: Sequelize.ENUM(['publishing', 'completed', 'failed']),
18
+ allowNull: false,
19
+ validate: {
20
+ notEmpty: false,
21
+ },
22
+ },
23
+ error: {
24
+ type: Sequelize.TEXT,
25
+ allowNull: true
26
+ },
27
+ createdAt: {
28
+ allowNull: false,
29
+ type: Sequelize.DATE,
30
+ },
31
+ updatedAt: {
32
+ allowNull: false,
33
+ type: Sequelize.DATE,
34
+ },
35
+ })
36
+ },
37
+ down: async (queryInterface) => {
38
+ await queryInterface.dropTable('Publications')
39
+ },
40
+ }
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.addColumn('Publications', 'description', {
6
+ type: Sequelize.STRING(255),
7
+ allowNull: true
8
+ })
9
+ },
10
+ down: async (queryInterface) => {
11
+ await queryInterface.removeColumn('Publications', 'description')
12
+ },
13
+ }
@@ -1,31 +1,31 @@
1
- exports.model = (sequelize, Sequelize) => {
2
- const OpenFAQs = sequelize.define('FaqQuestions', {
3
- name: {
4
- type: Sequelize.STRING(255),
5
- allowNull: false,
6
- validate: {
7
- notEmpty: true,
8
- },
9
- },
10
- OpenFAQId: {
11
- type: Sequelize.UUID,
12
- allowNull: false,
13
- references: {
14
- model: 'OpenFAQs',
15
- key: 'id',
16
- },
17
- onDelete: 'CASCADE',
18
- onUpdate: 'CASCADE',
19
- foreignKeyConstraint: true,
20
- validate: {
21
- notEmpty: true,
22
- },
23
- },
24
- })
25
-
26
- OpenFAQs.associate = (models) => {
27
- OpenFAQs.belongsTo(models.OpenFAQs)
28
- }
29
-
30
- return OpenFAQs
31
- }
1
+ exports.model = (sequelize, Sequelize) => {
2
+ const OpenFAQs = sequelize.define('FaqQuestions', {
3
+ name: {
4
+ type: Sequelize.STRING(255),
5
+ allowNull: false,
6
+ validate: {
7
+ notEmpty: true,
8
+ },
9
+ },
10
+ OpenFAQId: {
11
+ type: Sequelize.UUID,
12
+ allowNull: false,
13
+ references: {
14
+ model: 'OpenFAQs',
15
+ key: 'id',
16
+ },
17
+ onDelete: 'CASCADE',
18
+ onUpdate: 'CASCADE',
19
+ foreignKeyConstraint: true,
20
+ validate: {
21
+ notEmpty: true,
22
+ },
23
+ },
24
+ })
25
+
26
+ OpenFAQs.associate = (models) => {
27
+ OpenFAQs.belongsTo(models.OpenFAQs)
28
+ }
29
+
30
+ return OpenFAQs
31
+ }
@@ -50,6 +50,7 @@ exports.model = (sequelize, types) => {
50
50
  IbmProvider.associate = (models) => {
51
51
  IbmProvider.belongsTo(models.Intelligence)
52
52
  IbmProvider.hasMany(models.Skill)
53
+ IbmProvider.belongsTo(models.Enterprises)
53
54
  }
54
55
 
55
56
  return IbmProvider
@@ -27,6 +27,7 @@ exports.model = (sequelize, types) => {
27
27
  ItleanProvider.associate = (models) => {
28
28
  ItleanProvider.belongsTo(models.Intelligence)
29
29
  ItleanProvider.hasMany(models.Skill)
30
+ ItleanProvider.belongsTo(models.Enterprises)
30
31
  }
31
32
 
32
33
  return ItleanProvider
@@ -1,33 +1,33 @@
1
- exports.model = (sequelize, Sequelize) => {
2
- const OpenFAQs = sequelize.define('OpenFAQs', {
3
- name: {
4
- allowNull: false,
5
- type: Sequelize.TEXT,
6
- unique: false,
7
- },
8
- SkillId: {
9
- allowNull: false,
10
- type: Sequelize.UUID,
11
- references: {
12
- model: 'Skill',
13
- key: 'id',
14
- },
15
- onDelete: 'RESTRICT',
16
- onUpdate: 'CASCADE',
17
- },
18
- answers: {
19
- allowNull: false,
20
- type: Sequelize.JSON,
21
- validate: {
22
- notEmpty: true,
23
- },
24
- },
25
- })
26
-
27
- OpenFAQs.associate = (models) => {
28
- OpenFAQs.belongsTo(models.Skill)
29
- OpenFAQs.hasMany(models.FaqQuestions)
30
- }
31
-
32
- return OpenFAQs
33
- }
1
+ exports.model = (sequelize, Sequelize) => {
2
+ const OpenFAQs = sequelize.define('OpenFAQs', {
3
+ name: {
4
+ allowNull: false,
5
+ type: Sequelize.TEXT,
6
+ unique: false,
7
+ },
8
+ SkillId: {
9
+ allowNull: false,
10
+ type: Sequelize.UUID,
11
+ references: {
12
+ model: 'Skill',
13
+ key: 'id',
14
+ },
15
+ onDelete: 'RESTRICT',
16
+ onUpdate: 'CASCADE',
17
+ },
18
+ answers: {
19
+ allowNull: false,
20
+ type: Sequelize.JSON,
21
+ validate: {
22
+ notEmpty: true,
23
+ },
24
+ },
25
+ })
26
+
27
+ OpenFAQs.associate = (models) => {
28
+ OpenFAQs.belongsTo(models.Skill)
29
+ OpenFAQs.hasMany(models.FaqQuestions)
30
+ }
31
+
32
+ return OpenFAQs
33
+ }
@@ -0,0 +1,30 @@
1
+ exports.model = (sequelize, DataTypes) => {
2
+ const Publications = sequelize.define('Publications', {
3
+ SkillId: {
4
+ allowNull: false,
5
+ type: DataTypes.UUID,
6
+ },
7
+ status: {
8
+ type: DataTypes.ENUM(['publishing', 'completed', 'failed']),
9
+ allowNull: false,
10
+ validate: {
11
+ notEmpty: false,
12
+ },
13
+ },
14
+ error: {
15
+ type: DataTypes.TEXT,
16
+ allowNull: true
17
+ },
18
+ description: {
19
+ type: DataTypes.STRING(255),
20
+ allowNull: true
21
+ }
22
+ })
23
+
24
+ Publications.associate = models => {
25
+ Publications.belongsTo(models.Skill)
26
+ }
27
+
28
+ return Publications
29
+ }
30
+
@@ -1,41 +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
- }
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
+ }
@@ -1,43 +1,43 @@
1
- 'use strict'
2
-
3
- const skillId = '148d1182-9f28-4b30-8fc3-70b650672f73'
4
- const dialogNodeId = '9f023259-fd70-4724-9ab2-e11ce5555d77'
5
- const apiResourceId = '7756e862-61bc-41ee-b8ce-0b8a646c7de0'
6
- module.exports = {
7
- up: async (queryInterface, Sequelize) => {
8
- await queryInterface.bulkInsert('DialogNodes', [
9
- {
10
- id: dialogNodeId,
11
- contexts: '[]',
12
- name: 'Seeder Dialog Node',
13
- condition: 'test || test',
14
- step: '1',
15
- replayWait: true,
16
- type: 'node',
17
- isMultipleResponse: false,
18
- SkillId: skillId,
19
- JumpToDialogNodeId: null,
20
- JumpToSkillId: null,
21
- DialogNodeFolderId: null,
22
- createdAt: Sequelize.literal('now()'),
23
- updatedAt: Sequelize.literal('now()'),
24
- },
25
- ])
26
-
27
- await queryInterface.bulkInsert('DialogNodes_ApiResources', [
28
- {
29
- id: '395b05f4-e91f-445a-8be1-2ab199ea4824',
30
- DialogNodeId: dialogNodeId,
31
- ApiResourceId: apiResourceId,
32
- response: 'apiTest',
33
- createdAt: Sequelize.literal('now()'),
34
- updatedAt: Sequelize.literal('now()'),
35
- },
36
- ])
37
- },
38
-
39
- down: async (queryInterface) => {
40
- await queryInterface.bulkDelete('DialogNodes_ApiResources', null, {})
41
- await queryInterface.bulkDelete('DialogNodes', null, {})
42
- },
43
- }
1
+ 'use strict'
2
+
3
+ const skillId = '148d1182-9f28-4b30-8fc3-70b650672f73'
4
+ const dialogNodeId = '9f023259-fd70-4724-9ab2-e11ce5555d77'
5
+ const apiResourceId = '7756e862-61bc-41ee-b8ce-0b8a646c7de0'
6
+ module.exports = {
7
+ up: async (queryInterface, Sequelize) => {
8
+ await queryInterface.bulkInsert('DialogNodes', [
9
+ {
10
+ id: dialogNodeId,
11
+ contexts: '[]',
12
+ name: 'Seeder Dialog Node',
13
+ condition: 'test || test',
14
+ step: '1',
15
+ replayWait: true,
16
+ type: 'node',
17
+ isMultipleResponse: false,
18
+ SkillId: skillId,
19
+ JumpToDialogNodeId: null,
20
+ JumpToSkillId: null,
21
+ DialogNodeFolderId: null,
22
+ createdAt: Sequelize.literal('now()'),
23
+ updatedAt: Sequelize.literal('now()'),
24
+ },
25
+ ])
26
+
27
+ await queryInterface.bulkInsert('DialogNodes_ApiResources', [
28
+ {
29
+ id: '395b05f4-e91f-445a-8be1-2ab199ea4824',
30
+ DialogNodeId: dialogNodeId,
31
+ ApiResourceId: apiResourceId,
32
+ response: 'apiTest',
33
+ createdAt: Sequelize.literal('now()'),
34
+ updatedAt: Sequelize.literal('now()'),
35
+ },
36
+ ])
37
+ },
38
+
39
+ down: async (queryInterface) => {
40
+ await queryInterface.bulkDelete('DialogNodes_ApiResources', null, {})
41
+ await queryInterface.bulkDelete('DialogNodes', null, {})
42
+ },
43
+ }
@@ -1,201 +1,201 @@
1
- 'use strict'
2
-
3
- const apiId = 'f4f8f65e-565d-424e-9235-a17fcf019836'
4
-
5
- const apiBodyId = '45f353da-db0d-4928-8b59-5b649f9c0349'
6
-
7
- const apiResourceId = '618a7422-9d86-4ced-a0ca-8968474978d4'
8
-
9
- const dialogNodeId = '3cc49a93-e327-48b9-b001-b859fcc840fb'
10
-
11
- const SkillId = 'baee4f99-9966-4adb-a8de-596d5d4dd823'
12
-
13
- module.exports = {
14
- up: async (queryInterface, Sequelize) => {
15
- await queryInterface.bulkInsert('Apis', [
16
- {
17
- id: apiId,
18
- baseUrl: JSON.stringify([
19
- {
20
- url: 'https://leanbot.api.dev.itlean.com.br',
21
- type: 'apiKey',
22
- auth: {
23
- key: 'x-api-key',
24
- value: 'key',
25
- addTo: 'header',
26
- },
27
- environment: 'test',
28
- },
29
- ]),
30
- type: 'json',
31
- name: 'Api Seeder',
32
- description: 'Created by seeder to test pre-request',
33
- EnterpriseId: null,
34
- createdAt: Sequelize.literal('now()'),
35
- updatedAt: Sequelize.literal('now()'),
36
- },
37
- ])
38
-
39
- await queryInterface.bulkInsert('ApiResourcesBodies', [
40
- {
41
- id: apiBodyId,
42
- content: JSON.stringify({
43
- getContext: '$email',
44
- notInContext: '$notInContext',
45
- noReplace: 'noReplace',
46
- }),
47
- type: 'json',
48
- createdAt: Sequelize.literal('now()'),
49
- updatedAt: Sequelize.literal('now()'),
50
- },
51
- ])
52
-
53
- const resourcePathParamToReplaceKey = '$lang'
54
-
55
- await queryInterface.bulkInsert('ApiResources', [
56
- {
57
- id: apiResourceId,
58
- uri: `/api/framework/${resourcePathParamToReplaceKey}`,
59
- method: 'POST',
60
- name: 'Api Resource Seeder',
61
- description: 'Api Resource Seeder',
62
- ApiId: apiId,
63
- ApiResourcesBodyId: apiBodyId,
64
- createdAt: Sequelize.literal('now()'),
65
- updatedAt: Sequelize.literal('now()'),
66
- },
67
- ])
68
-
69
- await queryInterface.bulkInsert('ApiResourcesHeaders', [
70
- {
71
- id: 'a9f0008a-84bb-4fd4-a2ae-1b76f1093422',
72
- ApiResourceId: apiResourceId,
73
- value: 'en',
74
- type: 'Accept-Language',
75
- createdAt: Sequelize.literal('now()'),
76
- updatedAt: Sequelize.literal('now()'),
77
- },
78
- ])
79
-
80
- await queryInterface.bulkInsert('ApiResourcesPathParams', [
81
- {
82
- id: 'c264f31d-f8fc-4a1a-ad21-f29c66e24ab4',
83
- ApiResourceId: apiResourceId,
84
- key: resourcePathParamToReplaceKey,
85
- value: 'en',
86
- createdAt: Sequelize.literal('now()'),
87
- updatedAt: Sequelize.literal('now()'),
88
- },
89
- ])
90
-
91
- await queryInterface.bulkInsert('ApiResourcesQueryStringParams', [
92
- {
93
- id: '0ea48ff6-914b-46dc-9c61-5179fcddbc7c',
94
- ApiResourceId: apiResourceId,
95
- key: 'lang',
96
- type: 'string',
97
- value: 'en',
98
- createdAt: Sequelize.literal('now()'),
99
- updatedAt: Sequelize.literal('now()'),
100
- },
101
- ])
102
-
103
- await queryInterface.bulkInsert('ApiPreRequests', [
104
- {
105
- id: '2ab884ba-53f0-47d4-b4cb-376e5254ede2',
106
- ApiResourceId: apiResourceId,
107
- result: 'pre-result',
108
- delayForNewRequest: '600000',
109
- PreApiResourceId: '2ea2a347-bfdf-4209-b51f-7cacfa511299',
110
- createdAt: Sequelize.literal('now()'),
111
- updatedAt: Sequelize.literal('now()'),
112
- }
113
- ])
114
-
115
- const ibmIntelligenceId = await queryInterface.rawSelect(
116
- 'Intelligences',
117
- {
118
- where: {
119
- providerType: 'ibm',
120
- },
121
- },
122
- ['id']
123
- )
124
-
125
- const ibmProviderId = 'f5cc3829-e441-452f-9bea-70581bde9eff'
126
-
127
- await queryInterface.bulkInsert('Skills', [
128
- {
129
- id: SkillId,
130
- IntelligenceId: ibmIntelligenceId,
131
- AwsProviderId: null,
132
- ItleanProviderId: null,
133
- IbmProviderId: ibmProviderId,
134
- name: 'Skill Nlp Seed',
135
- description: 'skill created by seeders',
136
- lang: 'pt-br',
137
- externalIbmId: '1c6e2489-6675-4c08-aa89-fdac4bc50de3',
138
- createdAt: Sequelize.literal('now()'),
139
- updatedAt: Sequelize.literal('now()'),
140
- },
141
- ])
142
-
143
- await queryInterface.bulkInsert(
144
- 'DialogNodes',
145
- [
146
- {
147
- id: dialogNodeId,
148
- name: 'api_pre_request',
149
- SkillId,
150
- condition: 'true',
151
- contexts: '[]',
152
- step: 1,
153
- replayWait: true,
154
- type: 'node',
155
- isMultipleResponse: false,
156
- JumpToDialogNodeId: null,
157
- JumpToSkillId: null,
158
- DialogNodeFolderId: null,
159
- createdAt: Sequelize.literal('now()'),
160
- updatedAt: Sequelize.literal('now()'),
161
- },
162
- ],
163
- {}
164
- )
165
-
166
- await queryInterface.bulkInsert('DialogNodes_ApiResources', [
167
- {
168
- DialogNodeId: dialogNodeId,
169
- ApiResourceId: apiResourceId,
170
- response: 'api',
171
- environment: 'auth',
172
- createdAt: new Date(),
173
- updatedAt: new Date(),
174
- },
175
- ])
176
- },
177
-
178
- down: async (queryInterface) => {
179
- await queryInterface.bulkDelete('ApiResourcesQueryStringParams', [
180
- { ApiResourceId: apiResourceId },
181
- ])
182
- await queryInterface.bulkDelete('ApiResourcesPathParams', [
183
- { ApiResourceId: apiResourceId },
184
- ])
185
- await queryInterface.bulkDelete('ApiPreRequests', [
186
- { ApiResourceId: apiResourceId },
187
- ])
188
- await queryInterface.bulkDelete('ApiResourcesHeaders', [
189
- { ApiResourceId: apiResourceId },
190
- ])
191
- await queryInterface.bulkDelete('DialogNodes_ApiResources', [
192
- { ApiResourceId: apiResourceId },
193
- ])
194
- await queryInterface.bulkDelete('ApiResources', [{ id: apiResourceId }])
195
- await queryInterface.bulkDelete('ApiResourcesBodies', [{ id: apiBodyId }])
196
- await queryInterface.bulkDelete('Apis', [{ id: apiId }])
197
-
198
- await queryInterface.bulkDelete('Skills', [{ id: SkillId }])
199
- await queryInterface.bulkDelete('DialogNodes', [{ id: dialogNodeId }])
200
- },
201
- }
1
+ 'use strict'
2
+
3
+ const apiId = 'f4f8f65e-565d-424e-9235-a17fcf019836'
4
+
5
+ const apiBodyId = '45f353da-db0d-4928-8b59-5b649f9c0349'
6
+
7
+ const apiResourceId = '618a7422-9d86-4ced-a0ca-8968474978d4'
8
+
9
+ const dialogNodeId = '3cc49a93-e327-48b9-b001-b859fcc840fb'
10
+
11
+ const SkillId = 'baee4f99-9966-4adb-a8de-596d5d4dd823'
12
+
13
+ module.exports = {
14
+ up: async (queryInterface, Sequelize) => {
15
+ await queryInterface.bulkInsert('Apis', [
16
+ {
17
+ id: apiId,
18
+ baseUrl: JSON.stringify([
19
+ {
20
+ url: 'https://leanbot.api.dev.itlean.com.br',
21
+ type: 'apiKey',
22
+ auth: {
23
+ key: 'x-api-key',
24
+ value: 'key',
25
+ addTo: 'header',
26
+ },
27
+ environment: 'test',
28
+ },
29
+ ]),
30
+ type: 'json',
31
+ name: 'Api Seeder',
32
+ description: 'Created by seeder to test pre-request',
33
+ EnterpriseId: null,
34
+ createdAt: Sequelize.literal('now()'),
35
+ updatedAt: Sequelize.literal('now()'),
36
+ },
37
+ ])
38
+
39
+ await queryInterface.bulkInsert('ApiResourcesBodies', [
40
+ {
41
+ id: apiBodyId,
42
+ content: JSON.stringify({
43
+ getContext: '$email',
44
+ notInContext: '$notInContext',
45
+ noReplace: 'noReplace',
46
+ }),
47
+ type: 'json',
48
+ createdAt: Sequelize.literal('now()'),
49
+ updatedAt: Sequelize.literal('now()'),
50
+ },
51
+ ])
52
+
53
+ const resourcePathParamToReplaceKey = '$lang'
54
+
55
+ await queryInterface.bulkInsert('ApiResources', [
56
+ {
57
+ id: apiResourceId,
58
+ uri: `/api/framework/${resourcePathParamToReplaceKey}`,
59
+ method: 'POST',
60
+ name: 'Api Resource Seeder',
61
+ description: 'Api Resource Seeder',
62
+ ApiId: apiId,
63
+ ApiResourcesBodyId: apiBodyId,
64
+ createdAt: Sequelize.literal('now()'),
65
+ updatedAt: Sequelize.literal('now()'),
66
+ },
67
+ ])
68
+
69
+ await queryInterface.bulkInsert('ApiResourcesHeaders', [
70
+ {
71
+ id: 'a9f0008a-84bb-4fd4-a2ae-1b76f1093422',
72
+ ApiResourceId: apiResourceId,
73
+ value: 'en',
74
+ type: 'Accept-Language',
75
+ createdAt: Sequelize.literal('now()'),
76
+ updatedAt: Sequelize.literal('now()'),
77
+ },
78
+ ])
79
+
80
+ await queryInterface.bulkInsert('ApiResourcesPathParams', [
81
+ {
82
+ id: 'c264f31d-f8fc-4a1a-ad21-f29c66e24ab4',
83
+ ApiResourceId: apiResourceId,
84
+ key: resourcePathParamToReplaceKey,
85
+ value: 'en',
86
+ createdAt: Sequelize.literal('now()'),
87
+ updatedAt: Sequelize.literal('now()'),
88
+ },
89
+ ])
90
+
91
+ await queryInterface.bulkInsert('ApiResourcesQueryStringParams', [
92
+ {
93
+ id: '0ea48ff6-914b-46dc-9c61-5179fcddbc7c',
94
+ ApiResourceId: apiResourceId,
95
+ key: 'lang',
96
+ type: 'string',
97
+ value: 'en',
98
+ createdAt: Sequelize.literal('now()'),
99
+ updatedAt: Sequelize.literal('now()'),
100
+ },
101
+ ])
102
+
103
+ await queryInterface.bulkInsert('ApiPreRequests', [
104
+ {
105
+ id: '2ab884ba-53f0-47d4-b4cb-376e5254ede2',
106
+ ApiResourceId: apiResourceId,
107
+ result: 'pre-result',
108
+ delayForNewRequest: '600000',
109
+ PreApiResourceId: '2ea2a347-bfdf-4209-b51f-7cacfa511299',
110
+ createdAt: Sequelize.literal('now()'),
111
+ updatedAt: Sequelize.literal('now()'),
112
+ }
113
+ ])
114
+
115
+ const ibmIntelligenceId = await queryInterface.rawSelect(
116
+ 'Intelligences',
117
+ {
118
+ where: {
119
+ providerType: 'ibm',
120
+ },
121
+ },
122
+ ['id']
123
+ )
124
+
125
+ const ibmProviderId = 'f5cc3829-e441-452f-9bea-70581bde9eff'
126
+
127
+ await queryInterface.bulkInsert('Skills', [
128
+ {
129
+ id: SkillId,
130
+ IntelligenceId: ibmIntelligenceId,
131
+ AwsProviderId: null,
132
+ ItleanProviderId: null,
133
+ IbmProviderId: ibmProviderId,
134
+ name: 'Skill Nlp Seed',
135
+ description: 'skill created by seeders',
136
+ lang: 'pt-br',
137
+ externalIbmId: '1c6e2489-6675-4c08-aa89-fdac4bc50de3',
138
+ createdAt: Sequelize.literal('now()'),
139
+ updatedAt: Sequelize.literal('now()'),
140
+ },
141
+ ])
142
+
143
+ await queryInterface.bulkInsert(
144
+ 'DialogNodes',
145
+ [
146
+ {
147
+ id: dialogNodeId,
148
+ name: 'api_pre_request',
149
+ SkillId,
150
+ condition: 'true',
151
+ contexts: '[]',
152
+ step: 1,
153
+ replayWait: true,
154
+ type: 'node',
155
+ isMultipleResponse: false,
156
+ JumpToDialogNodeId: null,
157
+ JumpToSkillId: null,
158
+ DialogNodeFolderId: null,
159
+ createdAt: Sequelize.literal('now()'),
160
+ updatedAt: Sequelize.literal('now()'),
161
+ },
162
+ ],
163
+ {}
164
+ )
165
+
166
+ await queryInterface.bulkInsert('DialogNodes_ApiResources', [
167
+ {
168
+ DialogNodeId: dialogNodeId,
169
+ ApiResourceId: apiResourceId,
170
+ response: 'api',
171
+ environment: 'auth',
172
+ createdAt: new Date(),
173
+ updatedAt: new Date(),
174
+ },
175
+ ])
176
+ },
177
+
178
+ down: async (queryInterface) => {
179
+ await queryInterface.bulkDelete('ApiResourcesQueryStringParams', [
180
+ { ApiResourceId: apiResourceId },
181
+ ])
182
+ await queryInterface.bulkDelete('ApiResourcesPathParams', [
183
+ { ApiResourceId: apiResourceId },
184
+ ])
185
+ await queryInterface.bulkDelete('ApiPreRequests', [
186
+ { ApiResourceId: apiResourceId },
187
+ ])
188
+ await queryInterface.bulkDelete('ApiResourcesHeaders', [
189
+ { ApiResourceId: apiResourceId },
190
+ ])
191
+ await queryInterface.bulkDelete('DialogNodes_ApiResources', [
192
+ { ApiResourceId: apiResourceId },
193
+ ])
194
+ await queryInterface.bulkDelete('ApiResources', [{ id: apiResourceId }])
195
+ await queryInterface.bulkDelete('ApiResourcesBodies', [{ id: apiBodyId }])
196
+ await queryInterface.bulkDelete('Apis', [{ id: apiId }])
197
+
198
+ await queryInterface.bulkDelete('Skills', [{ id: SkillId }])
199
+ await queryInterface.bulkDelete('DialogNodes', [{ id: dialogNodeId }])
200
+ },
201
+ }