@oneuptime/common 8.0.5185 → 8.0.5201

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 (114) hide show
  1. package/Models/DatabaseModels/Project.ts +24 -0
  2. package/Server/API/BillingAPI.ts +123 -0
  3. package/Server/API/SlackAPI.ts +10 -10
  4. package/Server/API/StatusPageAPI.ts +1 -1
  5. package/Server/Infrastructure/ClickhouseDatabase.ts +3 -1
  6. package/Server/Infrastructure/Postgres/SchemaMigrations/1758313975491-MigrationName.ts +17 -0
  7. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
  8. package/Server/Services/AnalyticsDatabaseService.ts +7 -9
  9. package/Server/Services/BillingService.ts +17 -0
  10. package/Server/Services/CallService.ts +5 -5
  11. package/Server/Services/DatabaseService.ts +5 -5
  12. package/Server/Services/MailService.ts +5 -5
  13. package/Server/Services/SmsService.ts +5 -5
  14. package/Server/Services/StatusPageCertificateService.ts +24 -12
  15. package/Server/Services/StatusPageDomainService.ts +9 -9
  16. package/Server/Services/WorkflowService.ts +5 -5
  17. package/Server/Types/Workflow/Components/API/Delete.ts +5 -5
  18. package/Server/Types/Workflow/Components/API/Get.ts +5 -5
  19. package/Server/Types/Workflow/Components/API/Patch.ts +5 -5
  20. package/Server/Types/Workflow/Components/API/Post.ts +5 -5
  21. package/Server/Types/Workflow/Components/API/Put.ts +5 -5
  22. package/Server/Types/Workflow/Components/MicrosoftTeams/SendMessageToChannel.ts +24 -21
  23. package/Server/Utils/CodeRepository/GitHub/GitHub.ts +22 -20
  24. package/Server/Utils/Errors.ts +1 -0
  25. package/Server/Utils/VM/VMAPI.ts +5 -5
  26. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +4 -1
  27. package/Server/Utils/Workspace/Slack/Slack.ts +84 -83
  28. package/Tests/Utils/API.test.ts +27 -22
  29. package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +16 -17
  30. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +18 -19
  31. package/UI/Components/LogsViewer/LogsViewer.tsx +9 -9
  32. package/UI/Components/ModelList/ModelList.tsx +5 -5
  33. package/UI/Components/Workflow/DocumentationViewer.tsx +5 -5
  34. package/UI/Utils/API/API.ts +1 -1
  35. package/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts +47 -43
  36. package/UI/Utils/ModelAPI/ModelAPI.ts +34 -35
  37. package/UI/Utils/User.ts +6 -6
  38. package/Utils/API.ts +127 -153
  39. package/build/dist/Models/DatabaseModels/Project.js +26 -0
  40. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  41. package/build/dist/Server/API/BillingAPI.js +76 -0
  42. package/build/dist/Server/API/BillingAPI.js.map +1 -0
  43. package/build/dist/Server/API/SlackAPI.js +12 -4
  44. package/build/dist/Server/API/SlackAPI.js.map +1 -1
  45. package/build/dist/Server/API/StatusPageAPI.js +1 -1
  46. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  47. package/build/dist/Server/Infrastructure/ClickhouseDatabase.js +3 -1
  48. package/build/dist/Server/Infrastructure/ClickhouseDatabase.js.map +1 -1
  49. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1758313975491-MigrationName.js +12 -0
  50. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1758313975491-MigrationName.js.map +1 -0
  51. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
  52. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  53. package/build/dist/Server/Services/AnalyticsDatabaseService.js +4 -2
  54. package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
  55. package/build/dist/Server/Services/BillingService.js +17 -0
  56. package/build/dist/Server/Services/BillingService.js.map +1 -1
  57. package/build/dist/Server/Services/CallService.js +5 -1
  58. package/build/dist/Server/Services/CallService.js.map +1 -1
  59. package/build/dist/Server/Services/DatabaseService.js +8 -4
  60. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  61. package/build/dist/Server/Services/MailService.js +5 -1
  62. package/build/dist/Server/Services/MailService.js.map +1 -1
  63. package/build/dist/Server/Services/SmsService.js +5 -1
  64. package/build/dist/Server/Services/SmsService.js.map +1 -1
  65. package/build/dist/Server/Services/StatusPageCertificateService.js +12 -3
  66. package/build/dist/Server/Services/StatusPageCertificateService.js.map +1 -1
  67. package/build/dist/Server/Services/StatusPageDomainService.js +18 -12
  68. package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
  69. package/build/dist/Server/Services/WorkflowService.js +5 -1
  70. package/build/dist/Server/Services/WorkflowService.js.map +1 -1
  71. package/build/dist/Server/Types/Workflow/Components/API/Delete.js +5 -1
  72. package/build/dist/Server/Types/Workflow/Components/API/Delete.js.map +1 -1
  73. package/build/dist/Server/Types/Workflow/Components/API/Get.js +5 -1
  74. package/build/dist/Server/Types/Workflow/Components/API/Get.js.map +1 -1
  75. package/build/dist/Server/Types/Workflow/Components/API/Patch.js +5 -1
  76. package/build/dist/Server/Types/Workflow/Components/API/Patch.js.map +1 -1
  77. package/build/dist/Server/Types/Workflow/Components/API/Post.js +5 -1
  78. package/build/dist/Server/Types/Workflow/Components/API/Post.js.map +1 -1
  79. package/build/dist/Server/Types/Workflow/Components/API/Put.js +5 -1
  80. package/build/dist/Server/Types/Workflow/Components/API/Put.js.map +1 -1
  81. package/build/dist/Server/Types/Workflow/Components/MicrosoftTeams/SendMessageToChannel.js +24 -21
  82. package/build/dist/Server/Types/Workflow/Components/MicrosoftTeams/SendMessageToChannel.js.map +1 -1
  83. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js +29 -17
  84. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js.map +1 -1
  85. package/build/dist/Server/Utils/Errors.js +1 -0
  86. package/build/dist/Server/Utils/Errors.js.map +1 -1
  87. package/build/dist/Server/Utils/VM/VMAPI.js +5 -1
  88. package/build/dist/Server/Utils/VM/VMAPI.js.map +1 -1
  89. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +4 -1
  90. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  91. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +170 -106
  92. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  93. package/build/dist/Tests/Utils/API.test.js +26 -5
  94. package/build/dist/Tests/Utils/API.test.js.map +1 -1
  95. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +15 -16
  96. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
  97. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +15 -16
  98. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
  99. package/build/dist/UI/Components/LogsViewer/LogsViewer.js +9 -5
  100. package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
  101. package/build/dist/UI/Components/ModelList/ModelList.js +5 -1
  102. package/build/dist/UI/Components/ModelList/ModelList.js.map +1 -1
  103. package/build/dist/UI/Components/Workflow/DocumentationViewer.js +7 -3
  104. package/build/dist/UI/Components/Workflow/DocumentationViewer.js.map +1 -1
  105. package/build/dist/UI/Utils/API/API.js.map +1 -1
  106. package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js +60 -25
  107. package/build/dist/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.js.map +1 -1
  108. package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +52 -22
  109. package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
  110. package/build/dist/UI/Utils/User.js +3 -1
  111. package/build/dist/UI/Utils/User.js.map +1 -1
  112. package/build/dist/Utils/API.js +60 -27
  113. package/build/dist/Utils/API.js.map +1 -1
  114. package/package.json +1 -1
@@ -74,29 +74,32 @@ export default class SendMessageToChannel extends ComponentCode {
74
74
 
75
75
  try {
76
76
  // https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/incoming-webhook/nodejs/api/server/index.js#L28
77
- apiResult = await API.post(args["webhook-url"] as URL, {
78
- type: "message",
79
- attachments: [
80
- {
81
- contentType: "application/vnd.microsoft.card.adaptive",
82
- contentUrl: null,
83
- content: {
84
- $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
85
- msteams: {
86
- width: "Full",
87
- },
88
- type: "AdaptiveCard",
89
- version: "1.2",
90
- body: [
91
- {
92
- type: "TextBlock",
93
- wrap: "true",
94
- text: `${args["text"]}`,
77
+ apiResult = await API.post({
78
+ url: args["webhook-url"] as URL,
79
+ data: {
80
+ type: "message",
81
+ attachments: [
82
+ {
83
+ contentType: "application/vnd.microsoft.card.adaptive",
84
+ contentUrl: null,
85
+ content: {
86
+ $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
87
+ msteams: {
88
+ width: "Full",
95
89
  },
96
- ],
90
+ type: "AdaptiveCard",
91
+ version: "1.2",
92
+ body: [
93
+ {
94
+ type: "TextBlock",
95
+ wrap: "true",
96
+ text: `${args["text"]}`,
97
+ },
98
+ ],
99
+ },
97
100
  },
98
- },
99
- ],
101
+ ],
102
+ },
100
103
  });
101
104
 
102
105
  if (apiResult instanceof HTTPErrorResponse) {
@@ -61,15 +61,15 @@ export default class GitHubUtil extends HostedCodeRepository {
61
61
  `https://api.github.com/repos/${data.organizationName}/${data.repositoryName}/pulls/${data.pullRequestId}`,
62
62
  );
63
63
 
64
- const result: HTTPErrorResponse | HTTPResponse<JSONObject> = await API.get(
65
- url,
66
- {},
67
- {
64
+ const result: HTTPErrorResponse | HTTPResponse<JSONObject> = await API.get({
65
+ url: url,
66
+ data: {},
67
+ headers: {
68
68
  Authorization: `Bearer ${gitHubToken}`,
69
69
  Accept: "application/vnd.github+json",
70
70
  "X-GitHub-Api-Version": "2022-11-28",
71
71
  },
72
- );
72
+ });
73
73
 
74
74
  if (result instanceof HTTPErrorResponse) {
75
75
  throw result;
@@ -95,15 +95,15 @@ export default class GitHubUtil extends HostedCodeRepository {
95
95
  `https://api.github.com/repos/${data.organizationName}/${data.repositoryName}/pulls?base=${data.baseBranchName}&state=${data.pullRequestState}&per_page=100&page=${data.page}`,
96
96
  );
97
97
 
98
- const result: HTTPErrorResponse | HTTPResponse<JSONArray> = await API.get(
99
- url,
100
- {},
101
- {
98
+ const result: HTTPErrorResponse | HTTPResponse<JSONArray> = await API.get({
99
+ url: url,
100
+ data: {},
101
+ headers: {
102
102
  Authorization: `Bearer ${gitHubToken}`,
103
103
  Accept: "application/vnd.github+json",
104
104
  "X-GitHub-Api-Version": "2022-11-28",
105
105
  },
106
- );
106
+ });
107
107
 
108
108
  if (result instanceof HTTPErrorResponse) {
109
109
  throw result;
@@ -219,17 +219,19 @@ export default class GitHubUtil extends HostedCodeRepository {
219
219
  );
220
220
 
221
221
  const result: HTTPErrorResponse | HTTPResponse<JSONObject> = await API.post(
222
- url,
223
222
  {
224
- base: data.baseBranchName,
225
- head: data.headBranchName,
226
- title: data.title,
227
- body: data.body,
228
- },
229
- {
230
- Authorization: `Bearer ${gitHubToken}`,
231
- Accept: "application/vnd.github+json",
232
- "X-GitHub-Api-Version": "2022-11-28",
223
+ url: url,
224
+ data: {
225
+ base: data.baseBranchName,
226
+ head: data.headBranchName,
227
+ title: data.title,
228
+ body: data.body,
229
+ },
230
+ headers: {
231
+ Authorization: `Bearer ${gitHubToken}`,
232
+ Accept: "application/vnd.github+json",
233
+ "X-GitHub-Api-Version": "2022-11-28",
234
+ },
233
235
  },
234
236
  );
235
237
 
@@ -2,6 +2,7 @@ export default {
2
2
  BillingService: {
3
3
  BILLING_NOT_ENABLED: "Billing is not enabled for this server.",
4
4
  CLIENT_SECRET_MISSING: "client_secret not returned by payment provider.",
5
+ CUSTOMER_NOT_FOUND: "Customer not found.",
5
6
  INVOICE_NOT_GENERATED: "Invoice not generated.",
6
7
  MIN_REQUIRED_PAYMENT_METHOD_NOT_MET:
7
8
  "There's only one payment method associated with this account. It cannot be deleted. To delete this payment method please add more payment methods to your account.",
@@ -22,19 +22,19 @@ export default class VMUtil {
22
22
  }): Promise<ReturnResult> {
23
23
  const returnResultHttpResponse:
24
24
  | HTTPErrorResponse
25
- | HTTPResponse<JSONObject> = await API.post<JSONObject>(
26
- new URL(
25
+ | HTTPResponse<JSONObject> = await API.post<JSONObject>({
26
+ url: new URL(
27
27
  Protocol.HTTP,
28
28
  IsolatedVMHostname,
29
29
  new Route("/isolated-vm/run-code"),
30
30
  ),
31
- {
31
+ data: {
32
32
  ...data,
33
33
  },
34
- {
34
+ headers: {
35
35
  ...ClusterKeyAuthorization.getClusterKeyHeaders(),
36
36
  },
37
- );
37
+ });
38
38
 
39
39
  if (returnResultHttpResponse instanceof HTTPErrorResponse) {
40
40
  throw returnResultHttpResponse;
@@ -116,7 +116,10 @@ export default class MicrosoftTeams extends WorkspaceBase {
116
116
  const payload: JSONObject = this.buildMessageCardFromMarkdown(data.text);
117
117
 
118
118
  const apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null =
119
- await API.post(data.url, payload);
119
+ await API.post({
120
+ url: data.url,
121
+ data: payload,
122
+ });
120
123
 
121
124
  if (!apiResult) {
122
125
  logger.error(
@@ -53,20 +53,20 @@ export default class SlackUtil extends WorkspaceBase {
53
53
  logger.debug(data);
54
54
 
55
55
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
56
- await API.post<JSONObject>(
57
- URL.fromString("https://slack.com/api/users.info"),
58
- {
56
+ await API.post<JSONObject>({
57
+ url: URL.fromString("https://slack.com/api/users.info"),
58
+ data: {
59
59
  user: data.userId,
60
60
  },
61
- {
61
+ headers: {
62
62
  Authorization: `Bearer ${data.authToken}`,
63
63
  ["Content-Type"]: "application/x-www-form-urlencoded",
64
64
  },
65
- {
65
+ options: {
66
66
  retries: 3,
67
67
  exponentialBackoff: true,
68
68
  },
69
- );
69
+ });
70
70
 
71
71
  logger.debug("Response from Slack API for getting user info:");
72
72
  logger.debug(response);
@@ -119,18 +119,20 @@ export default class SlackUtil extends WorkspaceBase {
119
119
 
120
120
  // use view.open API to show modal
121
121
  const result: HTTPErrorResponse | HTTPResponse<JSONObject> = await API.post(
122
- URL.fromString("https://slack.com/api/views.open"),
123
- {
124
- trigger_id: data.triggerId,
125
- view: modalJson,
126
- },
127
- {
128
- Authorization: `Bearer ${data.authToken}`,
129
- ["Content-Type"]: "application/json",
130
- },
131
122
  {
132
- retries: 3,
133
- exponentialBackoff: true,
123
+ url: URL.fromString("https://slack.com/api/views.open"),
124
+ data: {
125
+ trigger_id: data.triggerId,
126
+ view: modalJson,
127
+ },
128
+ headers: {
129
+ Authorization: `Bearer ${data.authToken}`,
130
+ ["Content-Type"]: "application/json",
131
+ },
132
+ options: {
133
+ retries: 3,
134
+ exponentialBackoff: true,
135
+ },
134
136
  },
135
137
  );
136
138
 
@@ -205,20 +207,20 @@ export default class SlackUtil extends WorkspaceBase {
205
207
 
206
208
  for (const channelId of data.channelIds) {
207
209
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
208
- await API.post(
209
- URL.fromString("https://slack.com/api/conversations.archive"),
210
- {
210
+ await API.post({
211
+ url: URL.fromString("https://slack.com/api/conversations.archive"),
212
+ data: {
211
213
  channel: channelId,
212
214
  },
213
- {
215
+ headers: {
214
216
  Authorization: `Bearer ${data.authToken}`,
215
217
  ["Content-Type"]: "application/x-www-form-urlencoded",
216
218
  },
217
- {
219
+ options: {
218
220
  retries: 3,
219
221
  exponentialBackoff: true,
220
222
  },
221
- );
223
+ });
222
224
 
223
225
  logger.debug("Response from Slack API for archiving channel:");
224
226
  logger.debug(response);
@@ -252,20 +254,20 @@ export default class SlackUtil extends WorkspaceBase {
252
254
 
253
255
  // Join channel
254
256
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
255
- await API.post(
256
- URL.fromString("https://slack.com/api/conversations.join"),
257
- {
257
+ await API.post({
258
+ url: URL.fromString("https://slack.com/api/conversations.join"),
259
+ data: {
258
260
  channel: data.channelId,
259
261
  },
260
- {
262
+ headers: {
261
263
  Authorization: `Bearer ${data.authToken}`,
262
264
  ["Content-Type"]: "application/x-www-form-urlencoded",
263
265
  },
264
- {
266
+ options: {
265
267
  retries: 3,
266
268
  exponentialBackoff: true,
267
269
  },
268
- );
270
+ });
269
271
 
270
272
  logger.debug("Response from Slack API for joining channel:");
271
273
  logger.debug(response);
@@ -311,21 +313,21 @@ export default class SlackUtil extends WorkspaceBase {
311
313
  logger.debug(data);
312
314
 
313
315
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
314
- await API.post(
315
- URL.fromString("https://slack.com/api/conversations.invite"),
316
- {
316
+ await API.post({
317
+ url: URL.fromString("https://slack.com/api/conversations.invite"),
318
+ data: {
317
319
  channel: data.channelId,
318
320
  users: data.workspaceUserId,
319
321
  },
320
- {
322
+ headers: {
321
323
  Authorization: `Bearer ${data.authToken}`,
322
324
  ["Content-Type"]: "application/x-www-form-urlencoded",
323
325
  },
324
- {
326
+ options: {
325
327
  retries: 3,
326
328
  exponentialBackoff: true,
327
329
  },
328
- );
330
+ });
329
331
 
330
332
  logger.debug("Response from Slack API for inviting user:");
331
333
  logger.debug(response);
@@ -465,20 +467,20 @@ export default class SlackUtil extends WorkspaceBase {
465
467
  logger.debug(data);
466
468
 
467
469
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
468
- await API.post<JSONObject>(
469
- URL.fromString("https://slack.com/api/conversations.info"),
470
- {
470
+ await API.post<JSONObject>({
471
+ url: URL.fromString("https://slack.com/api/conversations.info"),
472
+ data: {
471
473
  channel: data.channelId,
472
474
  },
473
- {
475
+ headers: {
474
476
  Authorization: `Bearer ${data.authToken}`,
475
477
  ["Content-Type"]: "application/x-www-form-urlencoded",
476
478
  },
477
- {
479
+ options: {
478
480
  retries: 3,
479
481
  exponentialBackoff: true,
480
482
  },
481
- );
483
+ });
482
484
 
483
485
  logger.debug("Response from Slack API for getting channel info:");
484
486
  logger.debug(response);
@@ -546,18 +548,18 @@ export default class SlackUtil extends WorkspaceBase {
546
548
  }
547
549
 
548
550
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
549
- await API.post<JSONObject>(
550
- URL.fromString("https://slack.com/api/conversations.list"),
551
- requestBody,
552
- {
551
+ await API.post<JSONObject>({
552
+ url: URL.fromString("https://slack.com/api/conversations.list"),
553
+ data: requestBody,
554
+ headers: {
553
555
  Authorization: `Bearer ${data.authToken}`,
554
556
  ["Content-Type"]: "application/x-www-form-urlencoded",
555
557
  },
556
- {
558
+ options: {
557
559
  retries: 3,
558
560
  exponentialBackoff: true,
559
561
  },
560
- );
562
+ });
561
563
 
562
564
  if (response instanceof HTTPErrorResponse) {
563
565
  logger.error("Error response from Slack API:");
@@ -793,18 +795,18 @@ export default class SlackUtil extends WorkspaceBase {
793
795
  }
794
796
 
795
797
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
796
- await API.post<JSONObject>(
797
- URL.fromString("https://slack.com/api/conversations.list"),
798
- requestBody,
799
- {
798
+ await API.post<JSONObject>({
799
+ url: URL.fromString("https://slack.com/api/conversations.list"),
800
+ data: requestBody,
801
+ headers: {
800
802
  Authorization: `Bearer ${data.authToken}`,
801
803
  ["Content-Type"]: "application/x-www-form-urlencoded",
802
804
  },
803
- {
805
+ options: {
804
806
  retries: 3,
805
807
  exponentialBackoff: true,
806
808
  },
807
- );
809
+ });
808
810
 
809
811
  if (response instanceof HTTPErrorResponse) {
810
812
  logger.error("Error response from Slack API:");
@@ -1105,22 +1107,22 @@ export default class SlackUtil extends WorkspaceBase {
1105
1107
  logger.debug(JSON.stringify(data, null, 2));
1106
1108
 
1107
1109
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
1108
- await API.post(
1109
- URL.fromString("https://slack.com/api/chat.postMessage"),
1110
- {
1110
+ await API.post({
1111
+ url: URL.fromString("https://slack.com/api/chat.postMessage"),
1112
+ data: {
1111
1113
  channel: data.workspaceChannel.id,
1112
1114
  blocks: data.blocks,
1113
1115
  unfurl_links: false,
1114
1116
  },
1115
- {
1117
+ headers: {
1116
1118
  Authorization: `Bearer ${data.authToken}`,
1117
1119
  ["Content-Type"]: "application/json",
1118
1120
  },
1119
- {
1121
+ options: {
1120
1122
  retries: 3,
1121
1123
  exponentialBackoff: true,
1122
1124
  },
1123
- );
1125
+ });
1124
1126
 
1125
1127
  logger.debug("Response from Slack API for sending message:");
1126
1128
  logger.debug(response);
@@ -1186,20 +1188,20 @@ export default class SlackUtil extends WorkspaceBase {
1186
1188
  logger.debug(data);
1187
1189
 
1188
1190
  const response: HTTPResponse<JSONObject> | HTTPErrorResponse =
1189
- await API.post(
1190
- URL.fromString("https://slack.com/api/conversations.create"),
1191
- {
1191
+ await API.post({
1192
+ url: URL.fromString("https://slack.com/api/conversations.create"),
1193
+ data: {
1192
1194
  name: data.channelName,
1193
1195
  },
1194
- {
1196
+ headers: {
1195
1197
  Authorization: `Bearer ${data.authToken}`,
1196
1198
  ["Content-Type"]: "application/x-www-form-urlencoded",
1197
1199
  },
1198
- {
1200
+ options: {
1199
1201
  retries: 3,
1200
1202
  exponentialBackoff: true,
1201
1203
  },
1202
- );
1204
+ });
1203
1205
 
1204
1206
  logger.debug("Response from Slack API for creating channel:");
1205
1207
  logger.debug(response);
@@ -1590,20 +1592,20 @@ export default class SlackUtil extends WorkspaceBase {
1590
1592
  }): Promise<boolean> {
1591
1593
  // check of the user id is in the direct message channel id
1592
1594
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
1593
- await API.post(
1594
- URL.fromString("https://slack.com/api/conversations.info"),
1595
- {
1595
+ await API.post({
1596
+ url: URL.fromString("https://slack.com/api/conversations.info"),
1597
+ data: {
1596
1598
  channel: data.directMessageChannelId,
1597
1599
  },
1598
- {
1600
+ headers: {
1599
1601
  Authorization: `Bearer ${data.authToken}`,
1600
1602
  ["Content-Type"]: "application/x-www-form-urlencoded",
1601
1603
  },
1602
- {
1604
+ options: {
1603
1605
  retries: 3,
1604
1606
  exponentialBackoff: true,
1605
1607
  },
1606
- );
1608
+ });
1607
1609
 
1608
1610
  if (response instanceof HTTPErrorResponse) {
1609
1611
  logger.error("Error response from Slack API:");
@@ -1660,18 +1662,18 @@ export default class SlackUtil extends WorkspaceBase {
1660
1662
  }
1661
1663
 
1662
1664
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
1663
- await API.post<JSONObject>(
1664
- URL.fromString("https://slack.com/api/conversations.members"),
1665
- requestBody,
1666
- {
1665
+ await API.post<JSONObject>({
1666
+ url: URL.fromString("https://slack.com/api/conversations.members"),
1667
+ data: requestBody,
1668
+ headers: {
1667
1669
  Authorization: `Bearer ${data.authToken}`,
1668
1670
  ["Content-Type"]: "application/x-www-form-urlencoded",
1669
1671
  },
1670
- {
1672
+ options: {
1671
1673
  retries: 3,
1672
1674
  exponentialBackoff: true,
1673
1675
  },
1674
- );
1676
+ });
1675
1677
 
1676
1678
  logger.debug("Response from Slack API for getting channel members:");
1677
1679
  logger.debug(response);
@@ -1747,9 +1749,9 @@ export default class SlackUtil extends WorkspaceBase {
1747
1749
  logger.debug(data);
1748
1750
 
1749
1751
  const apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null =
1750
- await API.post(
1751
- data.url,
1752
- {
1752
+ await API.post({
1753
+ url: data.url,
1754
+ data: {
1753
1755
  blocks: [
1754
1756
  {
1755
1757
  type: "section",
@@ -1760,12 +1762,11 @@ export default class SlackUtil extends WorkspaceBase {
1760
1762
  },
1761
1763
  ],
1762
1764
  },
1763
- undefined,
1764
- {
1765
+ options: {
1765
1766
  retries: 3,
1766
1767
  exponentialBackoff: true,
1767
1768
  },
1768
- );
1769
+ });
1769
1770
 
1770
1771
  logger.debug("Response from Slack API for sending message via webhook:");
1771
1772
  logger.debug(apiResult);
@@ -257,13 +257,13 @@ describe("fetch", () => {
257
257
 
258
258
  mockedAxios.mockResolvedValueOnce(mockedAxiosResponse);
259
259
 
260
- const response: HTTPResponse<typeof responseData> = await API.fetch(
261
- HTTPMethod.POST,
262
- new URL(Protocol.HTTPS, "catfact.ninja", new Route("fact")),
263
- requestData,
264
- requestHeaders,
260
+ const response: HTTPResponse<typeof responseData> = await API.fetch({
261
+ method: HTTPMethod.POST,
262
+ url: new URL(Protocol.HTTPS, "catfact.ninja", new Route("fact")),
263
+ data: requestData,
264
+ headers: requestHeaders,
265
265
  params,
266
- );
266
+ });
267
267
 
268
268
  // Check method, url (protocol, hostname, parameters), headers, request data
269
269
  expect(axios).toBeCalledWith({
@@ -295,10 +295,10 @@ describe("fetch", () => {
295
295
 
296
296
  mockedAxios.mockRejectedValueOnce(mockedAxiosError);
297
297
 
298
- const httpErrorResponse: HTTPResponse<JSONObject> = await API.fetch(
299
- HTTPMethod.GET,
300
- new URL(Protocol.HTTPS, "catfact.ninja", new Route("fact")),
301
- );
298
+ const httpErrorResponse: HTTPResponse<JSONObject> = await API.fetch({
299
+ method: HTTPMethod.GET,
300
+ url: new URL(Protocol.HTTPS, "catfact.ninja", new Route("fact")),
301
+ });
302
302
 
303
303
  expect(axios).toBeCalledWith({
304
304
  method: "GET",
@@ -316,10 +316,10 @@ describe("fetch", () => {
316
316
  });
317
317
 
318
318
  await expect(async () => {
319
- await API.fetch(
320
- HTTPMethod.GET,
321
- new URL(Protocol.HTTPS, "catfact.ninja", new Route("fact")),
322
- );
319
+ await API.fetch({
320
+ method: HTTPMethod.GET,
321
+ url: new URL(Protocol.HTTPS, "catfact.ninja", new Route("fact")),
322
+ });
323
323
  }).rejects.toThrowError(APIException);
324
324
  });
325
325
  });
@@ -376,11 +376,11 @@ describe.each(httpMethodTests)("$name", ({ name, method }: HTTPMethodType) => {
376
376
  "catfact.ninja",
377
377
  new Route("fact"),
378
378
  );
379
- const got: HTTPResponse<JSONObject> = await API[name](
379
+ const got: HTTPResponse<JSONObject> = await (API as any)[name]({
380
380
  url,
381
- requestData,
382
- requestHeaders,
383
- );
381
+ data: requestData,
382
+ headers: requestHeaders,
383
+ });
384
384
 
385
385
  // Check method, url, headers, request data
386
386
  expect(axios).toBeCalledWith(
@@ -403,11 +403,16 @@ describe.each(httpMethodTests)(".$name", ({ name, method }: HTTPMethodType) => {
403
403
 
404
404
  mockedAxios.mockResolvedValueOnce(createAxiosResponse());
405
405
 
406
- const got: HTTPResponse<JSONObject> = await api[name](
407
- new Route(route),
408
- requestData,
409
- requestHeaders,
406
+ const url: URL = new URL(
407
+ api.protocol,
408
+ api.hostname,
409
+ api.baseRoute.addRoute(route),
410
410
  );
411
+ const got: HTTPResponse<JSONObject> = await (api as any)[name]({
412
+ url,
413
+ data: requestData,
414
+ headers: requestHeaders,
415
+ });
411
416
 
412
417
  // Check method, url (protocol, hostname, route), headers, request data
413
418
  expect(axios).toBeCalledWith(