148 lines
3.6 KiB
TypeScript
148 lines
3.6 KiB
TypeScript
import {
|
|
TextObjectFilterParams,
|
|
TextObjectFilterResult,
|
|
} from "../../Models/TextObjectFilter.model";
|
|
import { IClientDocument } from "./Clients.Adapter.Mongoose";
|
|
|
|
export type FindClientsParams = {
|
|
_id?: string;
|
|
companyId?: string;
|
|
email?: string;
|
|
firstName?: string;
|
|
lastName?: string;
|
|
userId?: string;
|
|
status?: boolean;
|
|
};
|
|
|
|
export type DetachClientUserParams = {
|
|
clientId: string;
|
|
};
|
|
|
|
export type FindClientByIdParams = {
|
|
id: string;
|
|
companyId: string;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export type PaginateClientsParams = FindClientsParams & {
|
|
page: number;
|
|
limit: number;
|
|
};
|
|
|
|
export type PaginateClientsResults = {
|
|
data: IClient[];
|
|
page: number;
|
|
pages: number;
|
|
};
|
|
|
|
export type PaginateOrganizationClientsParams = FindClientsParams & {
|
|
page: number;
|
|
limit: number;
|
|
};
|
|
|
|
export type OrganizationClientsResults = {
|
|
data: OrganizationClientView[];
|
|
page: number;
|
|
pages: number;
|
|
};
|
|
|
|
export type CreateClientByUserParams = {
|
|
companyId: string;
|
|
userId: string;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export type CreateCustomClientParams = {
|
|
companyId: string;
|
|
sessionUser: string;
|
|
firstName?: string;
|
|
lastName?: string;
|
|
phoneNumber?: string;
|
|
phoneCountryCode?: string;
|
|
phoneAreaCode?: string;
|
|
email?: string;
|
|
banned?: boolean;
|
|
};
|
|
|
|
export type UpdateClientParams = CreateCustomClientParams & {
|
|
id: string;
|
|
};
|
|
|
|
export type DelteClientsByCompanyParams = {
|
|
companyId: string;
|
|
};
|
|
|
|
export type DeleteClientParams = {
|
|
clientId: string;
|
|
checkCashOnAccount?: boolean;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export interface IClient {
|
|
id?: string;
|
|
companyId: string;
|
|
userId?: string;
|
|
fromClientId: string;
|
|
status: boolean;
|
|
firstName: string;
|
|
lastName: string;
|
|
phoneNumber: string;
|
|
phoneCountryCode: string;
|
|
phoneAreaCode: string;
|
|
email: string;
|
|
banned?: boolean;
|
|
}
|
|
|
|
export interface OrganizationClientView {
|
|
id: string;
|
|
firstName: string;
|
|
lastName: string;
|
|
fullName: string;
|
|
phoneNumber: string;
|
|
phoneCountryCode: string;
|
|
phoneAreaCode: string;
|
|
email: string;
|
|
avatar: string;
|
|
banned?: boolean;
|
|
}
|
|
|
|
export type ClientMergeParams = {
|
|
fromClientId: string;
|
|
toClientId: string;
|
|
sessionUser: string;
|
|
};
|
|
|
|
export interface IClientsAdapter {
|
|
create(
|
|
data: CreateClientByUserParams | CreateCustomClientParams
|
|
): Promise<IClient>;
|
|
delete(id: string): Promise<void>;
|
|
find(filters: FindClientsParams): Promise<IClient[]>;
|
|
findOne(filters: FindClientsParams): Promise<IClientDocument | null>;
|
|
paginate(filters: PaginateClientsParams): Promise<PaginateClientsResults>;
|
|
detachUser(data: DetachClientUserParams): Promise<void>;
|
|
}
|
|
|
|
export interface IClientsManager {
|
|
clients: IClientsAdapter;
|
|
createClientByUser(
|
|
data: CreateClientByUserParams
|
|
): Promise<IClientDocument>;
|
|
createCustomClient(
|
|
data: CreateCustomClientParams
|
|
): Promise<IClientDocument>;
|
|
updateClient(data: UpdateClientParams): Promise<void>;
|
|
findOrganizationClients(
|
|
filters: PaginateOrganizationClientsParams
|
|
): Promise<OrganizationClientsResults>;
|
|
textObjectFilter(
|
|
data: TextObjectFilterParams
|
|
): Promise<TextObjectFilterResult[]>;
|
|
findClientById(data: FindClientByIdParams): Promise<OrganizationClientView>;
|
|
getClientWapNumber(data: IClient): Promise<string>;
|
|
getClientFullName(data: IClient): string;
|
|
clientMerge(data: ClientMergeParams): Promise<void>;
|
|
deleteClientsByCompany(data: DelteClientsByCompanyParams): Promise<void>;
|
|
deleteClient(data: DeleteClientParams): Promise<void>;
|
|
}
|