Spaces:
Sleeping

File size: 2,072 Bytes
4e83772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { CreateProjectDTO, QueryProjectDTO } from "@/dtos/project.dto.js";
import { IProject } from "@/models/Projects.js";
import { DailyDeployments, ProjectUsageResults } from "../repository/IDeploymentRepository.js";

export type options = {
	updateStatusOnlyIfNoCurrentDeployment?: boolean;
};
export interface IProjectService {
	createProject(projectData: CreateProjectDTO, userId: string): Promise<IProject | null>;

	getAllProjects(userId: string, query: QueryProjectDTO): Promise<{ projects: IProject[]; total: number }>;
	getProjectById(id: string, userId: string, include?: string, full?: boolean): Promise<IProject | null>;
	getProjectSettings(id: string, userId: string, include?: string): Promise<IProject | null>;
	updateProject(id: string, userId: string, data: Partial<IProject>): Promise<IProject | null>;
	deleteProject(projectId: string, userId: string): Promise<boolean>;
	getProjectBandwidthData(projectId: string, userId: string, isMonthly: boolean): Promise<number>;
	getUserBandwidthData(userId: string, isMonthly: boolean): Promise<number>;
	changeProjectSubdomain(userId: string, projectId: string, newSubdomain: string): Promise<IProject | null>;
	checkSubdomainAvaiable(newSubdomain: string): Promise<boolean>;
	findProjectSimpleStats(
		userId: string,
		projectId: string,
	): Promise<{
		totalDeployments: number;
		successRate: number;
		failureRate: number;
		failedBuilds: number;
		avgBuildTime: number;
		buildHistory: string[];
		lastDeployed: Date | null;
		bandwidth: number;
	}>;

	findTotalUsage(
		userId: string,
		months: number,
	): Promise<{
		projectRslts: ProjectUsageResults[];
		deploys: DailyDeployments[];
	}>;
	__getProjectByRepository(repoId: number): Promise<IProject | null>;
	__getProjectById(id: string): Promise<IProject | null>;
	__updateProjectById(projectId: string, updateData: Partial<IProject>, options?: options): Promise<IProject | null>;
	__unLinkGhProjects(repos: number[], userId?: string): Promise<IProject | null>;
	__linkGhProjectsBack(repos: number[], userId?: string): Promise<IProject | null>;
}