Skip to main content

Overview

The User models define data structures for user profiles, user management, and user-related operations. These models represent passenger information throughout the app.

Core User Models

User

Complete user model with all details. Used for detailed user views and the logged-in user’s profile.
id
string
required
Unique user identifier
name
string
required
User’s full name
email
string
required
User’s email address
emailVerified
boolean
required
Whether the email address has been verified
phoneNumber
string
User’s phone number
phoneNumberVerified
boolean
required
Whether the phone number has been verified
userType
UserType
required
Type of user. One of: 'passenger', 'driver', or 'admin'
profilePictureUrl
string
URL to user’s profile picture
currentLocation
Geolocation
User’s current geographic location
vehicles
string[]
required
Array of vehicle IDs associated with the user
status
UserStatus
required
User account status. One of: 'active', 'inactive', or 'banned'
preferredLanguage
string
User’s preferred language code (e.g., ‘es’, ‘en’)
termsAcceptedAt
string
ISO 8601 timestamp when user accepted terms of service
privacyPolicyAcceptedAt
string
ISO 8601 timestamp when user accepted privacy policy
createdAt
string
required
ISO 8601 timestamp of user creation
deletedAt
string
ISO 8601 timestamp of user deletion (if soft-deleted)
export interface User {
  id: string;
  name: string;
  email: string;
  emailVerified: boolean;
  phoneNumber?: string;
  phoneNumberVerified: boolean;
  userType: UserType;
  profilePictureUrl?: string;
  currentLocation?: Geolocation;
  vehicles: string[];
  status: UserStatus;
  preferredLanguage?: string;
  termsAcceptedAt?: string;
  privacyPolicyAcceptedAt?: string;
  createdAt: string;
  deletedAt?: string;
}

UserProfile

Public or basic user profile. Used for displaying user information in the app.
id
string
required
User identifier
name
string | null
required
User’s name
email
string | null
required
User’s email
phoneNumber
string | null
User’s phone number
profilePictureUrl
string | null
Profile picture URL
userType
UserType
required
User type enum value
currentLocation
GeoJSON Point | null
Current location as GeoJSON Point
createdAt
string
ISO 8601 creation timestamp
export interface UserProfile {
  id: string;
  name: string | null;
  email: string | null;
  phoneNumber?: string | null;
  profilePictureUrl?: string | null;
  userType: UserType;
  currentLocation?: {
    type: 'Point';
    coordinates: [number, number];
  } | null;
  createdAt?: string;
}

UserListItem

Lightweight user model for displaying in lists.
id
string
required
User identifier
name
string
required
User’s name
email
string
required
User’s email
profilePictureUrl
string
Profile picture URL
userType
UserType
required
User type
status
UserStatus
required
User account status
phoneNumber
string
Phone number
createdAt
string
required
ISO 8601 creation timestamp
export interface UserListItem {
  id: string;
  name: string;
  email: string;
  profilePictureUrl?: string;
  userType: UserType;
  status: UserStatus;
  phoneNumber?: string;
  createdAt: string;
}

User Payload Models

CreateUserPayload

Payload for creating a new user profile.
name
string
required
User’s full name
email
string
required
User’s email address
userType
UserType
required
User type (passenger, driver, admin)
phoneNumber
string
User’s phone number
status
UserStatus
Initial account status
profilePictureUrl
string
Profile picture URL
currentLocation
Location
User’s current location
vehicleId
string
Associated vehicle ID
preferredLanguage
string
Preferred language code
termsAcceptedAt
string
ISO 8601 timestamp of terms acceptance
privacyPolicyAcceptedAt
string
ISO 8601 timestamp of privacy policy acceptance
export interface CreateUserPayload {
  name: string;
  email: string;
  userType: UserType;
  phoneNumber?: string;
  status?: UserStatus;
  profilePictureUrl?: string;
  currentLocation?: Location;
  vehicleId?: string;
  preferredLanguage?: string;
  termsAcceptedAt?: string;
  privacyPolicyAcceptedAt?: string;
}

UpdateUserPayload

Payload for updating an existing user profile. All fields are optional.
export type UpdateUserPayload = Partial<CreateUserPayload>;

RegisterUserPayload

Complete payload for user registration, combining profile and credentials.
user
CreateUserPayload
required
User profile data
credentials
CreateAuthCredentialsPayload
required
Authentication credentials
export interface RegisterUserPayload {
  user: CreateUserPayload;
  credentials: CreateAuthCredentialsPayload;
}

ChangePasswordPayload

Payload for changing user password.
newPassword
string
required
The new passwordExample: 'MiNuevaContrasenaSegura123!'
confirmPassword
string
required
Password confirmation (must match newPassword)Example: 'MiNuevaContrasenaSegura123!'
export interface ChangePasswordPayload {
  newPassword: string;
  confirmPassword: string;
}

CreateAuthCredentialsPayload

Payload for creating user authentication credentials.
authenticationMethod
AuthMethod
required
Authentication method. One of: 'local', 'google', 'facebook', or 'apple'
userId
string
User ID to associate credentials with
password
string
User password (required for local auth)
oauthProviders
OAuthProviders
OAuth provider IDs
mfaEnabled
boolean
Whether multi-factor authentication is enabled
lastPasswordChangeAt
string
ISO 8601 timestamp of last password change
export interface CreateAuthCredentialsPayload {
  authenticationMethod: AuthMethod;
  userId?: string;
  password?: string;
  oauthProviders?: OAuthProviders;
  mfaEnabled?: boolean;
  lastPasswordChangeAt?: string;
}

UpdateAuthCredentialsPayload

Payload for updating authentication credentials. All fields optional.
export type UpdateAuthCredentialsPayload = Partial<CreateAuthCredentialsPayload>;

Enums and Types

UserType

Defines the type/role of a user in the system.
export enum UserType {
  Passenger = 'passenger',
  Driver = 'driver',
  Admin = 'admin',
}
Values:
  • Passenger - Regular passenger user
  • Driver - Driver user (not used in passenger app)
  • Admin - Administrator user

UserStatus

Defines the current status of a user account.
export enum UserStatus {
  Active = 'active',
  Inactive = 'inactive',
  Banned = 'banned',
}
Values:
  • Active - User account is active and can use the app
  • Inactive - User account is temporarily inactive
  • Banned - User has been banned from the platform

AuthMethod

Defines available authentication methods.
export enum AuthMethod {
  LOCAL = 'local',
  GOOGLE = 'google',
  FACEBOOK = 'facebook',
  APPLE = 'apple',
}
Values:
  • LOCAL - Email/password authentication
  • GOOGLE - Google OAuth
  • FACEBOOK - Facebook OAuth
  • APPLE - Apple Sign In

AppAudience

Defines the application audience/platform.
export type AppAudience = 'driver_app' | 'passenger_app' | 'admin_panel' | 'api_client';

Supporting Types

Location

Geographic coordinates.
latitude
number
required
Latitude coordinate
longitude
number
required
Longitude coordinate
export interface Location {
  latitude: number;
  longitude: number;
}

OAuthProviders

OAuth provider identifiers.
googleId
string
Google OAuth user ID
facebookId
string
Facebook OAuth user ID
appleId
string
Apple OAuth user ID
export interface OAuthProviders {
  googleId?: string;
  facebookId?: string;
  appleId?: string;
}

PassengerPingDto

Payload for sending passenger location updates.
lat
number
Latitude
lng
number
Longitude
accuracyMeters
number
Location accuracy in meters
reportedAt
string
ISO 8601 timestamp when location was captured
forceSave
boolean
Force saving this location update
export interface PassengerPingDto {
  lat?: number;
  lng?: number;
  accuracyMeters?: number;
  reportedAt?: string;
  forceSave?: boolean;
}

Usage Examples

Creating a User Profile

import { CreateUserPayload, UserType, UserStatus } from '@/app/core/models/user/user.payload';

const newUser: CreateUserPayload = {
  name: 'María García',
  email: '[email protected]',
  userType: UserType.Passenger,
  phoneNumber: '+53 5555 1234',
  status: UserStatus.Active,
  preferredLanguage: 'es',
  currentLocation: {
    latitude: 23.1136,
    longitude: -82.3666
  },
  termsAcceptedAt: new Date().toISOString(),
  privacyPolicyAcceptedAt: new Date().toISOString()
};

Registering a New User

import { RegisterUserPayload, AuthMethod } from '@/app/core/models/user/user.payload';

const registration: RegisterUserPayload = {
  user: {
    name: 'Carlos Pérez',
    email: '[email protected]',
    userType: UserType.Passenger,
    phoneNumber: '+53 5555 5678'
  },
  credentials: {
    authenticationMethod: AuthMethod.LOCAL,
    password: 'SecurePassword123!',
    mfaEnabled: false
  }
};

Updating User Profile

import { UpdateUserPayload } from '@/app/core/models/user/user.payload';

const updates: UpdateUserPayload = {
  name: 'María García López',
  profilePictureUrl: 'https://example.com/photos/maria.jpg',
  preferredLanguage: 'en'
};

Changing Password

import { ChangePasswordPayload } from '@/app/core/models/user/user.payload';

const passwordChange: ChangePasswordPayload = {
  newPassword: 'NewSecurePassword456!',
  confirmPassword: 'NewSecurePassword456!'
};

Working with User Types

import { User, UserType, UserStatus } from '@/app/core/models/user/user.response';

function isActivePassenger(user: User): boolean {
  return user.userType === UserType.Passenger && 
         user.status === UserStatus.Active;
}

function getUserDisplayName(profile: UserProfile): string {
  return profile.name || profile.email || 'Usuario';
}

Build docs developers (and LLMs) love