@oneuptime/common 7.0.3010 → 7.0.3018

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/Models/DatabaseModels/CopilotAction.ts +232 -38
  2. package/Models/DatabaseModels/CopilotActionTypePriority.ts +325 -0
  3. package/Models/DatabaseModels/Index.ts +2 -0
  4. package/Server/API/CopilotActionAPI.ts +69 -7
  5. package/Server/API/StatusAPI.ts +0 -2
  6. package/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.ts +51 -0
  7. package/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.ts +23 -0
  8. package/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.ts +13 -0
  9. package/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.ts +17 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  11. package/Server/Services/CopilotActionTypePriorityService.ts +66 -0
  12. package/Server/Services/Index.ts +2 -0
  13. package/Server/Types/Workflow/Components/Email.ts +32 -25
  14. package/Server/Utils/CodeRepository/CodeRepository.ts +10 -14
  15. package/Server/Utils/CodeRepository/CodeRepositoryFile.ts +0 -7
  16. package/Types/Copilot/CopilotActionProps/DirectoryActionProp.ts +3 -0
  17. package/Types/Copilot/CopilotActionProps/ExceptionActionProp.ts +4 -0
  18. package/Types/Copilot/CopilotActionProps/FileActionProp.ts +5 -0
  19. package/Types/Copilot/CopilotActionProps/FunctionActionProp.ts +5 -0
  20. package/Types/Copilot/CopilotActionProps/Index.ts +96 -0
  21. package/Types/Copilot/CopilotActionProps/SpanActionProp.ts +4 -0
  22. package/Types/Copilot/CopilotActionStatus.ts +109 -1
  23. package/Types/Copilot/CopilotActionType.ts +203 -1
  24. package/Types/Icon/IconProp.ts +1 -0
  25. package/Types/Permission.ts +26 -0
  26. package/Types/Workflow/Components/Email.ts +4 -4
  27. package/UI/Components/Alerts/Alert.tsx +1 -1
  28. package/UI/Components/Icon/Icon.tsx +8 -0
  29. package/UI/Components/Workflow/WorkflowStatus.tsx +2 -2
  30. package/build/dist/Models/DatabaseModels/CopilotAction.js +237 -40
  31. package/build/dist/Models/DatabaseModels/CopilotAction.js.map +1 -1
  32. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js +343 -0
  33. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js.map +1 -0
  34. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  35. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  36. package/build/dist/Server/API/CopilotActionAPI.js +56 -9
  37. package/build/dist/Server/API/CopilotActionAPI.js.map +1 -1
  38. package/build/dist/Server/API/StatusAPI.js +0 -1
  39. package/build/dist/Server/API/StatusAPI.js.map +1 -1
  40. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.js +24 -0
  41. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.js.map +1 -0
  42. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.js +14 -0
  43. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.js.map +1 -0
  44. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.js +12 -0
  45. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.js.map +1 -0
  46. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.js +12 -0
  47. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.js.map +1 -0
  48. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  49. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  50. package/build/dist/Server/Services/CopilotActionTypePriorityService.js +45 -0
  51. package/build/dist/Server/Services/CopilotActionTypePriorityService.js.map +1 -0
  52. package/build/dist/Server/Services/Index.js +2 -0
  53. package/build/dist/Server/Services/Index.js.map +1 -1
  54. package/build/dist/Server/Types/Workflow/Components/Email.js +26 -27
  55. package/build/dist/Server/Types/Workflow/Components/Email.js.map +1 -1
  56. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js +5 -13
  57. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js.map +1 -1
  58. package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js +2 -0
  59. package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js.map +1 -0
  60. package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js +2 -0
  61. package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js.map +1 -0
  62. package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js +2 -0
  63. package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js.map +1 -0
  64. package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js +2 -0
  65. package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js.map +1 -0
  66. package/build/dist/Types/Copilot/CopilotActionProps/Index.js +64 -0
  67. package/build/dist/Types/Copilot/CopilotActionProps/Index.js.map +1 -0
  68. package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js +2 -0
  69. package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js.map +1 -0
  70. package/build/dist/Types/Copilot/CopilotActionStatus.js +89 -0
  71. package/build/dist/Types/Copilot/CopilotActionStatus.js.map +1 -1
  72. package/build/dist/Types/Copilot/CopilotActionType.js +165 -1
  73. package/build/dist/Types/Copilot/CopilotActionType.js.map +1 -1
  74. package/build/dist/Types/Icon/IconProp.js +1 -0
  75. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  76. package/build/dist/Types/Permission.js +24 -0
  77. package/build/dist/Types/Permission.js.map +1 -1
  78. package/build/dist/Types/Workflow/Components/Email.js +4 -4
  79. package/build/dist/Types/Workflow/Components/Email.js.map +1 -1
  80. package/build/dist/UI/Components/Alerts/Alert.js +1 -1
  81. package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
  82. package/build/dist/UI/Components/Icon/Icon.js +3 -0
  83. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  84. package/build/dist/UI/Components/Workflow/WorkflowStatus.js +2 -2
  85. package/build/dist/UI/Components/Workflow/WorkflowStatus.js.map +1 -1
  86. package/package.json +2 -2
@@ -0,0 +1,325 @@
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
+ read: [
30
+ Permission.ProjectOwner,
31
+ Permission.ProjectAdmin,
32
+ Permission.ProjectMember,
33
+ Permission.ReadCopilotAction,
34
+ ],
35
+ delete: [],
36
+ update: [],
37
+ })
38
+ @EnableWorkflow({
39
+ create: true,
40
+ delete: false,
41
+ update: true,
42
+ read: false,
43
+ })
44
+ @CrudApiEndpoint(new Route("/copilot-action-type-prority"))
45
+ @TableMetadata({
46
+ tableName: "CopilotActionType",
47
+ singularName: "Copilot Action Priority",
48
+ pluralName: "Copilot Action Priorities",
49
+ icon: IconProp.Bolt,
50
+ tableDescription: "Priority of Copilot Actions",
51
+ })
52
+ @Entity({
53
+ name: "CopilotActionTypePriority",
54
+ })
55
+ export default class CopilotActionTypePriority extends BaseModel {
56
+ @ColumnAccessControl({
57
+ create: [],
58
+ read: [
59
+ Permission.ProjectOwner,
60
+ Permission.ProjectAdmin,
61
+ Permission.ProjectMember,
62
+ Permission.ReadCopilotAction,
63
+ ],
64
+ update: [],
65
+ })
66
+ @TableColumn({
67
+ manyToOneRelationColumn: "projectId",
68
+ type: TableColumnType.Entity,
69
+ modelType: Project,
70
+ title: "Project",
71
+ description: "Relation to Project Resource in which this object belongs",
72
+ })
73
+ @ManyToOne(
74
+ () => {
75
+ return Project;
76
+ },
77
+ {
78
+ eager: false,
79
+ nullable: false,
80
+ onDelete: "CASCADE",
81
+ orphanedRowAction: "nullify",
82
+ },
83
+ )
84
+ @JoinColumn({ name: "projectId" })
85
+ public project?: Project = undefined;
86
+
87
+ @ColumnAccessControl({
88
+ create: [],
89
+ read: [
90
+ Permission.ProjectOwner,
91
+ Permission.ProjectAdmin,
92
+ Permission.ProjectMember,
93
+ Permission.ReadCopilotAction,
94
+ ],
95
+ update: [],
96
+ })
97
+ @Index()
98
+ @TableColumn({
99
+ type: TableColumnType.ObjectID,
100
+ required: true,
101
+ canReadOnRelationQuery: true,
102
+ title: "Project ID",
103
+ description: "ID of your OneUptime Project in which this object belongs",
104
+ })
105
+ @Column({
106
+ type: ColumnType.ObjectID,
107
+ nullable: false,
108
+ transformer: ObjectID.getDatabaseTransformer(),
109
+ })
110
+ public projectId?: ObjectID = undefined;
111
+
112
+ @ColumnAccessControl({
113
+ create: [],
114
+ read: [
115
+ Permission.ProjectOwner,
116
+ Permission.ProjectAdmin,
117
+ Permission.ProjectMember,
118
+ Permission.ReadCopilotAction,
119
+ ],
120
+ update: [],
121
+ })
122
+ @TableColumn({
123
+ manyToOneRelationColumn: "codeRepositoryId",
124
+ type: TableColumnType.Entity,
125
+ modelType: CodeRepository,
126
+ title: "Code Repository",
127
+ description:
128
+ "Relation to CodeRepository Resource in which this object belongs",
129
+ })
130
+ @ManyToOne(
131
+ () => {
132
+ return CodeRepository;
133
+ },
134
+ {
135
+ eager: false,
136
+ nullable: true,
137
+ onDelete: "CASCADE",
138
+ orphanedRowAction: "nullify",
139
+ },
140
+ )
141
+ @JoinColumn({ name: "codeRepositoryId" })
142
+ public codeRepository?: CodeRepository = undefined;
143
+
144
+ @ColumnAccessControl({
145
+ create: [],
146
+ read: [
147
+ Permission.ProjectOwner,
148
+ Permission.ProjectAdmin,
149
+ Permission.ProjectMember,
150
+ Permission.ReadCopilotAction,
151
+ ],
152
+ update: [],
153
+ })
154
+ @Index()
155
+ @TableColumn({
156
+ type: TableColumnType.ObjectID,
157
+ required: true,
158
+ canReadOnRelationQuery: true,
159
+ title: "Code Repository ID",
160
+ description:
161
+ "ID of your OneUptime Code Repository in which this object belongs",
162
+ })
163
+ @Column({
164
+ type: ColumnType.ObjectID,
165
+ nullable: false,
166
+ transformer: ObjectID.getDatabaseTransformer(),
167
+ })
168
+ public codeRepositoryId?: ObjectID = undefined;
169
+
170
+ @ColumnAccessControl({
171
+ create: [],
172
+ read: [
173
+ Permission.ProjectOwner,
174
+ Permission.ProjectAdmin,
175
+ Permission.ProjectMember,
176
+ Permission.ReadCopilotAction,
177
+ ],
178
+ update: [],
179
+ })
180
+ @TableColumn({
181
+ manyToOneRelationColumn: "createdByUserId",
182
+ type: TableColumnType.Entity,
183
+ modelType: User,
184
+ title: "Created by User",
185
+ description:
186
+ "Relation to User who created this object (if this object was created by a User)",
187
+ })
188
+ @ManyToOne(
189
+ () => {
190
+ return User;
191
+ },
192
+ {
193
+ eager: false,
194
+ nullable: true,
195
+ onDelete: "CASCADE",
196
+ orphanedRowAction: "nullify",
197
+ },
198
+ )
199
+ @JoinColumn({ name: "createdByUserId" })
200
+ public createdByUser?: User = undefined;
201
+
202
+ @ColumnAccessControl({
203
+ create: [],
204
+ read: [
205
+ Permission.ProjectOwner,
206
+ Permission.ProjectAdmin,
207
+ Permission.ProjectMember,
208
+ Permission.ReadCopilotAction,
209
+ ],
210
+ update: [],
211
+ })
212
+ @TableColumn({
213
+ type: TableColumnType.ObjectID,
214
+ title: "Created by User ID",
215
+ description:
216
+ "User ID who created this object (if this object was created by a User)",
217
+ })
218
+ @Column({
219
+ type: ColumnType.ObjectID,
220
+ nullable: true,
221
+ transformer: ObjectID.getDatabaseTransformer(),
222
+ })
223
+ public createdByUserId?: ObjectID = undefined;
224
+
225
+ @ColumnAccessControl({
226
+ create: [],
227
+ read: [
228
+ Permission.ProjectOwner,
229
+ Permission.ProjectAdmin,
230
+ Permission.ProjectMember,
231
+ Permission.ReadCopilotAction,
232
+ ],
233
+ update: [],
234
+ })
235
+ @TableColumn({
236
+ manyToOneRelationColumn: "deletedByUserId",
237
+ type: TableColumnType.Entity,
238
+ title: "Deleted by User",
239
+ description:
240
+ "Relation to User who deleted this object (if this object was deleted by a User)",
241
+ })
242
+ @ManyToOne(
243
+ () => {
244
+ return User;
245
+ },
246
+ {
247
+ cascade: false,
248
+ eager: false,
249
+ nullable: true,
250
+ onDelete: "CASCADE",
251
+ orphanedRowAction: "nullify",
252
+ },
253
+ )
254
+ @JoinColumn({ name: "deletedByUserId" })
255
+ public deletedByUser?: User = undefined;
256
+
257
+ @ColumnAccessControl({
258
+ create: [],
259
+ read: [
260
+ Permission.ProjectOwner,
261
+ Permission.ProjectAdmin,
262
+ Permission.ProjectMember,
263
+ Permission.ReadCopilotAction,
264
+ ],
265
+ update: [],
266
+ })
267
+ @TableColumn({
268
+ type: TableColumnType.ObjectID,
269
+ title: "Deleted by User ID",
270
+ description:
271
+ "User ID who deleted this object (if this object was deleted by a User)",
272
+ })
273
+ @Column({
274
+ type: ColumnType.ObjectID,
275
+ nullable: true,
276
+ transformer: ObjectID.getDatabaseTransformer(),
277
+ })
278
+ public deletedByUserId?: ObjectID = undefined;
279
+
280
+ @ColumnAccessControl({
281
+ create: [],
282
+ read: [
283
+ Permission.ProjectOwner,
284
+ Permission.ProjectAdmin,
285
+ Permission.ProjectMember,
286
+ Permission.ReadCopilotAction,
287
+ ],
288
+ update: [],
289
+ })
290
+ @TableColumn({
291
+ type: TableColumnType.ShortText,
292
+ title: "Copilot Action Type",
293
+ required: true,
294
+ description: "Copilot Action Type for this Code Repository",
295
+ })
296
+ @Column({
297
+ type: ColumnType.ShortText,
298
+ length: ColumnLength.ShortText,
299
+ nullable: false,
300
+ })
301
+ public actionType?: CopilotActionType = undefined;
302
+
303
+ @ColumnAccessControl({
304
+ create: [],
305
+ read: [
306
+ Permission.ProjectOwner,
307
+ Permission.ProjectAdmin,
308
+ Permission.ProjectMember,
309
+ Permission.ReadCopilotAction,
310
+ ],
311
+ update: [],
312
+ })
313
+ @TableColumn({
314
+ type: TableColumnType.Number,
315
+ title: "Priority",
316
+ required: true,
317
+ description: "Priority of Copilot Action Type for this Code Repository",
318
+ })
319
+ @Column({
320
+ type: ColumnType.Number,
321
+ nullable: false,
322
+ default: 1,
323
+ })
324
+ public priority?: number = undefined;
325
+ }
@@ -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,10 @@ 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";
18
22
 
19
23
  export default class CopilotActionAPI extends BaseAPI<
20
24
  CopilotAction,
@@ -26,7 +30,7 @@ export default class CopilotActionAPI extends BaseAPI<
26
30
  this.router.get(
27
31
  `${new this.entityType()
28
32
  .getCrudApiPath()
29
- ?.toString()}/copilot-actions-by-file/:secretkey`,
33
+ ?.toString()}/copilot-action-types-by-priority/:secretkey`,
30
34
  CodeRepositoryAuthorization.isAuthorizedRepository,
31
35
  async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
32
36
  try {
@@ -36,10 +40,68 @@ export default class CopilotActionAPI extends BaseAPI<
36
40
  throw new BadDataException("Secret key is required");
37
41
  }
38
42
 
39
- const filePath: string = req.body["filePath"]!;
43
+ const codeRepository: CopilotCodeRepository | null =
44
+ await CopilotCodeRepositoryService.findOneBy({
45
+ query: {
46
+ secretToken: new ObjectID(secretkey),
47
+ },
48
+ select: {
49
+ _id: true,
50
+ },
51
+ props: {
52
+ isRoot: true,
53
+ },
54
+ });
55
+
56
+ if (!codeRepository) {
57
+ throw new BadDataException(
58
+ "Code repository not found. Secret key is invalid.",
59
+ );
60
+ }
40
61
 
41
- if (!filePath) {
42
- throw new BadDataException("File path is required");
62
+ const copilotActionTypes: Array<CopilotActionTypePriority> =
63
+ await CopilotActionTypePriorityService.findBy({
64
+ query: {
65
+ codeRepositoryId: codeRepository.id!,
66
+ },
67
+ select: {
68
+ _id: true,
69
+ actionType: true,
70
+ priority: true,
71
+ },
72
+ skip: 0,
73
+ sort: {
74
+ priority: SortOrder.Ascending,
75
+ },
76
+ limit: LIMIT_PER_PROJECT,
77
+ props: {
78
+ isRoot: true,
79
+ },
80
+ });
81
+
82
+ return Response.sendJsonObjectResponse(req, res, {
83
+ actionTypes: CopilotActionTypePriority.toJSONArray(
84
+ copilotActionTypes,
85
+ CopilotActionTypePriority,
86
+ ),
87
+ });
88
+ } catch (err) {
89
+ next(err);
90
+ }
91
+ },
92
+ );
93
+
94
+ this.router.get(
95
+ `${new this.entityType()
96
+ .getCrudApiPath()
97
+ ?.toString()}/copilot-actions-in-queue/:secretkey`,
98
+ CodeRepositoryAuthorization.isAuthorizedRepository,
99
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
100
+ try {
101
+ const secretkey: string = req.params["secretkey"]!;
102
+
103
+ if (!secretkey) {
104
+ throw new BadDataException("Secret key is required");
43
105
  }
44
106
 
45
107
  const serviceCatalogId: string = req.body["serviceCatalogId"]!;
@@ -71,14 +133,13 @@ export default class CopilotActionAPI extends BaseAPI<
71
133
  await CopilotActionService.findBy({
72
134
  query: {
73
135
  codeRepositoryId: codeRepository.id!,
74
- filePath: filePath,
75
136
  serviceCatalogId: new ObjectID(serviceCatalogId),
137
+ copilotActionStatus: CopilotActionStatus.IN_QUEUE,
76
138
  },
77
139
  select: {
78
140
  _id: true,
79
141
  codeRepositoryId: true,
80
142
  serviceCatalogId: true,
81
- filePath: true,
82
143
  copilotActionStatus: true,
83
144
  copilotActionType: true,
84
145
  createdAt: true,
@@ -110,7 +171,7 @@ export default class CopilotActionAPI extends BaseAPI<
110
171
  this.router.post(
111
172
  `${new this.entityType()
112
173
  .getCrudApiPath()
113
- ?.toString()}/add-copilot-action/:secretkey`,
174
+ ?.toString()}/queue-copilot-action/:secretkey`,
114
175
  CodeRepositoryAuthorization.isAuthorizedRepository,
115
176
  async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
116
177
  try {
@@ -147,6 +208,7 @@ export default class CopilotActionAPI extends BaseAPI<
147
208
 
148
209
  copilotAction.codeRepositoryId = codeRepository.id!;
149
210
  copilotAction.projectId = codeRepository.projectId!;
211
+ copilotAction.copilotActionStatus = CopilotActionStatus.IN_QUEUE;
150
212
 
151
213
  const createdAction: CopilotAction =
152
214
  await CopilotActionService.create({
@@ -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
  });
@@ -0,0 +1,51 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1725291476867 implements MigrationInterface {
4
+ public name = "MigrationName1725291476867";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `CREATE TABLE "CopilotActionTypePriority" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP, "version" integer NOT NULL, "projectId" uuid NOT NULL, "codeRepositoryId" uuid NOT NULL, "createdByUserId" uuid, "deletedByUserId" uuid, "actionType" character varying(100) NOT NULL, "priority" integer NOT NULL DEFAULT '1', CONSTRAINT "PK_e87af58e75ac25610e48807703e" PRIMARY KEY ("_id"))`,
9
+ );
10
+ await queryRunner.query(
11
+ `CREATE INDEX "IDX_d8e9d95bc4e4094b84d812950f" ON "CopilotActionTypePriority" ("projectId") `,
12
+ );
13
+ await queryRunner.query(
14
+ `CREATE INDEX "IDX_a4c64c718646aebbfe469d6c95" ON "CopilotActionTypePriority" ("codeRepositoryId") `,
15
+ );
16
+ await queryRunner.query(
17
+ `ALTER TABLE "CopilotActionTypePriority" ADD CONSTRAINT "FK_d8e9d95bc4e4094b84d812950f2" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "CopilotActionTypePriority" ADD CONSTRAINT "FK_a4c64c718646aebbfe469d6c950" FOREIGN KEY ("codeRepositoryId") REFERENCES "CopilotCodeRepository"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
21
+ );
22
+ await queryRunner.query(
23
+ `ALTER TABLE "CopilotActionTypePriority" ADD CONSTRAINT "FK_039fd3af73a2c910eee5ed67669" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "CopilotActionTypePriority" ADD CONSTRAINT "FK_01864ec4b8b5f343e484a09128a" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
27
+ );
28
+ }
29
+
30
+ public async down(queryRunner: QueryRunner): Promise<void> {
31
+ await queryRunner.query(
32
+ `ALTER TABLE "CopilotActionTypePriority" DROP CONSTRAINT "FK_01864ec4b8b5f343e484a09128a"`,
33
+ );
34
+ await queryRunner.query(
35
+ `ALTER TABLE "CopilotActionTypePriority" DROP CONSTRAINT "FK_039fd3af73a2c910eee5ed67669"`,
36
+ );
37
+ await queryRunner.query(
38
+ `ALTER TABLE "CopilotActionTypePriority" DROP CONSTRAINT "FK_a4c64c718646aebbfe469d6c950"`,
39
+ );
40
+ await queryRunner.query(
41
+ `ALTER TABLE "CopilotActionTypePriority" DROP CONSTRAINT "FK_d8e9d95bc4e4094b84d812950f2"`,
42
+ );
43
+ await queryRunner.query(
44
+ `DROP INDEX "public"."IDX_a4c64c718646aebbfe469d6c95"`,
45
+ );
46
+ await queryRunner.query(
47
+ `DROP INDEX "public"."IDX_d8e9d95bc4e4094b84d812950f"`,
48
+ );
49
+ await queryRunner.query(`DROP TABLE "CopilotActionTypePriority"`);
50
+ }
51
+ }
@@ -0,0 +1,23 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1725357719072 implements MigrationInterface {
4
+ public name = "MigrationName1725357719072";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "CopilotAction" ADD "copilotActionProp" jsonb`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "CopilotAction" ADD "statusMessage" text`,
12
+ );
13
+ }
14
+
15
+ public async down(queryRunner: QueryRunner): Promise<void> {
16
+ await queryRunner.query(
17
+ `ALTER TABLE "CopilotAction" DROP COLUMN "statusMessage"`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "CopilotAction" DROP COLUMN "copilotActionProp"`,
21
+ );
22
+ }
23
+ }
@@ -0,0 +1,13 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1725360199561 implements MigrationInterface {
4
+ public name = "MigrationName1725360199561";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`ALTER TABLE "CopilotAction" ADD "logs" text`);
8
+ }
9
+
10
+ public async down(queryRunner: QueryRunner): Promise<void> {
11
+ await queryRunner.query(`ALTER TABLE "CopilotAction" DROP COLUMN "logs"`);
12
+ }
13
+ }
@@ -0,0 +1,17 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1725379949648 implements MigrationInterface {
4
+ public name = "MigrationName1725379949648";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "CopilotAction" ADD "isPriority" boolean NOT NULL DEFAULT false`,
9
+ );
10
+ }
11
+
12
+ public async down(queryRunner: QueryRunner): Promise<void> {
13
+ await queryRunner.query(
14
+ `ALTER TABLE "CopilotAction" DROP COLUMN "isPriority"`,
15
+ );
16
+ }
17
+ }
@@ -44,6 +44,10 @@ import { MigrationName1724078044172 } from "./1724078044172-MigrationName";
44
44
  import { MigrationName1724610006927 } from "./1724610006927-MigrationName";
45
45
  import { MigrationName1724613666632 } from "./1724613666632-MigrationName";
46
46
  import { MigrationName1724659071843 } from "./1724659071843-MigrationName";
47
+ import { MigrationName1725291476867 } from "./1725291476867-MigrationName";
48
+ import { MigrationName1725357719072 } from "./1725357719072-MigrationName";
49
+ import { MigrationName1725360199561 } from "./1725360199561-MigrationName";
50
+ import { MigrationName1725379949648 } from "./1725379949648-MigrationName";
47
51
 
48
52
  export default [
49
53
  InitialMigration,
@@ -92,4 +96,8 @@ export default [
92
96
  MigrationName1724610006927,
93
97
  MigrationName1724613666632,
94
98
  MigrationName1724659071843,
99
+ MigrationName1725291476867,
100
+ MigrationName1725357719072,
101
+ MigrationName1725360199561,
102
+ MigrationName1725379949648,
95
103
  ];
@@ -0,0 +1,66 @@
1
+ import CopilotActionType from "../../Types/Copilot/CopilotActionType";
2
+ import BadDataException from "../../Types/Exception/BadDataException";
3
+ import ObjectID from "../../Types/ObjectID";
4
+ import CreateBy from "../Types/Database/CreateBy";
5
+ import { OnCreate } from "../Types/Database/Hooks";
6
+ import DatabaseService from "./DatabaseService";
7
+ import Model from "Common/Models/DatabaseModels/CopilotActionTypePriority";
8
+
9
+ export class Service extends DatabaseService<Model> {
10
+ public constructor() {
11
+ super(Model);
12
+ }
13
+
14
+ protected override async onBeforeCreate(
15
+ createBy: CreateBy<Model>,
16
+ ): Promise<OnCreate<Model>> {
17
+ // check if the action exits witht he same name exists in the same repo.
18
+
19
+ const actionType: CopilotActionType | undefined = createBy.data.actionType;
20
+ const codeRepositoryId: ObjectID | undefined =
21
+ createBy.data.codeRepositoryId;
22
+
23
+ if (!actionType) {
24
+ throw new BadDataException("ActionType is required");
25
+ }
26
+
27
+ if (!codeRepositoryId) {
28
+ throw new BadDataException("CodeRepositoryId is required");
29
+ }
30
+
31
+ const existingItem: Model | null = await this.findOneBy({
32
+ query: {
33
+ actionType,
34
+ codeRepositoryId,
35
+ },
36
+ props: {
37
+ isRoot: true,
38
+ },
39
+ });
40
+
41
+ if (existingItem) {
42
+ throw new BadDataException(
43
+ "Action Type already exists for this repository.",
44
+ );
45
+ }
46
+
47
+ // check if the priority is in between 1 and 5.
48
+
49
+ const priority: number | undefined = createBy.data.priority;
50
+
51
+ if (!priority) {
52
+ throw new BadDataException("Priority is required");
53
+ }
54
+
55
+ if (priority < 1 || priority > 5) {
56
+ throw new BadDataException("Priority must be between 1 and 5");
57
+ }
58
+
59
+ return {
60
+ createBy: createBy,
61
+ carryForward: null,
62
+ };
63
+ }
64
+ }
65
+
66
+ export default new Service();
@@ -132,6 +132,7 @@ import ServiceCatalogDependencyService from "./ServiceCatalogDependencyService";
132
132
  import TelemetryAttributeService from "./TelemetryAttributeService";
133
133
  import TelemetryExceptionService from "./TelemetryExceptionService";
134
134
  import ExceptionInstanceService from "./ExceptionInstanceService";
135
+ import CopilotActionTypePriorityService from "./CopilotActionTypePriorityService";
135
136
 
136
137
  const services: Array<BaseService> = [
137
138
  AcmeCertificateService,
@@ -273,6 +274,7 @@ const services: Array<BaseService> = [
273
274
  CopilotActionService,
274
275
  ServiceCopilotCodeRepositoryService,
275
276
  CopilotPullRequestService,
277
+ CopilotActionTypePriorityService,
276
278
 
277
279
  TelemetryExceptionService,
278
280
  ];