@oneuptime/common 7.0.3010 → 7.0.3022

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/Models/DatabaseModels/CopilotAction.ts +232 -38
  2. package/Models/DatabaseModels/CopilotActionTypePriority.ts +340 -0
  3. package/Models/DatabaseModels/CopilotPullRequest.ts +1 -0
  4. package/Models/DatabaseModels/Index.ts +2 -0
  5. package/Server/API/CopilotActionAPI.ts +251 -7
  6. package/Server/API/StatusAPI.ts +0 -2
  7. package/Server/API/StatusPageAPI.ts +1 -1
  8. package/Server/API/TelemetryAPI.ts +1 -1
  9. package/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.ts +51 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.ts +23 -0
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.ts +13 -0
  12. package/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.ts +17 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  14. package/Server/Services/CopilotActionTypePriorityService.ts +66 -0
  15. package/Server/Services/CopilotCodeRepositoryService.ts +36 -0
  16. package/Server/Services/Index.ts +2 -0
  17. package/Server/Services/ServiceCatalogService.ts +1 -1
  18. package/Server/Services/TelemetryServiceService.ts +1 -1
  19. package/Server/Types/Database/Permissions/AccessControlPermission.ts +1 -1
  20. package/Server/Types/Workflow/Components/Email.ts +32 -25
  21. package/Server/Utils/CodeRepository/CodeRepository.ts +11 -14
  22. package/Server/Utils/CodeRepository/CodeRepositoryFile.ts +1 -7
  23. package/Tests/Types/ArrayUtil.test.ts +1 -1
  24. package/Types/Copilot/CopilotActionProps/DirectoryActionProp.ts +3 -0
  25. package/Types/Copilot/CopilotActionProps/ExceptionActionProp.ts +4 -0
  26. package/Types/Copilot/CopilotActionProps/FileActionProp.ts +7 -0
  27. package/Types/Copilot/CopilotActionProps/FunctionActionProp.ts +5 -0
  28. package/Types/Copilot/CopilotActionProps/Index.ts +96 -0
  29. package/Types/Copilot/CopilotActionProps/SpanActionProp.ts +4 -0
  30. package/Types/Copilot/CopilotActionStatus.ts +109 -1
  31. package/Types/Copilot/CopilotActionType.ts +203 -1
  32. package/Types/Icon/IconProp.ts +1 -0
  33. package/Types/Permission.ts +26 -0
  34. package/Types/Workflow/Components/Email.ts +4 -4
  35. package/UI/Components/Alerts/Alert.tsx +1 -1
  36. package/UI/Components/Icon/Icon.tsx +8 -0
  37. package/UI/Components/Workflow/WorkflowStatus.tsx +2 -2
  38. package/{Types/ArrayUtil.ts → Utils/Array.ts} +1 -1
  39. package/build/dist/Models/DatabaseModels/CopilotAction.js +237 -40
  40. package/build/dist/Models/DatabaseModels/CopilotAction.js.map +1 -1
  41. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js +358 -0
  42. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js.map +1 -0
  43. package/build/dist/Models/DatabaseModels/CopilotPullRequest.js +1 -0
  44. package/build/dist/Models/DatabaseModels/CopilotPullRequest.js.map +1 -1
  45. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  46. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  47. package/build/dist/Server/API/CopilotActionAPI.js +185 -9
  48. package/build/dist/Server/API/CopilotActionAPI.js.map +1 -1
  49. package/build/dist/Server/API/StatusAPI.js +0 -1
  50. package/build/dist/Server/API/StatusAPI.js.map +1 -1
  51. package/build/dist/Server/API/StatusPageAPI.js +1 -1
  52. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  53. package/build/dist/Server/API/TelemetryAPI.js +1 -1
  54. package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
  55. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.js +24 -0
  56. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.js.map +1 -0
  57. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.js +14 -0
  58. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.js.map +1 -0
  59. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.js +12 -0
  60. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.js.map +1 -0
  61. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.js +12 -0
  62. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.js.map +1 -0
  63. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  64. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  65. package/build/dist/Server/Services/CopilotActionTypePriorityService.js +45 -0
  66. package/build/dist/Server/Services/CopilotActionTypePriorityService.js.map +1 -0
  67. package/build/dist/Server/Services/CopilotCodeRepositoryService.js +22 -0
  68. package/build/dist/Server/Services/CopilotCodeRepositoryService.js.map +1 -1
  69. package/build/dist/Server/Services/Index.js +2 -0
  70. package/build/dist/Server/Services/Index.js.map +1 -1
  71. package/build/dist/Server/Services/ServiceCatalogService.js +1 -1
  72. package/build/dist/Server/Services/ServiceCatalogService.js.map +1 -1
  73. package/build/dist/Server/Services/TelemetryServiceService.js +1 -1
  74. package/build/dist/Server/Services/TelemetryServiceService.js.map +1 -1
  75. package/build/dist/Server/Types/Database/Permissions/AccessControlPermission.js +1 -1
  76. package/build/dist/Server/Types/Database/Permissions/AccessControlPermission.js.map +1 -1
  77. package/build/dist/Server/Types/Workflow/Components/Email.js +26 -27
  78. package/build/dist/Server/Types/Workflow/Components/Email.js.map +1 -1
  79. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js +6 -13
  80. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js.map +1 -1
  81. package/build/dist/Tests/Types/ArrayUtil.test.js +1 -1
  82. package/build/dist/Tests/Types/ArrayUtil.test.js.map +1 -1
  83. package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js +2 -0
  84. package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js.map +1 -0
  85. package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js +2 -0
  86. package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js.map +1 -0
  87. package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js +2 -0
  88. package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js.map +1 -0
  89. package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js +2 -0
  90. package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js.map +1 -0
  91. package/build/dist/Types/Copilot/CopilotActionProps/Index.js +64 -0
  92. package/build/dist/Types/Copilot/CopilotActionProps/Index.js.map +1 -0
  93. package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js +2 -0
  94. package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js.map +1 -0
  95. package/build/dist/Types/Copilot/CopilotActionStatus.js +89 -0
  96. package/build/dist/Types/Copilot/CopilotActionStatus.js.map +1 -1
  97. package/build/dist/Types/Copilot/CopilotActionType.js +165 -1
  98. package/build/dist/Types/Copilot/CopilotActionType.js.map +1 -1
  99. package/build/dist/Types/Icon/IconProp.js +1 -0
  100. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  101. package/build/dist/Types/Permission.js +24 -0
  102. package/build/dist/Types/Permission.js.map +1 -1
  103. package/build/dist/Types/Workflow/Components/Email.js +4 -4
  104. package/build/dist/Types/Workflow/Components/Email.js.map +1 -1
  105. package/build/dist/UI/Components/Alerts/Alert.js +1 -1
  106. package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
  107. package/build/dist/UI/Components/Icon/Icon.js +3 -0
  108. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  109. package/build/dist/UI/Components/Workflow/WorkflowStatus.js +2 -2
  110. package/build/dist/UI/Components/Workflow/WorkflowStatus.js.map +1 -1
  111. package/build/dist/{Types/ArrayUtil.js → Utils/Array.js} +1 -1
  112. package/build/dist/Utils/Array.js.map +1 -0
  113. package/package.json +2 -2
  114. package/build/dist/Types/ArrayUtil.js.map +0 -1
@@ -0,0 +1,340 @@
1
+ import CodeRepository from "./CopilotCodeRepository";
2
+ import Project from "./Project";
3
+ import User from "./User";
4
+ import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
5
+ import Route from "../../Types/API/Route";
6
+ import CopilotActionType from "../../Types/Copilot/CopilotActionType";
7
+ import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
8
+ import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
9
+ import CanAccessIfCanReadOn from "../../Types/Database/CanAccessIfCanReadOn";
10
+ import ColumnType from "../../Types/Database/ColumnType";
11
+ import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
12
+ import EnableDocumentation from "../../Types/Database/EnableDocumentation";
13
+ import EnableWorkflow from "../../Types/Database/EnableWorkflow";
14
+ import TableColumn from "../../Types/Database/TableColumn";
15
+ import TableColumnType from "../../Types/Database/TableColumnType";
16
+ import TableMetadata from "../../Types/Database/TableMetadata";
17
+ import TenantColumn from "../../Types/Database/TenantColumn";
18
+ import IconProp from "../../Types/Icon/IconProp";
19
+ import ObjectID from "../../Types/ObjectID";
20
+ import Permission from "../../Types/Permission";
21
+ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
22
+ import ColumnLength from "../../Types/Database/ColumnLength";
23
+
24
+ @CanAccessIfCanReadOn("codeRepository")
25
+ @EnableDocumentation()
26
+ @TenantColumn("projectId")
27
+ @TableAccessControl({
28
+ create: [
29
+ Permission.ProjectOwner,
30
+ Permission.ProjectAdmin,
31
+ Permission.ProjectMember,
32
+ Permission.CreateCopilotAction,
33
+ ],
34
+ read: [
35
+ Permission.ProjectOwner,
36
+ Permission.ProjectAdmin,
37
+ Permission.ProjectMember,
38
+ Permission.ReadCopilotAction,
39
+ ],
40
+ delete: [
41
+ Permission.ProjectOwner,
42
+ Permission.ProjectAdmin,
43
+ Permission.ProjectMember,
44
+ Permission.DeleteCopilotAction,
45
+ ],
46
+ update: [
47
+ Permission.ProjectOwner,
48
+ Permission.ProjectAdmin,
49
+ Permission.ProjectMember,
50
+ Permission.EditCopilotAction,
51
+ ],
52
+ })
53
+ @EnableWorkflow({
54
+ create: true,
55
+ delete: false,
56
+ update: true,
57
+ read: false,
58
+ })
59
+ @CrudApiEndpoint(new Route("/copilot-action-type-prority"))
60
+ @TableMetadata({
61
+ tableName: "CopilotActionType",
62
+ singularName: "Copilot Action Priority",
63
+ pluralName: "Copilot Action Priorities",
64
+ icon: IconProp.Bolt,
65
+ tableDescription: "Priority of Copilot Actions",
66
+ })
67
+ @Entity({
68
+ name: "CopilotActionTypePriority",
69
+ })
70
+ export default class CopilotActionTypePriority extends BaseModel {
71
+ @ColumnAccessControl({
72
+ create: [],
73
+ read: [
74
+ Permission.ProjectOwner,
75
+ Permission.ProjectAdmin,
76
+ Permission.ProjectMember,
77
+ Permission.ReadCopilotAction,
78
+ ],
79
+ update: [],
80
+ })
81
+ @TableColumn({
82
+ manyToOneRelationColumn: "projectId",
83
+ type: TableColumnType.Entity,
84
+ modelType: Project,
85
+ title: "Project",
86
+ description: "Relation to Project Resource in which this object belongs",
87
+ })
88
+ @ManyToOne(
89
+ () => {
90
+ return Project;
91
+ },
92
+ {
93
+ eager: false,
94
+ nullable: false,
95
+ onDelete: "CASCADE",
96
+ orphanedRowAction: "nullify",
97
+ },
98
+ )
99
+ @JoinColumn({ name: "projectId" })
100
+ public project?: Project = undefined;
101
+
102
+ @ColumnAccessControl({
103
+ create: [],
104
+ read: [
105
+ Permission.ProjectOwner,
106
+ Permission.ProjectAdmin,
107
+ Permission.ProjectMember,
108
+ Permission.ReadCopilotAction,
109
+ ],
110
+ update: [],
111
+ })
112
+ @Index()
113
+ @TableColumn({
114
+ type: TableColumnType.ObjectID,
115
+ required: true,
116
+ canReadOnRelationQuery: true,
117
+ title: "Project ID",
118
+ description: "ID of your OneUptime Project in which this object belongs",
119
+ })
120
+ @Column({
121
+ type: ColumnType.ObjectID,
122
+ nullable: false,
123
+ transformer: ObjectID.getDatabaseTransformer(),
124
+ })
125
+ public projectId?: ObjectID = undefined;
126
+
127
+ @ColumnAccessControl({
128
+ create: [],
129
+ read: [
130
+ Permission.ProjectOwner,
131
+ Permission.ProjectAdmin,
132
+ Permission.ProjectMember,
133
+ Permission.ReadCopilotAction,
134
+ ],
135
+ update: [],
136
+ })
137
+ @TableColumn({
138
+ manyToOneRelationColumn: "codeRepositoryId",
139
+ type: TableColumnType.Entity,
140
+ modelType: CodeRepository,
141
+ title: "Code Repository",
142
+ description:
143
+ "Relation to CodeRepository Resource in which this object belongs",
144
+ })
145
+ @ManyToOne(
146
+ () => {
147
+ return CodeRepository;
148
+ },
149
+ {
150
+ eager: false,
151
+ nullable: true,
152
+ onDelete: "CASCADE",
153
+ orphanedRowAction: "nullify",
154
+ },
155
+ )
156
+ @JoinColumn({ name: "codeRepositoryId" })
157
+ public codeRepository?: CodeRepository = undefined;
158
+
159
+ @ColumnAccessControl({
160
+ create: [],
161
+ read: [
162
+ Permission.ProjectOwner,
163
+ Permission.ProjectAdmin,
164
+ Permission.ProjectMember,
165
+ Permission.ReadCopilotAction,
166
+ ],
167
+ update: [],
168
+ })
169
+ @Index()
170
+ @TableColumn({
171
+ type: TableColumnType.ObjectID,
172
+ required: true,
173
+ canReadOnRelationQuery: true,
174
+ title: "Code Repository ID",
175
+ description:
176
+ "ID of your OneUptime Code Repository in which this object belongs",
177
+ })
178
+ @Column({
179
+ type: ColumnType.ObjectID,
180
+ nullable: false,
181
+ transformer: ObjectID.getDatabaseTransformer(),
182
+ })
183
+ public codeRepositoryId?: ObjectID = undefined;
184
+
185
+ @ColumnAccessControl({
186
+ create: [],
187
+ read: [
188
+ Permission.ProjectOwner,
189
+ Permission.ProjectAdmin,
190
+ Permission.ProjectMember,
191
+ Permission.ReadCopilotAction,
192
+ ],
193
+ update: [],
194
+ })
195
+ @TableColumn({
196
+ manyToOneRelationColumn: "createdByUserId",
197
+ type: TableColumnType.Entity,
198
+ modelType: User,
199
+ title: "Created by User",
200
+ description:
201
+ "Relation to User who created this object (if this object was created by a User)",
202
+ })
203
+ @ManyToOne(
204
+ () => {
205
+ return User;
206
+ },
207
+ {
208
+ eager: false,
209
+ nullable: true,
210
+ onDelete: "CASCADE",
211
+ orphanedRowAction: "nullify",
212
+ },
213
+ )
214
+ @JoinColumn({ name: "createdByUserId" })
215
+ public createdByUser?: User = undefined;
216
+
217
+ @ColumnAccessControl({
218
+ create: [],
219
+ read: [
220
+ Permission.ProjectOwner,
221
+ Permission.ProjectAdmin,
222
+ Permission.ProjectMember,
223
+ Permission.ReadCopilotAction,
224
+ ],
225
+ update: [],
226
+ })
227
+ @TableColumn({
228
+ type: TableColumnType.ObjectID,
229
+ title: "Created by User ID",
230
+ description:
231
+ "User ID who created this object (if this object was created by a User)",
232
+ })
233
+ @Column({
234
+ type: ColumnType.ObjectID,
235
+ nullable: true,
236
+ transformer: ObjectID.getDatabaseTransformer(),
237
+ })
238
+ public createdByUserId?: ObjectID = undefined;
239
+
240
+ @ColumnAccessControl({
241
+ create: [],
242
+ read: [
243
+ Permission.ProjectOwner,
244
+ Permission.ProjectAdmin,
245
+ Permission.ProjectMember,
246
+ Permission.ReadCopilotAction,
247
+ ],
248
+ update: [],
249
+ })
250
+ @TableColumn({
251
+ manyToOneRelationColumn: "deletedByUserId",
252
+ type: TableColumnType.Entity,
253
+ title: "Deleted by User",
254
+ description:
255
+ "Relation to User who deleted this object (if this object was deleted by a User)",
256
+ })
257
+ @ManyToOne(
258
+ () => {
259
+ return User;
260
+ },
261
+ {
262
+ cascade: false,
263
+ eager: false,
264
+ nullable: true,
265
+ onDelete: "CASCADE",
266
+ orphanedRowAction: "nullify",
267
+ },
268
+ )
269
+ @JoinColumn({ name: "deletedByUserId" })
270
+ public deletedByUser?: User = undefined;
271
+
272
+ @ColumnAccessControl({
273
+ create: [],
274
+ read: [
275
+ Permission.ProjectOwner,
276
+ Permission.ProjectAdmin,
277
+ Permission.ProjectMember,
278
+ Permission.ReadCopilotAction,
279
+ ],
280
+ update: [],
281
+ })
282
+ @TableColumn({
283
+ type: TableColumnType.ObjectID,
284
+ title: "Deleted by User ID",
285
+ description:
286
+ "User ID who deleted this object (if this object was deleted by a User)",
287
+ })
288
+ @Column({
289
+ type: ColumnType.ObjectID,
290
+ nullable: true,
291
+ transformer: ObjectID.getDatabaseTransformer(),
292
+ })
293
+ public deletedByUserId?: ObjectID = undefined;
294
+
295
+ @ColumnAccessControl({
296
+ create: [],
297
+ read: [
298
+ Permission.ProjectOwner,
299
+ Permission.ProjectAdmin,
300
+ Permission.ProjectMember,
301
+ Permission.ReadCopilotAction,
302
+ ],
303
+ update: [],
304
+ })
305
+ @TableColumn({
306
+ type: TableColumnType.ShortText,
307
+ title: "Copilot Action Type",
308
+ required: true,
309
+ description: "Copilot Action Type for this Code Repository",
310
+ })
311
+ @Column({
312
+ type: ColumnType.ShortText,
313
+ length: ColumnLength.ShortText,
314
+ nullable: false,
315
+ })
316
+ public actionType?: CopilotActionType = undefined;
317
+
318
+ @ColumnAccessControl({
319
+ create: [],
320
+ read: [
321
+ Permission.ProjectOwner,
322
+ Permission.ProjectAdmin,
323
+ Permission.ProjectMember,
324
+ Permission.ReadCopilotAction,
325
+ ],
326
+ update: [],
327
+ })
328
+ @TableColumn({
329
+ type: TableColumnType.Number,
330
+ title: "Priority",
331
+ required: true,
332
+ description: "Priority of Copilot Action Type for this Code Repository",
333
+ })
334
+ @Column({
335
+ type: ColumnType.Number,
336
+ nullable: false,
337
+ default: 1,
338
+ })
339
+ public priority?: number = undefined;
340
+ }
@@ -411,6 +411,7 @@ export default class CopilotPullRequest extends BaseModel {
411
411
  type: TableColumnType.ShortText,
412
412
  required: false,
413
413
  isDefaultValueColumn: false,
414
+ canReadOnRelationQuery: true,
414
415
  title: "Pull Request ID",
415
416
  description:
416
417
  "ID of Pull Request in the repository where this event was executed and then PR was created.",
@@ -136,6 +136,7 @@ import UserTwoFactorAuth from "./UserTwoFactorAuth";
136
136
  import TelemetryIngestionKey from "./TelemetryIngestionKey";
137
137
 
138
138
  import TelemetryException from "./TelemetryException";
139
+ import CopilotActionTypePriority from "./CopilotActionTypePriority";
139
140
 
140
141
  export default [
141
142
  User,
@@ -284,6 +285,7 @@ export default [
284
285
  CopilotAction,
285
286
  ServiceCopilotCodeRepository,
286
287
  CopilotPullRequest,
288
+ CopilotActionTypePriority,
287
289
 
288
290
  ProbeOwnerTeam,
289
291
  ProbeOwnerUser,
@@ -15,6 +15,13 @@ import ObjectID from "Common/Types/ObjectID";
15
15
  import CopilotAction from "Common/Models/DatabaseModels/CopilotAction";
16
16
  import CopilotCodeRepositoryService from "../Services/CopilotCodeRepositoryService";
17
17
  import CodeRepositoryAuthorization from "../Middleware/CodeRepositoryAuthorization";
18
+ import CopilotActionStatus from "../../Types/Copilot/CopilotActionStatus";
19
+ import CopilotActionTypePriority from "../../Models/DatabaseModels/CopilotActionTypePriority";
20
+ import CopilotActionTypePriorityService from "../Services/CopilotActionTypePriorityService";
21
+ import SortOrder from "../../Types/BaseDatabase/SortOrder";
22
+ import JSONFunctions from "../../Types/JSONFunctions";
23
+ import CopilotActionType from "../../Types/Copilot/CopilotActionType";
24
+ import { JSONObject } from "../../Types/JSON";
18
25
 
19
26
  export default class CopilotActionAPI extends BaseAPI<
20
27
  CopilotAction,
@@ -26,7 +33,7 @@ export default class CopilotActionAPI extends BaseAPI<
26
33
  this.router.get(
27
34
  `${new this.entityType()
28
35
  .getCrudApiPath()
29
- ?.toString()}/copilot-actions-by-file/:secretkey`,
36
+ ?.toString()}/copilot-action-types-by-priority/:secretkey`,
30
37
  CodeRepositoryAuthorization.isAuthorizedRepository,
31
38
  async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
32
39
  try {
@@ -36,10 +43,68 @@ export default class CopilotActionAPI extends BaseAPI<
36
43
  throw new BadDataException("Secret key is required");
37
44
  }
38
45
 
39
- const filePath: string = req.body["filePath"]!;
46
+ const codeRepository: CopilotCodeRepository | null =
47
+ await CopilotCodeRepositoryService.findOneBy({
48
+ query: {
49
+ secretToken: new ObjectID(secretkey),
50
+ },
51
+ select: {
52
+ _id: true,
53
+ },
54
+ props: {
55
+ isRoot: true,
56
+ },
57
+ });
40
58
 
41
- if (!filePath) {
42
- throw new BadDataException("File path is required");
59
+ if (!codeRepository) {
60
+ throw new BadDataException(
61
+ "Code repository not found. Secret key is invalid.",
62
+ );
63
+ }
64
+
65
+ const copilotActionTypes: Array<CopilotActionTypePriority> =
66
+ await CopilotActionTypePriorityService.findBy({
67
+ query: {
68
+ codeRepositoryId: codeRepository.id!,
69
+ },
70
+ select: {
71
+ _id: true,
72
+ actionType: true,
73
+ priority: true,
74
+ },
75
+ skip: 0,
76
+ sort: {
77
+ priority: SortOrder.Ascending,
78
+ },
79
+ limit: LIMIT_PER_PROJECT,
80
+ props: {
81
+ isRoot: true,
82
+ },
83
+ });
84
+
85
+ return Response.sendJsonObjectResponse(req, res, {
86
+ actionTypes: CopilotActionTypePriority.toJSONArray(
87
+ copilotActionTypes,
88
+ CopilotActionTypePriority,
89
+ ),
90
+ });
91
+ } catch (err) {
92
+ next(err);
93
+ }
94
+ },
95
+ );
96
+
97
+ this.router.get(
98
+ `${new this.entityType()
99
+ .getCrudApiPath()
100
+ ?.toString()}/copilot-actions-in-queue/:secretkey`,
101
+ CodeRepositoryAuthorization.isAuthorizedRepository,
102
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
103
+ try {
104
+ const secretkey: string = req.params["secretkey"]!;
105
+
106
+ if (!secretkey) {
107
+ throw new BadDataException("Secret key is required");
43
108
  }
44
109
 
45
110
  const serviceCatalogId: string = req.body["serviceCatalogId"]!;
@@ -71,14 +136,13 @@ export default class CopilotActionAPI extends BaseAPI<
71
136
  await CopilotActionService.findBy({
72
137
  query: {
73
138
  codeRepositoryId: codeRepository.id!,
74
- filePath: filePath,
75
139
  serviceCatalogId: new ObjectID(serviceCatalogId),
140
+ copilotActionStatus: CopilotActionStatus.IN_QUEUE,
76
141
  },
77
142
  select: {
78
143
  _id: true,
79
144
  codeRepositoryId: true,
80
145
  serviceCatalogId: true,
81
- filePath: true,
82
146
  copilotActionStatus: true,
83
147
  copilotActionType: true,
84
148
  createdAt: true,
@@ -107,10 +171,96 @@ export default class CopilotActionAPI extends BaseAPI<
107
171
  },
108
172
  );
109
173
 
174
+ this.router.get(
175
+ `${new this.entityType()
176
+ .getCrudApiPath()
177
+ ?.toString()}/get-copilot-action/:secretkey`,
178
+ CodeRepositoryAuthorization.isAuthorizedRepository,
179
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
180
+ try {
181
+ const secretkey: string = req.params["secretkey"]!;
182
+
183
+ if (!secretkey) {
184
+ throw new BadDataException("Secret key is required");
185
+ }
186
+
187
+ const serviceCatalogId: string = req.body["serviceCatalogId"]!;
188
+
189
+ if (!serviceCatalogId) {
190
+ throw new BadDataException("Service catalog id is required");
191
+ }
192
+
193
+ const codeRepository: CopilotCodeRepository | null =
194
+ await CopilotCodeRepositoryService.findOneBy({
195
+ query: {
196
+ secretToken: new ObjectID(secretkey),
197
+ },
198
+ select: {
199
+ _id: true,
200
+ },
201
+ props: {
202
+ isRoot: true,
203
+ },
204
+ });
205
+
206
+ if (!codeRepository) {
207
+ throw new BadDataException(
208
+ "Code repository not found. Secret key is invalid.",
209
+ );
210
+ }
211
+
212
+ const actionType: CopilotActionType = req.body["actionType"]!;
213
+
214
+ if (!actionType) {
215
+ throw new BadDataException("Action type is required");
216
+ }
217
+
218
+ const actionProps: JSONObject = req.body["actionProps"]!;
219
+
220
+ const copilotAction: CopilotAction | null =
221
+ await CopilotActionService.findOneBy({
222
+ query: {
223
+ codeRepositoryId: codeRepository.id!,
224
+ serviceCatalogId: new ObjectID(serviceCatalogId),
225
+ copilotActionType: actionType,
226
+ copilotActionProp: actionProps as any,
227
+ },
228
+ select: {
229
+ _id: true,
230
+ codeRepositoryId: true,
231
+ serviceCatalogId: true,
232
+ copilotActionStatus: true,
233
+ copilotActionType: true,
234
+ createdAt: true,
235
+ copilotPullRequest: {
236
+ _id: true,
237
+ pullRequestId: true,
238
+ copilotPullRequestStatus: true,
239
+ },
240
+ },
241
+ sort: {
242
+ createdAt: SortOrder.Descending,
243
+ },
244
+ props: {
245
+ isRoot: true,
246
+ },
247
+ });
248
+
249
+ return Response.sendJsonObjectResponse(req, res, {
250
+ copilotAction: copilotAction
251
+ ? CopilotAction.toJSONObject(copilotAction, CopilotAction)
252
+ : null,
253
+ });
254
+ } catch (err) {
255
+ next(err);
256
+ }
257
+ },
258
+ );
259
+
110
260
  this.router.post(
111
261
  `${new this.entityType()
112
262
  .getCrudApiPath()
113
- ?.toString()}/add-copilot-action/:secretkey`,
263
+ ?.toString()}/create-copilot-action/:secretkey`,
114
264
  CodeRepositoryAuthorization.isAuthorizedRepository,
115
265
  async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
116
266
  try {
@@ -147,6 +297,7 @@ export default class CopilotActionAPI extends BaseAPI<
147
297
 
148
298
  copilotAction.codeRepositoryId = codeRepository.id!;
149
299
  copilotAction.projectId = codeRepository.projectId!;
300
+ copilotAction.copilotActionStatus = CopilotActionStatus.IN_QUEUE;
150
301
 
151
302
  const createdAction: CopilotAction =
152
303
  await CopilotActionService.create({
@@ -167,5 +318,98 @@ export default class CopilotActionAPI extends BaseAPI<
167
318
  }
168
319
  },
169
320
  );
321
+
322
+ this.router.post(
323
+ `${new this.entityType()
324
+ .getCrudApiPath()
325
+ ?.toString()}/update-copilot-action/:secretkey`,
326
+ CodeRepositoryAuthorization.isAuthorizedRepository,
327
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
328
+ try {
329
+ const secretkey: string = req.params["secretkey"]!;
330
+
331
+ if (!secretkey) {
332
+ throw new BadDataException("Secret key is required");
333
+ }
334
+
335
+ const codeRepository: CopilotCodeRepository | null =
336
+ await CopilotCodeRepositoryService.findOneBy({
337
+ query: {
338
+ secretToken: new ObjectID(secretkey),
339
+ },
340
+ select: {
341
+ _id: true,
342
+ projectId: true,
343
+ },
344
+ props: {
345
+ isRoot: true,
346
+ },
347
+ });
348
+
349
+ if (!codeRepository) {
350
+ throw new BadDataException(
351
+ "Code repository not found. Secret key is invalid.",
352
+ );
353
+ }
354
+
355
+ req.body = JSONFunctions.deserialize(req.body);
356
+
357
+ const {
358
+ actionStatus,
359
+ pullRequestId,
360
+ commitHash,
361
+ statusMessage,
362
+ logs,
363
+ actionId,
364
+ }: {
365
+ actionStatus: CopilotActionStatus;
366
+ pullRequestId?: ObjectID | undefined;
367
+ commitHash?: string | undefined;
368
+ statusMessage?: string | undefined;
369
+ logs?: Array<string> | undefined;
370
+ actionId: ObjectID;
371
+ } = req.body;
372
+
373
+ const exisingAction: CopilotAction | null =
374
+ await CopilotActionService.findOneBy({
375
+ query: {
376
+ _id: actionId,
377
+ codeRepositoryId: codeRepository.id!,
378
+ },
379
+ select: {
380
+ _id: true,
381
+ },
382
+ props: {
383
+ isRoot: true,
384
+ },
385
+ });
386
+
387
+ if (!exisingAction) {
388
+ throw new BadDataException("Action not found");
389
+ }
390
+
391
+ await CopilotActionService.updateOneBy({
392
+ query: {
393
+ _id: actionId,
394
+ codeRepositoryId: codeRepository.id!,
395
+ },
396
+ data: {
397
+ copilotActionStatus: actionStatus!,
398
+ copilotPullRequestId: pullRequestId!,
399
+ commitHash: commitHash!,
400
+ statusMessage: statusMessage!,
401
+ logs: logs?.join("\n") || "",
402
+ },
403
+ props: {
404
+ isRoot: true,
405
+ },
406
+ });
407
+
408
+ return Response.sendEmptySuccessResponse(req, res);
409
+ } catch (err) {
410
+ next(err);
411
+ }
412
+ },
413
+ );
170
414
  }
171
415
  }
@@ -76,8 +76,6 @@ export default class StatusAPI {
76
76
  logger.info("Ready check: ok");
77
77
  stausReadySuccess.add(1);
78
78
 
79
- span.recordException(new ServerException("Server is ready"));
80
-
81
79
  Response.sendJsonObjectResponse(req, res, {
82
80
  status: "ok",
83
81
  });
@@ -36,7 +36,7 @@ import Response from "../Utils/Response";
36
36
  import BaseAPI from "./BaseAPI";
37
37
  import CommonAPI from "./CommonAPI";
38
38
  import BaseModel from "Common/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
39
- import ArrayUtil from "Common/Types/ArrayUtil";
39
+ import ArrayUtil from "Common/Utils/Array";
40
40
  import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
41
41
  import SortOrder from "Common/Types/BaseDatabase/SortOrder";
42
42
  import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
@@ -11,7 +11,7 @@ import CommonAPI from "./CommonAPI";
11
11
  import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
12
12
  import TelemetryType from "Common/Types/Telemetry/TelemetryType";
13
13
  import TelemetryAttributeService from "../Services/TelemetryAttributeService";
14
- import ArrayUtil from "Common/Types/ArrayUtil";
14
+ import ArrayUtil from "Common/Utils/Array";
15
15
 
16
16
  const router: ExpressRouter = Express.getRouter();
17
17