@orchesty/connector-upgates 1.0.0 → 1.0.1

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.
Files changed (100) hide show
  1. package/dist/package.json +4 -1
  2. package/package.json +4 -1
  3. package/CHANGELOG.md +0 -7
  4. package/coverage/clover.xml +0 -302
  5. package/coverage/coverage-final.json +0 -11
  6. package/coverage/lcov-report/base.css +0 -224
  7. package/coverage/lcov-report/block-navigation.js +0 -87
  8. package/coverage/lcov-report/favicon.png +0 -0
  9. package/coverage/lcov-report/index.html +0 -161
  10. package/coverage/lcov-report/prettify.css +0 -1
  11. package/coverage/lcov-report/prettify.js +0 -2
  12. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  13. package/coverage/lcov-report/sorter.js +0 -210
  14. package/coverage/lcov-report/src/Batch/UpgatesCreateWebhooks.ts.html +0 -358
  15. package/coverage/lcov-report/src/Batch/UpgatesGetOrders.ts.html +0 -727
  16. package/coverage/lcov-report/src/Batch/UpgatesGetProducts.ts.html +0 -733
  17. package/coverage/lcov-report/src/Batch/index.html +0 -146
  18. package/coverage/lcov-report/src/Connector/UpgatesDeleteWebhooks.ts.html +0 -370
  19. package/coverage/lcov-report/src/Connector/UpgatesGetOrderStates.ts.html +0 -190
  20. package/coverage/lcov-report/src/Connector/UpgatesGetPayments.ts.html +0 -268
  21. package/coverage/lcov-report/src/Connector/UpgatesGetProductParameters.ts.html +0 -316
  22. package/coverage/lcov-report/src/Connector/UpgatesGetShipments.ts.html +0 -274
  23. package/coverage/lcov-report/src/Connector/index.html +0 -176
  24. package/coverage/lcov-report/src/UpgatesApplication.ts.html +0 -379
  25. package/coverage/lcov-report/src/index.html +0 -116
  26. package/coverage/lcov-report/test/dataProvider.ts.html +0 -223
  27. package/coverage/lcov-report/test/index.html +0 -116
  28. package/coverage/lcov.info +0 -485
  29. package/jest.config.js +0 -13
  30. package/src/Batch/UpgatesCreateWebhooks.ts +0 -91
  31. package/src/Batch/UpgatesGetOrders.ts +0 -214
  32. package/src/Batch/UpgatesGetProducts.ts +0 -216
  33. package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/input.json +0 -6
  34. package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/mock.json +0 -14
  35. package/src/Batch/__tests__/Data/UpgatesCreateWebhooks/output.json +0 -6
  36. package/src/Batch/__tests__/Data/UpgatesGetOrders/input.json +0 -6
  37. package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-input.json +0 -6
  38. package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-mock.json +0 -191
  39. package/src/Batch/__tests__/Data/UpgatesGetOrders/lastRun-output.json +0 -11
  40. package/src/Batch/__tests__/Data/UpgatesGetOrders/mock.json +0 -191
  41. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-input.json +0 -8
  42. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-mock.json +0 -191
  43. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumber-output.json +0 -11
  44. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-input.json +0 -8
  45. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-mock.json +0 -191
  46. package/src/Batch/__tests__/Data/UpgatesGetOrders/orderNumbers-output.json +0 -11
  47. package/src/Batch/__tests__/Data/UpgatesGetOrders/output.json +0 -11
  48. package/src/Batch/__tests__/Data/UpgatesGetProducts/input.json +0 -6
  49. package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-input.json +0 -6
  50. package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-mock.json +0 -147
  51. package/src/Batch/__tests__/Data/UpgatesGetProducts/lastRun-output.json +0 -11
  52. package/src/Batch/__tests__/Data/UpgatesGetProducts/mock.json +0 -146
  53. package/src/Batch/__tests__/Data/UpgatesGetProducts/output.json +0 -11
  54. package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-input.json +0 -8
  55. package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-mock.json +0 -146
  56. package/src/Batch/__tests__/Data/UpgatesGetProducts/productId-output.json +0 -11
  57. package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-input.json +0 -8
  58. package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-mock.json +0 -146
  59. package/src/Batch/__tests__/Data/UpgatesGetProducts/productIds-output.json +0 -11
  60. package/src/Batch/__tests__/UpgatesCreateWebhooks.ts +0 -17
  61. package/src/Batch/__tests__/UpgatesGetOrders.ts +0 -33
  62. package/src/Batch/__tests__/UpgatesGetProducts.ts +0 -33
  63. package/src/Connector/UpgatesDeleteWebhooks.ts +0 -95
  64. package/src/Connector/UpgatesGetOrderStates.ts +0 -35
  65. package/src/Connector/UpgatesGetPayments.ts +0 -61
  66. package/src/Connector/UpgatesGetProductParameters.ts +0 -77
  67. package/src/Connector/UpgatesGetShipments.ts +0 -63
  68. package/src/Connector/UpgatesUpdateOrder.ts +0 -73
  69. package/src/Connector/UpgatesUpdateStock.ts +0 -59
  70. package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/input.json +0 -6
  71. package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/mock.json +0 -16
  72. package/src/Connector/__tests__/Data/UpgatesDeleteWebhooks/output.json +0 -6
  73. package/src/Connector/__tests__/Data/UpgatesGetOrderStates/input.json +0 -6
  74. package/src/Connector/__tests__/Data/UpgatesGetOrderStates/mock.json +0 -14
  75. package/src/Connector/__tests__/Data/UpgatesGetOrderStates/output.json +0 -15
  76. package/src/Connector/__tests__/Data/UpgatesGetPayments/input.json +0 -6
  77. package/src/Connector/__tests__/Data/UpgatesGetPayments/mock.json +0 -42
  78. package/src/Connector/__tests__/Data/UpgatesGetPayments/output.json +0 -43
  79. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-input.json +0 -9
  80. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-mock.json +0 -108
  81. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/both-output.json +0 -109
  82. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/input.json +0 -8
  83. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/mock.json +0 -108
  84. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-input.json +0 -6
  85. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-mock.json +0 -5
  86. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/none-output.json +0 -6
  87. package/src/Connector/__tests__/Data/UpgatesGetProductParameters/output.json +0 -109
  88. package/src/Connector/__tests__/Data/UpgatesGetShipments/input.json +0 -6
  89. package/src/Connector/__tests__/Data/UpgatesGetShipments/mock.json +0 -58
  90. package/src/Connector/__tests__/Data/UpgatesGetShipments/output.json +0 -59
  91. package/src/Connector/__tests__/UpgatesDeleteWebhooks.ts +0 -61
  92. package/src/Connector/__tests__/UpgatesGetOrderStates.ts +0 -18
  93. package/src/Connector/__tests__/UpgatesGetPayments.ts +0 -18
  94. package/src/Connector/__tests__/UpgatesGetProductParameters.ts +0 -28
  95. package/src/Connector/__tests__/UpgatesGetShipments.ts +0 -18
  96. package/src/UpgatesApplication.ts +0 -98
  97. package/test/dataProvider.ts +0 -46
  98. package/tsconfig.json +0 -8
  99. package/tsconfig.prod.json +0 -13
  100. package/tsconfig.prod.tsbuildinfo +0 -1
@@ -1,485 +0,0 @@
1
- TN:
2
- SF:src/UpgatesApplication.ts
3
- FN:25,(anonymous_10)
4
- FN:29,(anonymous_11)
5
- FN:33,(anonymous_12)
6
- FN:37,(anonymous_13)
7
- FN:41,(anonymous_14)
8
- FN:66,(anonymous_15)
9
- FN:76,(anonymous_16)
10
- FN:85,(anonymous_17)
11
- FN:90,(anonymous_18)
12
- FN:94,(anonymous_19)
13
- FNF:10
14
- FNH:5
15
- FNDA:0,(anonymous_10)
16
- FNDA:23,(anonymous_11)
17
- FNDA:0,(anonymous_12)
18
- FNDA:0,(anonymous_13)
19
- FNDA:14,(anonymous_14)
20
- FNDA:14,(anonymous_15)
21
- FNDA:0,(anonymous_16)
22
- FNDA:0,(anonymous_17)
23
- FNDA:4,(anonymous_18)
24
- FNDA:1,(anonymous_19)
25
- DA:1,8
26
- DA:3,8
27
- DA:4,8
28
- DA:5,8
29
- DA:6,8
30
- DA:8,8
31
- DA:13,8
32
- DA:14,8
33
- DA:16,8
34
- DA:17,8
35
- DA:19,8
36
- DA:21,8
37
- DA:23,8
38
- DA:26,0
39
- DA:30,23
40
- DA:34,0
41
- DA:38,0
42
- DA:48,14
43
- DA:49,14
44
- DA:52,14
45
- DA:58,14
46
- DA:59,14
47
- DA:60,14
48
- DA:63,14
49
- DA:67,14
50
- DA:68,14
51
- DA:69,14
52
- DA:70,0
53
- DA:73,14
54
- DA:77,0
55
- DA:82,0
56
- DA:86,0
57
- DA:87,0
58
- DA:91,4
59
- DA:95,1
60
- LF:35
61
- LH:27
62
- BRDA:58,0,0,14
63
- BRDA:58,0,1,0
64
- BRDA:59,1,0,14
65
- BRDA:59,1,1,0
66
- BRDA:67,2,0,14
67
- BRDA:67,2,1,0
68
- BRDA:69,3,0,0
69
- BRDA:69,3,1,14
70
- BRDA:87,4,0,0
71
- BRDA:87,4,1,0
72
- BRDA:87,4,2,0
73
- BRDA:91,5,0,2
74
- BRDA:91,5,1,2
75
- BRF:13
76
- BRH:6
77
- end_of_record
78
- TN:
79
- SF:src/Batch/UpgatesCreateWebhooks.ts
80
- FN:16,(anonymous_1)
81
- FN:20,(anonymous_2)
82
- FN:76,(anonymous_3)
83
- FNF:3
84
- FNH:2
85
- FNDA:8,(anonymous_1)
86
- FNDA:1,(anonymous_2)
87
- FNDA:0,(anonymous_3)
88
- DA:1,8
89
- DA:2,8
90
- DA:3,8
91
- DA:4,8
92
- DA:5,8
93
- DA:7,8
94
- DA:8,8
95
- DA:11,8
96
- DA:12,8
97
- DA:14,8
98
- DA:17,8
99
- DA:21,1
100
- DA:23,1
101
- DA:24,1
102
- DA:26,1
103
- DA:27,0
104
- DA:28,0
105
- DA:30,0
106
- DA:31,0
107
- DA:48,0
108
- DA:49,0
109
- DA:50,0
110
- DA:52,0
111
- DA:61,0
112
- DA:62,0
113
- DA:66,0
114
- DA:67,0
115
- DA:69,0
116
- DA:73,1
117
- DA:77,0
118
- LF:30
119
- LH:16
120
- BRDA:26,0,0,0
121
- BRDA:26,0,1,1
122
- BRDA:61,1,0,0
123
- BRDA:61,1,1,0
124
- BRDA:69,2,0,0
125
- BRDA:69,2,1,0
126
- BRF:6
127
- BRH:1
128
- end_of_record
129
- TN:
130
- SF:src/Batch/UpgatesGetOrders.ts
131
- FN:13,(anonymous_1)
132
- FN:17,(anonymous_2)
133
- FNF:2
134
- FNH:2
135
- FNDA:8,(anonymous_1)
136
- FNDA:4,(anonymous_2)
137
- DA:1,8
138
- DA:2,8
139
- DA:4,8
140
- DA:5,8
141
- DA:7,8
142
- DA:9,8
143
- DA:11,8
144
- DA:14,8
145
- DA:18,4
146
- DA:19,4
147
- DA:21,4
148
- DA:22,4
149
- DA:26,4
150
- DA:27,1
151
- DA:28,3
152
- DA:29,1
153
- DA:31,2
154
- DA:33,2
155
- DA:34,2
156
- DA:35,1
157
- DA:39,4
158
- DA:40,4
159
- DA:46,4
160
- DA:48,4
161
- DA:49,0
162
- DA:50,4
163
- DA:51,3
164
- DA:52,3
165
- DA:53,3
166
- DA:55,4
167
- DA:57,4
168
- LF:31
169
- LH:30
170
- BRDA:26,0,0,1
171
- BRDA:26,0,1,3
172
- BRDA:28,1,0,1
173
- BRDA:28,1,1,2
174
- BRDA:33,2,0,2
175
- BRDA:33,2,1,2
176
- BRDA:34,3,0,1
177
- BRDA:34,3,1,1
178
- BRDA:48,4,0,0
179
- BRDA:48,4,1,4
180
- BRDA:50,5,0,3
181
- BRDA:50,5,1,1
182
- BRF:12
183
- BRH:11
184
- end_of_record
185
- TN:
186
- SF:src/Batch/UpgatesGetProducts.ts
187
- FN:13,(anonymous_1)
188
- FN:17,(anonymous_2)
189
- FN:198,(anonymous_3)
190
- FN:205,(anonymous_4)
191
- FNF:4
192
- FNH:4
193
- FNDA:8,(anonymous_1)
194
- FNDA:4,(anonymous_2)
195
- FNDA:8,(anonymous_3)
196
- FNDA:8,(anonymous_4)
197
- DA:1,8
198
- DA:2,8
199
- DA:4,8
200
- DA:7,8
201
- DA:9,8
202
- DA:11,8
203
- DA:14,8
204
- DA:18,4
205
- DA:19,4
206
- DA:21,4
207
- DA:22,4
208
- DA:24,4
209
- DA:26,4
210
- DA:27,1
211
- DA:28,3
212
- DA:29,1
213
- DA:31,2
214
- DA:33,2
215
- DA:34,2
216
- DA:35,1
217
- DA:38,4
218
- DA:40,4
219
- DA:41,4
220
- DA:43,4
221
- DA:44,0
222
- DA:45,4
223
- DA:46,3
224
- DA:47,3
225
- DA:48,3
226
- DA:51,4
227
- DA:53,4
228
- DA:198,8
229
- DA:199,8
230
- DA:200,8
231
- DA:201,8
232
- DA:202,8
233
- DA:205,8
234
- DA:206,8
235
- DA:207,8
236
- DA:208,8
237
- DA:209,8
238
- DA:210,8
239
- DA:211,8
240
- DA:212,8
241
- DA:213,8
242
- DA:214,8
243
- DA:215,8
244
- LF:47
245
- LH:46
246
- BRDA:26,0,0,1
247
- BRDA:26,0,1,3
248
- BRDA:28,1,0,1
249
- BRDA:28,1,1,2
250
- BRDA:33,2,0,2
251
- BRDA:33,2,1,2
252
- BRDA:34,3,0,1
253
- BRDA:34,3,1,1
254
- BRDA:43,4,0,0
255
- BRDA:43,4,1,4
256
- BRDA:45,5,0,3
257
- BRDA:45,5,1,1
258
- BRDA:198,6,0,8
259
- BRDA:198,6,1,8
260
- BRDA:205,7,0,8
261
- BRDA:205,7,1,8
262
- BRF:16
263
- BRH:15
264
- end_of_record
265
- TN:
266
- SF:src/Connector/UpgatesDeleteWebhooks.ts
267
- FN:16,(anonymous_1)
268
- FN:20,(anonymous_2)
269
- FN:33,(anonymous_3)
270
- FN:37,(anonymous_4)
271
- FN:51,(anonymous_5)
272
- FN:62,(anonymous_6)
273
- FN:64,(anonymous_7)
274
- FNF:7
275
- FNH:6
276
- FNDA:8,(anonymous_1)
277
- FNDA:1,(anonymous_2)
278
- FNDA:2,(anonymous_3)
279
- FNDA:1,(anonymous_4)
280
- FNDA:0,(anonymous_5)
281
- FNDA:1,(anonymous_6)
282
- FNDA:1,(anonymous_7)
283
- DA:2,8
284
- DA:4,8
285
- DA:5,8
286
- DA:6,8
287
- DA:8,8
288
- DA:11,8
289
- DA:12,8
290
- DA:14,8
291
- DA:17,8
292
- DA:21,1
293
- DA:24,1
294
- DA:25,1
295
- DA:28,0
296
- DA:31,1
297
- DA:32,1
298
- DA:33,2
299
- DA:35,1
300
- DA:37,1
301
- DA:38,1
302
- DA:41,1
303
- DA:42,1
304
- DA:48,1
305
- DA:49,1
306
- DA:50,0
307
- DA:52,0
308
- DA:53,0
309
- DA:56,0
310
- DA:59,1
311
- DA:60,1
312
- DA:61,1
313
- DA:63,1
314
- DA:64,1
315
- DA:66,1
316
- DA:67,1
317
- DA:70,0
318
- DA:71,0
319
- DA:72,0
320
- DA:76,1
321
- DA:77,0
322
- DA:81,1
323
- LF:40
324
- LH:31
325
- BRDA:41,0,0,1
326
- BRDA:41,0,1,0
327
- BRDA:41,1,0,1
328
- BRDA:41,1,1,1
329
- BRDA:49,2,0,0
330
- BRDA:49,2,1,1
331
- BRDA:49,3,0,1
332
- BRDA:49,3,1,0
333
- BRDA:66,4,0,1
334
- BRDA:66,4,1,0
335
- BRDA:76,5,0,0
336
- BRDA:76,5,1,1
337
- BRF:12
338
- BRH:7
339
- end_of_record
340
- TN:
341
- SF:src/Connector/UpgatesGetOrderStates.ts
342
- FN:10,(anonymous_1)
343
- FN:14,(anonymous_2)
344
- FNF:2
345
- FNH:2
346
- FNDA:8,(anonymous_1)
347
- FNDA:1,(anonymous_2)
348
- DA:1,8
349
- DA:2,8
350
- DA:5,8
351
- DA:6,8
352
- DA:8,8
353
- DA:11,8
354
- DA:15,1
355
- DA:21,1
356
- DA:23,1
357
- LF:9
358
- LH:9
359
- BRF:0
360
- BRH:0
361
- end_of_record
362
- TN:
363
- SF:src/Connector/UpgatesGetPayments.ts
364
- FN:10,(anonymous_1)
365
- FN:14,(anonymous_2)
366
- FNF:2
367
- FNH:2
368
- FNDA:8,(anonymous_1)
369
- FNDA:1,(anonymous_2)
370
- DA:1,8
371
- DA:2,8
372
- DA:5,8
373
- DA:6,8
374
- DA:8,8
375
- DA:11,8
376
- DA:15,1
377
- DA:21,1
378
- DA:23,1
379
- LF:9
380
- LH:9
381
- BRF:0
382
- BRH:0
383
- end_of_record
384
- TN:
385
- SF:src/Connector/UpgatesGetProductParameters.ts
386
- FN:10,(anonymous_1)
387
- FN:14,(anonymous_2)
388
- FNF:2
389
- FNH:2
390
- FNDA:8,(anonymous_1)
391
- FNDA:3,(anonymous_2)
392
- DA:1,8
393
- DA:2,8
394
- DA:5,8
395
- DA:6,8
396
- DA:8,8
397
- DA:11,8
398
- DA:15,3
399
- DA:17,3
400
- DA:18,1
401
- DA:21,2
402
- DA:22,2
403
- DA:23,1
404
- DA:26,2
405
- DA:27,2
406
- DA:28,2
407
- DA:31,2
408
- DA:37,2
409
- DA:39,2
410
- LF:18
411
- LH:18
412
- BRDA:17,0,0,1
413
- BRDA:17,0,1,2
414
- BRDA:17,1,0,3
415
- BRDA:17,1,1,2
416
- BRDA:22,2,0,1
417
- BRDA:22,2,1,1
418
- BRDA:26,3,0,2
419
- BRDA:26,3,1,0
420
- BRDA:27,4,0,1
421
- BRDA:27,4,1,1
422
- BRF:10
423
- BRH:9
424
- end_of_record
425
- TN:
426
- SF:src/Connector/UpgatesGetShipments.ts
427
- FN:10,(anonymous_1)
428
- FN:14,(anonymous_2)
429
- FNF:2
430
- FNH:2
431
- FNDA:8,(anonymous_1)
432
- FNDA:1,(anonymous_2)
433
- DA:1,8
434
- DA:2,8
435
- DA:5,8
436
- DA:6,8
437
- DA:8,8
438
- DA:11,8
439
- DA:15,1
440
- DA:21,1
441
- DA:23,1
442
- LF:9
443
- LH:9
444
- BRF:0
445
- BRH:0
446
- end_of_record
447
- TN:
448
- SF:test/dataProvider.ts
449
- FN:19,mock
450
- FN:34,init
451
- FNF:2
452
- FNH:2
453
- FNDA:15,mock
454
- FNDA:8,init
455
- DA:1,8
456
- DA:2,8
457
- DA:3,8
458
- DA:8,8
459
- DA:9,8
460
- DA:10,8
461
- DA:11,8
462
- DA:12,8
463
- DA:13,8
464
- DA:14,8
465
- DA:15,8
466
- DA:16,8
467
- DA:17,8
468
- DA:19,8
469
- DA:20,15
470
- DA:34,8
471
- DA:35,8
472
- DA:36,8
473
- DA:38,8
474
- DA:39,8
475
- DA:40,8
476
- DA:41,8
477
- DA:42,8
478
- DA:43,8
479
- DA:44,8
480
- DA:45,8
481
- LF:26
482
- LH:26
483
- BRF:0
484
- BRH:0
485
- end_of_record
package/jest.config.js DELETED
@@ -1,13 +0,0 @@
1
- const baseConfig = require('../../jest.config.js');
2
-
3
- module.exports = {
4
- ...baseConfig,
5
- roots: ["<rootDir>/src"],
6
- setupFiles: ["<rootDir>/../../.jest/testEnvs.ts"],
7
- setupFilesAfterEnv: ["<rootDir>/../../.jest/testLifecycle.ts"],
8
- globalSetup: "<rootDir>/../../.jest/globalSetup.ts",
9
- moduleNameMapper: {
10
- "^@orchesty/nodejs-connectors/test/(.*)$": "<rootDir>/../../test/$1",
11
- "^@orchesty/nodejs-connectors/lib/(.*)$": "<rootDir>/../../lib/$1",
12
- },
13
- }
@@ -1,91 +0,0 @@
1
- import { ApplicationInstall } from '@orchesty/nodejs-sdk/dist/lib/Application/Database/ApplicationInstall';
2
- import Webhook from '@orchesty/nodejs-sdk/dist/lib/Application/Database/Webhook';
3
- import ABatchNode from '@orchesty/nodejs-sdk/dist/lib/Batch/ABatchNode';
4
- import TopologyRunner from '@orchesty/nodejs-sdk/dist/lib/Topology/TopologyRunner';
5
- import { HttpMethods } from '@orchesty/nodejs-sdk/dist/lib/Transport/HttpMethods';
6
- import BatchProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/BatchProcessDto';
7
- import ResultCode from '@orchesty/nodejs-sdk/dist/lib/Utils/ResultCode';
8
- import crypto from 'crypto';
9
- import UpgatesApplication from '../UpgatesApplication';
10
-
11
- export const NAME = 'upgates-create-webhooks';
12
- const UPGATES_CREATE_WEBHOOK_ENDPOINT = 'api/v2/webhooks';
13
-
14
- export default class UpgatesCreateWebhooks extends ABatchNode {
15
-
16
- public getName(): string {
17
- return NAME;
18
- }
19
-
20
- public async processAction(dto: BatchProcessDto): Promise<BatchProcessDto> {
21
- const app = this.getApplication<UpgatesApplication>();
22
-
23
- const webhookIndex = Number(dto.getBatchCursor('0'));
24
- const webhooks = app.getWebhookSubscriptions();
25
-
26
- if (webhooks.length > 0) {
27
- const appInstall = await this.getApplicationInstallFromProcess(dto);
28
- const repo = this.getDbClient().getRepository(Webhook);
29
-
30
- const token = this.getRandomToken();
31
- const requestDto = app.getRequestDto(
32
- dto,
33
- appInstall,
34
- HttpMethods.POST,
35
- UPGATES_CREATE_WEBHOOK_ENDPOINT,
36
- JSON.stringify({
37
- name: webhooks[webhookIndex].getName(),
38
- event: webhooks[webhookIndex].getName(),
39
- url: TopologyRunner.getWebhookUrl(
40
- webhooks[webhookIndex].getTopology(),
41
- webhooks[webhookIndex].getNode(),
42
- token,
43
- ),
44
- }),
45
- );
46
-
47
- let res;
48
- try {
49
- res = await this.getSender().send<IResponse>(requestDto);
50
- const respBody = res.getJsonBody();
51
-
52
- await repo.insert(new Webhook()
53
- .setWebhookId(respBody.webhook.id.toString())
54
- .setUser(appInstall.getUser())
55
- .setNode(webhooks[webhookIndex].getNode())
56
- .setToken(token)
57
- .setApplication(app.getName())
58
- .setTopology(webhooks[webhookIndex].getTopology())
59
- .setName(webhooks[webhookIndex].getName()));
60
-
61
- if (webhooks.length - 1 > webhookIndex) {
62
- dto.setBatchCursor((webhookIndex + 1).toString());
63
- }
64
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
65
- } catch (e) {
66
- appInstall.setEnabled(false);
67
- await this.getDbClient().getRepository(ApplicationInstall).update(appInstall);
68
-
69
- dto.setStopProcess(ResultCode.STOP_AND_FAILED, res?.getBody() ?? 'Webhook could not be registered!');
70
- }
71
- }
72
-
73
- return dto;
74
- }
75
-
76
- private getRandomToken(): string {
77
- return crypto.randomBytes(64).toString('hex');
78
- }
79
-
80
- }
81
-
82
- export interface IResponse {
83
- webhook: {
84
- id: number;
85
- // eslint-disable-next-line @typescript-eslint/naming-convention
86
- active_yn: boolean;
87
- name: string;
88
- url: string;
89
- event: string;
90
- };
91
- }