@oneuptime/common 7.0.2994 → 7.0.3018

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 (174) hide show
  1. package/Models/AnalyticsModels/ExceptionInstance.ts +488 -0
  2. package/Models/AnalyticsModels/Index.ts +2 -0
  3. package/Models/AnalyticsModels/Span.ts +2 -2
  4. package/Models/DatabaseModels/CopilotAction.ts +232 -38
  5. package/Models/DatabaseModels/CopilotActionTypePriority.ts +325 -0
  6. package/Models/DatabaseModels/Index.ts +6 -0
  7. package/Models/DatabaseModels/TelemetryException.ts +978 -0
  8. package/Server/API/CopilotActionAPI.ts +69 -7
  9. package/Server/API/StatusAPI.ts +61 -51
  10. package/Server/EnvironmentConfig.ts +3 -0
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.ts +93 -0
  12. package/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.ts +60 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.ts +17 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.ts +51 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.ts +23 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.ts +13 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.ts +17 -0
  18. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +14 -0
  19. package/Server/Infrastructure/QueueWorker.ts +2 -2
  20. package/Server/Services/CopilotActionTypePriorityService.ts +66 -0
  21. package/Server/Services/DatabaseService.ts +4 -5
  22. package/Server/Services/ExceptionInstanceService.ts +11 -0
  23. package/Server/Services/Index.ts +7 -0
  24. package/Server/Services/StatusPageDomainService.ts +118 -59
  25. package/Server/Services/TelemetryExceptionService.ts +10 -0
  26. package/Server/Types/Database/Permissions/Index.ts +1 -1
  27. package/Server/Types/Database/UpdateByID.ts +1 -1
  28. package/Server/Types/Workflow/Components/Email.ts +32 -25
  29. package/Server/Utils/CodeRepository/CodeRepository.ts +10 -14
  30. package/Server/Utils/CodeRepository/CodeRepositoryFile.ts +0 -7
  31. package/Server/Utils/Greenlock/Greenlock.ts +331 -204
  32. package/Server/Utils/Logger.ts +8 -2
  33. package/Server/Utils/Telemetry.ts +109 -25
  34. package/Types/Code/CodeType.ts +1 -0
  35. package/Types/Copilot/CopilotActionProps/DirectoryActionProp.ts +3 -0
  36. package/Types/Copilot/CopilotActionProps/ExceptionActionProp.ts +4 -0
  37. package/Types/Copilot/CopilotActionProps/FileActionProp.ts +5 -0
  38. package/Types/Copilot/CopilotActionProps/FunctionActionProp.ts +5 -0
  39. package/Types/Copilot/CopilotActionProps/Index.ts +96 -0
  40. package/Types/Copilot/CopilotActionProps/SpanActionProp.ts +4 -0
  41. package/Types/Copilot/CopilotActionStatus.ts +109 -1
  42. package/Types/Copilot/CopilotActionType.ts +203 -1
  43. package/Types/Database/PartialEntity.ts +14 -1
  44. package/Types/Date.ts +9 -1
  45. package/Types/Icon/IconProp.ts +3 -0
  46. package/Types/Permission.ts +65 -0
  47. package/Types/Workflow/Components/Email.ts +4 -4
  48. package/UI/Components/ActionCard/ActionCard.tsx +66 -0
  49. package/UI/Components/Alerts/Alert.tsx +69 -60
  50. package/UI/Components/Card/Card.tsx +1 -0
  51. package/UI/Components/Detail/Detail.tsx +6 -1
  52. package/UI/Components/GanttChart/Row/Row.tsx +4 -2
  53. package/UI/Components/GanttChart/Row/RowLabel.tsx +7 -3
  54. package/UI/Components/Icon/Icon.tsx +24 -0
  55. package/UI/Components/LogsViewer/LogsViewer.tsx +1 -1
  56. package/UI/Components/Types/FieldType.ts +1 -0
  57. package/UI/Components/Workflow/WorkflowStatus.tsx +2 -2
  58. package/UI/Config.ts +2 -0
  59. package/UI/Utils/Telemetry.ts +7 -2
  60. package/Utils/Crypto.ts +11 -0
  61. package/build/dist/Models/AnalyticsModels/ExceptionInstance.js +445 -0
  62. package/build/dist/Models/AnalyticsModels/ExceptionInstance.js.map +1 -0
  63. package/build/dist/Models/AnalyticsModels/Index.js +2 -0
  64. package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
  65. package/build/dist/Models/AnalyticsModels/Span.js +2 -2
  66. package/build/dist/Models/DatabaseModels/CopilotAction.js +237 -40
  67. package/build/dist/Models/DatabaseModels/CopilotAction.js.map +1 -1
  68. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js +343 -0
  69. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js.map +1 -0
  70. package/build/dist/Models/DatabaseModels/Index.js +4 -0
  71. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  72. package/build/dist/Models/DatabaseModels/TelemetryException.js +1010 -0
  73. package/build/dist/Models/DatabaseModels/TelemetryException.js.map +1 -0
  74. package/build/dist/Server/API/CopilotActionAPI.js +56 -9
  75. package/build/dist/Server/API/CopilotActionAPI.js.map +1 -1
  76. package/build/dist/Server/API/StatusAPI.js +51 -44
  77. package/build/dist/Server/API/StatusAPI.js.map +1 -1
  78. package/build/dist/Server/EnvironmentConfig.js +1 -0
  79. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  80. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.js +38 -0
  81. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.js.map +1 -0
  82. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.js +26 -0
  83. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.js.map +1 -0
  84. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.js +12 -0
  85. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.js.map +1 -0
  86. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.js +24 -0
  87. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.js.map +1 -0
  88. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.js +14 -0
  89. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.js.map +1 -0
  90. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.js +12 -0
  91. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.js.map +1 -0
  92. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.js +12 -0
  93. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.js.map +1 -0
  94. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +14 -0
  95. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  96. package/build/dist/Server/Infrastructure/QueueWorker.js +2 -2
  97. package/build/dist/Server/Infrastructure/QueueWorker.js.map +1 -1
  98. package/build/dist/Server/Services/CopilotActionTypePriorityService.js +45 -0
  99. package/build/dist/Server/Services/CopilotActionTypePriorityService.js.map +1 -0
  100. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  101. package/build/dist/Server/Services/ExceptionInstanceService.js +9 -0
  102. package/build/dist/Server/Services/ExceptionInstanceService.js.map +1 -0
  103. package/build/dist/Server/Services/Index.js +6 -0
  104. package/build/dist/Server/Services/Index.js.map +1 -1
  105. package/build/dist/Server/Services/StatusPageDomainService.js +101 -53
  106. package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
  107. package/build/dist/Server/Services/TelemetryExceptionService.js +9 -0
  108. package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -0
  109. package/build/dist/Server/Types/Database/Permissions/Index.js.map +1 -1
  110. package/build/dist/Server/Types/Workflow/Components/Email.js +26 -27
  111. package/build/dist/Server/Types/Workflow/Components/Email.js.map +1 -1
  112. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js +5 -13
  113. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js.map +1 -1
  114. package/build/dist/Server/Utils/Greenlock/Greenlock.js +234 -157
  115. package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
  116. package/build/dist/Server/Utils/Logger.js +5 -1
  117. package/build/dist/Server/Utils/Logger.js.map +1 -1
  118. package/build/dist/Server/Utils/Telemetry.js +63 -22
  119. package/build/dist/Server/Utils/Telemetry.js.map +1 -1
  120. package/build/dist/Types/Code/CodeType.js +1 -0
  121. package/build/dist/Types/Code/CodeType.js.map +1 -1
  122. package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js +2 -0
  123. package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js.map +1 -0
  124. package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js +2 -0
  125. package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js.map +1 -0
  126. package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js +2 -0
  127. package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js.map +1 -0
  128. package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js +2 -0
  129. package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js.map +1 -0
  130. package/build/dist/Types/Copilot/CopilotActionProps/Index.js +64 -0
  131. package/build/dist/Types/Copilot/CopilotActionProps/Index.js.map +1 -0
  132. package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js +2 -0
  133. package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js.map +1 -0
  134. package/build/dist/Types/Copilot/CopilotActionStatus.js +89 -0
  135. package/build/dist/Types/Copilot/CopilotActionStatus.js.map +1 -1
  136. package/build/dist/Types/Copilot/CopilotActionType.js +165 -1
  137. package/build/dist/Types/Copilot/CopilotActionType.js.map +1 -1
  138. package/build/dist/Types/Database/PartialEntity.js +3 -0
  139. package/build/dist/Types/Database/PartialEntity.js.map +1 -1
  140. package/build/dist/Types/Date.js +7 -1
  141. package/build/dist/Types/Date.js.map +1 -1
  142. package/build/dist/Types/Icon/IconProp.js +3 -0
  143. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  144. package/build/dist/Types/Permission.js +57 -0
  145. package/build/dist/Types/Permission.js.map +1 -1
  146. package/build/dist/Types/Workflow/Components/Email.js +4 -4
  147. package/build/dist/Types/Workflow/Components/Email.js.map +1 -1
  148. package/build/dist/UI/Components/ActionCard/ActionCard.js +27 -0
  149. package/build/dist/UI/Components/ActionCard/ActionCard.js.map +1 -0
  150. package/build/dist/UI/Components/Alerts/Alert.js +36 -45
  151. package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
  152. package/build/dist/UI/Components/Card/Card.js +1 -1
  153. package/build/dist/UI/Components/Card/Card.js.map +1 -1
  154. package/build/dist/UI/Components/Detail/Detail.js +5 -1
  155. package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
  156. package/build/dist/UI/Components/GanttChart/Row/Row.js +2 -2
  157. package/build/dist/UI/Components/GanttChart/Row/Row.js.map +1 -1
  158. package/build/dist/UI/Components/GanttChart/Row/RowLabel.js +3 -3
  159. package/build/dist/UI/Components/GanttChart/Row/RowLabel.js.map +1 -1
  160. package/build/dist/UI/Components/Icon/Icon.js +9 -0
  161. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  162. package/build/dist/UI/Components/LogsViewer/LogsViewer.js +1 -1
  163. package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
  164. package/build/dist/UI/Components/Types/FieldType.js +1 -0
  165. package/build/dist/UI/Components/Types/FieldType.js.map +1 -1
  166. package/build/dist/UI/Components/Workflow/WorkflowStatus.js +2 -2
  167. package/build/dist/UI/Components/Workflow/WorkflowStatus.js.map +1 -1
  168. package/build/dist/UI/Config.js +1 -0
  169. package/build/dist/UI/Config.js.map +1 -1
  170. package/build/dist/UI/Utils/Telemetry.js +6 -3
  171. package/build/dist/UI/Utils/Telemetry.js.map +1 -1
  172. package/build/dist/Utils/Crypto.js +10 -0
  173. package/build/dist/Utils/Crypto.js.map +1 -0
  174. package/package.json +11 -11
@@ -0,0 +1,66 @@
1
+ import CopilotActionType from "../../Types/Copilot/CopilotActionType";
2
+ import BadDataException from "../../Types/Exception/BadDataException";
3
+ import ObjectID from "../../Types/ObjectID";
4
+ import CreateBy from "../Types/Database/CreateBy";
5
+ import { OnCreate } from "../Types/Database/Hooks";
6
+ import DatabaseService from "./DatabaseService";
7
+ import Model from "Common/Models/DatabaseModels/CopilotActionTypePriority";
8
+
9
+ export class Service extends DatabaseService<Model> {
10
+ public constructor() {
11
+ super(Model);
12
+ }
13
+
14
+ protected override async onBeforeCreate(
15
+ createBy: CreateBy<Model>,
16
+ ): Promise<OnCreate<Model>> {
17
+ // check if the action exits witht he same name exists in the same repo.
18
+
19
+ const actionType: CopilotActionType | undefined = createBy.data.actionType;
20
+ const codeRepositoryId: ObjectID | undefined =
21
+ createBy.data.codeRepositoryId;
22
+
23
+ if (!actionType) {
24
+ throw new BadDataException("ActionType is required");
25
+ }
26
+
27
+ if (!codeRepositoryId) {
28
+ throw new BadDataException("CodeRepositoryId is required");
29
+ }
30
+
31
+ const existingItem: Model | null = await this.findOneBy({
32
+ query: {
33
+ actionType,
34
+ codeRepositoryId,
35
+ },
36
+ props: {
37
+ isRoot: true,
38
+ },
39
+ });
40
+
41
+ if (existingItem) {
42
+ throw new BadDataException(
43
+ "Action Type already exists for this repository.",
44
+ );
45
+ }
46
+
47
+ // check if the priority is in between 1 and 5.
48
+
49
+ const priority: number | undefined = createBy.data.priority;
50
+
51
+ if (!priority) {
52
+ throw new BadDataException("Priority is required");
53
+ }
54
+
55
+ if (priority < 1 || priority > 5) {
56
+ throw new BadDataException("Priority must be between 1 and 5");
57
+ }
58
+
59
+ return {
60
+ createBy: createBy,
61
+ carryForward: null,
62
+ };
63
+ }
64
+ }
65
+
66
+ export default new Service();
@@ -59,7 +59,6 @@ import Typeof from "../../Types/Typeof";
59
59
  import API from "Common/Utils/API";
60
60
  import Slug from "Common/Utils/Slug";
61
61
  import { DataSource, Repository, SelectQueryBuilder } from "typeorm";
62
- import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
63
62
  import { FindWhere } from "../../Types/BaseDatabase/Query";
64
63
 
65
64
  class DatabaseService<TBaseModel extends BaseModel> extends BaseService {
@@ -427,10 +426,10 @@ class DatabaseService<TBaseModel extends BaseModel> extends BaseService {
427
426
  }
428
427
 
429
428
  private async sanitizeCreateOrUpdate(
430
- data: TBaseModel | QueryDeepPartialEntity<TBaseModel>,
429
+ data: TBaseModel | PartialEntity<TBaseModel>,
431
430
  props: DatabaseCommonInteractionProps,
432
431
  isUpdate: boolean = false,
433
- ): Promise<TBaseModel | QueryDeepPartialEntity<TBaseModel>> {
432
+ ): Promise<TBaseModel | PartialEntity<TBaseModel>> {
434
433
  data = this.checkMaxLengthOfFields(data as TBaseModel);
435
434
 
436
435
  const columns: Columns = this.model.getTableColumns();
@@ -1274,12 +1273,12 @@ class DatabaseService<TBaseModel extends BaseModel> extends BaseService {
1274
1273
  beforeUpdateBy.props,
1275
1274
  );
1276
1275
 
1277
- const data: QueryDeepPartialEntity<TBaseModel> =
1276
+ const data: PartialEntity<TBaseModel> =
1278
1277
  (await this.sanitizeCreateOrUpdate(
1279
1278
  beforeUpdateBy.data,
1280
1279
  updateBy.props,
1281
1280
  true,
1282
- )) as QueryDeepPartialEntity<TBaseModel>;
1281
+ )) as PartialEntity<TBaseModel>;
1283
1282
 
1284
1283
  if (!(updateBy.skip instanceof PositiveNumber)) {
1285
1284
  updateBy.skip = new PositiveNumber(updateBy.skip);
@@ -0,0 +1,11 @@
1
+ import ClickhouseDatabase from "../Infrastructure/ClickhouseDatabase";
2
+ import AnalyticsDatabaseService from "./AnalyticsDatabaseService";
3
+ import ExceptionInstance from "Common/Models/AnalyticsModels/ExceptionInstance";
4
+
5
+ export class ExceptionInstanceService extends AnalyticsDatabaseService<ExceptionInstance> {
6
+ public constructor(clickhouseDatabase?: ClickhouseDatabase | undefined) {
7
+ super({ modelType: ExceptionInstance, database: clickhouseDatabase });
8
+ }
9
+ }
10
+
11
+ export default new ExceptionInstanceService();
@@ -130,6 +130,9 @@ import AnalyticsBaseModel from "Common/Models/AnalyticsModels/AnalyticsBaseModel
130
130
  import CopilotPullRequestService from "./CopilotPullRequestService";
131
131
  import ServiceCatalogDependencyService from "./ServiceCatalogDependencyService";
132
132
  import TelemetryAttributeService from "./TelemetryAttributeService";
133
+ import TelemetryExceptionService from "./TelemetryExceptionService";
134
+ import ExceptionInstanceService from "./ExceptionInstanceService";
135
+ import CopilotActionTypePriorityService from "./CopilotActionTypePriorityService";
133
136
 
134
137
  const services: Array<BaseService> = [
135
138
  AcmeCertificateService,
@@ -271,6 +274,9 @@ const services: Array<BaseService> = [
271
274
  CopilotActionService,
272
275
  ServiceCopilotCodeRepositoryService,
273
276
  CopilotPullRequestService,
277
+ CopilotActionTypePriorityService,
278
+
279
+ TelemetryExceptionService,
274
280
  ];
275
281
 
276
282
  export const AnalyticsServices: Array<
@@ -281,6 +287,7 @@ export const AnalyticsServices: Array<
281
287
  MetricService,
282
288
  MonitorMetricsByMinuteService,
283
289
  TelemetryAttributeService,
290
+ ExceptionInstanceService,
284
291
  ];
285
292
 
286
293
  export default services;
@@ -17,6 +17,7 @@ import AcmeCertificate from "Common/Models/DatabaseModels/AcmeCertificate";
17
17
  import Domain from "Common/Models/DatabaseModels/Domain";
18
18
  import StatusPageDomain from "Common/Models/DatabaseModels/StatusPageDomain";
19
19
  import AcmeCertificateService from "./AcmeCertificateService";
20
+ import Telemetry, { Span } from "../Utils/Telemetry";
20
21
 
21
22
  export class Service extends DatabaseService<StatusPageDomain> {
22
23
  public constructor() {
@@ -86,49 +87,79 @@ export class Service extends DatabaseService<StatusPageDomain> {
86
87
  }
87
88
 
88
89
  public async orderCert(statusPageDomain: StatusPageDomain): Promise<void> {
89
- if (!statusPageDomain.fullDomain) {
90
- const fetchedStatusPageDomain: StatusPageDomain | null =
91
- await this.findOneBy({
92
- query: {
93
- _id: statusPageDomain.id!.toString(),
94
- },
95
- select: {
96
- _id: true,
97
- fullDomain: true,
98
- },
99
- props: {
100
- isRoot: true,
101
- },
102
- });
103
-
104
- if (!fetchedStatusPageDomain) {
105
- throw new BadDataException("Domain not found");
106
- }
90
+ return Telemetry.startActiveSpan<Promise<void>>({
91
+ name: "StatusPageDomainService.orderCert",
92
+ options: {
93
+ attributes: {
94
+ fullDomain: statusPageDomain.fullDomain,
95
+ _id: statusPageDomain.id?.toString(),
96
+ },
97
+ },
98
+ fn: async (span: Span): Promise<void> => {
99
+ try {
100
+ if (!statusPageDomain.fullDomain) {
101
+ const fetchedStatusPageDomain: StatusPageDomain | null =
102
+ await this.findOneBy({
103
+ query: {
104
+ _id: statusPageDomain.id!.toString(),
105
+ },
106
+ select: {
107
+ _id: true,
108
+ fullDomain: true,
109
+ },
110
+ props: {
111
+ isRoot: true,
112
+ },
113
+ });
114
+
115
+ if (!fetchedStatusPageDomain) {
116
+ throw new BadDataException("Domain not found");
117
+ }
118
+
119
+ statusPageDomain = fetchedStatusPageDomain;
120
+ }
121
+
122
+ if (!statusPageDomain.fullDomain) {
123
+ throw new BadDataException(
124
+ "Unable to order certificate because domain is null",
125
+ );
126
+ }
127
+
128
+ logger.debug(
129
+ "Ordering SSL for domain: " + statusPageDomain.fullDomain,
130
+ );
107
131
 
108
- statusPageDomain = fetchedStatusPageDomain;
109
- }
132
+ await GreenlockUtil.orderCert({
133
+ domain: statusPageDomain.fullDomain as string,
134
+ validateCname: async (fullDomain: string) => {
135
+ return await this.isCnameValid(fullDomain);
136
+ },
137
+ });
110
138
 
111
- if (!statusPageDomain.fullDomain) {
112
- throw new BadDataException(
113
- "Unable to order certificate because domain is null",
114
- );
115
- }
139
+ logger.debug(
140
+ "SSL ordered for domain: " + statusPageDomain.fullDomain,
141
+ );
116
142
 
117
- await GreenlockUtil.orderCert({
118
- domain: statusPageDomain.fullDomain as string,
119
- validateCname: async (fullDomain: string) => {
120
- return await this.isCnameValid(fullDomain);
121
- },
122
- });
143
+ // update the order.
144
+ await this.updateOneById({
145
+ id: statusPageDomain.id!,
146
+ data: {
147
+ isSslOrdered: true,
148
+ },
149
+ props: {
150
+ isRoot: true,
151
+ },
152
+ });
153
+
154
+ Telemetry.endSpan(span);
155
+ } catch (err) {
156
+ Telemetry.recordExceptionMarkSpanAsErrorAndEndSpan({
157
+ span,
158
+ exception: err,
159
+ });
123
160
 
124
- // update the order.
125
- await this.updateOneById({
126
- id: statusPageDomain.id!,
127
- data: {
128
- isSslOrdered: true,
129
- },
130
- props: {
131
- isRoot: true,
161
+ throw err;
162
+ }
132
163
  },
133
164
  });
134
165
  }
@@ -215,6 +246,8 @@ export class Service extends DatabaseService<StatusPageDomain> {
215
246
  try {
216
247
  // get the token from the domain.
217
248
 
249
+ logger.debug("Checking for CNAME " + fullDomain);
250
+
218
251
  const statusPageDomain: StatusPageDomain | null = await this.findOneBy({
219
252
  query: {
220
253
  fullDomain: fullDomain,
@@ -234,6 +267,8 @@ export class Service extends DatabaseService<StatusPageDomain> {
234
267
 
235
268
  const token: string = statusPageDomain.cnameVerificationToken!;
236
269
 
270
+ logger.debug("Checking for CNAME " + fullDomain + " with token " + token);
271
+
237
272
  const result: HTTPErrorResponse | HTTPResponse<JSONObject> =
238
273
  await API.get(
239
274
  URL.fromString(
@@ -244,6 +279,9 @@ export class Service extends DatabaseService<StatusPageDomain> {
244
279
  ),
245
280
  );
246
281
 
282
+ logger.debug("CNAME verification result");
283
+ logger.debug(result);
284
+
247
285
  if (result.isSuccess()) {
248
286
  await this.updateCnameStatusForStatusPageDomain({
249
287
  domain: fullDomain,
@@ -265,6 +303,9 @@ export class Service extends DatabaseService<StatusPageDomain> {
265
303
  ),
266
304
  );
267
305
 
306
+ logger.debug("CNAME verification result for https");
307
+ logger.debug(resultHttps);
308
+
268
309
  if (resultHttps.isSuccess()) {
269
310
  await this.updateCnameStatusForStatusPageDomain({
270
311
  domain: fullDomain,
@@ -370,28 +411,46 @@ export class Service extends DatabaseService<StatusPageDomain> {
370
411
  }
371
412
 
372
413
  public async orderSSLForDomainsWhichAreNotOrderedYet(): Promise<void> {
373
- const domains: Array<StatusPageDomain> = await this.findBy({
374
- query: {
375
- isSslOrdered: false,
376
- },
377
- select: {
378
- _id: true,
379
- fullDomain: true,
380
- },
381
- limit: LIMIT_MAX,
382
- skip: 0,
383
- props: {
384
- isRoot: true,
414
+ return Telemetry.startActiveSpan<Promise<void>>({
415
+ name: "StatusPageDomainService.orderSSLForDomainsWhichAreNotOrderedYet",
416
+ options: { attributes: {} },
417
+ fn: async (span: Span): Promise<void> => {
418
+ try {
419
+ const domains: Array<StatusPageDomain> = await this.findBy({
420
+ query: {
421
+ isSslOrdered: false,
422
+ },
423
+ select: {
424
+ _id: true,
425
+ fullDomain: true,
426
+ },
427
+ limit: LIMIT_MAX,
428
+ skip: 0,
429
+ props: {
430
+ isRoot: true,
431
+ },
432
+ });
433
+
434
+ for (const domain of domains) {
435
+ try {
436
+ logger.debug("Ordering SSL for domain: " + domain.fullDomain);
437
+ await this.orderCert(domain);
438
+ } catch (e) {
439
+ logger.error(e);
440
+ }
441
+ }
442
+
443
+ Telemetry.endSpan(span);
444
+ } catch (err) {
445
+ Telemetry.recordExceptionMarkSpanAsErrorAndEndSpan({
446
+ span,
447
+ exception: err,
448
+ });
449
+
450
+ throw err;
451
+ }
385
452
  },
386
453
  });
387
-
388
- for (const domain of domains) {
389
- try {
390
- await this.orderCert(domain);
391
- } catch (e) {
392
- logger.error(e);
393
- }
394
- }
395
454
  }
396
455
 
397
456
  public async verifyCnameWhoseCnameisNotVerified(): Promise<void> {
@@ -0,0 +1,10 @@
1
+ import DatabaseService from "./DatabaseService";
2
+ import Model from "Common/Models/DatabaseModels/TelemetryException";
3
+
4
+ export class Service extends DatabaseService<Model> {
5
+ public constructor() {
6
+ super(Model);
7
+ }
8
+ }
9
+
10
+ export default new Service();
@@ -1,3 +1,4 @@
1
+ import QueryDeepPartialEntity from "../../../../Types/Database/PartialEntity";
1
2
  import Query from "../Query";
2
3
  import Select from "../Select";
3
4
  import CreatePermission from "./CreatePermission";
@@ -6,7 +7,6 @@ import ReadPermission, { CheckReadPermissionType } from "./ReadPermission";
6
7
  import UpdatePermission from "./UpdatePermission";
7
8
  import BaseModel from "Common/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
8
9
  import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
9
- import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
10
10
 
11
11
  export default class ModelPermission {
12
12
  public static async checkDeletePermissionByModel<
@@ -1,7 +1,7 @@
1
1
  import BaseModel from "Common/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
2
2
  import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
3
3
  import ObjectID from "Common/Types/ObjectID";
4
- import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
4
+ import QueryDeepPartialEntity from "../../../Types/Database/PartialEntity";
5
5
 
6
6
  export default interface UpdateBy<TBaseModel extends BaseModel> {
7
7
  id: ObjectID;
@@ -5,6 +5,7 @@ import ComponentMetadata, { Port } from "Common/Types/Workflow/Component";
5
5
  import ComponentID from "Common/Types/Workflow/ComponentID";
6
6
  import Components from "Common/Types/Workflow/Components/Email";
7
7
  import nodemailer, { Transporter } from "nodemailer";
8
+ import SMTPTransport from "nodemailer/lib/smtp-transport";
8
9
 
9
10
  export default class Email extends ComponentCode {
10
11
  public constructor() {
@@ -48,53 +49,49 @@ export default class Email extends ComponentCode {
48
49
  }
49
50
 
50
51
  if (!args["to"]) {
51
- throw options.onError(new BadDataException("to not found"));
52
+ throw options.onError(new BadDataException("To Email not found"));
52
53
  }
53
54
 
54
55
  if (args["to"] && typeof args["to"] !== "string") {
55
- throw options.onError(new BadDataException("to is not type of string"));
56
+ throw options.onError(
57
+ new BadDataException("To Email is not type of string"),
58
+ );
56
59
  }
57
60
 
58
61
  if (!args["from"]) {
59
- throw options.onError(new BadDataException("from not found"));
62
+ throw options.onError(new BadDataException("From Email not found"));
60
63
  }
61
64
 
62
65
  if (args["from"] && typeof args["from"] !== "string") {
63
- throw options.onError(new BadDataException("from is not type of string"));
64
- }
65
-
66
- if (!args["smtp-username"]) {
67
- throw options.onError(new BadDataException("email not found"));
66
+ throw options.onError(
67
+ new BadDataException("From Email is not type of string"),
68
+ );
68
69
  }
69
70
 
70
71
  if (args["smtp-username"] && typeof args["smtp-username"] !== "string") {
71
72
  throw options.onError(
72
- new BadDataException("smtp-username is not type of string"),
73
+ new BadDataException("SMTP Username is not type of string"),
73
74
  );
74
75
  }
75
76
 
76
- if (!args["smtp-password"]) {
77
- throw options.onError(new BadDataException("email not found"));
78
- }
79
-
80
77
  if (args["smtp-password"] && typeof args["smtp-password"] !== "string") {
81
78
  throw options.onError(
82
- new BadDataException("smtp-username is not type of string"),
79
+ new BadDataException("SMTP Password is not type of string"),
83
80
  );
84
81
  }
85
82
 
86
83
  if (!args["smtp-host"]) {
87
- throw options.onError(new BadDataException("email not found"));
84
+ throw options.onError(new BadDataException("SMTP Host not found"));
88
85
  }
89
86
 
90
87
  if (args["smtp-host"] && typeof args["smtp-host"] !== "string") {
91
88
  throw options.onError(
92
- new BadDataException("smtp-host is not type of string"),
89
+ new BadDataException("SMTP Host is not type of string"),
93
90
  );
94
91
  }
95
92
 
96
93
  if (!args["smtp-port"]) {
97
- throw options.onError(new BadDataException("email not found"));
94
+ throw options.onError(new BadDataException("SMTP Port not found"));
98
95
  }
99
96
 
100
97
  if (args["smtp-port"] && typeof args["smtp-port"] === "string") {
@@ -103,20 +100,30 @@ export default class Email extends ComponentCode {
103
100
 
104
101
  if (args["smtp-port"] && typeof args["smtp-port"] !== "number") {
105
102
  throw options.onError(
106
- new BadDataException("smtp-host is not type of number"),
103
+ new BadDataException("SMTP Port is not type of number"),
107
104
  );
108
105
  }
109
106
 
110
107
  try {
111
- const mailer: Transporter = nodemailer.createTransport({
108
+ const username: string | undefined =
109
+ args["smtp-username"]?.toString() || undefined;
110
+ const password: string | undefined =
111
+ args["smtp-password"]?.toString() || undefined;
112
+
113
+ const smtpTransport: SMTPTransport.Options = {
112
114
  host: args["smtp-host"]?.toString(),
113
115
  port: args["smtp-port"] as number,
114
116
  secure: Boolean(args["secure"]),
115
- auth: {
116
- user: args["smtp-username"] as string,
117
- pass: args["smtp-password"] as string,
118
- },
119
- });
117
+ };
118
+
119
+ if (username && password) {
120
+ smtpTransport.auth = {
121
+ user: username,
122
+ pass: password,
123
+ };
124
+ }
125
+
126
+ const mailer: Transporter = nodemailer.createTransport(smtpTransport);
120
127
 
121
128
  await mailer.sendMail({
122
129
  from: args["from"].toString(),
@@ -135,7 +142,7 @@ export default class Email extends ComponentCode {
135
142
  options.log(err as Error);
136
143
  return Promise.resolve({
137
144
  returnValues: {},
138
- executePort: successPort,
145
+ executePort: errorPort,
139
146
  });
140
147
  }
141
148
  }
@@ -3,9 +3,18 @@ import LocalFile from "../LocalFile";
3
3
  import logger from "../Logger";
4
4
  import CodeRepositoryFile from "./CodeRepositoryFile";
5
5
  import Dictionary from "Common/Types/Dictionary";
6
- import ServiceLanguageUtil from "Common/Utils/TechStack";
7
6
 
8
7
  export default class CodeRepositoryUtil {
8
+ public static getCurrentCommitHash(data: {
9
+ repoPath: string;
10
+ }): Promise<string> {
11
+ const command: string = `cd ${data.repoPath} && git rev-parse HEAD`;
12
+
13
+ logger.debug("Executing command: " + command);
14
+
15
+ return Execute.executeCommand(command);
16
+ }
17
+
9
18
  public static async addAllChangedFilesToGit(data: {
10
19
  repoPath: string;
11
20
  }): Promise<void> {
@@ -367,24 +376,11 @@ export default class CodeRepositoryUtil {
367
376
  }
368
377
  }
369
378
 
370
- const gitCommitHash: string = await this.getGitCommitHashForFile({
371
- filePath,
372
- repoPath,
373
- });
374
-
375
- const fileExtension: string = fileName.split(".").pop() || "";
376
379
  files[filePath] = {
377
- filePath: LocalFile.sanitizeFilePath(`${directoryPath}/${fileName}`),
378
- gitCommitHash,
379
- fileExtension,
380
- fileName,
381
380
  fileContent: await this.getFileContent({
382
381
  filePath: LocalFile.sanitizeFilePath(`${directoryPath}/${fileName}`),
383
382
  repoPath,
384
383
  }),
385
- fileLanguage: ServiceLanguageUtil.getLanguageByFileExtension({
386
- fileExtension,
387
- }),
388
384
  };
389
385
  }
390
386
 
@@ -1,10 +1,3 @@
1
- import TechStack from "Common/Types/ServiceCatalog/TechStack";
2
-
3
1
  export default interface CodeRepositoryFile {
4
- filePath: string;
5
- gitCommitHash: string;
6
- fileExtension: string;
7
- fileName: string;
8
2
  fileContent: string;
9
- fileLanguage: TechStack;
10
3
  }