@oneuptime/common 9.2.12 → 9.2.14

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 (190) hide show
  1. package/Models/DatabaseModels/AlertInternalNote.ts +29 -0
  2. package/Models/DatabaseModels/IncidentInternalNote.ts +29 -0
  3. package/Models/DatabaseModels/IncidentPublicNote.ts +29 -0
  4. package/Models/DatabaseModels/Index.ts +3 -11
  5. package/Models/DatabaseModels/{CopilotPullRequest.ts → LlmProvider.ts} +243 -248
  6. package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.ts +29 -0
  7. package/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts +29 -0
  8. package/Server/API/LlmProviderAPI.ts +57 -0
  9. package/Server/API/MicrosoftTeamsAPI.ts +2 -146
  10. package/Server/API/SlackAPI.ts +105 -0
  11. package/Server/API/StatusPageAPI.ts +6 -0
  12. package/Server/Infrastructure/Postgres/SchemaMigrations/1765477339178-MigrationName.ts +71 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1765540325149-MigrationName.ts +45 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1765540549739-MigrationName.ts +61 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1765544010078-MigrationName.ts +35 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  17. package/Server/Middleware/SlackAuthorization.ts +4 -1
  18. package/Server/Services/AlertInternalNoteService.ts +26 -0
  19. package/Server/Services/IncidentInternalNoteService.ts +26 -0
  20. package/Server/Services/IncidentPublicNoteService.ts +26 -0
  21. package/Server/Services/Index.ts +2 -11
  22. package/Server/Services/LlmProviderService.ts +100 -0
  23. package/Server/Services/ScheduledMaintenanceInternalNoteService.ts +26 -0
  24. package/Server/Services/ScheduledMaintenancePublicNoteService.ts +26 -0
  25. package/Server/Services/StatusPageService.ts +3 -0
  26. package/Server/Utils/Express.ts +1 -0
  27. package/Server/Utils/StartServer.ts +5 -0
  28. package/Server/Utils/StatusPageResource.ts +89 -0
  29. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +96 -55
  30. package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +16 -0
  31. package/Server/Utils/Workspace/Slack/Actions/Alert.ts +184 -1
  32. package/Server/Utils/Workspace/Slack/Actions/Incident.ts +224 -1
  33. package/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.ts +232 -1
  34. package/Server/Utils/Workspace/Slack/Slack.ts +113 -0
  35. package/Server/Utils/Workspace/Slack/app-manifest.json +13 -2
  36. package/Tests/Server/Utils/StatusPageResource.test.ts +161 -0
  37. package/Types/Icon/IconProp.ts +1 -0
  38. package/Types/LLM/Index.ts +4 -0
  39. package/Types/LLM/LlmType.ts +7 -0
  40. package/Types/Permission.ts +38 -113
  41. package/UI/Components/Icon/Icon.tsx +8 -0
  42. package/UI/Components/Link/Link.tsx +5 -1
  43. package/build/dist/Models/DatabaseModels/AlertInternalNote.js +30 -0
  44. package/build/dist/Models/DatabaseModels/AlertInternalNote.js.map +1 -1
  45. package/build/dist/Models/DatabaseModels/IncidentInternalNote.js +30 -0
  46. package/build/dist/Models/DatabaseModels/IncidentInternalNote.js.map +1 -1
  47. package/build/dist/Models/DatabaseModels/IncidentPublicNote.js +30 -0
  48. package/build/dist/Models/DatabaseModels/IncidentPublicNote.js.map +1 -1
  49. package/build/dist/Models/DatabaseModels/Index.js +2 -10
  50. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  51. package/build/dist/Models/DatabaseModels/{CopilotPullRequest.js → LlmProvider.js} +263 -255
  52. package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -0
  53. package/build/dist/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +30 -0
  54. package/build/dist/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js.map +1 -1
  55. package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +30 -0
  56. package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js.map +1 -1
  57. package/build/dist/Server/API/LlmProviderAPI.js +36 -0
  58. package/build/dist/Server/API/LlmProviderAPI.js.map +1 -0
  59. package/build/dist/Server/API/MicrosoftTeamsAPI.js +2 -91
  60. package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
  61. package/build/dist/Server/API/SlackAPI.js +74 -0
  62. package/build/dist/Server/API/SlackAPI.js.map +1 -1
  63. package/build/dist/Server/API/StatusPageAPI.js +6 -0
  64. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  65. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765477339178-MigrationName.js +30 -0
  66. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765477339178-MigrationName.js.map +1 -0
  67. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765540325149-MigrationName.js +22 -0
  68. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765540325149-MigrationName.js.map +1 -0
  69. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765540549739-MigrationName.js +39 -0
  70. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765540549739-MigrationName.js.map +1 -0
  71. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765544010078-MigrationName.js +18 -0
  72. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765544010078-MigrationName.js.map +1 -0
  73. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  74. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  75. package/build/dist/Server/Middleware/SlackAuthorization.js +4 -1
  76. package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
  77. package/build/dist/Server/Services/AlertInternalNoteService.js +24 -0
  78. package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
  79. package/build/dist/Server/Services/IncidentInternalNoteService.js +24 -0
  80. package/build/dist/Server/Services/IncidentInternalNoteService.js.map +1 -1
  81. package/build/dist/Server/Services/IncidentPublicNoteService.js +24 -0
  82. package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
  83. package/build/dist/Server/Services/Index.js +2 -10
  84. package/build/dist/Server/Services/Index.js.map +1 -1
  85. package/build/dist/Server/Services/LlmProviderService.js +85 -0
  86. package/build/dist/Server/Services/LlmProviderService.js.map +1 -0
  87. package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js +24 -0
  88. package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js.map +1 -1
  89. package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +24 -0
  90. package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
  91. package/build/dist/Server/Services/StatusPageService.js +3 -0
  92. package/build/dist/Server/Services/StatusPageService.js.map +1 -1
  93. package/build/dist/Server/Utils/Express.js.map +1 -1
  94. package/build/dist/Server/Utils/StartServer.js +5 -0
  95. package/build/dist/Server/Utils/StartServer.js.map +1 -1
  96. package/build/dist/Server/Utils/StatusPageResource.js +68 -0
  97. package/build/dist/Server/Utils/StatusPageResource.js.map +1 -0
  98. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +73 -42
  99. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  100. package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +13 -0
  101. package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -1
  102. package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js +143 -1
  103. package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js.map +1 -1
  104. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +173 -1
  105. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -1
  106. package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js +173 -1
  107. package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js.map +1 -1
  108. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +92 -0
  109. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  110. package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +12 -2
  111. package/build/dist/Tests/Server/Utils/StatusPageResource.test.js +122 -0
  112. package/build/dist/Tests/Server/Utils/StatusPageResource.test.js.map +1 -0
  113. package/build/dist/Types/Icon/IconProp.js +1 -0
  114. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  115. package/build/dist/Types/LLM/Index.js +4 -0
  116. package/build/dist/Types/LLM/Index.js.map +1 -0
  117. package/build/dist/Types/LLM/LlmType.js +8 -0
  118. package/build/dist/Types/LLM/LlmType.js.map +1 -0
  119. package/build/dist/Types/Permission.js +32 -97
  120. package/build/dist/Types/Permission.js.map +1 -1
  121. package/build/dist/UI/Components/Icon/Icon.js +3 -0
  122. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  123. package/build/dist/UI/Components/Link/Link.js +4 -1
  124. package/build/dist/UI/Components/Link/Link.js.map +1 -1
  125. package/package.json +5 -1
  126. package/Models/DatabaseModels/CopilotAction.ts +0 -772
  127. package/Models/DatabaseModels/CopilotActionTypePriority.ts +0 -340
  128. package/Models/DatabaseModels/CopilotCodeRepository.ts +0 -637
  129. package/Models/DatabaseModels/ServiceCopilotCodeRepository.ts +0 -544
  130. package/Server/API/CopilotActionAPI.ts +0 -418
  131. package/Server/API/CopilotCodeRepositoryAPI.ts +0 -127
  132. package/Server/API/CopilotPullRequestAPI.ts +0 -243
  133. package/Server/Docs/CodeRepository.md +0 -43
  134. package/Server/Middleware/CodeRepositoryAuthorization.ts +0 -50
  135. package/Server/Services/CopilotActionService.ts +0 -10
  136. package/Server/Services/CopilotActionTypePriorityService.ts +0 -67
  137. package/Server/Services/CopilotCodeRepositoryService.ts +0 -62
  138. package/Server/Services/CopilotPullRequestService.ts +0 -10
  139. package/Server/Services/ServiceCopilotCodeRepositoryService.ts +0 -10
  140. package/Types/Copilot/CopilotActionProps/DirectoryActionProp.ts +0 -3
  141. package/Types/Copilot/CopilotActionProps/ExceptionActionProp.ts +0 -4
  142. package/Types/Copilot/CopilotActionProps/FileActionProp.ts +0 -7
  143. package/Types/Copilot/CopilotActionProps/FunctionActionProp.ts +0 -5
  144. package/Types/Copilot/CopilotActionProps/Index.ts +0 -96
  145. package/Types/Copilot/CopilotActionProps/SpanActionProp.ts +0 -4
  146. package/Types/Copilot/CopilotActionStatus.ts +0 -114
  147. package/Types/Copilot/CopilotActionType.ts +0 -212
  148. package/build/dist/Models/DatabaseModels/CopilotAction.js +0 -793
  149. package/build/dist/Models/DatabaseModels/CopilotAction.js.map +0 -1
  150. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js +0 -358
  151. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js.map +0 -1
  152. package/build/dist/Models/DatabaseModels/CopilotCodeRepository.js +0 -656
  153. package/build/dist/Models/DatabaseModels/CopilotCodeRepository.js.map +0 -1
  154. package/build/dist/Models/DatabaseModels/CopilotPullRequest.js.map +0 -1
  155. package/build/dist/Models/DatabaseModels/ServiceCopilotCodeRepository.js +0 -561
  156. package/build/dist/Models/DatabaseModels/ServiceCopilotCodeRepository.js.map +0 -1
  157. package/build/dist/Server/API/CopilotActionAPI.js +0 -295
  158. package/build/dist/Server/API/CopilotActionAPI.js.map +0 -1
  159. package/build/dist/Server/API/CopilotCodeRepositoryAPI.js +0 -91
  160. package/build/dist/Server/API/CopilotCodeRepositoryAPI.js.map +0 -1
  161. package/build/dist/Server/API/CopilotPullRequestAPI.js +0 -166
  162. package/build/dist/Server/API/CopilotPullRequestAPI.js.map +0 -1
  163. package/build/dist/Server/Middleware/CodeRepositoryAuthorization.js +0 -48
  164. package/build/dist/Server/Middleware/CodeRepositoryAuthorization.js.map +0 -1
  165. package/build/dist/Server/Services/CopilotActionService.js +0 -9
  166. package/build/dist/Server/Services/CopilotActionService.js.map +0 -1
  167. package/build/dist/Server/Services/CopilotActionTypePriorityService.js +0 -61
  168. package/build/dist/Server/Services/CopilotActionTypePriorityService.js.map +0 -1
  169. package/build/dist/Server/Services/CopilotCodeRepositoryService.js +0 -61
  170. package/build/dist/Server/Services/CopilotCodeRepositoryService.js.map +0 -1
  171. package/build/dist/Server/Services/CopilotPullRequestService.js +0 -9
  172. package/build/dist/Server/Services/CopilotPullRequestService.js.map +0 -1
  173. package/build/dist/Server/Services/ServiceCopilotCodeRepositoryService.js +0 -9
  174. package/build/dist/Server/Services/ServiceCopilotCodeRepositoryService.js.map +0 -1
  175. package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js +0 -2
  176. package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js.map +0 -1
  177. package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js +0 -2
  178. package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js.map +0 -1
  179. package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js +0 -2
  180. package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js.map +0 -1
  181. package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js +0 -2
  182. package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js.map +0 -1
  183. package/build/dist/Types/Copilot/CopilotActionProps/Index.js +0 -64
  184. package/build/dist/Types/Copilot/CopilotActionProps/Index.js.map +0 -1
  185. package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js +0 -2
  186. package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js.map +0 -1
  187. package/build/dist/Types/Copilot/CopilotActionStatus.js +0 -96
  188. package/build/dist/Types/Copilot/CopilotActionStatus.js.map +0 -1
  189. package/build/dist/Types/Copilot/CopilotActionType.js +0 -175
  190. package/build/dist/Types/Copilot/CopilotActionType.js.map +0 -1
@@ -1,295 +0,0 @@
1
- import CopilotActionService from "../Services/CopilotActionService";
2
- import Response from "../Utils/Response";
3
- import BaseAPI from "./BaseAPI";
4
- import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
5
- import BadDataException from "../../Types/Exception/BadDataException";
6
- import ObjectID from "../../Types/ObjectID";
7
- import CopilotAction from "../../Models/DatabaseModels/CopilotAction";
8
- import CopilotCodeRepositoryService from "../Services/CopilotCodeRepositoryService";
9
- import CodeRepositoryAuthorization from "../Middleware/CodeRepositoryAuthorization";
10
- import CopilotActionStatus from "../../Types/Copilot/CopilotActionStatus";
11
- import CopilotActionTypePriority from "../../Models/DatabaseModels/CopilotActionTypePriority";
12
- import CopilotActionTypePriorityService from "../Services/CopilotActionTypePriorityService";
13
- import SortOrder from "../../Types/BaseDatabase/SortOrder";
14
- import JSONFunctions from "../../Types/JSONFunctions";
15
- import OneUptimeDate from "../../Types/Date";
16
- export default class CopilotActionAPI extends BaseAPI {
17
- constructor() {
18
- var _a, _b, _c, _d, _e;
19
- super(CopilotAction, CopilotActionService);
20
- this.router.get(`${(_a = new this.entityType()
21
- .getCrudApiPath()) === null || _a === void 0 ? void 0 : _a.toString()}/copilot-action-types-by-priority/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
22
- try {
23
- const secretkey = req.params["secretkey"];
24
- if (!secretkey) {
25
- throw new BadDataException("Secret key is required");
26
- }
27
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
28
- query: {
29
- secretToken: new ObjectID(secretkey),
30
- },
31
- select: {
32
- _id: true,
33
- },
34
- props: {
35
- isRoot: true,
36
- },
37
- });
38
- if (!codeRepository) {
39
- throw new BadDataException("Code repository not found. Secret key is invalid.");
40
- }
41
- const copilotActionTypes = await CopilotActionTypePriorityService.findBy({
42
- query: {
43
- codeRepositoryId: codeRepository.id,
44
- },
45
- select: {
46
- _id: true,
47
- actionType: true,
48
- priority: true,
49
- },
50
- skip: 0,
51
- sort: {
52
- priority: SortOrder.Ascending,
53
- },
54
- limit: LIMIT_PER_PROJECT,
55
- props: {
56
- isRoot: true,
57
- },
58
- });
59
- return Response.sendJsonObjectResponse(req, res, {
60
- actionTypes: CopilotActionTypePriority.toJSONArray(copilotActionTypes, CopilotActionTypePriority),
61
- });
62
- }
63
- catch (err) {
64
- next(err);
65
- }
66
- });
67
- this.router.get(`${(_b = new this.entityType()
68
- .getCrudApiPath()) === null || _b === void 0 ? void 0 : _b.toString()}/copilot-actions-in-queue/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
69
- try {
70
- const secretkey = req.params["secretkey"];
71
- if (!secretkey) {
72
- throw new BadDataException("Secret key is required");
73
- }
74
- const serviceCatalogId = req.body["serviceCatalogId"];
75
- if (!serviceCatalogId) {
76
- throw new BadDataException("Service catalog id is required");
77
- }
78
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
79
- query: {
80
- secretToken: new ObjectID(secretkey),
81
- },
82
- select: {
83
- _id: true,
84
- },
85
- props: {
86
- isRoot: true,
87
- },
88
- });
89
- if (!codeRepository) {
90
- throw new BadDataException("Code repository not found. Secret key is invalid.");
91
- }
92
- const copilotActions = await CopilotActionService.findBy({
93
- query: {
94
- codeRepositoryId: codeRepository.id,
95
- serviceCatalogId: new ObjectID(serviceCatalogId),
96
- copilotActionStatus: CopilotActionStatus.IN_QUEUE,
97
- },
98
- select: {
99
- _id: true,
100
- codeRepositoryId: true,
101
- serviceCatalogId: true,
102
- copilotActionStatus: true,
103
- copilotActionType: true,
104
- copilotActionProp: true,
105
- createdAt: true,
106
- copilotPullRequest: {
107
- _id: true,
108
- pullRequestId: true,
109
- copilotPullRequestStatus: true,
110
- },
111
- },
112
- skip: 0,
113
- limit: LIMIT_PER_PROJECT,
114
- props: {
115
- isRoot: true,
116
- },
117
- });
118
- return Response.sendJsonObjectResponse(req, res, {
119
- copilotActions: CopilotAction.toJSONArray(copilotActions, CopilotAction),
120
- });
121
- }
122
- catch (err) {
123
- next(err);
124
- }
125
- });
126
- this.router.get(`${(_c = new this.entityType()
127
- .getCrudApiPath()) === null || _c === void 0 ? void 0 : _c.toString()}/get-copilot-action/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
128
- try {
129
- const secretkey = req.params["secretkey"];
130
- if (!secretkey) {
131
- throw new BadDataException("Secret key is required");
132
- }
133
- const serviceCatalogId = req.body["serviceCatalogId"];
134
- if (!serviceCatalogId) {
135
- throw new BadDataException("Service catalog id is required");
136
- }
137
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
138
- query: {
139
- secretToken: new ObjectID(secretkey),
140
- },
141
- select: {
142
- _id: true,
143
- },
144
- props: {
145
- isRoot: true,
146
- },
147
- });
148
- if (!codeRepository) {
149
- throw new BadDataException("Code repository not found. Secret key is invalid.");
150
- }
151
- const actionType = req.body["actionType"];
152
- if (!actionType) {
153
- throw new BadDataException("Action type is required");
154
- }
155
- const actionProps = req.body["actionProps"];
156
- const copilotAction = await CopilotActionService.findOneBy({
157
- query: {
158
- codeRepositoryId: codeRepository.id,
159
- serviceCatalogId: new ObjectID(serviceCatalogId),
160
- copilotActionType: actionType,
161
- copilotActionProp: actionProps,
162
- },
163
- select: {
164
- _id: true,
165
- codeRepositoryId: true,
166
- serviceCatalogId: true,
167
- copilotActionStatus: true,
168
- copilotActionType: true,
169
- createdAt: true,
170
- copilotPullRequest: {
171
- _id: true,
172
- pullRequestId: true,
173
- copilotPullRequestStatus: true,
174
- },
175
- },
176
- sort: {
177
- createdAt: SortOrder.Descending,
178
- },
179
- props: {
180
- isRoot: true,
181
- },
182
- });
183
- return Response.sendJsonObjectResponse(req, res, {
184
- copilotAction: copilotAction
185
- ? CopilotAction.toJSONObject(copilotAction, CopilotAction)
186
- : null,
187
- });
188
- }
189
- catch (err) {
190
- next(err);
191
- }
192
- });
193
- this.router.post(`${(_d = new this.entityType()
194
- .getCrudApiPath()) === null || _d === void 0 ? void 0 : _d.toString()}/create-copilot-action/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
195
- try {
196
- const secretkey = req.params["secretkey"];
197
- if (!secretkey) {
198
- throw new BadDataException("Secret key is required");
199
- }
200
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
201
- query: {
202
- secretToken: new ObjectID(secretkey),
203
- },
204
- select: {
205
- _id: true,
206
- projectId: true,
207
- },
208
- props: {
209
- isRoot: true,
210
- },
211
- });
212
- if (!codeRepository) {
213
- throw new BadDataException("Code repository not found. Secret key is invalid.");
214
- }
215
- const copilotAction = CopilotAction.fromJSON(req.body["copilotAction"], CopilotAction);
216
- copilotAction.codeRepositoryId = codeRepository.id;
217
- copilotAction.projectId = codeRepository.projectId;
218
- copilotAction.copilotActionStatus = CopilotActionStatus.IN_QUEUE;
219
- const createdAction = await CopilotActionService.create({
220
- data: copilotAction,
221
- props: {
222
- isRoot: true,
223
- },
224
- });
225
- return Response.sendEntityResponse(req, res, createdAction, CopilotAction);
226
- }
227
- catch (err) {
228
- next(err);
229
- }
230
- });
231
- this.router.post(`${(_e = new this.entityType()
232
- .getCrudApiPath()) === null || _e === void 0 ? void 0 : _e.toString()}/update-copilot-action/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
233
- try {
234
- const secretkey = req.params["secretkey"];
235
- if (!secretkey) {
236
- throw new BadDataException("Secret key is required");
237
- }
238
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
239
- query: {
240
- secretToken: new ObjectID(secretkey),
241
- },
242
- select: {
243
- _id: true,
244
- projectId: true,
245
- },
246
- props: {
247
- isRoot: true,
248
- },
249
- });
250
- if (!codeRepository) {
251
- throw new BadDataException("Code repository not found. Secret key is invalid.");
252
- }
253
- req.body = JSONFunctions.deserialize(req.body);
254
- const { actionStatus, pullRequestId, commitHash, statusMessage, logs, actionId, } = req.body;
255
- const exisingAction = await CopilotActionService.findOneBy({
256
- query: {
257
- _id: actionId,
258
- codeRepositoryId: codeRepository.id,
259
- },
260
- select: {
261
- _id: true,
262
- },
263
- props: {
264
- isRoot: true,
265
- },
266
- });
267
- if (!exisingAction) {
268
- throw new BadDataException("Action not found");
269
- }
270
- await CopilotActionService.updateOneBy({
271
- query: {
272
- _id: actionId,
273
- codeRepositoryId: codeRepository.id,
274
- },
275
- data: {
276
- copilotActionStatus: actionStatus,
277
- copilotPullRequestId: pullRequestId,
278
- commitHash: commitHash,
279
- statusMessage: statusMessage,
280
- statusChangedAt: OneUptimeDate.getCurrentDate(),
281
- logs: (logs === null || logs === void 0 ? void 0 : logs.join("\n")) || "",
282
- },
283
- props: {
284
- isRoot: true,
285
- },
286
- });
287
- return Response.sendEmptySuccessResponse(req, res);
288
- }
289
- catch (err) {
290
- next(err);
291
- }
292
- });
293
- }
294
- }
295
- //# sourceMappingURL=CopilotActionAPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopilotActionAPI.js","sourceRoot":"","sources":["../../../../Server/API/CopilotActionAPI.ts"],"names":[],"mappings":"AACA,OAAO,oBAEN,MAAM,kCAAkC,CAAC;AAM1C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,gBAAgB,MAAM,wCAAwC,CAAC;AACtE,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,aAAa,MAAM,2CAA2C,CAAC;AACtE,OAAO,4BAA4B,MAAM,0CAA0C,CAAC;AACpF,OAAO,2BAA2B,MAAM,2CAA2C,CAAC;AACpF,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAC1E,OAAO,yBAAyB,MAAM,uDAAuD,CAAC;AAC9F,OAAO,gCAAgC,MAAM,8CAA8C,CAAC;AAC5F,OAAO,SAAS,MAAM,oCAAoC,CAAC;AAC3D,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAGtD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAG7C;IACC;;QACE,KAAK,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;QA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KAAI,EAAE;qBAC7B;oBACD,KAAK,EAAE;wBACL,MAAM,EAAE,IAAI;qBACb;iBACF,CAAC,CAAC;gBAEH,OAAO,QAAQ,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,CAAC;YACZ,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -1,91 +0,0 @@
1
- import OneUptimeDate from "../../Types/Date";
2
- import CodeRepositoryAuthorization from "../Middleware/CodeRepositoryAuthorization";
3
- import CopilotCodeRepositoryService from "../Services/CopilotCodeRepositoryService";
4
- import ServiceCopilotCodeRepositoryService from "../Services/ServiceCopilotCodeRepositoryService";
5
- import Response from "../Utils/Response";
6
- import BaseAPI from "./BaseAPI";
7
- import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
8
- import BadDataException from "../../Types/Exception/BadDataException";
9
- import ObjectID from "../../Types/ObjectID";
10
- import CopilotCodeRepository from "../../Models/DatabaseModels/CopilotCodeRepository";
11
- import ServiceCopilotCodeRepository from "../../Models/DatabaseModels/ServiceCopilotCodeRepository";
12
- export default class CopilotCodeRepositoryAPI extends BaseAPI {
13
- constructor() {
14
- var _a, _b;
15
- super(CopilotCodeRepository, CopilotCodeRepositoryService);
16
- this.router.get(`${(_a = new this.entityType()
17
- .getCrudApiPath()) === null || _a === void 0 ? void 0 : _a.toString()}/is-valid/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
18
- try {
19
- return Response.sendEmptySuccessResponse(req, res);
20
- }
21
- catch (err) {
22
- next(err);
23
- }
24
- });
25
- this.router.get(`${(_b = new this.entityType()
26
- .getCrudApiPath()) === null || _b === void 0 ? void 0 : _b.toString()}/get-code-repository/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
27
- try {
28
- const secretkey = req.params["secretkey"];
29
- if (!secretkey) {
30
- throw new BadDataException("Secret key is required");
31
- }
32
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
33
- query: {
34
- secretToken: new ObjectID(secretkey),
35
- },
36
- select: {
37
- name: true,
38
- mainBranchName: true,
39
- organizationName: true,
40
- repositoryHostedAt: true,
41
- repositoryName: true,
42
- },
43
- props: {
44
- isRoot: true,
45
- },
46
- });
47
- if (!codeRepository) {
48
- throw new BadDataException("Code repository not found. Secret key is invalid.");
49
- }
50
- // update last run time.
51
- await CopilotCodeRepositoryService.updateOneById({
52
- id: codeRepository.id,
53
- data: {
54
- lastCopilotRunDateTime: OneUptimeDate.getCurrentDate(),
55
- },
56
- props: {
57
- isRoot: true,
58
- },
59
- });
60
- const servicesRepository = await ServiceCopilotCodeRepositoryService.findBy({
61
- query: {
62
- codeRepositoryId: codeRepository.id,
63
- enablePullRequests: true,
64
- },
65
- select: {
66
- serviceCatalog: {
67
- name: true,
68
- _id: true,
69
- techStack: true,
70
- },
71
- servicePathInRepository: true,
72
- limitNumberOfOpenPullRequestsCount: true,
73
- },
74
- limit: LIMIT_PER_PROJECT,
75
- skip: 0,
76
- props: {
77
- isRoot: true,
78
- },
79
- });
80
- return Response.sendJsonObjectResponse(req, res, {
81
- codeRepository: CopilotCodeRepository.toJSON(codeRepository, CopilotCodeRepository),
82
- servicesRepository: ServiceCopilotCodeRepository.toJSONArray(servicesRepository, ServiceCopilotCodeRepository),
83
- });
84
- }
85
- catch (err) {
86
- next(err);
87
- }
88
- });
89
- }
90
- }
91
- //# sourceMappingURL=CopilotCodeRepositoryAPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopilotCodeRepositoryAPI.js","sourceRoot":"","sources":["../../../../Server/API/CopilotCodeRepositoryAPI.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,2BAA2B,MAAM,2CAA2C,CAAC;AACpF,OAAO,4BAEN,MAAM,0CAA0C,CAAC;AAClD,OAAO,mCAAmC,M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BAC/C,cAAc,EAAE,qBAAqB,CAAC,MAAM,CAC1C,cAAc,EACd,qBAAqB,CACtB;oBACD,kBAAkB,EAAE,4BAA4B,CAAC,WAAW,CAC1D,kBAAkB,EAClB,4BAA4B,CAC7B;iBACF,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,CAAC;YACZ,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -1,166 +0,0 @@
1
- import CopilotPullRequestService from "../Services/CopilotPullRequestService";
2
- import Response from "../Utils/Response";
3
- import BaseAPI from "./BaseAPI";
4
- import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
5
- import BadDataException from "../../Types/Exception/BadDataException";
6
- import ObjectID from "../../Types/ObjectID";
7
- import CopilotCodeRepositoryService from "../Services/CopilotCodeRepositoryService";
8
- import CodeRepositoryAuthorization from "../Middleware/CodeRepositoryAuthorization";
9
- import CopilotPullRequest from "../../Models/DatabaseModels/CopilotPullRequest";
10
- import PullRequestState from "../../Types/CodeRepository/PullRequestState";
11
- export default class CopilotPullRequestAPI extends BaseAPI {
12
- constructor() {
13
- var _a, _b, _c;
14
- super(CopilotPullRequest, CopilotPullRequestService);
15
- this.router.get(`${(_a = new this.entityType()
16
- .getCrudApiPath()) === null || _a === void 0 ? void 0 : _a.toString()}/get-pending-pull-requests/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
17
- try {
18
- const secretkey = req.params["secretkey"];
19
- if (!secretkey) {
20
- throw new BadDataException("Secret key is required");
21
- }
22
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
23
- query: {
24
- secretToken: new ObjectID(secretkey),
25
- },
26
- select: {
27
- _id: true,
28
- },
29
- props: {
30
- isRoot: true,
31
- },
32
- });
33
- if (!codeRepository) {
34
- throw new BadDataException("Code repository not found. Secret key is invalid.");
35
- }
36
- const copilotPullRequests = await CopilotPullRequestService.findBy({
37
- query: {
38
- codeRepositoryId: codeRepository.id,
39
- copilotPullRequestStatus: PullRequestState.Open, // only get pending pull requests
40
- },
41
- select: {
42
- _id: true,
43
- codeRepositoryId: true,
44
- projectId: true,
45
- copilotPullRequestStatus: true,
46
- pullRequestId: true,
47
- isSetupPullRequest: true,
48
- serviceCatalogId: true,
49
- serviceRepositoryId: true,
50
- },
51
- skip: 0,
52
- limit: LIMIT_PER_PROJECT,
53
- props: {
54
- isRoot: true,
55
- },
56
- });
57
- return Response.sendJsonObjectResponse(req, res, {
58
- copilotPullRequests: CopilotPullRequest.toJSONArray(copilotPullRequests, CopilotPullRequest),
59
- });
60
- }
61
- catch (err) {
62
- next(err);
63
- }
64
- });
65
- this.router.post(`${(_b = new this.entityType()
66
- .getCrudApiPath()) === null || _b === void 0 ? void 0 : _b.toString()}/add-pull-request/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
67
- try {
68
- const secretkey = req.params["secretkey"];
69
- if (!secretkey) {
70
- throw new BadDataException("Secret key is required");
71
- }
72
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
73
- query: {
74
- secretToken: new ObjectID(secretkey),
75
- },
76
- select: {
77
- _id: true,
78
- projectId: true,
79
- },
80
- props: {
81
- isRoot: true,
82
- },
83
- });
84
- if (!codeRepository) {
85
- throw new BadDataException("Code repository not found. Secret key is invalid.");
86
- }
87
- if (!req.body["copilotPullRequest"]) {
88
- throw new BadDataException("Copilot pull request is required");
89
- }
90
- const copilotPullRequest = CopilotPullRequest.fromJSON(req.body["copilotPullRequest"], CopilotPullRequest);
91
- copilotPullRequest.codeRepositoryId = codeRepository.id;
92
- copilotPullRequest.projectId = codeRepository.projectId;
93
- copilotPullRequest.copilotPullRequestStatus = PullRequestState.Open;
94
- const createdPullRequest = await CopilotPullRequestService.create({
95
- data: copilotPullRequest,
96
- props: {
97
- isRoot: true,
98
- },
99
- });
100
- return Response.sendEntityResponse(req, res, createdPullRequest, CopilotPullRequest);
101
- }
102
- catch (err) {
103
- next(err);
104
- }
105
- });
106
- this.router.post(`${(_c = new this.entityType()
107
- .getCrudApiPath()) === null || _c === void 0 ? void 0 : _c.toString()}/update-pull-request-status/:secretkey`, CodeRepositoryAuthorization.isAuthorizedRepository, async (req, res, next) => {
108
- try {
109
- const secretkey = req.params["secretkey"];
110
- if (!secretkey) {
111
- throw new BadDataException("Secret key is required");
112
- }
113
- const codeRepository = await CopilotCodeRepositoryService.findOneBy({
114
- query: {
115
- secretToken: new ObjectID(secretkey),
116
- },
117
- select: {
118
- _id: true,
119
- projectId: true,
120
- },
121
- props: {
122
- isRoot: true,
123
- },
124
- });
125
- if (!codeRepository) {
126
- throw new BadDataException("Code repository not found. Secret key is invalid.");
127
- }
128
- if (!req.body["copilotPullRequestId"]) {
129
- throw new BadDataException("Copilot pull request is required");
130
- }
131
- // check copilotPullRequestStatus
132
- if (!req.body["copilotPullRequestStatus"]) {
133
- throw new BadDataException("Copilot pull request status is required");
134
- }
135
- const copilotPullRequestId = new ObjectID(req.body["copilotPullRequestId"]);
136
- const copilotPullRequest = await CopilotPullRequestService.findOneById({
137
- id: copilotPullRequestId,
138
- select: {
139
- copilotPullRequestStatus: true,
140
- pullRequestId: true,
141
- },
142
- props: {
143
- isRoot: true,
144
- },
145
- });
146
- if (!copilotPullRequest) {
147
- throw new BadDataException("Copilot pull request not found");
148
- }
149
- await CopilotPullRequestService.updateOneById({
150
- id: copilotPullRequestId,
151
- data: {
152
- copilotPullRequestStatus: req.body["copilotPullRequestStatus"],
153
- },
154
- props: {
155
- isRoot: true,
156
- },
157
- });
158
- return Response.sendEmptySuccessResponse(req, res);
159
- }
160
- catch (err) {
161
- next(err);
162
- }
163
- });
164
- }
165
- }
166
- //# sourceMappingURL=CopilotPullRequestAPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopilotPullRequestAPI.js","sourceRoot":"","sources":["../../../../Server/API/CopilotPullRequestAPI.ts"],"names":[],"mappings":"AACA,OAAO,yBAEN,MAAM,u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oBACxB,MAAM,EAAE;wBACN,wBAAwB,EAAE,IAAI;wBAC9B,aAAa,EAAE,IAAI;qBACpB;oBACD,KAAK,EAAE;wBACL,MAAM,EAAE,IAAI;qBACb;iBACF,CAAC,CAAC;gBAEL,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBACxB,MAAM,IAAI,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;gBAC/D,CAAC;gBAED,MAAM,yBAAyB,CAAC,aAAa,CAAC;oBAC5C,EAAE,EAAE,oBAAoB;oBACxB,IAAI,EAAE;wBACJ,wBAAwB,EAAE,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC;qBAC/D;oBACD,KAAK,EAAE;wBACL,MAAM,EAAE,IAAI;qBACb;iBACF,CAAC,CAAC;gBAEH,OAAO,QAAQ,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,CAAC;YACZ,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -1,48 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import BadDataException from "../../Types/Exception/BadDataException";
11
- import CopilotCodeRepositoryService from "../Services/CopilotCodeRepositoryService";
12
- import ObjectID from "../../Types/ObjectID";
13
- import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
14
- export default class CopilotCodeRepositoryAuthorization {
15
- static async isAuthorizedRepository(req, _res, next) {
16
- try {
17
- const secretkey = req.params["secretkey"];
18
- if (!secretkey) {
19
- throw new BadDataException("Secret key is required");
20
- }
21
- const CopilotCodeRepository = await CopilotCodeRepositoryService.findOneBy({
22
- query: {
23
- secretToken: new ObjectID(secretkey),
24
- },
25
- select: {
26
- _id: true,
27
- },
28
- props: {
29
- isRoot: true,
30
- },
31
- });
32
- if (!CopilotCodeRepository) {
33
- throw new BadDataException("Code repository not found. Secret key is invalid.");
34
- }
35
- next();
36
- }
37
- catch (err) {
38
- next(err);
39
- }
40
- }
41
- }
42
- __decorate([
43
- CaptureSpan(),
44
- __metadata("design:type", Function),
45
- __metadata("design:paramtypes", [Object, Object, Function]),
46
- __metadata("design:returntype", Promise)
47
- ], CopilotCodeRepositoryAuthorization, "isAuthorizedRepository", null);
48
- //# sourceMappingURL=CodeRepositoryAuthorization.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CodeRepositoryAuthorization.js","sourceRoot":"","sources":["../../../../Server/Middleware/CodeRepositoryAuthorization.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,gBAAgB,MAAM,wCAAwC,CAAC;AAOtE,OAAO,4BAA4B,MAAM,0CAA0C,CAAC;AACpF,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,WAAW,MAAM,gCAAgC,CAAC;AAEzD,MAAM,CAAC,OAAO,OAAO,kCAAkC;IAEjC,AAAb,MAAM,CAAC,KAAK,CAAC,sBAAsB,CACxC,GAAmB,EACnB,IAAqB,EACrB,IAAkB;QAElB,IAAI,CAAC;YACH,MAAM,SAAS,GAAW,GAAG,CAAC,MAAM,CAAC,WAAW,CAAE,CAAC;YAEnD,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,MAAM,IAAI,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,qBAAqB,GACzB,MAAM,4BAA4B,CAAC,SAAS,CAAC;gBAC3C,KAAK,EAAE;oBACL,WAAW,EAAE,IAAI,QAAQ,CAAC,SAAS,CAAC;iBACrC;gBACD,MAAM,EAAE;oBACN,GAAG,EAAE,IAAI;iBACV;gBACD,KAAK,EAAE;oBACL,MAAM,EAAE,IAAI;iBACb;aACF,CAAC,CAAC;YAEL,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC3B,MAAM,IAAI,gBAAgB,CACxB,mDAAmD,CACpD,CAAC;YACJ,CAAC;YAED,IAAI,EAAE,CAAC;QACT,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AApCqB;IADnB,WAAW,EAAE;;;;sEAoCb"}
@@ -1,9 +0,0 @@
1
- import DatabaseService from "./DatabaseService";
2
- import Model from "../../Models/DatabaseModels/CopilotAction";
3
- export class Service extends DatabaseService {
4
- constructor() {
5
- super(Model);
6
- }
7
- }
8
- export default new Service();
9
- //# sourceMappingURL=CopilotActionService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopilotActionService.js","sourceRoot":"","sources":["../../../../Server/Services/CopilotActionService.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,MAAM,2CAA2C,CAAC;AAE9D,MAAM,OAAO,OAAQ,SAAQ,eAAsB;IACjD;QACE,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF;AAED,eAAe,IAAI,OAAO,EAAE,CAAC"}