@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
@@ -5,6 +5,7 @@ import ComponentMetadata, { Port } from "Common/Types/Workflow/Component";
5
5
  import ComponentID from "Common/Types/Workflow/ComponentID";
6
6
  import Components from "Common/Types/Workflow/Components/Email";
7
7
  import nodemailer, { Transporter } from "nodemailer";
8
+ import SMTPTransport from "nodemailer/lib/smtp-transport";
8
9
 
9
10
  export default class Email extends ComponentCode {
10
11
  public constructor() {
@@ -48,53 +49,49 @@ export default class Email extends ComponentCode {
48
49
  }
49
50
 
50
51
  if (!args["to"]) {
51
- throw options.onError(new BadDataException("to not found"));
52
+ throw options.onError(new BadDataException("To Email not found"));
52
53
  }
53
54
 
54
55
  if (args["to"] && typeof args["to"] !== "string") {
55
- throw options.onError(new BadDataException("to is not type of string"));
56
+ throw options.onError(
57
+ new BadDataException("To Email is not type of string"),
58
+ );
56
59
  }
57
60
 
58
61
  if (!args["from"]) {
59
- throw options.onError(new BadDataException("from not found"));
62
+ throw options.onError(new BadDataException("From Email not found"));
60
63
  }
61
64
 
62
65
  if (args["from"] && typeof args["from"] !== "string") {
63
- throw options.onError(new BadDataException("from is not type of string"));
64
- }
65
-
66
- if (!args["smtp-username"]) {
67
- throw options.onError(new BadDataException("email not found"));
66
+ throw options.onError(
67
+ new BadDataException("From Email is not type of string"),
68
+ );
68
69
  }
69
70
 
70
71
  if (args["smtp-username"] && typeof args["smtp-username"] !== "string") {
71
72
  throw options.onError(
72
- new BadDataException("smtp-username is not type of string"),
73
+ new BadDataException("SMTP Username is not type of string"),
73
74
  );
74
75
  }
75
76
 
76
- if (!args["smtp-password"]) {
77
- throw options.onError(new BadDataException("email not found"));
78
- }
79
-
80
77
  if (args["smtp-password"] && typeof args["smtp-password"] !== "string") {
81
78
  throw options.onError(
82
- new BadDataException("smtp-username is not type of string"),
79
+ new BadDataException("SMTP Password is not type of string"),
83
80
  );
84
81
  }
85
82
 
86
83
  if (!args["smtp-host"]) {
87
- throw options.onError(new BadDataException("email not found"));
84
+ throw options.onError(new BadDataException("SMTP Host not found"));
88
85
  }
89
86
 
90
87
  if (args["smtp-host"] && typeof args["smtp-host"] !== "string") {
91
88
  throw options.onError(
92
- new BadDataException("smtp-host is not type of string"),
89
+ new BadDataException("SMTP Host is not type of string"),
93
90
  );
94
91
  }
95
92
 
96
93
  if (!args["smtp-port"]) {
97
- throw options.onError(new BadDataException("email not found"));
94
+ throw options.onError(new BadDataException("SMTP Port not found"));
98
95
  }
99
96
 
100
97
  if (args["smtp-port"] && typeof args["smtp-port"] === "string") {
@@ -103,20 +100,30 @@ export default class Email extends ComponentCode {
103
100
 
104
101
  if (args["smtp-port"] && typeof args["smtp-port"] !== "number") {
105
102
  throw options.onError(
106
- new BadDataException("smtp-host is not type of number"),
103
+ new BadDataException("SMTP Port is not type of number"),
107
104
  );
108
105
  }
109
106
 
110
107
  try {
111
- const mailer: Transporter = nodemailer.createTransport({
108
+ const username: string | undefined =
109
+ args["smtp-username"]?.toString() || undefined;
110
+ const password: string | undefined =
111
+ args["smtp-password"]?.toString() || undefined;
112
+
113
+ const smtpTransport: SMTPTransport.Options = {
112
114
  host: args["smtp-host"]?.toString(),
113
115
  port: args["smtp-port"] as number,
114
116
  secure: Boolean(args["secure"]),
115
- auth: {
116
- user: args["smtp-username"] as string,
117
- pass: args["smtp-password"] as string,
118
- },
119
- });
117
+ };
118
+
119
+ if (username && password) {
120
+ smtpTransport.auth = {
121
+ user: username,
122
+ pass: password,
123
+ };
124
+ }
125
+
126
+ const mailer: Transporter = nodemailer.createTransport(smtpTransport);
120
127
 
121
128
  await mailer.sendMail({
122
129
  from: args["from"].toString(),
@@ -135,7 +142,7 @@ export default class Email extends ComponentCode {
135
142
  options.log(err as Error);
136
143
  return Promise.resolve({
137
144
  returnValues: {},
138
- executePort: successPort,
145
+ executePort: errorPort,
139
146
  });
140
147
  }
141
148
  }
@@ -3,9 +3,18 @@ import LocalFile from "../LocalFile";
3
3
  import logger from "../Logger";
4
4
  import CodeRepositoryFile from "./CodeRepositoryFile";
5
5
  import Dictionary from "Common/Types/Dictionary";
6
- import ServiceLanguageUtil from "Common/Utils/TechStack";
7
6
 
8
7
  export default class CodeRepositoryUtil {
8
+ public static getCurrentCommitHash(data: {
9
+ repoPath: string;
10
+ }): Promise<string> {
11
+ const command: string = `cd ${data.repoPath} && git rev-parse HEAD`;
12
+
13
+ logger.debug("Executing command: " + command);
14
+
15
+ return Execute.executeCommand(command);
16
+ }
17
+
9
18
  public static async addAllChangedFilesToGit(data: {
10
19
  repoPath: string;
11
20
  }): Promise<void> {
@@ -367,24 +376,11 @@ export default class CodeRepositoryUtil {
367
376
  }
368
377
  }
369
378
 
370
- const gitCommitHash: string = await this.getGitCommitHashForFile({
371
- filePath,
372
- repoPath,
373
- });
374
-
375
- const fileExtension: string = fileName.split(".").pop() || "";
376
379
  files[filePath] = {
377
- filePath: LocalFile.sanitizeFilePath(`${directoryPath}/${fileName}`),
378
- gitCommitHash,
379
- fileExtension,
380
- fileName,
381
380
  fileContent: await this.getFileContent({
382
381
  filePath: LocalFile.sanitizeFilePath(`${directoryPath}/${fileName}`),
383
382
  repoPath,
384
383
  }),
385
- fileLanguage: ServiceLanguageUtil.getLanguageByFileExtension({
386
- fileExtension,
387
- }),
388
384
  };
389
385
  }
390
386
 
@@ -1,10 +1,3 @@
1
- import TechStack from "Common/Types/ServiceCatalog/TechStack";
2
-
3
1
  export default interface CodeRepositoryFile {
4
- filePath: string;
5
- gitCommitHash: string;
6
- fileExtension: string;
7
- fileName: string;
8
2
  fileContent: string;
9
- fileLanguage: TechStack;
10
3
  }
@@ -0,0 +1,3 @@
1
+ export default interface DirectoryActionProp {
2
+ directoryPath: string;
3
+ }
@@ -0,0 +1,4 @@
1
+ export default interface ExceptionActionProp {
2
+ fingerprint: string;
3
+ message: string;
4
+ }
@@ -0,0 +1,5 @@
1
+ export default interface FileActionProp {
2
+ filePath: string;
3
+ startLineNumber: number;
4
+ endLineNumber: number;
5
+ }
@@ -0,0 +1,5 @@
1
+ export default interface FunctionActionProp {
2
+ filePath: string;
3
+ className?: string | undefined; // some languages are not class based.
4
+ functionName: string;
5
+ }
@@ -0,0 +1,96 @@
1
+ import DirectoryActionProp from "./DirectoryActionProp";
2
+ import FileActionProp from "./FileActionProp";
3
+ import ExceptionActionProp from "./ExceptionActionProp";
4
+ import SpanActionProp from "./SpanActionProp";
5
+ import FunctionActionProp from "./FunctionActionProp";
6
+ import CopilotActionType from "../CopilotActionType";
7
+
8
+ type CopilotActionProp =
9
+ | DirectoryActionProp
10
+ | FileActionProp
11
+ | ExceptionActionProp
12
+ | SpanActionProp
13
+ | FunctionActionProp;
14
+
15
+ export enum CopilotActionPropType {
16
+ Directory = "Directory",
17
+ File = "File",
18
+ Exception = "Exception",
19
+ Span = "Span",
20
+ Metric = "Metric",
21
+ Function = "Function",
22
+ }
23
+
24
+ export class CopilotActionPropUtil {
25
+ public static getCopilotActionPropByActionType(
26
+ actionType: CopilotActionType,
27
+ ): CopilotActionPropType {
28
+ if (actionType === CopilotActionType.FIX_EXCEPTIONS) {
29
+ return CopilotActionPropType.Exception;
30
+ }
31
+
32
+ if (actionType === CopilotActionType.FIX_PERFORMANCE_ISSUES) {
33
+ return CopilotActionPropType.Span;
34
+ }
35
+
36
+ if (actionType === CopilotActionType.FIX_BUGS) {
37
+ return CopilotActionPropType.Function;
38
+ }
39
+
40
+ if (actionType === CopilotActionType.IMPROVE_LOGS) {
41
+ return CopilotActionPropType.File;
42
+ }
43
+
44
+ if (actionType === CopilotActionType.IMPROVE_SPANS) {
45
+ return CopilotActionPropType.Function;
46
+ }
47
+
48
+ if (actionType === CopilotActionType.IMPROVE_METRICS) {
49
+ return CopilotActionPropType.Function;
50
+ }
51
+
52
+ if (actionType === CopilotActionType.ADD_LOGS) {
53
+ return CopilotActionPropType.File;
54
+ }
55
+
56
+ if (actionType === CopilotActionType.ADD_SPANS) {
57
+ return CopilotActionPropType.Function;
58
+ }
59
+
60
+ if (actionType === CopilotActionType.ADD_METRICS) {
61
+ return CopilotActionPropType.Function;
62
+ }
63
+
64
+ if (actionType === CopilotActionType.REFACTOR_CODE) {
65
+ return CopilotActionPropType.Function;
66
+ }
67
+
68
+ if (actionType === CopilotActionType.WRITE_UNIT_TESTS) {
69
+ return CopilotActionPropType.Function;
70
+ }
71
+
72
+ if (actionType === CopilotActionType.IMPROVE_UNIT_TESTS) {
73
+ return CopilotActionPropType.Function;
74
+ }
75
+
76
+ if (actionType === CopilotActionType.IMPROVE_COMMENTS) {
77
+ return CopilotActionPropType.File;
78
+ }
79
+
80
+ if (actionType === CopilotActionType.ADD_COMMENTS) {
81
+ return CopilotActionPropType.File;
82
+ }
83
+
84
+ if (actionType === CopilotActionType.ADD_README) {
85
+ return CopilotActionPropType.Directory;
86
+ }
87
+
88
+ if (actionType === CopilotActionType.IMPROVE_README) {
89
+ return CopilotActionPropType.File;
90
+ }
91
+
92
+ return CopilotActionPropType.File;
93
+ }
94
+ }
95
+
96
+ export default CopilotActionProp;
@@ -0,0 +1,4 @@
1
+ export default interface SpanActionProp {
2
+ traceId: string;
3
+ spanId?: string;
4
+ }
@@ -1,6 +1,114 @@
1
1
  enum CopilotActionStatus {
2
+ // Processed States.
2
3
  PR_CREATED = "Pull Request Created", // PR created and waiting for review
3
- NO_ACTION_REQUIRED = "No Action Required", // No PR needed. All is good.
4
+ NO_ACTION_REQUIRED = "No Action Required", // Code is all good. No action required. No PR created.
5
+ CANNOT_FIX = "Cannot Fix", // OneUptime Copilot tried to fix the issue but failed.
6
+
7
+ // Processing States
8
+ PROCESSING = "Processing", // Action is being processed.
9
+
10
+ // In Queue
11
+ IN_QUEUE = "In Queue", // Action is in queue.
12
+ }
13
+
14
+ export interface CopilotActionStatusData {
15
+ status: CopilotActionStatus;
16
+ description: string;
17
+ }
18
+
19
+ export class CopilotActionStatusUtil {
20
+ public static getAllCopilotActionStatuses(): Array<CopilotActionStatus> {
21
+ return [
22
+ CopilotActionStatus.PR_CREATED,
23
+ CopilotActionStatus.NO_ACTION_REQUIRED,
24
+ CopilotActionStatus.CANNOT_FIX,
25
+ CopilotActionStatus.PROCESSING,
26
+ CopilotActionStatus.IN_QUEUE,
27
+ ];
28
+ }
29
+
30
+ public static getCopilotActionStatus(status: string): CopilotActionStatus {
31
+ switch (status) {
32
+ case CopilotActionStatus.PR_CREATED:
33
+ return CopilotActionStatus.PR_CREATED;
34
+ case CopilotActionStatus.NO_ACTION_REQUIRED:
35
+ return CopilotActionStatus.NO_ACTION_REQUIRED;
36
+ case CopilotActionStatus.CANNOT_FIX:
37
+ return CopilotActionStatus.CANNOT_FIX;
38
+ case CopilotActionStatus.PROCESSING:
39
+ return CopilotActionStatus.PROCESSING;
40
+ case CopilotActionStatus.IN_QUEUE:
41
+ return CopilotActionStatus.IN_QUEUE;
42
+ default:
43
+ throw new Error(`Invalid CopilotActionStatus: ${status}`);
44
+ }
45
+ }
46
+
47
+ public static isCopilotActionStatus(status: string): boolean {
48
+ return CopilotActionStatusUtil.getAllCopilotActionStatuses().includes(
49
+ status as CopilotActionStatus,
50
+ );
51
+ }
52
+
53
+ public static isCopilotActionStatusArray(statuses: Array<string>): boolean {
54
+ return statuses.every((status: string) => {
55
+ return CopilotActionStatusUtil.isCopilotActionStatus(status);
56
+ });
57
+ }
58
+
59
+ // get processing status
60
+ public static getProcessingStatus(): CopilotActionStatus {
61
+ return CopilotActionStatus.PROCESSING;
62
+ }
63
+
64
+ // get in queue status
65
+ public static getInQueueStatus(): CopilotActionStatus {
66
+ return CopilotActionStatus.IN_QUEUE;
67
+ }
68
+
69
+ // get processed status
70
+ public static getProcessedStatus(): Array<CopilotActionStatus> {
71
+ return [
72
+ CopilotActionStatus.PR_CREATED,
73
+ CopilotActionStatus.NO_ACTION_REQUIRED,
74
+ CopilotActionStatus.CANNOT_FIX,
75
+ ];
76
+ }
77
+
78
+ // get copilot actiomn status data
79
+ public static getCopilotActionStatusData(
80
+ status: CopilotActionStatus,
81
+ ): CopilotActionStatusData {
82
+ switch (status) {
83
+ case CopilotActionStatus.PR_CREATED:
84
+ return {
85
+ status: CopilotActionStatus.PR_CREATED,
86
+ description: "Pull Request Created",
87
+ };
88
+ case CopilotActionStatus.NO_ACTION_REQUIRED:
89
+ return {
90
+ status: CopilotActionStatus.NO_ACTION_REQUIRED,
91
+ description: "No Action Required",
92
+ };
93
+ case CopilotActionStatus.CANNOT_FIX:
94
+ return {
95
+ status: CopilotActionStatus.CANNOT_FIX,
96
+ description: "Cannot Fix",
97
+ };
98
+ case CopilotActionStatus.PROCESSING:
99
+ return {
100
+ status: CopilotActionStatus.PROCESSING,
101
+ description: "Processing",
102
+ };
103
+ case CopilotActionStatus.IN_QUEUE:
104
+ return {
105
+ status: CopilotActionStatus.IN_QUEUE,
106
+ description: "In Queue",
107
+ };
108
+ default:
109
+ throw new Error(`Invalid CopilotActionStatus: ${status}`);
110
+ }
111
+ }
4
112
  }
5
113
 
6
114
  export default CopilotActionStatus;
@@ -1,10 +1,212 @@
1
1
  enum CopilotActionType {
2
2
  IMPROVE_COMMENTS = "Improve Comments",
3
- IMRPOVE_README = "Improve Readme",
3
+ ADD_COMMENTS = "Add Comments",
4
+
5
+ IMPROVE_README = "Improve Readme",
6
+ ADD_README = "Add Readme",
7
+
4
8
  FIX_GRAMMAR_AND_SPELLING = "Fix Grammar and Spelling",
5
9
  IMPROVE_VARIABLE_NAMES = "Improve Variable Names",
6
10
  REFACTOR_CODE = "Refactor Code",
11
+
7
12
  WRITE_UNIT_TESTS = "Write Unit Tests",
13
+ IMPROVE_UNIT_TESTS = "Improve Unit Tests",
14
+
15
+ IMPROVE_LOGS = "Improve Logs",
16
+ ADD_LOGS = "Add Logs",
17
+
18
+ IMPROVE_SPANS = "Improve Spans",
19
+ ADD_SPANS = "Add Spans",
20
+
21
+ IMPROVE_METRICS = "Improve Metrics",
22
+ ADD_METRICS = "Add Metrics",
23
+
24
+ FIX_EXCEPTIONS = "Fix Exceptions",
25
+ FIX_PERFORMANCE_ISSUES = "Fix Performance Issues",
26
+ FIX_BUGS = "Fix Bugs",
27
+
28
+ // SETUP_ACTIONS
29
+ SETUP_OPEN_TELEMETRY = "Setup OpenTelemetry",
30
+
31
+ // Setup Unit Test Framework
32
+ SETUP_UNIT_TEST_FRAMEWORK = "Setup Unit Test Framework",
33
+ }
34
+
35
+ export interface CopilotActionTypeData {
36
+ type: CopilotActionType;
37
+ description: string;
38
+ defaultPriority: number;
39
+ dependsOn: Array<CopilotActionType>;
40
+ }
41
+
42
+ export class CopilotActionTypeUtil {
43
+ public static getAllCopilotActionTypes(): Array<CopilotActionTypeData> {
44
+ return [
45
+ // Fix broken code.
46
+ {
47
+ type: CopilotActionType.FIX_EXCEPTIONS,
48
+ description: "Fix exceptions in your codebase",
49
+ defaultPriority: 1,
50
+ dependsOn: [CopilotActionType.SETUP_OPEN_TELEMETRY],
51
+ },
52
+ {
53
+ type: CopilotActionType.FIX_PERFORMANCE_ISSUES,
54
+ description: "Fix performance issues in your codebase",
55
+ defaultPriority: 1,
56
+ dependsOn: [CopilotActionType.SETUP_OPEN_TELEMETRY],
57
+ },
58
+ {
59
+ type: CopilotActionType.FIX_BUGS,
60
+ description: "Fix simple bugs and small issues in your codebase",
61
+ defaultPriority: 1,
62
+ dependsOn: [],
63
+ },
64
+
65
+ // Improve debugging.
66
+
67
+ // add logs, metircs and spans.
68
+
69
+ {
70
+ type: CopilotActionType.ADD_LOGS,
71
+ description: "Add OpenTelemetry logs in your codebase",
72
+ defaultPriority: 2,
73
+ dependsOn: [CopilotActionType.SETUP_OPEN_TELEMETRY],
74
+ },
75
+ {
76
+ type: CopilotActionType.ADD_SPANS,
77
+ description: "Add OpenTelemetry spans in your codebase",
78
+ defaultPriority: 2,
79
+ dependsOn: [CopilotActionType.SETUP_OPEN_TELEMETRY],
80
+ },
81
+ {
82
+ type: CopilotActionType.ADD_METRICS,
83
+ description: "Add OpenTelemetry metrics in your codebase",
84
+ defaultPriority: 2,
85
+ dependsOn: [CopilotActionType.SETUP_OPEN_TELEMETRY],
86
+ },
87
+ {
88
+ type: CopilotActionType.IMPROVE_LOGS,
89
+ description:
90
+ "Improve OpenTelemetry logs in your codebase where required to make debugging easier.",
91
+ defaultPriority: 2,
92
+ dependsOn: [CopilotActionType.SETUP_OPEN_TELEMETRY],
93
+ },
94
+ {
95
+ type: CopilotActionType.IMPROVE_SPANS,
96
+ description:
97
+ "Improve OpenTelemetry spans in your codebase where required to make debugging easier.",
98
+ defaultPriority: 2,
99
+ dependsOn: [CopilotActionType.SETUP_OPEN_TELEMETRY],
100
+ },
101
+ {
102
+ type: CopilotActionType.IMPROVE_METRICS,
103
+ description:
104
+ "Improve OpenTelemetry metrics in your codebase where required to make debugging easier.",
105
+ defaultPriority: 2,
106
+ dependsOn: [CopilotActionType.SETUP_OPEN_TELEMETRY],
107
+ },
108
+
109
+ // Improve code and test quality.
110
+ {
111
+ type: CopilotActionType.REFACTOR_CODE,
112
+ description: "Refactor code and make it into smaller units",
113
+ defaultPriority: 3,
114
+ dependsOn: [],
115
+ },
116
+ {
117
+ type: CopilotActionType.WRITE_UNIT_TESTS,
118
+ description: "Add unit tests",
119
+ defaultPriority: 3,
120
+ dependsOn: [CopilotActionType.SETUP_UNIT_TEST_FRAMEWORK],
121
+ },
122
+ {
123
+ type: CopilotActionType.IMPROVE_UNIT_TESTS,
124
+ description: "Improve unit tests",
125
+ defaultPriority: 3,
126
+ dependsOn: [CopilotActionType.SETUP_UNIT_TEST_FRAMEWORK],
127
+ },
128
+
129
+ // add comments.
130
+ {
131
+ type: CopilotActionType.IMPROVE_COMMENTS,
132
+ description: "Improve comments in your codebase",
133
+ defaultPriority: 4,
134
+ dependsOn: [],
135
+ },
136
+ {
137
+ type: CopilotActionType.ADD_COMMENTS,
138
+ description: "Add comments in your codebase",
139
+ defaultPriority: 4,
140
+ dependsOn: [],
141
+ },
142
+
143
+ // Add or improve README file.
144
+ {
145
+ type: CopilotActionType.ADD_README,
146
+ description: "Add a README file",
147
+ defaultPriority: 4,
148
+ dependsOn: [],
149
+ },
150
+ {
151
+ type: CopilotActionType.IMPROVE_README,
152
+ description: "Improve the README file",
153
+ defaultPriority: 4,
154
+ dependsOn: [],
155
+ },
156
+
157
+ // Fix grammar and spelling mistakes
158
+ {
159
+ type: CopilotActionType.FIX_GRAMMAR_AND_SPELLING,
160
+ description: "Fix grammar and spelling mistakes",
161
+ defaultPriority: 5,
162
+ dependsOn: [],
163
+ },
164
+ {
165
+ type: CopilotActionType.IMPROVE_VARIABLE_NAMES,
166
+ description: "Improve variable names and make it understandable",
167
+ defaultPriority: 5,
168
+ dependsOn: [],
169
+ },
170
+ ];
171
+ }
172
+
173
+ public static getSetupActionTypes(): Array<CopilotActionTypeData> {
174
+ return [
175
+ {
176
+ type: CopilotActionType.SETUP_OPEN_TELEMETRY,
177
+ description: "Setup OpenTelemetry in your codebase",
178
+ defaultPriority: 1,
179
+ dependsOn: [],
180
+ },
181
+ {
182
+ type: CopilotActionType.SETUP_UNIT_TEST_FRAMEWORK,
183
+ description: "Setup Unit Test Framework in your codebase",
184
+ defaultPriority: 1,
185
+ dependsOn: [],
186
+ },
187
+ ];
188
+ }
189
+
190
+ public static getCopilotActionType(
191
+ type: CopilotActionType,
192
+ ): CopilotActionTypeData {
193
+ return this.getAllCopilotActionTypes().find(
194
+ (copilotActionTypeData: CopilotActionTypeData) => {
195
+ return copilotActionTypeData.type === type;
196
+ },
197
+ ) as CopilotActionTypeData;
198
+ }
199
+
200
+ // get actions by priority.
201
+ public static getActionsByPriority(
202
+ priority: number,
203
+ ): Array<CopilotActionTypeData> {
204
+ return this.getAllCopilotActionTypes().filter(
205
+ (copilotActionTypeData: CopilotActionTypeData) => {
206
+ return copilotActionTypeData.defaultPriority === priority;
207
+ },
208
+ );
209
+ }
8
210
  }
9
211
 
10
212
  export default CopilotActionType;
@@ -17,6 +17,7 @@ enum IconProp {
17
17
  ArrowUpDown = "ArrowUpDown",
18
18
  Cube = "Cube",
19
19
  Unarchive = "Unarchive",
20
+ CPUChip = "CPUChip",
20
21
  Swatch = "Swatch",
21
22
  Squares = "Squares",
22
23
  RectangleStack = "RectangleStack",
@@ -499,6 +499,9 @@ enum Permission {
499
499
  ReadCopilotCodeRepository = "ReadCopilotCodeRepository",
500
500
 
501
501
  ReadCopilotAction = "ReadCopilotAction",
502
+ CreateCopilotAction = "CreateCopilotAction",
503
+ DeleteCopilotAction = "DeleteCopilotAction",
504
+ EditCopilotAction = "EditCopilotAction",
502
505
 
503
506
  ReadCopilotPullRequest = "ReadCopilotPullRequest",
504
507
 
@@ -2556,6 +2559,29 @@ export class PermissionHelper {
2556
2559
  isAssignableToTenant: true,
2557
2560
  isAccessControlPermission: false,
2558
2561
  },
2562
+ {
2563
+ permission: Permission.EditCopilotAction,
2564
+ title: "Edit Copilot Event",
2565
+ description: "This permission can edit Copilot Event of this project.",
2566
+ isAssignableToTenant: true,
2567
+ isAccessControlPermission: false,
2568
+ },
2569
+ {
2570
+ permission: Permission.DeleteCopilotAction,
2571
+ title: "Delete Copilot Event",
2572
+ description:
2573
+ "This permission can delete Copilot Event of this project.",
2574
+ isAssignableToTenant: true,
2575
+ isAccessControlPermission: false,
2576
+ },
2577
+ {
2578
+ permission: Permission.CreateCopilotAction,
2579
+ title: "Create Copilot Event",
2580
+ description:
2581
+ "This permission can create Copilot Event of this project.",
2582
+ isAssignableToTenant: true,
2583
+ isAccessControlPermission: false,
2584
+ },
2559
2585
 
2560
2586
  {
2561
2587
  permission: Permission.CreateProbeOwnerTeam,