import type { TFunction } from 'i18next'; import type { Schema } from 'mongoose'; import type { ExtractProperty, GetModelTypeFromClass, GetModelTypeLiteFromSchema } from '../modules/BaseModel.ts'; import { BaseModel } from '../modules/BaseModel.ts'; export type UserModelLite = GetModelTypeLiteFromSchema>; export type TUser = GetModelTypeFromClass; declare class User extends BaseModel { static initHooks(schema: Schema): void; static get modelSchema(): { readonly avatar: { readonly type: StringConstructor; readonly maxlength: 255; }; readonly name: { readonly first: { readonly type: StringConstructor; readonly maxlength: 255; }; readonly last: { readonly type: StringConstructor; readonly maxlength: 255; }; readonly nick: { readonly minlength: 3; readonly maxlength: 255; readonly type: StringConstructor; readonly index: { readonly unique: true; readonly partialFilterExpression: { readonly 'name.nick': { readonly $type: "string"; }; }; }; }; }; readonly password: StringConstructor; readonly email: { readonly type: StringConstructor; readonly maxlength: 255; readonly index: { readonly unique: true; readonly partialFilterExpression: { readonly email: { readonly $type: "string"; }; }; }; }; readonly sessionTokens: readonly [{ readonly token: StringConstructor; readonly valid: DateConstructor; }]; readonly verificationTokens: readonly [{ readonly until: DateConstructor; readonly token: StringConstructor; }]; readonly passwordRecoveryTokens: readonly [{ readonly until: DateConstructor; readonly token: StringConstructor; }]; readonly permissions: readonly [StringConstructor]; readonly roles: readonly [StringConstructor]; readonly isVerified: { readonly type: BooleanConstructor; readonly default: false; }; readonly locale: { readonly type: StringConstructor; readonly default: "en"; }; readonly languages: readonly [StringConstructor]; }; static get modelStatics(): { /** * Get user by email and password * @param {string} email * @param {string} password * @returns {Promise | false>} */ readonly getUserByEmailAndPassword: (this: T, email: string, password: string) => Promise>; /** * Get user by token * @param {string} * @returns {Promise | false>} */ readonly getUserByToken: (this: UserModelLite, token: string) => Promise & { isVerified: boolean; locale: string; name?: { first?: string | null | undefined; last?: string | null | undefined; nick?: string | null | undefined; } | null | undefined; createdAt?: NativeDate | null | undefined; updatedAt?: NativeDate | null | undefined; avatar?: string | null | undefined; password?: string | null | undefined; email?: string | null | undefined; sessionTokens?: ({ token?: string | null | undefined; valid?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; verificationTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; passwordRecoveryTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; permissions?: string[] | null | undefined; roles?: string[] | null | undefined; languages?: string[] | null | undefined; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }> & { __v: number; } & { id: string; })>; /** * Get user by email * @param {string} * @returns {Promise | false>} */ readonly getUserByEmail: (this: UserModelLite, email: string) => Promise & { isVerified: boolean; locale: string; name?: { first?: string | null | undefined; last?: string | null | undefined; nick?: string | null | undefined; } | null | undefined; createdAt?: NativeDate | null | undefined; updatedAt?: NativeDate | null | undefined; avatar?: string | null | undefined; password?: string | null | undefined; email?: string | null | undefined; sessionTokens?: ({ token?: string | null | undefined; valid?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; verificationTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; passwordRecoveryTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; permissions?: string[] | null | undefined; roles?: string[] | null | undefined; languages?: string[] | null | undefined; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }> & { __v: number; } & { id: string; })>; /** * Get user by password recovery token * @param {string} passwordRecoveryToken * @returns {Promise | false>} */ readonly getUserByPasswordRecoveryToken: (this: UserModelLite, passwordRecoveryToken: string) => Promise & { isVerified: boolean; locale: string; name?: { first?: string | null | undefined; last?: string | null | undefined; nick?: string | null | undefined; } | null | undefined; createdAt?: NativeDate | null | undefined; updatedAt?: NativeDate | null | undefined; avatar?: string | null | undefined; password?: string | null | undefined; email?: string | null | undefined; sessionTokens?: ({ token?: string | null | undefined; valid?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; verificationTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; passwordRecoveryTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; permissions?: string[] | null | undefined; roles?: string[] | null | undefined; languages?: string[] | null | undefined; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }> & { __v: number; } & { id: string; }>; /** * Get user by verification token * @param {string} verificationToken * @returns {Promise | false>} */ readonly getUserByVerificationToken: (this: UserModelLite, verificationToken: string) => Promise & { isVerified: boolean; locale: string; name?: { first?: string | null | undefined; last?: string | null | undefined; nick?: string | null | undefined; } | null | undefined; createdAt?: NativeDate | null | undefined; updatedAt?: NativeDate | null | undefined; avatar?: string | null | undefined; password?: string | null | undefined; email?: string | null | undefined; sessionTokens?: ({ token?: string | null | undefined; valid?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; verificationTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; passwordRecoveryTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; permissions?: string[] | null | undefined; roles?: string[] | null | undefined; languages?: string[] | null | undefined; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }> & { __v: number; } & { id: string; }>; }; static get modelInstanceMethods(): { /** * Generate token for user * @returns {Object} */ readonly generateToken: (this: { email?: string | null; sessionTokens?: { token?: string | null; valid?: Date | null; }[] | null; save: () => Promise; }) => Promise<{ token: string; valid: Date; }>; /** * Send password recovery email * @param {Object} * @param {TFunction} * @param {string} i18n.language * @returns {Promise} */ readonly sendPasswordRecoveryEmail: (this: import("mongoose").Document & { isVerified: boolean; locale: string; name?: { first?: string | null | undefined; last?: string | null | undefined; nick?: string | null | undefined; } | null | undefined; createdAt?: NativeDate | null | undefined; updatedAt?: NativeDate | null | undefined; avatar?: string | null | undefined; password?: string | null | undefined; email?: string | null | undefined; sessionTokens?: ({ token?: string | null | undefined; valid?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; verificationTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; passwordRecoveryTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; permissions?: string[] | null | undefined; roles?: string[] | null | undefined; languages?: string[] | null | undefined; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }> & { __v: number; } & { id: string; }, i18n: { t: TFunction; language: string; }) => Promise; /** * Send verification email * @param {Object} * @param {TFunction} i18n.t * @param {string} i18n.language * @returns {Promise} */ readonly sendVerificationEmail: (this: import("mongoose").Document & { isVerified: boolean; locale: string; name?: { first?: string | null | undefined; last?: string | null | undefined; nick?: string | null | undefined; } | null | undefined; createdAt?: NativeDate | null | undefined; updatedAt?: NativeDate | null | undefined; avatar?: string | null | undefined; password?: string | null | undefined; email?: string | null | undefined; sessionTokens?: ({ token?: string | null | undefined; valid?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; verificationTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; passwordRecoveryTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; permissions?: string[] | null | undefined; roles?: string[] | null | undefined; languages?: string[] | null | undefined; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }> & { __v: number; } & { id: string; }, i18n: { t: TFunction; language: string; }) => Promise; /** * Get public user data * @returns {Object} */ readonly getPublic: (this: import("mongoose").Document & { isVerified: boolean; locale: string; name?: { first?: string | null | undefined; last?: string | null | undefined; nick?: string | null | undefined; } | null | undefined; createdAt?: NativeDate | null | undefined; updatedAt?: NativeDate | null | undefined; avatar?: string | null | undefined; password?: string | null | undefined; email?: string | null | undefined; sessionTokens?: ({ token?: string | null | undefined; valid?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; verificationTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; passwordRecoveryTokens?: ({ token?: string | null | undefined; until?: NativeDate | null | undefined; } & { _id: import("mongoose").Types.ObjectId; })[] | null | undefined; permissions?: string[] | null | undefined; roles?: string[] | null | undefined; languages?: string[] | null | undefined; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }> & { __v: number; } & { id: string; }) => { avatar: string | null | undefined; name: { first?: string | null | undefined; last?: string | null | undefined; nick?: string | null | undefined; } | null | undefined; email: string | null | undefined; id: string; isVerified: boolean; permissions: string[] | null | undefined; locale: string; }; }; } export declare const userHelpers: { /** * Generate user verification token * @param {InstanceType} userMongoose * @returns {Promise<{ token: string; until: number }>} */ generateUserVerificationToken: (userMongoose: InstanceType) => Promise<{ token: string; until: number; }>; /** * Get user by id * @param {string} * @returns {Promise | false>} */ generateUserPasswordRecoveryToken: (userMongoose: InstanceType) => Promise<{ token: string; until: number; }>; }; export default User;