@itleanchatbot/shared-models-js-postgres 2.8.7 → 2.8.9

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.7",
3
+ "version": "2.8.9",
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
+ };
@@ -1,20 +1,20 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- await queryInterface.addColumn('SystemUsers', 'isActive', {
6
- type: Sequelize.BOOLEAN,
7
- defaultValue: true,
8
- allowNull: false
9
- })
10
- await queryInterface.addColumn('SystemUsers', 'disabledAt', {
11
- type: Sequelize.DATE,
12
- allowNull: true
13
- })
14
- },
15
-
16
- down: async (queryInterface) => {
17
- await queryInterface.removeColumn('SystemUsers', 'isActive')
18
- await queryInterface.removeColumn('SystemUsers', 'disabledAt')
19
- }
20
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.addColumn('SystemUsers', 'isActive', {
6
+ type: Sequelize.BOOLEAN,
7
+ defaultValue: true,
8
+ allowNull: false
9
+ })
10
+ await queryInterface.addColumn('SystemUsers', 'disabledAt', {
11
+ type: Sequelize.DATE,
12
+ allowNull: true
13
+ })
14
+ },
15
+
16
+ down: async (queryInterface) => {
17
+ await queryInterface.removeColumn('SystemUsers', 'isActive')
18
+ await queryInterface.removeColumn('SystemUsers', 'disabledAt')
19
+ }
20
+ };
@@ -1,28 +1,28 @@
1
- 'use strict';
2
-
3
- const datesColumns = [
4
- 'processedAt', 'enqueuedAt', 'failedAt', 'readAt', 'sentAt', 'deliveredAt'
5
- ]
6
- module.exports = {
7
- async up (queryInterface, Sequelize) {
8
-
9
- await queryInterface.addColumn('BotIterables', 'brokerMessageStatus', {
10
- type: Sequelize.STRING(100),
11
- allowNull: true
12
- })
13
-
14
- for (const columnName of datesColumns) {
15
- await queryInterface.addColumn('BotIterables', columnName, {
16
- type: Sequelize.DATE,
17
- allowNull: true
18
- })
19
- }
20
- },
21
-
22
- async down (queryInterface) {
23
- await queryInterface.removeColumn('BotIterables', 'brokerStatus')
24
- for(const columnName of datesColumns) {
25
- await queryInterface.removeColumn('BotIterables', columnName)
26
- }
27
- }
28
- };
1
+ 'use strict';
2
+
3
+ const datesColumns = [
4
+ 'processedAt', 'enqueuedAt', 'failedAt', 'readAt', 'sentAt', 'deliveredAt'
5
+ ]
6
+ module.exports = {
7
+ async up (queryInterface, Sequelize) {
8
+
9
+ await queryInterface.addColumn('BotIterables', 'brokerMessageStatus', {
10
+ type: Sequelize.STRING(100),
11
+ allowNull: true
12
+ })
13
+
14
+ for (const columnName of datesColumns) {
15
+ await queryInterface.addColumn('BotIterables', columnName, {
16
+ type: Sequelize.DATE,
17
+ allowNull: true
18
+ })
19
+ }
20
+ },
21
+
22
+ async down (queryInterface) {
23
+ await queryInterface.removeColumn('BotIterables', 'brokerStatus')
24
+ for(const columnName of datesColumns) {
25
+ await queryInterface.removeColumn('BotIterables', columnName)
26
+ }
27
+ }
28
+ };
@@ -1,14 +1,14 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- async up (queryInterface, Sequelize) {
5
- await queryInterface.addColumn('Sessions', 'startedSessionAt', {
6
- type: Sequelize.DATE,
7
- allowNull: true
8
- })
9
- },
10
-
11
- async down (queryInterface) {
12
- await queryInterface.removeColumn('Sessions', 'startedSessionAt')
13
- }
14
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ async up (queryInterface, Sequelize) {
5
+ await queryInterface.addColumn('Sessions', 'startedSessionAt', {
6
+ type: Sequelize.DATE,
7
+ allowNull: true
8
+ })
9
+ },
10
+
11
+ async down (queryInterface) {
12
+ await queryInterface.removeColumn('Sessions', 'startedSessionAt')
13
+ }
14
+ };
@@ -1,15 +1,15 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- await queryInterface.addColumn('ConversationSessions', 'isHsm', {
6
- allowNull: false,
7
- defaultValue: false,
8
- type: Sequelize.BOOLEAN,
9
- })
10
- },
11
-
12
- down: async (queryInterface) => {
13
- await queryInterface.removeColumn('ConversationSessions', 'isHsm')
14
- }
15
- };
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.addColumn('ConversationSessions', 'isHsm', {
6
+ allowNull: false,
7
+ defaultValue: false,
8
+ type: Sequelize.BOOLEAN,
9
+ })
10
+ },
11
+
12
+ down: async (queryInterface) => {
13
+ await queryInterface.removeColumn('ConversationSessions', 'isHsm')
14
+ }
15
+ };
@@ -0,0 +1,161 @@
1
+ 'use strict'
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+
6
+ await queryInterface.sequelize.query(
7
+ `
8
+ CREATE OR REPLACE FUNCTION get_inactive_sessions(first_call boolean, records_per_page int, starter_page int, maximun int, current_page int DEFAULT 1)
9
+ RETURNS TABLE ("id" uuid) AS $$
10
+ declare r RECORD;
11
+ declare last_iterable "BotIterables"%ROWTYPE;
12
+ declare min_diff INT;
13
+ declare counter INT := 0;
14
+ BEGIN
15
+
16
+ IF ((records_per_page * current_page) > maximun) THEN
17
+ RETURN;
18
+ END IF;
19
+
20
+ IF (first_call) THEN
21
+ DROP TABLE IF EXISTS _tmp_get_inactive_sessions;
22
+ CREATE TEMPORARY TABLE _tmp_get_inactive_sessions (
23
+ "id" uuid
24
+ );
25
+ END IF;
26
+
27
+ FOR r IN (
28
+ select "Sessions"."id",
29
+ "InactivityTriggers"."min"
30
+ from "Sessions"
31
+ inner join "Clients"
32
+ on "Clients"."id" = "Sessions"."ClientId"
33
+ inner join "Channels"
34
+ on "Channels"."id" = "Sessions"."ChannelId"
35
+ inner join "ChannelTypes"
36
+ on "ChannelTypes"."id" = "Channels"."ChannelTypeId"
37
+ inner join "InactivityTriggers"
38
+ on "InactivityTriggers"."SkillId" = "Channels"."SkillId"
39
+ and "InactivityTriggers"."order" = "Sessions"."inactivityCounter"
40
+ where "Sessions"."status" = 'open'
41
+ and "Sessions"."tranship" = false
42
+ and "Channels"."deletedAt" is null
43
+ order by "Sessions"."createdAt"
44
+ limit records_per_page
45
+ offset ((starter_page - 1)*records_per_page)
46
+ ) LOOP
47
+
48
+ select * into last_iterable
49
+ from "BotIterables"
50
+ where "BotIterables"."SessionId" = r."id"
51
+ order by "BotIterables"."createdAt" DESC
52
+ limit 1;
53
+
54
+ min_diff := (
55
+ (SELECT DATE_PART('day', current_timestamp - last_iterable."createdAt") * 24 * 60) +
56
+ (SELECT DATE_PART('hour', current_timestamp - last_iterable."createdAt") * 60) +
57
+ (SELECT DATE_PART('minute', current_timestamp - last_iterable."createdAt"))
58
+ );
59
+
60
+ IF (last_iterable."action" = 'bot' and min_diff >= r."min") THEN
61
+
62
+ INSERT INTO _tmp_get_inactive_sessions ("id")
63
+ VALUES (r."id");
64
+
65
+ END IF;
66
+
67
+ counter := counter + 1;
68
+
69
+ END LOOP;
70
+
71
+ IF (counter = records_per_page) THEN
72
+ PERFORM get_inactive_sessions(false, records_per_page, starter_page + 1, maximun, current_page + 1);
73
+ END IF;
74
+
75
+ RETURN QUERY
76
+ SELECT * FROM _tmp_get_inactive_sessions;
77
+
78
+ END;
79
+ $$ LANGUAGE plpgsql;
80
+ `
81
+ )
82
+ },
83
+
84
+ down: async (queryInterface, Sequelize) => {
85
+ await queryInterface.sequelize.query(
86
+ `
87
+ CREATE OR REPLACE FUNCTION get_inactive_sessions(first_call boolean, records_per_page int, starter_page int, maximun int, current_page int DEFAULT 1)
88
+ RETURNS TABLE ("id" uuid) AS $$
89
+ declare r RECORD;
90
+ declare last_iterable "BotIterables"%ROWTYPE;
91
+ declare min_diff INT;
92
+ declare counter INT := 0;
93
+ BEGIN
94
+
95
+ IF ((records_per_page * current_page) > maximun) THEN
96
+ RETURN;
97
+ END IF;
98
+
99
+ IF (first_call) THEN
100
+ DROP TABLE IF EXISTS _tmp_get_inactive_sessions;
101
+ CREATE TEMPORARY TABLE _tmp_get_inactive_sessions (
102
+ "id" uuid
103
+ );
104
+ END IF;
105
+
106
+ FOR r IN (
107
+ select "Sessions"."id",
108
+ "InactivityTriggers"."min"
109
+ from "Sessions"
110
+ inner join "Clients"
111
+ on "Clients"."id" = "Sessions"."ClientId"
112
+ inner join "Channels"
113
+ on "Channels"."id" = "Sessions"."ChannelId"
114
+ inner join "ChannelTypes"
115
+ on "ChannelTypes"."id" = "Channels"."ChannelTypeId"
116
+ inner join "InactivityTriggers"
117
+ on "InactivityTriggers"."SkillId" = "Channels"."SkillId"
118
+ and "InactivityTriggers"."order" = "Sessions"."inactivityCounter"
119
+ where "Sessions"."status" = 'open'
120
+ and "Sessions"."tranship" = false
121
+ order by "Sessions"."createdAt"
122
+ limit records_per_page
123
+ offset ((starter_page - 1)*records_per_page)
124
+ ) LOOP
125
+
126
+ select * into last_iterable
127
+ from "BotIterables"
128
+ where "BotIterables"."SessionId" = r."id"
129
+ order by "BotIterables"."createdAt" DESC
130
+ limit 1;
131
+
132
+ min_diff := (
133
+ (SELECT DATE_PART('day', current_timestamp - last_iterable."createdAt") * 24 * 60) +
134
+ (SELECT DATE_PART('hour', current_timestamp - last_iterable."createdAt") * 60) +
135
+ (SELECT DATE_PART('minute', current_timestamp - last_iterable."createdAt"))
136
+ );
137
+
138
+ IF (last_iterable."action" = 'bot' and min_diff >= r."min") THEN
139
+
140
+ INSERT INTO _tmp_get_inactive_sessions ("id")
141
+ VALUES (r."id");
142
+
143
+ END IF;
144
+
145
+ counter := counter + 1;
146
+
147
+ END LOOP;
148
+
149
+ IF (counter = records_per_page) THEN
150
+ PERFORM get_inactive_sessions(false, records_per_page, starter_page + 1, maximun, current_page + 1);
151
+ END IF;
152
+
153
+ RETURN QUERY
154
+ SELECT * FROM _tmp_get_inactive_sessions;
155
+
156
+ END;
157
+ $$ LANGUAGE plpgsql;
158
+ `
159
+ )
160
+ },
161
+ }
@@ -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
+ }
@@ -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,98 @@
1
+
2
+
3
+ module.exports = {
4
+ up: async (queryInterface) => {
5
+ const departmentPermissionId = await queryInterface.rawSelect(
6
+ 'Permissions',
7
+ { where: { permissionCode: 'crud_departments' } },
8
+ ['id']
9
+ )
10
+
11
+ const subDepartmentPermissionId = await queryInterface.rawSelect(
12
+ 'Permissions',
13
+ { where: { permissionCode: 'crud_subDepartments' } },
14
+ ['id']
15
+ )
16
+
17
+ const linePermissionId = await queryInterface.rawSelect(
18
+ 'Permissions',
19
+ { where: { permissionCode: 'crud_lines' } },
20
+ ['id']
21
+ )
22
+
23
+ const branchPermissionId = await queryInterface.rawSelect(
24
+ 'Permissions',
25
+ { where: { permissionCode: 'crud_branches' } },
26
+ ['id']
27
+ )
28
+
29
+ const adminProfileId = await queryInterface.rawSelect(
30
+ 'Profiles',
31
+ { where: { name: 'Administrador' } },
32
+ ['id']
33
+ )
34
+
35
+
36
+ return queryInterface.bulkInsert('Profiles_Permissions', [
37
+ {
38
+ ProfileId: adminProfileId,
39
+ PermissionId: departmentPermissionId,
40
+ createdAt: new Date(),
41
+ updatedAt: new Date(),
42
+ },
43
+ {
44
+ ProfileId: adminProfileId,
45
+ PermissionId: subDepartmentPermissionId,
46
+ createdAt: new Date(),
47
+ updatedAt: new Date(),
48
+ },
49
+ {
50
+ ProfileId: adminProfileId,
51
+ PermissionId: linePermissionId,
52
+ createdAt: new Date(),
53
+ updatedAt: new Date(),
54
+ },
55
+ {
56
+ ProfileId: adminProfileId,
57
+ PermissionId: branchPermissionId,
58
+ createdAt: new Date(),
59
+ updatedAt: new Date(),
60
+ },
61
+ ])
62
+ },
63
+ down: async (queryInterface) => {
64
+ const departmentPermissionId = await queryInterface.rawSelect(
65
+ 'Permissions',
66
+ { where: { permissionCode: 'crud_departments' } },
67
+ ['id']
68
+ )
69
+
70
+ const subDepartmentPermissionId = await queryInterface.rawSelect(
71
+ 'Permissions',
72
+ { where: { permissionCode: 'crud_subDepartments' } },
73
+ ['id']
74
+ )
75
+
76
+ const linePermissionId = await queryInterface.rawSelect(
77
+ 'Permissions',
78
+ { where: { permissionCode: 'crud_lines' } },
79
+ ['id']
80
+ )
81
+
82
+ const branchPermissionId = await queryInterface.rawSelect(
83
+ 'Permissions',
84
+ { where: { permissionCode: 'crud_branches' } },
85
+ ['id']
86
+ )
87
+
88
+ const adminProfileId = await queryInterface.rawSelect(
89
+ 'Profiles',
90
+ { where: { name: 'Administrador' } },
91
+ ['id']
92
+ )
93
+ await queryInterface.bulkDelete('Profiles_Permissions', { ProfileId: adminProfileId, PermissionId: departmentPermissionId }, {})
94
+ await queryInterface.bulkDelete('Profiles_Permissions', { ProfileId: adminProfileId, PermissionId: subDepartmentPermissionId }, {})
95
+ await queryInterface.bulkDelete('Profiles_Permissions', { ProfileId: adminProfileId, PermissionId: linePermissionId }, {})
96
+ await queryInterface.bulkDelete('Profiles_Permissions', { ProfileId: adminProfileId, PermissionId: branchPermissionId }, {})
97
+ },
98
+ }
@@ -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
+ }