@syncot/presence
Advanced tools
Comparing version 0.0.3 to 0.0.4
/// <reference types="node" /> | ||
import { EmitterInterface, Id, SyncOtEmitter, Validator } from '@syncot/util'; | ||
import { EmitterInterface, SyncOtEmitter, Validator } from '@syncot/util'; | ||
import { Duplex } from 'stream'; | ||
export interface Presence { | ||
readonly sessionId: Id; | ||
readonly userId: Id; | ||
readonly locationId: Id; | ||
readonly sessionId: string; | ||
readonly userId: string; | ||
readonly locationId: string; | ||
readonly data: any; | ||
@@ -33,14 +33,14 @@ readonly lastModified: number; | ||
export interface PresenceClient extends EmitterInterface<SyncOtEmitter<PresenceClientEvents>> { | ||
readonly sessionId: Id | undefined; | ||
readonly userId: Id | undefined; | ||
locationId: Id | undefined; | ||
readonly sessionId: string | undefined; | ||
readonly userId: string | undefined; | ||
locationId: string | undefined; | ||
data: any; | ||
readonly localPresence: Presence | undefined; | ||
readonly online: boolean; | ||
getPresenceBySessionId(sessionId: Id): Promise<Presence | null>; | ||
getPresenceByUserId(userId: Id): Promise<Presence[]>; | ||
getPresenceByLocationId(locationId: Id): Promise<Presence[]>; | ||
streamPresenceBySessionId(sessionId: Id): Promise<Duplex>; | ||
streamPresenceByUserId(userId: Id): Promise<Duplex>; | ||
streamPresenceByLocationId(locationId: Id): Promise<Duplex>; | ||
getPresenceBySessionId(sessionId: string): Promise<Presence | null>; | ||
getPresenceByUserId(userId: string): Promise<Presence[]>; | ||
getPresenceByLocationId(locationId: string): Promise<Presence[]>; | ||
streamPresenceBySessionId(sessionId: string): Promise<Duplex>; | ||
streamPresenceByUserId(userId: string): Promise<Duplex>; | ||
streamPresenceByLocationId(locationId: string): Promise<Duplex>; | ||
} | ||
@@ -64,8 +64,8 @@ /** | ||
removePresence(): Promise<void>; | ||
getPresenceBySessionId(sessionId: Id): Promise<Presence | null>; | ||
getPresenceByUserId(userId: Id): Promise<Presence[]>; | ||
getPresenceByLocationId(locationId: Id): Promise<Presence[]>; | ||
streamPresenceBySessionId(sessionId: Id): Promise<Duplex>; | ||
streamPresenceByUserId(userId: Id): Promise<Duplex>; | ||
streamPresenceByLocationId(locationId: Id): Promise<Duplex>; | ||
getPresenceBySessionId(sessionId: string): Promise<Presence | null>; | ||
getPresenceByUserId(userId: string): Promise<Presence[]>; | ||
getPresenceByLocationId(locationId: string): Promise<Presence[]>; | ||
streamPresenceBySessionId(sessionId: string): Promise<Duplex>; | ||
streamPresenceByUserId(userId: string): Promise<Duplex>; | ||
streamPresenceByLocationId(locationId: string): Promise<Duplex>; | ||
} | ||
@@ -81,3 +81,3 @@ /** | ||
*/ | ||
export declare type PresenceRemovedMessage = [false, ...Id[]]; | ||
export declare type PresenceRemovedMessage = [false, ...string[]]; | ||
/** | ||
@@ -84,0 +84,0 @@ * Presence messages emitted by the streams returned by `streamPresenceBy...` functions. |
import { createInvalidEntityError } from '@syncot/error'; | ||
import { isId, validate, } from '@syncot/util'; | ||
import { validate, } from '@syncot/util'; | ||
export const validatePresence = validate([ | ||
@@ -7,9 +7,9 @@ presence => typeof presence === 'object' && presence != null | ||
: createInvalidEntityError('Presence', presence, null), | ||
presence => isId(presence.sessionId) | ||
presence => typeof presence.sessionId === 'string' | ||
? undefined | ||
: createInvalidEntityError('Presence', presence, 'sessionId'), | ||
presence => isId(presence.userId) | ||
presence => typeof presence.userId === 'string' | ||
? undefined | ||
: createInvalidEntityError('Presence', presence, 'userId'), | ||
presence => isId(presence.locationId) | ||
presence => typeof presence.locationId === 'string' | ||
? undefined | ||
@@ -16,0 +16,0 @@ : createInvalidEntityError('Presence', presence, 'locationId'), |
{ | ||
"name": "@syncot/presence", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Interfaces and type definitions related to global presence management.", | ||
@@ -30,6 +30,6 @@ "keywords": [ | ||
"@syncot/error": "^0.0.3", | ||
"@syncot/util": "^0.0.1", | ||
"@syncot/util": "^0.0.2", | ||
"tslib": "^1.9.3" | ||
}, | ||
"gitHead": "bd4d64ce07f354f6123f71b6f6ba0796bc5b198b" | ||
"gitHead": "b952421ee19e038a054420c80e3b870f52e23ed9" | ||
} |
6266
+ Added@syncot/util@0.0.2(transitive)
- Removed@syncot/util@0.0.1(transitive)
Updated@syncot/util@^0.0.2