@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.
- package/Models/DatabaseModels/CopilotAction.ts +232 -38
- package/Models/DatabaseModels/CopilotActionTypePriority.ts +340 -0
- package/Models/DatabaseModels/CopilotPullRequest.ts +1 -0
- package/Models/DatabaseModels/Index.ts +2 -0
- package/Server/API/CopilotActionAPI.ts +251 -7
- package/Server/API/StatusAPI.ts +0 -2
- package/Server/API/StatusPageAPI.ts +1 -1
- package/Server/API/TelemetryAPI.ts +1 -1
- package/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.ts +51 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.ts +23 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.ts +13 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Services/CopilotActionTypePriorityService.ts +66 -0
- package/Server/Services/CopilotCodeRepositoryService.ts +36 -0
- package/Server/Services/Index.ts +2 -0
- package/Server/Services/ServiceCatalogService.ts +1 -1
- package/Server/Services/TelemetryServiceService.ts +1 -1
- package/Server/Types/Database/Permissions/AccessControlPermission.ts +1 -1
- package/Server/Types/Workflow/Components/Email.ts +32 -25
- package/Server/Utils/CodeRepository/CodeRepository.ts +11 -14
- package/Server/Utils/CodeRepository/CodeRepositoryFile.ts +1 -7
- package/Tests/Types/ArrayUtil.test.ts +1 -1
- package/Types/Copilot/CopilotActionProps/DirectoryActionProp.ts +3 -0
- package/Types/Copilot/CopilotActionProps/ExceptionActionProp.ts +4 -0
- package/Types/Copilot/CopilotActionProps/FileActionProp.ts +7 -0
- package/Types/Copilot/CopilotActionProps/FunctionActionProp.ts +5 -0
- package/Types/Copilot/CopilotActionProps/Index.ts +96 -0
- package/Types/Copilot/CopilotActionProps/SpanActionProp.ts +4 -0
- package/Types/Copilot/CopilotActionStatus.ts +109 -1
- package/Types/Copilot/CopilotActionType.ts +203 -1
- package/Types/Icon/IconProp.ts +1 -0
- package/Types/Permission.ts +26 -0
- package/Types/Workflow/Components/Email.ts +4 -4
- package/UI/Components/Alerts/Alert.tsx +1 -1
- package/UI/Components/Icon/Icon.tsx +8 -0
- package/UI/Components/Workflow/WorkflowStatus.tsx +2 -2
- package/{Types/ArrayUtil.ts → Utils/Array.ts} +1 -1
- package/build/dist/Models/DatabaseModels/CopilotAction.js +237 -40
- package/build/dist/Models/DatabaseModels/CopilotAction.js.map +1 -1
- package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js +358 -0
- package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js.map +1 -0
- package/build/dist/Models/DatabaseModels/CopilotPullRequest.js +1 -0
- package/build/dist/Models/DatabaseModels/CopilotPullRequest.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Server/API/CopilotActionAPI.js +185 -9
- package/build/dist/Server/API/CopilotActionAPI.js.map +1 -1
- package/build/dist/Server/API/StatusAPI.js +0 -1
- package/build/dist/Server/API/StatusAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +1 -1
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/API/TelemetryAPI.js +1 -1
- package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.js +24 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725291476867-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725357719072-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725360199561-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725379949648-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/CopilotActionTypePriorityService.js +45 -0
- package/build/dist/Server/Services/CopilotActionTypePriorityService.js.map +1 -0
- package/build/dist/Server/Services/CopilotCodeRepositoryService.js +22 -0
- package/build/dist/Server/Services/CopilotCodeRepositoryService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +2 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/ServiceCatalogService.js +1 -1
- package/build/dist/Server/Services/ServiceCatalogService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryServiceService.js +1 -1
- package/build/dist/Server/Services/TelemetryServiceService.js.map +1 -1
- package/build/dist/Server/Types/Database/Permissions/AccessControlPermission.js +1 -1
- package/build/dist/Server/Types/Database/Permissions/AccessControlPermission.js.map +1 -1
- package/build/dist/Server/Types/Workflow/Components/Email.js +26 -27
- package/build/dist/Server/Types/Workflow/Components/Email.js.map +1 -1
- package/build/dist/Server/Utils/CodeRepository/CodeRepository.js +6 -13
- package/build/dist/Server/Utils/CodeRepository/CodeRepository.js.map +1 -1
- package/build/dist/Tests/Types/ArrayUtil.test.js +1 -1
- package/build/dist/Tests/Types/ArrayUtil.test.js.map +1 -1
- package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js +2 -0
- package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js.map +1 -0
- package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js +2 -0
- package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js.map +1 -0
- package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js +2 -0
- package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js.map +1 -0
- package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js +2 -0
- package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js.map +1 -0
- package/build/dist/Types/Copilot/CopilotActionProps/Index.js +64 -0
- package/build/dist/Types/Copilot/CopilotActionProps/Index.js.map +1 -0
- package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js +2 -0
- package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js.map +1 -0
- package/build/dist/Types/Copilot/CopilotActionStatus.js +89 -0
- package/build/dist/Types/Copilot/CopilotActionStatus.js.map +1 -1
- package/build/dist/Types/Copilot/CopilotActionType.js +165 -1
- package/build/dist/Types/Copilot/CopilotActionType.js.map +1 -1
- package/build/dist/Types/Icon/IconProp.js +1 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/Permission.js +24 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Workflow/Components/Email.js +4 -4
- package/build/dist/Types/Workflow/Components/Email.js.map +1 -1
- package/build/dist/UI/Components/Alerts/Alert.js +1 -1
- package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +3 -0
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/Workflow/WorkflowStatus.js +2 -2
- package/build/dist/UI/Components/Workflow/WorkflowStatus.js.map +1 -1
- package/build/dist/{Types/ArrayUtil.js → Utils/Array.js} +1 -1
- package/build/dist/Utils/Array.js.map +1 -0
- package/package.json +2 -2
- package/build/dist/Types/ArrayUtil.js.map +0 -1
|
@@ -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();
|
|
@@ -3,6 +3,12 @@ import { OnCreate } from "../Types/Database/Hooks";
|
|
|
3
3
|
import DatabaseService from "./DatabaseService";
|
|
4
4
|
import ObjectID from "../../Types/ObjectID";
|
|
5
5
|
import Model from "Common/Models/DatabaseModels/CopilotCodeRepository";
|
|
6
|
+
import {
|
|
7
|
+
CopilotActionTypeData,
|
|
8
|
+
CopilotActionTypeUtil,
|
|
9
|
+
} from "../../Types/Copilot/CopilotActionType";
|
|
10
|
+
import CopilotActionTypePriority from "../../Models/DatabaseModels/CopilotActionTypePriority";
|
|
11
|
+
import CopilotActionTypePriorityService from "./CopilotActionTypePriorityService";
|
|
6
12
|
|
|
7
13
|
export class Service extends DatabaseService<Model> {
|
|
8
14
|
public constructor() {
|
|
@@ -19,6 +25,36 @@ export class Service extends DatabaseService<Model> {
|
|
|
19
25
|
createBy: createBy,
|
|
20
26
|
};
|
|
21
27
|
}
|
|
28
|
+
|
|
29
|
+
protected override async onCreateSuccess(
|
|
30
|
+
_onCreate: OnCreate<Model>,
|
|
31
|
+
createdItem: Model,
|
|
32
|
+
): Promise<Model> {
|
|
33
|
+
// add all the actions.
|
|
34
|
+
|
|
35
|
+
const repo: Model = createdItem;
|
|
36
|
+
|
|
37
|
+
const defaultCopilotActionTypes: Array<CopilotActionTypeData> =
|
|
38
|
+
CopilotActionTypeUtil.getAllCopilotActionTypes();
|
|
39
|
+
|
|
40
|
+
for (const defaultAction of defaultCopilotActionTypes) {
|
|
41
|
+
const copilotActionTypePriority: CopilotActionTypePriority =
|
|
42
|
+
new CopilotActionTypePriority();
|
|
43
|
+
copilotActionTypePriority.projectId = repo.projectId!;
|
|
44
|
+
copilotActionTypePriority.actionType = defaultAction.type;
|
|
45
|
+
copilotActionTypePriority.priority = defaultAction.defaultPriority;
|
|
46
|
+
copilotActionTypePriority.codeRepositoryId = repo.id!;
|
|
47
|
+
|
|
48
|
+
await CopilotActionTypePriorityService.create({
|
|
49
|
+
data: copilotActionTypePriority,
|
|
50
|
+
props: {
|
|
51
|
+
isRoot: true,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return createdItem;
|
|
57
|
+
}
|
|
22
58
|
}
|
|
23
59
|
|
|
24
60
|
export default new Service();
|
package/Server/Services/Index.ts
CHANGED
|
@@ -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
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import CreateBy from "../Types/Database/CreateBy";
|
|
2
2
|
import { OnCreate } from "../Types/Database/Hooks";
|
|
3
3
|
import DatabaseService from "./DatabaseService";
|
|
4
|
-
import ArrayUtil from "../../
|
|
4
|
+
import ArrayUtil from "../../Utils/Array";
|
|
5
5
|
import { BrightColors } from "../../Types/BrandColors";
|
|
6
6
|
import Model from "Common/Models/DatabaseModels/ServiceCatalog";
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import CreateBy from "../Types/Database/CreateBy";
|
|
2
2
|
import { OnCreate } from "../Types/Database/Hooks";
|
|
3
3
|
import DatabaseService from "./DatabaseService";
|
|
4
|
-
import ArrayUtil from "../../
|
|
4
|
+
import ArrayUtil from "../../Utils/Array";
|
|
5
5
|
import { BrightColors } from "../../Types/BrandColors";
|
|
6
6
|
import BadDataException from "../../Types/Exception/BadDataException";
|
|
7
7
|
import ObjectID from "../../Types/ObjectID";
|
|
@@ -6,7 +6,7 @@ import AccessControlModel from "Common/Models/DatabaseModels/DatabaseBaseModel/A
|
|
|
6
6
|
import BaseModel, {
|
|
7
7
|
DatabaseBaseModelType,
|
|
8
8
|
} from "Common/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
|
|
9
|
-
import ArrayUtil from "Common/
|
|
9
|
+
import ArrayUtil from "Common/Utils/Array";
|
|
10
10
|
import { ColumnAccessControl } from "Common/Types/BaseDatabase/AccessControl";
|
|
11
11
|
import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
12
12
|
import DatabaseCommonInteractionPropsUtil, {
|
|
@@ -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("
|
|
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(
|
|
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("
|
|
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(
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
103
|
+
new BadDataException("SMTP Port is not type of number"),
|
|
107
104
|
);
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
try {
|
|
111
|
-
const
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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:
|
|
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,12 @@ 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
|
-
|
|
386
|
-
fileExtension,
|
|
387
|
-
}),
|
|
384
|
+
filePath: filePath,
|
|
388
385
|
};
|
|
389
386
|
}
|
|
390
387
|
|
|
@@ -1,10 +1,4 @@
|
|
|
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
|
-
|
|
3
|
+
filePath: string;
|
|
10
4
|
}
|
|
@@ -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;
|