@oneuptime/common 10.0.39 → 10.0.40

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 (282) hide show
  1. package/Models/AnalyticsModels/Index.ts +4 -0
  2. package/Models/AnalyticsModels/Profile.ts +687 -0
  3. package/Models/AnalyticsModels/ProfileSample.ts +547 -0
  4. package/Models/DatabaseModels/Dashboard.ts +357 -0
  5. package/Models/DatabaseModels/DashboardDomain.ts +658 -0
  6. package/Models/DatabaseModels/Index.ts +2 -0
  7. package/Models/DatabaseModels/StatusPage.ts +41 -0
  8. package/Server/API/DashboardAPI.ts +408 -0
  9. package/Server/API/DashboardDomainAPI.ts +235 -0
  10. package/Server/API/StatusPageAPI.ts +36 -2
  11. package/Server/API/TelemetryAPI.ts +393 -0
  12. package/Server/EnvironmentConfig.ts +12 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.ts +97 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.ts +17 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.ts +50 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.ts +59 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  18. package/Server/Middleware/UserAuthorization.ts +96 -1
  19. package/Server/Services/DashboardDomainService.ts +647 -0
  20. package/Server/Services/DashboardService.ts +174 -3
  21. package/Server/Services/IncidentService.ts +295 -50
  22. package/Server/Services/IncidentStateTimelineService.ts +1 -0
  23. package/Server/Services/Index.ts +6 -0
  24. package/Server/Services/MonitorService.ts +5 -0
  25. package/Server/Services/ProfileAggregationService.ts +559 -0
  26. package/Server/Services/ProfileSampleService.ts +11 -0
  27. package/Server/Services/ProfileService.ts +11 -0
  28. package/Server/Services/TelemetryUsageBillingService.ts +77 -3
  29. package/Server/Services/WorkspaceNotificationSummaryService.ts +15 -1
  30. package/Server/Types/Billing/MeteredPlan/AllMeteredPlans.ts +9 -0
  31. package/Server/Utils/Cookie.ts +48 -0
  32. package/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.ts +34 -0
  33. package/Server/Utils/Monitor/DataToProcess.ts +3 -1
  34. package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +299 -0
  35. package/Server/Utils/Profile/PprofEncoder.ts +225 -0
  36. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +53 -16
  37. package/Server/Utils/Workspace/Slack/Slack.ts +26 -6
  38. package/ServiceRoute.ts +2 -0
  39. package/Types/AnalyticsDatabase/AnalyticsTableName.ts +2 -0
  40. package/Types/CookieName.ts +1 -0
  41. package/Types/Dashboard/Chart/ChartType.ts +5 -0
  42. package/Types/Dashboard/DashboardComponentType.ts +4 -0
  43. package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +10 -0
  44. package/Types/Dashboard/DashboardComponents/DashboardChartComponent.ts +1 -2
  45. package/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.ts +17 -0
  46. package/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.ts +15 -0
  47. package/Types/Dashboard/DashboardComponents/DashboardTableComponent.ts +14 -0
  48. package/Types/Dashboard/DashboardComponents/DashboardTextComponent.ts +1 -0
  49. package/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.ts +13 -0
  50. package/Types/Dashboard/DashboardComponents/DashboardValueComponent.ts +2 -0
  51. package/Types/Dashboard/DashboardTemplates.ts +964 -0
  52. package/Types/Dashboard/DashboardVariable.ts +23 -0
  53. package/Types/Dashboard/DashboardViewConfig.ts +59 -0
  54. package/Types/Dashboard/MasterPassword.ts +10 -0
  55. package/Types/Icon/IconProp.ts +1 -0
  56. package/Types/Incident/IncidentMetricType.ts +3 -0
  57. package/Types/MeteredPlan/ProductType.ts +1 -0
  58. package/Types/Metrics/MetricQueryConfigData.ts +3 -0
  59. package/Types/Monitor/CriteriaFilter.ts +3 -0
  60. package/Types/Monitor/KubernetesAlertTemplates.ts +78 -7
  61. package/Types/Monitor/MetricMonitor/MetricMonitorResponse.ts +20 -0
  62. package/Types/Monitor/MonitorStep.ts +25 -0
  63. package/Types/Monitor/MonitorStepProfileMonitor.ts +96 -0
  64. package/Types/Monitor/MonitorType.ts +11 -0
  65. package/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.ts +12 -0
  66. package/Types/Permission.ts +87 -0
  67. package/Types/Telemetry/TelemetryType.ts +1 -0
  68. package/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.ts +1 -0
  69. package/UI/Components/Button/Button.tsx +1 -1
  70. package/UI/Components/Card/Card.tsx +8 -4
  71. package/UI/Components/Charts/Area/AreaChart.tsx +4 -0
  72. package/UI/Components/Charts/Bar/BarChart.tsx +4 -0
  73. package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +26 -0
  74. package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +26 -0
  75. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +26 -0
  76. package/UI/Components/Charts/Line/LineChart.tsx +4 -0
  77. package/UI/Components/Charts/Types/ReferenceLineProps.ts +6 -0
  78. package/UI/Components/Icon/Icon.tsx +33 -0
  79. package/UI/Components/ModelTable/BaseModelTable.tsx +13 -10
  80. package/UI/Components/MoreMenu/MoreMenu.tsx +15 -2
  81. package/UI/Components/MoreMenu/MoreMenuItem.tsx +4 -4
  82. package/UI/Components/Workflow/Component.tsx +450 -209
  83. package/UI/Components/Workflow/ComponentPortViewer.tsx +57 -20
  84. package/UI/Components/Workflow/ComponentReturnValueViewer.tsx +65 -25
  85. package/UI/Components/Workflow/ComponentSettingsModal.tsx +202 -37
  86. package/UI/Components/Workflow/ComponentsModal.tsx +180 -93
  87. package/UI/Components/Workflow/Workflow.tsx +105 -9
  88. package/UI/Config.ts +9 -0
  89. package/Utils/Dashboard/Components/DashboardChartComponent.ts +53 -22
  90. package/Utils/Dashboard/Components/DashboardGaugeComponent.ts +124 -0
  91. package/Utils/Dashboard/Components/DashboardLogStreamComponent.ts +110 -0
  92. package/Utils/Dashboard/Components/DashboardTableComponent.ts +86 -0
  93. package/Utils/Dashboard/Components/DashboardTextComponent.ts +32 -7
  94. package/Utils/Dashboard/Components/DashboardTraceListComponent.ts +86 -0
  95. package/Utils/Dashboard/Components/DashboardValueComponent.ts +39 -3
  96. package/Utils/Dashboard/Components/Index.ts +28 -0
  97. package/Utils/ValueFormatter.ts +170 -0
  98. package/build/dist/Models/AnalyticsModels/Index.js +4 -0
  99. package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
  100. package/build/dist/Models/AnalyticsModels/Profile.js +621 -0
  101. package/build/dist/Models/AnalyticsModels/Profile.js.map +1 -0
  102. package/build/dist/Models/AnalyticsModels/ProfileSample.js +497 -0
  103. package/build/dist/Models/AnalyticsModels/ProfileSample.js.map +1 -0
  104. package/build/dist/Models/DatabaseModels/Dashboard.js +365 -0
  105. package/build/dist/Models/DatabaseModels/Dashboard.js.map +1 -1
  106. package/build/dist/Models/DatabaseModels/DashboardDomain.js +691 -0
  107. package/build/dist/Models/DatabaseModels/DashboardDomain.js.map +1 -0
  108. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  109. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  110. package/build/dist/Models/DatabaseModels/StatusPage.js +42 -0
  111. package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
  112. package/build/dist/Server/API/DashboardAPI.js +293 -0
  113. package/build/dist/Server/API/DashboardAPI.js.map +1 -0
  114. package/build/dist/Server/API/DashboardDomainAPI.js +124 -0
  115. package/build/dist/Server/API/DashboardDomainAPI.js.map +1 -0
  116. package/build/dist/Server/API/StatusPageAPI.js +26 -2
  117. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  118. package/build/dist/Server/API/TelemetryAPI.js +222 -0
  119. package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
  120. package/build/dist/Server/EnvironmentConfig.js +4 -0
  121. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  122. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.js +40 -0
  123. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.js.map +1 -0
  124. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.js +12 -0
  125. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.js.map +1 -0
  126. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.js +23 -0
  127. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.js.map +1 -0
  128. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.js +26 -0
  129. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.js.map +1 -0
  130. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  131. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  132. package/build/dist/Server/Middleware/UserAuthorization.js +41 -0
  133. package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
  134. package/build/dist/Server/Services/DashboardDomainService.js +595 -0
  135. package/build/dist/Server/Services/DashboardDomainService.js.map +1 -0
  136. package/build/dist/Server/Services/DashboardService.js +117 -3
  137. package/build/dist/Server/Services/DashboardService.js.map +1 -1
  138. package/build/dist/Server/Services/IncidentService.js +231 -55
  139. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  140. package/build/dist/Server/Services/IncidentStateTimelineService.js +1 -1
  141. package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
  142. package/build/dist/Server/Services/Index.js +6 -0
  143. package/build/dist/Server/Services/Index.js.map +1 -1
  144. package/build/dist/Server/Services/MonitorService.js +5 -2
  145. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  146. package/build/dist/Server/Services/ProfileAggregationService.js +356 -0
  147. package/build/dist/Server/Services/ProfileAggregationService.js.map +1 -0
  148. package/build/dist/Server/Services/ProfileSampleService.js +9 -0
  149. package/build/dist/Server/Services/ProfileSampleService.js.map +1 -0
  150. package/build/dist/Server/Services/ProfileService.js +9 -0
  151. package/build/dist/Server/Services/ProfileService.js.map +1 -0
  152. package/build/dist/Server/Services/TelemetryUsageBillingService.js +61 -4
  153. package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
  154. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js +13 -1
  155. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js.map +1 -1
  156. package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js +8 -0
  157. package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js.map +1 -1
  158. package/build/dist/Server/Utils/Cookie.js +36 -0
  159. package/build/dist/Server/Utils/Cookie.js.map +1 -1
  160. package/build/dist/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.js +34 -0
  161. package/build/dist/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.js.map +1 -0
  162. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +173 -0
  163. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
  164. package/build/dist/Server/Utils/Profile/PprofEncoder.js +129 -0
  165. package/build/dist/Server/Utils/Profile/PprofEncoder.js.map +1 -0
  166. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +36 -14
  167. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  168. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +23 -6
  169. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  170. package/build/dist/ServiceRoute.js +1 -0
  171. package/build/dist/ServiceRoute.js.map +1 -1
  172. package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js +2 -0
  173. package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js.map +1 -1
  174. package/build/dist/Types/CookieName.js +1 -0
  175. package/build/dist/Types/CookieName.js.map +1 -1
  176. package/build/dist/Types/Dashboard/Chart/ChartType.js +5 -0
  177. package/build/dist/Types/Dashboard/Chart/ChartType.js.map +1 -1
  178. package/build/dist/Types/Dashboard/DashboardComponentType.js +4 -0
  179. package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
  180. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +1 -0
  181. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
  182. package/build/dist/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.js +2 -0
  183. package/build/dist/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.js.map +1 -0
  184. package/build/dist/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.js +2 -0
  185. package/build/dist/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.js.map +1 -0
  186. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTableComponent.js +2 -0
  187. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTableComponent.js.map +1 -0
  188. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.js +2 -0
  189. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.js.map +1 -0
  190. package/build/dist/Types/Dashboard/DashboardTemplates.js +853 -0
  191. package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -0
  192. package/build/dist/Types/Dashboard/DashboardVariable.js +7 -0
  193. package/build/dist/Types/Dashboard/DashboardVariable.js.map +1 -0
  194. package/build/dist/Types/Dashboard/DashboardViewConfig.js +50 -1
  195. package/build/dist/Types/Dashboard/DashboardViewConfig.js.map +1 -1
  196. package/build/dist/Types/Dashboard/MasterPassword.js +5 -0
  197. package/build/dist/Types/Dashboard/MasterPassword.js.map +1 -0
  198. package/build/dist/Types/Icon/IconProp.js +1 -0
  199. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  200. package/build/dist/Types/Incident/IncidentMetricType.js +3 -0
  201. package/build/dist/Types/Incident/IncidentMetricType.js.map +1 -1
  202. package/build/dist/Types/MeteredPlan/ProductType.js +1 -0
  203. package/build/dist/Types/MeteredPlan/ProductType.js.map +1 -1
  204. package/build/dist/Types/Metrics/MetricQueryConfigData.js +1 -0
  205. package/build/dist/Types/Metrics/MetricQueryConfigData.js.map +1 -1
  206. package/build/dist/Types/Monitor/CriteriaFilter.js +2 -0
  207. package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
  208. package/build/dist/Types/Monitor/KubernetesAlertTemplates.js +58 -7
  209. package/build/dist/Types/Monitor/KubernetesAlertTemplates.js.map +1 -1
  210. package/build/dist/Types/Monitor/MonitorStep.js +15 -0
  211. package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
  212. package/build/dist/Types/Monitor/MonitorStepProfileMonitor.js +59 -0
  213. package/build/dist/Types/Monitor/MonitorStepProfileMonitor.js.map +1 -0
  214. package/build/dist/Types/Monitor/MonitorType.js +10 -0
  215. package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
  216. package/build/dist/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.js +2 -0
  217. package/build/dist/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.js.map +1 -0
  218. package/build/dist/Types/Permission.js +75 -0
  219. package/build/dist/Types/Permission.js.map +1 -1
  220. package/build/dist/Types/Telemetry/TelemetryType.js +1 -0
  221. package/build/dist/Types/Telemetry/TelemetryType.js.map +1 -1
  222. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.js +1 -0
  223. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.js.map +1 -1
  224. package/build/dist/UI/Components/Button/Button.js +1 -1
  225. package/build/dist/UI/Components/Button/Button.js.map +1 -1
  226. package/build/dist/UI/Components/Card/Card.js +4 -4
  227. package/build/dist/UI/Components/Card/Card.js.map +1 -1
  228. package/build/dist/UI/Components/Charts/Area/AreaChart.js +1 -1
  229. package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
  230. package/build/dist/UI/Components/Charts/Bar/BarChart.js +1 -1
  231. package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
  232. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +5 -2
  233. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
  234. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +5 -2
  235. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
  236. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +6 -3
  237. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
  238. package/build/dist/UI/Components/Charts/Line/LineChart.js +1 -1
  239. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  240. package/build/dist/UI/Components/Charts/Types/ReferenceLineProps.js +2 -0
  241. package/build/dist/UI/Components/Charts/Types/ReferenceLineProps.js.map +1 -0
  242. package/build/dist/UI/Components/Icon/Icon.js +11 -0
  243. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  244. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +12 -9
  245. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  246. package/build/dist/UI/Components/MoreMenu/MoreMenu.js +8 -2
  247. package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
  248. package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js +4 -4
  249. package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js.map +1 -1
  250. package/build/dist/UI/Components/Workflow/Component.js +311 -143
  251. package/build/dist/UI/Components/Workflow/Component.js.map +1 -1
  252. package/build/dist/UI/Components/Workflow/ComponentPortViewer.js +44 -18
  253. package/build/dist/UI/Components/Workflow/ComponentPortViewer.js.map +1 -1
  254. package/build/dist/UI/Components/Workflow/ComponentReturnValueViewer.js +48 -22
  255. package/build/dist/UI/Components/Workflow/ComponentReturnValueViewer.js.map +1 -1
  256. package/build/dist/UI/Components/Workflow/ComponentSettingsModal.js +127 -21
  257. package/build/dist/UI/Components/Workflow/ComponentSettingsModal.js.map +1 -1
  258. package/build/dist/UI/Components/Workflow/ComponentsModal.js +107 -52
  259. package/build/dist/UI/Components/Workflow/ComponentsModal.js.map +1 -1
  260. package/build/dist/UI/Components/Workflow/Workflow.js +87 -12
  261. package/build/dist/UI/Components/Workflow/Workflow.js.map +1 -1
  262. package/build/dist/UI/Config.js +3 -1
  263. package/build/dist/UI/Config.js.map +1 -1
  264. package/build/dist/Utils/Dashboard/Components/DashboardChartComponent.js +50 -21
  265. package/build/dist/Utils/Dashboard/Components/DashboardChartComponent.js.map +1 -1
  266. package/build/dist/Utils/Dashboard/Components/DashboardGaugeComponent.js +104 -0
  267. package/build/dist/Utils/Dashboard/Components/DashboardGaugeComponent.js.map +1 -0
  268. package/build/dist/Utils/Dashboard/Components/DashboardLogStreamComponent.js +91 -0
  269. package/build/dist/Utils/Dashboard/Components/DashboardLogStreamComponent.js.map +1 -0
  270. package/build/dist/Utils/Dashboard/Components/DashboardTableComponent.js +70 -0
  271. package/build/dist/Utils/Dashboard/Components/DashboardTableComponent.js.map +1 -0
  272. package/build/dist/Utils/Dashboard/Components/DashboardTextComponent.js +28 -7
  273. package/build/dist/Utils/Dashboard/Components/DashboardTextComponent.js.map +1 -1
  274. package/build/dist/Utils/Dashboard/Components/DashboardTraceListComponent.js +70 -0
  275. package/build/dist/Utils/Dashboard/Components/DashboardTraceListComponent.js.map +1 -0
  276. package/build/dist/Utils/Dashboard/Components/DashboardValueComponent.js +34 -3
  277. package/build/dist/Utils/Dashboard/Components/DashboardValueComponent.js.map +1 -1
  278. package/build/dist/Utils/Dashboard/Components/Index.js +16 -0
  279. package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
  280. package/build/dist/Utils/ValueFormatter.js +132 -0
  281. package/build/dist/Utils/ValueFormatter.js.map +1 -0
  282. package/package.json +1 -1
@@ -0,0 +1,647 @@
1
+ import CreateBy from "../Types/Database/CreateBy";
2
+ import DeleteBy from "../Types/Database/DeleteBy";
3
+ import { OnCreate, OnDelete } from "../Types/Database/Hooks";
4
+ import GreenlockUtil from "../Utils/Greenlock/Greenlock";
5
+ import logger from "../Utils/Logger";
6
+ import DatabaseService from "./DatabaseService";
7
+ import DomainService from "./DomainService";
8
+ import HTTPErrorResponse from "../../Types/API/HTTPErrorResponse";
9
+ import HTTPResponse from "../../Types/API/HTTPResponse";
10
+ import URL from "../../Types/API/URL";
11
+ import LIMIT_MAX from "../../Types/Database/LimitMax";
12
+ import BadDataException from "../../Types/Exception/BadDataException";
13
+ import { JSONObject } from "../../Types/JSON";
14
+ import ObjectID from "../../Types/ObjectID";
15
+ import API from "../../Utils/API";
16
+ import AcmeCertificate from "../../Models/DatabaseModels/AcmeCertificate";
17
+ import DomainModel from "../../Models/DatabaseModels/Domain";
18
+ import DashboardDomain from "../../Models/DatabaseModels/DashboardDomain";
19
+ import AcmeCertificateService from "./AcmeCertificateService";
20
+ import Telemetry, { Span } from "../Utils/Telemetry";
21
+ import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
22
+ import { DashboardCNameRecord } from "../EnvironmentConfig";
23
+ import Domain from "../Types/Domain";
24
+
25
+ export class Service extends DatabaseService<DashboardDomain> {
26
+ public constructor() {
27
+ super(DashboardDomain);
28
+ }
29
+
30
+ @CaptureSpan()
31
+ protected override async onBeforeCreate(
32
+ createBy: CreateBy<DashboardDomain>,
33
+ ): Promise<OnCreate<DashboardDomain>> {
34
+ const domain: DomainModel | null = await DomainService.findOneBy({
35
+ query: {
36
+ _id:
37
+ createBy.data.domainId?.toString() || createBy.data.domain?._id || "",
38
+ },
39
+ select: { domain: true, isVerified: true },
40
+ props: {
41
+ isRoot: true,
42
+ },
43
+ });
44
+
45
+ if (!domain?.isVerified) {
46
+ throw new BadDataException(
47
+ "This domain is not verified. Please verify it by going to Settings > Domains",
48
+ );
49
+ }
50
+
51
+ let normalizedSubdomain: string =
52
+ createBy.data.subdomain?.trim().toLowerCase() || "";
53
+
54
+ if (normalizedSubdomain === "@") {
55
+ normalizedSubdomain = "";
56
+ }
57
+
58
+ createBy.data.subdomain = normalizedSubdomain;
59
+
60
+ if (domain) {
61
+ const baseDomain: string =
62
+ domain.domain?.toString().toLowerCase().trim() || "";
63
+
64
+ if (!baseDomain) {
65
+ throw new BadDataException("Please select a valid domain.");
66
+ }
67
+
68
+ createBy.data.fullDomain = normalizedSubdomain
69
+ ? `${normalizedSubdomain}.${baseDomain}`
70
+ : baseDomain;
71
+ }
72
+
73
+ createBy.data.cnameVerificationToken = ObjectID.generate().toString();
74
+
75
+ if (createBy.data.isCustomCertificate) {
76
+ if (
77
+ !createBy.data.customCertificate ||
78
+ !createBy.data.customCertificateKey
79
+ ) {
80
+ throw new BadDataException(
81
+ "Custom certificate or private key is missing",
82
+ );
83
+ }
84
+ }
85
+
86
+ return { createBy, carryForward: null };
87
+ }
88
+
89
+ @CaptureSpan()
90
+ protected override async onBeforeDelete(
91
+ deleteBy: DeleteBy<DashboardDomain>,
92
+ ): Promise<OnDelete<DashboardDomain>> {
93
+ const domains: Array<DashboardDomain> = await this.findBy({
94
+ query: {
95
+ ...deleteBy.query,
96
+ },
97
+ skip: 0,
98
+ limit: LIMIT_MAX,
99
+ select: { fullDomain: true },
100
+ props: {
101
+ isRoot: true,
102
+ },
103
+ });
104
+
105
+ return { deleteBy, carryForward: domains };
106
+ }
107
+
108
+ @CaptureSpan()
109
+ protected override async onDeleteSuccess(
110
+ onDelete: OnDelete<DashboardDomain>,
111
+ _itemIdsBeforeDelete: ObjectID[],
112
+ ): Promise<OnDelete<DashboardDomain>> {
113
+ for (const domain of onDelete.carryForward) {
114
+ await this.removeDomainFromGreenlock(domain.fullDomain as string);
115
+ }
116
+
117
+ return onDelete;
118
+ }
119
+
120
+ @CaptureSpan()
121
+ public async removeDomainFromGreenlock(domain: string): Promise<void> {
122
+ await GreenlockUtil.removeDomain(domain);
123
+ }
124
+
125
+ @CaptureSpan()
126
+ public async orderCert(dashboardDomain: DashboardDomain): Promise<void> {
127
+ return Telemetry.startActiveSpan<Promise<void>>({
128
+ name: "DashboardDomainService.orderCert",
129
+ options: {
130
+ attributes: {
131
+ fullDomain: dashboardDomain.fullDomain,
132
+ _id: dashboardDomain.id?.toString(),
133
+ },
134
+ },
135
+ fn: async (span: Span): Promise<void> => {
136
+ try {
137
+ if (!dashboardDomain.fullDomain) {
138
+ const fetchedDashboardDomain: DashboardDomain | null =
139
+ await this.findOneBy({
140
+ query: {
141
+ _id: dashboardDomain.id!.toString(),
142
+ },
143
+ select: {
144
+ _id: true,
145
+ fullDomain: true,
146
+ },
147
+ props: {
148
+ isRoot: true,
149
+ },
150
+ });
151
+
152
+ if (!fetchedDashboardDomain) {
153
+ throw new BadDataException("DomainModel not found");
154
+ }
155
+
156
+ dashboardDomain = fetchedDashboardDomain;
157
+ }
158
+
159
+ if (!dashboardDomain.fullDomain) {
160
+ throw new BadDataException(
161
+ "Unable to order certificate because domain is null",
162
+ );
163
+ }
164
+
165
+ logger.debug(
166
+ "Ordering SSL for domain: " + dashboardDomain.fullDomain,
167
+ );
168
+
169
+ await GreenlockUtil.orderCert({
170
+ domain: dashboardDomain.fullDomain as string,
171
+ validateCname: async (fullDomain: string) => {
172
+ return await this.isCnameValid(fullDomain);
173
+ },
174
+ });
175
+
176
+ logger.debug("SSL ordered for domain: " + dashboardDomain.fullDomain);
177
+
178
+ await this.updateOneById({
179
+ id: dashboardDomain.id!,
180
+ data: {
181
+ isSslOrdered: true,
182
+ },
183
+ props: {
184
+ isRoot: true,
185
+ },
186
+ });
187
+
188
+ Telemetry.endSpan(span);
189
+ } catch (err) {
190
+ Telemetry.recordExceptionMarkSpanAsErrorAndEndSpan({
191
+ span,
192
+ exception: err,
193
+ });
194
+
195
+ throw err;
196
+ }
197
+ },
198
+ });
199
+ }
200
+
201
+ @CaptureSpan()
202
+ public async updateSslProvisioningStatusForAllDomains(): Promise<void> {
203
+ const domains: Array<DashboardDomain> = await this.findBy({
204
+ query: {
205
+ isSslOrdered: true,
206
+ isCustomCertificate: false,
207
+ },
208
+ select: {
209
+ _id: true,
210
+ },
211
+ limit: LIMIT_MAX,
212
+ skip: 0,
213
+ props: {
214
+ isRoot: true,
215
+ },
216
+ });
217
+
218
+ for (const domain of domains) {
219
+ await this.updateSslProvisioningStatus(domain);
220
+ }
221
+ }
222
+
223
+ private async isSSLProvisioned(
224
+ fulldomain: string,
225
+ token: string,
226
+ ): Promise<boolean> {
227
+ try {
228
+ const result: HTTPErrorResponse | HTTPResponse<JSONObject> =
229
+ await API.get({
230
+ url: URL.fromString(
231
+ "https://" +
232
+ fulldomain +
233
+ "/dashboard-api/cname-verification/" +
234
+ token,
235
+ ),
236
+ });
237
+
238
+ if (result.isFailure()) {
239
+ return false;
240
+ }
241
+
242
+ return true;
243
+ } catch (err) {
244
+ logger.error(err);
245
+ return false;
246
+ }
247
+ }
248
+
249
+ @CaptureSpan()
250
+ public async updateCnameStatusForDashboardDomain(data: {
251
+ domain: string;
252
+ cnameStatus: boolean;
253
+ }): Promise<void> {
254
+ if (!data.cnameStatus) {
255
+ await this.updateOneBy({
256
+ query: {
257
+ fullDomain: data.domain,
258
+ },
259
+ data: {
260
+ isCnameVerified: false,
261
+ isSslOrdered: false,
262
+ isSslProvisioned: false,
263
+ },
264
+ props: {
265
+ isRoot: true,
266
+ },
267
+ });
268
+ } else {
269
+ await this.updateOneBy({
270
+ query: {
271
+ fullDomain: data.domain,
272
+ },
273
+ data: {
274
+ isCnameVerified: true,
275
+ },
276
+ props: {
277
+ isRoot: true,
278
+ },
279
+ });
280
+ }
281
+ }
282
+
283
+ @CaptureSpan()
284
+ public async isCnameValid(fullDomain: string): Promise<boolean> {
285
+ try {
286
+ logger.debug("Checking for CNAME " + fullDomain);
287
+
288
+ const dashboardDomain: DashboardDomain | null = await this.findOneBy({
289
+ query: {
290
+ fullDomain: fullDomain,
291
+ },
292
+ select: {
293
+ _id: true,
294
+ cnameVerificationToken: true,
295
+ },
296
+ props: {
297
+ isRoot: true,
298
+ },
299
+ });
300
+
301
+ if (!dashboardDomain) {
302
+ return false;
303
+ }
304
+
305
+ const token: string = dashboardDomain.cnameVerificationToken!;
306
+
307
+ logger.debug("Checking for CNAME " + fullDomain + " with token " + token);
308
+
309
+ try {
310
+ const result: HTTPErrorResponse | HTTPResponse<JSONObject> =
311
+ await API.get({
312
+ url: URL.fromString(
313
+ "http://" +
314
+ fullDomain +
315
+ "/dashboard-api/cname-verification/" +
316
+ token,
317
+ ),
318
+ });
319
+
320
+ logger.debug("CNAME verification result");
321
+ logger.debug(result);
322
+
323
+ if (result.isSuccess()) {
324
+ await this.updateCnameStatusForDashboardDomain({
325
+ domain: fullDomain,
326
+ cnameStatus: true,
327
+ });
328
+
329
+ return true;
330
+ }
331
+ } catch (err) {
332
+ logger.debug("Failed checking for CNAME " + fullDomain);
333
+ logger.debug(err);
334
+ }
335
+
336
+ try {
337
+ const resultHttps: HTTPErrorResponse | HTTPResponse<JSONObject> =
338
+ await API.get({
339
+ url: URL.fromString(
340
+ "https://" +
341
+ fullDomain +
342
+ "/dashboard-api/cname-verification/" +
343
+ token,
344
+ ),
345
+ });
346
+
347
+ logger.debug("CNAME verification result for https");
348
+ logger.debug(resultHttps);
349
+
350
+ if (resultHttps.isSuccess()) {
351
+ await this.updateCnameStatusForDashboardDomain({
352
+ domain: fullDomain,
353
+ cnameStatus: true,
354
+ });
355
+
356
+ return true;
357
+ }
358
+ } catch (err) {
359
+ logger.debug("Failed checking for CNAME " + fullDomain);
360
+ logger.debug(err);
361
+ }
362
+
363
+ try {
364
+ if (DashboardCNameRecord) {
365
+ const cnameRecords: Array<string> = await Domain.getCnameRecords({
366
+ domain: fullDomain,
367
+ });
368
+
369
+ let cnameRecord: string | undefined = undefined;
370
+ if (cnameRecords.length > 0) {
371
+ cnameRecord = cnameRecords[0];
372
+ }
373
+
374
+ if (!cnameRecord) {
375
+ logger.debug(
376
+ `No CNAME record found for ${fullDomain}. Expected record: ${DashboardCNameRecord}`,
377
+ );
378
+ await this.updateCnameStatusForDashboardDomain({
379
+ domain: fullDomain,
380
+ cnameStatus: false,
381
+ });
382
+ return false;
383
+ }
384
+
385
+ if (
386
+ cnameRecord &&
387
+ cnameRecord.trim().toLocaleLowerCase() ===
388
+ DashboardCNameRecord.trim().toLocaleLowerCase()
389
+ ) {
390
+ logger.debug(
391
+ `CNAME record for ${fullDomain} matches the expected record: ${DashboardCNameRecord}`,
392
+ );
393
+
394
+ await this.updateCnameStatusForDashboardDomain({
395
+ domain: fullDomain,
396
+ cnameStatus: true,
397
+ });
398
+
399
+ return true;
400
+ }
401
+
402
+ logger.debug(
403
+ `CNAME record for ${fullDomain} is ${cnameRecord} and it does not match the expected record: ${DashboardCNameRecord}`,
404
+ );
405
+ }
406
+ } catch (err) {
407
+ logger.debug("Failed checking for CNAME " + fullDomain);
408
+ logger.debug(err);
409
+ }
410
+
411
+ await this.updateCnameStatusForDashboardDomain({
412
+ domain: fullDomain,
413
+ cnameStatus: false,
414
+ });
415
+
416
+ return false;
417
+ } catch (err) {
418
+ logger.debug("Failed checking for CNAME " + fullDomain);
419
+ logger.debug(err);
420
+
421
+ await this.updateCnameStatusForDashboardDomain({
422
+ domain: fullDomain,
423
+ cnameStatus: false,
424
+ });
425
+
426
+ return false;
427
+ }
428
+ }
429
+
430
+ @CaptureSpan()
431
+ public async updateSslProvisioningStatus(
432
+ domain: DashboardDomain,
433
+ ): Promise<void> {
434
+ if (!domain.id) {
435
+ throw new BadDataException("DomainModel ID is required");
436
+ }
437
+
438
+ const dashboardDomain: DashboardDomain | null = await this.findOneBy({
439
+ query: {
440
+ _id: domain.id?.toString(),
441
+ },
442
+ select: {
443
+ _id: true,
444
+ fullDomain: true,
445
+ cnameVerificationToken: true,
446
+ },
447
+ props: {
448
+ isRoot: true,
449
+ },
450
+ });
451
+
452
+ if (!dashboardDomain) {
453
+ throw new BadDataException("DomainModel not found");
454
+ }
455
+
456
+ logger.debug(
457
+ `DashboardCerts:RemoveCerts - Checking CNAME ${dashboardDomain.fullDomain}`,
458
+ );
459
+
460
+ const isValid: boolean = await this.isSSLProvisioned(
461
+ dashboardDomain.fullDomain!,
462
+ dashboardDomain.cnameVerificationToken!,
463
+ );
464
+
465
+ if (!isValid) {
466
+ const isCnameValid: boolean = await this.isCnameValid(
467
+ dashboardDomain.fullDomain!,
468
+ );
469
+
470
+ await this.updateOneById({
471
+ id: dashboardDomain.id!,
472
+ data: {
473
+ isSslProvisioned: false,
474
+ },
475
+ props: {
476
+ isRoot: true,
477
+ },
478
+ });
479
+
480
+ if (isCnameValid) {
481
+ try {
482
+ await this.orderCert(dashboardDomain);
483
+ } catch (err) {
484
+ logger.error(
485
+ "Cannot order cert for domain: " + dashboardDomain.fullDomain,
486
+ );
487
+ logger.error(err);
488
+ }
489
+ }
490
+ } else {
491
+ await this.updateOneById({
492
+ id: dashboardDomain.id!,
493
+ data: {
494
+ isSslProvisioned: true,
495
+ },
496
+ props: {
497
+ isRoot: true,
498
+ },
499
+ });
500
+ }
501
+ }
502
+
503
+ @CaptureSpan()
504
+ public async orderSSLForDomainsWhichAreNotOrderedYet(): Promise<void> {
505
+ return Telemetry.startActiveSpan<Promise<void>>({
506
+ name: "DashboardDomainService.orderSSLForDomainsWhichAreNotOrderedYet",
507
+ options: { attributes: {} },
508
+ fn: async (span: Span): Promise<void> => {
509
+ try {
510
+ const domains: Array<DashboardDomain> = await this.findBy({
511
+ query: {
512
+ isSslOrdered: false,
513
+ isCustomCertificate: false,
514
+ },
515
+ select: {
516
+ _id: true,
517
+ fullDomain: true,
518
+ },
519
+ limit: LIMIT_MAX,
520
+ skip: 0,
521
+ props: {
522
+ isRoot: true,
523
+ },
524
+ });
525
+
526
+ for (const domain of domains) {
527
+ try {
528
+ logger.debug("Ordering SSL for domain: " + domain.fullDomain);
529
+ await this.orderCert(domain);
530
+ } catch (e) {
531
+ logger.error(e);
532
+ }
533
+ }
534
+
535
+ Telemetry.endSpan(span);
536
+ } catch (err) {
537
+ Telemetry.recordExceptionMarkSpanAsErrorAndEndSpan({
538
+ span,
539
+ exception: err,
540
+ });
541
+
542
+ throw err;
543
+ }
544
+ },
545
+ });
546
+ }
547
+
548
+ @CaptureSpan()
549
+ public async verifyCnameWhoseCnameisNotVerified(): Promise<void> {
550
+ const domains: Array<DashboardDomain> = await this.findBy({
551
+ query: {
552
+ isCnameVerified: false,
553
+ },
554
+ select: {
555
+ _id: true,
556
+ fullDomain: true,
557
+ },
558
+ limit: LIMIT_MAX,
559
+ skip: 0,
560
+ props: {
561
+ isRoot: true,
562
+ },
563
+ });
564
+
565
+ for (const domain of domains) {
566
+ try {
567
+ await this.isCnameValid(domain.fullDomain as string);
568
+ } catch (e) {
569
+ logger.error(e);
570
+ }
571
+ }
572
+ }
573
+
574
+ @CaptureSpan()
575
+ public async renewCertsWhichAreExpiringSoon(): Promise<void> {
576
+ await GreenlockUtil.renewAllCertsWhichAreExpiringSoon({
577
+ validateCname: async (fullDomain: string) => {
578
+ return await this.isCnameValid(fullDomain);
579
+ },
580
+ notifyDomainRemoved: async (domain: string) => {
581
+ await this.updateOneBy({
582
+ query: {
583
+ fullDomain: domain,
584
+ },
585
+ data: {
586
+ isSslOrdered: false,
587
+ isSslProvisioned: false,
588
+ },
589
+ props: {
590
+ isRoot: true,
591
+ },
592
+ });
593
+
594
+ logger.debug(`DomainModel removed from greenlock: ${domain}`);
595
+ },
596
+ });
597
+ }
598
+
599
+ @CaptureSpan()
600
+ public async checkOrderStatus(): Promise<void> {
601
+ const domains: Array<DashboardDomain> = await this.findBy({
602
+ query: {
603
+ isSslOrdered: true,
604
+ isCustomCertificate: false,
605
+ },
606
+ select: {
607
+ _id: true,
608
+ fullDomain: true,
609
+ cnameVerificationToken: true,
610
+ },
611
+ limit: LIMIT_MAX,
612
+ skip: 0,
613
+ props: {
614
+ isRoot: true,
615
+ },
616
+ });
617
+
618
+ for (const domain of domains) {
619
+ if (!domain.fullDomain) {
620
+ continue;
621
+ }
622
+
623
+ const acmeCert: AcmeCertificate | null =
624
+ await AcmeCertificateService.findOneBy({
625
+ query: {
626
+ domain: domain.fullDomain,
627
+ },
628
+ select: {
629
+ _id: true,
630
+ },
631
+ props: {
632
+ isRoot: true,
633
+ },
634
+ });
635
+
636
+ if (!acmeCert) {
637
+ try {
638
+ await this.orderCert(domain);
639
+ } catch (err) {
640
+ logger.error("Cannot order cert for domain: " + domain.fullDomain);
641
+ logger.error(err);
642
+ }
643
+ }
644
+ }
645
+ }
646
+ }
647
+ export default new Service();