import { MultiLanguageString, Address, Avatar, Phone, Timestamp, } from './common'; import { Distance, Weight, Height, Temperature, } from './unit'; import { FamilyId } from './family'; import { SchoolId } from './school'; import { ClientId } from './client'; import { DateFormat, FirstDayOfWeek, TimeFormat, Timezone } from './localization'; // import { StudentId } from './student'; export type UserId = string; export type Role = "system" | "admin" | "manager" | "staff" | "teacher" | "guardian" | "student"; export type UserTypeGuardian = "father" | "mother" | "grandparent" | "other"; export type UserTypeStaff = "headTeacher" | "teacher" | "assistant" | "office" | "other"; export type UserType = UserTypeGuardian | UserTypeStaff; /** * dbRef: userData/{uid} */ export interface UserData { badges: { [id: string]: number; }; devices: { [deviceId: string]: UserDevice; }; files?: { [fileId: string]: string; }; metadata: UserMetadata; presence: UserPresence; profile: UserProfile; pushTokens?: { [deviceId: string]: UserPushToken; } settings: UserSettings; } /** * dbRef: userData/{uid}/devices/{deviceId} */ export interface UserDevice { experienceId?: string; appId: string; appVersion: string; deviceId: string; deviceName?: string; isDevice: boolean; deviceType?: string; locale?: string; manufacturer?: string; modalYear?: number; modelName?: string; browserName?: string; browserVersion?: string; osName: string; osVersion: string; timezone?: string; pushToken?: string; fcmToken?: string; ipV4?: string; status?: UserPresenceStatus; statusUpdatedAt?: Timestamp; } /** * dbRef: userData/{uid}/metadata */ export interface UserMetadata { students?: { [studentId: string]: boolean; }; createdAt: Date; cid: ClientId; fid?: FamilyId; sid: SchoolId; } export type UserPresenceStatus = 'online' | 'offline' | 'idle'; /** * dbRef: userData/{uid}/presence */ export interface UserPresence { updatedAt: Timestamp; status: UserPresenceStatus; deviceId: string, ipV4?: string, } /** * dbRef: userData/{uid}/profile */ export interface UserProfile { address?: Address; avatar?: Avatar; email: string; fName: MultiLanguageString | string; lName: MultiLanguageString | string; name: MultiLanguageString | string; phone: Phone; photoURL?: string; type: UserType; } /** * dbRef: userData/{uid}/pushTokens/{deviceId} */ export interface UserPushToken { deviceId: string; experienceId: string; pushToken: string; } /** * dbRef: userData/{uid}/settings */ export interface UserSettings { locale: string; locales: UserSettingsLocales; notifications: UserSettingsNotifications; } /** * dbRef: userData/{uid}/settings/locales */ export interface UserSettingsLocales { continent?: string; country?: string; format: { date?: DateFormat; time?: TimeFormat; fdow?: FirstDayOfWeek; }; language: string; unit: { distance?: Distance; height?: Height; weight?: Weight; temperature?: Temperature; }; theme: { color?: string; mode?: 'light' | 'dark'; }; timezone?: Timezone; } /** * dbRef: userData/{uid}/settings/notifications */ export interface UserSettingsNotifications { email?: { [key: string]: boolean; }; mobile?: { [key: string]: boolean; }; browser?: { [key: string]: boolean; } } export type { Address, Avatar, Phone }; /** * DB: userProfile/{uid} * @deprecated */ export interface UserProfileV2 { id: string; // V2 school: string | null; // V2 nameFurigana: string; // V2 nameKanji: string; // V2 nameRomaji: string; // V2 firstNameRomaji: string; // V2 firstNameFurigana: string; // V2 firstNameKanji: string; // V2 lastNameRomaji: string; // V2 lastNameFurigana: string; // V2 lastNameKanji: string; // V2 childRelationship: UserTypeGuardian | null; // V2 phoneMobileDialCode: string | null; // V2 phoneMobile?: string; phoneWork: string | null; phoneHome: string | null; phoneNumber?: | string | null | { // V3 dialCode?: string | null; mobile?: string | null; home?: string | null; office?: string | null; work?: string | null; }; email: string | undefined; avatar?: Avatar; fName?: MultiLanguageString; // V3 lName?: MultiLanguageString; // V3 name?: MultiLanguageString; // V3 sid?: SchoolId | null; // V3 // role?: Role, // V3 // type?: UserTypeGuardian | UserTypeStaff, // V3 } /** * DB: userSettings/{uid} * @deprecated */ export interface UserSettingsV2 { id?: string; // V2 cid?: string; // V2 school?: string | null; // V2 locale: string; emailNotifications: { [key: string]: boolean }; pushNotifications: { [key: string]: boolean; } } /** * DB: userMetadata/{uid} * @deprecated */ export interface UserMetadataV2 { id: string; // V2 school: string | null; // V2 family?: string | null; // V2 active: boolean; // V2 archived: boolean; // v2 claimsTokenRefreshTime: number; // V2 userType: string; // V2 locale: string; disabled: boolean; createdAt: number; badges: { [id: string]: number; }; children?: { // - GUARDIAN USER ONLY [id: string]: boolean; } | null; pushTokens?: { [deviceId: string]: string | UserMetadataPushTokenV2; }; devices: { [deviceId: string]: UserMetadataDeviceV2; // V3 }; cid: string; uid?: string; // V3 sid?: string | null; // V3 fid?: string | null; // V3 - GUARDIAN USER ONLY role?: Role; // V3 type: UserTypeGuardian | UserTypeStaff | null; // V3 classes?: { // - ADMIN, MANAGER, STAFF & STUDENT USERS ONLY [id: string]: boolean; }; } /** * DB: userMetadata/{uid}/pushTokens/{tokenId} * @deprecated */ export interface UserMetadataPushTokenV2 { createdAt: number; // V2 locale: string; // V2 token: string; // V2 } /** * DB: userMetadata/{uid}/devices/{deviceId} * @deprecated */ export interface UserMetadataDeviceV2 { appId: string; appVersion: string; deviceId: string; deviceName?: string; isDevice: boolean; locale: string; manufacturer?: string; modalYear?: number; modelName?: string; osName: string; osVersion: string; timezone: string; pushToken?: string; }