@jvhaile/loopback4-helper
Version:
Helper components and tools for loopback 4.
116 lines (102 loc) • 2.53 kB
text/typescript
import {Entity, model, property, belongsTo} from '@loopback/repository';
import {BaseUser} from './base.user.model';
import {BaseClient} from './base.client.model';
import {TimeStampedEntity} from "./time.stamped.model";
export interface UserAgent {
isYaBrowser: boolean;
isAuthoritative: boolean;
isMobile: boolean;
isMobileNative: boolean;
isTablet: boolean;
isiPad: boolean;
isiPod: boolean;
isiPhone: boolean;
isiPhoneNative: boolean;
isAndroid: boolean;
isAndroidNative: boolean;
isBlackberry: boolean;
isOpera: boolean;
isIE: boolean;
isEdge: boolean;
isIECompatibilityMode: boolean;
isSafari: boolean;
isFirefox: boolean;
isWebkit: boolean;
isChrome: boolean;
isKonqueror: boolean;
isOmniWeb: boolean;
isSeaMonkey: boolean;
isFlock: boolean;
isAmaya: boolean;
isPhantomJS: boolean;
isEpiphany: boolean;
isDesktop: boolean;
isWindows: boolean;
isLinux: boolean;
isLinux64: boolean;
isMac: boolean;
isChromeOS: boolean;
isBada: boolean;
isSamsung: boolean;
isRaspberry: boolean;
isBot: string | boolean;
isCurl: boolean;
isAndroidTablet: boolean;
isWinJs: boolean;
isKindleFire: boolean;
isSilk: boolean;
isCaptive: boolean;
isSmartTV: boolean;
isUC: boolean;
isFacebook: boolean;
isAlamoFire: boolean;
isElectron: boolean;
silkAccelerated: boolean;
browser: string;
version: string;
os: string;
platform: string;
geoIp: any;
source: string;
isWechat: boolean;
electronVersion: string;
ip: string,
ips: string[],
}
@model()
export class BaseSession extends TimeStampedEntity {
@property({
type: 'string',
id: true,
generated: true,
})
id?: string;
@property({
type: 'object',
})
userAgent?: UserAgent;
@property({
type: 'string',
})
fcmToken?: string;
@property({
type: 'string',
})
loginMethod?: 'email' | 'phone' | 'facebook' | 'google';
@property({
type: 'boolean',
default: true,
})
active?: boolean;
@belongsTo(() => BaseUser)
userId: string;
@belongsTo(() => BaseClient)
clientId: string;
constructor(data?: Partial<BaseSession>) {
super(data);
}
}
export interface BaseSessionRelations {
// describe navigational properties here
}
export type BaseSessionWithRelations = BaseSession & BaseSessionRelations;