UNPKG

alapa

Version:

A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.

514 lines (513 loc) 16.8 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthenticatableModel = void 0; const typeorm_1 = require("typeorm"); const columns_1 = require("../../utils/columns"); const models_1 = require("../../models"); /** * Abstract model for an authenticatable user entity with various personal, security, and engagement properties. * Used to store user-related data including login details, preferences, security, and audit information. */ class AuthenticatableModel extends models_1.Model { /** * The user's first name. */ firstName; /** * The user's last name. */ lastName; /** * The user's middle name (if applicable). */ middleName; /** * The user's current status (e.g., 'active', 'inactive', 'suspended'). */ status; /** * The user's gender. */ gender; /** * The unique username for the user. */ username; /** * The unique email address of the user. */ email; /** * Indicates whether the user's email has been verified. */ emailVerified; /** * The hashed password of the user. */ password; /** * Token used for user login sessions. */ loginToken; /** * Token used for resetting the user's password. */ resetToken; /** * Expiry time for the password reset token. */ resetTokenExpiresTime; /** * The country of residence of the user. */ country; /** * The user's role (e.g., 'admin', 'user', 'moderator'). */ role; /** * The unique phone number of the user. */ phoneNumber; /** * The user's home or office address. */ address; /** * The URL to the user's profile picture. */ profilePicture; /** * The user's date of birth. */ dateOfBirth; /** * Indicates whether the user has enabled email notifications. */ isEmailNotificationsEnabled; /** * Indicates whether the user has enabled two-factor authentication. */ isTwoFactorEnabled; /** * The date and time when the user account was created. */ createdAt; /** * The date and time when the user account was last updated. */ updatedAt; /** * Timestamp for soft deletion of the user account. */ deletedAt; /** * Indicates whether the user's account is active. */ isActive; /** * The timestamp of the last login by the user. */ lastLoginAt; /** * The number of failed login attempts made by the user. */ failedLoginAttempts; /** * The timestamp indicating when the user's account will be unlocked after too many failed login attempts. */ lockoutExpiresAt; /** * The user's preferred language for the platform. */ languagePreference; /** * The timezone of the user, useful for scheduling events or activities. */ timezone; /** * The current subscription status of the user (e.g., 'free', 'premium'). */ subscriptionStatus; /** * The specific subscription plan the user is on (e.g., 'basic', 'enterprise'). */ subscriptionPlan; /** * A list of the user's social media profiles or links. */ socialMediaLinks; /** * A short description or "about" section where the user can introduce themselves or share relevant details. * This can be used to describe the user's interests, profession, or any personal information. */ aboutYourself; /** * The user's personal or business website URL. */ websiteUrl; /** * The secret used for generating one-time passwords (OTP) for two-factor authentication. */ otpSecret; /** * The timestamp of the last password change by the user. */ lastPasswordChangeAt; /** * The name of the external authentication provider, if the user authenticated via an external service (e.g., 'google', 'facebook'). */ externalAuthProvider; /** * The unique identifier from the external authentication provider. */ externalAuthId; // Additional fields for engagement and audit /** * Whether the user has opted in to receive marketing emails. */ emailOptIn; /** * Whether the user has opted in to receive SMS notifications or phone-based alerts. */ phoneOptIn; /** * Whether the user has enabled push notifications for mobile or web apps. */ pushNotificationsEnabled; /** * Flag for whether the user account is marked as deleted. */ isDeleted; /** * The referral code generated for the user, used in referral programs. */ referralCode; /** * The ID or username of the user who referred the current user. */ referredBy; /** * The timestamp of when the user accepted the terms and conditions. */ termsAcceptedAt; /** * The timestamp of when the user accepted the privacy policy. */ privacyPolicyAcceptedAt; /** * The type of user account (e.g., 'personal', 'business'). */ accountType; /** * The user's preferred method of communication (e.g., 'email', 'phone'). */ preferredContactMethod; /** * The timestamp of the most recent activity by the user on the platform. */ lastActivityAt; /** * The verification status of the user's account (e.g., 'verified', 'pending', 'rejected'). */ accountVerificationStatus; /** * Recovery codes for two-factor authentication in case the user loses their authentication method. */ twoFactorRecoveryCodes; /** * Whether the user has installed the mobile app for push notifications and other interactions. */ mobileAppInstalled; /** * The method of login used by the user (e.g., 'email', 'google', 'facebook'). */ loginMethod; /** * The timestamp of when the user last saw a notification from the platform. */ lastNotificationSeenAt; /** * The timestamp indicating when the user's account will be unlocked after it was locked (e.g., due to security issues). */ accountLockedUntil; /** * Whether the user has been verified (e.g., email verification, admin verification). */ isVerified; /** * Whether the user has given feedback or filled out a survey. */ feedbackGiven; /** * The total number of support tickets opened by the user. */ customerSupportTicketCount; /** * Whether the user has opted in for marketing or promotional messages. */ marketingOptIn; /** * Reason for blocking the user */ blockReason; /** * Indicates whether the user is a VIP customer with special privileges or benefits. */ isVIP; } exports.AuthenticatableModel = AuthenticatableModel; __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "firstName", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "lastName", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "middleName", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "status", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "gender", void 0); __decorate([ (0, columns_1.NullColumn)({ unique: true }), __metadata("design:type", String) ], AuthenticatableModel.prototype, "username", void 0); __decorate([ (0, columns_1.NullColumn)({ unique: true }), __metadata("design:type", String) ], AuthenticatableModel.prototype, "email", void 0); __decorate([ (0, columns_1.NullColumn)({ default: false }), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "emailVerified", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "password", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "loginToken", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "resetToken", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "resetTokenExpiresTime", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "country", void 0); __decorate([ (0, columns_1.NullColumn)({ default: "user" }), __metadata("design:type", String) ], AuthenticatableModel.prototype, "role", void 0); __decorate([ (0, columns_1.NullColumn)({ unique: true }), __metadata("design:type", String) ], AuthenticatableModel.prototype, "phoneNumber", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "address", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "profilePicture", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "dateOfBirth", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "isEmailNotificationsEnabled", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "isTwoFactorEnabled", void 0); __decorate([ (0, typeorm_1.CreateDateColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "createdAt", void 0); __decorate([ (0, typeorm_1.UpdateDateColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "updatedAt", void 0); __decorate([ (0, typeorm_1.DeleteDateColumn)() // Soft delete timestamp , __metadata("design:type", Date) ], AuthenticatableModel.prototype, "deletedAt", void 0); __decorate([ (0, columns_1.NullColumn)({ default: true }), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "isActive", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "lastLoginAt", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Number) ], AuthenticatableModel.prototype, "failedLoginAttempts", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "lockoutExpiresAt", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "languagePreference", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "timezone", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "subscriptionStatus", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "subscriptionPlan", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "socialMediaLinks", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "aboutYourself", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "websiteUrl", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "otpSecret", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "lastPasswordChangeAt", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "externalAuthProvider", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "externalAuthId", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "emailOptIn", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "phoneOptIn", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "pushNotificationsEnabled", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "isDeleted", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "referralCode", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "referredBy", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "termsAcceptedAt", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "privacyPolicyAcceptedAt", void 0); __decorate([ (0, columns_1.NullColumn)({ default: "personal" }), __metadata("design:type", String) ], AuthenticatableModel.prototype, "accountType", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "preferredContactMethod", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "lastActivityAt", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "accountVerificationStatus", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "twoFactorRecoveryCodes", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "mobileAppInstalled", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "loginMethod", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "lastNotificationSeenAt", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Date) ], AuthenticatableModel.prototype, "accountLockedUntil", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "isVerified", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "feedbackGiven", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Number) ], AuthenticatableModel.prototype, "customerSupportTicketCount", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "marketingOptIn", void 0); __decorate([ (0, columns_1.TextColumn)(), __metadata("design:type", String) ], AuthenticatableModel.prototype, "blockReason", void 0); __decorate([ (0, columns_1.NullColumn)(), __metadata("design:type", Boolean) ], AuthenticatableModel.prototype, "isVIP", void 0);