Spaces:
Sleeping

File size: 1,629 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 { QueryDeploymentDTO } from "@/dtos/deployment.dto.js";
import { IDeployment } from "@/models/Deployment.js";

export type DeploymentDbOptions = {
	fields?: string[];
	includes?: string;
	exclude?: string[];
};

export type ProjectUsageResults = {
	projectId: string;
	deploys: number;
	projectName: string;
	total_build: number;
	isDeleted: boolean;
	bandwidthMontly: number;
	bandwidthTotal: number;
	month: string;
};
export type DailyDeployments = { _id: string; count: number };
export interface IDeploymentRepository {
	createDeployment(deploymentData: Partial<IDeployment>): Promise<IDeployment | null>;
	findDeploymentById(id: string, userId: string, options?: DeploymentDbOptions): Promise<IDeployment | null>;

	findAllDeployments(
		userId: string,
		query: QueryDeploymentDTO,
		options?: DeploymentDbOptions,
	): Promise<{ deployments: IDeployment[]; total: number }>;
	findProjectDeployments(
		userId: string,
		projectId: string,
		query: QueryDeploymentDTO,
		options?: DeploymentDbOptions,
	): Promise<{ deployments: IDeployment[]; total: number }>;

	deleteDeployment(projectId: string, deploymentId: string, userId: string): Promise<number>;

	getTotalBuildTime(userId: string): Promise<ProjectUsageResults[]>;
	getDailyDeployments(userId: string, months: number): Promise<DailyDeployments[]>;

	__findDeployment(id: string): Promise<IDeployment | null>;

	__updateDeployment(projectId: string, deploymentId: string, updateData: Partial<IDeployment>): Promise<IDeployment | null>;
	__findAllProjectDeployment(projectId: string, sortOptions?: string | Record<string, 1 | -1>): Promise<IDeployment[]>;
}