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 48996b0 commit 3a4ae31
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 101 deletions.
4 changes: 2 additions & 2 deletions App/FeatureSet/BaseAPI/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseAPI from "CommonServer/API/BaseAPI";
import BaseAnalyticsAPI from "CommonServer/API/BaseAnalyticsAPI";
import BillingInvoiceAPI from "CommonServer/API/BillingInvoiceAPI";
import BillingPaymentMethodAPI from "CommonServer/API/BillingPaymentMethodAPI";
import CodeRepositoryAPI from "CommonServer/API/CodeRepositoryAPI";
import CopilotCodeRepositoryAPI from "CommonServer/API/CopilotCodeRepositoryAPI";
import CopilotActionAPI from "CommonServer/API/CopilotActionAPI";
import FileAPI from "CommonServer/API/FileAPI";
import GlobalConfigAPI from "CommonServer/API/GlobalConfigAPI";
Expand Down Expand Up @@ -1036,7 +1036,7 @@ const BaseAPIFeatureSet: FeatureSet = {

app.use(
`/${APP_NAME.toLocaleLowerCase()}`,
new CodeRepositoryAPI().getRouter(),
new CopilotCodeRepositoryAPI().getRouter(),
);

app.use(
Expand Down
16 changes: 8 additions & 8 deletions Common/Types/Permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@ enum Permission {
EditServiceCatalog = "EditServiceCatalog",
ReadServiceCatalog = "ReadServiceCatalog",

CreateCodeRepository = "CreateCodeRepository",
DeleteCodeRepository = "DeleteCodeRepository",
EditCodeRepository = "EditCodeRepository",
ReadCodeRepository = "ReadCodeRepository",
CreateCopilotCodeRepository = "CreateCopilotCodeRepository",
DeleteCopilotCodeRepository = "DeleteCopilotCodeRepository",
EditCopilotCodeRepository = "EditCopilotCodeRepository",
ReadCopilotCodeRepository = "ReadCopilotCodeRepository",

ReadCopilotAction = "ReadCopilotAction",

Expand Down Expand Up @@ -2384,30 +2384,30 @@ export class PermissionHelper {
},

{
permission: Permission.CreateCodeRepository,
permission: Permission.CreateCopilotCodeRepository,
title: "Create Code Repository",
description: "This permission can create Code Repository this project.",
isAssignableToTenant: true,
isAccessControlPermission: true,
},
{
permission: Permission.DeleteCodeRepository,
permission: Permission.DeleteCopilotCodeRepository,
title: "Delete Code Repository",
description:
"This permission can delete Code Repository of this project.",
isAssignableToTenant: true,
isAccessControlPermission: true,
},
{
permission: Permission.EditCodeRepository,
permission: Permission.EditCopilotCodeRepository,
title: "Edit Code Repository",
description:
"This permission can edit Code Repository of this project.",
isAssignableToTenant: true,
isAccessControlPermission: true,
},
{
permission: Permission.ReadCodeRepository,
permission: Permission.ReadCopilotCodeRepository,
title: "Read Code Repository",
description:
"This permission can read Code Repository of this project.",
Expand Down
12 changes: 6 additions & 6 deletions CommonServer/API/CopilotActionAPI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CodeRepository from "Model/Models/CodeRepository";
import CopilotCodeRepository from "Model/Models/CopilotCodeRepository";
import CopilotActionService, {
Service as CopilotActionServiceType,
} from "../Services/CopilotActionService";
Expand All @@ -13,7 +13,7 @@ import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
import BadDataException from "Common/Types/Exception/BadDataException";
import ObjectID from "Common/Types/ObjectID";
import CopilotAction from "Model/Models/CopilotAction";
import CodeRepositoryService from "../Services/CodeRepositoryService";
import CopilotCodeRepositoryService from "../Services/CopilotCodeRepositoryService";
import CodeRepositoryAuthorization from "../Middleware/CodeRepositoryAuthorization";

export default class CopilotActionAPI extends BaseAPI<
Expand Down Expand Up @@ -48,8 +48,8 @@ export default class CopilotActionAPI extends BaseAPI<
throw new BadDataException("Service catalog id is required");
}

const codeRepository: CodeRepository | null =
await CodeRepositoryService.findOneBy({
const codeRepository: CopilotCodeRepository | null =
await CopilotCodeRepositoryService.findOneBy({
query: {
secretToken: new ObjectID(secretkey),
},
Expand Down Expand Up @@ -115,8 +115,8 @@ export default class CopilotActionAPI extends BaseAPI<
throw new BadDataException("Secret key is required");
}

const codeRepository: CodeRepository | null =
await CodeRepositoryService.findOneBy({
const codeRepository: CopilotCodeRepository | null =
await CopilotCodeRepositoryService.findOneBy({
query: {
secretToken: new ObjectID(secretkey),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CodeRepositoryAuthorization from "../Middleware/CodeRepositoryAuthorization";
import CodeRepositoryService, {
Service as CodeRepositoryServiceType,
} from "../Services/CodeRepositoryService";
import CopilotCodeRepositoryService, {
Service as CopilotCodeRepositoryServiceType,
} from "../Services/CopilotCodeRepositoryService";
import ServiceRepositoryService from "../Services/ServiceRepositoryService";
import {
ExpressRequest,
Expand All @@ -13,15 +13,15 @@ import BaseAPI from "./BaseAPI";
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
import BadDataException from "Common/Types/Exception/BadDataException";
import ObjectID from "Common/Types/ObjectID";
import CodeRepository from "Model/Models/CodeRepository";
import CopilotCodeRepository from "Model/Models/CopilotCodeRepository";
import ServiceRepository from "Model/Models/ServiceRepository";

export default class CodeRepositoryAPI extends BaseAPI<
CodeRepository,
CodeRepositoryServiceType
export default class CopilotCodeRepositoryAPI extends BaseAPI<
CopilotCodeRepository,
CopilotCodeRepositoryServiceType
> {
public constructor() {
super(CodeRepository, CodeRepositoryService);
super(CopilotCodeRepository, CopilotCodeRepositoryService);

this.router.get(
`${new this.entityType()
Expand Down Expand Up @@ -50,8 +50,8 @@ export default class CodeRepositoryAPI extends BaseAPI<
throw new BadDataException("Secret key is required");
}

const codeRepository: CodeRepository | null =
await CodeRepositoryService.findOneBy({
const codeRepository: CopilotCodeRepository | null =
await CopilotCodeRepositoryService.findOneBy({
query: {
secretToken: new ObjectID(secretkey),
},
Expand Down Expand Up @@ -96,9 +96,9 @@ export default class CodeRepositoryAPI extends BaseAPI<
});

return Response.sendJsonObjectResponse(req, res, {
codeRepository: CodeRepository.toJSON(
codeRepository: CopilotCodeRepository.toJSON(
codeRepository,
CodeRepository,
CopilotCodeRepository,
),
servicesRepository: ServiceRepository.toJSONArray(
servicesRepository,
Expand Down
12 changes: 6 additions & 6 deletions CommonServer/Middleware/CodeRepositoryAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
ExpressResponse,
NextFunction,
} from "../Utils/Express";
import CodeRepository from "Model/Models/CodeRepository";
import CodeRepositoryService from "../Services/CodeRepositoryService";
import CopilotCodeRepository from "Model/Models/CopilotCodeRepository";
import CopilotCodeRepositoryService from "../Services/CopilotCodeRepositoryService";
import ObjectID from "Common/Types/ObjectID";

export default class CodeRepositoryAuthorization {
export default class CopilotCodeRepositoryAuthorization {
public static async isAuthorizedRepository(
req: ExpressRequest,
_res: ExpressResponse,
Expand All @@ -21,8 +21,8 @@ export default class CodeRepositoryAuthorization {
throw new BadDataException("Secret key is required");
}

const codeRepository: CodeRepository | null =
await CodeRepositoryService.findOneBy({
const CopilotCodeRepository: CopilotCodeRepository | null =
await CopilotCodeRepositoryService.findOneBy({
query: {
secretToken: new ObjectID(secretkey),
},
Expand All @@ -34,7 +34,7 @@ export default class CodeRepositoryAuthorization {
},
});

if (!codeRepository) {
if (!CopilotCodeRepository) {
throw new BadDataException(
"Code repository not found. Secret key is invalid.",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CreateBy from "../Types/Database/CreateBy";
import { OnCreate } from "../Types/Database/Hooks";
import DatabaseService from "./DatabaseService";
import ObjectID from "Common/Types/ObjectID";
import Model from "Model/Models/CodeRepository";
import Model from "Model/Models/CopilotCodeRepository";

export class Service extends DatabaseService<Model> {
public constructor(postgresDatabase?: PostgresDatabase) {
Expand Down
2 changes: 1 addition & 1 deletion CommonServer/Services/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BillingPaymentMethodsService from "./BillingPaymentMethodService";
import BillingService from "./BillingService";
import CallLogService from "./CallLogService";
import CallService from "./CallService";
import CodeRepositoryService from "./CodeRepositoryService";
import CodeRepositoryService from "./CopilotCodeRepositoryService";
import CopilotActionService from "./CopilotActionService";
import DataMigrationService from "./DataMigrationService";
import DomainService from "./DomainService";
Expand Down
26 changes: 13 additions & 13 deletions Copilot/Utils/CodeRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import CodeRepositoryServerUtil from "CommonServer/Utils/CodeRepository/CodeRepo
import GitHubUtil from "CommonServer/Utils/CodeRepository/GitHub/GitHub";
import LocalFile from "CommonServer/Utils/LocalFile";
import logger from "CommonServer/Utils/Logger";
import CodeRepositoryModel from "Model/Models/CodeRepository";
import CopilotCodeRepository from "Model/Models/CopilotCodeRepository";
import ServiceRepository from "Model/Models/ServiceRepository";

export interface CodeRepositoryResult {
codeRepository: CodeRepositoryModel;
codeRepository: CopilotCodeRepository;
servicesToImprove: Array<ServiceToImproveResult>;
serviceRepositories: Array<ServiceRepository>;
}
Expand Down Expand Up @@ -61,7 +61,7 @@ export default class CodeRepositoryUtil {

// returns the folder name of the cloned repository.
public static async cloneRepository(data: {
codeRepository: CodeRepositoryModel;
codeRepository: CopilotCodeRepository;
}): Promise<void> {
// make sure this.getLocalRepositoryPath() is empty.
const repoLocalPath: string = this.getLocalRepositoryPath();
Expand Down Expand Up @@ -276,7 +276,7 @@ export default class CodeRepositoryUtil {
}

public static async checkoutMainBranch(): Promise<void> {
const codeRepository: CodeRepositoryModel = 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 +326,7 @@ export default class CodeRepositoryUtil {
serviceRepository: data.serviceRepository,
});

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

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

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

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

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

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

public static async getServicesToImproveCode(data: {
codeRepository: CodeRepositoryModel;
codeRepository: CopilotCodeRepository;
services: Array<ServiceRepository>;
}): Promise<Array<ServiceToImproveResult>> {
const servicesToImproveCode: Array<ServiceToImproveResult> = [];
Expand Down Expand Up @@ -483,7 +483,7 @@ export default class CodeRepositoryUtil {
const url: URL = URL.fromString(
GetOneUptimeURL().toString() + "/api",
).addRoute(
`${new CodeRepositoryModel()
`${new CopilotCodeRepository()
.getCrudApiPath()
?.toString()}/get-code-repository/${repositorySecretKey}`,
);
Expand All @@ -495,10 +495,10 @@ export default class CodeRepositoryUtil {
throw codeRepositoryResult;
}

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

const servicesRepository: Array<ServiceRepository> = (
codeRepositoryResult.data["servicesRepository"] as JSONArray
Expand Down Expand Up @@ -541,7 +541,7 @@ export default class CodeRepositoryUtil {
return this.codeRepositoryResult;
}

public static async getCodeRepository(): Promise<CodeRepositoryModel> {
public static async getCodeRepository(): Promise<CopilotCodeRepository> {
if (!this.codeRepositoryResult) {
const result: CodeRepositoryResult = await this.getCodeRepositoryResult();
return result.codeRepository;
Expand Down
2 changes: 1 addition & 1 deletion Model/Models/CopilotAction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CodeRepository from "./CodeRepository";
import CodeRepository from "./CopilotCodeRepository";
import Project from "./Project";
import ServiceCatalog from "./ServiceCatalog";
import ServiceRepository from "./ServiceRepository";
Expand Down
Loading

0 comments on commit 3a4ae31

Please sign in to comment.