Spaces:
Sleeping

File size: 1,557 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
import { Types } from "mongoose";

import { IUser } from "@/models/User.js";
import { IPlans } from "@/constants/plan.js";
export type SimpleOptions = {
	fillPass: boolean;
};
export type GithubIds = { installId: number; loginId: number };
export type GithubIdsOutput = { githubInstallationId: number; githubAccountId: number };

export interface IUserRepository {
	createUser(data: Partial<IUser>): Promise<IUser>;
	findByUserEmail(email: string, options?: SimpleOptions): Promise<IUser | null>;
	findByUserId(id: string): Promise<IUser | null>;
	incrementProjects(userId: Types.ObjectId | string): Promise<void>;
	decrementProjects(userId: Types.ObjectId | string): Promise<void>;
	updateUser(userId: string, updateData: Partial<IUser>): Promise<IUser | null>;
	updateUserPlansWithStripe(stripeId: string, planData: keyof IPlans, paymentData: IUser["payment"]): Promise<IUser | null>;
	updateUserPlans(userId: string, planData: keyof IPlans): Promise<IUser | null>;
	getOrUpdateDeployments(userId: string): Promise<IUser | null>;
	findUserByCustomerId(id: string): Promise<IUser | null>;
	incrementDeployment(userId: string): Promise<void>;

	findAuthProviders(userId: string): Promise<Partial<IUser> | null>;

	addGhbApCreds(userId: string, updateData: { installId: number; loginId: number }): Promise<GithubIdsOutput | null>;
	removeGhbApCreds(installationId: number): Promise<void>;
	findGhbApCreds(userId: string): Promise<GithubIdsOutput | null>;
	findUserByInstallationId(installationId: number, onlyNeededFields: boolean): Promise<IUser | null>;
}