@oneuptime/common 8.0.5183 → 8.0.5199

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
@@ -1292,6 +1292,30 @@ export default class Project extends TenantModel {
1292
1292
  })
1293
1293
  public letCustomerSupportAccessProject?: boolean = undefined;
1294
1294
 
1295
+ // This is an internal field. This is used for internal analytics for example: Metabase.
1296
+ // Values can be between 0 and 100.
1297
+ @ColumnAccessControl({
1298
+ create: [],
1299
+ read: [],
1300
+ update: [],
1301
+ })
1302
+ @TableColumn({
1303
+ required: true,
1304
+ type: TableColumnType.Number,
1305
+ isDefaultValueColumn: true,
1306
+ hideColumnInDocumentation: true,
1307
+ title: "Discount Percent",
1308
+ description: "Discount percentage applied to the project billing",
1309
+ defaultValue: 0,
1310
+ })
1311
+ @Column({
1312
+ type: ColumnType.Number,
1313
+ nullable: false,
1314
+ unique: false,
1315
+ default: 0,
1316
+ })
1317
+ public discountPercent?: number = undefined;
1318
+
1295
1319
  @ColumnAccessControl({
1296
1320
  create: [],
1297
1321
  read: [
@@ -0,0 +1,123 @@
1
+ import { IsBillingEnabled } from "../EnvironmentConfig";
2
+ import UserMiddleware from "../Middleware/UserAuthorization";
3
+ import BillingService from "../Services/BillingService";
4
+ import ProjectService from "../Services/ProjectService";
5
+ import Express, {
6
+ ExpressRequest,
7
+ ExpressResponse,
8
+ ExpressRouter,
9
+ NextFunction,
10
+ OneUptimeRequest,
11
+ } from "../Utils/Express";
12
+ import Response from "../Utils/Response";
13
+ import BadDataException from "../../Types/Exception/BadDataException";
14
+ import Permission, { UserPermission } from "../../Types/Permission";
15
+ import Project from "../../Models/DatabaseModels/Project";
16
+ import CommonAPI from "./CommonAPI";
17
+ import ObjectID from "../../Types/ObjectID";
18
+ import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
19
+
20
+ export default class BillingAPI {
21
+ public router: ExpressRouter;
22
+
23
+ public constructor() {
24
+ this.router = Express.getRouter();
25
+
26
+ this.router.get(
27
+ `/billing/customer-balance`,
28
+ UserMiddleware.getUserMiddleware,
29
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
30
+ try {
31
+ if (!IsBillingEnabled) {
32
+ throw new BadDataException(
33
+ "Billing is not enabled for this server",
34
+ );
35
+ }
36
+
37
+ const userPermissions: Array<UserPermission> = (
38
+ await this.getPermissionsForTenant(req)
39
+ ).filter((permission: UserPermission) => {
40
+ return (
41
+ permission.permission.toString() ===
42
+ Permission.ProjectOwner.toString() ||
43
+ permission.permission.toString() ===
44
+ Permission.ManageProjectBilling.toString()
45
+ );
46
+ });
47
+
48
+ if (
49
+ userPermissions.length === 0 &&
50
+ !(req as OneUptimeRequest).userAuthorization?.isMasterAdmin
51
+ ) {
52
+ throw new BadDataException(
53
+ `You need ${Permission.ProjectOwner} or ${Permission.ManageProjectBilling} permission to view billing balance.`,
54
+ );
55
+ }
56
+
57
+ const project: Project | null = await ProjectService.findOneById({
58
+ id: this.getTenantId(req)!,
59
+ props: {
60
+ isRoot: true,
61
+ },
62
+ select: {
63
+ _id: true,
64
+ paymentProviderCustomerId: true,
65
+ },
66
+ });
67
+
68
+ if (!project) {
69
+ throw new BadDataException("Project not found");
70
+ }
71
+
72
+ if (!project.paymentProviderCustomerId) {
73
+ throw new BadDataException("Payment Provider customer not found");
74
+ }
75
+
76
+ const balance: number = await BillingService.getCustomerBalance(
77
+ project.paymentProviderCustomerId,
78
+ );
79
+
80
+ return Response.sendJsonObjectResponse(req, res, {
81
+ balance: balance,
82
+ });
83
+ } catch (err) {
84
+ next(err);
85
+ }
86
+ },
87
+ );
88
+ }
89
+
90
+ public async getPermissionsForTenant(
91
+ req: ExpressRequest,
92
+ ): Promise<Array<UserPermission>> {
93
+ const permissions: Array<UserPermission> = [];
94
+
95
+ const props: DatabaseCommonInteractionProps =
96
+ await CommonAPI.getDatabaseCommonInteractionProps(req);
97
+
98
+ if (
99
+ props &&
100
+ props.userTenantAccessPermission &&
101
+ props.userTenantAccessPermission[props.tenantId?.toString() || ""]
102
+ ) {
103
+ return (
104
+ props.userTenantAccessPermission[props.tenantId?.toString() || ""]
105
+ ?.permissions || []
106
+ );
107
+ }
108
+
109
+ return permissions;
110
+ }
111
+
112
+ public getTenantId(req: ExpressRequest): ObjectID | null {
113
+ if ((req as OneUptimeRequest).tenantId) {
114
+ return (req as OneUptimeRequest).tenantId as ObjectID;
115
+ }
116
+
117
+ return null;
118
+ }
119
+
120
+ public getRouter(): ExpressRouter {
121
+ return this.router;
122
+ }
123
+ }
@@ -157,13 +157,13 @@ export default class SlackAPI {
157
157
  // send the request to slack api to get the access token https://slack.com/api/oauth.v2.access
158
158
 
159
159
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
160
- await API.post(
161
- URL.fromString("https://slack.com/api/oauth.v2.access"),
162
- requestBody,
163
- {
160
+ await API.post({
161
+ url: URL.fromString("https://slack.com/api/oauth.v2.access"),
162
+ data: requestBody,
163
+ headers: {
164
164
  "Content-Type": "application/x-www-form-urlencoded",
165
165
  },
166
- );
166
+ });
167
167
 
168
168
  if (response instanceof HTTPErrorResponse) {
169
169
  throw response;
@@ -369,13 +369,13 @@ export default class SlackAPI {
369
369
  // send the request to slack api to get the access token https://slack.com/api/oauth.v2.access
370
370
 
371
371
  const response: HTTPErrorResponse | HTTPResponse<JSONObject> =
372
- await API.post(
373
- URL.fromString("https://slack.com/api/openid.connect.token"),
374
- requestBody,
375
- {
372
+ await API.post({
373
+ url: URL.fromString("https://slack.com/api/openid.connect.token"),
374
+ data: requestBody,
375
+ headers: {
376
376
  "Content-Type": "application/x-www-form-urlencoded",
377
377
  },
378
- );
378
+ });
379
379
 
380
380
  if (response instanceof HTTPErrorResponse) {
381
381
  throw response;
@@ -1100,7 +1100,7 @@ export default class StatusPageAPI extends BaseAPI<
1100
1100
  },
1101
1101
  select: select,
1102
1102
  sort: {
1103
- createdAt: SortOrder.Ascending,
1103
+ createdAt: SortOrder.Descending,
1104
1104
  },
1105
1105
 
1106
1106
  skip: 0,
@@ -122,7 +122,9 @@ export default class ClickhouseDatabase {
122
122
  }
123
123
 
124
124
  const result: HTTPErrorResponse | HTTPResponse<JSONObject> =
125
- await API.get(URL.fromString(dbUrl.toString()));
125
+ await API.get({
126
+ url: URL.fromString(dbUrl.toString()),
127
+ });
126
128
 
127
129
  logger.debug("Clickhouse Connection Status Result");
128
130
  logger.debug(result);
@@ -0,0 +1,17 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1758313975491 implements MigrationInterface {
4
+ public name = "MigrationName1758313975491";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "Project" ADD "discountPercent" integer NOT NULL DEFAULT '0'`,
9
+ );
10
+ }
11
+
12
+ public async down(queryRunner: QueryRunner): Promise<void> {
13
+ await queryRunner.query(
14
+ `ALTER TABLE "Project" DROP COLUMN "discountPercent"`,
15
+ );
16
+ }
17
+ }
@@ -167,6 +167,7 @@ import { MigrationName1756300358095 } from "./1756300358095-MigrationName";
167
167
  import { MigrationName1756821449686 } from "./1756821449686-MigrationName";
168
168
  import { MigrationName1757416939595 } from "./1757416939595-MigrationName";
169
169
  import { MigrationName1757423505855 } from "./1757423505855-MigrationName";
170
+ import { MigrationName1758313975491 } from "./1758313975491-MigrationName";
170
171
 
171
172
  export default [
172
173
  InitialMigration,
@@ -338,4 +339,5 @@ export default [
338
339
  MigrationName1756821449686,
339
340
  MigrationName1757416939595,
340
341
  MigrationName1757423505855,
342
+ MigrationName1758313975491,
341
343
  ];
@@ -1122,8 +1122,8 @@ export default class AnalyticsDatabaseService<
1122
1122
  triggerType: DatabaseTriggerType
1123
1123
  ): Promise<void> {
1124
1124
  if (this.getModel().enableWorkflowOn) {
1125
- API.post(
1126
- new URL(
1125
+ API.post({
1126
+ url: new URL(
1127
1127
  Protocol.HTTP,
1128
1128
  WorkflowHostname,
1129
1129
  new Route(
@@ -1132,15 +1132,13 @@ export default class AnalyticsDatabaseService<
1132
1132
  )}/${triggerType}`
1133
1133
  )
1134
1134
  ),
1135
- {
1136
- data: {
1137
- _id: id.toString(),
1138
- },
1135
+ data: {
1136
+ _id: id.toString(),
1139
1137
  },
1140
- {
1138
+ headers: {
1141
1139
  ...ClusterKeyAuthorization.getClusterKeyHeaders(),
1142
- }
1143
- ).catch((error: Error) => {
1140
+ },
1141
+ }).catch((error: Error) => {
1144
1142
  logger.error(error);
1145
1143
  });
1146
1144
  }
@@ -763,6 +763,23 @@ export class BillingService extends BaseService {
763
763
  return setupIntent.client_secret;
764
764
  }
765
765
 
766
+ @CaptureSpan()
767
+ public async getCustomerBalance(customerId: string): Promise<number> {
768
+ if (!this.isBillingEnabled()) {
769
+ throw new BadDataException(Errors.BillingService.BILLING_NOT_ENABLED);
770
+ }
771
+
772
+ const customer: Stripe.Response<Stripe.Customer | Stripe.DeletedCustomer> =
773
+ await this.stripe.customers.retrieve(customerId);
774
+
775
+ if (!customer || customer.deleted) {
776
+ throw new BadDataException(Errors.BillingService.CUSTOMER_NOT_FOUND);
777
+ }
778
+
779
+ // Balance is in cents, convert to dollars
780
+ return ((customer as Stripe.Customer).balance || 0) / 100;
781
+ }
782
+
766
783
  @CaptureSpan()
767
784
  public async cancelSubscription(subscriptionId: string): Promise<void> {
768
785
  if (!this.isBillingEnabled()) {
@@ -70,17 +70,17 @@ export class CallService extends BaseService {
70
70
  onCallScheduleId: options.onCallScheduleId?.toString(),
71
71
  };
72
72
 
73
- return await API.post<EmptyResponseData>(
74
- new URL(
73
+ return await API.post<EmptyResponseData>({
74
+ url: new URL(
75
75
  Protocol.HTTP,
76
76
  AppApiHostname,
77
77
  new Route("/api/notification/call/make-call"),
78
78
  ),
79
- body,
80
- {
79
+ data: body,
80
+ headers: {
81
81
  ...ClusterKeyAuthorization.getClusterKeyHeaders(),
82
82
  },
83
- );
83
+ });
84
84
  }
85
85
  }
86
86
 
@@ -617,8 +617,8 @@ class DatabaseService<TBaseModel extends BaseModel> extends BaseService {
617
617
  miscData?: JSONObject | undefined, // miscData is used for passing data to workflow.
618
618
  ): Promise<void> {
619
619
  if (this.getModel().enableWorkflowOn) {
620
- API.post(
621
- new URL(
620
+ API.post({
621
+ url: new URL(
622
622
  Protocol.HTTP,
623
623
  WorkflowHostname,
624
624
  new Route(
@@ -627,16 +627,16 @@ class DatabaseService<TBaseModel extends BaseModel> extends BaseService {
627
627
  )}/${triggerType}`,
628
628
  ),
629
629
  ),
630
- {
630
+ data: {
631
631
  data: {
632
632
  _id: id.toString(),
633
633
  miscData: miscData,
634
634
  },
635
635
  },
636
- {
636
+ headers: {
637
637
  ...ClusterKeyAuthorization.getClusterKeyHeaders(),
638
638
  },
639
- ).catch((error: Error) => {
639
+ }).catch((error: Error) => {
640
640
  logger.error(error);
641
641
  });
642
642
  }
@@ -108,17 +108,17 @@ export class MailService extends BaseService {
108
108
  body["teamId"] = options.teamId.toString();
109
109
  }
110
110
 
111
- return await API.post<EmptyResponseData>(
112
- new URL(
111
+ return await API.post<EmptyResponseData>({
112
+ url: new URL(
113
113
  Protocol.HTTP,
114
114
  AppApiHostname,
115
115
  new Route("/api/notification/email/send"),
116
116
  ),
117
- body,
118
- {
117
+ data: body,
118
+ headers: {
119
119
  ...ClusterKeyAuthorization.getClusterKeyHeaders(),
120
120
  },
121
- );
121
+ });
122
122
  }
123
123
  }
124
124
 
@@ -71,17 +71,17 @@ export class SmsService extends BaseService {
71
71
  teamId: options.teamId?.toString(),
72
72
  };
73
73
 
74
- return await API.post<EmptyResponseData>(
75
- new URL(
74
+ return await API.post<EmptyResponseData>({
75
+ url: new URL(
76
76
  Protocol.HTTP,
77
77
  AppApiHostname,
78
78
  new Route("/api/notification/sms/send"),
79
79
  ),
80
- body,
81
- {
80
+ data: body,
81
+ headers: {
82
82
  ...ClusterKeyAuthorization.getClusterKeyHeaders(),
83
83
  },
84
- );
84
+ });
85
85
  }
86
86
  }
87
87
 
@@ -23,10 +23,14 @@ export class StatusPageCertificateService extends BaseService {
23
23
 
24
24
  const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol();
25
25
 
26
- return await API.post<EmptyResponseData>(
27
- new URL(httpProtocol, AppApiHostname, new Route("/api/workers/cert")),
28
- body,
29
- );
26
+ return await API.post<EmptyResponseData>({
27
+ url: new URL(
28
+ httpProtocol,
29
+ AppApiHostname,
30
+ new Route("/api/workers/cert"),
31
+ ),
32
+ data: body,
33
+ });
30
34
  }
31
35
 
32
36
  @CaptureSpan()
@@ -39,10 +43,14 @@ export class StatusPageCertificateService extends BaseService {
39
43
  domain: domain,
40
44
  };
41
45
 
42
- return await API.delete<EmptyResponseData>(
43
- new URL(httpProtocol, AppApiHostname, new Route("/api/workers/cert")),
44
- body,
45
- );
46
+ return await API.delete<EmptyResponseData>({
47
+ url: new URL(
48
+ httpProtocol,
49
+ AppApiHostname,
50
+ new Route("/api/workers/cert"),
51
+ ),
52
+ data: body,
53
+ });
46
54
  }
47
55
 
48
56
  @CaptureSpan()
@@ -53,10 +61,14 @@ export class StatusPageCertificateService extends BaseService {
53
61
 
54
62
  const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol();
55
63
 
56
- return await API.get<JSONObject>(
57
- new URL(httpProtocol, AppApiHostname, new Route("/api/workers/cert")),
58
- body,
59
- );
64
+ return await API.get<JSONObject>({
65
+ url: new URL(
66
+ httpProtocol,
67
+ AppApiHostname,
68
+ new Route("/api/workers/cert"),
69
+ ),
70
+ data: body,
71
+ });
60
72
  }
61
73
  }
62
74
 
@@ -222,14 +222,14 @@ export class Service extends DatabaseService<StatusPageDomain> {
222
222
  ): Promise<boolean> {
223
223
  try {
224
224
  const result: HTTPErrorResponse | HTTPResponse<JSONObject> =
225
- await API.get(
226
- URL.fromString(
225
+ await API.get({
226
+ url: URL.fromString(
227
227
  "https://" +
228
228
  fulldomain +
229
229
  "/status-page-api/cname-verification/" +
230
230
  token,
231
231
  ),
232
- );
232
+ });
233
233
 
234
234
  if (result.isFailure()) {
235
235
  return false;
@@ -306,14 +306,14 @@ export class Service extends DatabaseService<StatusPageDomain> {
306
306
 
307
307
  try {
308
308
  const result: HTTPErrorResponse | HTTPResponse<JSONObject> =
309
- await API.get(
310
- URL.fromString(
309
+ await API.get({
310
+ url: URL.fromString(
311
311
  "http://" +
312
312
  fullDomain +
313
313
  "/status-page-api/cname-verification/" +
314
314
  token,
315
315
  ),
316
- );
316
+ });
317
317
 
318
318
  logger.debug("CNAME verification result");
319
319
  logger.debug(result);
@@ -335,14 +335,14 @@ export class Service extends DatabaseService<StatusPageDomain> {
335
335
 
336
336
  try {
337
337
  const resultHttps: HTTPErrorResponse | HTTPResponse<JSONObject> =
338
- await API.get(
339
- URL.fromString(
338
+ await API.get({
339
+ url: URL.fromString(
340
340
  "https://" +
341
341
  fullDomain +
342
342
  "/status-page-api/cname-verification/" +
343
343
  token,
344
344
  ),
345
- );
345
+ });
346
346
 
347
347
  logger.debug("CNAME verification result for https");
348
348
  logger.debug(resultHttps);
@@ -68,17 +68,17 @@ export class Service extends DatabaseService<Model> {
68
68
 
69
69
  logger.debug("Updating workflow on the workflow service");
70
70
 
71
- await API.post<EmptyResponseData>(
72
- new URL(
71
+ await API.post<EmptyResponseData>({
72
+ url: new URL(
73
73
  Protocol.HTTP,
74
74
  WorkflowHostname,
75
75
  new Route("/workflow/update/" + onUpdate.updateBy.query._id!),
76
76
  ),
77
- {},
78
- {
77
+ data: {},
78
+ headers: {
79
79
  ...ClusterKeyAuthorization.getClusterKeyHeaders(),
80
80
  },
81
- );
81
+ });
82
82
 
83
83
  logger.debug("Updated workflow on the workflow service");
84
84
 
@@ -42,11 +42,11 @@ export default class ApiDelete extends ComponentCode {
42
42
  let apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null = null;
43
43
 
44
44
  try {
45
- apiResult = await API.delete(
46
- args["url"] as URL,
47
- args["request-body"] as JSONObject,
48
- args["request-headers"] as Dictionary<string>,
49
- );
45
+ apiResult = await API.delete({
46
+ url: args["url"] as URL,
47
+ data: args["request-body"] as JSONObject,
48
+ headers: args["request-headers"] as Dictionary<string>,
49
+ });
50
50
 
51
51
  return Promise.resolve({
52
52
  returnValues: ApiComponentUtils.getReturnValues(apiResult),
@@ -42,11 +42,11 @@ export default class ApiGet extends ComponentCode {
42
42
  let apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null = null;
43
43
 
44
44
  try {
45
- apiResult = await API.get(
46
- args["url"] as URL,
47
- args["request-body"] as JSONObject,
48
- args["request-headers"] as Dictionary<string>,
49
- );
45
+ apiResult = await API.get({
46
+ url: args["url"] as URL,
47
+ data: args["request-body"] as JSONObject,
48
+ headers: args["request-headers"] as Dictionary<string>,
49
+ });
50
50
 
51
51
  return Promise.resolve({
52
52
  returnValues: ApiComponentUtils.getReturnValues(apiResult),
@@ -42,11 +42,11 @@ export default class ApiPut extends ComponentCode {
42
42
  let apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null = null;
43
43
 
44
44
  try {
45
- apiResult = await API.patch(
46
- args["url"] as URL,
47
- args["request-body"] as JSONObject,
48
- args["request-headers"] as Dictionary<string>,
49
- );
45
+ apiResult = await API.patch({
46
+ url: args["url"] as URL,
47
+ data: args["request-body"] as JSONObject,
48
+ headers: args["request-headers"] as Dictionary<string>,
49
+ });
50
50
 
51
51
  return Promise.resolve({
52
52
  returnValues: ApiComponentUtils.getReturnValues(apiResult),
@@ -62,11 +62,11 @@ export default class ApiPost extends ComponentCode {
62
62
  logger.debug(`Request Headers: ${JSON.stringify(requestHeaders)}`);
63
63
 
64
64
  try {
65
- apiResult = await API.post(
66
- args["url"] as URL,
67
- args["request-body"] as JSONObject,
68
- args["request-headers"] as Dictionary<string>,
69
- );
65
+ apiResult = await API.post({
66
+ url: args["url"] as URL,
67
+ data: args["request-body"] as JSONObject,
68
+ headers: args["request-headers"] as Dictionary<string>,
69
+ });
70
70
 
71
71
  logger.debug("API Post Component is done.");
72
72
 
@@ -42,11 +42,11 @@ export default class ApiPut extends ComponentCode {
42
42
  let apiResult: HTTPResponse<JSONObject> | HTTPErrorResponse | null = null;
43
43
 
44
44
  try {
45
- apiResult = await API.put(
46
- args["url"] as URL,
47
- args["request-body"] as JSONObject,
48
- args["request-headers"] as Dictionary<string>,
49
- );
45
+ apiResult = await API.put({
46
+ url: args["url"] as URL,
47
+ data: args["request-body"] as JSONObject,
48
+ headers: args["request-headers"] as Dictionary<string>,
49
+ });
50
50
 
51
51
  return Promise.resolve({
52
52
  returnValues: ApiComponentUtils.getReturnValues(apiResult),