Skip to content

Commit

Permalink
chore: Update import paths for CodeRepository to CopilotCodeRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Jul 9, 2024
1 parent ad48ea5 commit f58e935
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 14 deletions.
2 changes: 1 addition & 1 deletion App/FeatureSet/ApiReference/Service/PageNotFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export default class ServiceHandler {
pageData: {}, // An empty object to hold any additional page data
});
}
}
}
2 changes: 1 addition & 1 deletion App/FeatureSet/ApiReference/Service/Pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ export default class ServiceHandler {
pageData: pageData, // Pass the page data
});
}
}
}
2 changes: 1 addition & 1 deletion App/FeatureSet/Docs/Utils/Nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ const DocsNav: NavGroup[] = [
];

// Export the array of navigation groups
export default DocsNav;
export default DocsNav;
3 changes: 1 addition & 2 deletions App/FeatureSet/Docs/Utils/Render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import Markdown, { MarkdownContentType } from "CommonServer/Types/Markdown";

// This class is responsible for rendering markdown content to HTML
export default class DocsRender {

// Render markdown content to HTML and return the result as a promise
public static async render(markdownContent: string): Promise<string> {
// Use the Markdown library to convert markdown content to HTML
return Markdown.convertToHTML(markdownContent, MarkdownContentType.Docs);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class MigrationName1720530235698 implements MigrationInterface {
public name = "MigrationName1720530235698";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "ServiceRepository" DROP CONSTRAINT "FK_da3f196daf93e32b5ae51b865ef"`,
);
await queryRunner.query(
`ALTER TABLE "CopilotAction" DROP CONSTRAINT "FK_d1f62129e09784b750ef9143bfe"`,
);
await queryRunner.query(
`CREATE TABLE "CopilotCodeRepository" ("_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, "name" character varying(100) NOT NULL, "slug" character varying(100) NOT NULL, "description" character varying(500), "createdByUserId" uuid, "deletedByUserId" uuid, "secretToken" uuid NOT NULL, "mainBranchName" character varying(100) NOT NULL DEFAULT 'master', "repositoryHostedAt" character varying(100) NOT NULL DEFAULT 'GitHub', "organizationName" character varying(100) NOT NULL, "repositoryName" character varying(100) NOT NULL, "onBeforeRepositoryCloneScript" text, CONSTRAINT "PK_bde620517f9f70ae4e07f20794c" PRIMARY KEY ("_id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_41b81a046fcc36dba0499886dc" ON "CopilotCodeRepository" ("projectId") `,
);
await queryRunner.query(
`CREATE INDEX "IDX_67f63dde71654d6a24478c751c" ON "CopilotCodeRepository" ("secretToken") `,
);
await queryRunner.query(
`CREATE TABLE "CopilotCodeRepositoryLabel" ("CopilotCodeRepositoryId" uuid NOT NULL, "labelId" uuid NOT NULL, CONSTRAINT "PK_750b6ac49ba58e6b6ad7d6043e5" PRIMARY KEY ("CopilotCodeRepositoryId", "labelId"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_71c1427b8dfc31dbec3d65f70d" ON "CopilotCodeRepositoryLabel" ("CopilotCodeRepositoryId") `,
);
await queryRunner.query(
`CREATE INDEX "IDX_d3bb0fc11b6e3b7fd3ca0464c1" ON "CopilotCodeRepositoryLabel" ("labelId") `,
);
await queryRunner.query(
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
);
await queryRunner.query(
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepository" ADD CONSTRAINT "FK_41b81a046fcc36dba0499886dc8" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepository" ADD CONSTRAINT "FK_ab1b484839c4c9ed25150d248ff" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepository" ADD CONSTRAINT "FK_681f7e53081da05fd0aefcad93f" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "ServiceRepository" ADD CONSTRAINT "FK_da3f196daf93e32b5ae51b865ef" FOREIGN KEY ("codeRepositoryId") REFERENCES "CopilotCodeRepository"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "CopilotAction" ADD CONSTRAINT "FK_d1f62129e09784b750ef9143bfe" FOREIGN KEY ("codeRepositoryId") REFERENCES "CopilotCodeRepository"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepositoryLabel" ADD CONSTRAINT "FK_71c1427b8dfc31dbec3d65f70d5" FOREIGN KEY ("CopilotCodeRepositoryId") REFERENCES "CopilotCodeRepository"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepositoryLabel" ADD CONSTRAINT "FK_d3bb0fc11b6e3b7fd3ca0464c15" FOREIGN KEY ("labelId") REFERENCES "Label"("_id") ON DELETE CASCADE ON UPDATE CASCADE`,
);

// drop table CodeRepository
await queryRunner.query(`DROP TABLE "CodeRepository"`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepositoryLabel" DROP CONSTRAINT "FK_d3bb0fc11b6e3b7fd3ca0464c15"`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepositoryLabel" DROP CONSTRAINT "FK_71c1427b8dfc31dbec3d65f70d5"`,
);
await queryRunner.query(
`ALTER TABLE "CopilotAction" DROP CONSTRAINT "FK_d1f62129e09784b750ef9143bfe"`,
);
await queryRunner.query(
`ALTER TABLE "ServiceRepository" DROP CONSTRAINT "FK_da3f196daf93e32b5ae51b865ef"`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepository" DROP CONSTRAINT "FK_681f7e53081da05fd0aefcad93f"`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepository" DROP CONSTRAINT "FK_ab1b484839c4c9ed25150d248ff"`,
);
await queryRunner.query(
`ALTER TABLE "CopilotCodeRepository" DROP CONSTRAINT "FK_41b81a046fcc36dba0499886dc8"`,
);
await queryRunner.query(
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
);
await queryRunner.query(
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_d3bb0fc11b6e3b7fd3ca0464c1"`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_71c1427b8dfc31dbec3d65f70d"`,
);
await queryRunner.query(`DROP TABLE "CopilotCodeRepositoryLabel"`);
await queryRunner.query(
`DROP INDEX "public"."IDX_67f63dde71654d6a24478c751c"`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_41b81a046fcc36dba0499886dc"`,
);
await queryRunner.query(`DROP TABLE "CopilotCodeRepository"`);
await queryRunner.query(
`ALTER TABLE "CopilotAction" ADD CONSTRAINT "FK_d1f62129e09784b750ef9143bfe" FOREIGN KEY ("codeRepositoryId") REFERENCES "CodeRepository"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "ServiceRepository" ADD CONSTRAINT "FK_da3f196daf93e32b5ae51b865ef" FOREIGN KEY ("codeRepositoryId") REFERENCES "CodeRepository"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { MigrationName1719831213463 } from "./1719831213463-MigrationName";
import { MigrationName1719838746775 } from "./1719838746775-MigrationName";
import { MigrationName1719915433542 } from "./1719915433542-MigrationName";
import { MigrationName1720024126646 } from "./1720024126646-MigrationName";
import { MigrationName1720530235698 } from "./1720530235698-MigrationName";

export default [
InitialMigration,
Expand Down Expand Up @@ -52,4 +53,5 @@ export default [
MigrationName1719838746775,
MigrationName1719915433542,
MigrationName1720024126646,
MigrationName1720530235698,
];
21 changes: 13 additions & 8 deletions Copilot/Utils/CodeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ export default class CodeRepositoryUtil {
}

public static async checkoutMainBranch(): Promise<void> {
const codeRepository: CopilotCodeRepository = await this.getCodeRepository();
const codeRepository: CopilotCodeRepository =
await this.getCodeRepository();

if (!codeRepository.mainBranchName) {
throw new BadDataException("Main Branch Name is required");
Expand Down Expand Up @@ -326,7 +327,8 @@ export default class CodeRepositoryUtil {
serviceRepository: data.serviceRepository,
});

const codeRepository: CopilotCodeRepository = await this.getCodeRepository();
const codeRepository: CopilotCodeRepository =
await this.getCodeRepository();

if (!codeRepository.mainBranchName) {
throw new BadDataException("Main Branch Name is required");
Expand All @@ -351,7 +353,8 @@ export default class CodeRepositoryUtil {
}

public static async switchToMainBranch(): Promise<void> {
const codeRepository: CopilotCodeRepository = await this.getCodeRepository();
const codeRepository: CopilotCodeRepository =
await this.getCodeRepository();

if (!codeRepository.mainBranchName) {
throw new BadDataException("Main Branch Name is required");
Expand All @@ -373,7 +376,8 @@ export default class CodeRepositoryUtil {
serviceRepository: data.serviceRepository,
});

const codeRepository: CopilotCodeRepository = await this.getCodeRepository();
const codeRepository: CopilotCodeRepository =
await this.getCodeRepository();

if (!codeRepository.mainBranchName) {
throw new BadDataException("Main Branch Name is required");
Expand Down Expand Up @@ -495,10 +499,11 @@ export default class CodeRepositoryUtil {
throw codeRepositoryResult;
}

const codeRepository: CopilotCodeRepository = CopilotCodeRepository.fromJSON(
codeRepositoryResult.data["codeRepository"] as JSONObject,
CopilotCodeRepository,
) as CopilotCodeRepository;
const codeRepository: CopilotCodeRepository =
CopilotCodeRepository.fromJSON(
codeRepositoryResult.data["codeRepository"] as JSONObject,
CopilotCodeRepository,
) as CopilotCodeRepository;

const servicesRepository: Array<ServiceRepository> = (
codeRepositoryResult.data["servicesRepository"] as JSONArray
Expand Down
1 change: 0 additions & 1 deletion Model/Models/CopilotCodeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ export default class CopilotCodeRepository extends BaseModel {
})
public repositoryName?: string = undefined;


@ColumnAccessControl({
create: [
Permission.ProjectOwner,
Expand Down

0 comments on commit f58e935

Please sign in to comment.