UNPKG

@accounts/mikro-orm

Version:
35 lines (34 loc) 2.29 kB
import { Collection, EntitySchema } from '@mikro-orm/core'; import { Service, type ServiceCtor, type ServiceCtorArgs } from './Service'; import { Email, type EmailCtor, type EmailCtorArgs } from './Email'; import { Session, type SessionCtor } from './Session'; export interface IUser<CustomEmail extends Email<any>, CustomSession extends Session<any>, CustomService extends Service<any>> { id: number; username?: string; services: Collection<CustomService>; emails: Collection<CustomEmail>; sessions: Collection<CustomSession>; deactivated: boolean; createdAt: Date; updatedAt: Date; } export declare const getUserCtor: <CustomEmail extends Email<any>, CustomSession extends Session<any>, CustomService extends Service<any>, CustomUserCtorArgs extends UserCtorArgs = UserCtorArgs, CustomEmailCtorArgs extends EmailCtorArgs<any> = EmailCtorArgs<any>, CustomServiceCtorArgs extends ServiceCtorArgs<any> = ServiceCtorArgs<any>>({ abstract, EmailEntity, ServiceEntity, getCustomEmailArgs, getCustomServiceArgs, }?: { abstract?: boolean | undefined; EmailEntity?: (new (args: CustomEmailCtorArgs) => CustomEmail) | undefined; ServiceEntity?: (new (args: CustomServiceCtorArgs) => CustomService) | undefined; getCustomEmailArgs?: ((args: CustomUserCtorArgs) => Partial<CustomEmailCtorArgs>) | undefined; getCustomServiceArgs?: ((args: CustomUserCtorArgs) => Partial<CustomServiceCtorArgs>) | undefined; }) => UserCtor<CustomEmail, CustomSession, CustomService, UserCtorArgs>; export interface UserCtorArgs { email?: string; password?: string; username?: string; } export type UserCtor<CustomEmail extends Email<any>, CustomSession extends Session<any>, CustomService extends Service<any>, CustomUserCtorArgs extends UserCtorArgs = UserCtorArgs> = new (args: CustomUserCtorArgs) => IUser<CustomEmail, CustomSession, CustomService>; export declare const getUserSchema: ({ AccountsUser, EmailEntity, SessionEntity, ServiceEntity, abstract, }: { AccountsUser: UserCtor<any, any, any, any>; EmailEntity?: EmailCtor<any, any> | undefined; SessionEntity?: SessionCtor<any, any> | undefined; ServiceEntity?: ServiceCtor<any, any> | undefined; abstract?: boolean | undefined; }) => EntitySchema<IUser<any, any, any>, never>;