@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.
@@ -0,0 +1,400 @@
1
+ 'use strict'
2
+
3
+ const skillId_01 = '3621cbe5-3f13-4b8f-8123-480f2d0b880e'
4
+
5
+ const clientId_01 = 'b030b2f0-3489-40d6-9809-34be3d5f042d'
6
+ const clientId_02 = '812ac754-144d-4983-b8d9-fd971c3654aa'
7
+ const clientId_03 = '0754ccaf-81b8-4c0c-9bad-772404538984'
8
+
9
+ const channelId_01 = 'cd8b7c8e-f868-4106-8c59-e0075277b2f9'
10
+ const channelId_02 = 'd1da9b34-5398-4501-96dc-d89af431ec03'
11
+ const channelId_03 = '4ab7eaf5-fca7-4bee-858d-ce7aa3016443'
12
+
13
+ const webchatServerId = '2f4e6490-e856-4de3-bf76-4e51df65a8a1'
14
+
15
+ const sessionId_01 = 'd8a0e493-8c5d-48f8-9bef-1117a464864c'
16
+ const sessionId_02 = '4b39781e-33f5-43e5-86fd-6ad5aa3b70b8'
17
+ const sessionId_03 = '1dba647d-1a9c-45ac-83b2-3cdb3a485733'
18
+
19
+ const chatSession = 'rze18pd9zpbf9bh2rbei9'
20
+
21
+ const interaxaMediaId = '49905304-aab7-404f-88d4-c97fcc846e5f'
22
+
23
+ const socketClientId_01 = '729c8833-4615-41fd-99fd-38e2dc82a750'
24
+
25
+ const socketId = 'p5m2smfxjttebo6f25qzp'
26
+
27
+ const clientId_04 = '4e86e41f-d0bc-4541-8ee4-e44a991c1622'
28
+ const clientId_05 = '4a1e478d-e023-471b-b22f-e2c168c1db5f'
29
+ const clientId_06 = '4d10d9df-f68d-45db-af62-3700fd2c49b3'
30
+
31
+ const channelId_04 = '333ba1b5-0471-41cf-b21f-b0244e1f3231'
32
+ const channelId_05 = '35c5f4cc-8823-49e7-97b1-8b033b373479'
33
+ const channelId_06 = '788cb8e1-3c9f-4c43-a60e-ab20fd0545a5'
34
+
35
+ const webchatServerId02 = '393343d1-c0a1-46ed-9946-df75c016d88a'
36
+
37
+ const sessionId_04 = '0568a7de-c91f-439b-b9c4-373de843a0b7'
38
+ const sessionId_05 = '74e4f546-110b-439e-8ac5-64a682254b94'
39
+ const sessionId_06 = '9d3ffd21-13db-43e6-9be8-97abf38176e9'
40
+
41
+ const chatSession02 = 'qt4klyphjygfcddu09buyf'
42
+
43
+ const interaxaMediaId02 = '5e307400-e4cc-4198-bb11-74ef93ca2497'
44
+
45
+ const socketClientId_02 = '667ba481-1005-4626-a4e2-949d0120f61a'
46
+
47
+ const socketId02 = 'le12mt1vtafvss5kttkfft'
48
+
49
+ module.exports = {
50
+ up: async (queryInterface, Sequelize) => {
51
+ const IntelligenceId = await queryInterface.rawSelect(
52
+ 'Intelligences',
53
+ {
54
+ where: {
55
+ providerType: 'itlean',
56
+ },
57
+ },
58
+ ['id']
59
+ )
60
+
61
+ const ItleanProviderId = await queryInterface.rawSelect(
62
+ 'ItleanProviders',
63
+ {},
64
+ ['id']
65
+ )
66
+
67
+ const webchatChannelTypeId = await queryInterface.rawSelect(
68
+ 'ChannelTypes',
69
+ { where: { channelName: 'webchat' } },
70
+ ['id']
71
+ )
72
+
73
+ const interaxaChannelTypeId = await queryInterface.rawSelect(
74
+ 'ChannelTypes',
75
+ { where: { channelName: 'whatsapp_interaxa' } },
76
+ ['id']
77
+ )
78
+
79
+ const gupshupChannelTypeId = await queryInterface.rawSelect(
80
+ 'ChannelTypes',
81
+ { where: { channelName: 'whatsapp_gupshup' } },
82
+ ['id']
83
+ )
84
+
85
+ await queryInterface.bulkInsert('Skills', [
86
+ {
87
+ id: skillId_01,
88
+ IntelligenceId,
89
+ AwsProviderId: null,
90
+ ItleanProviderId,
91
+ IbmProviderId: null,
92
+ name: 'Skill de Testes',
93
+ description: 'DialogNodes',
94
+ lang: 'pt-br',
95
+ createdAt: Sequelize.literal('now()'),
96
+ updatedAt: Sequelize.literal('now()'),
97
+ },
98
+ ])
99
+
100
+ await queryInterface.bulkInsert('Clients', [
101
+ {
102
+ // client mock webchat
103
+ id: clientId_01,
104
+ serverId: webchatServerId,
105
+ clientId: chatSession,
106
+ createdAt: Sequelize.literal('now()'),
107
+ updatedAt: Sequelize.literal('now()'),
108
+ },
109
+ {
110
+ // client mock interaxa
111
+ id: clientId_02,
112
+ serverId: interaxaMediaId,
113
+ clientId: '5511920210813',
114
+ createdAt: Sequelize.literal('now()'),
115
+ updatedAt: Sequelize.literal('now()'),
116
+ },
117
+ {
118
+ // client mock gupshup
119
+ id: clientId_03,
120
+ serverId: '5511920210815',
121
+ clientId: '5511920210815',
122
+ createdAt: Sequelize.literal('now()'),
123
+ updatedAt: Sequelize.literal('now()'),
124
+ },
125
+
126
+ /// flowoff
127
+ {
128
+ // client mock interaxa 02
129
+ id: clientId_04,
130
+ serverId: interaxaMediaId02,
131
+ clientId: '5511920210816',
132
+ createdAt: Sequelize.literal('now()'),
133
+ updatedAt: Sequelize.literal('now()'),
134
+ },
135
+ {
136
+ // client mock gupshup 02
137
+ id: clientId_05,
138
+ serverId: '5511920210817',
139
+ clientId: '5511920210817',
140
+ createdAt: Sequelize.literal('now()'),
141
+ updatedAt: Sequelize.literal('now()'),
142
+ },
143
+
144
+ {
145
+ // client mock webchat 02
146
+ id: clientId_06,
147
+ serverId: webchatServerId02,
148
+ clientId: chatSession02,
149
+ createdAt: Sequelize.literal('now()'),
150
+ updatedAt: Sequelize.literal('now()'),
151
+ },
152
+ ])
153
+
154
+ await queryInterface.bulkInsert('Channels', [
155
+ {
156
+ id: channelId_01,
157
+ ChannelTypeId: webchatChannelTypeId,
158
+ SkillId: skillId_01,
159
+ FileId: null,
160
+ name: '20210813144230',
161
+ configurations: JSON.stringify({
162
+ domainName: '20210814',
163
+ displayName: '20210814',
164
+ sendAttachments: false,
165
+ componentsColor: '#ffffff',
166
+ backgroundColor: '#000000',
167
+ fontColor: '#444444',
168
+ serverId: webchatServerId,
169
+ }),
170
+ createdAt: Sequelize.literal('now()'),
171
+ updatedAt: Sequelize.literal('now()'),
172
+ },
173
+ {
174
+ id: channelId_02,
175
+ ChannelTypeId: interaxaChannelTypeId,
176
+ SkillId: skillId_01,
177
+ FileId: null,
178
+ name: '20210813145030',
179
+ configurations: JSON.stringify({
180
+ phoneNumber: '5511920210814',
181
+ mediaId: interaxaMediaId,
182
+ namespace: 'test',
183
+ urlApi: 'https://test.interaxa.com/api',
184
+ apiUser: 'test',
185
+ apiPassword: 'test',
186
+ }),
187
+ createdAt: Sequelize.literal('now()'),
188
+ updatedAt: Sequelize.literal('now()'),
189
+ },
190
+ {
191
+ id: channelId_03,
192
+ ChannelTypeId: gupshupChannelTypeId,
193
+ SkillId: skillId_01,
194
+ FileId: null,
195
+ name: '20210813145530',
196
+ configurations: JSON.stringify({
197
+ source: '5511920210815',
198
+ wabaid: '5511920210815',
199
+ 'src.name': '5511920210815',
200
+ apikey: 'test',
201
+ urlApi: 'https://test.gupshup.com/api',
202
+ appId: '5511920210815',
203
+ }),
204
+ createdAt: Sequelize.literal('now()'),
205
+ updatedAt: Sequelize.literal('now()'),
206
+ },
207
+
208
+ //// flowOff
209
+ {
210
+ id: channelId_04,
211
+ ChannelTypeId: interaxaChannelTypeId,
212
+ SkillId: skillId_01,
213
+ FileId: null,
214
+ name: '20210813145531',
215
+ configurations: JSON.stringify({
216
+ phoneNumber: '5511920210816',
217
+ mediaId: interaxaMediaId02,
218
+ namespace: 'test',
219
+ urlApi: 'https://test.interaxa.com/api',
220
+ apiUser: 'test',
221
+ apiPassword: 'test',
222
+ }),
223
+ createdAt: Sequelize.literal('now()'),
224
+ updatedAt: Sequelize.literal('now()'),
225
+ },
226
+ {
227
+ id: channelId_05,
228
+ ChannelTypeId: gupshupChannelTypeId,
229
+ SkillId: skillId_01,
230
+ FileId: null,
231
+ name: '20210813145532',
232
+ configurations: JSON.stringify({
233
+ source: '5511920210817',
234
+ wabaid: '5511920210817',
235
+ 'src.name': '5511920210817',
236
+ apikey: 'test',
237
+ urlApi: 'https://test.gupshup.com/api',
238
+ appId: '5511920210817',
239
+ }),
240
+ createdAt: Sequelize.literal('now()'),
241
+ updatedAt: Sequelize.literal('now()'),
242
+ },
243
+ {
244
+ id: channelId_06,
245
+ ChannelTypeId: webchatChannelTypeId,
246
+ SkillId: skillId_01,
247
+ FileId: null,
248
+ name: '20210813145533',
249
+ configurations: JSON.stringify({
250
+ domainName: '20210815',
251
+ displayName: '20210815',
252
+ sendAttachments: false,
253
+ componentsColor: '#ffffff',
254
+ backgroundColor: '#000000',
255
+ fontColor: '#444444',
256
+ serverId: webchatServerId02,
257
+ }),
258
+ createdAt: Sequelize.literal('now()'),
259
+ updatedAt: Sequelize.literal('now()'),
260
+ },
261
+ ])
262
+
263
+ await queryInterface.bulkInsert('Sessions', [
264
+ {
265
+ id: sessionId_01,
266
+ ChannelId: channelId_01,
267
+ context: JSON.stringify({ 1: '1' }),
268
+ tranship: false,
269
+ status: 'open',
270
+ endOfSession: '2050-08-13 09:10:20.563-03',
271
+ ClientId: clientId_01,
272
+ createdAt: Sequelize.literal('now()'),
273
+ updatedAt: Sequelize.literal('now()'),
274
+ },
275
+ {
276
+ id: sessionId_02,
277
+ ChannelId: channelId_02,
278
+ context: JSON.stringify({ 1: '1' }),
279
+ tranship: false,
280
+ status: 'open',
281
+ endOfSession: '2050-08-13 09:10:20.563-03',
282
+ ClientId: clientId_02,
283
+ createdAt: Sequelize.literal('now()'),
284
+ updatedAt: Sequelize.literal('now()'),
285
+ },
286
+ {
287
+ id: sessionId_03,
288
+ ChannelId: channelId_03,
289
+ context: JSON.stringify({ 1: '1' }),
290
+ tranship: false,
291
+ status: 'open',
292
+ endOfSession: '2050-08-13 09:10:20.563-03',
293
+ ClientId: clientId_03,
294
+ createdAt: Sequelize.literal('now()'),
295
+ updatedAt: Sequelize.literal('now()'),
296
+ },
297
+
298
+ //// flowOff
299
+ {
300
+ // Interaxa
301
+ id: sessionId_04,
302
+ ChannelId: channelId_04,
303
+ context: JSON.stringify({ 1: '1' }),
304
+ tranship: false,
305
+ status: 'open',
306
+ endOfSession: '2050-08-13 09:10:20.563-03',
307
+ ClientId: clientId_04,
308
+ createdAt: Sequelize.literal('now()'),
309
+ updatedAt: Sequelize.literal('now()'),
310
+ },
311
+ {
312
+ // Gupshup
313
+ id: sessionId_05,
314
+ ChannelId: channelId_05,
315
+ context: JSON.stringify({ 1: '1' }),
316
+ tranship: false,
317
+ status: 'open',
318
+ endOfSession: '2050-08-13 09:10:20.563-03',
319
+ ClientId: clientId_05,
320
+ createdAt: Sequelize.literal('now()'),
321
+ updatedAt: Sequelize.literal('now()'),
322
+ },
323
+ {
324
+ // Webchat
325
+ id: sessionId_06,
326
+ ChannelId: channelId_06,
327
+ context: JSON.stringify({ 1: '1' }),
328
+ tranship: false,
329
+ status: 'open',
330
+ endOfSession: '2050-08-13 09:10:20.563-03',
331
+ ClientId: clientId_06,
332
+ createdAt: Sequelize.literal('now()'),
333
+ updatedAt: Sequelize.literal('now()'),
334
+ },
335
+ ])
336
+
337
+ await queryInterface.bulkInsert('SocketClients', [
338
+ {
339
+ id: socketClientId_01,
340
+ socketId,
341
+ serverId: webchatServerId,
342
+ chatSession,
343
+ protocol: 'webchat',
344
+ createdAt: new Date(),
345
+ updatedAt: new Date(),
346
+ },
347
+ {
348
+ id: socketClientId_02,
349
+ socketId: socketId02,
350
+ serverId: webchatServerId02,
351
+ chatSession: chatSession02,
352
+ protocol: 'webchat',
353
+ createdAt: new Date(),
354
+ updatedAt: new Date(),
355
+ },
356
+ ])
357
+ },
358
+ down: async (queryInterface, Sequelize) => {
359
+ await queryInterface.bulkDelete('SocketClients', [
360
+ { id: [socketClientId_01, socketClientId_02] },
361
+ ])
362
+ await queryInterface.bulkDelete('Sessions', [
363
+ {
364
+ id: [
365
+ sessionId_01,
366
+ sessionId_02,
367
+ sessionId_03,
368
+ sessionId_04,
369
+ sessionId_05,
370
+ sessionId_06,
371
+ ],
372
+ },
373
+ ])
374
+ await queryInterface.bulkDelete('Channels', [
375
+ {
376
+ id: [
377
+ channelId_01,
378
+ channelId_02,
379
+ channelId_03,
380
+ channelId_04,
381
+ channelId_05,
382
+ channelId_06,
383
+ ],
384
+ },
385
+ ])
386
+ await queryInterface.bulkDelete('Clients', [
387
+ {
388
+ id: [
389
+ clientId_01,
390
+ clientId_02,
391
+ clientId_03,
392
+ clientId_04,
393
+ clientId_05,
394
+ clientId_06,
395
+ ],
396
+ },
397
+ ])
398
+ await queryInterface.bulkDelete('Skills', [{ id: skillId_01 }])
399
+ },
400
+ }